wasm-ast-types 0.5.0 → 0.6.1
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/main/{wasm.js → client/client.js} +54 -40
- package/main/client/index.js +18 -0
- package/main/client/test/ts-client.arrays.spec.js +25 -0
- package/main/client/test/ts-client.cw-named-groups.test.js +25 -0
- package/main/client/test/ts-client.cw-proposal-single.test.js +30 -0
- package/main/client/test/ts-client.empty-enums.spec.js +19 -0
- package/main/client/test/ts-client.sg721.spec.js +25 -0
- package/main/client/test/ts-client.spec.js +106 -0
- package/main/client/test/ts-client.vectis.spec.js +56 -0
- package/main/context/context.js +48 -0
- package/main/context/index.js +18 -0
- package/main/{messages.js → from-partial/from-partial.js} +17 -60
- package/main/from-partial/from-partial.spec.js +20 -0
- package/main/from-partial/index.js +18 -0
- package/main/index.js +34 -8
- package/main/react-query/index.js +18 -0
- package/main/{react-query.js → react-query/react-query.js} +39 -64
- package/main/{react-query.spec.js → react-query/react-query.spec.js} +33 -43
- package/main/recoil/index.js +18 -0
- package/main/{recoil.js → recoil/recoil.js} +7 -26
- package/main/{recoil.spec.js → recoil/recoil.spec.js} +9 -14
- package/main/utils/babel.spec.js +7 -15
- package/main/utils/index.js +13 -0
- package/main/utils/types.js +35 -33
- package/module/{wasm.js → client/client.js} +43 -33
- package/module/client/index.js +1 -0
- package/module/client/test/ts-client.arrays.spec.js +17 -0
- package/module/client/test/ts-client.cw-named-groups.test.js +17 -0
- package/module/client/test/ts-client.cw-proposal-single.test.js +21 -0
- package/module/client/test/ts-client.empty-enums.spec.js +11 -0
- package/module/client/test/ts-client.sg721.spec.js +17 -0
- package/module/client/test/ts-client.spec.js +85 -0
- package/module/client/test/ts-client.vectis.spec.js +44 -0
- package/module/context/context.js +25 -0
- package/module/context/index.js +1 -0
- package/module/{messages.js → from-partial/from-partial.js} +16 -57
- package/module/from-partial/from-partial.spec.js +12 -0
- package/module/from-partial/index.js +1 -0
- package/module/index.js +5 -3
- package/module/react-query/index.js +1 -0
- package/module/{react-query.js → react-query/react-query.js} +30 -49
- package/module/react-query/react-query.spec.js +53 -0
- package/module/recoil/index.js +1 -0
- package/module/{recoil.js → recoil/recoil.js} +6 -20
- package/module/recoil/recoil.spec.js +15 -0
- package/module/utils/babel.spec.js +1 -10
- package/module/utils/index.js +2 -1
- package/module/utils/types.js +33 -31
- package/package.json +26 -24
- package/types/src/client/client.d.ts +17 -0
- package/types/src/client/index.d.ts +1 -0
- package/types/src/client/test/ts-client.cw-named-groups.test.d.ts +1 -0
- package/types/src/client/test/ts-client.cw-proposal-single.test.d.ts +1 -0
- package/types/src/context/context.d.ts +20 -0
- package/types/src/context/index.d.ts +1 -0
- package/types/src/from-partial/from-partial.d.ts +4 -0
- package/types/src/from-partial/index.d.ts +1 -0
- package/types/src/index.d.ts +7 -0
- package/types/src/react-query/index.d.ts +1 -0
- package/types/src/react-query/react-query.d.ts +81 -0
- package/types/src/recoil/index.d.ts +1 -0
- package/types/{recoil.d.ts → src/recoil/recoil.d.ts} +5 -5
- package/types/{types.d.ts → src/types.d.ts} +17 -0
- package/types/{utils.d.ts → src/utils/babel.d.ts} +21 -1
- package/types/src/utils/index.d.ts +2 -0
- package/types/src/utils/types.d.ts +18 -0
- package/types/test-utils/index.d.ts +2 -0
- package/main/messages.spec.js +0 -24
- package/main/wasm.arrays.spec.js +0 -30
- package/main/wasm.cw-named-groups.test.js +0 -30
- package/main/wasm.cw-proposal-single.test.js +0 -32
- package/main/wasm.empty-enums.spec.js +0 -24
- package/main/wasm.sg721.spec.js +0 -30
- package/main/wasm.spec.js +0 -95
- package/main/wasm.vectis.spec.js +0 -53
- package/module/messages.spec.js +0 -18
- package/module/react-query.spec.js +0 -65
- package/module/recoil.spec.js +0 -22
- package/module/wasm.arrays.spec.js +0 -24
- package/module/wasm.cw-named-groups.test.js +0 -24
- package/module/wasm.cw-proposal-single.test.js +0 -25
- package/module/wasm.empty-enums.spec.js +0 -18
- package/module/wasm.sg721.spec.js +0 -24
- package/module/wasm.spec.js +0 -76
- package/module/wasm.vectis.spec.js +0 -43
- package/types/amino/amino-interfaces.d.ts +0 -6
- package/types/amino/from-amino.d.ts +0 -13
- package/types/amino/index.d.ts +0 -3
- package/types/amino/to-amino.d.ts +0 -11
- package/types/index.d.ts +0 -5
- package/types/messages.d.ts +0 -4
- package/types/react-query.d.ts +0 -70
- package/types/wasm.d.ts +0 -24
package/module/utils/types.js
CHANGED
|
@@ -3,31 +3,15 @@ import { camel } from 'case';
|
|
|
3
3
|
import { propertySignature } from './babel';
|
|
4
4
|
|
|
5
5
|
const getTypeStrFromRef = $ref => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return 'Binary';
|
|
9
|
-
|
|
10
|
-
default:
|
|
11
|
-
if ($ref?.startsWith('#/definitions/')) {
|
|
12
|
-
return $ref.replace('#/definitions/', '');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
throw new Error('what is $ref: ' + $ref);
|
|
6
|
+
if ($ref?.startsWith('#/definitions/')) {
|
|
7
|
+
return $ref.replace('#/definitions/', '');
|
|
16
8
|
}
|
|
9
|
+
|
|
10
|
+
throw new Error('what is $ref: ' + $ref);
|
|
17
11
|
};
|
|
18
12
|
|
|
19
13
|
export const getTypeFromRef = $ref => {
|
|
20
|
-
|
|
21
|
-
case '#/definitions/Binary':
|
|
22
|
-
return t.tsTypeReference(t.identifier('Binary'));
|
|
23
|
-
|
|
24
|
-
default:
|
|
25
|
-
if ($ref?.startsWith('#/definitions/')) {
|
|
26
|
-
return t.tsTypeReference(t.identifier($ref.replace('#/definitions/', '')));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
throw new Error('what is $ref: ' + $ref);
|
|
30
|
-
}
|
|
14
|
+
return t.tsTypeReference(t.identifier(getTypeStrFromRef($ref)));
|
|
31
15
|
};
|
|
32
16
|
|
|
33
17
|
const getArrayTypeFromRef = $ref => {
|
|
@@ -61,7 +45,7 @@ export const getType = type => {
|
|
|
61
45
|
throw new Error('contact maintainers [unknown type]: ' + type);
|
|
62
46
|
}
|
|
63
47
|
};
|
|
64
|
-
export const getPropertyType = (schema, prop) => {
|
|
48
|
+
export const getPropertyType = (context, schema, prop) => {
|
|
65
49
|
const props = schema.properties ?? {};
|
|
66
50
|
let info = props[prop];
|
|
67
51
|
let type = null;
|
|
@@ -150,12 +134,12 @@ export const getPropertyType = (schema, prop) => {
|
|
|
150
134
|
optional
|
|
151
135
|
};
|
|
152
136
|
};
|
|
153
|
-
export function getPropertySignatureFromProp(jsonschema, prop, camelize) {
|
|
137
|
+
export function getPropertySignatureFromProp(context, jsonschema, prop, camelize) {
|
|
154
138
|
if (jsonschema.properties[prop].type === 'object') {
|
|
155
139
|
if (jsonschema.properties[prop].title) {
|
|
156
140
|
return propertySignature(camelize ? camel(prop) : prop, t.tsTypeAnnotation(t.tsTypeReference(t.identifier(jsonschema.properties[prop].title))));
|
|
157
141
|
} else {
|
|
158
|
-
throw new Error('
|
|
142
|
+
throw new Error('getPropertySignatureFromProp() contact maintainer');
|
|
159
143
|
}
|
|
160
144
|
}
|
|
161
145
|
|
|
@@ -190,7 +174,7 @@ export function getPropertySignatureFromProp(jsonschema, prop, camelize) {
|
|
|
190
174
|
}
|
|
191
175
|
|
|
192
176
|
try {
|
|
193
|
-
getPropertyType(jsonschema, prop);
|
|
177
|
+
getPropertyType(context, jsonschema, prop);
|
|
194
178
|
} catch (e) {
|
|
195
179
|
console.log(e);
|
|
196
180
|
console.log(jsonschema, prop);
|
|
@@ -199,23 +183,41 @@ export function getPropertySignatureFromProp(jsonschema, prop, camelize) {
|
|
|
199
183
|
const {
|
|
200
184
|
type,
|
|
201
185
|
optional
|
|
202
|
-
} = getPropertyType(jsonschema, prop);
|
|
186
|
+
} = getPropertyType(context, jsonschema, prop);
|
|
203
187
|
return propertySignature(camelize ? camel(prop) : prop, t.tsTypeAnnotation(type), optional);
|
|
204
188
|
}
|
|
205
|
-
export const getParamsTypeAnnotation = (jsonschema, camelize = true) => {
|
|
189
|
+
export const getParamsTypeAnnotation = (context, jsonschema, camelize = true) => {
|
|
206
190
|
const keys = Object.keys(jsonschema.properties ?? {});
|
|
191
|
+
|
|
192
|
+
if (!keys.length && jsonschema.$ref) {
|
|
193
|
+
return t.tsTypeAnnotation(getTypeFromRef(jsonschema.$ref));
|
|
194
|
+
}
|
|
195
|
+
|
|
207
196
|
if (!keys.length) return undefined;
|
|
208
|
-
const typedParams = keys.map(prop => getPropertySignatureFromProp(jsonschema, prop, camelize));
|
|
197
|
+
const typedParams = keys.map(prop => getPropertySignatureFromProp(context, jsonschema, prop, camelize));
|
|
209
198
|
return t.tsTypeAnnotation(t.tsTypeLiteral([...typedParams]));
|
|
210
199
|
};
|
|
211
|
-
export const createTypedObjectParams = (jsonschema, camelize = true) => {
|
|
200
|
+
export const createTypedObjectParams = (context, jsonschema, camelize = true) => {
|
|
212
201
|
const keys = Object.keys(jsonschema.properties ?? {});
|
|
213
|
-
|
|
202
|
+
|
|
203
|
+
if (!keys.length) {
|
|
204
|
+
// is there a ref?
|
|
205
|
+
if (jsonschema.$ref) {
|
|
206
|
+
const obj = context.refLookup(jsonschema.$ref);
|
|
207
|
+
|
|
208
|
+
if (obj) {
|
|
209
|
+
return createTypedObjectParams(context, obj, camelize);
|
|
210
|
+
}
|
|
211
|
+
} // no results...
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
214
216
|
|
|
215
217
|
const params = keys.map(prop => {
|
|
216
218
|
return t.objectProperty(camelize ? t.identifier(camel(prop)) : t.identifier(prop), camelize ? t.identifier(camel(prop)) : t.identifier(prop), false, true);
|
|
217
219
|
});
|
|
218
220
|
const obj = t.objectPattern([...params]);
|
|
219
|
-
obj.typeAnnotation = getParamsTypeAnnotation(jsonschema, camelize);
|
|
221
|
+
obj.typeAnnotation = getParamsTypeAnnotation(context, jsonschema, camelize);
|
|
220
222
|
return obj;
|
|
221
223
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wasm-ast-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "CosmWasm TypeScript AST generation",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/pyramation/cosmwasm-typescript-gen/tree/master/packages/wasm-ast-types#readme",
|
|
@@ -48,41 +48,43 @@
|
|
|
48
48
|
"url": "https://github.com/pyramation/cosmwasm-typescript-gen/issues"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@babel/cli": "7.
|
|
52
|
-
"@babel/core": "7.18.
|
|
53
|
-
"@babel/eslint-parser": "^7.18.
|
|
54
|
-
"@babel/generator": "7.18.
|
|
55
|
-
"@babel/node": "^7.18.
|
|
56
|
-
"@babel/parser": "^7.18.
|
|
57
|
-
"@babel/plugin-proposal-class-properties": "7.
|
|
58
|
-
"@babel/plugin-proposal-export-default-from": "7.
|
|
59
|
-
"@babel/plugin-proposal-object-rest-spread": "7.18.
|
|
60
|
-
"@babel/plugin-transform-runtime": "7.18.
|
|
61
|
-
"@babel/preset-env": "7.18.
|
|
62
|
-
"@babel/preset-typescript": "^7.
|
|
63
|
-
"@babel/traverse": "7.18.
|
|
64
|
-
"@types/jest": "^28.1.
|
|
51
|
+
"@babel/cli": "7.18.10",
|
|
52
|
+
"@babel/core": "7.18.10",
|
|
53
|
+
"@babel/eslint-parser": "^7.18.9",
|
|
54
|
+
"@babel/generator": "7.18.12",
|
|
55
|
+
"@babel/node": "^7.18.10",
|
|
56
|
+
"@babel/parser": "^7.18.11",
|
|
57
|
+
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
58
|
+
"@babel/plugin-proposal-export-default-from": "7.18.10",
|
|
59
|
+
"@babel/plugin-proposal-object-rest-spread": "7.18.9",
|
|
60
|
+
"@babel/plugin-transform-runtime": "7.18.10",
|
|
61
|
+
"@babel/preset-env": "7.18.10",
|
|
62
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
63
|
+
"@babel/traverse": "7.18.11",
|
|
64
|
+
"@types/jest": "^28.1.6",
|
|
65
65
|
"babel-core": "7.0.0-bridge.0",
|
|
66
|
-
"babel-jest": "28.1.
|
|
66
|
+
"babel-jest": "^28.1.3",
|
|
67
67
|
"babel-watch": "^7.0.0",
|
|
68
68
|
"cross-env": "^7.0.2",
|
|
69
|
-
"eslint": "8.
|
|
69
|
+
"eslint": "8.21.0",
|
|
70
70
|
"eslint-config-prettier": "^8.5.0",
|
|
71
|
-
"eslint-plugin-prettier": "^4.
|
|
71
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
72
72
|
"glob": "8.0.3",
|
|
73
|
-
"jest": "
|
|
73
|
+
"jest": "28.1.3",
|
|
74
74
|
"jest-in-case": "^1.0.2",
|
|
75
75
|
"mkdirp": "1.0.4",
|
|
76
76
|
"prettier": "^2.7.1",
|
|
77
77
|
"regenerator-runtime": "^0.13.7",
|
|
78
|
-
"ts-jest": "^28.0.
|
|
78
|
+
"ts-jest": "^28.0.7",
|
|
79
79
|
"typescript": "^4.7.4"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@babel/runtime": "^7.18.
|
|
83
|
-
"@babel/types": "7.18.
|
|
82
|
+
"@babel/runtime": "^7.18.9",
|
|
83
|
+
"@babel/types": "7.18.10",
|
|
84
|
+
"@jest/transform": "28.1.3",
|
|
84
85
|
"ast-stringify": "0.1.0",
|
|
85
|
-
"case": "1.6.3"
|
|
86
|
+
"case": "1.6.3",
|
|
87
|
+
"deepmerge": "4.2.2"
|
|
86
88
|
},
|
|
87
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "8c35eebc33e7109da33ecb5f5bdeffc9a1b0d9af"
|
|
88
90
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { QueryMsg, ExecuteMsg } from '../types';
|
|
3
|
+
import { RenderContext } from '../context';
|
|
4
|
+
import { JSONSchema } from '../types';
|
|
5
|
+
export declare const CONSTANT_EXEC_PARAMS: (t.AssignmentPattern | t.Identifier)[];
|
|
6
|
+
export declare const FIXED_EXECUTE_PARAMS: t.Identifier[];
|
|
7
|
+
export declare const createWasmQueryMethod: (context: RenderContext, jsonschema: any) => t.ClassProperty;
|
|
8
|
+
export declare const createQueryClass: (context: RenderContext, className: string, implementsClassName: string, queryMsg: QueryMsg) => t.ExportNamedDeclaration;
|
|
9
|
+
export declare const getWasmMethodArgs: (context: RenderContext, jsonschema: JSONSchema) => t.ObjectProperty[];
|
|
10
|
+
export declare const createWasmExecMethod: (context: RenderContext, jsonschema: JSONSchema) => t.ClassProperty;
|
|
11
|
+
export declare const createExecuteClass: (context: RenderContext, className: string, implementsClassName: string, extendsClassName: string, execMsg: ExecuteMsg) => t.ExportNamedDeclaration;
|
|
12
|
+
export declare const createExecuteInterface: (context: RenderContext, className: string, extendsClassName: string | null, execMsg: ExecuteMsg) => t.ExportNamedDeclaration;
|
|
13
|
+
export declare const createPropertyFunctionWithObjectParams: (context: RenderContext, methodName: string, responseType: string, jsonschema: JSONSchema) => t.TSPropertySignature;
|
|
14
|
+
export declare const createPropertyFunctionWithObjectParamsForExec: (context: RenderContext, methodName: string, responseType: string, jsonschema: JSONSchema) => t.TSPropertySignature;
|
|
15
|
+
export declare const createQueryInterface: (context: RenderContext, className: string, queryMsg: QueryMsg) => t.ExportNamedDeclaration;
|
|
16
|
+
export declare const createTypeOrInterface: (context: RenderContext, Type: string, jsonschema: JSONSchema) => t.ExportNamedDeclaration;
|
|
17
|
+
export declare const createTypeInterface: (context: RenderContext, jsonschema: JSONSchema) => t.ExportNamedDeclaration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './client';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JSONSchema } from "../types";
|
|
2
|
+
export interface ReactQueryOptions {
|
|
3
|
+
optionalClient?: boolean;
|
|
4
|
+
v4?: boolean;
|
|
5
|
+
mutations?: boolean;
|
|
6
|
+
camelize?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface RenderOptions {
|
|
9
|
+
reactQuery: ReactQueryOptions;
|
|
10
|
+
}
|
|
11
|
+
export interface RenderContext {
|
|
12
|
+
schema: JSONSchema;
|
|
13
|
+
options: RenderOptions;
|
|
14
|
+
}
|
|
15
|
+
export declare const defaultOptions: RenderOptions;
|
|
16
|
+
export declare class RenderContext implements RenderContext {
|
|
17
|
+
schema: JSONSchema;
|
|
18
|
+
constructor(schema: JSONSchema, options?: RenderOptions);
|
|
19
|
+
refLookup($ref: string): JSONSchema;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './context';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { ExecuteMsg } from '../types';
|
|
3
|
+
export declare const createFromPartialClass: (context: RenderContext, className: string, implementsClassName: string, execMsg: ExecuteMsg) => t.ExportNamedDeclaration;
|
|
4
|
+
export declare const createFromPartialInterface: (context: RenderContext, className: string, execMsg: ExecuteMsg) => t.ExportNamedDeclaration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './from-partial';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './react-query';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { ExecuteMsg, QueryMsg } from '../types';
|
|
3
|
+
import { RenderContext } from '../context';
|
|
4
|
+
import { JSONSchema } from '../types';
|
|
5
|
+
interface ReactQueryHookQuery {
|
|
6
|
+
context: RenderContext;
|
|
7
|
+
hookName: string;
|
|
8
|
+
hookParamsTypeName: string;
|
|
9
|
+
hookKeyName: string;
|
|
10
|
+
responseType: string;
|
|
11
|
+
methodName: string;
|
|
12
|
+
jsonschema: any;
|
|
13
|
+
}
|
|
14
|
+
interface ReactQueryHooks {
|
|
15
|
+
context: RenderContext;
|
|
16
|
+
queryMsg: QueryMsg;
|
|
17
|
+
contractName: string;
|
|
18
|
+
QueryClient: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const createReactQueryHooks: ({ context, queryMsg, contractName, QueryClient }: ReactQueryHooks) => any;
|
|
21
|
+
export declare const createReactQueryHook: ({ context, hookName, hookParamsTypeName, responseType, hookKeyName, methodName, jsonschema }: ReactQueryHookQuery) => t.ExportNamedDeclaration;
|
|
22
|
+
interface ReactQueryMutationHookInterface {
|
|
23
|
+
context: RenderContext;
|
|
24
|
+
ExecuteClient: string;
|
|
25
|
+
mutationHookParamsTypeName: string;
|
|
26
|
+
jsonschema: JSONSchema;
|
|
27
|
+
useMutationTypeParameter: t.TSTypeParameterInstantiation;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Example:
|
|
31
|
+
```
|
|
32
|
+
export interface Cw4UpdateMembersMutation {
|
|
33
|
+
client: Cw4GroupClient
|
|
34
|
+
args: {
|
|
35
|
+
tokenId: string
|
|
36
|
+
remove: string[]
|
|
37
|
+
}
|
|
38
|
+
options?: Omit<
|
|
39
|
+
UseMutationOptions<ExecuteResult, Error, Pick<Cw4UpdateMembersMutation, 'args'>>,
|
|
40
|
+
'mutationFn'
|
|
41
|
+
>
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
*/
|
|
45
|
+
export declare const createReactQueryMutationArgsInterface: ({ context, ExecuteClient, mutationHookParamsTypeName, useMutationTypeParameter, jsonschema, }: ReactQueryMutationHookInterface) => t.ExportNamedDeclaration;
|
|
46
|
+
interface ReactQueryMutationHooks {
|
|
47
|
+
context: RenderContext;
|
|
48
|
+
execMsg: ExecuteMsg;
|
|
49
|
+
contractName: string;
|
|
50
|
+
ExecuteClient: string;
|
|
51
|
+
}
|
|
52
|
+
export declare const createReactQueryMutationHooks: ({ context, execMsg, contractName, ExecuteClient }: ReactQueryMutationHooks) => any;
|
|
53
|
+
interface ReactQueryMutationHook {
|
|
54
|
+
context: RenderContext;
|
|
55
|
+
mutationHookName: string;
|
|
56
|
+
mutationHookParamsTypeName: string;
|
|
57
|
+
execMethodName: string;
|
|
58
|
+
useMutationTypeParameter: t.TSTypeParameterInstantiation;
|
|
59
|
+
hasMsg: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* Example:
|
|
64
|
+
```
|
|
65
|
+
export const useCw4UpdateMembersMutation = ({ client, options }: Omit<Cw4UpdateMembersMutation, 'args'>) =>
|
|
66
|
+
useMutation<ExecuteResult, Error, Pick<Cw4UpdateMembersMutation, 'args'>>(
|
|
67
|
+
({ args }) => client.updateMembers(args),
|
|
68
|
+
options
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
*/
|
|
72
|
+
export declare const createReactQueryMutationHook: ({ context, mutationHookName, mutationHookParamsTypeName, execMethodName, useMutationTypeParameter, hasMsg, }: ReactQueryMutationHook) => t.ExportNamedDeclaration;
|
|
73
|
+
interface ReactQueryHookQueryInterface {
|
|
74
|
+
context: RenderContext;
|
|
75
|
+
QueryClient: string;
|
|
76
|
+
hookParamsTypeName: string;
|
|
77
|
+
responseType: string;
|
|
78
|
+
jsonschema: any;
|
|
79
|
+
}
|
|
80
|
+
export declare const createReactQueryHookInterface: ({ context, QueryClient, hookParamsTypeName, responseType, jsonschema }: ReactQueryHookQueryInterface) => t.ExportNamedDeclaration;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './recoil';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
|
-
import { QueryMsg } from '
|
|
3
|
-
|
|
4
|
-
export declare const createRecoilSelector: (keyPrefix: string, QueryClient: string, methodName: string) => t.ExportNamedDeclaration;
|
|
5
|
-
export declare const createRecoilSelectors: (keyPrefix: string, QueryClient: string, queryMsg: QueryMsg) => any;
|
|
2
|
+
import { QueryMsg } from '../types';
|
|
3
|
+
import { RenderContext } from '../context';
|
|
4
|
+
export declare const createRecoilSelector: (context: RenderContext, keyPrefix: string, QueryClient: string, methodName: string) => t.ExportNamedDeclaration;
|
|
5
|
+
export declare const createRecoilSelectors: (context: RenderContext, keyPrefix: string, QueryClient: string, queryMsg: QueryMsg) => any;
|
|
6
6
|
export declare const createRecoilQueryClientType: () => {
|
|
7
7
|
type: string;
|
|
8
8
|
id: {
|
|
@@ -27,4 +27,4 @@ export declare const createRecoilQueryClientType: () => {
|
|
|
27
27
|
}[];
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
export declare const createRecoilQueryClient: (keyPrefix: string, QueryClient: string) => t.ExportNamedDeclaration;
|
|
30
|
+
export declare const createRecoilQueryClient: (context: RenderContext, keyPrefix: string, QueryClient: string) => t.ExportNamedDeclaration;
|
|
@@ -22,3 +22,20 @@ export interface ExecuteMsg {
|
|
|
22
22
|
allOf?: any;
|
|
23
23
|
anyOf?: any;
|
|
24
24
|
}
|
|
25
|
+
export interface JSONSchema {
|
|
26
|
+
$ref?: string;
|
|
27
|
+
$schema?: string;
|
|
28
|
+
additionalProperties?: boolean;
|
|
29
|
+
allOf?: JSONSchema[];
|
|
30
|
+
anyOf?: JSONSchema[];
|
|
31
|
+
definitions?: Record<string, JSONSchema>;
|
|
32
|
+
description?: string;
|
|
33
|
+
oneOf?: JSONSchema[];
|
|
34
|
+
properties?: Record<string, JSONSchema>;
|
|
35
|
+
patternProperties?: Record<string, JSONSchema>;
|
|
36
|
+
items?: JSONSchema[] | JSONSchema;
|
|
37
|
+
additionalItems?: JSONSchema;
|
|
38
|
+
required?: string[];
|
|
39
|
+
title?: string;
|
|
40
|
+
type?: string;
|
|
41
|
+
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
|
-
import { Field, QueryMsg, ExecuteMsg } from '
|
|
2
|
+
import { Field, QueryMsg, ExecuteMsg } from '../types';
|
|
3
3
|
import { TSTypeAnnotation, TSExpressionWithTypeArguments } from '@babel/types';
|
|
4
|
+
export declare const propertySignature: (name: string, typeAnnotation: t.TSTypeAnnotation, optional?: boolean) => {
|
|
5
|
+
type: string;
|
|
6
|
+
key: t.Identifier;
|
|
7
|
+
typeAnnotation: t.TSTypeAnnotation;
|
|
8
|
+
optional: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const identifier: (name: string, typeAnnotation: t.TSTypeAnnotation, optional?: boolean) => t.Identifier;
|
|
11
|
+
export declare const tsTypeOperator: (typeAnnotation: t.TSType, operator: string) => t.TSTypeOperator;
|
|
4
12
|
export declare const getMessageProperties: (msg: QueryMsg | ExecuteMsg) => any;
|
|
5
13
|
export declare const tsPropertySignature: (key: t.Expression, typeAnnotation: t.TSTypeAnnotation, optional: boolean) => t.TSPropertySignature;
|
|
6
14
|
export declare const tsObjectPattern: (properties: (t.RestElement | t.ObjectProperty)[], typeAnnotation: t.TSTypeAnnotation) => t.ObjectPattern;
|
|
@@ -31,3 +39,15 @@ export declare const getFieldDimensionality: (field: Field) => {
|
|
|
31
39
|
};
|
|
32
40
|
export declare const memberExpressionOrIdentifier: (names: any) => any;
|
|
33
41
|
export declare const memberExpressionOrIdentifierSnake: (names: any) => any;
|
|
42
|
+
/**
|
|
43
|
+
* If optional, return a conditional, otherwise just the expression
|
|
44
|
+
*/
|
|
45
|
+
export declare const optionalConditionalExpression: (test: t.Expression, expression: t.Expression, alternate: t.Expression, optional?: boolean) => t.Expression;
|
|
46
|
+
export declare const typeRefOrOptionalUnion: (identifier: t.Identifier, optional?: boolean) => t.TSType;
|
|
47
|
+
export declare const parameterizedTypeReference: (identifier: string, from: t.TSType, omit: string | Array<string>) => t.TSTypeReference;
|
|
48
|
+
/**
|
|
49
|
+
* omitTypeReference(t.tsTypeReference(t.identifier('Cw4UpdateMembersMutation'),),'args').....
|
|
50
|
+
* Omit<Cw4UpdateMembersMutation, 'args'>
|
|
51
|
+
*/
|
|
52
|
+
export declare const omitTypeReference: (from: t.TSType, omit: string | Array<string>) => t.TSTypeReference;
|
|
53
|
+
export declare const pickTypeReference: (from: t.TSType, pick: string | Array<string>) => t.TSTypeReference;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { TSTypeAnnotation } from '@babel/types';
|
|
3
|
+
import { RenderContext } from '../context';
|
|
4
|
+
import { JSONSchema } from '../types';
|
|
5
|
+
export declare const getTypeFromRef: ($ref: any) => t.TSTypeReference;
|
|
6
|
+
export declare const getType: (type: any) => t.TSBooleanKeyword | t.TSNumberKeyword | t.TSStringKeyword;
|
|
7
|
+
export declare const getPropertyType: (context: RenderContext, schema: JSONSchema, prop: string) => {
|
|
8
|
+
type: any;
|
|
9
|
+
optional: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function getPropertySignatureFromProp(context: RenderContext, jsonschema: JSONSchema, prop: string, camelize: boolean): {
|
|
12
|
+
type: string;
|
|
13
|
+
key: t.Identifier;
|
|
14
|
+
typeAnnotation: t.TSTypeAnnotation;
|
|
15
|
+
optional: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const getParamsTypeAnnotation: (context: RenderContext, jsonschema: any, camelize?: boolean) => t.TSTypeAnnotation;
|
|
18
|
+
export declare const createTypedObjectParams: (context: RenderContext, jsonschema: JSONSchema, camelize?: boolean) => t.ObjectPattern;
|
package/main/messages.spec.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
6
|
-
|
|
7
|
-
var _execute_msg_for__empty = _interopRequireDefault(require("./../../../__fixtures__/basic/execute_msg_for__empty.json"));
|
|
8
|
-
|
|
9
|
-
var _messages = require("./messages");
|
|
10
|
-
|
|
11
|
-
var expectCode = function expectCode(ast) {
|
|
12
|
-
expect((0, _generator["default"])(ast).code).toMatchSnapshot();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var printCode = function printCode(ast) {
|
|
16
|
-
console.log((0, _generator["default"])(ast).code);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it('execute classes', function () {
|
|
20
|
-
expectCode((0, _messages.createFromPartialClass)('SG721MessageComposer', 'SG721Message', _execute_msg_for__empty["default"]));
|
|
21
|
-
});
|
|
22
|
-
it('createFromPartialInterface', function () {
|
|
23
|
-
expectCode((0, _messages.createFromPartialInterface)('SG721Message', _execute_msg_for__empty["default"]));
|
|
24
|
-
});
|
package/main/wasm.arrays.spec.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
6
|
-
|
|
7
|
-
var _schema = _interopRequireDefault(require("./../../../__fixtures__/arrays/schema/schema.json"));
|
|
8
|
-
|
|
9
|
-
var _wasm = require("./wasm");
|
|
10
|
-
|
|
11
|
-
var expectCode = function expectCode(ast) {
|
|
12
|
-
expect((0, _generator["default"])(ast).code).toMatchSnapshot();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var printCode = function printCode(ast) {
|
|
16
|
-
console.log((0, _generator["default"])(ast).code);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it('execute_msg_for__empty', function () {
|
|
20
|
-
expectCode((0, _wasm.createTypeInterface)(_schema["default"]));
|
|
21
|
-
});
|
|
22
|
-
it('query classes', function () {
|
|
23
|
-
expectCode((0, _wasm.createQueryClass)('SG721QueryClient', 'SG721ReadOnlyInstance', _schema["default"]));
|
|
24
|
-
});
|
|
25
|
-
it('execute classes array types', function () {
|
|
26
|
-
expectCode((0, _wasm.createExecuteClass)('SG721Client', 'SG721Instance', null, _schema["default"]));
|
|
27
|
-
});
|
|
28
|
-
it('execute interfaces no extends', function () {
|
|
29
|
-
expectCode((0, _wasm.createExecuteInterface)('SG721Instance', null, _schema["default"]));
|
|
30
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
6
|
-
|
|
7
|
-
var _execute_msg = _interopRequireDefault(require("./../../../__fixtures__/daodao/cw-named-groups/execute_msg.json"));
|
|
8
|
-
|
|
9
|
-
var _wasm = require("./wasm");
|
|
10
|
-
|
|
11
|
-
var expectCode = function expectCode(ast) {
|
|
12
|
-
expect((0, _generator["default"])(ast).code).toMatchSnapshot();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var printCode = function printCode(ast) {
|
|
16
|
-
console.log((0, _generator["default"])(ast).code);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it('execute_msg', function () {
|
|
20
|
-
expectCode((0, _wasm.createTypeInterface)(_execute_msg["default"]));
|
|
21
|
-
});
|
|
22
|
-
it('query classes', function () {
|
|
23
|
-
expectCode((0, _wasm.createQueryClass)('SG721QueryClient', 'SG721ReadOnlyInstance', _execute_msg["default"]));
|
|
24
|
-
});
|
|
25
|
-
it('execute classes array types', function () {
|
|
26
|
-
expectCode((0, _wasm.createExecuteClass)('SG721Client', 'SG721Instance', null, _execute_msg["default"]));
|
|
27
|
-
});
|
|
28
|
-
it('execute interfaces no extends', function () {
|
|
29
|
-
expectCode((0, _wasm.createExecuteInterface)('SG721Instance', null, _execute_msg["default"]));
|
|
30
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
6
|
-
|
|
7
|
-
var _execute_msg = _interopRequireDefault(require("./../../../__fixtures__/daodao/cw-proposal-single/execute_msg.json"));
|
|
8
|
-
|
|
9
|
-
var _query_msg = _interopRequireDefault(require("./../../../__fixtures__/daodao/cw-proposal-single/query_msg.json"));
|
|
10
|
-
|
|
11
|
-
var _wasm = require("./wasm");
|
|
12
|
-
|
|
13
|
-
var expectCode = function expectCode(ast) {
|
|
14
|
-
expect((0, _generator["default"])(ast).code).toMatchSnapshot();
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
var printCode = function printCode(ast) {
|
|
18
|
-
console.log((0, _generator["default"])(ast).code);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
it('execute_msg_for', function () {
|
|
22
|
-
expectCode((0, _wasm.createTypeInterface)(_execute_msg["default"]));
|
|
23
|
-
});
|
|
24
|
-
it('query classes', function () {
|
|
25
|
-
expectCode((0, _wasm.createQueryClass)('SG721QueryClient', 'SG721ReadOnlyInstance', _query_msg["default"]));
|
|
26
|
-
});
|
|
27
|
-
it('execute classes array types', function () {
|
|
28
|
-
expectCode((0, _wasm.createExecuteClass)('SG721Client', 'SG721Instance', null, _execute_msg["default"]));
|
|
29
|
-
});
|
|
30
|
-
it('execute interfaces no extends', function () {
|
|
31
|
-
expectCode((0, _wasm.createExecuteInterface)('SG721Instance', null, _execute_msg["default"]));
|
|
32
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
6
|
-
|
|
7
|
-
var _query_msg = _interopRequireDefault(require("./../../../__fixtures__/daodao/cw-admin-factory/query_msg.json"));
|
|
8
|
-
|
|
9
|
-
var _wasm = require("./wasm");
|
|
10
|
-
|
|
11
|
-
var expectCode = function expectCode(ast) {
|
|
12
|
-
expect((0, _generator["default"])(ast).code).toMatchSnapshot();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var printCode = function printCode(ast) {
|
|
16
|
-
console.log((0, _generator["default"])(ast).code);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it('query classes', function () {
|
|
20
|
-
expectCode((0, _wasm.createQueryClass)('SG721QueryClient', 'SG721ReadOnlyInstance', _query_msg["default"]));
|
|
21
|
-
});
|
|
22
|
-
it('query interface', function () {
|
|
23
|
-
expectCode((0, _wasm.createQueryInterface)('ReadOnlyInstance', _query_msg["default"]));
|
|
24
|
-
});
|
package/main/wasm.sg721.spec.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _generator = _interopRequireDefault(require("@babel/generator"));
|
|
6
|
-
|
|
7
|
-
var _execute_msg_for__empty = _interopRequireDefault(require("./../../../__fixtures__/sg721/execute_msg_for__empty.json"));
|
|
8
|
-
|
|
9
|
-
var _wasm = require("./wasm");
|
|
10
|
-
|
|
11
|
-
var expectCode = function expectCode(ast) {
|
|
12
|
-
expect((0, _generator["default"])(ast).code).toMatchSnapshot();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var printCode = function printCode(ast) {
|
|
16
|
-
console.log((0, _generator["default"])(ast).code);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it('execute_msg_for__empty', function () {
|
|
20
|
-
expectCode((0, _wasm.createTypeInterface)(_execute_msg_for__empty["default"]));
|
|
21
|
-
});
|
|
22
|
-
it('query classes', function () {
|
|
23
|
-
expectCode((0, _wasm.createQueryClass)('SG721QueryClient', 'SG721ReadOnlyInstance', _execute_msg_for__empty["default"]));
|
|
24
|
-
});
|
|
25
|
-
it('execute classes array types', function () {
|
|
26
|
-
expectCode((0, _wasm.createExecuteClass)('SG721Client', 'SG721Instance', null, _execute_msg_for__empty["default"]));
|
|
27
|
-
});
|
|
28
|
-
it('execute interfaces no extends', function () {
|
|
29
|
-
expectCode((0, _wasm.createExecuteInterface)('SG721Instance', null, _execute_msg_for__empty["default"]));
|
|
30
|
-
});
|