@blocklet/meta 1.15.17 → 1.16.0-beta-8ee536d7
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/channel.d.ts +32 -0
- package/lib/channel.js +54 -0
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +5 -152
- package/lib/did.d.ts +3 -0
- package/lib/did.js +9 -9
- package/lib/engine.d.ts +7 -0
- package/lib/engine.js +21 -25
- package/lib/entry.d.ts +3 -0
- package/lib/entry.js +51 -64
- package/lib/extension.d.ts +14 -0
- package/lib/extension.js +82 -77
- package/lib/file.d.ts +23 -0
- package/lib/file.js +51 -36
- package/lib/fix.d.ts +36 -0
- package/lib/fix.js +231 -228
- package/lib/get-component-process-id.d.ts +5 -0
- package/lib/get-component-process-id.js +16 -0
- package/lib/has-reserved-key.d.ts +3 -0
- package/lib/has-reserved-key.js +15 -0
- package/lib/index.d.ts +86 -0
- package/lib/index.js +55 -34
- package/lib/info.d.ts +15 -0
- package/lib/info.js +70 -38
- package/lib/name.d.ts +15 -0
- package/lib/name.js +41 -8
- package/lib/nft-templates.d.ts +86 -0
- package/lib/nft-templates.js +52 -0
- package/lib/parse-navigation-from-blocklet.d.ts +92 -0
- package/lib/parse-navigation-from-blocklet.js +539 -0
- package/lib/parse-navigation.d.ts +3 -0
- package/lib/parse-navigation.js +197 -0
- package/lib/parse.d.ts +22 -0
- package/lib/parse.js +100 -89
- package/lib/payment/index.d.ts +254 -0
- package/lib/payment/index.js +14 -0
- package/lib/payment/v1.d.ts +185 -0
- package/lib/payment/v1.js +84 -0
- package/lib/payment/v2.d.ts +242 -0
- package/lib/payment/v2.js +576 -0
- package/lib/schema.d.ts +63 -0
- package/lib/schema.js +669 -283
- package/lib/service.d.ts +27 -0
- package/lib/service.js +71 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +18 -0
- package/lib/types/schema.d.ts +284 -0
- package/lib/types/schema.js +3 -0
- package/lib/url-friendly.d.ts +6 -0
- package/lib/url-friendly.js +20 -0
- package/lib/util-meta.d.ts +42 -0
- package/lib/util-meta.js +146 -0
- package/lib/util.d.ts +201 -0
- package/lib/util.js +501 -82
- package/lib/validate.d.ts +13 -0
- package/lib/validate.js +37 -61
- package/lib/verify-multi-sig.d.ts +3 -0
- package/lib/verify-multi-sig.js +86 -59
- package/lib/wallet.d.ts +9 -0
- package/lib/wallet.js +19 -30
- package/package.json +59 -20
- package/lib/payment.js +0 -114
package/lib/file.js
CHANGED
|
@@ -1,40 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.update = exports.select = exports.read = exports.list = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const constants_1 = __importDefault(require("./constants"));
|
|
11
|
+
const { BLOCKLET_META_FILE, BLOCKLET_META_FILE_ALT } = constants_1.default;
|
|
12
|
+
const list = [BLOCKLET_META_FILE, BLOCKLET_META_FILE_ALT];
|
|
13
|
+
exports.list = list;
|
|
8
14
|
const select = (dir, { throwOnError = true } = {}) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const metaFile = path_1.default.join(dir, BLOCKLET_META_FILE);
|
|
16
|
+
const metaFileAlt = path_1.default.join(dir, BLOCKLET_META_FILE_ALT);
|
|
17
|
+
if (fs_extra_1.default.existsSync(metaFile) === false && fs_extra_1.default.existsSync(metaFileAlt) === false) {
|
|
18
|
+
if (throwOnError) {
|
|
19
|
+
throw new Error('blocklet.yml not found, please migrate your blocklet meta by run `abtnode blocklet:migrate`');
|
|
20
|
+
}
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
const metaToUpdate = fs_extra_1.default.existsSync(metaFile) ? metaFile : fs_extra_1.default.existsSync(metaFileAlt) ? metaFileAlt : null; // eslint-disable-line
|
|
24
|
+
return metaToUpdate;
|
|
25
|
+
};
|
|
26
|
+
exports.select = select;
|
|
27
|
+
const update = (file, meta, { fix = true } = {}) => {
|
|
28
|
+
if (!fix) {
|
|
29
|
+
fs_extra_1.default.writeFileSync(file, js_yaml_1.default.dump(meta, { sortKeys: false, skipInvalid: true }));
|
|
30
|
+
return;
|
|
15
31
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
delete meta.path;
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
delete meta.folder;
|
|
35
|
+
delete meta.htmlAst;
|
|
36
|
+
delete meta.stats;
|
|
37
|
+
delete meta.nftFactory;
|
|
38
|
+
delete meta.signatures;
|
|
39
|
+
delete meta.lastPublishedAt;
|
|
40
|
+
if (!meta.specVersion) {
|
|
41
|
+
meta.specVersion = '1.0.0';
|
|
42
|
+
}
|
|
43
|
+
fs_extra_1.default.writeFileSync(file, js_yaml_1.default.dump(meta, { sortKeys: false, skipInvalid: true }));
|
|
44
|
+
};
|
|
45
|
+
exports.update = update;
|
|
46
|
+
const read = (file) => {
|
|
47
|
+
const fileContent = fs_extra_1.default.readFileSync(file, 'utf8').toString();
|
|
48
|
+
return js_yaml_1.default.load(fileContent);
|
|
22
49
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
delete meta.stats;
|
|
29
|
-
delete meta.nftFactory;
|
|
30
|
-
delete meta.signatures;
|
|
31
|
-
delete meta.lastPublishedAt;
|
|
32
|
-
|
|
33
|
-
if (!meta.specVersion) {
|
|
34
|
-
meta.specVersion = '1.0.0';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
fs.writeFileSync(file, yaml.safeDump(meta, { sortKeys: false, skipInvalid: true }));
|
|
50
|
+
exports.read = read;
|
|
51
|
+
exports.default = {
|
|
52
|
+
list,
|
|
53
|
+
select,
|
|
54
|
+
update,
|
|
38
55
|
};
|
|
39
|
-
|
|
40
|
-
module.exports = { list, select, update };
|
package/lib/fix.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { fixAndValidateService } from './validate';
|
|
2
|
+
declare const fixRequired: (data: any, dir: string) => void;
|
|
3
|
+
declare const fixRepository: (data: any) => void;
|
|
4
|
+
declare const fixFiles: (data: any) => void;
|
|
5
|
+
declare const fixKeywords: (data: any) => void;
|
|
6
|
+
declare const fixTags: (data: any) => void;
|
|
7
|
+
declare const formatPerson: (person: string | Record<string, any>) => string;
|
|
8
|
+
declare const parsePerson: (person: string) => any;
|
|
9
|
+
declare const fixPerson: (data: any) => any;
|
|
10
|
+
declare const fixInterfaces: (meta: any, removeMerged?: boolean) => any;
|
|
11
|
+
declare const fixName: (meta: any) => any;
|
|
12
|
+
export { fixRequired };
|
|
13
|
+
export { fixRepository };
|
|
14
|
+
export { fixFiles };
|
|
15
|
+
export { fixKeywords };
|
|
16
|
+
export { fixPerson };
|
|
17
|
+
export { fixTags };
|
|
18
|
+
export { fixName };
|
|
19
|
+
export { formatPerson };
|
|
20
|
+
export { parsePerson };
|
|
21
|
+
export { fixInterfaces };
|
|
22
|
+
export { fixAndValidateService as fixService };
|
|
23
|
+
declare const _default: {
|
|
24
|
+
fixRequired: (data: any, dir: string) => void;
|
|
25
|
+
fixRepository: (data: any) => void;
|
|
26
|
+
fixFiles: (data: any) => void;
|
|
27
|
+
fixKeywords: (data: any) => void;
|
|
28
|
+
fixPerson: (data: any) => any;
|
|
29
|
+
fixTags: (data: any) => void;
|
|
30
|
+
fixName: (meta: any) => any;
|
|
31
|
+
formatPerson: (person: string | Record<string, any>) => string;
|
|
32
|
+
parsePerson: (person: string) => any;
|
|
33
|
+
fixInterfaces: (meta: any, removeMerged?: boolean) => any;
|
|
34
|
+
fixService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
|
|
35
|
+
};
|
|
36
|
+
export default _default;
|
package/lib/fix.js
CHANGED
|
@@ -1,253 +1,256 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.fixService = exports.fixInterfaces = exports.parsePerson = exports.formatPerson = exports.fixName = exports.fixTags = exports.fixPerson = exports.fixKeywords = exports.fixFiles = exports.fixRepository = exports.fixRequired = void 0;
|
|
30
|
+
const fs_1 = __importDefault(require("fs"));
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
33
|
+
const gitInfo = __importStar(require("hosted-git-info"));
|
|
34
|
+
const debug_1 = __importDefault(require("debug"));
|
|
35
|
+
const validate_1 = require("./validate");
|
|
36
|
+
Object.defineProperty(exports, "fixService", { enumerable: true, get: function () { return validate_1.fixAndValidateService; } });
|
|
37
|
+
const constants_1 = __importDefault(require("./constants"));
|
|
38
|
+
const name_1 = require("./name");
|
|
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
|
+
// Assign sensible defaults: description/main/group/version/public_url
|
|
21
42
|
const fixRequired = (data, dir) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!data.version) {
|
|
31
|
-
data.version = BLOCKLET_DEFAULT_VERSION;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!data.main && !data.group) {
|
|
35
|
-
debug('guess main and group', dir);
|
|
36
|
-
data.group = 'static';
|
|
37
|
-
|
|
38
|
-
const items = ['.'].concat(fs.readdirSync(dir));
|
|
39
|
-
const item = items.find(
|
|
40
|
-
(x) => fs.existsSync(path.resolve(dir, x, 'index.html')) || fs.existsSync(path.resolve(dir, x, 'index.htm'))
|
|
41
|
-
);
|
|
42
|
-
if (item) {
|
|
43
|
-
data.main = item;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!data.group) {
|
|
48
|
-
const main = path.join(dir, data.main);
|
|
49
|
-
try {
|
|
50
|
-
const stat = fs.statSync(main);
|
|
51
|
-
if (stat.isDirectory()) {
|
|
43
|
+
if (!data.description) {
|
|
44
|
+
data.description = `Blocklet from ${dir}`;
|
|
45
|
+
}
|
|
46
|
+
if (!data.version) {
|
|
47
|
+
data.version = BLOCKLET_DEFAULT_VERSION;
|
|
48
|
+
}
|
|
49
|
+
if (!data.main && !data.group) {
|
|
50
|
+
debug('guess main and group', dir);
|
|
52
51
|
data.group = 'static';
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
const items = ['.'].concat(fs_1.default.readdirSync(dir));
|
|
53
|
+
const item = items.find((x) => fs_1.default.existsSync(path_1.default.resolve(dir, x, 'index.html')) || fs_1.default.existsSync(path_1.default.resolve(dir, x, 'index.htm')));
|
|
54
|
+
if (item) {
|
|
55
|
+
data.main = item;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!data.group) {
|
|
59
|
+
const main = path_1.default.join(dir, data.main);
|
|
60
|
+
try {
|
|
61
|
+
const stat = fs_1.default.statSync(main);
|
|
62
|
+
if (stat.isDirectory()) {
|
|
63
|
+
data.group = 'static';
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
data.group = 'dapp';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
data.group = 'static';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
64
73
|
};
|
|
65
|
-
|
|
74
|
+
exports.fixRequired = fixRequired;
|
|
66
75
|
const fixRepository = (data) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
data.repository
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
if (!data.repository)
|
|
77
|
+
return;
|
|
78
|
+
if (typeof data.repository === 'string') {
|
|
79
|
+
data.repository = {
|
|
80
|
+
type: 'git',
|
|
81
|
+
url: data.repository,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (data.repository.url) {
|
|
85
|
+
const info = gitInfo.fromUrl(data.repository.url);
|
|
86
|
+
if (info) {
|
|
87
|
+
data.repository.url = info.getDefaultRepresentation() === 'shortcut' ? info.https() : info.toString();
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
|
-
}
|
|
80
90
|
};
|
|
81
|
-
|
|
91
|
+
exports.fixRepository = fixRepository;
|
|
82
92
|
const fixFiles = (data) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
+
if (!Array.isArray(data.files)) {
|
|
94
|
+
delete data.files;
|
|
95
|
+
}
|
|
96
|
+
else if (data.files) {
|
|
97
|
+
data.files = data.files.filter((file) => {
|
|
98
|
+
return !(!file || typeof file !== 'string');
|
|
99
|
+
});
|
|
100
|
+
}
|
|
93
101
|
};
|
|
94
|
-
|
|
102
|
+
exports.fixFiles = fixFiles;
|
|
95
103
|
const fixKeywords = (data) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
}
|
|
104
|
+
if (typeof data.keywords === 'string') {
|
|
105
|
+
data.keywords = data.keywords.split(/,\s+/);
|
|
106
|
+
}
|
|
107
|
+
if (data.keywords && !Array.isArray(data.keywords)) {
|
|
108
|
+
delete data.keywords;
|
|
109
|
+
}
|
|
110
|
+
else if (data.keywords) {
|
|
111
|
+
data.keywords = data.keywords.filter((kw) => {
|
|
112
|
+
return !(typeof kw !== 'string' || !kw);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
109
115
|
};
|
|
110
|
-
|
|
116
|
+
exports.fixKeywords = fixKeywords;
|
|
111
117
|
const fixTags = (data) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
}
|
|
118
|
+
if (typeof data.tags === 'string') {
|
|
119
|
+
data.tags = data.tags.split(/,\s+/);
|
|
120
|
+
}
|
|
121
|
+
if (data.tags && !Array.isArray(data.tags)) {
|
|
122
|
+
delete data.tags;
|
|
123
|
+
}
|
|
124
|
+
else if (data.tags) {
|
|
125
|
+
data.tags = data.tags.filter((t) => {
|
|
126
|
+
return !(typeof t !== 'string' || !t);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
125
129
|
};
|
|
126
|
-
|
|
130
|
+
exports.fixTags = fixTags;
|
|
127
131
|
const updatePerson = (data, fn) => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
if (data.author)
|
|
133
|
+
data.author = fn(data.author);
|
|
134
|
+
['maintainers', 'contributors'].forEach((key) => {
|
|
135
|
+
if (!Array.isArray(data[key])) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
data[key] = data[key].map(fn);
|
|
139
|
+
});
|
|
140
|
+
return data;
|
|
137
141
|
};
|
|
138
|
-
|
|
139
142
|
const formatPerson = (person) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
143
|
+
if (!person) {
|
|
144
|
+
return '';
|
|
145
|
+
}
|
|
146
|
+
if (typeof person === 'string') {
|
|
147
|
+
return person;
|
|
148
|
+
}
|
|
149
|
+
const name = person.name || '';
|
|
150
|
+
const u = person.url || person.web;
|
|
151
|
+
const url = u ? ` (${u})` : '';
|
|
152
|
+
const e = person.email || person.mail;
|
|
153
|
+
const email = e ? ` <${e}>` : '';
|
|
154
|
+
return name + email + url;
|
|
152
155
|
};
|
|
153
|
-
|
|
156
|
+
exports.formatPerson = formatPerson;
|
|
154
157
|
const parsePerson = (person) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
158
|
+
if (typeof person !== 'string') {
|
|
159
|
+
return person;
|
|
160
|
+
}
|
|
161
|
+
const name = person.match(/^([^(<]+)/);
|
|
162
|
+
const url = person.match(/\(([^)]+)\)/);
|
|
163
|
+
const email = person.match(/<([^>]+)>/);
|
|
164
|
+
const obj = {};
|
|
165
|
+
if (name && name[0].trim())
|
|
166
|
+
obj.name = name[0].trim();
|
|
167
|
+
if (email) {
|
|
168
|
+
[, obj.email] = email;
|
|
169
|
+
}
|
|
170
|
+
if (url) {
|
|
171
|
+
[, obj.url] = url;
|
|
172
|
+
}
|
|
173
|
+
return obj;
|
|
170
174
|
};
|
|
171
|
-
|
|
175
|
+
exports.parsePerson = parsePerson;
|
|
172
176
|
const fixPerson = (data) => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
177
|
+
updatePerson(data, formatPerson);
|
|
178
|
+
updatePerson(data, parsePerson);
|
|
179
|
+
return data;
|
|
176
180
|
};
|
|
177
|
-
|
|
181
|
+
exports.fixPerson = fixPerson;
|
|
178
182
|
const fixInterfaces = (meta, removeMerged = true) => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
183
|
+
if (!Array.isArray(meta.interfaces)) {
|
|
184
|
+
meta.interfaces = [];
|
|
185
|
+
}
|
|
186
|
+
if (meta.interfaces.length) {
|
|
187
|
+
// Web interfaces should always use http protocol
|
|
188
|
+
meta.interfaces.forEach((x) => {
|
|
189
|
+
if (x.type === BLOCKLET_INTERFACE_TYPE_WEB) {
|
|
190
|
+
x.protocol = 'http';
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
return meta;
|
|
194
|
+
}
|
|
195
|
+
const supportDynamicPathPrefix = (0, get_1.default)(meta, 'capabilities.dynamicPathPrefix', true);
|
|
196
|
+
const prefix = supportDynamicPathPrefix ? BLOCKLET_DYNAMIC_PATH_PREFIX : '/';
|
|
197
|
+
const addInterface = ({ type = 'web', name, path: _path = '/', // eslint-disable-line no-shadow
|
|
198
|
+
protocol = 'http', port = BLOCKLET_DEFAULT_PORT_NAME, }) => {
|
|
199
|
+
meta.interfaces.push({ type, name, path: _path, prefix, port, protocol });
|
|
200
|
+
};
|
|
201
|
+
[BLOCKLET_INTERFACE_PUBLIC].forEach((x) => {
|
|
202
|
+
if (meta[x]) {
|
|
203
|
+
addInterface({ name: x, path: meta[x] });
|
|
204
|
+
}
|
|
189
205
|
});
|
|
206
|
+
if (Array.isArray(meta.exposeServices)) {
|
|
207
|
+
meta.exposeServices.forEach((x) => {
|
|
208
|
+
addInterface({
|
|
209
|
+
type: 'service',
|
|
210
|
+
name: x.protocol,
|
|
211
|
+
protocol: x.protocol,
|
|
212
|
+
port: {
|
|
213
|
+
internal: `BLOCKLET_${x.protocol}_PORT`.toUpperCase(),
|
|
214
|
+
external: x.port,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
if (removeMerged) {
|
|
220
|
+
delete meta.publicUrl;
|
|
221
|
+
delete meta.adminUrl;
|
|
222
|
+
delete meta.configUrl;
|
|
223
|
+
delete meta.docUrl;
|
|
224
|
+
delete meta.exposeServices;
|
|
225
|
+
if (meta.capabilities) {
|
|
226
|
+
delete meta.capabilities.dynamicPathPrefix;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return meta;
|
|
230
|
+
};
|
|
231
|
+
exports.fixInterfaces = fixInterfaces;
|
|
232
|
+
const fixName = (meta) => {
|
|
233
|
+
const { did } = meta;
|
|
234
|
+
try {
|
|
235
|
+
(0, name_1.validateNewDid)(did);
|
|
236
|
+
meta.name = did;
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
/* empty */
|
|
240
|
+
}
|
|
190
241
|
return meta;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const supportDynamicPathPrefix = get(meta, 'capabilities.dynamicPathPrefix', true);
|
|
194
|
-
const prefix = supportDynamicPathPrefix ? BLOCKLET_DYNAMIC_PATH_PREFIX : '/';
|
|
195
|
-
|
|
196
|
-
const addInterface = ({
|
|
197
|
-
type = 'web',
|
|
198
|
-
name,
|
|
199
|
-
path = '/', // eslint-disable-line no-shadow
|
|
200
|
-
protocol = 'http',
|
|
201
|
-
port = BLOCKLET_DEFAULT_PORT_NAME,
|
|
202
|
-
}) => {
|
|
203
|
-
meta.interfaces.push({ type, name, path, prefix, port, protocol });
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
[BLOCKLET_INTERFACE_PUBLIC, BLOCKLET_INTERFACE_ADMIN, BLOCKLET_INTERFACE_CONFIG, BLOCKLET_INTERFACE_DOC].forEach(
|
|
207
|
-
(x) => {
|
|
208
|
-
if (meta[x]) {
|
|
209
|
-
addInterface({ name: x, path: meta[x] });
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
if (Array.isArray(meta.exposeServices)) {
|
|
215
|
-
meta.exposeServices.forEach((x) => {
|
|
216
|
-
addInterface({
|
|
217
|
-
type: 'service',
|
|
218
|
-
name: x.protocol,
|
|
219
|
-
protocol: x.protocol,
|
|
220
|
-
port: {
|
|
221
|
-
internal: `BLOCKLET_${x.protocol}_PORT`.toUpperCase(),
|
|
222
|
-
external: x.port,
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (removeMerged) {
|
|
229
|
-
delete meta.publicUrl;
|
|
230
|
-
delete meta.adminUrl;
|
|
231
|
-
delete meta.configUrl;
|
|
232
|
-
delete meta.docUrl;
|
|
233
|
-
delete meta.exposeServices;
|
|
234
|
-
if (meta.capabilities) {
|
|
235
|
-
delete meta.capabilities.dynamicPathPrefix;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return meta;
|
|
240
242
|
};
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
243
|
+
exports.fixName = fixName;
|
|
244
|
+
exports.default = {
|
|
245
|
+
fixRequired,
|
|
246
|
+
fixRepository,
|
|
247
|
+
fixFiles,
|
|
248
|
+
fixKeywords,
|
|
249
|
+
fixPerson,
|
|
250
|
+
fixTags,
|
|
251
|
+
fixName,
|
|
252
|
+
formatPerson,
|
|
253
|
+
parsePerson,
|
|
254
|
+
fixInterfaces,
|
|
255
|
+
fixService: validate_1.fixAndValidateService,
|
|
253
256
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
6
|
+
const md5 = (str) => crypto_1.default.createHash('md5').update(str).digest('hex');
|
|
7
|
+
const getComponentProcessId = (component, ancestors = []) => {
|
|
8
|
+
const name = !ancestors.length
|
|
9
|
+
? component.meta.name
|
|
10
|
+
: `${ancestors.map((x) => encodeURIComponent(x.meta.name)).join('/')}/${encodeURIComponent(component.meta.name)}`;
|
|
11
|
+
if (name.length < 240) {
|
|
12
|
+
return name;
|
|
13
|
+
}
|
|
14
|
+
return md5(name);
|
|
15
|
+
};
|
|
16
|
+
module.exports = getComponentProcessId;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const constants_1 = __importDefault(require("./constants"));
|
|
6
|
+
const { BLOCKLET_CONFIGURABLE_KEY } = constants_1.default;
|
|
7
|
+
const hasReservedKey = (environments) => environments.some((x) => {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
const key = (x.key || x.name || '').toString();
|
|
10
|
+
if (key.startsWith('ABT_NODE_')) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return !!(key.startsWith('BLOCKLET_') && !BLOCKLET_CONFIGURABLE_KEY[key]);
|
|
14
|
+
});
|
|
15
|
+
module.exports = hasReservedKey;
|