Skip to content

Commit 74a35f3

Browse files
committed
Revert "Remove not ready schemas"
This reverts commit 20c64a6.
1 parent 9964995 commit 74a35f3

File tree

14 files changed

+505
-28
lines changed

14 files changed

+505
-28
lines changed

src/server/components/public-api/constants.ts

Lines changed: 98 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const PUBLIC_API_URL = '/rpc/:version/:action';
99
export const PUBLIC_API_ROUTE = `${PUBLIC_API_HTTP_METHOD} ${PUBLIC_API_URL}`;
1010

1111
enum ApiTag {
12+
Navigation = 'Navigation',
1213
Connection = 'Connection',
1314
Dataset = 'Dataset',
1415
Wizard = 'Wizard',
@@ -18,16 +19,44 @@ enum ApiTag {
1819

1920
export const PUBLIC_API_PROXY_MAP = {
2021
v0: {
21-
// Connection
22+
// navigation
23+
// getNavigationList: {
24+
// resolve: (api) => api.mix.getNavigationList,
25+
// openApi: {
26+
// summary: 'Get navigation list',
27+
// tags: [ApiTag.Navigation],
28+
// },
29+
// },
30+
// connection
31+
// getConnection: {
32+
// resolve: (api) => api.bi.getConnection,
33+
// openApi: {
34+
// summary: 'Get connection',
35+
// tags: [ApiTag.Connection],
36+
// },
37+
// },
38+
// updateConnection: {
39+
// resolve: (api) => api.bi.updateConnection,
40+
// openApi: {
41+
// summary: 'Update connection',
42+
// tags: [ApiTag.Connection],
43+
// },
44+
// },
45+
// createConnection: {
46+
// resolve: (api) => api.bi.createConnection,
47+
// openApi: {
48+
// summary: 'Create connection',
49+
// tags: [ApiTag.Connection],
50+
// },
51+
// },
2252
deleteConnection: {
2353
resolve: (api) => api.bi.deleteConnection,
2454
openApi: {
2555
summary: 'Delete connection',
2656
tags: [ApiTag.Connection],
2757
},
2858
},
29-
30-
// Dataset
59+
// dataset
3160
getDataset: {
3261
resolve: (api) => api.bi.getDatasetByVersion,
3362
openApi: {
@@ -56,26 +85,86 @@ export const PUBLIC_API_PROXY_MAP = {
5685
tags: [ApiTag.Dataset],
5786
},
5887
},
59-
60-
// Wizard
88+
// wizard
89+
getWizardChart: {
90+
resolve: (api) => api.mix.__getWizardChart__,
91+
openApi: {
92+
summary: 'Get wizard chart',
93+
tags: [ApiTag.Wizard],
94+
},
95+
},
96+
updateWizardChart: {
97+
resolve: (api) => api.mix.__updateWizardChart__,
98+
openApi: {
99+
summary: 'Update wizard chart',
100+
tags: [ApiTag.Wizard],
101+
},
102+
},
103+
createWizardChart: {
104+
resolve: (api) => api.mix.__createWizardChart__,
105+
openApi: {
106+
summary: 'Create wizard chart',
107+
tags: [ApiTag.Wizard],
108+
},
109+
},
61110
deleteWizardChart: {
62111
resolve: (api) => api.mix.__deleteWizardChart__,
63112
openApi: {
64113
summary: 'Delete wizard chart',
65114
tags: [ApiTag.Wizard],
66115
},
67116
},
68-
69-
// Editor
117+
// editor
118+
getEditorChart: {
119+
resolve: (api) => api.mix.__getEditorChart__,
120+
openApi: {
121+
summary: 'Get editor chart',
122+
tags: [ApiTag.Editor],
123+
},
124+
},
125+
// updateEditorChart: {
126+
// resolve: (api) => api.mix.updateEditorChart,
127+
// openApi: {
128+
// summary: 'Update editor chart',
129+
// tags: [ApiTag.Editor],
130+
// },
131+
// },
132+
// createEditorChart: {
133+
// resolve: (api) => api.mix.createEditorChart,
134+
// openApi: {
135+
// summary: 'Create editor chart',
136+
// tags: [ApiTag.Editor],
137+
// },
138+
// },
70139
deleteEditorChart: {
71140
resolve: (api) => api.mix.__deleteEditorChart__,
72141
openApi: {
73142
summary: 'Delete editor chart',
74143
tags: [ApiTag.Editor],
75144
},
76145
},
77-
78-
// Dashboard
146+
// Dash
147+
getDashboard: {
148+
resolve: (api) => api.mix.__getDashboard__,
149+
openApi: {
150+
summary: 'Get dashboard',
151+
tags: [ApiTag.Dashboard],
152+
},
153+
},
154+
updateDashboard: {
155+
resolve: (api) => api.mix.__updateDashboard__,
156+
openApi: {
157+
summary: 'Delete dashboard',
158+
tags: [ApiTag.Dashboard],
159+
},
160+
},
161+
createDashboard: {
162+
resolve: (api) => api.mix.__createDashboard__,
163+
openApi: {
164+
summary: 'Create dashboard',
165+
tags: [ApiTag.Dashboard],
166+
},
167+
},
79168
deleteDashboard: {
80169
resolve: (api) => api.mix.__deleteDashboard__,
81170
openApi: {

src/shared/schema/bi/schemas/datasets.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import z from 'zod/v4';
22

3-
import {datasetBodySchema, datasetOptionsSchema, datasetSchema} from '../../../zod-schemas/dataset';
3+
import {
4+
datasetBodySchema,
5+
datasetOptionsSchema,
6+
datasetSchema,
7+
} from '../../../sdk/zod-schemas/dataset-api.schema';
48

59
const createDatasetDefaultArgsSchema = z.object({
610
name: z.string(),

src/shared/schema/mix/actions/dash.ts

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import _, {pick} from 'lodash';
12
import type {DeepNonNullable} from 'utility-types';
23

4+
import Dash from '../../../../server/components/sdk/dash';
5+
import {DASH_ENTRY_RELEVANT_FIELDS} from '../../../../server/constants';
36
import type {ChartsStats} from '../../../types/charts';
7+
import {EntryScope} from '../../../types/common';
48
import {createAction, createTypedAction} from '../../gateway-utils';
59
import {getTypedApi} from '../../simple-schema';
610
import {getEntryVisualizationType} from '../helpers';
@@ -11,19 +15,63 @@ import {
1115
prepareDatasetData,
1216
prepareWidgetDatasetData,
1317
} from '../helpers/dash';
14-
import {deleteDashArgsSchema, deleteDashResultSchema} from '../schemas/dash';
18+
import {
19+
createDashArgsSchema,
20+
createDashResultSchema,
21+
deleteDashArgsSchema,
22+
deleteDashResultSchema,
23+
getDashArgsSchema,
24+
getDashResultSchema,
25+
updateDashArgsSchema,
26+
updateDashResultSchema,
27+
} from '../schemas/dash';
1528
import type {
1629
CollectChartkitStatsArgs,
1730
CollectChartkitStatsResponse,
1831
CollectDashStatsArgs,
1932
CollectDashStatsResponse,
33+
CreateDashResponse,
2034
GetEntriesDatasetsFieldsArgs,
2135
GetEntriesDatasetsFieldsResponse,
2236
GetWidgetsDatasetsFieldsArgs,
2337
GetWidgetsDatasetsFieldsResponse,
38+
UpdateDashResponse,
2439
} from '../types';
2540

2641
export const dashActions = {
42+
// WIP
43+
__getDashboard__: createTypedAction(
44+
{
45+
paramsSchema: getDashArgsSchema,
46+
resultSchema: getDashResultSchema,
47+
},
48+
async (_, args, {headers, ctx}) => {
49+
const {dashboardId, includePermissions, includeLinks, branch, revId} = args;
50+
51+
if (!dashboardId || dashboardId === 'null') {
52+
throw new Error(`Not found ${dashboardId} id`);
53+
}
54+
55+
const result = await Dash.read(
56+
dashboardId,
57+
{
58+
includePermissions: includePermissions ? includePermissions?.toString() : '0',
59+
includeLinks: includeLinks ? includeLinks?.toString() : '0',
60+
...(branch ? {branch} : {branch: 'published'}),
61+
...(revId ? {revId} : {}),
62+
},
63+
headers,
64+
ctx,
65+
{forceMigrate: true},
66+
);
67+
68+
if (result.scope !== EntryScope.Dash) {
69+
throw new Error('No entry found');
70+
}
71+
72+
return pick(result, DASH_ENTRY_RELEVANT_FIELDS) as any;
73+
},
74+
),
2775
// WIP
2876
__deleteDashboard__: createTypedAction(
2977
{
@@ -41,6 +89,39 @@ export const dashActions = {
4189
return {};
4290
},
4391
),
92+
// WIP
93+
__updateDashboard__: createTypedAction(
94+
{
95+
paramsSchema: updateDashArgsSchema,
96+
resultSchema: updateDashResultSchema,
97+
},
98+
async (_, args, {headers, ctx}) => {
99+
const {entryId} = args;
100+
101+
const I18n = ctx.get('i18n');
102+
103+
return (await Dash.update(entryId as any, args as any, headers, ctx, I18n, {
104+
forceMigrate: true,
105+
})) as unknown as UpdateDashResponse;
106+
},
107+
),
108+
// WIP
109+
__createDashboard__: createTypedAction(
110+
{
111+
paramsSchema: createDashArgsSchema,
112+
resultSchema: createDashResultSchema,
113+
},
114+
async (_, args, {headers, ctx}) => {
115+
const I18n = ctx.get('i18n');
116+
117+
return (await Dash.create(
118+
args as any,
119+
headers,
120+
ctx,
121+
I18n,
122+
)) as unknown as CreateDashResponse;
123+
},
124+
),
44125

45126
collectDashStats: createAction<CollectDashStatsResponse, CollectDashStatsArgs>(
46127
async (_, args, {ctx}) => {

src/shared/schema/mix/actions/editor.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,35 @@ import type {
99
} from '../../us/types';
1010
import {getEntryLinks} from '../helpers';
1111
import {validateData} from '../helpers/editor/validation';
12-
import {deleteEditorChartArgsSchema, deleteEditorChartResultSchema} from '../schemas/editor';
12+
import {
13+
deleteEditorChartArgsSchema,
14+
deleteEditorChartResultSchema,
15+
getEditorChartArgsSchema,
16+
getEditorChartResultSchema,
17+
} from '../schemas/editor';
18+
import type {GetEditorChartResponse} from '../types';
1319

1420
export const editorActions = {
21+
// WIP
22+
__getEditorChart__: createTypedAction(
23+
{
24+
paramsSchema: getEditorChartArgsSchema,
25+
resultSchema: getEditorChartResultSchema,
26+
},
27+
async (api, args) => {
28+
const {includePermissions, includeLinks, revId, chardId, branch, workbookId} = args;
29+
const typedApi = getTypedApi(api);
30+
31+
return typedApi.us.getEntry({
32+
entryId: chardId,
33+
includePermissionsInfo: includePermissions ? Boolean(includePermissions) : false,
34+
includeLinks: includeLinks ? Boolean(includeLinks) : false,
35+
...(revId ? {revId} : {}),
36+
workbookId: workbookId || null,
37+
branch: branch || 'published',
38+
}) as unknown as GetEditorChartResponse;
39+
},
40+
),
1541
createEditorChart: createAction<CreateEditorChartResponse, CreateEditorChartArgs>(
1642
async (api, args, {ctx}) => {
1743
const {checkRequestForDeveloperModeAccess} = ctx.get('gateway');

src/shared/schema/mix/actions/wizard.ts

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,82 @@
1+
import {USProvider} from '../../../../server/components/charts-engine/components/storage/united-storage/provider';
2+
import {EntryScope} from '../../../types';
13
import {createTypedAction} from '../../gateway-utils';
24
import {getTypedApi} from '../../simple-schema';
3-
import {deleteWizardChartArgsSchema, deleteWizardChartResultSchema} from '../schemas/wizard';
5+
import {
6+
createWizardChartArgsSchema,
7+
createWizardChartResultSchema,
8+
deleteWizardChartArgsSchema,
9+
deleteWizardChartResultSchema,
10+
getWizardChartArgsSchema,
11+
getWizardChartResultSchema,
12+
updateWizardChartArgsSchema,
13+
updateWizardChartResultSchema,
14+
} from '../schemas/wizard';
415

516
export const wizardActions = {
17+
// WIP
18+
__getWizardChart__: createTypedAction(
19+
{
20+
paramsSchema: getWizardChartArgsSchema,
21+
resultSchema: getWizardChartResultSchema,
22+
},
23+
async (_, args, {ctx, headers}) => {
24+
const {includePermissions, includeLinks, unreleased, revId, chardId} = args;
25+
26+
const result = await USProvider.retrieveParsedWizardChart(ctx, {
27+
id: chardId,
28+
includePermissionsInfo: includePermissions ? includePermissions?.toString() : '0',
29+
includeLinks: includeLinks ? includeLinks?.toString() : '0',
30+
...(revId ? {revId} : {}),
31+
...(unreleased ? {unreleased} : {unreleased: false}),
32+
headers,
33+
});
34+
35+
return result as any;
36+
},
37+
),
38+
// WIP
39+
__createWizardChart__: createTypedAction(
40+
{
41+
paramsSchema: createWizardChartArgsSchema,
42+
resultSchema: createWizardChartResultSchema,
43+
},
44+
async (_, args, {ctx, headers}) => {
45+
const {data, type, key, workbookId, name} = args;
46+
47+
const result = await USProvider.create(ctx, {
48+
type,
49+
data,
50+
key,
51+
name,
52+
scope: EntryScope.Widget,
53+
...(workbookId ? {workbookId} : {workbookId: null}),
54+
headers,
55+
});
56+
57+
return result as any;
58+
},
59+
),
60+
// WIP
61+
__updateWizardChart__: createTypedAction(
62+
{
63+
paramsSchema: updateWizardChartArgsSchema,
64+
resultSchema: updateWizardChartResultSchema,
65+
},
66+
async (_, args, {ctx, headers}) => {
67+
const {entryId, revId, data, type} = args;
68+
69+
const result = await USProvider.update(ctx, {
70+
entryId,
71+
...(revId ? {revId} : {}),
72+
...(type ? {type} : {}),
73+
data,
74+
headers,
75+
});
76+
77+
return result as any;
78+
},
79+
),
680
// WIP
781
__deleteWizardChart__: createTypedAction(
882
{

0 commit comments

Comments
 (0)