@dedot/codegen 0.0.1-alpha.8 → 0.0.1-next.0

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.
@@ -30,18 +30,20 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
30
30
  });
31
31
  }
32
32
  else {
33
- const specsByModule = this.#runtimeApisSpecsByModule();
34
- Object.values(specsByModule).forEach((specs) => {
35
- specs.forEach(({ methods, runtimeApiName, runtimeApiHash, version }) => {
36
- runtimeCallsOut += (0, utils_1.commentBlock)(`@runtimeapi: ${runtimeApiName} - ${runtimeApiHash}`, `@version: ${version}`);
37
- runtimeCallsOut += `${(0, util_1.stringCamelCase)(runtimeApiName)}: {
33
+ const specs = this.#targetRuntimeApiSpecs();
34
+ specs.forEach(({ methods, runtimeApiName, runtimeApiHash, version }) => {
35
+ runtimeCallsOut += (0, utils_1.commentBlock)(`@runtimeapi: ${runtimeApiName} - ${runtimeApiHash}`, `@version: ${version}`);
36
+ runtimeCallsOut += `${(0, util_1.stringCamelCase)(runtimeApiName)}: {
38
37
  ${Object.keys(methods)
39
- .map((methodName) => this.#generateMethodDefFromSpec({ ...methods[methodName], runtimeApiName, methodName }))
40
- .join('\n')}
38
+ .map((methodName) => this.#generateMethodDefFromSpec({
39
+ ...methods[methodName],
40
+ runtimeApiName,
41
+ methodName,
42
+ }))
43
+ .join('\n')}
41
44
 
42
45
  ${(0, utils_1.commentBlock)('Generic runtime api call')}[method: string]: GenericRuntimeApiMethod
43
46
  }`;
44
- });
45
47
  });
46
48
  }
47
49
  const importTypes = this.typesGen.typeImports.toImports();
@@ -92,7 +94,7 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
92
94
  .join(', ');
93
95
  return `${(0, utils_1.commentBlock)(docs, '\n', defaultDocs, typedInputs.map(({ type, name }) => `@param {${type}} ${name}`))}${(0, util_1.stringCamelCase)(methodName)}: GenericRuntimeApiMethod<(${paramsOut}) => Promise<${typeOut}>>`;
94
96
  }
95
- #runtimeApisSpecsByModule() {
97
+ #targetRuntimeApiSpecs() {
96
98
  const specs = this.runtimeApis.map(([runtimeApiHash, version]) => {
97
99
  const runtimeApiSpec = (0, specs_1.findRuntimeApiSpec)(runtimeApiHash, version);
98
100
  if (!runtimeApiSpec)
@@ -106,15 +108,8 @@ class RuntimeApisGen extends RpcGen_1.RpcGen {
106
108
  if (!spec) {
107
109
  return o;
108
110
  }
109
- const { moduleName } = spec;
110
- if (!moduleName) {
111
- return o;
112
- }
113
- return {
114
- ...o,
115
- [moduleName]: o[moduleName] ? [...o[moduleName], spec] : [spec],
116
- };
117
- }, {});
111
+ return [...o, spec];
112
+ }, []);
118
113
  }
119
114
  }
120
115
  exports.RuntimeApisGen = RuntimeApisGen;
package/cjs/index.js CHANGED
@@ -42,15 +42,15 @@ async function generateTypesFromChain(network, endpoint, outDir) {
42
42
  exports.generateTypesFromChain = generateTypesFromChain;
43
43
  async function generateTypes(network, metadata, rpcMethods, runtimeApis, outDir = '.') {
44
44
  const dirPath = path.resolve(outDir, network.chain);
45
- const defTypesFileName = path.join(dirPath, `types.ts`);
46
- const constsTypesFileName = path.join(dirPath, `consts.ts`);
47
- const queryTypesFileName = path.join(dirPath, `query.ts`);
48
- const rpcCallsFileName = path.join(dirPath, `rpc.ts`);
49
- const indexFileName = path.join(dirPath, `index.ts`);
50
- const errorsFileName = path.join(dirPath, `errors.ts`);
51
- const eventsFileName = path.join(dirPath, `events.ts`);
52
- const runtimeApisFileName = path.join(dirPath, `runtime.ts`);
53
- const txFileName = path.join(dirPath, `tx.ts`);
45
+ const defTypesFileName = path.join(dirPath, `types.d.ts`);
46
+ const constsTypesFileName = path.join(dirPath, `consts.d.ts`);
47
+ const queryTypesFileName = path.join(dirPath, `query.d.ts`);
48
+ const rpcCallsFileName = path.join(dirPath, `rpc.d.ts`);
49
+ const indexFileName = path.join(dirPath, `index.d.ts`);
50
+ const errorsFileName = path.join(dirPath, `errors.d.ts`);
51
+ const eventsFileName = path.join(dirPath, `events.d.ts`);
52
+ const runtimeApisFileName = path.join(dirPath, `runtime.d.ts`);
53
+ const txFileName = path.join(dirPath, `tx.d.ts`);
54
54
  if (!fs.existsSync(dirPath)) {
55
55
  fs.mkdirSync(dirPath, { recursive: true });
56
56
  }
@@ -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.24' };
5
+ exports.packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.25' };
@@ -27,18 +27,20 @@ export class RuntimeApisGen extends RpcGen {
27
27
  });
28
28
  }
29
29
  else {
30
- const specsByModule = this.#runtimeApisSpecsByModule();
31
- Object.values(specsByModule).forEach((specs) => {
32
- specs.forEach(({ methods, runtimeApiName, runtimeApiHash, version }) => {
33
- runtimeCallsOut += commentBlock(`@runtimeapi: ${runtimeApiName} - ${runtimeApiHash}`, `@version: ${version}`);
34
- runtimeCallsOut += `${stringCamelCase(runtimeApiName)}: {
30
+ const specs = this.#targetRuntimeApiSpecs();
31
+ specs.forEach(({ methods, runtimeApiName, runtimeApiHash, version }) => {
32
+ runtimeCallsOut += commentBlock(`@runtimeapi: ${runtimeApiName} - ${runtimeApiHash}`, `@version: ${version}`);
33
+ runtimeCallsOut += `${stringCamelCase(runtimeApiName)}: {
35
34
  ${Object.keys(methods)
36
- .map((methodName) => this.#generateMethodDefFromSpec({ ...methods[methodName], runtimeApiName, methodName }))
37
- .join('\n')}
35
+ .map((methodName) => this.#generateMethodDefFromSpec({
36
+ ...methods[methodName],
37
+ runtimeApiName,
38
+ methodName,
39
+ }))
40
+ .join('\n')}
38
41
 
39
42
  ${commentBlock('Generic runtime api call')}[method: string]: GenericRuntimeApiMethod
40
43
  }`;
41
- });
42
44
  });
43
45
  }
44
46
  const importTypes = this.typesGen.typeImports.toImports();
@@ -89,7 +91,7 @@ export class RuntimeApisGen extends RpcGen {
89
91
  .join(', ');
90
92
  return `${commentBlock(docs, '\n', defaultDocs, typedInputs.map(({ type, name }) => `@param {${type}} ${name}`))}${stringCamelCase(methodName)}: GenericRuntimeApiMethod<(${paramsOut}) => Promise<${typeOut}>>`;
91
93
  }
92
- #runtimeApisSpecsByModule() {
94
+ #targetRuntimeApiSpecs() {
93
95
  const specs = this.runtimeApis.map(([runtimeApiHash, version]) => {
94
96
  const runtimeApiSpec = findRuntimeApiSpec(runtimeApiHash, version);
95
97
  if (!runtimeApiSpec)
@@ -103,14 +105,7 @@ export class RuntimeApisGen extends RpcGen {
103
105
  if (!spec) {
104
106
  return o;
105
107
  }
106
- const { moduleName } = spec;
107
- if (!moduleName) {
108
- return o;
109
- }
110
- return {
111
- ...o,
112
- [moduleName]: o[moduleName] ? [...o[moduleName], spec] : [spec],
113
- };
114
- }, {});
108
+ return [...o, spec];
109
+ }, []);
115
110
  }
116
111
  }
package/index.js CHANGED
@@ -15,15 +15,15 @@ export async function generateTypesFromChain(network, endpoint, outDir) {
15
15
  }
16
16
  export async function generateTypes(network, metadata, rpcMethods, runtimeApis, outDir = '.') {
17
17
  const dirPath = path.resolve(outDir, network.chain);
18
- const defTypesFileName = path.join(dirPath, `types.ts`);
19
- const constsTypesFileName = path.join(dirPath, `consts.ts`);
20
- const queryTypesFileName = path.join(dirPath, `query.ts`);
21
- const rpcCallsFileName = path.join(dirPath, `rpc.ts`);
22
- const indexFileName = path.join(dirPath, `index.ts`);
23
- const errorsFileName = path.join(dirPath, `errors.ts`);
24
- const eventsFileName = path.join(dirPath, `events.ts`);
25
- const runtimeApisFileName = path.join(dirPath, `runtime.ts`);
26
- const txFileName = path.join(dirPath, `tx.ts`);
18
+ const defTypesFileName = path.join(dirPath, `types.d.ts`);
19
+ const constsTypesFileName = path.join(dirPath, `consts.d.ts`);
20
+ const queryTypesFileName = path.join(dirPath, `query.d.ts`);
21
+ const rpcCallsFileName = path.join(dirPath, `rpc.d.ts`);
22
+ const indexFileName = path.join(dirPath, `index.d.ts`);
23
+ const errorsFileName = path.join(dirPath, `errors.d.ts`);
24
+ const eventsFileName = path.join(dirPath, `events.d.ts`);
25
+ const runtimeApisFileName = path.join(dirPath, `runtime.d.ts`);
26
+ const txFileName = path.join(dirPath, `tx.d.ts`);
27
27
  if (!fs.existsSync(dirPath)) {
28
28
  fs.mkdirSync(dirPath, { recursive: true });
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dedot/codegen",
3
- "version": "0.0.1-alpha.8+a951731",
3
+ "version": "0.0.1-next.0+44b180e",
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",
@@ -17,12 +17,12 @@
17
17
  "copy": "cp -R ./src/templates ./dist && cp -R ./src/templates ./dist/cjs"
18
18
  },
19
19
  "dependencies": {
20
- "@dedot/codecs": "0.0.1-alpha.8+a951731",
21
- "@dedot/shape": "0.0.1-alpha.8+a951731",
22
- "@dedot/specs": "0.0.1-alpha.8+a951731",
23
- "@dedot/utils": "0.0.1-alpha.8+a951731",
20
+ "@dedot/codecs": "0.0.1-next.0+44b180e",
21
+ "@dedot/shape": "0.0.1-next.0+44b180e",
22
+ "@dedot/specs": "0.0.1-next.0+44b180e",
23
+ "@dedot/utils": "0.0.1-next.0+44b180e",
24
24
  "@polkadot/util": "^12.6.2",
25
- "dedot": "0.0.1-alpha.8+a951731",
25
+ "dedot": "0.0.1-next.0+44b180e",
26
26
  "handlebars": "^4.7.8",
27
27
  "prettier": "^3.0.3"
28
28
  },
@@ -31,7 +31,7 @@
31
31
  "directory": "dist"
32
32
  },
33
33
  "license": "Apache-2.0",
34
- "gitHead": "a951731c63fd9a09b3e9e90cb424ec152fb3abdd",
34
+ "gitHead": "44b180e85a3126e45dcf408fcb3d32adc4bedeca",
35
35
  "module": "./index.js",
36
36
  "types": "./index.d.ts",
37
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.24' };
2
+ export const packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.25' };