@cosmwasm/ts-codegen 0.35.7 → 1.1.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/LICENSE-Apache +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +106 -101
- package/{types/src/builder → builder}/builder.d.ts +2 -2
- package/builder/builder.js +172 -0
- package/builder/index.js +17 -0
- package/bundler/bundler.d.ts +8 -0
- package/bundler/bundler.js +79 -0
- package/bundler/index.js +17 -0
- package/cli.d.ts +2 -0
- package/cli.js +24 -0
- package/cmds.d.ts +2 -0
- package/cmds.js +14 -0
- package/commands/create-boilerplate.d.ts +3 -0
- package/commands/create-boilerplate.js +132 -0
- package/commands/generate.d.ts +3 -0
- package/commands/generate.js +175 -0
- package/commands/install.d.ts +3 -0
- package/commands/install.js +107 -0
- package/{src/builder/builder.ts → esm/builder/builder.js} +39 -139
- package/esm/builder/index.js +1 -0
- package/esm/bundler/bundler.js +47 -0
- package/esm/bundler/index.js +1 -0
- package/esm/cli.js +20 -0
- package/{src → esm}/cmds.js +0 -1
- package/{src/commands/create-boilerplate.ts → esm/commands/create-boilerplate.js} +35 -70
- package/{src/commands/generate.ts → esm/commands/generate.js} +19 -24
- package/{src/commands/install.ts → esm/commands/install.js} +22 -35
- package/esm/file.js +18 -0
- package/esm/generators/client.js +67 -0
- package/esm/generators/create-helpers.js +36 -0
- package/esm/generators/message-builder.js +58 -0
- package/esm/generators/message-composer.js +55 -0
- package/esm/generators/react-query.js +76 -0
- package/esm/generators/recoil.js +58 -0
- package/esm/generators/types.js +58 -0
- package/{src/index.ts → esm/index.js} +4 -6
- package/esm/plugins/client.js +59 -0
- package/esm/plugins/message-builder.js +52 -0
- package/esm/plugins/message-composer.js +46 -0
- package/esm/plugins/plugin-base.js +47 -0
- package/esm/plugins/provider-bundle.js +58 -0
- package/esm/plugins/provider.js +73 -0
- package/esm/plugins/react-query.js +69 -0
- package/esm/plugins/recoil.js +51 -0
- package/esm/plugins/types.js +38 -0
- package/{src → esm}/ts-codegen.js +1 -2
- package/{src/utils/clean.ts → esm/utils/clean.js} +7 -7
- package/{src/utils/cleanse.ts → esm/utils/cleanse.js} +18 -22
- package/esm/utils/files.js +42 -0
- package/{src/utils/parse.ts → esm/utils/parse.js} +4 -13
- package/esm/utils/prompt.js +59 -0
- package/{src/utils/schemas.ts → esm/utils/schemas.js} +16 -44
- package/esm/utils/unused.js +47 -0
- package/file.js +20 -0
- package/generators/client.js +95 -0
- package/generators/create-helpers.js +43 -0
- package/generators/message-builder.js +86 -0
- package/generators/message-composer.js +83 -0
- package/generators/react-query.js +104 -0
- package/generators/recoil.js +86 -0
- package/generators/types.js +86 -0
- package/{module/helpers → helpers}/contractContextBase.js +5 -2
- package/{module/helpers → helpers}/contractContextBaseShortHandCtor.js +5 -2
- package/{module/helpers → helpers}/contractsContextTSX.js +5 -2
- package/{module/helpers/index.js → helpers/index.d.ts} +1 -1
- package/helpers/index.js +19 -0
- package/{types/src/index.d.ts → index.d.ts} +1 -0
- package/index.js +41 -0
- package/package.json +28 -63
- package/plugins/client.js +86 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +17 -0
- package/plugins/message-builder.js +79 -0
- package/plugins/message-composer.js +73 -0
- package/{types/src/plugins → plugins}/plugin-base.d.ts +1 -1
- package/plugins/plugin-base.js +77 -0
- package/plugins/provider-bundle.js +85 -0
- package/{types/src/plugins → plugins}/provider.d.ts +2 -2
- package/plugins/provider.js +102 -0
- package/plugins/react-query.js +96 -0
- package/plugins/recoil.js +78 -0
- package/plugins/types.js +65 -0
- package/ts-codegen.js +8 -0
- package/utils/clean.js +49 -0
- package/utils/cleanse.js +89 -0
- package/utils/files.js +73 -0
- package/utils/header.js +14 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +17 -0
- package/utils/parse.d.ts +1 -0
- package/utils/parse.js +43 -0
- package/utils/prompt.d.ts +3 -0
- package/utils/prompt.js +65 -0
- package/utils/schemas.d.ts +11 -0
- package/utils/schemas.js +81 -0
- package/utils/unused.js +73 -0
- package/main/builder/builder.js +0 -308
- package/main/builder/index.js +0 -16
- package/main/bundler/bundler.js +0 -61
- package/main/bundler/index.js +0 -16
- package/main/cli.js +0 -51
- package/main/cmds.js +0 -15
- package/main/commands/create-boilerplate.js +0 -166
- package/main/commands/generate.js +0 -196
- package/main/commands/install.js +0 -138
- package/main/file.js +0 -35
- package/main/generators/client.js +0 -90
- package/main/generators/create-helpers.js +0 -38
- package/main/generators/message-composer.js +0 -77
- package/main/generators/msg-builder.js +0 -84
- package/main/generators/react-query.js +0 -102
- package/main/generators/recoil.js +0 -81
- package/main/generators/types.js +0 -82
- package/main/helpers/contractContextBase.js +0 -8
- package/main/helpers/contractContextBaseShortHandCtor.js +0 -8
- package/main/helpers/contractsContextTSX.js +0 -8
- package/main/helpers/index.js +0 -38
- package/main/index.js +0 -119
- package/main/plugins/client.js +0 -112
- package/main/plugins/index.js +0 -16
- package/main/plugins/message-builder.js +0 -102
- package/main/plugins/message-composer.js +0 -98
- package/main/plugins/plugin-base.js +0 -103
- package/main/plugins/provider-bundle.js +0 -108
- package/main/plugins/provider.js +0 -126
- package/main/plugins/react-query.js +0 -120
- package/main/plugins/recoil.js +0 -108
- package/main/plugins/types.js +0 -89
- package/main/ts-codegen.js +0 -20
- package/main/utils/clean.js +0 -53
- package/main/utils/cleanse.js +0 -87
- package/main/utils/files.js +0 -57
- package/main/utils/header.js +0 -11
- package/main/utils/index.js +0 -16
- package/main/utils/parse.js +0 -44
- package/main/utils/prompt.js +0 -98
- package/main/utils/schemas.js +0 -144
- package/main/utils/unused.js +0 -57
- package/module/builder/builder.js +0 -143
- package/module/builder/index.js +0 -1
- package/module/bundler/bundler.js +0 -36
- package/module/bundler/index.js +0 -1
- package/module/cli.js +0 -19
- package/module/cmds.js +0 -8
- package/module/commands/create-boilerplate.js +0 -102
- package/module/commands/generate.js +0 -163
- package/module/commands/install.js +0 -98
- package/module/file.js +0 -18
- package/module/generators/client.js +0 -65
- package/module/generators/create-helpers.js +0 -33
- package/module/generators/message-composer.js +0 -52
- package/module/generators/msg-builder.js +0 -58
- package/module/generators/react-query.js +0 -75
- package/module/generators/recoil.js +0 -53
- package/module/generators/types.js +0 -55
- package/module/index.js +0 -14
- package/module/plugins/client.js +0 -63
- package/module/plugins/index.js +0 -1
- package/module/plugins/message-builder.js +0 -55
- package/module/plugins/message-composer.js +0 -49
- package/module/plugins/plugin-base.js +0 -66
- package/module/plugins/provider-bundle.js +0 -56
- package/module/plugins/provider.js +0 -68
- package/module/plugins/react-query.js +0 -72
- package/module/plugins/recoil.js +0 -57
- package/module/plugins/types.js +0 -42
- package/module/ts-codegen.js +0 -6
- package/module/utils/clean.js +0 -44
- package/module/utils/cleanse.js +0 -78
- package/module/utils/files.js +0 -40
- package/module/utils/header.js +0 -8
- package/module/utils/index.js +0 -1
- package/module/utils/parse.js +0 -35
- package/module/utils/prompt.js +0 -63
- package/module/utils/schemas.js +0 -85
- package/module/utils/unused.js +0 -43
- package/src/builder/index.ts +0 -1
- package/src/bundler/bundler.ts +0 -67
- package/src/bundler/index.ts +0 -1
- package/src/cli.js +0 -21
- package/src/file.js +0 -20
- package/src/generators/client.ts +0 -109
- package/src/generators/create-helpers.ts +0 -71
- package/src/generators/message-composer.ts +0 -86
- package/src/generators/msg-builder.ts +0 -78
- package/src/generators/react-query.ts +0 -102
- package/src/generators/recoil.ts +0 -92
- package/src/generators/types.ts +0 -94
- package/src/helpers/index.ts +0 -3
- package/src/plugins/client.ts +0 -124
- package/src/plugins/index.ts +0 -1
- package/src/plugins/message-builder.ts +0 -85
- package/src/plugins/message-composer.ts +0 -89
- package/src/plugins/plugin-base.ts +0 -122
- package/src/plugins/provider-bundle.ts +0 -98
- package/src/plugins/provider.ts +0 -115
- package/src/plugins/react-query.ts +0 -115
- package/src/plugins/recoil.ts +0 -89
- package/src/plugins/types.ts +0 -74
- package/src/utils/files.ts +0 -73
- package/src/utils/index.ts +0 -1
- package/src/utils/prompt.js +0 -65
- package/src/utils/unused.ts +0 -52
- package/types/src/bundler/bundler.d.ts +0 -4
- package/types/src/cli.d.ts +0 -1
- package/types/src/cmds.d.ts +0 -1
- package/types/src/commands/create-boilerplate.d.ts +0 -2
- package/types/src/commands/generate.d.ts +0 -2
- package/types/src/commands/install.d.ts +0 -2
- package/types/src/generators/msg-builder.ts +0 -5
- package/types/src/plugins/msg-builder.d.ts +0 -12
- package/types/src/plugins/use-contracts.d.ts +0 -12
- package/types/src/types.d.ts +0 -16
- package/types/src/utils/parse.d.ts +0 -1
- package/types/src/utils/prompt.d.ts +0 -3
- package/types/src/utils/schemas.d.ts +0 -10
- /package/{types/src/builder → builder}/index.d.ts +0 -0
- /package/{types/src/bundler → bundler}/index.d.ts +0 -0
- /package/{src/helpers/contractContextBase.ts → esm/helpers/contractContextBase.js} +0 -0
- /package/{src/helpers/contractContextBaseShortHandCtor.ts → esm/helpers/contractContextBaseShortHandCtor.js} +0 -0
- /package/{src/helpers/contractsContextTSX.ts → esm/helpers/contractsContextTSX.js} +0 -0
- /package/{types/src/helpers/index.d.ts → esm/helpers/index.js} +0 -0
- /package/{types/src/plugins/index.d.ts → esm/plugins/index.js} +0 -0
- /package/{src/utils/header.ts → esm/utils/header.js} +0 -0
- /package/{types/src/utils/index.d.ts → esm/utils/index.js} +0 -0
- /package/{types/src/file.d.ts → file.d.ts} +0 -0
- /package/{types/src/generators → generators}/client.d.ts +0 -0
- /package/{types/src/generators → generators}/create-helpers.d.ts +0 -0
- /package/{types/src/generators/msg-builder.d.ts → generators/message-builder.d.ts} +0 -0
- /package/{types/src/generators → generators}/message-composer.d.ts +0 -0
- /package/{types/src/generators → generators}/react-query.d.ts +0 -0
- /package/{types/src/generators → generators}/recoil.d.ts +0 -0
- /package/{types/src/generators → generators}/types.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractContextBase.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractContextBaseShortHandCtor.d.ts +0 -0
- /package/{types/src/helpers → helpers}/contractsContextTSX.d.ts +0 -0
- /package/{types/src/plugins → plugins}/client.d.ts +0 -0
- /package/{types/src/plugins → plugins}/message-builder.d.ts +0 -0
- /package/{types/src/plugins → plugins}/message-composer.d.ts +0 -0
- /package/{types/src/plugins → plugins}/provider-bundle.d.ts +0 -0
- /package/{types/src/plugins → plugins}/react-query.d.ts +0 -0
- /package/{types/src/plugins → plugins}/recoil.d.ts +0 -0
- /package/{types/src/plugins → plugins}/types.d.ts +0 -0
- /package/{types/src/ts-codegen.d.ts → ts-codegen.d.ts} +0 -0
- /package/{types/src/utils → utils}/clean.d.ts +0 -0
- /package/{types/src/utils → utils}/cleanse.d.ts +0 -0
- /package/{types/src/utils → utils}/files.d.ts +0 -0
- /package/{types/src/utils → utils}/header.d.ts +0 -0
- /package/{types/src/utils → utils}/unused.d.ts +0 -0
package/src/utils/prompt.js
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
import { filter } from 'fuzzy';
|
2
|
-
import { prompt as inquirerer } from 'inquirerer';
|
3
|
-
|
4
|
-
export const getFuzzySearch = (list) => {
|
5
|
-
return (answers, input) => {
|
6
|
-
input = input || '';
|
7
|
-
return new Promise(function (resolve) {
|
8
|
-
setTimeout(function () {
|
9
|
-
const fuzzyResult = filter(input, list);
|
10
|
-
resolve(
|
11
|
-
fuzzyResult.map(function (el) {
|
12
|
-
return el.original;
|
13
|
-
})
|
14
|
-
);
|
15
|
-
}, 25);
|
16
|
-
});
|
17
|
-
};
|
18
|
-
};
|
19
|
-
|
20
|
-
export const getFuzzySearchNames = (nameValueItemList) => {
|
21
|
-
const list = nameValueItemList.map(({ name, value }) => name);
|
22
|
-
return (answers, input) => {
|
23
|
-
input = input || '';
|
24
|
-
return new Promise(function (resolve) {
|
25
|
-
setTimeout(function () {
|
26
|
-
const fuzzyResult = filter(input, list);
|
27
|
-
resolve(
|
28
|
-
fuzzyResult.map(function (el) {
|
29
|
-
return nameValueItemList.find(
|
30
|
-
({ name, value }) => el.original == name
|
31
|
-
);
|
32
|
-
})
|
33
|
-
);
|
34
|
-
}, 25);
|
35
|
-
});
|
36
|
-
};
|
37
|
-
};
|
38
|
-
const transform = (questions) => {
|
39
|
-
return questions.map((q) => {
|
40
|
-
if (q.type === 'fuzzy') {
|
41
|
-
const choices = q.choices;
|
42
|
-
delete q.choices;
|
43
|
-
return {
|
44
|
-
...q,
|
45
|
-
type: 'autocomplete',
|
46
|
-
source: getFuzzySearch(choices)
|
47
|
-
};
|
48
|
-
} else if (q.type === 'fuzzy:objects') {
|
49
|
-
const choices = q.choices;
|
50
|
-
delete q.choices;
|
51
|
-
return {
|
52
|
-
...q,
|
53
|
-
type: 'autocomplete',
|
54
|
-
source: getFuzzySearchNames(choices)
|
55
|
-
};
|
56
|
-
} else {
|
57
|
-
return q;
|
58
|
-
}
|
59
|
-
});
|
60
|
-
};
|
61
|
-
|
62
|
-
export const prompt = async (questions = [], argv = {}) => {
|
63
|
-
questions = transform(questions);
|
64
|
-
return await inquirerer(questions, argv);
|
65
|
-
};
|
package/src/utils/unused.ts
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
//@ts-nocheck
|
2
|
-
|
3
|
-
import * as t from '@babel/types';
|
4
|
-
|
5
|
-
// https://github.com/chuyik/babel-plugin-danger-remove-unused-import
|
6
|
-
// https://github.com/chuyik/babel-plugin-danger-remove-unused-import/blob/c5454c21e94698a2464a12baa5590761932a71a8/License#L1
|
7
|
-
|
8
|
-
export const unused = {
|
9
|
-
Program: {
|
10
|
-
exit: (path) => {
|
11
|
-
const UnRefBindings = new Map()
|
12
|
-
for (const [name, binding] of Object.entries(path.scope.bindings)) {
|
13
|
-
if (!binding.path.parentPath || binding.kind !== 'module') continue
|
14
|
-
|
15
|
-
const source = binding.path.parentPath.get('source')
|
16
|
-
const importName = source.node.value
|
17
|
-
if (
|
18
|
-
!t.isStringLiteral(source)
|
19
|
-
)
|
20
|
-
continue
|
21
|
-
|
22
|
-
const key = `${importName}(${source.node.loc &&
|
23
|
-
source.node.loc.start.line})`
|
24
|
-
|
25
|
-
if (!UnRefBindings.has(key)) {
|
26
|
-
UnRefBindings.set(key, binding)
|
27
|
-
}
|
28
|
-
|
29
|
-
if (binding.referenced) {
|
30
|
-
UnRefBindings.set(key, null)
|
31
|
-
} else {
|
32
|
-
const nodeType = binding.path.node.type
|
33
|
-
if (nodeType === 'ImportSpecifier') {
|
34
|
-
binding.path.remove()
|
35
|
-
} else if (nodeType === 'ImportDefaultSpecifier') {
|
36
|
-
binding.path.remove()
|
37
|
-
} else if (nodeType === 'ImportNamespaceSpecifier') {
|
38
|
-
binding.path.remove()
|
39
|
-
} else if (binding.path.parentPath) {
|
40
|
-
binding.path.parentPath.remove()
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
UnRefBindings.forEach((binding, key) => {
|
46
|
-
if (binding && binding.path.parentPath) {
|
47
|
-
binding.path.parentPath.remove()
|
48
|
-
}
|
49
|
-
})
|
50
|
-
}
|
51
|
-
}
|
52
|
-
};
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import * as t from '@babel/types';
|
2
|
-
export declare const recursiveModuleBundle: (obj: any) => any;
|
3
|
-
export declare const importNamespace: (ident: string, path: string) => t.ImportDeclaration;
|
4
|
-
export declare const createFileBundle: (pkg: any, filename: any, bundleFile: any, importPaths: any, bundleVariables: any) => void;
|
package/types/src/cli.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export function cli(argv: any): Promise<void>;
|
package/types/src/cmds.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export const Commands: typeof Commands;
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { ContractInfo } from "wasm-ast-types";
|
2
|
-
import { MessageBuilderOptions } from "wasm-ast-types";
|
3
|
-
import { BuilderFile } from "../builder";
|
4
|
-
declare const _default: (name: string, contractInfo: ContractInfo, outPath: string, messageBuilderOptions?: MessageBuilderOptions) => Promise<BuilderFile[]>;
|
5
|
-
export default _default;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { RenderContext, RenderContextBase, ContractInfo, RenderOptions } from 'wasm-ast-types';
|
2
|
-
import { BuilderFileType } from '../builder';
|
3
|
-
import { BuilderPluginBase } from './plugin-base';
|
4
|
-
export declare class MessageBuilderPlugin extends BuilderPluginBase<RenderOptions> {
|
5
|
-
initContext(contract: ContractInfo, options?: RenderOptions): RenderContextBase<RenderOptions>;
|
6
|
-
doRender(name: string, context: RenderContext): Promise<{
|
7
|
-
type: BuilderFileType;
|
8
|
-
pluginType?: string;
|
9
|
-
localname: string;
|
10
|
-
body: any[];
|
11
|
-
}[]>;
|
12
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { ContractInfo, RenderContextBase, RenderContext } from 'wasm-ast-types';
|
2
|
-
import { BuilderFileType, TSBuilderOptions } from '../builder';
|
3
|
-
import { BuilderPluginBase } from './plugin-base';
|
4
|
-
export declare class ContractsContextPlugin extends BuilderPluginBase<TSBuilderOptions> {
|
5
|
-
initContext(contract: ContractInfo, options?: TSBuilderOptions): RenderContextBase<TSBuilderOptions>;
|
6
|
-
doRender(name: string, context: RenderContext): Promise<{
|
7
|
-
type: BuilderFileType;
|
8
|
-
pluginType?: string;
|
9
|
-
localname: string;
|
10
|
-
body: any[];
|
11
|
-
}[]>;
|
12
|
-
}
|
package/types/src/types.d.ts
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
import { JSONSchema } from "wasm-ast-types";
|
2
|
-
interface KeyedSchema {
|
3
|
-
[key: string]: JSONSchema;
|
4
|
-
}
|
5
|
-
export interface IDLObject {
|
6
|
-
contract_name: string;
|
7
|
-
contract_version: string;
|
8
|
-
idl_version: string;
|
9
|
-
instantiate: JSONSchema;
|
10
|
-
execute: JSONSchema;
|
11
|
-
query: JSONSchema;
|
12
|
-
migrate: JSONSchema;
|
13
|
-
sudo: JSONSchema;
|
14
|
-
responses: KeyedSchema;
|
15
|
-
}
|
16
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const parser: (codes: any) => {};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { ContractInfo } from 'wasm-ast-types';
|
2
|
-
interface ReadSchemaOpts {
|
3
|
-
schemaDir: string;
|
4
|
-
clean?: boolean;
|
5
|
-
}
|
6
|
-
export declare const readSchemas: ({ schemaDir, clean }: ReadSchemaOpts) => Promise<ContractInfo>;
|
7
|
-
export declare const findQueryMsg: (schemas: any) => any;
|
8
|
-
export declare const findExecuteMsg: (schemas: any) => any;
|
9
|
-
export declare const findAndParseTypes: (schemas: any) => Promise<{}>;
|
10
|
-
export {};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|