@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
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
6
|
+
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
7
|
+
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
8
|
+
const normalize_path_prefix_1 = __importDefault(require("@abtnode/util/lib/normalize-path-prefix"));
|
|
9
|
+
const parseLinkString = (link, prefix = '') => link.startsWith('/') ? (0, normalize_path_prefix_1.default)(`${prefix}${link || '/'}`) : link;
|
|
10
|
+
const parseLink = (input, prefix) => {
|
|
11
|
+
if (Object.prototype.toString.call(input) === '[object Object]') {
|
|
12
|
+
return Object.entries(input).reduce((o, [key, value]) => {
|
|
13
|
+
o[key] = parseLinkString(value, prefix);
|
|
14
|
+
return o;
|
|
15
|
+
}, {});
|
|
16
|
+
}
|
|
17
|
+
return parseLinkString(input, prefix);
|
|
18
|
+
};
|
|
19
|
+
const getGroups = (navigation) => {
|
|
20
|
+
const groups = {};
|
|
21
|
+
for (const nav of navigation) {
|
|
22
|
+
const sections = !nav.section || !nav.section.length ? ['__undefined__'] : nav.section;
|
|
23
|
+
for (const sec of sections) {
|
|
24
|
+
if (!groups[sec]) {
|
|
25
|
+
groups[sec] = [];
|
|
26
|
+
}
|
|
27
|
+
const item = {
|
|
28
|
+
...nav,
|
|
29
|
+
};
|
|
30
|
+
if (nav.section) {
|
|
31
|
+
item.section = sec === '__undefined__' ? [] : [sec];
|
|
32
|
+
}
|
|
33
|
+
groups[sec].push(item);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return Object.values(groups);
|
|
37
|
+
};
|
|
38
|
+
const getChildName = (nav) => nav.component || nav.child;
|
|
39
|
+
const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
40
|
+
const result = [];
|
|
41
|
+
(navigation || []).forEach((nav) => {
|
|
42
|
+
if (!getChildName(nav)) {
|
|
43
|
+
if (_level > 1 && nav.items?.length) {
|
|
44
|
+
const list = doParseNavigation(nav.items, blocklet, prefix, _level + 1);
|
|
45
|
+
result.push(...list);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const item = {
|
|
49
|
+
title: nav.title,
|
|
50
|
+
id: undefined,
|
|
51
|
+
};
|
|
52
|
+
if (nav.section) {
|
|
53
|
+
item.section = nav.section;
|
|
54
|
+
}
|
|
55
|
+
if (nav.icon) {
|
|
56
|
+
item.icon = nav.icon;
|
|
57
|
+
}
|
|
58
|
+
if (nav.link) {
|
|
59
|
+
item.link = parseLink(nav.link, prefix);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
item.link = '';
|
|
63
|
+
}
|
|
64
|
+
if (nav.role) {
|
|
65
|
+
item.role = nav.role;
|
|
66
|
+
}
|
|
67
|
+
if (nav.items?.length) {
|
|
68
|
+
const list = doParseNavigation(nav.items, blocklet, prefix, _level + 1);
|
|
69
|
+
if (list.length) {
|
|
70
|
+
item.items = list;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
result.push(item);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!blocklet) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// parse child
|
|
80
|
+
const child = (blocklet.children || []).find((x) => [x.meta.name, x.meta.did].includes(getChildName(nav)));
|
|
81
|
+
if (!child) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const childTitle = child.meta.title || child.meta.name;
|
|
85
|
+
const itemProto = {
|
|
86
|
+
title: nav.title || childTitle,
|
|
87
|
+
id: undefined,
|
|
88
|
+
};
|
|
89
|
+
if (nav.section) {
|
|
90
|
+
itemProto.section = nav.section;
|
|
91
|
+
}
|
|
92
|
+
if (nav.icon) {
|
|
93
|
+
itemProto.icon = nav.icon;
|
|
94
|
+
}
|
|
95
|
+
if (nav.role) {
|
|
96
|
+
itemProto.role = nav.role;
|
|
97
|
+
}
|
|
98
|
+
// get groups by section
|
|
99
|
+
const groups = getGroups((0, get_1.default)(child, 'meta.navigation', []));
|
|
100
|
+
if (!groups.length) {
|
|
101
|
+
// child does not declares menu
|
|
102
|
+
const item = (0, cloneDeep_1.default)(itemProto);
|
|
103
|
+
item.link = parseLink(child.mountPoint || '/', prefix);
|
|
104
|
+
result.push(item);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
for (const childNavigation of groups) {
|
|
108
|
+
if (childNavigation.length === 1) {
|
|
109
|
+
// child declares one menu
|
|
110
|
+
const childNav = childNavigation[0];
|
|
111
|
+
const item = (0, cloneDeep_1.default)(itemProto);
|
|
112
|
+
item.title = nav.title || childNav.title || childTitle;
|
|
113
|
+
if (childNav.icon) {
|
|
114
|
+
item.icon = item.icon || childNav.icon;
|
|
115
|
+
}
|
|
116
|
+
if (childNav.role) {
|
|
117
|
+
item.role = item.role || childNav.role;
|
|
118
|
+
}
|
|
119
|
+
if (childNav.section) {
|
|
120
|
+
item.section = item.section || childNav.section;
|
|
121
|
+
}
|
|
122
|
+
item.link = parseLink(childNavigation[0].link || '/', (0, normalize_path_prefix_1.default)(`${prefix}${child.mountPoint}`));
|
|
123
|
+
// doParseNavigation because child nav depth may be > 1
|
|
124
|
+
const list = doParseNavigation(childNavigation, child, (0, normalize_path_prefix_1.default)(`${prefix}${child.mountPoint}`), _level + 1);
|
|
125
|
+
if (list.length > 1) {
|
|
126
|
+
// more than 1 child nav
|
|
127
|
+
delete item.link;
|
|
128
|
+
result.push({
|
|
129
|
+
...item,
|
|
130
|
+
items: list,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// only 1 child nav
|
|
135
|
+
item.link = list[0].link;
|
|
136
|
+
result.push(item);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// child declares multiple menus
|
|
141
|
+
const groupSection = childNavigation[0].section || [];
|
|
142
|
+
const list = doParseNavigation(childNavigation, child, (0, normalize_path_prefix_1.default)(`${prefix}${child.mountPoint}`), _level + 1);
|
|
143
|
+
if (_level === 1) {
|
|
144
|
+
// primary menu
|
|
145
|
+
const item = (0, cloneDeep_1.default)(itemProto);
|
|
146
|
+
if (groupSection.length) {
|
|
147
|
+
item.section = item.section || groupSection;
|
|
148
|
+
}
|
|
149
|
+
item.items = list;
|
|
150
|
+
result.push({
|
|
151
|
+
...item,
|
|
152
|
+
items: list,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// secondary menu
|
|
157
|
+
result.push(...list);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
const markDuplicate = (navigation, compares = []) => {
|
|
166
|
+
navigation.forEach((item) => {
|
|
167
|
+
const compare = { link: item.link, section: item.section || [] };
|
|
168
|
+
if (item.link && compares.some((x) => (0, isEqual_1.default)(x, compare))) {
|
|
169
|
+
item.duplicate = true;
|
|
170
|
+
}
|
|
171
|
+
if (item.link) {
|
|
172
|
+
compares.push(compare);
|
|
173
|
+
}
|
|
174
|
+
if (item.items) {
|
|
175
|
+
markDuplicate(item.items, compares);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return navigation;
|
|
179
|
+
};
|
|
180
|
+
const filterDuplicate = (navigation) => {
|
|
181
|
+
const res = navigation.filter((x) => !x.duplicate);
|
|
182
|
+
res.forEach((item) => {
|
|
183
|
+
if (item.items) {
|
|
184
|
+
item.items = filterDuplicate(item.items);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return res;
|
|
188
|
+
};
|
|
189
|
+
const uniq = (navigation) => {
|
|
190
|
+
return filterDuplicate(markDuplicate(navigation));
|
|
191
|
+
};
|
|
192
|
+
const parseNavigation = (...args) => {
|
|
193
|
+
// @ts-expect-error
|
|
194
|
+
const res = doParseNavigation(...args);
|
|
195
|
+
return uniq(res).filter((x) => x.link || (x.items && x.items.length));
|
|
196
|
+
};
|
|
197
|
+
module.exports = parseNavigation;
|
package/lib/parse.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TBlockletMeta, TComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Get blocklet meta from blocklet.yml
|
|
4
|
+
* @param {string} dir blocklet directory
|
|
5
|
+
* @param {object} options.extraRawAttrs extra attributes, will be used as base attributes
|
|
6
|
+
* @param {boolean} options.ensureMain should we verify that main exists
|
|
7
|
+
* @param {boolean} options.ensureDist should we verify that dist exists
|
|
8
|
+
* @param {boolean} options.ensureFiles should we verify that logo and files exists
|
|
9
|
+
*/
|
|
10
|
+
declare const parse: (dir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, extraRawAttrs, schemaOptions, defaultStoreUrl, fix, }?: {
|
|
11
|
+
ensureMain?: boolean;
|
|
12
|
+
ensureFiles?: boolean;
|
|
13
|
+
ensureDist?: boolean;
|
|
14
|
+
ensureComponentStore?: boolean;
|
|
15
|
+
extraRawAttrs?: any;
|
|
16
|
+
schemaOptions?: any;
|
|
17
|
+
enableDefaults?: boolean;
|
|
18
|
+
extraAttrSpec?: any;
|
|
19
|
+
defaultStoreUrl?: string | ((component: TComponent) => string);
|
|
20
|
+
fix?: boolean;
|
|
21
|
+
}) => TBlockletMeta;
|
|
22
|
+
export = parse;
|
package/lib/parse.js
CHANGED
|
@@ -1,102 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const fs_1 = __importDefault(require("fs"));
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
8
|
+
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
9
|
+
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const constants_1 = __importDefault(require("./constants"));
|
|
12
|
+
const schema_1 = require("./schema");
|
|
13
|
+
const fix_1 = require("./fix");
|
|
14
|
+
const debug = (0, debug_1.default)('@blocklet/meta:parse');
|
|
15
|
+
const { BLOCKLET_META_FILE, BLOCKLET_META_FILE_ALT } = constants_1.default;
|
|
16
|
+
const isSourceFromStore = (source) => 'name' in source || 'did' in source;
|
|
13
17
|
/**
|
|
14
|
-
* Get blocklet meta from blocklet.yml
|
|
18
|
+
* Get blocklet meta from blocklet.yml
|
|
15
19
|
* @param {string} dir blocklet directory
|
|
16
20
|
* @param {object} options.extraRawAttrs extra attributes, will be used as base attributes
|
|
17
21
|
* @param {boolean} options.ensureMain should we verify that main exists
|
|
18
22
|
* @param {boolean} options.ensureDist should we verify that dist exists
|
|
19
23
|
* @param {boolean} options.ensureFiles should we verify that logo and files exists
|
|
20
|
-
* @param {Array} options.serviceMetas should we verify that each service is validate (using JSON Schema defined serviceMetas)
|
|
21
24
|
*/
|
|
22
|
-
const parse = (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
25
|
+
const parse = (dir, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, extraRawAttrs = {}, schemaOptions = {}, defaultStoreUrl, fix = true, } = {}) => {
|
|
26
|
+
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);
|
|
29
|
+
if (fs_1.default.existsSync(blockletMetaFile)) {
|
|
30
|
+
try {
|
|
31
|
+
result = js_yaml_1.default.load(fs_1.default.readFileSync(blockletMetaFile).toString(), { json: true });
|
|
32
|
+
debug(`parse ${blockletMetaFile}`, result);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
console.error(`parse_blocklet_meta from ${BLOCKLET_META_FILE} failed`, err);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (fs_1.default.existsSync(blockletMetaFileAlt)) {
|
|
39
|
+
try {
|
|
40
|
+
result = Object.assign({}, js_yaml_1.default.load(fs_1.default.readFileSync(blockletMetaFileAlt).toString(), { json: true }));
|
|
41
|
+
debug(`parse ${blockletMetaFileAlt}`, result);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
console.error(`parse_blocklet_meta from ${BLOCKLET_META_FILE_ALT} failed`, err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error(`no ${BLOCKLET_META_FILE} or ${BLOCKLET_META_FILE_ALT} found`);
|
|
36
49
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (fs.existsSync(blockletMetaFileOld)) {
|
|
41
|
-
try {
|
|
42
|
-
result = Object.assign(result, JSON.parse(fs.readFileSync(blockletMetaFileOld).toString()));
|
|
43
|
-
debug(`parse ${BLOCKLET_META_FILE_OLD}`, result);
|
|
44
|
-
} catch (err) {
|
|
45
|
-
console.error(`parse_blocklet_meta from ${BLOCKLET_META_FILE_OLD} failed`, err);
|
|
50
|
+
// User Can override with extra meta attrs: useful for registry
|
|
51
|
+
if (extraRawAttrs) {
|
|
52
|
+
result = Object.assign(result, extraRawAttrs);
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const blockletMetaFileAlt = path.join(dir, BLOCKLET_META_FILE_ALT);
|
|
51
|
-
if (fs.existsSync(blockletMetaFile)) {
|
|
52
|
-
try {
|
|
53
|
-
result = Object.assign(result, yaml.safeLoad(fs.readFileSync(blockletMetaFile).toString(), { json: true }));
|
|
54
|
-
debug(`parse ${blockletMetaFile}`, result);
|
|
55
|
-
} catch (err) {
|
|
56
|
-
console.error(`parse_blocklet_meta from ${BLOCKLET_META_FILE} failed`, err);
|
|
54
|
+
if (!fix) {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
return result;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
// Fix
|
|
59
|
+
(0, fix_1.fixRequired)(result, dir);
|
|
60
|
+
(0, fix_1.fixRepository)(result);
|
|
61
|
+
(0, fix_1.fixFiles)(result);
|
|
62
|
+
(0, fix_1.fixKeywords)(result);
|
|
63
|
+
(0, fix_1.fixTags)(result);
|
|
64
|
+
(0, fix_1.fixName)(result);
|
|
65
|
+
(0, fix_1.fixPerson)(result);
|
|
66
|
+
(0, fix_1.fixService)(result);
|
|
67
|
+
['components', 'staticComponents'].forEach((prop) => {
|
|
68
|
+
if (defaultStoreUrl && result[prop]?.length) {
|
|
69
|
+
result[prop].forEach((x) => {
|
|
70
|
+
if (isSourceFromStore(x.source)) {
|
|
71
|
+
if (!x.source.store) {
|
|
72
|
+
x.source.store = typeof defaultStoreUrl === 'function' ? defaultStoreUrl((0, cloneDeep_1.default)(x)) : defaultStoreUrl;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// We will overwrite did anyway
|
|
79
|
+
result.path = `/${result.group}/${result.name}`;
|
|
80
|
+
// Ensure camelCase
|
|
81
|
+
result = Object.keys(result).reduce((acc, k) => {
|
|
82
|
+
acc[(0, camelCase_1.default)(k)] = result[k];
|
|
83
|
+
return acc;
|
|
84
|
+
}, {});
|
|
85
|
+
debug('fix', result);
|
|
86
|
+
// Validate and cleanup
|
|
87
|
+
const schema = (0, schema_1.createBlockletSchema)(dir, {
|
|
88
|
+
ensureMain,
|
|
89
|
+
ensureFiles,
|
|
90
|
+
ensureDist,
|
|
91
|
+
ensureComponentStore,
|
|
92
|
+
...schemaOptions,
|
|
93
|
+
});
|
|
94
|
+
const { value, error } = schema.validate(result);
|
|
95
|
+
if (error) {
|
|
96
|
+
throw new Error(`Invalid blocklet.yml: ${error.details
|
|
97
|
+
.map((x) => {
|
|
98
|
+
try {
|
|
99
|
+
// 根据 navigation 校验规则定制特殊的错误消息显示
|
|
100
|
+
if (x.type === 'array.unique' && x.path[0] === 'navigation') {
|
|
101
|
+
return `${x.message}: ${x.context.value.id}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
//
|
|
106
|
+
}
|
|
107
|
+
return x.message;
|
|
108
|
+
})
|
|
109
|
+
.join(', ')}`);
|
|
64
110
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// User Can override with extra meta attrs: useful for registry
|
|
68
|
-
if (extraRawAttrs) {
|
|
69
|
-
result = Object.assign(result, extraRawAttrs);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Fix
|
|
73
|
-
fixRequired(result, dir);
|
|
74
|
-
fixRepository(result);
|
|
75
|
-
fixFiles(result);
|
|
76
|
-
fixKeywords(result);
|
|
77
|
-
fixTags(result);
|
|
78
|
-
fixPerson(result);
|
|
79
|
-
fixService(result, serviceMetas);
|
|
80
|
-
debug('fix', result);
|
|
81
|
-
|
|
82
|
-
// We will overwrite did anyway
|
|
83
|
-
result.path = `/${result.group}/${result.name}`;
|
|
84
|
-
result.did = toBlockletDid(Buffer.from(result.name, 'utf8'));
|
|
85
|
-
|
|
86
|
-
// Ensure camelCase
|
|
87
|
-
result = Object.keys(result).reduce((acc, k) => {
|
|
88
|
-
acc[camelCase(k)] = result[k];
|
|
89
|
-
return acc;
|
|
90
|
-
}, {});
|
|
91
|
-
|
|
92
|
-
// Validate and cleanup
|
|
93
|
-
const schema = createBlockletSchema(dir, { ensureMain, ensureFiles, ensureDist });
|
|
94
|
-
const { value, error } = schema.validate(result);
|
|
95
|
-
if (error) {
|
|
96
|
-
throw new Error(`Invalid blocklet meta: ${error.details.map((x) => x.message).join(', ')}`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return value;
|
|
111
|
+
return value;
|
|
100
112
|
};
|
|
101
|
-
|
|
102
113
|
module.exports = parse;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import v2 from './v2';
|
|
2
|
+
export declare const createNftFactoryItx: ({ meta, tokens, shares, issuers, serviceUrl, }: {
|
|
3
|
+
meta: import("../types").TBlockletMeta;
|
|
4
|
+
tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "address" | "value">[];
|
|
5
|
+
shares: {
|
|
6
|
+
value: number;
|
|
7
|
+
address: string;
|
|
8
|
+
}[];
|
|
9
|
+
issuers: string[];
|
|
10
|
+
serviceUrl: string;
|
|
11
|
+
}) => {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
settlement: string;
|
|
15
|
+
limit: number;
|
|
16
|
+
trustedIssuers: string[];
|
|
17
|
+
input: {
|
|
18
|
+
tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "address" | "value">[];
|
|
19
|
+
assets: any[];
|
|
20
|
+
variables: any[];
|
|
21
|
+
};
|
|
22
|
+
output: {
|
|
23
|
+
issuer: string;
|
|
24
|
+
parent: string;
|
|
25
|
+
moniker: string;
|
|
26
|
+
readonly: boolean;
|
|
27
|
+
transferrable: boolean;
|
|
28
|
+
data: {
|
|
29
|
+
type: string;
|
|
30
|
+
value: {
|
|
31
|
+
'@context': string;
|
|
32
|
+
id: string;
|
|
33
|
+
tag: string[];
|
|
34
|
+
type: string[];
|
|
35
|
+
issuer: {
|
|
36
|
+
id: string;
|
|
37
|
+
pk: string;
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
40
|
+
issuanceDate: string;
|
|
41
|
+
credentialSubject: {
|
|
42
|
+
id: string;
|
|
43
|
+
sn: string;
|
|
44
|
+
purchased: {
|
|
45
|
+
blocklet: {
|
|
46
|
+
id: string;
|
|
47
|
+
url: string;
|
|
48
|
+
name: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
display: {
|
|
52
|
+
type: string;
|
|
53
|
+
content: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
credentialStatus: {
|
|
57
|
+
id: string;
|
|
58
|
+
type: string;
|
|
59
|
+
scope: string;
|
|
60
|
+
};
|
|
61
|
+
proof: {
|
|
62
|
+
type: string;
|
|
63
|
+
created: string;
|
|
64
|
+
proofPurpose: string;
|
|
65
|
+
jws: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
data: {
|
|
71
|
+
type: string;
|
|
72
|
+
value: {
|
|
73
|
+
did: string;
|
|
74
|
+
url: string;
|
|
75
|
+
name: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
hooks: {
|
|
79
|
+
name: string;
|
|
80
|
+
type: string;
|
|
81
|
+
hook: string;
|
|
82
|
+
}[];
|
|
83
|
+
};
|
|
84
|
+
export { v2 };
|
|
85
|
+
declare const _default: {
|
|
86
|
+
createNftFactoryItx: ({ meta, tokens, shares, issuers, serviceUrl, }: {
|
|
87
|
+
meta: import("../types").TBlockletMeta;
|
|
88
|
+
tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "address" | "value">[];
|
|
89
|
+
shares: {
|
|
90
|
+
value: number;
|
|
91
|
+
address: string;
|
|
92
|
+
}[];
|
|
93
|
+
issuers: string[];
|
|
94
|
+
serviceUrl: string;
|
|
95
|
+
}) => {
|
|
96
|
+
name: string;
|
|
97
|
+
description: string;
|
|
98
|
+
settlement: string;
|
|
99
|
+
limit: number;
|
|
100
|
+
trustedIssuers: string[];
|
|
101
|
+
input: {
|
|
102
|
+
tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "address" | "value">[];
|
|
103
|
+
assets: any[];
|
|
104
|
+
variables: any[];
|
|
105
|
+
};
|
|
106
|
+
output: {
|
|
107
|
+
issuer: string;
|
|
108
|
+
parent: string;
|
|
109
|
+
moniker: string;
|
|
110
|
+
readonly: boolean;
|
|
111
|
+
transferrable: boolean;
|
|
112
|
+
data: {
|
|
113
|
+
type: string;
|
|
114
|
+
value: {
|
|
115
|
+
'@context': string;
|
|
116
|
+
id: string;
|
|
117
|
+
tag: string[];
|
|
118
|
+
type: string[];
|
|
119
|
+
issuer: {
|
|
120
|
+
id: string;
|
|
121
|
+
pk: string;
|
|
122
|
+
name: string;
|
|
123
|
+
};
|
|
124
|
+
issuanceDate: string;
|
|
125
|
+
credentialSubject: {
|
|
126
|
+
id: string;
|
|
127
|
+
sn: string;
|
|
128
|
+
purchased: {
|
|
129
|
+
blocklet: {
|
|
130
|
+
id: string;
|
|
131
|
+
url: string;
|
|
132
|
+
name: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
display: {
|
|
136
|
+
type: string;
|
|
137
|
+
content: string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
credentialStatus: {
|
|
141
|
+
id: string;
|
|
142
|
+
type: string;
|
|
143
|
+
scope: string;
|
|
144
|
+
};
|
|
145
|
+
proof: {
|
|
146
|
+
type: string;
|
|
147
|
+
created: string;
|
|
148
|
+
proofPurpose: string;
|
|
149
|
+
jws: string;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
data: {
|
|
155
|
+
type: string;
|
|
156
|
+
value: {
|
|
157
|
+
did: string;
|
|
158
|
+
url: string;
|
|
159
|
+
name: string;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
hooks: {
|
|
163
|
+
name: string;
|
|
164
|
+
type: string;
|
|
165
|
+
hook: string;
|
|
166
|
+
}[];
|
|
167
|
+
};
|
|
168
|
+
v2: {
|
|
169
|
+
createNftFactoryItx: ({ blockletMeta, ocapClient, issuers, storeUrl, }: {
|
|
170
|
+
blockletMeta: import("../types").TBlockletMeta;
|
|
171
|
+
ocapClient: any;
|
|
172
|
+
issuers: string[];
|
|
173
|
+
storeUrl: string;
|
|
174
|
+
}) => Promise<{
|
|
175
|
+
itx: any;
|
|
176
|
+
stores: {
|
|
177
|
+
id: string;
|
|
178
|
+
url: string;
|
|
179
|
+
}[];
|
|
180
|
+
shares: {
|
|
181
|
+
amount: string;
|
|
182
|
+
tokenAddress: string;
|
|
183
|
+
accountAddress: string;
|
|
184
|
+
}[];
|
|
185
|
+
}>;
|
|
186
|
+
verifyPaymentIntegrity: ({ integrity: expected, blockletMeta, ocapClient, storeId, }: {
|
|
187
|
+
integrity: string;
|
|
188
|
+
blockletMeta: import("../types").TBlockletMeta;
|
|
189
|
+
ocapClient: any;
|
|
190
|
+
storeId: string;
|
|
191
|
+
}) => Promise<string>;
|
|
192
|
+
verifyNftFactory: ({ factoryState, signerWallet, }: {
|
|
193
|
+
factoryState: {
|
|
194
|
+
data: {
|
|
195
|
+
value: string;
|
|
196
|
+
};
|
|
197
|
+
input?: any;
|
|
198
|
+
address?: string;
|
|
199
|
+
hooks?: {
|
|
200
|
+
type: string;
|
|
201
|
+
hook: string;
|
|
202
|
+
}[];
|
|
203
|
+
};
|
|
204
|
+
signerWallet: any;
|
|
205
|
+
}) => Promise<any>;
|
|
206
|
+
checkFreeBlocklet: (blockletMeta: import("../types").TBlockletMeta) => Promise<boolean>;
|
|
207
|
+
version: string;
|
|
208
|
+
_test: {
|
|
209
|
+
getPriceTokens: (meta: any, ocapClient: any) => Promise<any>;
|
|
210
|
+
getFactoryInput: (inputTokens: {
|
|
211
|
+
address: string;
|
|
212
|
+
value: string | number;
|
|
213
|
+
decimal: number;
|
|
214
|
+
}[], { formatToken }?: {
|
|
215
|
+
formatToken?: boolean;
|
|
216
|
+
}) => {
|
|
217
|
+
tokens: {
|
|
218
|
+
address: string;
|
|
219
|
+
value: string | number;
|
|
220
|
+
decimal: number;
|
|
221
|
+
}[];
|
|
222
|
+
assets: [];
|
|
223
|
+
variables: [];
|
|
224
|
+
};
|
|
225
|
+
getPaymentIntegrity: ({ contract, factoryInput, storeComponents, meta, client, storeId, }: {
|
|
226
|
+
contract?: string;
|
|
227
|
+
factoryInput?: any;
|
|
228
|
+
storeComponents?: any;
|
|
229
|
+
meta?: any;
|
|
230
|
+
client?: any;
|
|
231
|
+
storeId?: string;
|
|
232
|
+
}) => Promise<string>;
|
|
233
|
+
getComponents: (inputMeta: any) => Promise<{
|
|
234
|
+
components: import("./v2").Component[];
|
|
235
|
+
stores: import("./v2").Store[];
|
|
236
|
+
}>;
|
|
237
|
+
getContract: ({ meta, priceTokens, components, }: {
|
|
238
|
+
meta: import("../types").TBlockletMeta;
|
|
239
|
+
priceTokens: {
|
|
240
|
+
decimal: number;
|
|
241
|
+
}[];
|
|
242
|
+
components: any;
|
|
243
|
+
}) => Promise<{
|
|
244
|
+
code: string;
|
|
245
|
+
shares: {
|
|
246
|
+
amount: string;
|
|
247
|
+
tokenAddress: string;
|
|
248
|
+
accountAddress: string;
|
|
249
|
+
}[];
|
|
250
|
+
}>;
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
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.v2 = exports.createNftFactoryItx = void 0;
|
|
7
|
+
const v1_1 = __importDefault(require("./v1"));
|
|
8
|
+
const v2_1 = __importDefault(require("./v2"));
|
|
9
|
+
exports.v2 = v2_1.default;
|
|
10
|
+
exports.createNftFactoryItx = v1_1.default.createNftFactoryItx;
|
|
11
|
+
exports.default = {
|
|
12
|
+
createNftFactoryItx: exports.createNftFactoryItx,
|
|
13
|
+
v2: v2_1.default,
|
|
14
|
+
};
|