wasm-ast-types 0.7.1 → 0.8.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.
@@ -150,7 +150,8 @@ var createPropertyFunctionWithObjectParams = function createPropertyFunctionWith
150
150
  typeAnnotation: (0, _utils.promiseTypeAnnotation)(responseType),
151
151
  parameters: obj ? [obj] : []
152
152
  };
153
- return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(func));
153
+ return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation( // @ts-ignore:next-line
154
+ func));
154
155
  };
155
156
 
156
157
  exports.createPropertyFunctionWithObjectParams = createPropertyFunctionWithObjectParams;
@@ -163,7 +164,8 @@ var createPropertyFunctionWithObjectParamsForExec = function createPropertyFunct
163
164
  typeAnnotation: (0, _utils.promiseTypeAnnotation)(responseType),
164
165
  parameters: obj ? [obj].concat(FIXED_EXECUTE_PARAMS) : FIXED_EXECUTE_PARAMS
165
166
  };
166
- return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(func));
167
+ return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation( // @ts-ignore:next-line
168
+ func));
167
169
  };
168
170
 
169
171
  exports.createPropertyFunctionWithObjectParamsForExec = createPropertyFunctionWithObjectParamsForExec;
@@ -198,7 +200,8 @@ var createTypeOrInterface = function createTypeOrInterface(context, Type, jsonsc
198
200
 
199
201
  return (0, _babel.propertySignature)((0, _case.camel)(prop), t.tsTypeAnnotation(type), optional);
200
202
  });
201
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(Type), null, [], t.tsInterfaceBody((0, _toConsumableArray2["default"])(props))));
203
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(Type), null, [], t.tsInterfaceBody( // @ts-ignore:next-line
204
+ (0, _toConsumableArray2["default"])(props))));
202
205
  };
203
206
 
204
207
  exports.createTypeOrInterface = createTypeOrInterface;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _arraysRef = _interopRequireDefault(require("../../../../../__fixtures__/misc/schema/arrays-ref.json"));
6
+
7
+ var _client = require("../client");
8
+
9
+ var _context = require("../../context");
10
+
11
+ var _testUtils = require("../../../test-utils");
12
+
13
+ var ctx = new _context.RenderContext(_arraysRef["default"]);
14
+ it('execute_msg_for__empty', function () {
15
+ (0, _testUtils.expectCode)((0, _client.createTypeInterface)(ctx, _arraysRef["default"]));
16
+ });
17
+ it('query classes', function () {
18
+ (0, _testUtils.expectCode)((0, _client.createQueryClass)(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', _arraysRef["default"]));
19
+ });
20
+ it('execute classes array types', function () {
21
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(ctx, 'SG721Client', 'SG721Instance', null, _arraysRef["default"]));
22
+ });
23
+ it('execute interfaces no extends', function () {
24
+ (0, _testUtils.expectCode)((0, _client.createExecuteInterface)(ctx, 'SG721Instance', null, _arraysRef["default"]));
25
+ });
@@ -84,5 +84,6 @@ var createPropertyFunctionWithObjectParamsForMessageComposer = function createPr
84
84
  typeAnnotation: t.tsTypeAnnotation(t.tsTypeReference(t.identifier(responseType))),
85
85
  parameters: obj ? [obj].concat(fixedParams) : fixedParams
86
86
  };
87
- return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(func));
87
+ return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation( // @ts-ignore:next-line
88
+ func));
88
89
  };
@@ -33,11 +33,17 @@ var createReactQueryHooks = function createReactQueryHooks(_ref) {
33
33
  contractName = _ref.contractName,
34
34
  QueryClient = _ref.QueryClient;
35
35
  var options = context.options.reactQuery;
36
- return (0, _utils.getMessageProperties)(queryMsg).reduce(function (m, schema) {
36
+ var genericQueryInterfaceName = "".concat((0, _case.pascal)(contractName), "ReactQuery");
37
+ var body = [createReactQueryHookGenericInterface({
38
+ context: context,
39
+ QueryClient: QueryClient,
40
+ genericQueryInterfaceName: genericQueryInterfaceName
41
+ })];
42
+ body.push.apply(body, (0, _toConsumableArray2["default"])((0, _utils.getMessageProperties)(queryMsg).reduce(function (m, schema) {
37
43
  var underscoreName = Object.keys(schema.properties)[0];
38
44
  var methodName = (0, _case.camel)(underscoreName);
39
- var hookName = "use".concat((0, _case.pascal)(contractName)).concat((0, _case.pascal)(methodName), "Query");
40
45
  var hookParamsTypeName = "".concat((0, _case.pascal)(contractName)).concat((0, _case.pascal)(methodName), "Query");
46
+ var hookName = "use".concat(hookParamsTypeName);
41
47
  var responseType = (0, _case.pascal)("".concat(methodName, "Response"));
42
48
  var getterKey = (0, _case.camel)("".concat(contractName).concat((0, _case.pascal)(methodName)));
43
49
  var jsonschema = schema.properties[underscoreName];
@@ -45,9 +51,9 @@ var createReactQueryHooks = function createReactQueryHooks(_ref) {
45
51
  context: context,
46
52
  hookParamsTypeName: hookParamsTypeName,
47
53
  responseType: responseType,
54
+ queryInterfaceName: genericQueryInterfaceName,
48
55
  QueryClient: QueryClient,
49
- jsonschema: jsonschema,
50
- options: options
56
+ jsonschema: jsonschema
51
57
  }), createReactQueryHook({
52
58
  context: context,
53
59
  methodName: methodName,
@@ -57,7 +63,8 @@ var createReactQueryHooks = function createReactQueryHooks(_ref) {
57
63
  hookKeyName: getterKey,
58
64
  jsonschema: jsonschema
59
65
  })].concat((0, _toConsumableArray2["default"])(m));
60
- }, []);
66
+ }, [])));
67
+ return body;
61
68
  };
62
69
 
63
70
  exports.createReactQueryHooks = createReactQueryHooks;
@@ -92,8 +99,8 @@ var createReactQueryHook = function createReactQueryHook(_ref2) {
92
99
 
93
100
  return t.exportNamedDeclaration(t.functionDeclaration(t.identifier(hookName), [(0, _utils.tsObjectPattern)((0, _toConsumableArray2["default"])(props.map(function (prop) {
94
101
  return t.objectProperty(t.identifier(prop), t.identifier(prop), false, true);
95
- })), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName))))], t.blockStatement([t.returnStatement((0, _utils.callExpression)(t.identifier('useQuery'), [t.arrayExpression(generateUseQueryQueryKey(hookKeyName, props, options.optionalClient)), t.arrowFunctionExpression([], (0, _babel.optionalConditionalExpression)(t.identifier('client'), t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), t.identifier('undefined'), options.optionalClient), false), options.optionalClient ? t.objectExpression([t.spreadElement(t.identifier('options')), t.objectProperty(t.identifier('enabled'), t.logicalExpression('&&', t.unaryExpression('!', t.unaryExpression('!', t.identifier('client'))), t.conditionalExpression( // explicitly check for undefined
96
- t.binaryExpression('!=', t.optionalMemberExpression(t.identifier('options'), t.identifier('enabled'), false, true), t.identifier('undefined')), t.memberExpression(t.identifier('options'), t.identifier('enabled')), t.booleanLiteral(true))))]) : t.identifier('options')], t.tsTypeParameterInstantiation([(0, _babel.typeRefOrOptionalUnion)(t.identifier(responseType), options.optionalClient), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(responseType)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))])))])));
102
+ })), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName))))], t.blockStatement([t.returnStatement((0, _utils.callExpression)(t.identifier('useQuery'), [t.arrayExpression(generateUseQueryQueryKey(hookKeyName, props, options.optionalClient)), t.arrowFunctionExpression([], (0, _babel.optionalConditionalExpression)(t.identifier('client'), t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), t.callExpression(t.memberExpression(t.identifier('Promise'), t.identifier('reject')), [t.newExpression(t.identifier('Error'), [t.stringLiteral('Invalid client')])]), options.optionalClient), false), options.optionalClient ? t.objectExpression([t.spreadElement(t.identifier('options')), t.objectProperty(t.identifier('enabled'), t.logicalExpression('&&', t.unaryExpression('!', t.unaryExpression('!', t.identifier('client'))), t.conditionalExpression( // explicitly check for undefined
103
+ t.binaryExpression('!=', t.optionalMemberExpression(t.identifier('options'), t.identifier('enabled'), false, true), t.identifier('undefined')), t.memberExpression(t.identifier('options'), t.identifier('enabled')), t.booleanLiteral(true))))]) : t.identifier('options')], t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(responseType)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))])))])));
97
104
  };
98
105
 
99
106
  exports.createReactQueryHook = createReactQueryHook;
@@ -126,11 +133,15 @@ var createReactQueryMutationArgsInterface = function createReactQueryMutationArg
126
133
 
127
134
  if (msgType) {
128
135
  body.push(t.tsPropertySignature(t.identifier('msg'), msgType));
129
- } // fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]
136
+ }
130
137
 
138
+ context.addUtil('StdFee');
139
+ context.addUtil('Coin'); // fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]
131
140
 
132
- var optionalArgs = t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation(t.tsTypeLiteral(_client.FIXED_EXECUTE_PARAMS.map(function (param) {
133
- return (0, _babel.propertySignature)(param.name, param.typeAnnotation, param.optional);
141
+ var optionalArgs = t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation( // @ts-ignore:next-line
142
+ t.tsTypeLiteral(_client.FIXED_EXECUTE_PARAMS.map(function (param) {
143
+ return (0, _babel.propertySignature)(param.name, // @ts-ignore:next-line
144
+ param.typeAnnotation, param.optional);
134
145
  }))));
135
146
  optionalArgs.optional = true;
136
147
  body.push(optionalArgs);
@@ -226,24 +237,36 @@ var createReactQueryMutationHook = function createReactQueryMutationHook(_ref5)
226
237
 
227
238
  exports.createReactQueryMutationHook = createReactQueryMutationHook;
228
239
 
229
- var createReactQueryHookInterface = function createReactQueryHookInterface(_ref6) {
240
+ function createReactQueryHookGenericInterface(_ref6) {
230
241
  var context = _ref6.context,
231
242
  QueryClient = _ref6.QueryClient,
232
- hookParamsTypeName = _ref6.hookParamsTypeName,
233
- responseType = _ref6.responseType,
234
- jsonschema = _ref6.jsonschema;
235
- // merge the user options with the defaults
243
+ genericQueryInterfaceName = _ref6.genericQueryInterfaceName;
236
244
  var options = context.options.reactQuery;
245
+ var genericTypeName = 'TResponse';
237
246
  context.addUtil('UseQueryOptions');
238
- var typedUseQueryOptions = t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([(0, _babel.typeRefOrOptionalUnion)(t.identifier(responseType), options.optionalClient), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(responseType)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))]));
239
- var body = [(0, _utils.tsPropertySignature)(t.identifier('client'), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(QueryClient))), options.optionalClient), (0, _utils.tsPropertySignature)(t.identifier('options'), t.tsTypeAnnotation(options.version === 'v4' ? t.tSIntersectionType([(0, _babel.omitTypeReference)(typedUseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'"), t.tSTypeLiteral([t.tsPropertySignature(t.identifier('initialData?'), t.tsTypeAnnotation(t.tsUndefinedKeyword()))])]) : typedUseQueryOptions), true)];
247
+ var typedUseQueryOptions = t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(genericTypeName)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(genericTypeName)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))]));
248
+ var body = [(0, _utils.tsPropertySignature)(t.identifier('client'), t.tsTypeAnnotation(options.optionalClient ? t.tsUnionType([t.tsTypeReference(t.identifier(QueryClient)), t.tsUndefinedKeyword()]) : t.tsTypeReference(t.identifier(QueryClient))), false), (0, _utils.tsPropertySignature)(t.identifier('options'), t.tsTypeAnnotation(options.version === 'v4' ? t.tSIntersectionType([(0, _babel.omitTypeReference)(typedUseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'"), t.tSTypeLiteral([t.tsPropertySignature(t.identifier('initialData?'), t.tsTypeAnnotation(t.tsUndefinedKeyword()))])]) : typedUseQueryOptions), true)];
249
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(genericQueryInterfaceName), t.tsTypeParameterDeclaration([t.tsTypeParameter(undefined, undefined, genericTypeName)]), [], t.tSInterfaceBody(body)));
250
+ }
251
+
252
+ var createReactQueryHookInterface = function createReactQueryHookInterface(_ref7) {
253
+ var context = _ref7.context,
254
+ QueryClient = _ref7.QueryClient,
255
+ hookParamsTypeName = _ref7.hookParamsTypeName,
256
+ queryInterfaceName = _ref7.queryInterfaceName,
257
+ responseType = _ref7.responseType,
258
+ jsonschema = _ref7.jsonschema;
259
+ // merge the user options with the defaults
260
+ var options = context.options.reactQuery;
261
+ var body = [];
240
262
  var props = getProps(context, jsonschema);
241
263
 
242
264
  if (props.length) {
243
- body.push(t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation(t.tsTypeLiteral(props))));
265
+ body.push(t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation( // @ts-ignore:next-line
266
+ t.tsTypeLiteral(props))));
244
267
  }
245
268
 
246
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), null, [], t.tsInterfaceBody(body)));
269
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), null, [t.tSExpressionWithTypeArguments(t.identifier(queryInterfaceName), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType))]))], t.tsInterfaceBody(body)));
247
270
  };
248
271
 
249
272
  exports.createReactQueryHookInterface = createReactQueryHookInterface;
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.typedIdentifier = exports.typeRefOrOptionalUnion = exports.tsTypeOperator = exports.tsPropertySignature = exports.tsObjectPattern = exports.shorthandProperty = exports.recursiveNamespace = exports.propertySignature = exports.promiseTypeAnnotation = exports.pickTypeReference = exports.parameterizedTypeReference = exports.optionalConditionalExpression = exports.omitTypeReference = exports.memberExpressionOrIdentifierSnake = exports.memberExpressionOrIdentifier = exports.importStmt = exports.importAs = exports.importAminoMsg = exports.identifier = exports.getMessageProperties = exports.getFieldDimensionality = exports.classProperty = exports.classDeclaration = exports.callExpression = exports.bindMethod = exports.arrowFunctionExpression = exports.arrayTypeNDimensions = exports.FieldTypeAsts = void 0;
10
+ exports.typedIdentifier = exports.typeRefOrUnionWithUndefined = exports.tsTypeOperator = exports.tsPropertySignature = exports.tsObjectPattern = exports.shorthandProperty = exports.recursiveNamespace = exports.propertySignature = exports.promiseTypeAnnotation = exports.pickTypeReference = exports.parameterizedTypeReference = exports.optionalConditionalExpression = exports.omitTypeReference = exports.memberExpressionOrIdentifierSnake = exports.memberExpressionOrIdentifier = exports.importStmt = exports.importAs = exports.importAminoMsg = exports.identifier = exports.getMessageProperties = exports.getFieldDimensionality = exports.classProperty = exports.classDeclaration = exports.callExpression = exports.bindMethod = exports.arrowFunctionExpression = exports.arrayTypeNDimensions = exports.FieldTypeAsts = void 0;
11
11
 
12
12
  var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
13
13
 
@@ -280,13 +280,13 @@ var optionalConditionalExpression = function optionalConditionalExpression(test,
280
280
 
281
281
  exports.optionalConditionalExpression = optionalConditionalExpression;
282
282
 
283
- var typeRefOrOptionalUnion = function typeRefOrOptionalUnion(identifier) {
283
+ var typeRefOrUnionWithUndefined = function typeRefOrUnionWithUndefined(identifier) {
284
284
  var optional = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
285
285
  var typeReference = t.tsTypeReference(identifier);
286
286
  return optional ? t.tsUnionType([typeReference, t.tsUndefinedKeyword()]) : typeReference;
287
287
  };
288
288
 
289
- exports.typeRefOrOptionalUnion = typeRefOrOptionalUnion;
289
+ exports.typeRefOrUnionWithUndefined = typeRefOrUnionWithUndefined;
290
290
 
291
291
  var parameterizedTypeReference = function parameterizedTypeReference(identifier, from, omit) {
292
292
  return t.tsTypeReference(t.identifier(identifier), t.tsTypeParameterInstantiation([from, typeof omit === 'string' ? t.tsLiteralType(t.stringLiteral(omit)) : t.tsUnionType(omit.map(function (o) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _typeof = require("@babel/runtime/helpers/typeof");
5
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
6
6
 
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
@@ -13,6 +13,8 @@ exports.getTypeFromRef = exports.getType = exports.getPropertyType = void 0;
13
13
 
14
14
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
15
 
16
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
17
+
16
18
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
19
 
18
20
  var t = _interopRequireWildcard(require("@babel/types"));
@@ -23,7 +25,7 @@ var _babel = require("./babel");
23
25
 
24
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
27
 
26
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
29
 
28
30
  var getTypeStrFromRef = function getTypeStrFromRef($ref) {
29
31
  if ($ref !== null && $ref !== void 0 && $ref.startsWith('#/definitions/')) {
@@ -43,10 +45,22 @@ var getArrayTypeFromRef = function getArrayTypeFromRef($ref) {
43
45
  return t.tsArrayType(getTypeFromRef($ref));
44
46
  };
45
47
 
48
+ var getTypeOrRef = function getTypeOrRef(obj) {
49
+ if (obj.type) {
50
+ return getType(obj.type);
51
+ }
52
+
53
+ if (obj.$ref) {
54
+ return getTypeFromRef(obj.$ref);
55
+ }
56
+
57
+ throw new Error('contact maintainers cannot find type for ' + obj);
58
+ };
59
+
46
60
  var getArrayTypeFromItems = function getArrayTypeFromItems(items) {
47
61
  if (items.type === 'array') {
48
62
  if (Array.isArray(items.items)) {
49
- return t.tsArrayType(t.tsArrayType(getType(items.items[0].type)));
63
+ return t.tsArrayType(t.tsArrayType(getTypeOrRef(items.items[0])));
50
64
  } else {
51
65
  return t.tsArrayType(getArrayTypeFromItems(items.items));
52
66
  }
@@ -118,12 +132,16 @@ var getPropertyType = function getPropertyType(context, schema, prop) {
118
132
 
119
133
  if (typeof info.type === 'string') {
120
134
  if (info.type === 'array') {
121
- if (info.items.$ref) {
122
- type = getArrayTypeFromRef(info.items.$ref);
123
- } else if (info.items.title) {
124
- type = t.tsArrayType(t.tsTypeReference(t.identifier(info.items.title)));
125
- } else if (info.items.type) {
126
- type = getArrayTypeFromItems(info.items);
135
+ if ((0, _typeof2["default"])(info.items) === 'object' && !Array.isArray(info.items)) {
136
+ if (info.items.$ref) {
137
+ type = getArrayTypeFromRef(info.items.$ref);
138
+ } else if (info.items.title) {
139
+ type = t.tsArrayType(t.tsTypeReference(t.identifier(info.items.title)));
140
+ } else if (info.items.type) {
141
+ type = getArrayTypeFromItems(info.items);
142
+ } else {
143
+ throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
144
+ }
127
145
  } else {
128
146
  throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
129
147
  }
@@ -146,7 +164,7 @@ var getPropertyType = function getPropertyType(context, schema, prop) {
146
164
  throw new Error('please report this to maintainers (field type): ' + JSON.stringify(info, null, 2));
147
165
  }
148
166
 
149
- if (_nullableType === 'array') {
167
+ if (_nullableType === 'array' && (0, _typeof2["default"])(info.items) === 'object' && !Array.isArray(info.items)) {
150
168
  type = t.tsArrayType(getType(info.items.type));
151
169
  } else {
152
170
  type = getType(_nullableType);
@@ -188,7 +206,8 @@ function getPropertySignatureFromProp(context, jsonschema, prop, camelize) {
188
206
  if (el.title) return el.title;
189
207
  if (el.$ref) return getTypeStrFromRef(el.$ref);
190
208
  return el.type;
191
- });
209
+ }); // @ts-ignore:next-line
210
+
192
211
  var uniqUnionTypes = (0, _toConsumableArray2["default"])(new Set(unionTypes));
193
212
 
194
213
  if (uniqUnionTypes.length === 1) {
@@ -207,7 +226,8 @@ function getPropertySignatureFromProp(context, jsonschema, prop, camelize) {
207
226
  if (el.title) return el.title;
208
227
  if (el.$ref) return getTypeStrFromRef(el.$ref);
209
228
  return el.type;
210
- });
229
+ }); // @ts-ignore:next-line
230
+
211
231
 
212
232
  var _uniqUnionTypes = (0, _toConsumableArray2["default"])(new Set(_unionTypes));
213
233
 
@@ -248,7 +268,8 @@ var getParamsTypeAnnotation = function getParamsTypeAnnotation(context, jsonsche
248
268
  var typedParams = keys.map(function (prop) {
249
269
  return getPropertySignatureFromProp(context, jsonschema, prop, camelize);
250
270
  });
251
- return t.tsTypeAnnotation(t.tsTypeLiteral((0, _toConsumableArray2["default"])(typedParams)));
271
+ return t.tsTypeAnnotation(t.tsTypeLiteral( // @ts-ignore:next-line
272
+ (0, _toConsumableArray2["default"])(typedParams)));
252
273
  };
253
274
 
254
275
  exports.getParamsTypeAnnotation = getParamsTypeAnnotation;
@@ -95,7 +95,8 @@ export const createPropertyFunctionWithObjectParams = (context, methodName, resp
95
95
  typeAnnotation: promiseTypeAnnotation(responseType),
96
96
  parameters: obj ? [obj] : []
97
97
  };
98
- return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(func));
98
+ return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation( // @ts-ignore:next-line
99
+ func));
99
100
  };
100
101
  export const createPropertyFunctionWithObjectParamsForExec = (context, methodName, responseType, jsonschema) => {
101
102
  context.addUtil('Coin');
@@ -105,7 +106,8 @@ export const createPropertyFunctionWithObjectParamsForExec = (context, methodNam
105
106
  typeAnnotation: promiseTypeAnnotation(responseType),
106
107
  parameters: obj ? [obj, ...FIXED_EXECUTE_PARAMS] : FIXED_EXECUTE_PARAMS
107
108
  };
108
- return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(func));
109
+ return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation( // @ts-ignore:next-line
110
+ func));
109
111
  };
110
112
  export const createQueryInterface = (context, className, queryMsg) => {
111
113
  const methods = getMessageProperties(queryMsg).map(jsonschema => {
@@ -132,7 +134,8 @@ export const createTypeOrInterface = (context, Type, jsonschema) => {
132
134
  } = getPropertyType(context, jsonschema, prop);
133
135
  return propertySignature(camel(prop), t.tsTypeAnnotation(type), optional);
134
136
  });
135
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(Type), null, [], t.tsInterfaceBody([...props])));
137
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(Type), null, [], t.tsInterfaceBody( // @ts-ignore:next-line
138
+ [...props])));
136
139
  };
137
140
  export const createTypeInterface = (context, jsonschema) => {
138
141
  const Type = jsonschema.title;
@@ -0,0 +1,17 @@
1
+ import message from '../../../../../__fixtures__/misc/schema/arrays-ref.json';
2
+ import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
3
+ import { RenderContext } from '../../context';
4
+ import { expectCode } from '../../../test-utils';
5
+ const ctx = new RenderContext(message);
6
+ it('execute_msg_for__empty', () => {
7
+ expectCode(createTypeInterface(ctx, message));
8
+ });
9
+ it('query classes', () => {
10
+ expectCode(createQueryClass(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', message));
11
+ });
12
+ it('execute classes array types', () => {
13
+ expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', null, message));
14
+ });
15
+ it('execute interfaces no extends', () => {
16
+ expectCode(createExecuteInterface(ctx, 'SG721Instance', null, message));
17
+ });
@@ -53,5 +53,6 @@ const createPropertyFunctionWithObjectParamsForMessageComposer = (context, metho
53
53
  typeAnnotation: t.tsTypeAnnotation(t.tsTypeReference(t.identifier(responseType))),
54
54
  parameters: obj ? [obj, ...fixedParams] : fixedParams
55
55
  };
56
- return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation(func));
56
+ return t.tSPropertySignature(t.identifier(methodName), t.tsTypeAnnotation( // @ts-ignore:next-line
57
+ func));
57
58
  };
@@ -1,7 +1,7 @@
1
1
  import * as t from '@babel/types';
2
2
  import { camel, pascal } from 'case';
3
3
  import { callExpression, getMessageProperties, identifier, tsObjectPattern, tsPropertySignature } from '../utils';
4
- import { omitTypeReference, optionalConditionalExpression, propertySignature, shorthandProperty, typeRefOrOptionalUnion } from '../utils/babel';
4
+ import { omitTypeReference, optionalConditionalExpression, propertySignature, shorthandProperty } from '../utils/babel';
5
5
  import { getParamsTypeAnnotation, getPropertyType } from '../utils/types';
6
6
  import { FIXED_EXECUTE_PARAMS } from '../client';
7
7
  export const createReactQueryHooks = ({
@@ -11,11 +11,17 @@ export const createReactQueryHooks = ({
11
11
  QueryClient
12
12
  }) => {
13
13
  const options = context.options.reactQuery;
14
- return getMessageProperties(queryMsg).reduce((m, schema) => {
14
+ const genericQueryInterfaceName = `${pascal(contractName)}ReactQuery`;
15
+ const body = [createReactQueryHookGenericInterface({
16
+ context,
17
+ QueryClient,
18
+ genericQueryInterfaceName
19
+ })];
20
+ body.push(...getMessageProperties(queryMsg).reduce((m, schema) => {
15
21
  const underscoreName = Object.keys(schema.properties)[0];
16
22
  const methodName = camel(underscoreName);
17
- const hookName = `use${pascal(contractName)}${pascal(methodName)}Query`;
18
23
  const hookParamsTypeName = `${pascal(contractName)}${pascal(methodName)}Query`;
24
+ const hookName = `use${hookParamsTypeName}`;
19
25
  const responseType = pascal(`${methodName}Response`);
20
26
  const getterKey = camel(`${contractName}${pascal(methodName)}`);
21
27
  const jsonschema = schema.properties[underscoreName];
@@ -23,9 +29,9 @@ export const createReactQueryHooks = ({
23
29
  context,
24
30
  hookParamsTypeName,
25
31
  responseType,
32
+ queryInterfaceName: genericQueryInterfaceName,
26
33
  QueryClient,
27
- jsonschema,
28
- options
34
+ jsonschema
29
35
  }), createReactQueryHook({
30
36
  context,
31
37
  methodName,
@@ -35,7 +41,8 @@ export const createReactQueryHooks = ({
35
41
  hookKeyName: getterKey,
36
42
  jsonschema
37
43
  }), ...m];
38
- }, []);
44
+ }, []));
45
+ return body;
39
46
  };
40
47
  export const createReactQueryHook = ({
41
48
  context,
@@ -66,8 +73,8 @@ export const createReactQueryHook = ({
66
73
 
67
74
  return t.exportNamedDeclaration(t.functionDeclaration(t.identifier(hookName), [tsObjectPattern([...props.map(prop => {
68
75
  return t.objectProperty(t.identifier(prop), t.identifier(prop), false, true);
69
- })], t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName))))], t.blockStatement([t.returnStatement(callExpression(t.identifier('useQuery'), [t.arrayExpression(generateUseQueryQueryKey(hookKeyName, props, options.optionalClient)), t.arrowFunctionExpression([], optionalConditionalExpression(t.identifier('client'), t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), t.identifier('undefined'), options.optionalClient), false), options.optionalClient ? t.objectExpression([t.spreadElement(t.identifier('options')), t.objectProperty(t.identifier('enabled'), t.logicalExpression('&&', t.unaryExpression('!', t.unaryExpression('!', t.identifier('client'))), t.conditionalExpression( // explicitly check for undefined
70
- t.binaryExpression('!=', t.optionalMemberExpression(t.identifier('options'), t.identifier('enabled'), false, true), t.identifier('undefined')), t.memberExpression(t.identifier('options'), t.identifier('enabled')), t.booleanLiteral(true))))]) : t.identifier('options')], t.tsTypeParameterInstantiation([typeRefOrOptionalUnion(t.identifier(responseType), options.optionalClient), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(responseType)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))])))])));
76
+ })], t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName))))], t.blockStatement([t.returnStatement(callExpression(t.identifier('useQuery'), [t.arrayExpression(generateUseQueryQueryKey(hookKeyName, props, options.optionalClient)), t.arrowFunctionExpression([], optionalConditionalExpression(t.identifier('client'), t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), t.callExpression(t.memberExpression(t.identifier('Promise'), t.identifier('reject')), [t.newExpression(t.identifier('Error'), [t.stringLiteral('Invalid client')])]), options.optionalClient), false), options.optionalClient ? t.objectExpression([t.spreadElement(t.identifier('options')), t.objectProperty(t.identifier('enabled'), t.logicalExpression('&&', t.unaryExpression('!', t.unaryExpression('!', t.identifier('client'))), t.conditionalExpression( // explicitly check for undefined
77
+ t.binaryExpression('!=', t.optionalMemberExpression(t.identifier('options'), t.identifier('enabled'), false, true), t.identifier('undefined')), t.memberExpression(t.identifier('options'), t.identifier('enabled')), t.booleanLiteral(true))))]) : t.identifier('options')], t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(responseType)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))])))])));
71
78
  };
72
79
 
73
80
  /**
@@ -99,10 +106,14 @@ export const createReactQueryMutationArgsInterface = ({
99
106
 
100
107
  if (msgType) {
101
108
  body.push(t.tsPropertySignature(t.identifier('msg'), msgType));
102
- } // fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]
109
+ }
103
110
 
111
+ context.addUtil('StdFee');
112
+ context.addUtil('Coin'); // fee: number | StdFee | "auto" = "auto", memo?: string, funds?: Coin[]
104
113
 
105
- const optionalArgs = t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation(t.tsTypeLiteral(FIXED_EXECUTE_PARAMS.map(param => propertySignature(param.name, param.typeAnnotation, param.optional)))));
114
+ const optionalArgs = t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation( // @ts-ignore:next-line
115
+ t.tsTypeLiteral(FIXED_EXECUTE_PARAMS.map(param => propertySignature(param.name, // @ts-ignore:next-line
116
+ param.typeAnnotation, param.optional)))));
106
117
  optionalArgs.optional = true;
107
118
  body.push(optionalArgs);
108
119
  return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(mutationHookParamsTypeName), null, [], t.tsInterfaceBody(body)));
@@ -184,25 +195,39 @@ export const createReactQueryMutationHook = ({
184
195
  return t.exportNamedDeclaration(t.functionDeclaration(t.identifier(mutationHookName), [identifier('options', t.tsTypeAnnotation(omitTypeReference(t.tsTypeReference(t.identifier('UseMutationOptions'), useMutationTypeParameter), 'mutationFn')), true)], t.blockStatement([t.returnStatement(callExpression(t.identifier('useMutation'), [t.arrowFunctionExpression([t.objectPattern(useMutationFunctionArgs)], t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(execMethodName)), (hasMsg ? [t.identifier('msg')] : []).concat(FIXED_EXECUTE_PARAMS.map(param => t.identifier(param.name)))), false // not async
185
196
  ), t.identifier('options')], useMutationTypeParameter))])));
186
197
  };
198
+
199
+ function createReactQueryHookGenericInterface({
200
+ context,
201
+ QueryClient,
202
+ genericQueryInterfaceName
203
+ }) {
204
+ const options = context.options.reactQuery;
205
+ const genericTypeName = 'TResponse';
206
+ context.addUtil('UseQueryOptions');
207
+ const typedUseQueryOptions = t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(genericTypeName)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(genericTypeName)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))]));
208
+ const body = [tsPropertySignature(t.identifier('client'), t.tsTypeAnnotation(options.optionalClient ? t.tsUnionType([t.tsTypeReference(t.identifier(QueryClient)), t.tsUndefinedKeyword()]) : t.tsTypeReference(t.identifier(QueryClient))), false), tsPropertySignature(t.identifier('options'), t.tsTypeAnnotation(options.version === 'v4' ? t.tSIntersectionType([omitTypeReference(typedUseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'"), t.tSTypeLiteral([t.tsPropertySignature(t.identifier('initialData?'), t.tsTypeAnnotation(t.tsUndefinedKeyword()))])]) : typedUseQueryOptions), true)];
209
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(genericQueryInterfaceName), t.tsTypeParameterDeclaration([t.tsTypeParameter(undefined, undefined, genericTypeName)]), [], t.tSInterfaceBody(body)));
210
+ }
211
+
187
212
  export const createReactQueryHookInterface = ({
188
213
  context,
189
214
  QueryClient,
190
215
  hookParamsTypeName,
216
+ queryInterfaceName,
191
217
  responseType,
192
218
  jsonschema
193
219
  }) => {
194
220
  // merge the user options with the defaults
195
221
  const options = context.options.reactQuery;
196
- context.addUtil('UseQueryOptions');
197
- const typedUseQueryOptions = t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([typeRefOrOptionalUnion(t.identifier(responseType), options.optionalClient), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(responseType)), t.tsArrayType(t.tsParenthesizedType(t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()])))]));
198
- const body = [tsPropertySignature(t.identifier('client'), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(QueryClient))), options.optionalClient), tsPropertySignature(t.identifier('options'), t.tsTypeAnnotation(options.version === 'v4' ? t.tSIntersectionType([omitTypeReference(typedUseQueryOptions, "'queryKey' | 'queryFn' | 'initialData'"), t.tSTypeLiteral([t.tsPropertySignature(t.identifier('initialData?'), t.tsTypeAnnotation(t.tsUndefinedKeyword()))])]) : typedUseQueryOptions), true)];
222
+ const body = [];
199
223
  const props = getProps(context, jsonschema);
200
224
 
201
225
  if (props.length) {
202
- body.push(t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation(t.tsTypeLiteral(props))));
226
+ body.push(t.tsPropertySignature(t.identifier('args'), t.tsTypeAnnotation( // @ts-ignore:next-line
227
+ t.tsTypeLiteral(props))));
203
228
  }
204
229
 
205
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), null, [], t.tsInterfaceBody(body)));
230
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), null, [t.tSExpressionWithTypeArguments(t.identifier(queryInterfaceName), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType))]))], t.tsInterfaceBody(body)));
206
231
  };
207
232
 
208
233
  const getProps = (context, jsonschema) => {
@@ -165,7 +165,7 @@ export const memberExpressionOrIdentifierSnake = names => {
165
165
  export const optionalConditionalExpression = (test, expression, alternate, optional = false) => {
166
166
  return optional ? t.conditionalExpression(test, expression, alternate) : expression;
167
167
  };
168
- export const typeRefOrOptionalUnion = (identifier, optional = false) => {
168
+ export const typeRefOrUnionWithUndefined = (identifier, optional = false) => {
169
169
  const typeReference = t.tsTypeReference(identifier);
170
170
  return optional ? t.tsUnionType([typeReference, t.tsUndefinedKeyword()]) : typeReference;
171
171
  };
@@ -18,10 +18,22 @@ const getArrayTypeFromRef = $ref => {
18
18
  return t.tsArrayType(getTypeFromRef($ref));
19
19
  };
20
20
 
21
+ const getTypeOrRef = obj => {
22
+ if (obj.type) {
23
+ return getType(obj.type);
24
+ }
25
+
26
+ if (obj.$ref) {
27
+ return getTypeFromRef(obj.$ref);
28
+ }
29
+
30
+ throw new Error('contact maintainers cannot find type for ' + obj);
31
+ };
32
+
21
33
  const getArrayTypeFromItems = items => {
22
34
  if (items.type === 'array') {
23
35
  if (Array.isArray(items.items)) {
24
- return t.tsArrayType(t.tsArrayType(getType(items.items[0].type)));
36
+ return t.tsArrayType(t.tsArrayType(getTypeOrRef(items.items[0])));
25
37
  } else {
26
38
  return t.tsArrayType(getArrayTypeFromItems(items.items));
27
39
  }
@@ -86,12 +98,16 @@ export const getPropertyType = (context, schema, prop) => {
86
98
 
87
99
  if (typeof info.type === 'string') {
88
100
  if (info.type === 'array') {
89
- if (info.items.$ref) {
90
- type = getArrayTypeFromRef(info.items.$ref);
91
- } else if (info.items.title) {
92
- type = t.tsArrayType(t.tsTypeReference(t.identifier(info.items.title)));
93
- } else if (info.items.type) {
94
- type = getArrayTypeFromItems(info.items);
101
+ if (typeof info.items === 'object' && !Array.isArray(info.items)) {
102
+ if (info.items.$ref) {
103
+ type = getArrayTypeFromRef(info.items.$ref);
104
+ } else if (info.items.title) {
105
+ type = t.tsArrayType(t.tsTypeReference(t.identifier(info.items.title)));
106
+ } else if (info.items.type) {
107
+ type = getArrayTypeFromItems(info.items);
108
+ } else {
109
+ throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
110
+ }
95
111
  } else {
96
112
  throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
97
113
  }
@@ -112,7 +128,7 @@ export const getPropertyType = (context, schema, prop) => {
112
128
  throw new Error('please report this to maintainers (field type): ' + JSON.stringify(info, null, 2));
113
129
  }
114
130
 
115
- if (nullableType === 'array') {
131
+ if (nullableType === 'array' && typeof info.items === 'object' && !Array.isArray(info.items)) {
116
132
  type = t.tsArrayType(getType(info.items.type));
117
133
  } else {
118
134
  type = getType(nullableType);
@@ -149,7 +165,8 @@ export function getPropertySignatureFromProp(context, jsonschema, prop, camelize
149
165
  if (el.title) return el.title;
150
166
  if (el.$ref) return getTypeStrFromRef(el.$ref);
151
167
  return el.type;
152
- });
168
+ }); // @ts-ignore:next-line
169
+
153
170
  const uniqUnionTypes = [...new Set(unionTypes)];
154
171
 
155
172
  if (uniqUnionTypes.length === 1) {
@@ -163,7 +180,8 @@ export function getPropertySignatureFromProp(context, jsonschema, prop, camelize
163
180
  if (el.title) return el.title;
164
181
  if (el.$ref) return getTypeStrFromRef(el.$ref);
165
182
  return el.type;
166
- });
183
+ }); // @ts-ignore:next-line
184
+
167
185
  const uniqUnionTypes = [...new Set(unionTypes)];
168
186
 
169
187
  if (uniqUnionTypes.length === 1) {
@@ -195,7 +213,8 @@ export const getParamsTypeAnnotation = (context, jsonschema, camelize = true) =>
195
213
 
196
214
  if (!keys.length) return undefined;
197
215
  const typedParams = keys.map(prop => getPropertySignatureFromProp(context, jsonschema, prop, camelize));
198
- return t.tsTypeAnnotation(t.tsTypeLiteral([...typedParams]));
216
+ return t.tsTypeAnnotation(t.tsTypeLiteral( // @ts-ignore:next-line
217
+ [...typedParams]));
199
218
  };
200
219
  export const createTypedObjectParams = (context, jsonschema, camelize = true) => {
201
220
  const keys = Object.keys(jsonschema.properties ?? {});
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "wasm-ast-types",
3
- "version": "0.7.1",
3
+ "version": "0.8.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",
7
7
  "license": "SEE LICENSE IN LICENSE",
8
8
  "main": "main/index.js",
9
9
  "module": "module/index.js",
10
- "typings": "types/src/index.d.ts",
10
+ "typings": "types/index.d.ts",
11
11
  "directories": {
12
12
  "lib": "src",
13
13
  "test": "__tests__"
@@ -86,5 +86,5 @@
86
86
  "case": "1.6.3",
87
87
  "deepmerge": "4.2.2"
88
88
  },
89
- "gitHead": "18729d1c098208cb9f4576109a192ca1489e9284"
89
+ "gitHead": "548ad021d449f695ecc4f946a11e2ebe8af53780"
90
90
  }
@@ -17,7 +17,7 @@ interface ReactQueryHooks {
17
17
  contractName: string;
18
18
  QueryClient: string;
19
19
  }
20
- export declare const createReactQueryHooks: ({ context, queryMsg, contractName, QueryClient }: ReactQueryHooks) => any;
20
+ export declare const createReactQueryHooks: ({ context, queryMsg, contractName, QueryClient }: ReactQueryHooks) => t.ExportNamedDeclaration[];
21
21
  export declare const createReactQueryHook: ({ context, hookName, hookParamsTypeName, responseType, hookKeyName, methodName, jsonschema }: ReactQueryHookQuery) => t.ExportNamedDeclaration;
22
22
  interface ReactQueryMutationHookInterface {
23
23
  context: RenderContext;
@@ -74,8 +74,9 @@ interface ReactQueryHookQueryInterface {
74
74
  context: RenderContext;
75
75
  QueryClient: string;
76
76
  hookParamsTypeName: string;
77
+ queryInterfaceName: string;
77
78
  responseType: string;
78
79
  jsonschema: any;
79
80
  }
80
- export declare const createReactQueryHookInterface: ({ context, QueryClient, hookParamsTypeName, responseType, jsonschema }: ReactQueryHookQueryInterface) => t.ExportNamedDeclaration;
81
+ export declare const createReactQueryHookInterface: ({ context, QueryClient, hookParamsTypeName, queryInterfaceName, responseType, jsonschema }: ReactQueryHookQueryInterface) => t.ExportNamedDeclaration;
81
82
  export {};
package/types/types.d.ts CHANGED
@@ -33,7 +33,7 @@ export interface JSONSchema {
33
33
  oneOf?: JSONSchema[];
34
34
  properties?: Record<string, JSONSchema>;
35
35
  patternProperties?: Record<string, JSONSchema>;
36
- items?: JSONSchema[] | JSONSchema;
36
+ items?: JSONSchema | JSONSchema[];
37
37
  additionalItems?: JSONSchema;
38
38
  required?: string[];
39
39
  title?: string;
@@ -44,7 +44,7 @@ export declare const memberExpressionOrIdentifierSnake: (names: any) => any;
44
44
  * If optional, return a conditional, otherwise just the expression
45
45
  */
46
46
  export declare const optionalConditionalExpression: (test: t.Expression, expression: t.Expression, alternate: t.Expression, optional?: boolean) => t.Expression;
47
- export declare const typeRefOrOptionalUnion: (identifier: t.Identifier, optional?: boolean) => t.TSType;
47
+ export declare const typeRefOrUnionWithUndefined: (identifier: t.Identifier, optional?: boolean) => t.TSType;
48
48
  export declare const parameterizedTypeReference: (identifier: string, from: t.TSType, omit: string | Array<string>) => t.TSTypeReference;
49
49
  /**
50
50
  * omitTypeReference(t.tsTypeReference(t.identifier('Cw4UpdateMembersMutation'),),'args').....