@dedot/codegen 0.0.1-next.3f5dd645.0 → 0.0.1-next.41a5fa17.16
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/cjs/genSupportedChainTypes.js +3 -3
- package/cjs/generator/ConstsGen.js +9 -10
- package/cjs/generator/ErrorsGen.js +12 -13
- package/cjs/generator/EventsGen.js +13 -14
- package/cjs/generator/IndexGen.js +5 -5
- package/cjs/generator/QueryGen.js +9 -10
- package/cjs/generator/RpcGen.js +18 -19
- package/cjs/generator/RuntimeApisGen.js +19 -20
- package/cjs/generator/TxGen.js +15 -15
- package/cjs/generator/TypesGen.js +21 -22
- package/cjs/generator/index.js +10 -10
- package/cjs/generator/utils.js +30 -1
- package/cjs/index.js +12 -12
- package/cjs/packageInfo.js +1 -1
- package/genSupportedChainTypes.js +1 -1
- package/generator/ApiGen.d.ts +1 -1
- package/generator/ConstsGen.d.ts +1 -1
- package/generator/ConstsGen.js +4 -5
- package/generator/ErrorsGen.d.ts +1 -1
- package/generator/ErrorsGen.js +3 -4
- package/generator/EventsGen.d.ts +1 -1
- package/generator/EventsGen.js +3 -4
- package/generator/IndexGen.d.ts +1 -1
- package/generator/IndexGen.js +2 -2
- package/generator/QueryGen.d.ts +1 -1
- package/generator/QueryGen.js +4 -5
- package/generator/RpcGen.d.ts +1 -1
- package/generator/RpcGen.js +3 -4
- package/generator/RuntimeApisGen.d.ts +2 -2
- package/generator/RuntimeApisGen.js +5 -6
- package/generator/TxGen.d.ts +1 -1
- package/generator/TxGen.js +3 -3
- package/generator/TypesGen.d.ts +1 -1
- package/generator/TypesGen.js +5 -6
- package/generator/index.d.ts +10 -10
- package/generator/index.js +10 -10
- package/generator/utils.d.ts +5 -0
- package/generator/utils.js +28 -0
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/package.json +7 -8
- package/packageInfo.js +1 -1
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const index_js_1 = require("./index.js");
|
|
7
7
|
const static_substrate_1 = require("@polkadot/types-support/metadata/static-substrate");
|
|
8
8
|
const substrate_hex_1 = __importDefault(require("@polkadot/types-support/metadata/v15/substrate-hex"));
|
|
9
9
|
const codecs_1 = require("@dedot/codecs");
|
|
@@ -61,13 +61,13 @@ async function run() {
|
|
|
61
61
|
const { chain, endpoint, metadataHex, rpcMethods } = network;
|
|
62
62
|
if (endpoint) {
|
|
63
63
|
console.log(`Generate types for ${chain} via endpoint ${endpoint}`);
|
|
64
|
-
await (0,
|
|
64
|
+
await (0, index_js_1.generateTypesFromChain)(network, endpoint, OUT_DIR);
|
|
65
65
|
}
|
|
66
66
|
else if (metadataHex && rpcMethods) {
|
|
67
67
|
console.log(`Generate types for ${chain} via raw data`);
|
|
68
68
|
const metadata = codecs_1.$Metadata.tryDecode(metadataHex);
|
|
69
69
|
const runtimeVersion = getRuntimeVersion(metadata);
|
|
70
|
-
await (0,
|
|
70
|
+
await (0, index_js_1.generateTypes)(network, metadata.latest, rpcMethods, runtimeVersion.apis, OUT_DIR);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
console.log('DONE!');
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConstsGen = void 0;
|
|
4
|
-
const util_1 = require("@polkadot/util");
|
|
5
4
|
const utils_1 = require("@dedot/utils");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
class ConstsGen extends
|
|
5
|
+
const index_js_1 = require("../generator/index.js");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
class ConstsGen extends index_js_1.ApiGen {
|
|
9
8
|
generate() {
|
|
10
9
|
const { pallets } = this.metadata;
|
|
11
10
|
this.typesGen.clearCache();
|
|
@@ -17,16 +16,16 @@ class ConstsGen extends generator_1.ApiGen {
|
|
|
17
16
|
type: this.typesGen.generateType(one.typeId, 1, true),
|
|
18
17
|
docs: one.docs,
|
|
19
18
|
}));
|
|
20
|
-
defTypeOut += (0,
|
|
21
|
-
defTypeOut += `${(0,
|
|
22
|
-
${typedConstants.map(({ name, type, docs }) => `${(0,
|
|
19
|
+
defTypeOut += (0, utils_js_1.commentBlock)(`Pallet \`${pallet.name}\`'s constants`);
|
|
20
|
+
defTypeOut += `${(0, utils_1.stringCamelCase)(pallet.name)}: {
|
|
21
|
+
${typedConstants.map(({ name, type, docs }) => `${(0, utils_js_1.commentBlock)(docs)}${name}: ${type}`).join(',\n')}
|
|
23
22
|
|
|
24
|
-
${(0,
|
|
23
|
+
${(0, utils_js_1.commentBlock)('Generic pallet constant')}[name: string]: any,
|
|
25
24
|
},`;
|
|
26
25
|
}
|
|
27
26
|
const importTypes = this.typesGen.typeImports.toImports();
|
|
28
|
-
const template = (0,
|
|
29
|
-
return (0,
|
|
27
|
+
const template = (0, utils_js_1.compileTemplate)('consts.hbs');
|
|
28
|
+
return (0, utils_js_1.beautifySourceCode)(template({ importTypes, defTypeOut }));
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
exports.ConstsGen = ConstsGen;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ErrorsGen = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
class ErrorsGen extends ApiGen_1.ApiGen {
|
|
4
|
+
const ApiGen_js_1 = require("./ApiGen.js");
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const utils_1 = require("@dedot/utils");
|
|
7
|
+
class ErrorsGen extends ApiGen_js_1.ApiGen {
|
|
9
8
|
generate() {
|
|
10
9
|
const { pallets } = this.metadata;
|
|
11
10
|
this.typesGen.clearCache();
|
|
@@ -17,24 +16,24 @@ class ErrorsGen extends ApiGen_1.ApiGen {
|
|
|
17
16
|
continue;
|
|
18
17
|
}
|
|
19
18
|
const errorDefs = this.#getErrorDefs(errorTypeId);
|
|
20
|
-
defTypeOut += (0,
|
|
21
|
-
defTypeOut += `${(0,
|
|
19
|
+
defTypeOut += (0, utils_js_1.commentBlock)(`Pallet \`${pallet.name}\`'s errors`);
|
|
20
|
+
defTypeOut += `${(0, utils_1.stringCamelCase)(pallet.name)}: {
|
|
22
21
|
${errorDefs
|
|
23
|
-
.map(({ name, docs }) => `${(0,
|
|
22
|
+
.map(({ name, docs }) => `${(0, utils_js_1.commentBlock)(docs)}${(0, utils_1.stringPascalCase)(name)}: GenericPalletError`)
|
|
24
23
|
.join(',\n')}
|
|
25
24
|
|
|
26
|
-
${(0,
|
|
25
|
+
${(0, utils_js_1.commentBlock)('Generic pallet error')}[error: string]: GenericPalletError,
|
|
27
26
|
},`;
|
|
28
27
|
}
|
|
29
28
|
const importTypes = this.typesGen.typeImports.toImports();
|
|
30
|
-
const template = (0,
|
|
31
|
-
return (0,
|
|
29
|
+
const template = (0, utils_js_1.compileTemplate)('errors.hbs');
|
|
30
|
+
return (0, utils_js_1.beautifySourceCode)(template({ importTypes, defTypeOut }));
|
|
32
31
|
}
|
|
33
32
|
#getErrorDefs(errorTypeId) {
|
|
34
33
|
const def = this.metadata.types[errorTypeId];
|
|
35
|
-
(0,
|
|
34
|
+
(0, utils_1.assert)(def, `Error def not found for id ${errorTypeId}`);
|
|
36
35
|
const { tag, value } = def.type;
|
|
37
|
-
(0,
|
|
36
|
+
(0, utils_1.assert)(tag === 'Enum', `Invalid pallet error type!`);
|
|
38
37
|
return value.members;
|
|
39
38
|
}
|
|
40
39
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EventsGen = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
class EventsGen extends ApiGen_1.ApiGen {
|
|
4
|
+
const ApiGen_js_1 = require("./ApiGen.js");
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const utils_1 = require("@dedot/utils");
|
|
7
|
+
class EventsGen extends ApiGen_js_1.ApiGen {
|
|
9
8
|
generate() {
|
|
10
9
|
const { pallets } = this.metadata;
|
|
11
10
|
this.typesGen.clearCache();
|
|
@@ -18,8 +17,8 @@ class EventsGen extends ApiGen_1.ApiGen {
|
|
|
18
17
|
}
|
|
19
18
|
const eventDefs = this.#getEventDefs(eventTypeId);
|
|
20
19
|
const flatMembers = eventDefs.every((d) => d.fields.length === 0);
|
|
21
|
-
defTypeOut += (0,
|
|
22
|
-
defTypeOut += `${(0,
|
|
20
|
+
defTypeOut += (0, utils_js_1.commentBlock)(`Pallet \`${pallet.name}\`'s events`);
|
|
21
|
+
defTypeOut += `${(0, utils_1.stringCamelCase)(pallet.name)}: {
|
|
23
22
|
${eventDefs
|
|
24
23
|
.map((def) => {
|
|
25
24
|
const genericParts = [`'${pallet.name}'`, `'${def.name}'`];
|
|
@@ -32,21 +31,21 @@ class EventsGen extends ApiGen_1.ApiGen {
|
|
|
32
31
|
}
|
|
33
32
|
return { ...def, genericParts };
|
|
34
33
|
})
|
|
35
|
-
.map(({ name, docs, fields, genericParts }) => `${(0,
|
|
34
|
+
.map(({ name, docs, fields, genericParts }) => `${(0, utils_js_1.commentBlock)(docs)}${(0, utils_1.stringPascalCase)(name)}: GenericPalletEvent<${genericParts.join(', ')}>`)
|
|
36
35
|
.join(',\n')}
|
|
37
36
|
|
|
38
|
-
${(0,
|
|
37
|
+
${(0, utils_js_1.commentBlock)('Generic pallet event')}[prop: string]: GenericPalletEvent,
|
|
39
38
|
},`;
|
|
40
39
|
}
|
|
41
40
|
const importTypes = this.typesGen.typeImports.toImports();
|
|
42
|
-
const template = (0,
|
|
43
|
-
return (0,
|
|
41
|
+
const template = (0, utils_js_1.compileTemplate)('events.hbs');
|
|
42
|
+
return (0, utils_js_1.beautifySourceCode)(template({ importTypes, defTypeOut }));
|
|
44
43
|
}
|
|
45
44
|
#getEventDefs(typeId) {
|
|
46
45
|
const def = this.metadata.types[typeId];
|
|
47
|
-
(0,
|
|
46
|
+
(0, utils_1.assert)(def, `Event def not found for id ${typeId}`);
|
|
48
47
|
const { tag, value } = def.type;
|
|
49
|
-
(0,
|
|
48
|
+
(0, utils_1.assert)(tag === 'Enum', 'Invalid pallet event type!');
|
|
50
49
|
return value.members;
|
|
51
50
|
}
|
|
52
51
|
#generateMemberDefType(fields) {
|
|
@@ -57,7 +56,7 @@ class EventsGen extends ApiGen_1.ApiGen {
|
|
|
57
56
|
return fields.length === 1
|
|
58
57
|
? this.typesGen.generateType(fields[0].typeId, 1, true)
|
|
59
58
|
: `[${fields
|
|
60
|
-
.map(({ typeId, docs }) => `${(0,
|
|
59
|
+
.map(({ typeId, docs }) => `${(0, utils_js_1.commentBlock)(docs)}${this.typesGen.generateType(typeId, 1, true)}`)
|
|
61
60
|
.join(', ')}]`;
|
|
62
61
|
}
|
|
63
62
|
else {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IndexGen = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
|
+
const utils_1 = require("@dedot/utils");
|
|
6
6
|
class IndexGen {
|
|
7
7
|
networkInfo;
|
|
8
8
|
constructor(networkInfo) {
|
|
@@ -10,9 +10,9 @@ class IndexGen {
|
|
|
10
10
|
}
|
|
11
11
|
async generate() {
|
|
12
12
|
const { chain } = this.networkInfo;
|
|
13
|
-
const interfaceName = (0,
|
|
14
|
-
const template = (0,
|
|
15
|
-
return (0,
|
|
13
|
+
const interfaceName = (0, utils_1.stringPascalCase)(chain);
|
|
14
|
+
const template = (0, utils_js_1.compileTemplate)('index.hbs');
|
|
15
|
+
return (0, utils_js_1.beautifySourceCode)(template({ interfaceName }));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.IndexGen = IndexGen;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QueryGen = void 0;
|
|
4
|
-
const util_1 = require("@polkadot/util");
|
|
5
4
|
const utils_1 = require("@dedot/utils");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
class QueryGen extends
|
|
5
|
+
const index_js_1 = require("../generator/index.js");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
class QueryGen extends index_js_1.ApiGen {
|
|
9
8
|
generate() {
|
|
10
9
|
const { pallets } = this.metadata;
|
|
11
10
|
this.typesGen.clearCache();
|
|
@@ -16,17 +15,17 @@ class QueryGen extends generator_1.ApiGen {
|
|
|
16
15
|
if (!storage)
|
|
17
16
|
continue;
|
|
18
17
|
const queries = storage.entries.map((one) => this.#generateEntry(one));
|
|
19
|
-
const queryDefs = queries.map(({ name, valueType, keyType, docs }) => `${(0,
|
|
20
|
-
defTypeOut += (0,
|
|
21
|
-
defTypeOut += `${(0,
|
|
18
|
+
const queryDefs = queries.map(({ name, valueType, keyType, docs }) => `${(0, utils_js_1.commentBlock)(docs)}${name}: GenericStorageQuery<(${keyType}) => ${valueType}>`);
|
|
19
|
+
defTypeOut += (0, utils_js_1.commentBlock)(`Pallet \`${pallet.name}\`'s storage queries`);
|
|
20
|
+
defTypeOut += `${(0, utils_1.stringCamelCase)(pallet.name)}: {
|
|
22
21
|
${queryDefs.join(',\n')}
|
|
23
22
|
|
|
24
|
-
${(0,
|
|
23
|
+
${(0, utils_js_1.commentBlock)('Generic pallet storage query')}[storage: string]: GenericStorageQuery;
|
|
25
24
|
},`;
|
|
26
25
|
}
|
|
27
26
|
const importTypes = this.typesGen.typeImports.toImports();
|
|
28
|
-
const template = (0,
|
|
29
|
-
return (0,
|
|
27
|
+
const template = (0, utils_js_1.compileTemplate)('query.hbs');
|
|
28
|
+
return (0, utils_js_1.beautifySourceCode)(template({ importTypes, defTypeOut }));
|
|
30
29
|
}
|
|
31
30
|
#generateEntry(entry) {
|
|
32
31
|
const { name, type, docs, modifier } = entry;
|
package/cjs/generator/RpcGen.js
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RpcGen = void 0;
|
|
4
4
|
const specs_1 = require("@dedot/specs");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const known_codecs_1 = require("./known-codecs");
|
|
5
|
+
const index_js_1 = require("../generator/index.js");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
const known_codecs_js_1 = require("./known-codecs.js");
|
|
9
8
|
const HIDDEN_RPCS = [
|
|
10
9
|
// Ref: https://github.com/paritytech/polkadot-sdk/blob/43415ef58c143b985e09015cd000dbd65f6d3997/substrate/client/rpc-servers/src/lib.rs#L152C9-L158
|
|
11
10
|
'rpc_methods',
|
|
12
11
|
];
|
|
13
|
-
class RpcGen extends
|
|
12
|
+
class RpcGen extends index_js_1.ApiGen {
|
|
14
13
|
typesGen;
|
|
15
14
|
rpcMethods;
|
|
16
15
|
constructor(typesGen, rpcMethods) {
|
|
@@ -63,8 +62,8 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
63
62
|
});
|
|
64
63
|
// TODO include & define external types
|
|
65
64
|
const importTypes = this.typesGen.typeImports.toImports();
|
|
66
|
-
const template = (0,
|
|
67
|
-
return (0,
|
|
65
|
+
const template = (0, utils_js_1.compileTemplate)('rpc.hbs');
|
|
66
|
+
return (0, utils_js_1.beautifySourceCode)(template({ importTypes, rpcCallsOut }));
|
|
68
67
|
}
|
|
69
68
|
#generateMethodDef(spec) {
|
|
70
69
|
const { name, type, module, method, docs = [], params, pubsub, deprecated } = spec;
|
|
@@ -74,7 +73,7 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
74
73
|
defaultDocs.push(`@deprecated: ${deprecated}`);
|
|
75
74
|
}
|
|
76
75
|
if (type === 'GenericRpcCall' && params.length === 0) {
|
|
77
|
-
return `${(0,
|
|
76
|
+
return `${(0, utils_js_1.commentBlock)(defaultDocs)}${method}: GenericRpcCall`;
|
|
78
77
|
}
|
|
79
78
|
this.addTypeImport(type, false);
|
|
80
79
|
params.forEach(({ type, isScale }) => {
|
|
@@ -92,10 +91,10 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
92
91
|
defaultDocs.shift();
|
|
93
92
|
defaultDocs.unshift(`@pubsub: ${pubsub?.join(', ')}`);
|
|
94
93
|
paramsOut.push(`callback: Callback<${typeOut}>`);
|
|
95
|
-
return `${(0,
|
|
94
|
+
return `${(0, utils_js_1.commentBlock)(docs, '\n', defaultDocs, paramsDoc)}${method}: GenericRpcCall<(${paramsOut.join(', ')}) => Promise<Unsub>>`;
|
|
96
95
|
}
|
|
97
96
|
else {
|
|
98
|
-
return `${(0,
|
|
97
|
+
return `${(0, utils_js_1.commentBlock)(docs, '\n', defaultDocs, paramsDoc)}${method}: GenericRpcCall<(${paramsOut.join(', ')}) => Promise<${typeOut}>>`;
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
// TODO check typeIn, typeOut if param type, or rpc type isScale
|
|
@@ -105,15 +104,15 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
105
104
|
return;
|
|
106
105
|
}
|
|
107
106
|
type = type.trim();
|
|
108
|
-
if ((0,
|
|
107
|
+
if ((0, utils_js_1.isNativeType)(type)) {
|
|
109
108
|
return;
|
|
110
109
|
}
|
|
111
110
|
// Handle generic wrapper types
|
|
112
|
-
const matchArray = type.match(
|
|
111
|
+
const matchArray = type.match(utils_js_1.WRAPPER_TYPE_REGEX);
|
|
113
112
|
if (matchArray) {
|
|
114
113
|
const [_, $1, $2] = matchArray;
|
|
115
114
|
this.addTypeImport($1, toTypeIn);
|
|
116
|
-
if ($2.match(
|
|
115
|
+
if ($2.match(utils_js_1.WRAPPER_TYPE_REGEX) || $2.match(utils_js_1.TUPLE_TYPE_REGEX)) {
|
|
117
116
|
this.addTypeImport($2, toTypeIn);
|
|
118
117
|
}
|
|
119
118
|
else {
|
|
@@ -122,7 +121,7 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
122
121
|
return;
|
|
123
122
|
}
|
|
124
123
|
// Check tuple type
|
|
125
|
-
if (type.match(
|
|
124
|
+
if (type.match(utils_js_1.TUPLE_TYPE_REGEX)) {
|
|
126
125
|
this.addTypeImport(type.slice(1, -1).split(','), toTypeIn);
|
|
127
126
|
return;
|
|
128
127
|
}
|
|
@@ -132,7 +131,7 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
132
131
|
}
|
|
133
132
|
try {
|
|
134
133
|
const codecType = this.#getCodecType(type, toTypeIn);
|
|
135
|
-
if ((0,
|
|
134
|
+
if ((0, utils_js_1.isNativeType)(codecType))
|
|
136
135
|
return;
|
|
137
136
|
this.typesGen.typeImports.addCodecType(codecType);
|
|
138
137
|
return;
|
|
@@ -142,11 +141,11 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
142
141
|
}
|
|
143
142
|
getGeneratedTypeName(type, toTypeIn = true) {
|
|
144
143
|
try {
|
|
145
|
-
const matchArray = type.match(
|
|
144
|
+
const matchArray = type.match(utils_js_1.WRAPPER_TYPE_REGEX);
|
|
146
145
|
if (matchArray) {
|
|
147
146
|
const [_, $1, $2] = matchArray;
|
|
148
147
|
const wrapperTypeName = this.#getCodecType($1, toTypeIn);
|
|
149
|
-
if ($2.match(
|
|
148
|
+
if ($2.match(utils_js_1.WRAPPER_TYPE_REGEX) || $2.match(utils_js_1.TUPLE_TYPE_REGEX)) {
|
|
150
149
|
return `${wrapperTypeName}<${this.getGeneratedTypeName($2, toTypeIn)}>`;
|
|
151
150
|
}
|
|
152
151
|
const innerTypeNames = $2
|
|
@@ -155,7 +154,7 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
155
154
|
.join(', ');
|
|
156
155
|
return `${wrapperTypeName}<${innerTypeNames}>`;
|
|
157
156
|
}
|
|
158
|
-
else if (type.match(
|
|
157
|
+
else if (type.match(utils_js_1.TUPLE_TYPE_REGEX)) {
|
|
159
158
|
const innerTypeNames = type
|
|
160
159
|
.slice(1, -1)
|
|
161
160
|
.split(',')
|
|
@@ -169,7 +168,7 @@ class RpcGen extends generator_1.ApiGen {
|
|
|
169
168
|
return type;
|
|
170
169
|
}
|
|
171
170
|
#getCodecType(type, toTypeIn = true) {
|
|
172
|
-
const { typeIn, typeOut } = (0,
|
|
171
|
+
const { typeIn, typeOut } = (0, known_codecs_js_1.findKnownCodecType)(type);
|
|
173
172
|
return toTypeIn ? typeIn : typeOut;
|
|
174
173
|
}
|
|
175
174
|
}
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RuntimeApisGen = void 0;
|
|
4
4
|
const specs_1 = require("@dedot/specs");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
class RuntimeApisGen extends RpcGen_1.RpcGen {
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const utils_1 = require("@dedot/utils");
|
|
7
|
+
const RpcGen_js_1 = require("./RpcGen.js");
|
|
8
|
+
class RuntimeApisGen extends RpcGen_js_1.RpcGen {
|
|
10
9
|
typesGen;
|
|
11
10
|
runtimeApis;
|
|
12
11
|
constructor(typesGen, runtimeApis) {
|
|
@@ -21,19 +20,19 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
|
|
|
21
20
|
if (this.metadata.apis.length > 0) {
|
|
22
21
|
this.metadata.apis.forEach((runtimeApi) => {
|
|
23
22
|
const { name: runtimeApiName, methods } = runtimeApi;
|
|
24
|
-
runtimeCallsOut += (0,
|
|
25
|
-
runtimeCallsOut += `${(0,
|
|
23
|
+
runtimeCallsOut += (0, utils_js_1.commentBlock)(`@runtimeapi: ${runtimeApiName} - ${(0, utils_1.calcRuntimeApiHash)(runtimeApiName)}`);
|
|
24
|
+
runtimeCallsOut += `${(0, utils_1.stringCamelCase)(runtimeApiName)}: {
|
|
26
25
|
${methods.map((method) => this.#generateMethodDef(runtimeApiName, method)).join('\n')}
|
|
27
26
|
|
|
28
|
-
${(0,
|
|
27
|
+
${(0, utils_js_1.commentBlock)('Generic runtime api call')}[method: string]: GenericRuntimeApiMethod
|
|
29
28
|
}`;
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
else {
|
|
33
32
|
const specs = this.#targetRuntimeApiSpecs();
|
|
34
33
|
specs.forEach(({ methods, runtimeApiName, runtimeApiHash, version }) => {
|
|
35
|
-
runtimeCallsOut += (0,
|
|
36
|
-
runtimeCallsOut += `${(0,
|
|
34
|
+
runtimeCallsOut += (0, utils_js_1.commentBlock)(`@runtimeapi: ${runtimeApiName} - ${runtimeApiHash}`, `@version: ${version}`);
|
|
35
|
+
runtimeCallsOut += `${(0, utils_1.stringCamelCase)(runtimeApiName)}: {
|
|
37
36
|
${Object.keys(methods)
|
|
38
37
|
.map((methodName) => this.#generateMethodDefFromSpec({
|
|
39
38
|
...methods[methodName],
|
|
@@ -42,13 +41,13 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
|
|
|
42
41
|
}))
|
|
43
42
|
.join('\n')}
|
|
44
43
|
|
|
45
|
-
${(0,
|
|
44
|
+
${(0, utils_js_1.commentBlock)('Generic runtime api call')}[method: string]: GenericRuntimeApiMethod
|
|
46
45
|
}`;
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
const importTypes = this.typesGen.typeImports.toImports();
|
|
50
|
-
const template = (0,
|
|
51
|
-
return (0,
|
|
49
|
+
const template = (0, utils_js_1.compileTemplate)('runtime.hbs');
|
|
50
|
+
return (0, utils_js_1.beautifySourceCode)(template({ importTypes, runtimeCallsOut }));
|
|
52
51
|
}
|
|
53
52
|
#isOptionalType(type) {
|
|
54
53
|
return type.startsWith('Option<') || type.endsWith('| undefined');
|
|
@@ -58,7 +57,7 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
|
|
|
58
57
|
}
|
|
59
58
|
#generateMethodDefFromSpec(spec) {
|
|
60
59
|
const { docs = [], params, type, runtimeApiName, methodName } = spec;
|
|
61
|
-
const callName = `${runtimeApiName}_${(0,
|
|
60
|
+
const callName = `${runtimeApiName}_${(0, utils_1.stringSnakeCase)(methodName)}`;
|
|
62
61
|
const defaultDocs = [`@callname: ${callName}`];
|
|
63
62
|
this.addTypeImport(type, false);
|
|
64
63
|
params.forEach(({ type }) => this.addTypeImport(type));
|
|
@@ -68,14 +67,14 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
|
|
|
68
67
|
plainType: this.getGeneratedTypeName(param.type),
|
|
69
68
|
}));
|
|
70
69
|
const paramsOut = typedParams
|
|
71
|
-
.map(({ name, isOptional, plainType }) => `${(0,
|
|
70
|
+
.map(({ name, isOptional, plainType }) => `${(0, utils_1.stringCamelCase)(name)}${isOptional ? '?' : ''}: ${plainType}`)
|
|
72
71
|
.join(', ');
|
|
73
72
|
const typeOut = this.getGeneratedTypeName(type, false);
|
|
74
|
-
return `${(0,
|
|
73
|
+
return `${(0, utils_js_1.commentBlock)(docs, '\n', defaultDocs, typedParams.map(({ plainType, name }) => `@param {${plainType}} ${name}`))}${methodName}: GenericRuntimeApiMethod<(${paramsOut}) => Promise<${typeOut}>>`;
|
|
75
74
|
}
|
|
76
75
|
#generateMethodDef(runtimeApiName, methodDef) {
|
|
77
76
|
const { name: methodName, inputs, output, docs } = methodDef;
|
|
78
|
-
const callName = `${runtimeApiName}_${(0,
|
|
77
|
+
const callName = `${runtimeApiName}_${(0, utils_1.stringSnakeCase)(methodName)}`;
|
|
79
78
|
const defaultDocs = [`@callname: ${callName}`];
|
|
80
79
|
const typeOut = this.typesGen.generateType(output, 1, true);
|
|
81
80
|
this.addTypeImport(typeOut, false);
|
|
@@ -90,9 +89,9 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
|
|
|
90
89
|
}));
|
|
91
90
|
this.addTypeImport(typedInputs.map((t) => t.type));
|
|
92
91
|
const paramsOut = typedInputs
|
|
93
|
-
.map(({ name, type, isOptional }) => `${(0,
|
|
92
|
+
.map(({ name, type, isOptional }) => `${(0, utils_1.stringCamelCase)(name)}${isOptional ? '?' : ''}: ${type}`)
|
|
94
93
|
.join(', ');
|
|
95
|
-
return `${(0,
|
|
94
|
+
return `${(0, utils_js_1.commentBlock)(docs, '\n', defaultDocs, typedInputs.map(({ type, name }) => `@param {${type}} ${name}`))}${(0, utils_1.stringCamelCase)(methodName)}: GenericRuntimeApiMethod<(${paramsOut}) => Promise<${typeOut}>>`;
|
|
96
95
|
}
|
|
97
96
|
#targetRuntimeApiSpecs() {
|
|
98
97
|
const specs = this.runtimeApis.map(([runtimeApiHash, version]) => {
|
|
@@ -112,7 +111,7 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
|
|
|
112
111
|
}, []);
|
|
113
112
|
}
|
|
114
113
|
#findRuntimeApiSpec = (runtimeApiHash, version) => {
|
|
115
|
-
const runtimeApiName = (0, specs_1.getRuntimeApiNames)().find((one) => (0,
|
|
114
|
+
const runtimeApiName = (0, specs_1.getRuntimeApiNames)().find((one) => (0, utils_1.calcRuntimeApiHash)(one) === runtimeApiHash);
|
|
116
115
|
return (0, specs_1.getRuntimeApiSpecs)().find((one) => one.runtimeApiName === runtimeApiName && one.version === version);
|
|
117
116
|
};
|
|
118
117
|
}
|
package/cjs/generator/TxGen.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TxGen = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
class TxGen extends
|
|
4
|
+
const index_js_1 = require("../generator/index.js");
|
|
5
|
+
const utils_1 = require("@dedot/utils");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
class TxGen extends index_js_1.ApiGen {
|
|
8
8
|
generate() {
|
|
9
9
|
const { pallets, types } = this.metadata;
|
|
10
10
|
this.typesGen.clearCache();
|
|
@@ -26,9 +26,9 @@ class TxGen extends generator_1.ApiGen {
|
|
|
26
26
|
const isFlatEnum = type.value.members.every((m) => m.fields.length === 0);
|
|
27
27
|
const typedTxs = type.value.members
|
|
28
28
|
.map((one) => ({
|
|
29
|
-
functionName: (0,
|
|
29
|
+
functionName: (0, utils_1.stringCamelCase)(one.name),
|
|
30
30
|
params: one.fields.map((f) => ({
|
|
31
|
-
name: (0,
|
|
31
|
+
name: (0, utils_1.stringCamelCase)(f.name),
|
|
32
32
|
normalizedName: this.#normalizeParamName(f.name),
|
|
33
33
|
type: this.typesGen.generateType(f.typeId, 1),
|
|
34
34
|
docs: f.docs,
|
|
@@ -38,16 +38,16 @@ class TxGen extends generator_1.ApiGen {
|
|
|
38
38
|
.map((f) => {
|
|
39
39
|
return {
|
|
40
40
|
...f,
|
|
41
|
-
callInput: this.#generateCallInput((0,
|
|
41
|
+
callInput: this.#generateCallInput((0, utils_1.stringPascalCase)(pallet.name), (0, utils_1.stringPascalCase)(f.functionName), !isFlatEnum ? f.params.map((p) => `${p.name}: ${p.type}`) : undefined),
|
|
42
42
|
};
|
|
43
43
|
});
|
|
44
|
-
txDefsOut += (0,
|
|
45
|
-
txDefsOut += `${(0,
|
|
44
|
+
txDefsOut += (0, utils_js_1.commentBlock)(`Pallet \`${pallet.name}\`'s transaction calls`);
|
|
45
|
+
txDefsOut += `${(0, utils_1.stringCamelCase)(pallet.name)}: {
|
|
46
46
|
${typedTxs
|
|
47
|
-
.map(({ functionName, params, docs, callInput }) => `${(0,
|
|
47
|
+
.map(({ functionName, params, docs, callInput }) => `${(0, utils_js_1.commentBlock)(docs, '\n', params.map((p) => `@param {${p.type}} ${p.normalizedName} ${p.docs}`))}${functionName}: GenericTxCall<(${params.map((p) => `${p.normalizedName}: ${p.type}`).join(', ')}) => ChainSubmittableExtrinsic<${callInput}>>`)
|
|
48
48
|
.join(',\n')}
|
|
49
49
|
|
|
50
|
-
${(0,
|
|
50
|
+
${(0, utils_js_1.commentBlock)('Generic pallet tx call')}[callName: string]: GenericTxCall<TxCall>,
|
|
51
51
|
},`;
|
|
52
52
|
}
|
|
53
53
|
const importTypes = this.typesGen.typeImports.toImports();
|
|
@@ -59,12 +59,12 @@ class TxGen extends generator_1.ApiGen {
|
|
|
59
59
|
|
|
60
60
|
export type TxCall = (...args: any[]) => ChainSubmittableExtrinsic;
|
|
61
61
|
`;
|
|
62
|
-
const template = (0,
|
|
63
|
-
return (0,
|
|
62
|
+
const template = (0, utils_js_1.compileTemplate)('tx.hbs');
|
|
63
|
+
return (0, utils_js_1.beautifySourceCode)(template({ importTypes, defTypes, txDefsOut }));
|
|
64
64
|
}
|
|
65
65
|
#normalizeParamName(name) {
|
|
66
|
-
name = (0,
|
|
67
|
-
return (0,
|
|
66
|
+
name = (0, utils_1.stringCamelCase)(name);
|
|
67
|
+
return (0, utils_js_1.isReservedWord)(name) ? `${name}_` : name;
|
|
68
68
|
}
|
|
69
69
|
#generateCallInput(palletName, callName, params) {
|
|
70
70
|
if (!params) {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypesGen = exports.BASIC_KNOWN_TYPES = void 0;
|
|
4
|
-
const util_1 = require("@polkadot/util");
|
|
5
4
|
const codecs_1 = require("@dedot/codecs");
|
|
6
5
|
const utils_1 = require("@dedot/utils");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
const known_types_js_1 = require("./known-types.js");
|
|
8
|
+
const TypeImports_js_1 = require("./TypeImports.js");
|
|
9
|
+
const known_codecs_js_1 = require("./known-codecs.js");
|
|
11
10
|
// Skip generate types for these
|
|
12
11
|
// as we do have native types for them
|
|
13
12
|
const SKIP_TYPES = [
|
|
@@ -43,7 +42,7 @@ class TypesGen {
|
|
|
43
42
|
this.metadata = metadata;
|
|
44
43
|
this.registry = new codecs_1.PortableRegistry(this.metadata);
|
|
45
44
|
this.includedTypes = this.#includedTypes();
|
|
46
|
-
this.typeImports = new
|
|
45
|
+
this.typeImports = new TypeImports_js_1.TypeImports();
|
|
47
46
|
}
|
|
48
47
|
generate() {
|
|
49
48
|
this.clearCache();
|
|
@@ -51,14 +50,14 @@ class TypesGen {
|
|
|
51
50
|
Object.values(this.includedTypes)
|
|
52
51
|
.filter(({ skip, knownType }) => !(skip || knownType))
|
|
53
52
|
.forEach(({ name, nameOut, id, docs }) => {
|
|
54
|
-
defTypeOut += `${(0,
|
|
53
|
+
defTypeOut += `${(0, utils_js_1.commentBlock)(docs)}export type ${nameOut} = ${this.generateType(id, 0, true)};\n\n`;
|
|
55
54
|
if (this.#shouldGenerateTypeIn(id)) {
|
|
56
55
|
defTypeOut += `export type ${name} = ${this.generateType(id)};\n\n`;
|
|
57
56
|
}
|
|
58
57
|
});
|
|
59
58
|
const importTypes = this.typeImports.toImports('./types');
|
|
60
|
-
const template = (0,
|
|
61
|
-
return (0,
|
|
59
|
+
const template = (0, utils_js_1.compileTemplate)('types.hbs');
|
|
60
|
+
return (0, utils_js_1.beautifySourceCode)(template({ importTypes, defTypeOut }));
|
|
62
61
|
}
|
|
63
62
|
typeCache = {};
|
|
64
63
|
clearCache() {
|
|
@@ -103,7 +102,7 @@ class TypesGen {
|
|
|
103
102
|
const { tag, value } = type;
|
|
104
103
|
switch (tag) {
|
|
105
104
|
case 'Primitive':
|
|
106
|
-
const $codec = (0,
|
|
105
|
+
const $codec = (0, known_codecs_js_1.findKnownCodec)(value.kind);
|
|
107
106
|
if ($codec.nativeType) {
|
|
108
107
|
return $codec.nativeType;
|
|
109
108
|
}
|
|
@@ -151,12 +150,12 @@ class TypesGen {
|
|
|
151
150
|
return 'null';
|
|
152
151
|
}
|
|
153
152
|
else if (members.every((x) => x.fields.length === 0)) {
|
|
154
|
-
return members.map(({ name, docs }) => `${(0,
|
|
153
|
+
return members.map(({ name, docs }) => `${(0, utils_js_1.commentBlock)(docs)}'${(0, utils_1.stringPascalCase)(name)}'`).join(' | ');
|
|
155
154
|
}
|
|
156
155
|
else {
|
|
157
156
|
const membersType = [];
|
|
158
157
|
for (const { fields, name, docs } of members) {
|
|
159
|
-
const keyName = (0,
|
|
158
|
+
const keyName = (0, utils_1.stringPascalCase)(name);
|
|
160
159
|
if (fields.length === 0) {
|
|
161
160
|
membersType.push([keyName, null, docs]);
|
|
162
161
|
}
|
|
@@ -164,7 +163,7 @@ class TypesGen {
|
|
|
164
163
|
const valueType = fields.length === 1
|
|
165
164
|
? this.generateType(fields[0].typeId, nestedLevel + 1, typeOut)
|
|
166
165
|
: `[${fields
|
|
167
|
-
.map(({ typeId, docs }) => `${(0,
|
|
166
|
+
.map(({ typeId, docs }) => `${(0, utils_js_1.commentBlock)(docs)}${this.generateType(typeId, nestedLevel + 1, typeOut)}`)
|
|
168
167
|
.join(', ')}]`;
|
|
169
168
|
membersType.push([keyName, valueType, docs]);
|
|
170
169
|
}
|
|
@@ -179,7 +178,7 @@ class TypesGen {
|
|
|
179
178
|
value: valueType ? `, ${valueKey}${this.#isOptionalType(valueType) ? '?' : ''}: ${valueType} ` : '',
|
|
180
179
|
docs,
|
|
181
180
|
}))
|
|
182
|
-
.map(({ tag, value, docs }) => `${(0,
|
|
181
|
+
.map(({ tag, value, docs }) => `${(0, utils_js_1.commentBlock)(docs)}{ ${tag}${value} }`)
|
|
183
182
|
.join(' | ');
|
|
184
183
|
}
|
|
185
184
|
}
|
|
@@ -226,7 +225,7 @@ class TypesGen {
|
|
|
226
225
|
};
|
|
227
226
|
});
|
|
228
227
|
return `{${props
|
|
229
|
-
.map(({ name, type, optional, docs }) => `${(0,
|
|
228
|
+
.map(({ name, type, optional, docs }) => `${(0, utils_js_1.commentBlock)(docs)}${name}${optional ? '?' : ''}: ${type}`)
|
|
230
229
|
.join(',\n')}}`;
|
|
231
230
|
}
|
|
232
231
|
#isOptionalType(type) {
|
|
@@ -267,8 +266,8 @@ class TypesGen {
|
|
|
267
266
|
const suffix = typeSuffixes.get(id) || '';
|
|
268
267
|
let knownType = false;
|
|
269
268
|
let name, nameOut;
|
|
270
|
-
if ((0,
|
|
271
|
-
const codecType = (0,
|
|
269
|
+
if ((0, known_codecs_js_1.isKnownCodecType)(joinedPath)) {
|
|
270
|
+
const codecType = (0, known_codecs_js_1.findKnownCodecType)(path.at(-1));
|
|
272
271
|
name = codecType.typeIn;
|
|
273
272
|
nameOut = codecType.typeOut;
|
|
274
273
|
knownType = true;
|
|
@@ -315,7 +314,7 @@ class TypesGen {
|
|
|
315
314
|
*/
|
|
316
315
|
#cleanPath(path) {
|
|
317
316
|
return path
|
|
318
|
-
.map((one) => (0,
|
|
317
|
+
.map((one) => (0, utils_1.stringPascalCase)(one))
|
|
319
318
|
.filter((one, idx, currentPath) => idx === 0 || one !== currentPath[idx - 1])
|
|
320
319
|
.join('');
|
|
321
320
|
}
|
|
@@ -390,10 +389,10 @@ class TypesGen {
|
|
|
390
389
|
if (diffParam?.typeId) {
|
|
391
390
|
const diffType = types[diffParam.typeId];
|
|
392
391
|
if (diffType.path.length > 0) {
|
|
393
|
-
return (0,
|
|
392
|
+
return (0, utils_1.stringPascalCase)(diffType.path.at(-1));
|
|
394
393
|
}
|
|
395
394
|
else if (diffType.type.tag === 'Primitive') {
|
|
396
|
-
return (0,
|
|
395
|
+
return (0, utils_1.stringPascalCase)(diffType.type.value.kind);
|
|
397
396
|
}
|
|
398
397
|
}
|
|
399
398
|
// Last resort!
|
|
@@ -404,7 +403,7 @@ class TypesGen {
|
|
|
404
403
|
typeName.forEach((one) => this.addTypeImport(one));
|
|
405
404
|
return;
|
|
406
405
|
}
|
|
407
|
-
if ((0,
|
|
406
|
+
if ((0, utils_js_1.isNativeType)(typeName)) {
|
|
408
407
|
return;
|
|
409
408
|
}
|
|
410
409
|
for (let type of Object.values(this.includedTypes)) {
|
|
@@ -426,7 +425,7 @@ class TypesGen {
|
|
|
426
425
|
this.typeImports.addCodecType(typeName);
|
|
427
426
|
return;
|
|
428
427
|
}
|
|
429
|
-
if (
|
|
428
|
+
if (known_types_js_1.knownTypes.includes(typeName)) {
|
|
430
429
|
this.typeImports.addKnownType(typeName);
|
|
431
430
|
}
|
|
432
431
|
else {
|
package/cjs/generator/index.js
CHANGED
|
@@ -14,13 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./TypesGen"), exports);
|
|
18
|
-
__exportStar(require("./ApiGen"), exports);
|
|
19
|
-
__exportStar(require("./ConstsGen"), exports);
|
|
20
|
-
__exportStar(require("./QueryGen"), exports);
|
|
21
|
-
__exportStar(require("./RpcGen"), exports);
|
|
22
|
-
__exportStar(require("./IndexGen"), exports);
|
|
23
|
-
__exportStar(require("./ErrorsGen"), exports);
|
|
24
|
-
__exportStar(require("./EventsGen"), exports);
|
|
25
|
-
__exportStar(require("./TxGen"), exports);
|
|
26
|
-
__exportStar(require("./RuntimeApisGen"), exports);
|
|
17
|
+
__exportStar(require("./TypesGen.js"), exports);
|
|
18
|
+
__exportStar(require("./ApiGen.js"), exports);
|
|
19
|
+
__exportStar(require("./ConstsGen.js"), exports);
|
|
20
|
+
__exportStar(require("./QueryGen.js"), exports);
|
|
21
|
+
__exportStar(require("./RpcGen.js"), exports);
|
|
22
|
+
__exportStar(require("./IndexGen.js"), exports);
|
|
23
|
+
__exportStar(require("./ErrorsGen.js"), exports);
|
|
24
|
+
__exportStar(require("./EventsGen.js"), exports);
|
|
25
|
+
__exportStar(require("./TxGen.js"), exports);
|
|
26
|
+
__exportStar(require("./RuntimeApisGen.js"), exports);
|
package/cjs/generator/utils.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.isReservedWord = exports.compileTemplate = exports.beautifySourceCode = exports.commentBlock = exports.TUPLE_TYPE_REGEX = exports.WRAPPER_TYPE_REGEX = void 0;
|
|
29
|
+
exports.isNativeType = exports.isReservedWord = exports.compileTemplate = exports.beautifySourceCode = exports.commentBlock = exports.TUPLE_TYPE_REGEX = exports.WRAPPER_TYPE_REGEX = void 0;
|
|
30
30
|
const fs = __importStar(require("fs"));
|
|
31
31
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
32
32
|
const path = __importStar(require("path"));
|
|
@@ -66,3 +66,32 @@ const TS_RESERVED_WORDS = ['new', 'class'];
|
|
|
66
66
|
*/
|
|
67
67
|
const isReservedWord = (word) => TS_RESERVED_WORDS.includes(word);
|
|
68
68
|
exports.isReservedWord = isReservedWord;
|
|
69
|
+
const TS_PRIMITIVE_TYPES = [
|
|
70
|
+
'void',
|
|
71
|
+
'undefined',
|
|
72
|
+
'null',
|
|
73
|
+
'number',
|
|
74
|
+
'boolean',
|
|
75
|
+
'bigint',
|
|
76
|
+
'Map',
|
|
77
|
+
'Set',
|
|
78
|
+
'string',
|
|
79
|
+
'any',
|
|
80
|
+
'Array',
|
|
81
|
+
'Record',
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* Check if a type is native JS/TS type
|
|
85
|
+
* @param type
|
|
86
|
+
*/
|
|
87
|
+
const isNativeType = (type) => {
|
|
88
|
+
return TS_PRIMITIVE_TYPES.some((one) => {
|
|
89
|
+
if (typeof one === 'string') {
|
|
90
|
+
return one === type;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return type.match(one);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
exports.isNativeType = isNativeType;
|
package/cjs/index.js
CHANGED
|
@@ -27,14 +27,14 @@ exports.generateTypes = exports.generateTypesFromChain = void 0;
|
|
|
27
27
|
const dedot_1 = require("dedot");
|
|
28
28
|
const fs = __importStar(require("fs"));
|
|
29
29
|
const path = __importStar(require("path"));
|
|
30
|
-
const
|
|
31
|
-
const
|
|
30
|
+
const index_js_1 = require("./generator/index.js");
|
|
31
|
+
const utils_1 = require("@dedot/utils");
|
|
32
32
|
async function generateTypesFromChain(network, endpoint, outDir) {
|
|
33
33
|
const api = await dedot_1.Dedot.create(endpoint);
|
|
34
34
|
const { methods } = await api.rpc.rpc.methods();
|
|
35
35
|
const apis = api.runtimeVersion?.apis || [];
|
|
36
36
|
if (!network.chain) {
|
|
37
|
-
network.chain = (0,
|
|
37
|
+
network.chain = (0, utils_1.stringCamelCase)(api.runtimeVersion?.specName || api.runtimeChain || 'local');
|
|
38
38
|
}
|
|
39
39
|
await generateTypes(network, api.metadataLatest, methods, apis, outDir);
|
|
40
40
|
await api.disconnect();
|
|
@@ -54,15 +54,15 @@ async function generateTypes(network, metadata, rpcMethods, runtimeApis, outDir
|
|
|
54
54
|
if (!fs.existsSync(dirPath)) {
|
|
55
55
|
fs.mkdirSync(dirPath, { recursive: true });
|
|
56
56
|
}
|
|
57
|
-
const typesGen = new
|
|
58
|
-
const constsGen = new
|
|
59
|
-
const queryGen = new
|
|
60
|
-
const rpcGen = new
|
|
61
|
-
const indexGen = new
|
|
62
|
-
const errorsGen = new
|
|
63
|
-
const eventsGen = new
|
|
64
|
-
const runtimeApisGen = new
|
|
65
|
-
const txGen = new
|
|
57
|
+
const typesGen = new index_js_1.TypesGen(metadata);
|
|
58
|
+
const constsGen = new index_js_1.ConstsGen(typesGen);
|
|
59
|
+
const queryGen = new index_js_1.QueryGen(typesGen);
|
|
60
|
+
const rpcGen = new index_js_1.RpcGen(typesGen, rpcMethods);
|
|
61
|
+
const indexGen = new index_js_1.IndexGen(network);
|
|
62
|
+
const errorsGen = new index_js_1.ErrorsGen(typesGen);
|
|
63
|
+
const eventsGen = new index_js_1.EventsGen(typesGen);
|
|
64
|
+
const runtimeApisGen = new index_js_1.RuntimeApisGen(typesGen, runtimeApis);
|
|
65
|
+
const txGen = new index_js_1.TxGen(typesGen);
|
|
66
66
|
fs.writeFileSync(defTypesFileName, await typesGen.generate());
|
|
67
67
|
fs.writeFileSync(errorsFileName, await errorsGen.generate());
|
|
68
68
|
fs.writeFileSync(eventsFileName, await eventsGen.generate());
|
package/cjs/packageInfo.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.packageInfo = void 0;
|
|
5
|
-
exports.packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.
|
|
5
|
+
exports.packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.28' };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateTypes, generateTypesFromChain } from './index';
|
|
1
|
+
import { generateTypes, generateTypesFromChain } from './index.js';
|
|
2
2
|
import { rpc } from '@polkadot/types-support/metadata/static-substrate';
|
|
3
3
|
import staticSubstrate from '@polkadot/types-support/metadata/v15/substrate-hex';
|
|
4
4
|
import { $Metadata, PortableRegistry } from '@dedot/codecs';
|
package/generator/ApiGen.d.ts
CHANGED
package/generator/ConstsGen.d.ts
CHANGED
package/generator/ConstsGen.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { beautifySourceCode, commentBlock, compileTemplate } from './utils';
|
|
1
|
+
import { normalizeName, stringCamelCase } from '@dedot/utils';
|
|
2
|
+
import { ApiGen } from '../generator/index.js';
|
|
3
|
+
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
5
4
|
export class ConstsGen extends ApiGen {
|
|
6
5
|
generate() {
|
|
7
6
|
const { pallets } = this.metadata;
|
|
@@ -15,7 +14,7 @@ export class ConstsGen extends ApiGen {
|
|
|
15
14
|
docs: one.docs,
|
|
16
15
|
}));
|
|
17
16
|
defTypeOut += commentBlock(`Pallet \`${pallet.name}\`'s constants`);
|
|
18
|
-
defTypeOut += `${
|
|
17
|
+
defTypeOut += `${stringCamelCase(pallet.name)}: {
|
|
19
18
|
${typedConstants.map(({ name, type, docs }) => `${commentBlock(docs)}${name}: ${type}`).join(',\n')}
|
|
20
19
|
|
|
21
20
|
${commentBlock('Generic pallet constant')}[name: string]: any,
|
package/generator/ErrorsGen.d.ts
CHANGED
package/generator/ErrorsGen.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ApiGen } from './ApiGen';
|
|
2
|
-
import { beautifySourceCode, commentBlock, compileTemplate } from './utils';
|
|
3
|
-
import { stringCamelCase, stringPascalCase } from '@
|
|
4
|
-
import { assert } from '@dedot/utils';
|
|
1
|
+
import { ApiGen } from './ApiGen.js';
|
|
2
|
+
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
3
|
+
import { assert, stringCamelCase, stringPascalCase } from '@dedot/utils';
|
|
5
4
|
export class ErrorsGen extends ApiGen {
|
|
6
5
|
generate() {
|
|
7
6
|
const { pallets } = this.metadata;
|
package/generator/EventsGen.d.ts
CHANGED
package/generator/EventsGen.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ApiGen } from './ApiGen';
|
|
2
|
-
import { beautifySourceCode, commentBlock, compileTemplate } from './utils';
|
|
3
|
-
import { stringCamelCase, stringPascalCase } from '@
|
|
4
|
-
import { assert } from '@dedot/utils';
|
|
1
|
+
import { ApiGen } from './ApiGen.js';
|
|
2
|
+
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
3
|
+
import { assert, stringCamelCase, stringPascalCase } from '@dedot/utils';
|
|
5
4
|
export class EventsGen extends ApiGen {
|
|
6
5
|
generate() {
|
|
7
6
|
const { pallets } = this.metadata;
|
package/generator/IndexGen.d.ts
CHANGED
package/generator/IndexGen.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { beautifySourceCode, compileTemplate } from './utils';
|
|
2
|
-
import { stringPascalCase } from '@
|
|
1
|
+
import { beautifySourceCode, compileTemplate } from './utils.js';
|
|
2
|
+
import { stringPascalCase } from '@dedot/utils';
|
|
3
3
|
export class IndexGen {
|
|
4
4
|
networkInfo;
|
|
5
5
|
constructor(networkInfo) {
|
package/generator/QueryGen.d.ts
CHANGED
package/generator/QueryGen.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { beautifySourceCode, commentBlock, compileTemplate } from './utils';
|
|
1
|
+
import { normalizeName, stringCamelCase } from '@dedot/utils';
|
|
2
|
+
import { ApiGen } from '../generator/index.js';
|
|
3
|
+
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
5
4
|
export class QueryGen extends ApiGen {
|
|
6
5
|
generate() {
|
|
7
6
|
const { pallets } = this.metadata;
|
|
@@ -15,7 +14,7 @@ export class QueryGen extends ApiGen {
|
|
|
15
14
|
const queries = storage.entries.map((one) => this.#generateEntry(one));
|
|
16
15
|
const queryDefs = queries.map(({ name, valueType, keyType, docs }) => `${commentBlock(docs)}${name}: GenericStorageQuery<(${keyType}) => ${valueType}>`);
|
|
17
16
|
defTypeOut += commentBlock(`Pallet \`${pallet.name}\`'s storage queries`);
|
|
18
|
-
defTypeOut += `${
|
|
17
|
+
defTypeOut += `${stringCamelCase(pallet.name)}: {
|
|
19
18
|
${queryDefs.join(',\n')}
|
|
20
19
|
|
|
21
20
|
${commentBlock('Generic pallet storage query')}[storage: string]: GenericStorageQuery;
|
package/generator/RpcGen.d.ts
CHANGED
package/generator/RpcGen.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { findAliasRpcSpec, findRpcSpec, isUnsubscribeMethod } from '@dedot/specs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { findKnownCodecType } from './known-codecs';
|
|
2
|
+
import { ApiGen } from '../generator/index.js';
|
|
3
|
+
import { isNativeType, beautifySourceCode, commentBlock, compileTemplate, TUPLE_TYPE_REGEX, WRAPPER_TYPE_REGEX, } from './utils.js';
|
|
4
|
+
import { findKnownCodecType } from './known-codecs.js';
|
|
6
5
|
const HIDDEN_RPCS = [
|
|
7
6
|
// Ref: https://github.com/paritytech/polkadot-sdk/blob/43415ef58c143b985e09015cd000dbd65f6d3997/substrate/client/rpc-servers/src/lib.rs#L152C9-L158
|
|
8
7
|
'rpc_methods',
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { getRuntimeApiNames, getRuntimeApiSpecs } from '@dedot/specs';
|
|
2
|
-
import { beautifySourceCode, commentBlock, compileTemplate } from './utils';
|
|
3
|
-
import {
|
|
4
|
-
import { RpcGen } from './RpcGen';
|
|
5
|
-
import { stringCamelCase } from '@polkadot/util';
|
|
2
|
+
import { beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
3
|
+
import { calcRuntimeApiHash, stringSnakeCase, stringCamelCase } from '@dedot/utils';
|
|
4
|
+
import { RpcGen } from './RpcGen.js';
|
|
6
5
|
export class RuntimeApisGen extends RpcGen {
|
|
7
6
|
typesGen;
|
|
8
7
|
runtimeApis;
|
|
@@ -18,7 +17,7 @@ export class RuntimeApisGen extends RpcGen {
|
|
|
18
17
|
if (this.metadata.apis.length > 0) {
|
|
19
18
|
this.metadata.apis.forEach((runtimeApi) => {
|
|
20
19
|
const { name: runtimeApiName, methods } = runtimeApi;
|
|
21
|
-
runtimeCallsOut += commentBlock(`@runtimeapi: ${runtimeApiName} - ${
|
|
20
|
+
runtimeCallsOut += commentBlock(`@runtimeapi: ${runtimeApiName} - ${calcRuntimeApiHash(runtimeApiName)}`);
|
|
22
21
|
runtimeCallsOut += `${stringCamelCase(runtimeApiName)}: {
|
|
23
22
|
${methods.map((method) => this.#generateMethodDef(runtimeApiName, method)).join('\n')}
|
|
24
23
|
|
|
@@ -109,7 +108,7 @@ export class RuntimeApisGen extends RpcGen {
|
|
|
109
108
|
}, []);
|
|
110
109
|
}
|
|
111
110
|
#findRuntimeApiSpec = (runtimeApiHash, version) => {
|
|
112
|
-
const runtimeApiName = getRuntimeApiNames().find((one) =>
|
|
111
|
+
const runtimeApiName = getRuntimeApiNames().find((one) => calcRuntimeApiHash(one) === runtimeApiHash);
|
|
113
112
|
return getRuntimeApiSpecs().find((one) => one.runtimeApiName === runtimeApiName && one.version === version);
|
|
114
113
|
};
|
|
115
114
|
}
|
package/generator/TxGen.d.ts
CHANGED
package/generator/TxGen.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ApiGen } from '../generator';
|
|
2
|
-
import { stringCamelCase, stringPascalCase } from '@
|
|
3
|
-
import { beautifySourceCode, commentBlock, compileTemplate, isReservedWord } from './utils';
|
|
1
|
+
import { ApiGen } from '../generator/index.js';
|
|
2
|
+
import { stringCamelCase, stringPascalCase } from '@dedot/utils';
|
|
3
|
+
import { beautifySourceCode, commentBlock, compileTemplate, isReservedWord } from './utils.js';
|
|
4
4
|
export class TxGen extends ApiGen {
|
|
5
5
|
generate() {
|
|
6
6
|
const { pallets, types } = this.metadata;
|
package/generator/TypesGen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PortableRegistry, Field, MetadataLatest, PortableType, TypeId } from '@dedot/codecs';
|
|
2
|
-
import { TypeImports } from './TypeImports';
|
|
2
|
+
import { TypeImports } from './TypeImports.js';
|
|
3
3
|
interface NamedType extends PortableType {
|
|
4
4
|
name: string;
|
|
5
5
|
nameOut: string;
|
package/generator/TypesGen.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { stringPascalCase } from '@polkadot/util';
|
|
2
1
|
import { PortableRegistry } from '@dedot/codecs';
|
|
3
|
-
import {
|
|
4
|
-
import { beautifySourceCode, commentBlock, compileTemplate } from './utils';
|
|
5
|
-
import { knownTypes } from './known-types';
|
|
6
|
-
import { TypeImports } from './TypeImports';
|
|
7
|
-
import { findKnownCodec, findKnownCodecType, isKnownCodecType } from './known-codecs';
|
|
2
|
+
import { normalizeName, stringPascalCase } from '@dedot/utils';
|
|
3
|
+
import { isNativeType, beautifySourceCode, commentBlock, compileTemplate } from './utils.js';
|
|
4
|
+
import { knownTypes } from './known-types.js';
|
|
5
|
+
import { TypeImports } from './TypeImports.js';
|
|
6
|
+
import { findKnownCodec, findKnownCodecType, isKnownCodecType } from './known-codecs.js';
|
|
8
7
|
// Skip generate types for these
|
|
9
8
|
// as we do have native types for them
|
|
10
9
|
const SKIP_TYPES = [
|
package/generator/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './TypesGen';
|
|
2
|
-
export * from './ApiGen';
|
|
3
|
-
export * from './ConstsGen';
|
|
4
|
-
export * from './QueryGen';
|
|
5
|
-
export * from './RpcGen';
|
|
6
|
-
export * from './IndexGen';
|
|
7
|
-
export * from './ErrorsGen';
|
|
8
|
-
export * from './EventsGen';
|
|
9
|
-
export * from './TxGen';
|
|
10
|
-
export * from './RuntimeApisGen';
|
|
1
|
+
export * from './TypesGen.js';
|
|
2
|
+
export * from './ApiGen.js';
|
|
3
|
+
export * from './ConstsGen.js';
|
|
4
|
+
export * from './QueryGen.js';
|
|
5
|
+
export * from './RpcGen.js';
|
|
6
|
+
export * from './IndexGen.js';
|
|
7
|
+
export * from './ErrorsGen.js';
|
|
8
|
+
export * from './EventsGen.js';
|
|
9
|
+
export * from './TxGen.js';
|
|
10
|
+
export * from './RuntimeApisGen.js';
|
package/generator/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from './TypesGen';
|
|
2
|
-
export * from './ApiGen';
|
|
3
|
-
export * from './ConstsGen';
|
|
4
|
-
export * from './QueryGen';
|
|
5
|
-
export * from './RpcGen';
|
|
6
|
-
export * from './IndexGen';
|
|
7
|
-
export * from './ErrorsGen';
|
|
8
|
-
export * from './EventsGen';
|
|
9
|
-
export * from './TxGen';
|
|
10
|
-
export * from './RuntimeApisGen';
|
|
1
|
+
export * from './TypesGen.js';
|
|
2
|
+
export * from './ApiGen.js';
|
|
3
|
+
export * from './ConstsGen.js';
|
|
4
|
+
export * from './QueryGen.js';
|
|
5
|
+
export * from './RpcGen.js';
|
|
6
|
+
export * from './IndexGen.js';
|
|
7
|
+
export * from './ErrorsGen.js';
|
|
8
|
+
export * from './EventsGen.js';
|
|
9
|
+
export * from './TxGen.js';
|
|
10
|
+
export * from './RuntimeApisGen.js';
|
package/generator/utils.d.ts
CHANGED
|
@@ -8,3 +8,8 @@ export declare const compileTemplate: (templateFileName: string) => HandlebarsTe
|
|
|
8
8
|
* @param word
|
|
9
9
|
*/
|
|
10
10
|
export declare const isReservedWord: (word: string) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a type is native JS/TS type
|
|
13
|
+
* @param type
|
|
14
|
+
*/
|
|
15
|
+
export declare const isNativeType: (type: string) => boolean;
|
package/generator/utils.js
CHANGED
|
@@ -33,3 +33,31 @@ const TS_RESERVED_WORDS = ['new', 'class'];
|
|
|
33
33
|
* @param word
|
|
34
34
|
*/
|
|
35
35
|
export const isReservedWord = (word) => TS_RESERVED_WORDS.includes(word);
|
|
36
|
+
const TS_PRIMITIVE_TYPES = [
|
|
37
|
+
'void',
|
|
38
|
+
'undefined',
|
|
39
|
+
'null',
|
|
40
|
+
'number',
|
|
41
|
+
'boolean',
|
|
42
|
+
'bigint',
|
|
43
|
+
'Map',
|
|
44
|
+
'Set',
|
|
45
|
+
'string',
|
|
46
|
+
'any',
|
|
47
|
+
'Array',
|
|
48
|
+
'Record',
|
|
49
|
+
];
|
|
50
|
+
/**
|
|
51
|
+
* Check if a type is native JS/TS type
|
|
52
|
+
* @param type
|
|
53
|
+
*/
|
|
54
|
+
export const isNativeType = (type) => {
|
|
55
|
+
return TS_PRIMITIVE_TYPES.some((one) => {
|
|
56
|
+
if (typeof one === 'string') {
|
|
57
|
+
return one === type;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return type.match(one);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { MetadataLatest } from '@dedot/codecs';
|
|
2
|
-
import { NetworkInfo } from './types';
|
|
2
|
+
import { NetworkInfo } from './types.js';
|
|
3
3
|
export declare function generateTypesFromChain(network: NetworkInfo, endpoint: string, outDir: string): Promise<void>;
|
|
4
4
|
export declare function generateTypes(network: NetworkInfo, metadata: MetadataLatest, rpcMethods: string[], runtimeApis: any[], outDir?: string): Promise<void>;
|
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Dedot } from 'dedot';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
-
import { ConstsGen, ErrorsGen, EventsGen, IndexGen, QueryGen, RpcGen, RuntimeApisGen, TxGen, TypesGen, } from './generator';
|
|
5
|
-
import { stringCamelCase } from '@
|
|
4
|
+
import { ConstsGen, ErrorsGen, EventsGen, IndexGen, QueryGen, RpcGen, RuntimeApisGen, TxGen, TypesGen, } from './generator/index.js';
|
|
5
|
+
import { stringCamelCase } from '@dedot/utils';
|
|
6
6
|
export async function generateTypesFromChain(network, endpoint, outDir) {
|
|
7
7
|
const api = await Dedot.create(endpoint);
|
|
8
8
|
const { methods } = await api.rpc.rpc.methods();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/codegen",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.41a5fa17.16+41a5fa1",
|
|
4
4
|
"description": "Generate types",
|
|
5
5
|
"author": "Thang X. Vu <thang@coongcrafts.io>",
|
|
6
6
|
"homepage": "https://github.com/dedotdev/dedot/tree/main/packages/codegen",
|
|
@@ -18,12 +18,11 @@
|
|
|
18
18
|
"copy": "cp -R ./src/templates ./dist && cp -R ./src/templates ./dist/cjs"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dedot/codecs": "0.0.1-next.
|
|
22
|
-
"@dedot/shape": "0.0.1-next.
|
|
23
|
-
"@dedot/specs": "0.0.1-next.
|
|
24
|
-
"@dedot/utils": "0.0.1-next.
|
|
25
|
-
"
|
|
26
|
-
"dedot": "0.0.1-next.3f5dd645.0+3f5dd64",
|
|
21
|
+
"@dedot/codecs": "0.0.1-next.41a5fa17.16+41a5fa1",
|
|
22
|
+
"@dedot/shape": "0.0.1-next.41a5fa17.16+41a5fa1",
|
|
23
|
+
"@dedot/specs": "0.0.1-next.41a5fa17.16+41a5fa1",
|
|
24
|
+
"@dedot/utils": "0.0.1-next.41a5fa17.16+41a5fa1",
|
|
25
|
+
"dedot": "0.0.1-next.41a5fa17.16+41a5fa1",
|
|
27
26
|
"handlebars": "^4.7.8",
|
|
28
27
|
"prettier": "^3.0.3"
|
|
29
28
|
},
|
|
@@ -32,7 +31,7 @@
|
|
|
32
31
|
"directory": "dist"
|
|
33
32
|
},
|
|
34
33
|
"license": "Apache-2.0",
|
|
35
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "41a5fa17e0b5721f8505271acfcbe4c94c0c8ca5",
|
|
36
35
|
"module": "./index.js",
|
|
37
36
|
"types": "./index.d.ts",
|
|
38
37
|
"exports": {
|
package/packageInfo.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
|
|
2
|
-
export const packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.
|
|
2
|
+
export const packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.28' };
|