@blocklet/meta 1.16.16-beta-e038cde7 → 1.16.16-beta-740ea329
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/schema.js +1 -1
- package/lib/util.d.ts +14 -9
- package/lib/util.js +37 -29
- package/package.json +5 -5
package/lib/schema.js
CHANGED
|
@@ -162,7 +162,7 @@ const environmentSchema = Joi.object({
|
|
|
162
162
|
required: Joi.boolean().default(false),
|
|
163
163
|
secure: Joi.boolean().default(false),
|
|
164
164
|
validation: Joi.string().optional(),
|
|
165
|
-
shared: Joi.boolean().default((parent) =>
|
|
165
|
+
shared: Joi.boolean().default((parent) => (parent.secure ? false : undefined)),
|
|
166
166
|
})
|
|
167
167
|
.custom((x, helper) => {
|
|
168
168
|
if (x.secure && x.default) {
|
package/lib/util.d.ts
CHANGED
|
@@ -84,11 +84,15 @@ declare const findComponentById: (blocklet: TComponent, componentId: string | Ar
|
|
|
84
84
|
declare const findComponentV2: (app: TApp, isEqualFn: (component: TComponent, app: TApp) => boolean) => ComponentState;
|
|
85
85
|
declare const findComponentByIdV2: (app: TApp, componentId: string | Array<string>) => ComponentState;
|
|
86
86
|
declare const filterComponentsV2: (app: TApp, isEqualFn: (component: TComponent, app: TApp) => boolean) => any[];
|
|
87
|
-
declare const
|
|
88
|
-
|
|
87
|
+
declare const isEnvShareableToClient: (env?: TConfig) => boolean;
|
|
88
|
+
/**
|
|
89
|
+
* is env shareable between components
|
|
90
|
+
*/
|
|
91
|
+
declare const isEnvShareable: (env?: Partial<TConfig>) => boolean;
|
|
92
|
+
declare const getSharedConfigObj: (app?: BlockletState, component?: BlockletState) => any;
|
|
89
93
|
declare const isPreferenceKey: (x: Partial<TConfig>) => Boolean;
|
|
90
|
-
declare const getAppMissingConfigs: (
|
|
91
|
-
declare const getComponentMissingConfigs: (component?: any,
|
|
94
|
+
declare const getAppMissingConfigs: (app?: any) => any[];
|
|
95
|
+
declare const getComponentMissingConfigs: (component?: any, app?: any) => any[];
|
|
92
96
|
declare const isFreeBlocklet: (meta: TBlockletMeta) => boolean;
|
|
93
97
|
declare const isFreeComponent: (meta: TBlockletMeta) => boolean;
|
|
94
98
|
declare const isComponentBlocklet: (meta?: TBlockletMeta) => boolean;
|
|
@@ -143,7 +147,7 @@ declare const isInProgress: (status: string | number) => boolean;
|
|
|
143
147
|
declare const isBeforeInstalled: (status: string | number) => boolean;
|
|
144
148
|
declare const isRunning: (status: string | number) => boolean;
|
|
145
149
|
declare const hasStartEngine: (meta: TBlockletMeta) => boolean;
|
|
146
|
-
export { isFreeBlocklet, isFreeComponent, isComponentBlocklet, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findServiceFromMeta, getWhoCanAccess, getComponentWhoCanAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getRolesFromAuthConfig, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, isGatewayBlocklet, hasStartEngine, };
|
|
150
|
+
export { isFreeBlocklet, isFreeComponent, isComponentBlocklet, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareableToClient, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findServiceFromMeta, getWhoCanAccess, getComponentWhoCanAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getRolesFromAuthConfig, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, isGatewayBlocklet, hasStartEngine, };
|
|
147
151
|
declare const _default: {
|
|
148
152
|
isFreeBlocklet: (meta: TBlockletMeta) => boolean;
|
|
149
153
|
isFreeComponent: (meta: TBlockletMeta) => boolean;
|
|
@@ -170,10 +174,11 @@ declare const _default: {
|
|
|
170
174
|
}) => Promise<unknown>;
|
|
171
175
|
forEachComponentV2Sync: (blocklet: any, cb: Function) => Promise<unknown>;
|
|
172
176
|
isDeletableBlocklet: (blocklet?: BlockletState) => boolean;
|
|
173
|
-
getSharedConfigObj: (
|
|
174
|
-
getAppMissingConfigs: (
|
|
175
|
-
getComponentMissingConfigs: (component?: any,
|
|
176
|
-
|
|
177
|
+
getSharedConfigObj: (app?: BlockletState, component?: BlockletState) => any;
|
|
178
|
+
getAppMissingConfigs: (app?: any) => any[];
|
|
179
|
+
getComponentMissingConfigs: (component?: any, app?: any) => any[];
|
|
180
|
+
isEnvShareableToClient: (env?: TConfig) => boolean;
|
|
181
|
+
isEnvShareable: (env?: Partial<TConfig>) => boolean;
|
|
177
182
|
wipeSensitiveData: (blocklet?: BlockletState) => BlockletState;
|
|
178
183
|
hasRunnableComponent: (blocklet: BlockletState) => boolean;
|
|
179
184
|
getAppName: (blocklet: BlockletState, onlyUseMeta?: boolean) => string;
|
package/lib/util.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.hasStartEngine = exports.isGatewayBlocklet = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getBlockletChainInfo = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.filterComponentsV2 = exports.findComponentByIdV2 = exports.findComponentV2 = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getComponentWhoCanAccess = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachComponentV2Sync = exports.forEachComponentV2 = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
|
|
6
|
+
exports.hasStartEngine = exports.isGatewayBlocklet = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getBlockletChainInfo = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.filterComponentsV2 = exports.findComponentByIdV2 = exports.findComponentV2 = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getComponentWhoCanAccess = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.isEnvShareableToClient = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachComponentV2Sync = exports.forEachComponentV2 = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
|
|
7
7
|
/* eslint-disable no-await-in-loop */
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
9
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
@@ -259,40 +259,47 @@ const filterComponentsV2 = (app, isEqualFn) => {
|
|
|
259
259
|
return list;
|
|
260
260
|
};
|
|
261
261
|
exports.filterComponentsV2 = filterComponentsV2;
|
|
262
|
-
const
|
|
262
|
+
const isEnvShareableToClient = (env) => {
|
|
263
263
|
return (!!env &&
|
|
264
264
|
!!(env.key || env.name) &&
|
|
265
265
|
!env.secure &&
|
|
266
266
|
env.shared !== false &&
|
|
267
267
|
!constant_2.BLOCKLET_CONFIGURABLE_KEY[env.key || env.name]);
|
|
268
268
|
};
|
|
269
|
+
exports.isEnvShareableToClient = isEnvShareableToClient;
|
|
270
|
+
/**
|
|
271
|
+
* is env shareable between components
|
|
272
|
+
*/
|
|
273
|
+
const isEnvShareable = (env) => {
|
|
274
|
+
return (!!env && !!(env.key || env.name) && !env.secure && !!env.shared && !constant_2.BLOCKLET_CONFIGURABLE_KEY[env.key || env.name]);
|
|
275
|
+
};
|
|
269
276
|
exports.isEnvShareable = isEnvShareable;
|
|
270
|
-
const getSharedConfigObj = (
|
|
277
|
+
const getSharedConfigObj = (app, component) => {
|
|
271
278
|
const res = {};
|
|
272
|
-
if (!
|
|
279
|
+
if (!app || !component) {
|
|
273
280
|
return res;
|
|
274
281
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
282
|
+
if (Array.isArray(app.configs)) {
|
|
283
|
+
app.configs.forEach(({ key, value, secure }) => {
|
|
284
|
+
if (!isEnvShareable({
|
|
285
|
+
key,
|
|
286
|
+
secure,
|
|
287
|
+
// config in container is force shared to components
|
|
288
|
+
shared: true,
|
|
289
|
+
})) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const config = (component.configs || []).find((x) => x.key === key);
|
|
293
|
+
if (!config || // component does not have this config
|
|
294
|
+
isEnvShareable(config) || // component config is shareable
|
|
295
|
+
!config.value // component config is empty
|
|
296
|
+
) {
|
|
297
|
+
res[key] = value;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
292
300
|
}
|
|
293
301
|
// share blocklet app chain config
|
|
294
|
-
|
|
295
|
-
(ancestor.configs || []).forEach(({ key, value }) => {
|
|
302
|
+
(app.configs || []).forEach(({ key, value }) => {
|
|
296
303
|
if (![
|
|
297
304
|
constant_2.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_HOST,
|
|
298
305
|
constant_2.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_ID,
|
|
@@ -321,14 +328,14 @@ const isConfigMissing = (item, sharedConfigObj) => {
|
|
|
321
328
|
}
|
|
322
329
|
return false;
|
|
323
330
|
};
|
|
324
|
-
const getAppMissingConfigs = (
|
|
331
|
+
const getAppMissingConfigs = (app = {}) => {
|
|
325
332
|
const missingConfigs = [];
|
|
326
|
-
|
|
327
|
-
if (
|
|
333
|
+
forEachComponentV2Sync(app, (b) => {
|
|
334
|
+
if (b.meta?.group === constant_2.BlockletGroup.gateway) {
|
|
328
335
|
return;
|
|
329
336
|
}
|
|
330
337
|
const configs = b.configs || [];
|
|
331
|
-
const sharedConfigObj = getSharedConfigObj(
|
|
338
|
+
const sharedConfigObj = getSharedConfigObj(app, b);
|
|
332
339
|
configs.forEach((item) => {
|
|
333
340
|
if (isConfigMissing(item, sharedConfigObj)) {
|
|
334
341
|
missingConfigs.push({ did: b.meta.did, key: item.key, description: item.description });
|
|
@@ -338,10 +345,10 @@ const getAppMissingConfigs = (blocklet = {}) => {
|
|
|
338
345
|
return missingConfigs.filter((x) => !isPreferenceKey(x));
|
|
339
346
|
};
|
|
340
347
|
exports.getAppMissingConfigs = getAppMissingConfigs;
|
|
341
|
-
const getComponentMissingConfigs = (component = {},
|
|
348
|
+
const getComponentMissingConfigs = (component = {}, app = {}) => {
|
|
342
349
|
const missingConfigs = [];
|
|
343
350
|
const configs = component.configs || [];
|
|
344
|
-
const sharedConfigObj = getSharedConfigObj(
|
|
351
|
+
const sharedConfigObj = getSharedConfigObj(app, component);
|
|
345
352
|
configs.forEach((item) => {
|
|
346
353
|
if (isConfigMissing(item, sharedConfigObj)) {
|
|
347
354
|
missingConfigs.push({ did: component.meta.did, key: item.key, description: item.description });
|
|
@@ -689,6 +696,7 @@ exports.default = {
|
|
|
689
696
|
getSharedConfigObj,
|
|
690
697
|
getAppMissingConfigs,
|
|
691
698
|
getComponentMissingConfigs,
|
|
699
|
+
isEnvShareableToClient,
|
|
692
700
|
isEnvShareable,
|
|
693
701
|
wipeSensitiveData,
|
|
694
702
|
hasRunnableComponent,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.16-beta-
|
|
6
|
+
"version": "1.16.16-beta-740ea329",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@abtnode/constant": "1.16.16-beta-
|
|
28
|
-
"@abtnode/util": "1.16.16-beta-
|
|
27
|
+
"@abtnode/constant": "1.16.16-beta-740ea329",
|
|
28
|
+
"@abtnode/util": "1.16.16-beta-740ea329",
|
|
29
29
|
"@arcblock/did": "1.18.89",
|
|
30
30
|
"@arcblock/did-ext": "1.18.89",
|
|
31
31
|
"@arcblock/did-util": "1.18.89",
|
|
32
32
|
"@arcblock/jwt": "1.18.89",
|
|
33
|
-
"@blocklet/constant": "1.16.16-beta-
|
|
33
|
+
"@blocklet/constant": "1.16.16-beta-740ea329",
|
|
34
34
|
"@ocap/asset": "1.18.89",
|
|
35
35
|
"@ocap/mcrypto": "1.18.89",
|
|
36
36
|
"@ocap/types": "1.18.89",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"ts-node": "^10.9.1",
|
|
79
79
|
"typescript": "^5.0.4"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "6abb5a7319ad1093f1e2d04d76215d4a127b538d"
|
|
82
82
|
}
|