@blocklet/meta 1.16.8-next-da13616b → 1.16.8-next-ee2c4046
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/constants.d.ts +1 -2
- package/lib/constants.js +15 -4
- package/lib/entry.js +5 -6
- package/lib/file.d.ts +2 -2
- package/lib/file.js +4 -5
- package/lib/fix.js +6 -7
- package/lib/has-reserved-key.js +2 -6
- package/lib/index.d.ts +3 -3
- package/lib/index.js +26 -3
- package/lib/parse.js +6 -7
- package/lib/schema.js +19 -20
- package/lib/util.js +29 -30
- package/package.json +5 -5
package/lib/constants.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export = constant;
|
|
1
|
+
export * from '@blocklet/constant';
|
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4
15
|
};
|
|
5
|
-
|
|
6
|
-
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@blocklet/constant"), exports);
|
package/lib/entry.js
CHANGED
|
@@ -7,14 +7,13 @@ const path_1 = __importDefault(require("path"));
|
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
-
const
|
|
11
|
-
const { BLOCKLET_BUNDLE_FOLDER, BlockletGroup } = constants_1.default;
|
|
10
|
+
const constant_1 = require("@blocklet/constant");
|
|
12
11
|
const validateBlockletEntry = (dir, meta) => {
|
|
13
12
|
const { main, group } = meta;
|
|
14
|
-
if (group === BlockletGroup.dapp) {
|
|
13
|
+
if (group === constant_1.BlockletGroup.dapp) {
|
|
15
14
|
// backward compatible
|
|
16
15
|
if (!fs_1.default.existsSync(path_1.default.join(dir, 'blocklet.js')) &&
|
|
17
|
-
!fs_1.default.existsSync(path_1.default.join(dir, BLOCKLET_BUNDLE_FOLDER, 'blocklet.js'))) {
|
|
16
|
+
!fs_1.default.existsSync(path_1.default.join(dir, constant_1.BLOCKLET_BUNDLE_FOLDER, 'blocklet.js'))) {
|
|
18
17
|
// backward compatible
|
|
19
18
|
if ((0, isEmpty_1.default)(meta.engine)) {
|
|
20
19
|
throw new Error(`${meta.bundleName} may be corrupted or not properly bundled: missing blocklet.js`);
|
|
@@ -42,13 +41,13 @@ const validateBlockletEntry = (dir, meta) => {
|
|
|
42
41
|
}
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
|
-
if (group === BlockletGroup.static) {
|
|
44
|
+
if (group === constant_1.BlockletGroup.static) {
|
|
46
45
|
if (!fs_1.default.existsSync(path_1.default.join(dir, main))) {
|
|
47
46
|
throw new Error(`${meta.bundleName} may be corrupted or not properly configured: missing main folder`);
|
|
48
47
|
}
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
51
|
-
if (group === BlockletGroup.gateway) {
|
|
50
|
+
if (group === constant_1.BlockletGroup.gateway) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
53
|
throw new Error(`${meta.bundleName} Unsupported blocklet type ${group}`);
|
package/lib/file.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TBlockletMeta } from './types';
|
|
2
|
-
declare const list:
|
|
2
|
+
declare const list: string[];
|
|
3
3
|
declare const select: (dir: string, { throwOnError }?: {
|
|
4
4
|
throwOnError?: boolean;
|
|
5
5
|
}) => string;
|
|
@@ -12,7 +12,7 @@ export { read };
|
|
|
12
12
|
export { select };
|
|
13
13
|
export { update };
|
|
14
14
|
declare const _default: {
|
|
15
|
-
list:
|
|
15
|
+
list: string[];
|
|
16
16
|
select: (dir: string, { throwOnError }?: {
|
|
17
17
|
throwOnError?: boolean;
|
|
18
18
|
}) => string;
|
package/lib/file.js
CHANGED
|
@@ -7,13 +7,12 @@ exports.update = exports.select = exports.read = exports.list = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const list = [BLOCKLET_META_FILE, BLOCKLET_META_FILE_ALT];
|
|
10
|
+
const constant_1 = require("@blocklet/constant");
|
|
11
|
+
const list = [constant_1.BLOCKLET_META_FILE, constant_1.BLOCKLET_META_FILE_ALT];
|
|
13
12
|
exports.list = list;
|
|
14
13
|
const select = (dir, { throwOnError = true } = {}) => {
|
|
15
|
-
const metaFile = path_1.default.join(dir, BLOCKLET_META_FILE);
|
|
16
|
-
const metaFileAlt = path_1.default.join(dir, BLOCKLET_META_FILE_ALT);
|
|
14
|
+
const metaFile = path_1.default.join(dir, constant_1.BLOCKLET_META_FILE);
|
|
15
|
+
const metaFileAlt = path_1.default.join(dir, constant_1.BLOCKLET_META_FILE_ALT);
|
|
17
16
|
if (fs_extra_1.default.existsSync(metaFile) === false && fs_extra_1.default.existsSync(metaFileAlt) === false) {
|
|
18
17
|
if (throwOnError) {
|
|
19
18
|
throw new Error('blocklet.yml not found, please migrate your blocklet meta by run `abtnode blocklet:migrate`');
|
package/lib/fix.js
CHANGED
|
@@ -32,19 +32,18 @@ const path_1 = __importDefault(require("path"));
|
|
|
32
32
|
const get_1 = __importDefault(require("lodash/get"));
|
|
33
33
|
const gitInfo = __importStar(require("hosted-git-info"));
|
|
34
34
|
const debug_1 = __importDefault(require("debug"));
|
|
35
|
+
const constant_1 = require("@blocklet/constant");
|
|
35
36
|
const validate_1 = require("./validate");
|
|
36
37
|
Object.defineProperty(exports, "fixService", { enumerable: true, get: function () { return validate_1.fixAndValidateService; } });
|
|
37
|
-
const constants_1 = __importDefault(require("./constants"));
|
|
38
38
|
const name_1 = require("./name");
|
|
39
39
|
const debug = (0, debug_1.default)('@blocklet/meta:fix');
|
|
40
|
-
const { BLOCKLET_DEFAULT_VERSION, BLOCKLET_DEFAULT_PORT_NAME, BLOCKLET_DYNAMIC_PATH_PREFIX, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_INTERFACE_PUBLIC, } = constants_1.default;
|
|
41
40
|
// Assign sensible defaults: description/main/group/version/public_url
|
|
42
41
|
const fixRequired = (data, dir) => {
|
|
43
42
|
if (!data.description) {
|
|
44
43
|
data.description = `Blocklet from ${dir}`;
|
|
45
44
|
}
|
|
46
45
|
if (!data.version) {
|
|
47
|
-
data.version = BLOCKLET_DEFAULT_VERSION;
|
|
46
|
+
data.version = constant_1.BLOCKLET_DEFAULT_VERSION;
|
|
48
47
|
}
|
|
49
48
|
if (!data.main && !data.group) {
|
|
50
49
|
debug('guess main and group', dir);
|
|
@@ -186,19 +185,19 @@ const fixInterfaces = (meta, removeMerged = true) => {
|
|
|
186
185
|
if (meta.interfaces.length) {
|
|
187
186
|
// Web interfaces should always use http protocol
|
|
188
187
|
meta.interfaces.forEach((x) => {
|
|
189
|
-
if (x.type === BLOCKLET_INTERFACE_TYPE_WEB) {
|
|
188
|
+
if (x.type === constant_1.BLOCKLET_INTERFACE_TYPE_WEB) {
|
|
190
189
|
x.protocol = 'http';
|
|
191
190
|
}
|
|
192
191
|
});
|
|
193
192
|
return meta;
|
|
194
193
|
}
|
|
195
194
|
const supportDynamicPathPrefix = (0, get_1.default)(meta, 'capabilities.dynamicPathPrefix', true);
|
|
196
|
-
const prefix = supportDynamicPathPrefix ? BLOCKLET_DYNAMIC_PATH_PREFIX : '/';
|
|
195
|
+
const prefix = supportDynamicPathPrefix ? constant_1.BLOCKLET_DYNAMIC_PATH_PREFIX : '/';
|
|
197
196
|
const addInterface = ({ type = 'web', name, path: _path = '/', // eslint-disable-line no-shadow
|
|
198
|
-
protocol = 'http', port = BLOCKLET_DEFAULT_PORT_NAME, }) => {
|
|
197
|
+
protocol = 'http', port = constant_1.BLOCKLET_DEFAULT_PORT_NAME, }) => {
|
|
199
198
|
meta.interfaces.push({ type, name, path: _path, prefix, port, protocol });
|
|
200
199
|
};
|
|
201
|
-
[BLOCKLET_INTERFACE_PUBLIC].forEach((x) => {
|
|
200
|
+
[constant_1.BLOCKLET_INTERFACE_PUBLIC].forEach((x) => {
|
|
202
201
|
if (meta[x]) {
|
|
203
202
|
addInterface({ name: x, path: meta[x] });
|
|
204
203
|
}
|
package/lib/has-reserved-key.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
const constants_1 = __importDefault(require("./constants"));
|
|
6
|
-
const { BLOCKLET_CONFIGURABLE_KEY } = constants_1.default;
|
|
2
|
+
const constant_1 = require("@blocklet/constant");
|
|
7
3
|
const hasReservedKey = (environments) => environments.some((x) => {
|
|
8
4
|
// @ts-ignore
|
|
9
5
|
const key = (x.key || x.name || '').toString();
|
|
10
6
|
if (key.startsWith('ABT_NODE_')) {
|
|
11
7
|
return true;
|
|
12
8
|
}
|
|
13
|
-
return !!(key.startsWith('BLOCKLET_') && !BLOCKLET_CONFIGURABLE_KEY[key]);
|
|
9
|
+
return !!(key.startsWith('BLOCKLET_') && !constant_1.BLOCKLET_CONFIGURABLE_KEY[key]);
|
|
14
10
|
});
|
|
15
11
|
module.exports = hasReservedKey;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import constants from './constants';
|
|
2
|
+
import * as constants from './constants';
|
|
3
3
|
import parse from './parse';
|
|
4
4
|
import toBlockletDid from './did';
|
|
5
5
|
import getBlockletWallet from './wallet';
|
|
@@ -31,8 +31,8 @@ export { getBlockletEngine };
|
|
|
31
31
|
export { verifyMultiSig };
|
|
32
32
|
export { getConnectedAccounts, getConnectedDids, getPermanentDid, getWallet, getWalletDid };
|
|
33
33
|
declare const _default: {
|
|
34
|
-
constants:
|
|
35
|
-
list:
|
|
34
|
+
constants: typeof constants;
|
|
35
|
+
list: string[];
|
|
36
36
|
select: (dir: string, { throwOnError }?: {
|
|
37
37
|
throwOnError?: boolean;
|
|
38
38
|
}) => string;
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.getWalletDid = exports.getWallet = exports.getPermanentDid = exports.getConnectedDids = exports.getConnectedAccounts = exports.verifyMultiSig = exports.getBlockletEngine = exports.getBlockletInfo = exports.getBlockletWallet = exports.toBlockletDid = exports.fixName = exports.fixService = exports.fixInterfaces = exports.fixPerson = exports.parsePerson = exports.formatPerson = exports.fixAndValidateService = exports.validateMeta = exports.parse = exports.read = exports.update = exports.select = exports.list = exports.constants = void 0;
|
|
7
|
-
const
|
|
8
|
-
exports.constants =
|
|
30
|
+
const constants = __importStar(require("./constants"));
|
|
31
|
+
exports.constants = constants;
|
|
9
32
|
const parse_1 = __importDefault(require("./parse"));
|
|
10
33
|
exports.parse = parse_1.default;
|
|
11
34
|
const did_1 = __importDefault(require("./did"));
|
|
@@ -40,7 +63,7 @@ Object.defineProperty(exports, "getPermanentDid", { enumerable: true, get: funct
|
|
|
40
63
|
Object.defineProperty(exports, "getWallet", { enumerable: true, get: function () { return did_utils_1.getWallet; } });
|
|
41
64
|
Object.defineProperty(exports, "getWalletDid", { enumerable: true, get: function () { return did_utils_1.getWalletDid; } });
|
|
42
65
|
exports.default = {
|
|
43
|
-
constants
|
|
66
|
+
constants,
|
|
44
67
|
list: file_1.list,
|
|
45
68
|
select: file_1.select,
|
|
46
69
|
update: file_1.update,
|
package/lib/parse.js
CHANGED
|
@@ -8,11 +8,10 @@ const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
|
8
8
|
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
9
9
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
10
10
|
const debug_1 = __importDefault(require("debug"));
|
|
11
|
-
const
|
|
11
|
+
const constant_1 = require("@blocklet/constant");
|
|
12
12
|
const schema_1 = require("./schema");
|
|
13
13
|
const fix_1 = require("./fix");
|
|
14
14
|
const debug = (0, debug_1.default)('@blocklet/meta:parse');
|
|
15
|
-
const { BLOCKLET_META_FILE, BLOCKLET_META_FILE_ALT } = constants_1.default;
|
|
16
15
|
const isSourceFromStore = (source) => 'name' in source || 'did' in source;
|
|
17
16
|
/**
|
|
18
17
|
* Get blocklet meta from blocklet.yml
|
|
@@ -24,15 +23,15 @@ const isSourceFromStore = (source) => 'name' in source || 'did' in source;
|
|
|
24
23
|
*/
|
|
25
24
|
const parse = (dir, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, extraRawAttrs = {}, schemaOptions = {}, defaultStoreUrl, fix = true, } = {}) => {
|
|
26
25
|
let result;
|
|
27
|
-
const blockletMetaFile = path_1.default.join(dir, BLOCKLET_META_FILE);
|
|
28
|
-
const blockletMetaFileAlt = path_1.default.join(dir, BLOCKLET_META_FILE_ALT);
|
|
26
|
+
const blockletMetaFile = path_1.default.join(dir, constant_1.BLOCKLET_META_FILE);
|
|
27
|
+
const blockletMetaFileAlt = path_1.default.join(dir, constant_1.BLOCKLET_META_FILE_ALT);
|
|
29
28
|
if (fs_1.default.existsSync(blockletMetaFile)) {
|
|
30
29
|
try {
|
|
31
30
|
result = js_yaml_1.default.load(fs_1.default.readFileSync(blockletMetaFile).toString(), { json: true });
|
|
32
31
|
debug(`parse ${blockletMetaFile}`, result);
|
|
33
32
|
}
|
|
34
33
|
catch (err) {
|
|
35
|
-
console.error(`parse_blocklet_meta from ${BLOCKLET_META_FILE} failed`, err);
|
|
34
|
+
console.error(`parse_blocklet_meta from ${constant_1.BLOCKLET_META_FILE} failed`, err);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
else if (fs_1.default.existsSync(blockletMetaFileAlt)) {
|
|
@@ -41,11 +40,11 @@ const parse = (dir, { ensureMain = false, ensureFiles = false, ensureDist = fals
|
|
|
41
40
|
debug(`parse ${blockletMetaFileAlt}`, result);
|
|
42
41
|
}
|
|
43
42
|
catch (err) {
|
|
44
|
-
console.error(`parse_blocklet_meta from ${BLOCKLET_META_FILE_ALT} failed`, err);
|
|
43
|
+
console.error(`parse_blocklet_meta from ${constant_1.BLOCKLET_META_FILE_ALT} failed`, err);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
else {
|
|
48
|
-
throw new Error(`no ${BLOCKLET_META_FILE} or ${BLOCKLET_META_FILE_ALT} found`);
|
|
47
|
+
throw new Error(`no ${constant_1.BLOCKLET_META_FILE} or ${constant_1.BLOCKLET_META_FILE_ALT} found`);
|
|
49
48
|
}
|
|
50
49
|
// User Can override with extra meta attrs: useful for registry
|
|
51
50
|
if (extraRawAttrs) {
|
package/lib/schema.js
CHANGED
|
@@ -35,14 +35,13 @@ const joi_extension_semver_1 = require("joi-extension-semver");
|
|
|
35
35
|
const is_var_name_1 = __importDefault(require("is-var-name"));
|
|
36
36
|
const constant_1 = require("@abtnode/constant");
|
|
37
37
|
const did_1 = require("@arcblock/did");
|
|
38
|
+
const constant_2 = require("@blocklet/constant");
|
|
38
39
|
const did_2 = __importDefault(require("./did"));
|
|
39
40
|
const extension_1 = require("./extension");
|
|
40
41
|
const name_1 = require("./name");
|
|
41
|
-
const constants_1 = __importDefault(require("./constants"));
|
|
42
42
|
const parse_navigation_from_blocklet_1 = require("./parse-navigation-from-blocklet");
|
|
43
43
|
const url_path_friendly_1 = __importStar(require("./url-path-friendly"));
|
|
44
44
|
const cjkLength = cjk_length_1.default.default;
|
|
45
|
-
const { BLOCKLET_GROUPS, BLOCKLET_PLATFORMS, BLOCKLET_ARCHITECTURES, BLOCKLET_INTERFACE_TYPES, BLOCKLET_INTERFACE_PROTOCOLS, BLOCKLET_ENTRY_FILE, BLOCKLET_BUNDLE_FILE, BLOCKLET_DEFAULT_PORT_NAME, BLOCKLET_DYNAMIC_PATH_PREFIX, BlockletGroup, BLOCKLET_LATEST_REQUIREMENT_SERVER, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_INTERFACE_TYPE_WELLKNOWN, BLOCKLET_APP_SPACE_ENDPOINTS, } = constants_1.default;
|
|
46
45
|
const WELLKNOWN_PATH_PREFIX = '/.well-known';
|
|
47
46
|
const MAX_TITLE_LENGTH = 24;
|
|
48
47
|
const Joi = joi_1.default.extend(joi_extension_semver_1.semver)
|
|
@@ -247,25 +246,25 @@ exports.cacheableSchema = cacheableSchema;
|
|
|
247
246
|
const interfaceSchema = Joi.object({
|
|
248
247
|
type: Joi.string()
|
|
249
248
|
.lowercase()
|
|
250
|
-
.valid(...BLOCKLET_INTERFACE_TYPES)
|
|
249
|
+
.valid(...constant_2.BLOCKLET_INTERFACE_TYPES)
|
|
251
250
|
.required(),
|
|
252
251
|
// Human readable name of the interface, such as `public_url`
|
|
253
252
|
name: Joi.string().trim().required(),
|
|
254
253
|
// The path where the interface is served from the blocklet
|
|
255
254
|
path: Joi.string().trim().default('/'),
|
|
256
255
|
// `*` means the interface can be mounted at any path prefix
|
|
257
|
-
prefix: Joi.string().trim().min(1).default(BLOCKLET_DYNAMIC_PATH_PREFIX),
|
|
256
|
+
prefix: Joi.string().trim().min(1).default(constant_2.BLOCKLET_DYNAMIC_PATH_PREFIX),
|
|
258
257
|
protocol: Joi.string()
|
|
259
258
|
.lowercase()
|
|
260
|
-
.valid(...BLOCKLET_INTERFACE_PROTOCOLS)
|
|
259
|
+
.valid(...constant_2.BLOCKLET_INTERFACE_PROTOCOLS)
|
|
261
260
|
.default('http'),
|
|
262
261
|
// Can be a string or an object
|
|
263
262
|
port: Joi.alternatives()
|
|
264
|
-
.try(Joi.string().uppercase().default(BLOCKLET_DEFAULT_PORT_NAME), Joi.object({
|
|
263
|
+
.try(Joi.string().uppercase().default(constant_2.BLOCKLET_DEFAULT_PORT_NAME), Joi.object({
|
|
265
264
|
internal: Joi.string().uppercase().required(),
|
|
266
265
|
external: Joi.number().port().required(),
|
|
267
266
|
}))
|
|
268
|
-
.default(BLOCKLET_DEFAULT_PORT_NAME),
|
|
267
|
+
.default(constant_2.BLOCKLET_DEFAULT_PORT_NAME),
|
|
269
268
|
cacheable: Joi.array().items(cacheableSchema).unique(),
|
|
270
269
|
services: Joi.array().items(serviceSchema).unique('name'),
|
|
271
270
|
endpoints: Joi.array().items(endpointSchema).unique('type'),
|
|
@@ -276,7 +275,7 @@ const interfaceSchema = Joi.object({
|
|
|
276
275
|
exports.interfaceSchema = interfaceSchema;
|
|
277
276
|
const engineSchema = Joi.object({
|
|
278
277
|
platform: Joi.string()
|
|
279
|
-
.valid(...BLOCKLET_PLATFORMS)
|
|
278
|
+
.valid(...constant_2.BLOCKLET_PLATFORMS)
|
|
280
279
|
.optional(),
|
|
281
280
|
interpreter: Joi.string().valid('binary', 'node').default('node'),
|
|
282
281
|
script: Joi.string().required(),
|
|
@@ -472,7 +471,7 @@ const blockletMetaProps = {
|
|
|
472
471
|
name: Joi.string().optional(),
|
|
473
472
|
description: descriptionSchema.required(),
|
|
474
473
|
group: Joi.string()
|
|
475
|
-
.valid(...BLOCKLET_GROUPS)
|
|
474
|
+
.valid(...constant_2.BLOCKLET_GROUPS)
|
|
476
475
|
.required(),
|
|
477
476
|
main: Joi.string().trim().required(),
|
|
478
477
|
title: titleSchema.optional().allow(''),
|
|
@@ -572,11 +571,11 @@ const blockletMetaProps = {
|
|
|
572
571
|
requirements: Joi.object({
|
|
573
572
|
abtnode: Joi.semverRange().valid(),
|
|
574
573
|
server: Joi.semverRange().valid(),
|
|
575
|
-
os: Joi.alternatives().try(Joi.string().valid('*', ...BLOCKLET_PLATFORMS), Joi.array()
|
|
576
|
-
.items(Joi.string().valid(...BLOCKLET_PLATFORMS))
|
|
574
|
+
os: Joi.alternatives().try(Joi.string().valid('*', ...constant_2.BLOCKLET_PLATFORMS), Joi.array()
|
|
575
|
+
.items(Joi.string().valid(...constant_2.BLOCKLET_PLATFORMS))
|
|
577
576
|
.min(1)),
|
|
578
|
-
cpu: Joi.alternatives().try(Joi.string().valid('*', ...BLOCKLET_ARCHITECTURES), Joi.array()
|
|
579
|
-
.items(Joi.string().valid(...BLOCKLET_ARCHITECTURES))
|
|
577
|
+
cpu: Joi.alternatives().try(Joi.string().valid('*', ...constant_2.BLOCKLET_ARCHITECTURES), Joi.array()
|
|
578
|
+
.items(Joi.string().valid(...constant_2.BLOCKLET_ARCHITECTURES))
|
|
580
579
|
.min(1)),
|
|
581
580
|
fuels: Joi.array().items(Joi.object({
|
|
582
581
|
endpoint: Joi.string().trim().required(),
|
|
@@ -585,19 +584,19 @@ const blockletMetaProps = {
|
|
|
585
584
|
reason: Joi.string().trim().required(),
|
|
586
585
|
})),
|
|
587
586
|
nodejs: Joi.semverRange().valid(),
|
|
588
|
-
}).default({ server: BLOCKLET_LATEST_REQUIREMENT_SERVER, os: '*', cpu: '*', nodejs: '*' }),
|
|
587
|
+
}).default({ server: constant_2.BLOCKLET_LATEST_REQUIREMENT_SERVER, os: '*', cpu: '*', nodejs: '*' }),
|
|
589
588
|
// interfaces: https://github.com/blocklet/blocklet-specification/issues/2
|
|
590
589
|
interfaces: Joi.array()
|
|
591
590
|
.items(interfaceSchema)
|
|
592
591
|
.unique('name')
|
|
593
592
|
.min(1)
|
|
594
593
|
.custom((value, helper) => {
|
|
595
|
-
const webItems = value.filter((x) => x.type === BLOCKLET_INTERFACE_TYPE_WEB);
|
|
594
|
+
const webItems = value.filter((x) => x.type === constant_2.BLOCKLET_INTERFACE_TYPE_WEB);
|
|
596
595
|
if (webItems.length > 1) {
|
|
597
596
|
// @ts-expect-error
|
|
598
|
-
return helper.message(`Only one ${BLOCKLET_INTERFACE_TYPE_WEB} interface can be declared`);
|
|
597
|
+
return helper.message(`Only one ${constant_2.BLOCKLET_INTERFACE_TYPE_WEB} interface can be declared`);
|
|
599
598
|
}
|
|
600
|
-
const wellknownItems = value.filter((x) => x.type === BLOCKLET_INTERFACE_TYPE_WELLKNOWN);
|
|
599
|
+
const wellknownItems = value.filter((x) => x.type === constant_2.BLOCKLET_INTERFACE_TYPE_WELLKNOWN);
|
|
601
600
|
for (const x of wellknownItems) {
|
|
602
601
|
if (!x.prefix.startsWith(WELLKNOWN_PATH_PREFIX)) {
|
|
603
602
|
// @ts-expect-error
|
|
@@ -630,7 +629,7 @@ const blockletMetaProps = {
|
|
|
630
629
|
// added in 1.2.2
|
|
631
630
|
component: Joi.boolean().default(true),
|
|
632
631
|
didSpace: Joi.string()
|
|
633
|
-
.valid(...Object.values(BLOCKLET_APP_SPACE_ENDPOINTS))
|
|
632
|
+
.valid(...Object.values(constant_2.BLOCKLET_APP_SPACE_ENDPOINTS))
|
|
634
633
|
.optional(),
|
|
635
634
|
navigation: Joi.boolean().default(true),
|
|
636
635
|
serverless: Joi.boolean().optional(), // Can the blocklet be installed on serverless
|
|
@@ -679,7 +678,7 @@ const createBlockletSchema = (baseDir, { ensureMain = false, ensureFiles = false
|
|
|
679
678
|
return Joi.object({
|
|
680
679
|
...blockletMetaProps,
|
|
681
680
|
main: Joi.when('group', {
|
|
682
|
-
is: Joi.valid(BlockletGroup.gateway),
|
|
681
|
+
is: Joi.valid(constant_2.BlockletGroup.gateway),
|
|
683
682
|
then: Joi.forbidden(),
|
|
684
683
|
otherwise: ensureMain ? Joi.file().exists({ baseDir }).required() : Joi.string().trim().required(),
|
|
685
684
|
}),
|
|
@@ -688,7 +687,7 @@ const createBlockletSchema = (baseDir, { ensureMain = false, ensureFiles = false
|
|
|
688
687
|
files: Joi.array()
|
|
689
688
|
.items(ensureFiles
|
|
690
689
|
? // eslint-disable-next-line
|
|
691
|
-
Joi.file().exists({ baseDir, canSkip: (dir, name) => [BLOCKLET_ENTRY_FILE, BLOCKLET_BUNDLE_FILE].includes(name) || (0, is_glob_1.default)(name) }) // prettier-ignore
|
|
690
|
+
Joi.file().exists({ baseDir, canSkip: (dir, name) => [constant_2.BLOCKLET_ENTRY_FILE, constant_2.BLOCKLET_BUNDLE_FILE].includes(name) || (0, is_glob_1.default)(name) }) // prettier-ignore
|
|
692
691
|
: Joi.string().trim())
|
|
693
692
|
.optional(),
|
|
694
693
|
dist: ensureDist ? distSchema.required() : distSchema.optional(),
|
package/lib/util.js
CHANGED
|
@@ -10,9 +10,8 @@ const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
|
10
10
|
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
|
-
const
|
|
13
|
+
const constant_2 = require("@blocklet/constant");
|
|
14
14
|
const { NODE_SERVICES, SLOT_FOR_IP_DNS_SITE, WHO_CAN_ACCESS, WHO_CAN_ACCESS_PREFIX_ROLES } = constant_1.default;
|
|
15
|
-
const { BlockletGroup, BlockletStatus, fromBlockletStatus, fromBlockletSource, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_CONFIGURABLE_KEY, CHAIN_INFO_CONFIG, CHAIN_PROP_MAP, BLOCKLET_PREFERENCE_PREFIX, BLOCKLET_INTERFACE_TYPE_SERVICE, } = constants_1.default;
|
|
16
15
|
const getComponentId = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.did : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.did : ''}`;
|
|
17
16
|
exports.getComponentId = getComponentId;
|
|
18
17
|
const getComponentName = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.name : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.name : ''}`;
|
|
@@ -183,7 +182,7 @@ const isEnvShareable = (env) => {
|
|
|
183
182
|
!!(env.key || env.name) &&
|
|
184
183
|
!env.secure &&
|
|
185
184
|
env.shared !== false &&
|
|
186
|
-
!BLOCKLET_CONFIGURABLE_KEY[env.key || env.name]);
|
|
185
|
+
!constant_2.BLOCKLET_CONFIGURABLE_KEY[env.key || env.name]);
|
|
187
186
|
};
|
|
188
187
|
exports.isEnvShareable = isEnvShareable;
|
|
189
188
|
const getSharedConfigObj = (component, ancestors) => {
|
|
@@ -198,7 +197,7 @@ const getSharedConfigObj = (component, ancestors) => {
|
|
|
198
197
|
if (res[key]) {
|
|
199
198
|
return;
|
|
200
199
|
}
|
|
201
|
-
if (!value || secure !== false || shared === false || BLOCKLET_CONFIGURABLE_KEY[key]) {
|
|
200
|
+
if (!value || secure !== false || shared === false || constant_2.BLOCKLET_CONFIGURABLE_KEY[key]) {
|
|
202
201
|
return;
|
|
203
202
|
}
|
|
204
203
|
const config = (component.configs || []).find((x) => x.key === key);
|
|
@@ -213,18 +212,18 @@ const getSharedConfigObj = (component, ancestors) => {
|
|
|
213
212
|
const ancestor = ancestors[0];
|
|
214
213
|
(ancestor.configs || []).forEach(({ key, value }) => {
|
|
215
214
|
if (![
|
|
216
|
-
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_HOST,
|
|
217
|
-
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_ID,
|
|
218
|
-
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_TYPE,
|
|
215
|
+
constant_2.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_HOST,
|
|
216
|
+
constant_2.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_ID,
|
|
217
|
+
constant_2.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_TYPE,
|
|
219
218
|
].includes(key)) {
|
|
220
219
|
return;
|
|
221
220
|
}
|
|
222
|
-
res[CHAIN_PROP_MAP[key]] = value;
|
|
221
|
+
res[constant_2.CHAIN_PROP_MAP[key]] = value;
|
|
223
222
|
});
|
|
224
223
|
return res;
|
|
225
224
|
};
|
|
226
225
|
exports.getSharedConfigObj = getSharedConfigObj;
|
|
227
|
-
const isPreferenceKey = (x) => x.key.startsWith(BLOCKLET_PREFERENCE_PREFIX) === true;
|
|
226
|
+
const isPreferenceKey = (x) => x.key.startsWith(constant_2.BLOCKLET_PREFERENCE_PREFIX) === true;
|
|
228
227
|
exports.isPreferenceKey = isPreferenceKey;
|
|
229
228
|
const isConfigMissing = (item, sharedConfigObj) => {
|
|
230
229
|
if (item.required) {
|
|
@@ -232,7 +231,7 @@ const isConfigMissing = (item, sharedConfigObj) => {
|
|
|
232
231
|
// if the value and the shared value are both empty
|
|
233
232
|
(!item.value && !sharedConfigObj[item.key]) ||
|
|
234
233
|
// if CHAIN_HOST, CHAIN_ID, CHAIN_TYPE in sharedConfigObj and the shared value is empty
|
|
235
|
-
(Object.values(CHAIN_PROP_MAP).includes(item.key) &&
|
|
234
|
+
(Object.values(constant_2.CHAIN_PROP_MAP).includes(item.key) &&
|
|
236
235
|
Object.keys(sharedConfigObj).includes(item.key) &&
|
|
237
236
|
!sharedConfigObj[item.key])) {
|
|
238
237
|
return true;
|
|
@@ -243,7 +242,7 @@ const isConfigMissing = (item, sharedConfigObj) => {
|
|
|
243
242
|
const getAppMissingConfigs = (blocklet = {}) => {
|
|
244
243
|
const missingConfigs = [];
|
|
245
244
|
forEachBlockletSync(blocklet, (b, { ancestors, level }) => {
|
|
246
|
-
if (level === 0 && b.meta?.group === BlockletGroup.gateway) {
|
|
245
|
+
if (level === 0 && b.meta?.group === constant_2.BlockletGroup.gateway) {
|
|
247
246
|
return;
|
|
248
247
|
}
|
|
249
248
|
const configs = b.configs || [];
|
|
@@ -334,7 +333,7 @@ exports.isDeletableBlocklet = isDeletableBlocklet;
|
|
|
334
333
|
const hasRunnableComponent = (blocklet) => {
|
|
335
334
|
let has = false;
|
|
336
335
|
forEachBlockletSync(blocklet, (x) => {
|
|
337
|
-
if (x.meta.group !== BlockletGroup.gateway) {
|
|
336
|
+
if (x.meta.group !== constant_2.BlockletGroup.gateway) {
|
|
338
337
|
has = true;
|
|
339
338
|
}
|
|
340
339
|
});
|
|
@@ -389,17 +388,17 @@ const fixBlockletStatus = (blocklet) => {
|
|
|
389
388
|
return;
|
|
390
389
|
}
|
|
391
390
|
forEachBlockletSync(blocklet, (b) => {
|
|
392
|
-
b.status = fromBlockletStatus(b.status);
|
|
391
|
+
b.status = (0, constant_2.fromBlockletStatus)(b.status);
|
|
393
392
|
if (b.source !== undefined) {
|
|
394
|
-
b.source = fromBlockletSource(b.source);
|
|
393
|
+
b.source = (0, constant_2.fromBlockletSource)(b.source);
|
|
395
394
|
}
|
|
396
395
|
});
|
|
397
396
|
if (blocklet.settings) {
|
|
398
397
|
(blocklet.settings.children || []).forEach((child) => {
|
|
399
398
|
forEachBlockletSync(child, (b) => {
|
|
400
|
-
b.status = fromBlockletStatus(b.status);
|
|
399
|
+
b.status = (0, constant_2.fromBlockletStatus)(b.status);
|
|
401
400
|
if (b.source !== undefined) {
|
|
402
|
-
b.source = fromBlockletSource(b.source);
|
|
401
|
+
b.source = (0, constant_2.fromBlockletSource)(b.source);
|
|
403
402
|
}
|
|
404
403
|
});
|
|
405
404
|
});
|
|
@@ -416,7 +415,7 @@ const findWebInterface = (blocklet) => {
|
|
|
416
415
|
if (!Array.isArray(interfaces)) {
|
|
417
416
|
return null;
|
|
418
417
|
}
|
|
419
|
-
return interfaces.find((x) => x.type === BLOCKLET_INTERFACE_TYPE_WEB);
|
|
418
|
+
return interfaces.find((x) => x.type === constant_2.BLOCKLET_INTERFACE_TYPE_WEB);
|
|
420
419
|
};
|
|
421
420
|
exports.findWebInterface = findWebInterface;
|
|
422
421
|
const findWebInterfacePort = (blocklet) => {
|
|
@@ -476,7 +475,7 @@ const replaceSlotToIp = (url, ip) => (url || '').replace(SLOT_FOR_IP_DNS_SITE, (
|
|
|
476
475
|
exports.replaceSlotToIp = replaceSlotToIp;
|
|
477
476
|
const getChainInfo = (env) => {
|
|
478
477
|
// @ts-ignore
|
|
479
|
-
const result = Object.entries(CHAIN_INFO_CONFIG).reduce((info, x) => {
|
|
478
|
+
const result = Object.entries(constant_2.CHAIN_INFO_CONFIG).reduce((info, x) => {
|
|
480
479
|
const [envName, [key, value]] = x;
|
|
481
480
|
info[key] = (0, get_1.default)(env, envName) || value;
|
|
482
481
|
return info;
|
|
@@ -529,7 +528,7 @@ const getBlockletServices = (blocklet) => {
|
|
|
529
528
|
return services;
|
|
530
529
|
}
|
|
531
530
|
forEachBlockletSync(blocklet, (component) => {
|
|
532
|
-
const interfaces = (component.meta?.interfaces || []).filter((x) => x.type === BLOCKLET_INTERFACE_TYPE_SERVICE);
|
|
531
|
+
const interfaces = (component.meta?.interfaces || []).filter((x) => x.type === constant_2.BLOCKLET_INTERFACE_TYPE_SERVICE);
|
|
533
532
|
interfaces.forEach((x) => {
|
|
534
533
|
const port = (x.port || {});
|
|
535
534
|
services.push({
|
|
@@ -544,12 +543,12 @@ const getBlockletServices = (blocklet) => {
|
|
|
544
543
|
};
|
|
545
544
|
exports.getBlockletServices = getBlockletServices;
|
|
546
545
|
const isInProgress = (status) => [
|
|
547
|
-
BlockletStatus.downloading,
|
|
548
|
-
BlockletStatus.waiting,
|
|
549
|
-
BlockletStatus.starting,
|
|
550
|
-
BlockletStatus.installing,
|
|
551
|
-
BlockletStatus.stopping,
|
|
552
|
-
BlockletStatus.upgrading,
|
|
546
|
+
constant_2.BlockletStatus.downloading,
|
|
547
|
+
constant_2.BlockletStatus.waiting,
|
|
548
|
+
constant_2.BlockletStatus.starting,
|
|
549
|
+
constant_2.BlockletStatus.installing,
|
|
550
|
+
constant_2.BlockletStatus.stopping,
|
|
551
|
+
constant_2.BlockletStatus.upgrading,
|
|
553
552
|
'downloading',
|
|
554
553
|
'waiting',
|
|
555
554
|
'starting',
|
|
@@ -561,17 +560,17 @@ const isInProgress = (status) => [
|
|
|
561
560
|
].includes(status);
|
|
562
561
|
exports.isInProgress = isInProgress;
|
|
563
562
|
const isBeforeInstalled = (status) => [
|
|
564
|
-
BlockletStatus.added,
|
|
565
|
-
BlockletStatus.waiting,
|
|
566
|
-
BlockletStatus.downloading,
|
|
567
|
-
BlockletStatus.installing,
|
|
563
|
+
constant_2.BlockletStatus.added,
|
|
564
|
+
constant_2.BlockletStatus.waiting,
|
|
565
|
+
constant_2.BlockletStatus.downloading,
|
|
566
|
+
constant_2.BlockletStatus.installing,
|
|
568
567
|
'added',
|
|
569
568
|
'waiting',
|
|
570
569
|
'downloading',
|
|
571
570
|
'installing',
|
|
572
571
|
].includes(status);
|
|
573
572
|
exports.isBeforeInstalled = isBeforeInstalled;
|
|
574
|
-
const isRunning = (status) => [BlockletStatus.running, 'running'].includes(status);
|
|
573
|
+
const isRunning = (status) => [constant_2.BlockletStatus.running, 'running'].includes(status);
|
|
575
574
|
exports.isRunning = isRunning;
|
|
576
575
|
exports.default = {
|
|
577
576
|
isFreeBlocklet,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.8-next-
|
|
6
|
+
"version": "1.16.8-next-ee2c4046",
|
|
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.8-next-
|
|
28
|
-
"@abtnode/util": "1.16.8-next-
|
|
27
|
+
"@abtnode/constant": "1.16.8-next-ee2c4046",
|
|
28
|
+
"@abtnode/util": "1.16.8-next-ee2c4046",
|
|
29
29
|
"@arcblock/did": "1.18.80",
|
|
30
30
|
"@arcblock/did-ext": "1.18.80",
|
|
31
31
|
"@arcblock/did-util": "1.18.80",
|
|
32
32
|
"@arcblock/jwt": "1.18.80",
|
|
33
|
-
"@blocklet/constant": "1.16.8-next-
|
|
33
|
+
"@blocklet/constant": "1.16.8-next-ee2c4046",
|
|
34
34
|
"@ocap/asset": "1.18.80",
|
|
35
35
|
"@ocap/mcrypto": "1.18.80",
|
|
36
36
|
"@ocap/types": "1.18.80",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"ts-node": "^10.9.1",
|
|
80
80
|
"typescript": "^5.0.4"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "5912296fd1da5d742b4ebdf3095c045040284377"
|
|
83
83
|
}
|