@steedos/service-metadata-apps 3.0.13-beta.3 → 3.0.13-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actionsHandler.js +533 -459
- package/lib/actionsHandler.js.map +1 -1
- package/lib/apps.service.js +19 -40
- package/lib/apps.service.js.map +1 -1
- package/lib/getNotLicensedTabNames.js +25 -28
- package/lib/getNotLicensedTabNames.js.map +1 -1
- package/lib/index.js +25 -32
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/actionsHandler.ts +94 -1
- package/tsconfig.json +3 -7
package/lib/actionsHandler.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActionHandlers = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const _1 = require(".");
|
|
6
5
|
const _ = require("lodash");
|
|
7
6
|
const utils_1 = require("@steedos/utils");
|
|
@@ -11,118 +10,104 @@ const getNotLicensedTabNames_1 = require("./getNotLicensedTabNames");
|
|
|
11
10
|
function cacherKey(appApiName) {
|
|
12
11
|
return `$steedos.#${_1.METADATA_TYPE}.${appApiName}`;
|
|
13
12
|
}
|
|
14
|
-
function registerApp(ctx, appApiName, data, meta) {
|
|
15
|
-
return
|
|
16
|
-
return yield ctx.broker.call("metadata.add", { key: cacherKey(appApiName), data: data }, { meta: meta });
|
|
17
|
-
});
|
|
13
|
+
async function registerApp(ctx, appApiName, data, meta) {
|
|
14
|
+
return await ctx.broker.call("metadata.add", { key: cacherKey(appApiName), data: data }, { meta: meta });
|
|
18
15
|
}
|
|
19
|
-
function getSpaceApp(ctx, appApiName) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
!_.isEmpty(config.mobile_objects)) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
16
|
+
async function getSpaceApp(ctx, appApiName) {
|
|
17
|
+
const allApps = await getAllApps(ctx);
|
|
18
|
+
const userSession = ctx.meta.user;
|
|
19
|
+
const spaceId = userSession.spaceId;
|
|
20
|
+
const userApps = _.filter(allApps, function (metadataConfig) {
|
|
21
|
+
const config = metadataConfig.metadata;
|
|
22
|
+
if (!config.visible) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (_.has(config, "space") && config.space) {
|
|
26
|
+
return config.space === spaceId;
|
|
27
|
+
}
|
|
28
|
+
if (!_.isEmpty(config.tabs) ||
|
|
29
|
+
!_.isEmpty(config.objects) ||
|
|
30
|
+
!_.isEmpty(config.mobile_objects)) {
|
|
37
31
|
return true;
|
|
38
|
-
}
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
35
|
+
return _.find(userApps, function (metadataConfig) {
|
|
36
|
+
const config = metadataConfig.metadata;
|
|
37
|
+
return config.space && config.code === appApiName;
|
|
43
38
|
});
|
|
44
39
|
}
|
|
45
|
-
function get(ctx) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
async function get(ctx) {
|
|
41
|
+
const spaceAppMetadataConfig = await getSpaceApp(ctx, ctx.params.appApiName);
|
|
42
|
+
if (spaceAppMetadataConfig) {
|
|
43
|
+
return spaceAppMetadataConfig;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const metadataConfig = await ctx.broker.call("metadata.get", { key: cacherKey(ctx.params.appApiName) }, { meta: ctx.meta });
|
|
47
|
+
if (metadataConfig) {
|
|
48
|
+
return metadataConfig;
|
|
50
49
|
}
|
|
51
50
|
else {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return config.space === spaceId;
|
|
67
|
-
}
|
|
68
|
-
if (!_.isEmpty(config.tabs) ||
|
|
69
|
-
!_.isEmpty(config.objects) ||
|
|
70
|
-
!_.isEmpty(config.mobile_objects)) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
51
|
+
const allApps = await getAllApps(ctx);
|
|
52
|
+
const userSession = ctx.meta.user;
|
|
53
|
+
const spaceId = userSession.spaceId;
|
|
54
|
+
const userApps = _.filter(allApps, function (metadataConfig) {
|
|
55
|
+
const config = metadataConfig.metadata;
|
|
56
|
+
if (!config.visible) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (_.has(config, "space") && config.space) {
|
|
60
|
+
return config.space === spaceId;
|
|
61
|
+
}
|
|
62
|
+
if (!_.isEmpty(config.tabs) ||
|
|
63
|
+
!_.isEmpty(config.objects) ||
|
|
64
|
+
!_.isEmpty(config.mobile_objects)) {
|
|
73
65
|
return true;
|
|
74
|
-
});
|
|
75
|
-
if (ctx.params.appApiName === "-") {
|
|
76
|
-
return _.first(_.sortBy(userApps, ["metadata.sort"]));
|
|
77
66
|
}
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
return true;
|
|
68
|
+
});
|
|
69
|
+
if (ctx.params.appApiName === "-") {
|
|
70
|
+
return _.first(_.sortBy(userApps, ["metadata.sort"]));
|
|
82
71
|
}
|
|
72
|
+
return _.find(userApps, function (metadataConfig) {
|
|
73
|
+
const app = metadataConfig.metadata;
|
|
74
|
+
return app.code === ctx.params.appApiName;
|
|
75
|
+
});
|
|
83
76
|
}
|
|
84
|
-
}
|
|
77
|
+
}
|
|
85
78
|
}
|
|
86
|
-
function getAllApps(ctx) {
|
|
87
|
-
return
|
|
88
|
-
return yield ctx.broker.call("metadata.filter", { key: cacherKey("*") }, { meta: ctx.meta });
|
|
89
|
-
});
|
|
79
|
+
async function getAllApps(ctx) {
|
|
80
|
+
return await ctx.broker.call("metadata.filter", { key: cacherKey("*") }, { meta: ctx.meta });
|
|
90
81
|
}
|
|
91
|
-
function getAllTabs(ctx) {
|
|
92
|
-
return
|
|
93
|
-
return yield ctx.broker.call("tabs.getAll");
|
|
94
|
-
});
|
|
82
|
+
async function getAllTabs(ctx) {
|
|
83
|
+
return await ctx.broker.call("tabs.getAll");
|
|
95
84
|
}
|
|
96
|
-
function getContext(ctx) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (userSession.is_space_admin) {
|
|
101
|
-
return {
|
|
102
|
-
tabs: allTabs,
|
|
103
|
-
hiddenTabNames: [],
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
let hiddenTabNames = yield getHiddenTabNames(ctx, allTabs);
|
|
107
|
-
const notLicensedTabNames = yield (0, getNotLicensedTabNames_1.getNotLicensedTabNames)(ctx, allTabs);
|
|
108
|
-
hiddenTabNames = hiddenTabNames.concat(notLicensedTabNames);
|
|
85
|
+
async function getContext(ctx) {
|
|
86
|
+
const userSession = ctx.meta.user;
|
|
87
|
+
const allTabs = await getAllTabs(ctx);
|
|
88
|
+
if (userSession.is_space_admin) {
|
|
109
89
|
return {
|
|
110
90
|
tabs: allTabs,
|
|
111
|
-
hiddenTabNames:
|
|
91
|
+
hiddenTabNames: [],
|
|
112
92
|
};
|
|
113
|
-
}
|
|
93
|
+
}
|
|
94
|
+
let hiddenTabNames = await getHiddenTabNames(ctx, allTabs);
|
|
95
|
+
const notLicensedTabNames = await (0, getNotLicensedTabNames_1.getNotLicensedTabNames)(ctx, allTabs);
|
|
96
|
+
hiddenTabNames = hiddenTabNames.concat(notLicensedTabNames);
|
|
97
|
+
return {
|
|
98
|
+
tabs: allTabs,
|
|
99
|
+
hiddenTabNames: hiddenTabNames,
|
|
100
|
+
};
|
|
114
101
|
}
|
|
115
|
-
function getTab(ctx, tabApiName) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return metadataConfig === null || metadataConfig === void 0 ? void 0 : metadataConfig.metadata;
|
|
119
|
-
});
|
|
102
|
+
async function getTab(ctx, tabApiName) {
|
|
103
|
+
const metadataConfig = await ctx.broker.call("tabs.get", { tabApiName });
|
|
104
|
+
return metadataConfig?.metadata;
|
|
120
105
|
}
|
|
121
106
|
function getTabChildren(context, tabApiName) {
|
|
122
107
|
if (context) {
|
|
123
108
|
const { tabs } = context;
|
|
124
109
|
return _.filter(tabs, function (tab) {
|
|
125
|
-
return
|
|
110
|
+
return tab?.metadata.parent === tabApiName;
|
|
126
111
|
});
|
|
127
112
|
}
|
|
128
113
|
}
|
|
@@ -146,443 +131,532 @@ function checkAppMobile(app, mobile) {
|
|
|
146
131
|
}
|
|
147
132
|
return isChecked;
|
|
148
133
|
}
|
|
149
|
-
function getHiddenTabNames(ctx, allTabs) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
showTabNames.push(permissionTab.tab);
|
|
161
|
-
}
|
|
134
|
+
async function getHiddenTabNames(ctx, allTabs) {
|
|
135
|
+
const userSession = ctx.meta.user;
|
|
136
|
+
if (!userSession) {
|
|
137
|
+
throw new Error("no permission.");
|
|
138
|
+
}
|
|
139
|
+
const hiddenTabNames = [];
|
|
140
|
+
const permissionTabs = await getPermissionTabs(ctx, userSession);
|
|
141
|
+
const showTabNames = [];
|
|
142
|
+
for (const permissionTab of permissionTabs) {
|
|
143
|
+
if (permissionTab.permission === "on") {
|
|
144
|
+
showTabNames.push(permissionTab.tab);
|
|
162
145
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
146
|
+
}
|
|
147
|
+
for (const permissionTab of permissionTabs) {
|
|
148
|
+
if ((permissionTab.permission === "off" ||
|
|
149
|
+
permissionTab.permission === "hidden") &&
|
|
150
|
+
!showTabNames.includes(permissionTab.tab)) {
|
|
151
|
+
hiddenTabNames.push(permissionTab.tab);
|
|
169
152
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
153
|
+
}
|
|
154
|
+
for (const config of allTabs) {
|
|
155
|
+
if (config.metadata && config.metadata.hidden) {
|
|
156
|
+
hiddenTabNames.push(config.metadata.name);
|
|
174
157
|
}
|
|
175
|
-
|
|
176
|
-
|
|
158
|
+
}
|
|
159
|
+
return hiddenTabNames;
|
|
177
160
|
}
|
|
178
|
-
function getPermissionTabs(ctx, userSession) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
permissionTabs.push(ptConfig.metadata);
|
|
194
|
-
}
|
|
161
|
+
async function getPermissionTabs(ctx, userSession) {
|
|
162
|
+
const { roles, spaceId } = userSession;
|
|
163
|
+
const permissionTabs = [];
|
|
164
|
+
for (const role of roles) {
|
|
165
|
+
const pattern = `${role}_*`;
|
|
166
|
+
const filterResult = await ctx.broker.call("permission_tabs.filter", {
|
|
167
|
+
pattern: pattern,
|
|
168
|
+
}, {
|
|
169
|
+
user: { spaceId: spaceId },
|
|
170
|
+
});
|
|
171
|
+
for (const ptConfig of filterResult) {
|
|
172
|
+
if (ptConfig.metadata.permission_set === role &&
|
|
173
|
+
(!_.has(ptConfig.metadata, "space") ||
|
|
174
|
+
ptConfig.metadata.space === spaceId)) {
|
|
175
|
+
permissionTabs.push(ptConfig.metadata);
|
|
195
176
|
}
|
|
196
177
|
}
|
|
197
|
-
|
|
198
|
-
|
|
178
|
+
}
|
|
179
|
+
return permissionTabs;
|
|
199
180
|
}
|
|
200
|
-
function tabMenus(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
181
|
+
async function tabMenus(ctx, appPath, tabApiName, menu, mobile, userSession, context, props = {}) {
|
|
182
|
+
try {
|
|
183
|
+
const tab = await getTab(ctx, tabApiName);
|
|
184
|
+
if (props.group) {
|
|
185
|
+
props.group =
|
|
186
|
+
_.find(menu.tab_groups, { id: props.group })?.group_name || props.group;
|
|
187
|
+
}
|
|
188
|
+
if (tabApiName) {
|
|
189
|
+
props.tabApiName = tabApiName;
|
|
190
|
+
}
|
|
191
|
+
if (tab) {
|
|
192
|
+
const isMobileChecked = checkTabMobile(tab, mobile);
|
|
193
|
+
if (!isMobileChecked) {
|
|
194
|
+
return;
|
|
211
195
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
196
|
+
const tabChildren = getTabChildren(context, tabApiName);
|
|
197
|
+
if (tabChildren && tabChildren.length > 0) {
|
|
198
|
+
const tabMenu = {
|
|
199
|
+
id: tab.name,
|
|
200
|
+
icon: tab.icon,
|
|
201
|
+
name: `${tab.label}`,
|
|
202
|
+
children: [],
|
|
203
|
+
...props,
|
|
204
|
+
};
|
|
205
|
+
for (const { metadata: tabChild } of tabChildren) {
|
|
206
|
+
if (tabChild && tabChild.apiName) {
|
|
207
|
+
await tabMenus(ctx, appPath, tabChild.apiName, tabMenu, mobile, userSession, context);
|
|
208
|
+
}
|
|
216
209
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
210
|
+
menu.children.push(tabMenu);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
if (tab.type === "object") {
|
|
214
|
+
const allowRead = await objectAllowRead(tab.object, userSession);
|
|
215
|
+
if (!allowRead) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const objectConfig = await (0, objectql_1.getObject)(tab.object).getConfig();
|
|
219
|
+
if (objectConfig) {
|
|
220
|
+
const objectLabel = (0, i18n_1.translationObjectLabel)(userSession.language, objectConfig.name, objectConfig.label || objectConfig.name);
|
|
221
|
+
menu.children.push({
|
|
222
|
+
id: objectConfig.name,
|
|
223
|
+
type: tab.type,
|
|
224
|
+
icon: objectConfig.icon,
|
|
225
|
+
path: `${appPath}/${objectConfig.name}`,
|
|
226
|
+
name: `${objectLabel}`,
|
|
227
|
+
...props,
|
|
228
|
+
});
|
|
224
229
|
}
|
|
225
|
-
menu.children.push(tabMenu);
|
|
226
230
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
231
|
+
if (tab.type === "url") {
|
|
232
|
+
tab.label = (0, i18n_1.translationTabLabel)(userSession.language, tab.name, tab.label || tab.name);
|
|
233
|
+
let urlMenu = {
|
|
234
|
+
id: `${tab.name}`,
|
|
235
|
+
type: tab.type,
|
|
236
|
+
icon: tab.icon,
|
|
237
|
+
path: `${tab.url}`,
|
|
238
|
+
name: `${tab.label}`,
|
|
239
|
+
...props,
|
|
240
|
+
};
|
|
241
|
+
if (tab.is_new_window) {
|
|
242
|
+
urlMenu.target = "_blank";
|
|
238
243
|
}
|
|
239
|
-
if (tab.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (tab.is_new_window) {
|
|
243
|
-
urlMenu.target = "_blank";
|
|
244
|
-
}
|
|
245
|
-
else if (tab.is_use_iframe) {
|
|
246
|
-
urlMenu.is_use_iframe = true;
|
|
247
|
-
urlMenu.path = `${appPath}/tab_iframe/${tab.name}/?url=${encodeURIComponent(tab.url)}`;
|
|
248
|
-
}
|
|
249
|
-
menu.children.push(urlMenu);
|
|
244
|
+
else if (tab.is_use_iframe) {
|
|
245
|
+
urlMenu.is_use_iframe = true;
|
|
246
|
+
urlMenu.path = `${appPath}/tab_iframe/${tab.name}/?url=${encodeURIComponent(tab.url)}`;
|
|
250
247
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
248
|
+
menu.children.push(urlMenu);
|
|
249
|
+
}
|
|
250
|
+
if (tab.type === "page") {
|
|
251
|
+
tab.label = (0, i18n_1.translationTabLabel)(userSession.language, tab.name, tab.label || tab.name);
|
|
252
|
+
menu.children.push({
|
|
253
|
+
id: `${tab.name}`,
|
|
254
|
+
icon: tab.icon,
|
|
255
|
+
type: tab.type,
|
|
256
|
+
page: tab.page,
|
|
257
|
+
path: `${appPath}/${tab.type}/${tab.page}`,
|
|
258
|
+
name: `${tab.label}`,
|
|
259
|
+
...props,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (tab.type === "analytics_dashboard") {
|
|
263
|
+
const url = `/analytics/embed/dashboard/${tab.analytics_dashboard}?titled=false&bordered=false`;
|
|
264
|
+
tab.label = (0, i18n_1.translationTabLabel)(userSession.language, tab.name, tab.label || tab.name);
|
|
265
|
+
let urlMenu = {
|
|
266
|
+
id: `${tab.name}`,
|
|
267
|
+
type: tab.type,
|
|
268
|
+
icon: tab.icon,
|
|
269
|
+
path: `${url}`,
|
|
270
|
+
name: `${tab.label}`,
|
|
271
|
+
...props,
|
|
272
|
+
};
|
|
273
|
+
if (tab.is_new_window) {
|
|
274
|
+
urlMenu.target = "_blank";
|
|
254
275
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
let urlMenu = Object.assign({ id: `${tab.name}`, type: tab.type, icon: tab.icon, path: `${url}`, name: `${tab.label}` }, props);
|
|
259
|
-
if (tab.is_new_window) {
|
|
260
|
-
urlMenu.target = "_blank";
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
urlMenu.is_use_iframe = true;
|
|
264
|
-
urlMenu.path = `${appPath}/tab_iframe/${tab.name}/?url=${url}`;
|
|
265
|
-
}
|
|
266
|
-
menu.children.push(urlMenu);
|
|
276
|
+
else {
|
|
277
|
+
urlMenu.is_use_iframe = true;
|
|
278
|
+
urlMenu.path = `${appPath}/tab_iframe/${tab.name}/?url=${url}`;
|
|
267
279
|
}
|
|
280
|
+
menu.children.push(urlMenu);
|
|
268
281
|
}
|
|
269
282
|
}
|
|
270
283
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
ctx.broker.logger.info(error.message);
|
|
287
|
+
}
|
|
275
288
|
}
|
|
276
|
-
function objectAllowRead(objectApiName, userSession) {
|
|
277
|
-
return
|
|
278
|
-
return yield (0, objectql_1.getObject)(objectApiName).allowRead(userSession);
|
|
279
|
-
});
|
|
289
|
+
async function objectAllowRead(objectApiName, userSession) {
|
|
290
|
+
return await (0, objectql_1.getObject)(objectApiName).allowRead(userSession);
|
|
280
291
|
}
|
|
281
|
-
function transformAppToMenus(ctx, app, mobile, userSession, context) {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (app.url) {
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
appPath = (0, objectql_1.absoluteUrl)("/api/external/app/" + (app._id || app.code));
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
appPath = app.url;
|
|
302
|
-
}
|
|
292
|
+
async function transformAppToMenus(ctx, app, mobile, userSession, context) {
|
|
293
|
+
if (!app.code && !app._id) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const isAppShow = checkAppMobile(app, mobile);
|
|
297
|
+
if (!isAppShow) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (!app.code) {
|
|
301
|
+
app.code = app._id;
|
|
302
|
+
}
|
|
303
|
+
(0, i18n_1.translationApp)(userSession.language, app.code, app);
|
|
304
|
+
var appPath = `/app/${app.code}`;
|
|
305
|
+
if (app.url) {
|
|
306
|
+
if (/^http(s?):\/\//.test(app.url)) {
|
|
307
|
+
if (app.secret) {
|
|
308
|
+
appPath = (0, objectql_1.absoluteUrl)("/api/external/app/" + (app._id || app.code));
|
|
303
309
|
}
|
|
304
310
|
else {
|
|
305
311
|
appPath = app.url;
|
|
306
312
|
}
|
|
307
313
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
314
|
+
else {
|
|
315
|
+
appPath = app.url;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const menu = {
|
|
319
|
+
id: app.code,
|
|
320
|
+
path: appPath,
|
|
321
|
+
name: `${app.label || app.name}`,
|
|
322
|
+
icon: app.icon_slds,
|
|
323
|
+
color: app.color,
|
|
324
|
+
dark: app.dark,
|
|
325
|
+
showSidebar: app.showSidebar,
|
|
326
|
+
description: app.description,
|
|
327
|
+
children: [],
|
|
328
|
+
blank: app.is_new_window,
|
|
329
|
+
on_click: app.on_click,
|
|
330
|
+
isExternalUrl: !!app.url,
|
|
331
|
+
tab_groups: app.tab_groups,
|
|
332
|
+
is_hide_mobile_menu: app.is_hide_mobile_menu,
|
|
333
|
+
visible_on: app.visible_on || "${true}",
|
|
334
|
+
default_tab: app.default_tab,
|
|
335
|
+
};
|
|
336
|
+
if (app.enable_nav_schema &&
|
|
337
|
+
app.nav_schema &&
|
|
338
|
+
(!mobile || mobile === "false")) {
|
|
339
|
+
menu.nav_schema = _.isString(app.nav_schema)
|
|
340
|
+
? JSON.parse(app.nav_schema)
|
|
341
|
+
: app.nav_schema;
|
|
342
|
+
}
|
|
343
|
+
const hiddenTabNames = context.hiddenTabNames || [];
|
|
344
|
+
if (app.tab_items) {
|
|
345
|
+
if (_.isArray(app.tab_items)) {
|
|
346
|
+
for (const item of app.tab_items) {
|
|
347
|
+
try {
|
|
348
|
+
if (hiddenTabNames.includes(item.tab_name))
|
|
349
|
+
continue;
|
|
350
|
+
await tabMenus(ctx, appPath, item.tab_name, menu, mobile, userSession, context, item);
|
|
342
351
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
for (const tabApiName in app.tab_items) {
|
|
346
|
-
try {
|
|
347
|
-
if (hiddenTabNames.includes(tabApiName))
|
|
348
|
-
continue;
|
|
349
|
-
const props = app.tab_items[tabApiName];
|
|
350
|
-
yield tabMenus(ctx, appPath, tabApiName, menu, mobile, userSession, context, props);
|
|
351
|
-
}
|
|
352
|
-
catch (error) {
|
|
353
|
-
ctx.broker.logger.info(error.message);
|
|
354
|
-
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
ctx.broker.logger.info(error.message);
|
|
355
354
|
}
|
|
356
355
|
}
|
|
357
356
|
}
|
|
358
|
-
else
|
|
359
|
-
for (const tabApiName
|
|
357
|
+
else {
|
|
358
|
+
for (const tabApiName in app.tab_items) {
|
|
360
359
|
try {
|
|
361
360
|
if (hiddenTabNames.includes(tabApiName))
|
|
362
361
|
continue;
|
|
363
|
-
|
|
362
|
+
const props = app.tab_items[tabApiName];
|
|
363
|
+
await tabMenus(ctx, appPath, tabApiName, menu, mobile, userSession, context, props);
|
|
364
364
|
}
|
|
365
365
|
catch (error) {
|
|
366
366
|
ctx.broker.logger.info(error.message);
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
ctx,
|
|
378
|
-
appPath,
|
|
379
|
-
app,
|
|
380
|
-
}));
|
|
370
|
+
}
|
|
371
|
+
else if (_.isArray(app.tabs)) {
|
|
372
|
+
for (const tabApiName of app.tabs) {
|
|
373
|
+
try {
|
|
374
|
+
if (hiddenTabNames.includes(tabApiName))
|
|
375
|
+
continue;
|
|
376
|
+
await tabMenus(ctx, appPath, tabApiName, menu, mobile, userSession, context);
|
|
381
377
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (child) {
|
|
385
|
-
menu.children.push(child);
|
|
386
|
-
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
ctx.broker.logger.info(error.message);
|
|
387
380
|
}
|
|
388
381
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
ctx
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
382
|
+
}
|
|
383
|
+
const objects = mobile ? app.mobile_objects : app.objects;
|
|
384
|
+
if (_.isArray(objects)) {
|
|
385
|
+
const getChildrenPromises = [];
|
|
386
|
+
for (const objectApiName of objects) {
|
|
387
|
+
getChildrenPromises.push(getMenuChildren({
|
|
388
|
+
objectApiName,
|
|
389
|
+
userSession,
|
|
390
|
+
ctx,
|
|
391
|
+
appPath,
|
|
392
|
+
app,
|
|
393
|
+
}));
|
|
394
|
+
}
|
|
395
|
+
const children = await Promise.all(getChildrenPromises);
|
|
396
|
+
for (const child of children) {
|
|
397
|
+
if (child) {
|
|
398
|
+
menu.children.push(child);
|
|
403
399
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (menu.default_tab && _.isString(menu.default_tab)) {
|
|
403
|
+
const defaultTabStr = menu.default_tab;
|
|
404
|
+
let defaultTab = _.find(menu.children, (item) => {
|
|
405
|
+
return item.id === defaultTabStr || item.tabApiName === defaultTabStr;
|
|
406
|
+
});
|
|
407
|
+
if (!defaultTab && context && context.tabs) {
|
|
408
|
+
const tabConfig = _.find(context.tabs, (t) => t.metadata && t.metadata.name === defaultTabStr);
|
|
409
|
+
if (tabConfig && tabConfig.metadata) {
|
|
410
|
+
const tab = tabConfig.metadata;
|
|
411
|
+
if (tab.type === "object" && tab.object) {
|
|
412
|
+
defaultTab = _.find(menu.children, (item) => item.id === tab.object);
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
defaultTab = _.find(menu.children, (item) => item.id === tab.name);
|
|
416
|
+
}
|
|
417
|
+
if (!defaultTab) {
|
|
418
|
+
try {
|
|
419
|
+
if (tab.type === "object") {
|
|
420
|
+
defaultTab = {
|
|
421
|
+
id: tab.object,
|
|
422
|
+
type: tab.type,
|
|
423
|
+
icon: tab.icon,
|
|
424
|
+
path: `${appPath}/${tab.object}`,
|
|
425
|
+
name: tab.label || tab.name,
|
|
426
|
+
tabApiName: tab.name,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
else if (tab.type === "url") {
|
|
430
|
+
defaultTab = {
|
|
431
|
+
id: tab.name,
|
|
432
|
+
type: tab.type,
|
|
433
|
+
icon: tab.icon,
|
|
434
|
+
path: tab.url,
|
|
435
|
+
name: tab.label || tab.name,
|
|
436
|
+
tabApiName: tab.name,
|
|
437
|
+
};
|
|
438
|
+
if (tab.is_new_window) {
|
|
439
|
+
defaultTab.target = "_blank";
|
|
440
|
+
}
|
|
441
|
+
else if (tab.is_use_iframe) {
|
|
442
|
+
defaultTab.is_use_iframe = true;
|
|
443
|
+
defaultTab.path = `${appPath}/tab_iframe/${tab.name}/?url=${encodeURIComponent(tab.url)}`;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
else if (tab.type === "page") {
|
|
447
|
+
defaultTab = {
|
|
448
|
+
id: tab.name,
|
|
449
|
+
icon: tab.icon,
|
|
450
|
+
type: tab.type,
|
|
451
|
+
page: tab.page,
|
|
452
|
+
path: `${appPath}/${tab.type}/${tab.page}`,
|
|
453
|
+
name: tab.label || tab.name,
|
|
454
|
+
tabApiName: tab.name,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
else if (tab.type === "analytics_dashboard") {
|
|
458
|
+
const url = `/analytics/embed/dashboard/${tab.analytics_dashboard}?titled=false&bordered=false`;
|
|
459
|
+
defaultTab = {
|
|
460
|
+
id: tab.name,
|
|
461
|
+
type: tab.type,
|
|
462
|
+
icon: tab.icon,
|
|
463
|
+
path: url,
|
|
464
|
+
name: tab.label || tab.name,
|
|
465
|
+
tabApiName: tab.name,
|
|
466
|
+
};
|
|
467
|
+
if (tab.is_new_window) {
|
|
468
|
+
defaultTab.target = "_blank";
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
defaultTab.is_use_iframe = true;
|
|
472
|
+
defaultTab.path = `${appPath}/tab_iframe/${tab.name}/?url=${url}`;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
catch (e) {
|
|
477
|
+
console.error(e);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
412
480
|
}
|
|
413
481
|
}
|
|
414
|
-
|
|
415
|
-
|
|
482
|
+
if (defaultTab) {
|
|
483
|
+
menu.default_tab = defaultTab;
|
|
416
484
|
}
|
|
417
|
-
}
|
|
485
|
+
}
|
|
486
|
+
return menu;
|
|
418
487
|
}
|
|
419
|
-
function
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
if (!
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
let assigned_apps = yield (0, objectql_1.getAssignedApps)(userSession);
|
|
426
|
-
let mobile = ctx.params.mobile;
|
|
427
|
-
if (typeof mobile !== "boolean") {
|
|
428
|
-
mobile = mobile === "true" ? true : false;
|
|
429
|
-
}
|
|
430
|
-
const spaceId = userSession.spaceId;
|
|
431
|
-
const metadataApps = yield getAllApps(ctx);
|
|
432
|
-
const context = yield getContext(ctx);
|
|
433
|
-
const allApps = _.map(metadataApps, "metadata");
|
|
434
|
-
if (assigned_apps && assigned_apps.length) {
|
|
435
|
-
assigned_apps = _.filter(allApps, (item) => {
|
|
436
|
-
return assigned_apps.includes(item.code);
|
|
437
|
-
});
|
|
488
|
+
async function getMenuChildren({ objectApiName, userSession, ctx, appPath, app, }) {
|
|
489
|
+
try {
|
|
490
|
+
const objectConfig = await (0, objectql_1.getObject)(objectApiName).getConfig();
|
|
491
|
+
if (!objectConfig) {
|
|
492
|
+
ctx.broker.logger.error(`${objectApiName} is not found in the objects of app ${app.code} `);
|
|
493
|
+
return;
|
|
438
494
|
}
|
|
439
|
-
|
|
440
|
-
|
|
495
|
+
const allowRead = await objectAllowRead(objectApiName, userSession);
|
|
496
|
+
if (!allowRead) {
|
|
497
|
+
return;
|
|
441
498
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
499
|
+
if (objectConfig) {
|
|
500
|
+
const objectLabel = (0, i18n_1.translationObjectLabel)(userSession.language, objectConfig.name, objectConfig.label || objectConfig.name);
|
|
501
|
+
return {
|
|
502
|
+
id: objectConfig.name,
|
|
503
|
+
icon: objectConfig.icon,
|
|
504
|
+
path: `${appPath}/${objectConfig.name}`,
|
|
505
|
+
name: `${objectLabel}`,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
ctx.broker.logger.error(error);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
async function getAppsMenus(ctx) {
|
|
514
|
+
const userSession = ctx.meta.user;
|
|
515
|
+
if (!userSession) {
|
|
516
|
+
throw new Error("no permission.");
|
|
517
|
+
}
|
|
518
|
+
let assigned_apps = await (0, objectql_1.getAssignedApps)(userSession);
|
|
519
|
+
let mobile = ctx.params.mobile;
|
|
520
|
+
if (typeof mobile !== "boolean") {
|
|
521
|
+
mobile = mobile === "true" ? true : false;
|
|
522
|
+
}
|
|
523
|
+
const spaceId = userSession.spaceId;
|
|
524
|
+
const metadataApps = await getAllApps(ctx);
|
|
525
|
+
const context = await getContext(ctx);
|
|
526
|
+
const allApps = _.map(metadataApps, "metadata");
|
|
527
|
+
if (assigned_apps && assigned_apps.length) {
|
|
528
|
+
assigned_apps = _.filter(allApps, (item) => {
|
|
529
|
+
return assigned_apps.includes(item.code);
|
|
460
530
|
});
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
assigned_apps = allApps;
|
|
534
|
+
}
|
|
535
|
+
const _userApps = _.filter(assigned_apps, function (config) {
|
|
536
|
+
if (!config.visible) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
if (config._id === config.code) {
|
|
540
|
+
let dbApp = _.find(assigned_apps, (item) => {
|
|
541
|
+
return (item.code === config.code &&
|
|
542
|
+
item._id != item.code &&
|
|
543
|
+
item.space === spaceId);
|
|
469
544
|
});
|
|
470
|
-
if (
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
const _app = userApps[_appIndex];
|
|
475
|
-
if (!_app.space && app.space) {
|
|
476
|
-
userApps[_appIndex] = app;
|
|
477
|
-
}
|
|
545
|
+
if (dbApp) {
|
|
546
|
+
return dbApp.visible;
|
|
478
547
|
}
|
|
548
|
+
}
|
|
549
|
+
if (_.has(config, "space") && config.space) {
|
|
550
|
+
return config.space === spaceId;
|
|
551
|
+
}
|
|
552
|
+
return true;
|
|
553
|
+
});
|
|
554
|
+
const menus = [];
|
|
555
|
+
let userApps = [];
|
|
556
|
+
_.each(_.sortBy(_userApps, ["sort"]), function (app) {
|
|
557
|
+
if (!app.code) {
|
|
558
|
+
app.code = app._id;
|
|
559
|
+
}
|
|
560
|
+
const _appIndex = _.findIndex(userApps, function (item) {
|
|
561
|
+
return item.code === app.code;
|
|
479
562
|
});
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
563
|
+
if (_appIndex < 0) {
|
|
564
|
+
userApps.push(app);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
const _app = userApps[_appIndex];
|
|
568
|
+
if (!_app.space && app.space) {
|
|
569
|
+
userApps[_appIndex] = app;
|
|
484
570
|
}
|
|
485
571
|
}
|
|
486
|
-
return menus;
|
|
487
572
|
});
|
|
573
|
+
for (const app of _.sortBy(userApps, ["sort"])) {
|
|
574
|
+
const menu = await transformAppToMenus(ctx, app, mobile, userSession, context);
|
|
575
|
+
if (menu) {
|
|
576
|
+
menus.push(menu);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return menus;
|
|
488
580
|
}
|
|
489
|
-
function getAppMenus(ctx) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
const context = yield getContext(ctx);
|
|
506
|
-
const appMenus = yield transformAppToMenus(ctx, appConfig, mobile, userSession, context);
|
|
507
|
-
if (userSession.is_space_admin &&
|
|
508
|
-
appConfig._id &&
|
|
509
|
-
appConfig.code &&
|
|
510
|
-
appConfig._id != appConfig.code) {
|
|
511
|
-
appMenus.allowEditApp = true;
|
|
512
|
-
}
|
|
513
|
-
return appMenus;
|
|
581
|
+
async function getAppMenus(ctx) {
|
|
582
|
+
const userSession = ctx.meta.user;
|
|
583
|
+
const { mobile } = ctx.params;
|
|
584
|
+
if (!userSession) {
|
|
585
|
+
throw new Error("no permission.");
|
|
586
|
+
}
|
|
587
|
+
const spaceId = userSession.spaceId;
|
|
588
|
+
const metadataConf = await get(ctx);
|
|
589
|
+
if (metadataConf) {
|
|
590
|
+
const appConfig = metadataConf.metadata;
|
|
591
|
+
if (_.has(appConfig, "space") &&
|
|
592
|
+
appConfig.space &&
|
|
593
|
+
appConfig.space != spaceId) {
|
|
594
|
+
return;
|
|
514
595
|
}
|
|
515
|
-
|
|
596
|
+
const context = await getContext(ctx);
|
|
597
|
+
const appMenus = await transformAppToMenus(ctx, appConfig, mobile, userSession, context);
|
|
598
|
+
if (userSession.is_space_admin &&
|
|
599
|
+
appConfig._id &&
|
|
600
|
+
appConfig.code &&
|
|
601
|
+
appConfig._id != appConfig.code) {
|
|
602
|
+
appMenus.allowEditApp = true;
|
|
603
|
+
}
|
|
604
|
+
return appMenus;
|
|
605
|
+
}
|
|
516
606
|
}
|
|
517
607
|
exports.ActionHandlers = {
|
|
518
|
-
get(ctx) {
|
|
519
|
-
return
|
|
520
|
-
return yield ctx.broker.call("metadata.get", { key: cacherKey(ctx.params.appApiName) }, { meta: ctx.meta });
|
|
521
|
-
});
|
|
608
|
+
async get(ctx) {
|
|
609
|
+
return await ctx.broker.call("metadata.get", { key: cacherKey(ctx.params.appApiName) }, { meta: ctx.meta });
|
|
522
610
|
},
|
|
523
|
-
getAll(ctx) {
|
|
524
|
-
return
|
|
525
|
-
return yield getAllApps(ctx);
|
|
526
|
-
});
|
|
611
|
+
async getAll(ctx) {
|
|
612
|
+
return await getAllApps(ctx);
|
|
527
613
|
},
|
|
528
|
-
getMenus(ctx) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
return menus;
|
|
532
|
-
});
|
|
614
|
+
async getMenus(ctx) {
|
|
615
|
+
const menus = await getAppsMenus(ctx);
|
|
616
|
+
return menus;
|
|
533
617
|
},
|
|
534
|
-
getAppMenus(ctx) {
|
|
535
|
-
return
|
|
536
|
-
return yield getAppMenus(ctx);
|
|
537
|
-
});
|
|
618
|
+
async getAppMenus(ctx) {
|
|
619
|
+
return await getAppMenus(ctx);
|
|
538
620
|
},
|
|
539
|
-
add(ctx) {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}),
|
|
553
|
-
});
|
|
554
|
-
const appConfig = yield (0, _1.refreshApp)(ctx, metadataApiName);
|
|
555
|
-
return yield registerApp(ctx, metadataApiName, appConfig, ctx.meta);
|
|
621
|
+
async add(ctx) {
|
|
622
|
+
let config = ctx.params.data;
|
|
623
|
+
const serviceName = ctx.meta.metadataServiceName;
|
|
624
|
+
const metadataApiName = ctx.params.appApiName;
|
|
625
|
+
const metadataConfig = await (0, _1.getServiceAppConfig)(ctx, serviceName, metadataApiName);
|
|
626
|
+
if (metadataConfig && metadataConfig.metadata) {
|
|
627
|
+
config = (0, utils_1.defaultsDeep)(config, metadataConfig.metadata);
|
|
628
|
+
}
|
|
629
|
+
await ctx.broker.call("metadata.addServiceMetadata", { key: cacherKey(metadataApiName), data: config }, {
|
|
630
|
+
meta: Object.assign({}, ctx.meta, {
|
|
631
|
+
metadataType: _1.METADATA_TYPE,
|
|
632
|
+
metadataApiName: metadataApiName,
|
|
633
|
+
}),
|
|
556
634
|
});
|
|
635
|
+
const appConfig = await (0, _1.refreshApp)(ctx, metadataApiName);
|
|
636
|
+
return await registerApp(ctx, metadataApiName, appConfig, ctx.meta);
|
|
557
637
|
},
|
|
558
|
-
delete(ctx) {
|
|
559
|
-
return
|
|
560
|
-
return yield ctx.broker.call("metadata.delete", { key: cacherKey(ctx.params.appApiName) }, { meta: ctx.meta });
|
|
561
|
-
});
|
|
638
|
+
async delete(ctx) {
|
|
639
|
+
return await ctx.broker.call("metadata.delete", { key: cacherKey(ctx.params.appApiName) }, { meta: ctx.meta });
|
|
562
640
|
},
|
|
563
|
-
verify(ctx) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
return true;
|
|
567
|
-
});
|
|
641
|
+
async verify(ctx) {
|
|
642
|
+
console.log("verify");
|
|
643
|
+
return true;
|
|
568
644
|
},
|
|
569
|
-
refresh(ctx) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
yield registerApp(ctx, metadataApiName, appConfig, {});
|
|
582
|
-
}
|
|
645
|
+
async refresh(ctx) {
|
|
646
|
+
const { isClear, metadataApiNames } = ctx.params;
|
|
647
|
+
if (isClear) {
|
|
648
|
+
for (const metadataApiName of metadataApiNames) {
|
|
649
|
+
const appConfig = await (0, _1.refreshApp)(ctx, metadataApiName);
|
|
650
|
+
if (!appConfig) {
|
|
651
|
+
await ctx.broker.call("metadata.delete", {
|
|
652
|
+
key: cacherKey(metadataApiName),
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
await registerApp(ctx, metadataApiName, appConfig, {});
|
|
583
657
|
}
|
|
584
658
|
}
|
|
585
|
-
}
|
|
659
|
+
}
|
|
586
660
|
},
|
|
587
661
|
};
|
|
588
662
|
//# sourceMappingURL=actionsHandler.js.map
|