@blocklet/meta 1.16.17-beta-09df289d → 1.16.17-beta-4f13d99d
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/has-start-engine.d.ts +4 -0
- package/lib/has-start-engine.js +4 -0
- package/lib/parse-navigation-from-blocklet.d.ts +1 -1
- package/lib/parse-navigation-from-blocklet.js +11 -21
- package/lib/schema.js +5 -7
- package/lib/url-path-friendly.d.ts +2 -1
- package/lib/url-path-friendly.js +22 -1
- package/lib/util.d.ts +2 -2
- package/lib/util.js +3 -3
- package/package.json +13 -13
|
@@ -14,27 +14,13 @@ const url_join_1 = __importDefault(require("url-join"));
|
|
|
14
14
|
const path_1 = __importDefault(require("path"));
|
|
15
15
|
const is_absolute_url_1 = __importDefault(require("is-absolute-url"));
|
|
16
16
|
const lodash_1 = require("lodash");
|
|
17
|
+
const has_start_engine_1 = __importDefault(require("./has-start-engine"));
|
|
18
|
+
const url_path_friendly_1 = require("./url-path-friendly");
|
|
19
|
+
Object.defineProperty(exports, "checkLink", { enumerable: true, get: function () { return url_path_friendly_1.checkLink; } });
|
|
17
20
|
const DEFAULT_SECTION = 'header';
|
|
18
21
|
const BASE_PATH = '/';
|
|
19
22
|
const DEFAULT_LINK = '/';
|
|
20
23
|
const ID_SEPARATE = '/';
|
|
21
|
-
/**
|
|
22
|
-
* 判断一个 url 是否为合法的 url 拼接路径
|
|
23
|
-
* /abc, /abc/bcd valid
|
|
24
|
-
* /abc, /abc//bcd invalid
|
|
25
|
-
* @param value 需要检查的 url path
|
|
26
|
-
* @returns boolean
|
|
27
|
-
*/
|
|
28
|
-
const checkUrlPath = (value) => {
|
|
29
|
-
return /^\/(?:[^/]+\/)*$/.test(value) || /^\/(?:[^/]+\/)*[^/]+$/.test(value);
|
|
30
|
-
};
|
|
31
|
-
const checkLink = (value) => {
|
|
32
|
-
if ((0, is_absolute_url_1.default)(value) || checkUrlPath(value)) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
exports.checkLink = checkLink;
|
|
38
24
|
function deepWalk(tree, cb = () => { }, { key = 'children', order = 'first' } = {}) {
|
|
39
25
|
function walk(current, { index = 0, parent = null, level = 0 } = {}) {
|
|
40
26
|
if (Array.isArray(current)) {
|
|
@@ -114,20 +100,20 @@ function smartJoinLink(_parentLink, _childLink, { strict = true, } = {}) {
|
|
|
114
100
|
parentLink = parentLink || '/';
|
|
115
101
|
childLink = childLink || '/';
|
|
116
102
|
}
|
|
117
|
-
if ((0, lodash_1.isObject)(parentLink) && (0, lodash_1.isString)(childLink) && checkLink(childLink)) {
|
|
103
|
+
if ((0, lodash_1.isObject)(parentLink) && (0, lodash_1.isString)(childLink) && (0, url_path_friendly_1.checkLink)(childLink)) {
|
|
118
104
|
return Object.keys(parentLink).reduce((res, key) => {
|
|
119
105
|
res[key] = optionalJoin(parentLink[key], childLink);
|
|
120
106
|
return res;
|
|
121
107
|
}, {});
|
|
122
108
|
}
|
|
123
|
-
if ((0, lodash_1.isString)(parentLink) && checkLink(parentLink) && (0, lodash_1.isObject)(childLink)) {
|
|
109
|
+
if ((0, lodash_1.isString)(parentLink) && (0, url_path_friendly_1.checkLink)(parentLink) && (0, lodash_1.isObject)(childLink)) {
|
|
124
110
|
return Object.keys(childLink).reduce((res, key) => {
|
|
125
111
|
res[key] = optionalJoin(parentLink, childLink[key]);
|
|
126
112
|
return res;
|
|
127
113
|
}, {});
|
|
128
114
|
}
|
|
129
115
|
if ((0, lodash_1.isString)(parentLink) && (0, lodash_1.isString)(childLink)) {
|
|
130
|
-
if (checkLink(parentLink) || checkLink(childLink)) {
|
|
116
|
+
if ((0, url_path_friendly_1.checkLink)(parentLink) || (0, url_path_friendly_1.checkLink)(childLink)) {
|
|
131
117
|
return optionalJoin(parentLink, childLink);
|
|
132
118
|
}
|
|
133
119
|
return childLink;
|
|
@@ -212,7 +198,7 @@ function parseBlockletNavigationList(blocklet = {}) {
|
|
|
212
198
|
const targetList = [];
|
|
213
199
|
const { children = [], meta = {} } = current;
|
|
214
200
|
const navigation = (0, cloneDeep_1.default)(meta?.navigation || []);
|
|
215
|
-
if (current.meta?.capabilities?.navigation !== false) {
|
|
201
|
+
if ((0, has_start_engine_1.default)(meta) && current.meta?.capabilities?.navigation !== false) {
|
|
216
202
|
targetList.push(...navigation);
|
|
217
203
|
}
|
|
218
204
|
const parentName = parent.name || '';
|
|
@@ -220,6 +206,10 @@ function parseBlockletNavigationList(blocklet = {}) {
|
|
|
220
206
|
const currentName = current === blocklet ? '' : meta.name || '';
|
|
221
207
|
const currentBase = current === blocklet ? '' : current.mountPoint || BASE_PATH;
|
|
222
208
|
for (const child of children) {
|
|
209
|
+
if (!(0, has_start_engine_1.default)(child.meta)) {
|
|
210
|
+
// eslint-disable-next-line no-continue
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
223
213
|
const childName = child.meta.name;
|
|
224
214
|
const childBase = child.mountPoint;
|
|
225
215
|
const mergeName = [parentName, currentName, childName].filter(Boolean).join('.');
|
package/lib/schema.js
CHANGED
|
@@ -39,18 +39,16 @@ const constant_2 = require("@blocklet/constant");
|
|
|
39
39
|
const did_2 = __importDefault(require("./did"));
|
|
40
40
|
const extension_1 = require("./extension");
|
|
41
41
|
const name_1 = require("./name");
|
|
42
|
-
const parse_navigation_from_blocklet_1 = require("./parse-navigation-from-blocklet");
|
|
43
42
|
const url_path_friendly_1 = __importStar(require("./url-path-friendly"));
|
|
44
43
|
const cjkLength = cjk_length_1.default.default;
|
|
45
44
|
const WELLKNOWN_PATH_PREFIX = '/.well-known';
|
|
46
|
-
const MAX_TITLE_LENGTH = 24;
|
|
47
45
|
const Joi = joi_1.default.extend(joi_extension_semver_1.semver)
|
|
48
46
|
.extend(joi_extension_semver_1.semverRange)
|
|
49
47
|
.extend(extension_1.fileExtension)
|
|
50
48
|
.extend(extension_1.didExtension);
|
|
51
49
|
exports.Joi = Joi;
|
|
52
50
|
const checkLinkHelper = (value, helper) => {
|
|
53
|
-
if ((0,
|
|
51
|
+
if ((0, url_path_friendly_1.checkLink)(value)) {
|
|
54
52
|
return value;
|
|
55
53
|
}
|
|
56
54
|
// @ts-expect-error
|
|
@@ -81,8 +79,8 @@ const titleSchema = Joi.string()
|
|
|
81
79
|
.trim()
|
|
82
80
|
.min(1)
|
|
83
81
|
.custom((value) => {
|
|
84
|
-
if (cjkLength(value) > MAX_TITLE_LENGTH) {
|
|
85
|
-
throw new Error(`title length should not exceed ${MAX_TITLE_LENGTH} (see: https://www.npmjs.com/package/cjk-length)`);
|
|
82
|
+
if (cjkLength(value) > constant_2.MAX_TITLE_LENGTH) {
|
|
83
|
+
throw new Error(`title length should not exceed ${constant_2.MAX_TITLE_LENGTH} (see: https://www.npmjs.com/package/cjk-length)`);
|
|
86
84
|
}
|
|
87
85
|
return value;
|
|
88
86
|
})
|
|
@@ -406,9 +404,9 @@ const localeList = ['en', 'zh', 'fr', 'ru', 'ar', 'es', 'de', 'pt', 'ja', 'hi'];
|
|
|
406
404
|
const navigationItemProps = {
|
|
407
405
|
id: Joi.string().custom(checkId),
|
|
408
406
|
title: Joi.alternatives()
|
|
409
|
-
.try(Joi.string().min(1).max(MAX_TITLE_LENGTH), Joi.object()
|
|
407
|
+
.try(Joi.string().min(1).max(constant_2.MAX_TITLE_LENGTH), Joi.object()
|
|
410
408
|
.min(1)
|
|
411
|
-
.pattern(Joi.string().valid(...localeList), Joi.string().min(1).max(MAX_TITLE_LENGTH)))
|
|
409
|
+
.pattern(Joi.string().valid(...localeList), Joi.string().min(1).max(constant_2.MAX_TITLE_LENGTH)))
|
|
412
410
|
.required(),
|
|
413
411
|
link: Joi.alternatives().try(Joi.string().custom(checkLinkHelper), Joi.object()
|
|
414
412
|
.min(1)
|
|
@@ -2,5 +2,6 @@ declare const isValidUrlPath: (name: any) => boolean;
|
|
|
2
2
|
declare const urlPathFriendly: (name: any, { keepSlash }?: {
|
|
3
3
|
keepSlash?: boolean;
|
|
4
4
|
}) => any;
|
|
5
|
-
|
|
5
|
+
declare const checkLink: (value: string) => boolean;
|
|
6
|
+
export { isValidUrlPath, checkLink };
|
|
6
7
|
export default urlPathFriendly;
|
package/lib/url-path-friendly.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidUrlPath = void 0;
|
|
6
|
+
exports.checkLink = exports.isValidUrlPath = void 0;
|
|
7
|
+
const is_absolute_url_1 = __importDefault(require("is-absolute-url"));
|
|
4
8
|
const isValidUrlPath = (name) => {
|
|
5
9
|
// Check if the path contains any uppercase letters
|
|
6
10
|
if (/[A-Z]/.test(name)) {
|
|
@@ -34,4 +38,21 @@ const urlPathFriendly = (name, { keepSlash = true } = {}) => {
|
|
|
34
38
|
}
|
|
35
39
|
return noConsecutiveSlashes;
|
|
36
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* 判断一个 url 是否为合法的 url 拼接路径
|
|
43
|
+
* /abc, /abc/bcd valid
|
|
44
|
+
* /abc, /abc//bcd invalid
|
|
45
|
+
* @param value 需要检查的 url path
|
|
46
|
+
* @returns boolean
|
|
47
|
+
*/
|
|
48
|
+
const checkUrlPath = (value) => {
|
|
49
|
+
return /^\/(?:[^/]+\/)*$/.test(value) || /^\/(?:[^/]+\/)*[^/]+$/.test(value);
|
|
50
|
+
};
|
|
51
|
+
const checkLink = (value) => {
|
|
52
|
+
if ((0, is_absolute_url_1.default)(value) || checkUrlPath(value)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
57
|
+
exports.checkLink = checkLink;
|
|
37
58
|
exports.default = urlPathFriendly;
|
package/lib/util.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BlockletState, ComponentState } from '@abtnode/client';
|
|
2
2
|
import type { Request } from 'express';
|
|
3
|
+
import hasStartEngine from './has-start-engine';
|
|
3
4
|
import type { TBlockletMeta, TEnvironment } from './types';
|
|
4
5
|
type TConfig = TEnvironment & {
|
|
5
6
|
key: string;
|
|
@@ -145,7 +146,6 @@ declare const getBlockletServices: (blocklet: Partial<BlockletState>) => Array<{
|
|
|
145
146
|
declare const isInProgress: (status: string | number) => boolean;
|
|
146
147
|
declare const isBeforeInstalled: (status: string | number) => boolean;
|
|
147
148
|
declare const isRunning: (status: string | number) => boolean;
|
|
148
|
-
declare const hasStartEngine: (meta: TBlockletMeta) => boolean;
|
|
149
149
|
export { isFreeBlocklet, isFreeComponent, 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, };
|
|
150
150
|
declare const _default: {
|
|
151
151
|
isFreeBlocklet: (meta: TBlockletMeta) => boolean;
|
|
@@ -253,6 +253,6 @@ declare const _default: {
|
|
|
253
253
|
isBeforeInstalled: (status: string | number) => boolean;
|
|
254
254
|
isRunning: (status: string | number) => boolean;
|
|
255
255
|
isGatewayBlocklet: (meta: TBlockletMeta) => boolean;
|
|
256
|
-
hasStartEngine: (meta: TBlockletMeta) => boolean;
|
|
256
|
+
hasStartEngine: (meta: TBlockletMeta | import("@abtnode/client").BlockletMeta) => boolean;
|
|
257
257
|
};
|
|
258
258
|
export default _default;
|
package/lib/util.js
CHANGED
|
@@ -11,6 +11,8 @@ const url_join_1 = __importDefault(require("url-join"));
|
|
|
11
11
|
const p_limit_1 = __importDefault(require("p-limit"));
|
|
12
12
|
const constant_1 = __importDefault(require("@abtnode/constant"));
|
|
13
13
|
const constant_2 = require("@blocklet/constant");
|
|
14
|
+
const has_start_engine_1 = __importDefault(require("./has-start-engine"));
|
|
15
|
+
exports.hasStartEngine = has_start_engine_1.default;
|
|
14
16
|
const { NODE_SERVICES, SLOT_FOR_IP_DNS_SITE, WHO_CAN_ACCESS, WHO_CAN_ACCESS_PREFIX_ROLES } = constant_1.default;
|
|
15
17
|
const getComponentId = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.did : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.did : ''}`;
|
|
16
18
|
exports.getComponentId = getComponentId;
|
|
@@ -676,8 +678,6 @@ const isBeforeInstalled = (status) => [
|
|
|
676
678
|
exports.isBeforeInstalled = isBeforeInstalled;
|
|
677
679
|
const isRunning = (status) => [constant_2.BlockletStatus.running, 'running'].includes(status);
|
|
678
680
|
exports.isRunning = isRunning;
|
|
679
|
-
const hasStartEngine = (meta) => !!meta?.main;
|
|
680
|
-
exports.hasStartEngine = hasStartEngine;
|
|
681
681
|
exports.default = {
|
|
682
682
|
isFreeBlocklet,
|
|
683
683
|
isFreeComponent,
|
|
@@ -725,5 +725,5 @@ exports.default = {
|
|
|
725
725
|
isBeforeInstalled,
|
|
726
726
|
isRunning,
|
|
727
727
|
isGatewayBlocklet,
|
|
728
|
-
hasStartEngine,
|
|
728
|
+
hasStartEngine: has_start_engine_1.default,
|
|
729
729
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.17-beta-
|
|
6
|
+
"version": "1.16.17-beta-4f13d99d",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -24,17 +24,17 @@
|
|
|
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.17-beta-
|
|
28
|
-
"@arcblock/did": "1.18.
|
|
29
|
-
"@arcblock/did-ext": "1.18.
|
|
30
|
-
"@arcblock/did-util": "1.18.
|
|
31
|
-
"@arcblock/jwt": "1.18.
|
|
32
|
-
"@blocklet/constant": "1.16.17-beta-
|
|
33
|
-
"@ocap/asset": "1.18.
|
|
34
|
-
"@ocap/mcrypto": "1.18.
|
|
35
|
-
"@ocap/types": "1.18.
|
|
36
|
-
"@ocap/util": "1.18.
|
|
37
|
-
"@ocap/wallet": "1.18.
|
|
27
|
+
"@abtnode/constant": "1.16.17-beta-4f13d99d",
|
|
28
|
+
"@arcblock/did": "1.18.92",
|
|
29
|
+
"@arcblock/did-ext": "1.18.92",
|
|
30
|
+
"@arcblock/did-util": "1.18.92",
|
|
31
|
+
"@arcblock/jwt": "1.18.92",
|
|
32
|
+
"@blocklet/constant": "1.16.17-beta-4f13d99d",
|
|
33
|
+
"@ocap/asset": "1.18.92",
|
|
34
|
+
"@ocap/mcrypto": "1.18.92",
|
|
35
|
+
"@ocap/types": "1.18.92",
|
|
36
|
+
"@ocap/util": "1.18.92",
|
|
37
|
+
"@ocap/wallet": "1.18.92",
|
|
38
38
|
"ajv": "^8.11.0",
|
|
39
39
|
"axios": "^0.27.2",
|
|
40
40
|
"cjk-length": "^1.0.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"ts-node": "^10.9.1",
|
|
79
79
|
"typescript": "^5.0.4"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "005478c4b14448f2ae896ae363972afbde1d7e7b"
|
|
82
82
|
}
|