@cosmwasm/ts-codegen 1.9.0 → 1.10.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.
- package/builder/builder.d.ts +1 -1
- package/builder/builder.js +12 -12
- package/cli.d.ts +1 -0
- package/cli.js +2 -2
- package/commands/create-boilerplate.d.ts +1 -0
- package/commands/create-boilerplate.js +1 -1
- package/commands/generate.d.ts +1 -0
- package/commands/generate.js +1 -2
- package/commands/install.d.ts +1 -0
- package/commands/install.js +5 -5
- package/esm/builder/builder.js +19 -19
- package/esm/bundler/bundler.js +1 -1
- package/esm/cli.js +2 -2
- package/esm/commands/create-boilerplate.js +1 -1
- package/esm/commands/generate.js +1 -2
- package/esm/commands/install.js +5 -5
- package/esm/file.js +2 -2
- package/esm/helpers/create-helpers.js +9 -9
- package/esm/index.js +1 -1
- package/esm/plugins/client.js +9 -9
- package/esm/plugins/index.js +7 -7
- package/esm/plugins/message-builder.js +2 -2
- package/esm/plugins/message-composer.js +9 -9
- package/esm/plugins/plugin-base.js +9 -9
- package/esm/plugins/provider-bundle.js +20 -20
- package/esm/plugins/provider.js +12 -12
- package/esm/plugins/react-query.js +2 -2
- package/esm/plugins/recoil.js +2 -2
- package/esm/plugins/types.js +3 -3
- package/esm/ts-codegen.js +1 -1
- package/esm/utils/clean.js +3 -3
- package/esm/utils/cleanse.js +7 -7
- package/esm/utils/files.js +15 -15
- package/esm/utils/header.js +1 -1
- package/esm/utils/package.js +2 -2
- package/esm/utils/parse.js +1 -1
- package/esm/utils/prompt.js +4 -4
- package/esm/utils/schemas.js +6 -3
- package/file.js +2 -2
- package/helpers/create-helpers.d.ts +2 -1
- package/helpers/create-helpers.js +6 -6
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +6 -5
- package/plugins/client.d.ts +3 -3
- package/plugins/client.js +6 -6
- package/plugins/index.d.ts +7 -7
- package/plugins/index.js +3 -3
- package/plugins/message-builder.d.ts +1 -1
- package/plugins/message-builder.js +2 -2
- package/plugins/message-composer.d.ts +3 -3
- package/plugins/message-composer.js +6 -6
- package/plugins/plugin-base.d.ts +4 -4
- package/plugins/plugin-base.js +6 -6
- package/plugins/provider-bundle.d.ts +3 -3
- package/plugins/provider-bundle.js +16 -16
- package/plugins/provider.d.ts +3 -3
- package/plugins/provider.js +9 -9
- package/plugins/react-query.d.ts +1 -1
- package/plugins/react-query.js +2 -2
- package/plugins/recoil.d.ts +1 -1
- package/plugins/recoil.js +2 -2
- package/plugins/types.js +2 -2
- package/ts-codegen.js +1 -1
- package/utils/clean.js +3 -3
- package/utils/cleanse.js +6 -6
- package/utils/contracts.d.ts +1 -0
- package/utils/files.d.ts +1 -1
- package/utils/files.js +11 -11
- package/utils/package.js +1 -1
- package/utils/parse.js +1 -1
- package/utils/prompt.d.ts +2 -2
- package/utils/prompt.js +4 -4
- package/utils/schemas.d.ts +1 -1
- package/utils/schemas.js +6 -3
package/plugins/react-query.js
CHANGED
@@ -24,10 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
26
|
exports.ReactQueryPlugin = void 0;
|
27
|
-
const case_1 = require("case");
|
28
27
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
29
|
-
const utils_1 = require("../utils");
|
30
28
|
const ts_codegen_ast_1 = require("@cosmwasm/ts-codegen-ast");
|
29
|
+
const case_1 = require("case");
|
30
|
+
const utils_1 = require("../utils");
|
31
31
|
const plugin_base_1 = require("./plugin-base");
|
32
32
|
class ReactQueryPlugin extends plugin_base_1.BuilderPluginBase {
|
33
33
|
initContext(contract, options) {
|
package/plugins/recoil.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ContractInfo, RenderContext, RenderContextBase,
|
1
|
+
import { ContractInfo, RenderContext, RenderContextBase, RenderOptions, UtilMapping } from '@cosmwasm/ts-codegen-ast';
|
2
2
|
import { BuilderFileType } from '../builder';
|
3
3
|
import { BuilderPluginBase } from './plugin-base';
|
4
4
|
export declare class RecoilPlugin extends BuilderPluginBase<RenderOptions> {
|
package/plugins/recoil.js
CHANGED
@@ -24,10 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
26
|
exports.RecoilPlugin = void 0;
|
27
|
-
const case_1 = require("case");
|
28
27
|
const w = __importStar(require("@cosmwasm/ts-codegen-ast"));
|
29
|
-
const utils_1 = require("../utils");
|
30
28
|
const ts_codegen_ast_1 = require("@cosmwasm/ts-codegen-ast");
|
29
|
+
const case_1 = require("case");
|
30
|
+
const utils_1 = require("../utils");
|
31
31
|
const plugin_base_1 = require("./plugin-base");
|
32
32
|
class RecoilPlugin extends plugin_base_1.BuilderPluginBase {
|
33
33
|
utils = {
|
package/plugins/types.js
CHANGED
@@ -25,10 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
26
|
exports.TypesPlugin = void 0;
|
27
27
|
const t = __importStar(require("@babel/types"));
|
28
|
-
const
|
28
|
+
const ts_codegen_ast_1 = require("@cosmwasm/ts-codegen-ast");
|
29
29
|
const case_1 = require("case");
|
30
30
|
const utils_1 = require("../utils");
|
31
|
-
const
|
31
|
+
const clean_1 = require("../utils/clean");
|
32
32
|
const plugin_base_1 = require("./plugin-base");
|
33
33
|
class TypesPlugin extends plugin_base_1.BuilderPluginBase {
|
34
34
|
initContext(contract, options) {
|
package/ts-codegen.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"use strict";
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
4
|
const cli_1 = require("./cli");
|
5
|
-
|
5
|
+
let argv = require('minimist')(process.argv.slice(2));
|
6
6
|
(async () => {
|
7
7
|
await (0, cli_1.cli)(argv);
|
8
8
|
})();
|
package/utils/clean.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.clean = void 0;
|
4
4
|
const clean = (obj) => {
|
5
|
-
|
5
|
+
let copy;
|
6
6
|
// Handle the 3 simple types, and null or undefined
|
7
7
|
if (null == obj || 'object' != typeof obj)
|
8
8
|
return obj;
|
@@ -15,7 +15,7 @@ const clean = (obj) => {
|
|
15
15
|
// Handle Array
|
16
16
|
if (obj instanceof Array) {
|
17
17
|
copy = [];
|
18
|
-
for (
|
18
|
+
for (let i = 0, len = obj.length; i < len; i++) {
|
19
19
|
copy[i] = (0, exports.clean)(obj[i]);
|
20
20
|
}
|
21
21
|
return copy;
|
@@ -23,7 +23,7 @@ const clean = (obj) => {
|
|
23
23
|
// Handle Object
|
24
24
|
if (obj instanceof Object || typeof obj === 'object') {
|
25
25
|
copy = {};
|
26
|
-
for (
|
26
|
+
for (let attr in obj) {
|
27
27
|
if (obj.hasOwnProperty(attr)) {
|
28
28
|
switch (attr) {
|
29
29
|
case 'leadingComments':
|
package/utils/cleanse.js
CHANGED
@@ -4,9 +4,9 @@ exports.cleanse = void 0;
|
|
4
4
|
const case_1 = require("case");
|
5
5
|
const cleanFor = (str) => {
|
6
6
|
/*
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
1. look at first char after _for_
|
8
|
+
2. ONLY if you find capitals after, modify it
|
9
|
+
*/
|
10
10
|
while (/_[a-z]+_[A-Z]/.test(str)) {
|
11
11
|
const m = str.match(/(_[a-z]+_)[A-Z]/);
|
12
12
|
str = str.replace(m[1], (0, case_1.pascal)(m[1]));
|
@@ -20,7 +20,7 @@ const cleanNullable = (str) => {
|
|
20
20
|
return str;
|
21
21
|
};
|
22
22
|
const cleanse = (obj) => {
|
23
|
-
|
23
|
+
let copy;
|
24
24
|
// Handle the 3 simple types, and null or undefined
|
25
25
|
if (null == obj || 'object' != typeof obj)
|
26
26
|
return obj;
|
@@ -33,7 +33,7 @@ const cleanse = (obj) => {
|
|
33
33
|
// Handle Array
|
34
34
|
if (obj instanceof Array) {
|
35
35
|
copy = [];
|
36
|
-
for (
|
36
|
+
for (let i = 0, len = obj.length; i < len; i++) {
|
37
37
|
copy[i] = (0, exports.cleanse)(obj[i]);
|
38
38
|
}
|
39
39
|
return copy;
|
@@ -48,7 +48,7 @@ const cleanse = (obj) => {
|
|
48
48
|
obj.type = 'string';
|
49
49
|
}
|
50
50
|
}
|
51
|
-
for (
|
51
|
+
for (let attr in obj) {
|
52
52
|
if (obj.hasOwnProperty(attr)) {
|
53
53
|
if (/_for_/.test(attr)) {
|
54
54
|
// @ts-ignore
|
package/utils/contracts.d.ts
CHANGED
package/utils/files.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import * as t from
|
1
|
+
import * as t from '@babel/types';
|
2
2
|
export declare const writeAstToFile: (outPath: string, program: t.Statement[], filename: string, removeUnusedImports?: boolean, isTsDisable?: boolean, isEslintDisable?: boolean) => void;
|
3
3
|
export declare const writeContentToFile: (outPath: string, content: string, filename: string, isTsDisable?: boolean, isEslintDisable?: boolean) => void;
|
package/utils/files.js
CHANGED
@@ -27,21 +27,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.writeContentToFile = exports.writeAstToFile = void 0;
|
30
|
-
const
|
30
|
+
const generator_1 = __importDefault(require("@babel/generator"));
|
31
31
|
const parser_1 = require("@babel/parser");
|
32
|
-
const
|
32
|
+
const traverse_1 = __importDefault(require("@babel/traverse"));
|
33
|
+
const t = __importStar(require("@babel/types"));
|
33
34
|
const fs_1 = require("fs");
|
35
|
+
const mkdirp_1 = require("mkdirp");
|
34
36
|
const path_1 = require("path");
|
35
|
-
const generator_1 = __importDefault(require("@babel/generator"));
|
36
37
|
const unused_1 = require("./unused");
|
37
|
-
const traverse_1 = __importDefault(require("@babel/traverse"));
|
38
38
|
const writeAstToFile = (outPath, program, filename, removeUnusedImports = false, isTsDisable = false, isEslintDisable = false) => {
|
39
39
|
const ast = t.program(program);
|
40
40
|
const content = (0, generator_1.default)(ast).code;
|
41
41
|
if (removeUnusedImports) {
|
42
|
-
const plugins = [
|
42
|
+
const plugins = ['typescript'];
|
43
43
|
const newAst = (0, parser_1.parse)(content, {
|
44
|
-
sourceType:
|
44
|
+
sourceType: 'module',
|
45
45
|
plugins,
|
46
46
|
});
|
47
47
|
(0, traverse_1.default)(newAst, unused_1.unused);
|
@@ -54,12 +54,12 @@ const writeAstToFile = (outPath, program, filename, removeUnusedImports = false,
|
|
54
54
|
};
|
55
55
|
exports.writeAstToFile = writeAstToFile;
|
56
56
|
const writeContentToFile = (outPath, content, filename, isTsDisable = false, isEslintDisable = false) => {
|
57
|
-
let esLintPrefix =
|
58
|
-
let tsLintPrefix =
|
59
|
-
let nameWithoutPath = filename.replace(outPath,
|
57
|
+
let esLintPrefix = '';
|
58
|
+
let tsLintPrefix = '';
|
59
|
+
let nameWithoutPath = filename.replace(outPath, '');
|
60
60
|
// strip off leading slash
|
61
|
-
if (nameWithoutPath.startsWith(
|
62
|
-
nameWithoutPath = nameWithoutPath.replace(/^\//,
|
61
|
+
if (nameWithoutPath.startsWith('/'))
|
62
|
+
nameWithoutPath = nameWithoutPath.replace(/^\//, '');
|
63
63
|
if (isTsDisable) {
|
64
64
|
tsLintPrefix = `//@ts-nocheck\n`;
|
65
65
|
}
|
package/utils/package.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.readAndParsePackageJson = void 0;
|
4
|
-
const path_1 = require("path");
|
5
4
|
const fs_1 = require("fs");
|
5
|
+
const path_1 = require("path");
|
6
6
|
// need to search due to the dist/ folder and src/, etc.
|
7
7
|
function findPackageJson(currentDir) {
|
8
8
|
const filePath = (0, path_1.join)(currentDir, 'package.json');
|
package/utils/parse.js
CHANGED
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.parser = void 0;
|
7
|
-
const traverse_1 = __importDefault(require("@babel/traverse"));
|
8
7
|
const parser_1 = require("@babel/parser");
|
8
|
+
const traverse_1 = __importDefault(require("@babel/traverse"));
|
9
9
|
const parser = (codes) => {
|
10
10
|
const hash = {};
|
11
11
|
codes.forEach(code => {
|
package/utils/prompt.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export declare const getFuzzySearch: (list: any) => (
|
2
|
-
export declare const getFuzzySearchNames: (nameValueItemList: any) => (
|
1
|
+
export declare const getFuzzySearch: (list: any) => (_answers: any, input: any) => Promise<unknown>;
|
2
|
+
export declare const getFuzzySearchNames: (nameValueItemList: any) => (_answers: any, input: any) => Promise<unknown>;
|
3
3
|
export declare const prompt: (questions?: any[], argv?: {}) => Promise<any>;
|
package/utils/prompt.js
CHANGED
@@ -5,7 +5,7 @@ exports.prompt = exports.getFuzzySearchNames = exports.getFuzzySearch = void 0;
|
|
5
5
|
const fuzzy_1 = require("fuzzy");
|
6
6
|
const inquirerer_1 = require("inquirerer");
|
7
7
|
const getFuzzySearch = (list) => {
|
8
|
-
return (
|
8
|
+
return (_answers, input) => {
|
9
9
|
input = input || '';
|
10
10
|
return new Promise(function (resolve) {
|
11
11
|
setTimeout(function () {
|
@@ -19,14 +19,14 @@ const getFuzzySearch = (list) => {
|
|
19
19
|
};
|
20
20
|
exports.getFuzzySearch = getFuzzySearch;
|
21
21
|
const getFuzzySearchNames = (nameValueItemList) => {
|
22
|
-
const list = nameValueItemList.map(({ name, value }) => name);
|
23
|
-
return (
|
22
|
+
const list = nameValueItemList.map(({ name, value: _value }) => name);
|
23
|
+
return (_answers, input) => {
|
24
24
|
input = input || '';
|
25
25
|
return new Promise(function (resolve) {
|
26
26
|
setTimeout(function () {
|
27
27
|
const fuzzyResult = (0, fuzzy_1.filter)(input, list);
|
28
28
|
resolve(fuzzyResult.map(function (el) {
|
29
|
-
return nameValueItemList.find(({ name, value }) => el.original == name);
|
29
|
+
return nameValueItemList.find(({ name, value: _value }) => el.original == name);
|
30
30
|
}));
|
31
31
|
}, 25);
|
32
32
|
});
|
package/utils/schemas.d.ts
CHANGED
package/utils/schemas.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.findAndParseTypes = exports.findExecuteMsg = exports.findQueryMsg = exports.readSchemas = void 0;
|
4
|
-
const
|
4
|
+
const json_schema_to_typescript_1 = require("@pyramation/json-schema-to-typescript");
|
5
5
|
const fs_1 = require("fs");
|
6
|
+
const glob_1 = require("glob");
|
6
7
|
const cleanse_1 = require("./cleanse");
|
7
|
-
const json_schema_to_typescript_1 = require("@pyramation/json-schema-to-typescript");
|
8
8
|
const parse_1 = require("./parse");
|
9
9
|
;
|
10
10
|
const readSchemas = async ({ schemaDir, clean = true }) => {
|
@@ -27,7 +27,10 @@ const readSchemas = async ({ schemaDir, clean = true }) => {
|
|
27
27
|
throw new Error('Error [too many files]: CosmWasm v1.1 schemas supports one file');
|
28
28
|
}
|
29
29
|
const idlObject = schemas[0];
|
30
|
-
const {
|
30
|
+
const {
|
31
|
+
// contract_name,
|
32
|
+
// contract_version,
|
33
|
+
idl_version, responses, instantiate, execute, query, migrate, sudo } = idlObject;
|
31
34
|
if (typeof idl_version !== 'string') {
|
32
35
|
// legacy
|
33
36
|
return {
|