wasm-ast-types 0.7.0 → 0.8.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.
Files changed (30) hide show
  1. package/main/client/client.js +6 -3
  2. package/main/message-composer/message-composer.js +2 -1
  3. package/main/react-query/react-query.js +42 -19
  4. package/main/utils/babel.js +3 -3
  5. package/main/utils/types.js +21 -12
  6. package/module/client/client.js +6 -3
  7. package/module/message-composer/message-composer.js +2 -1
  8. package/module/react-query/react-query.js +40 -15
  9. package/module/utils/babel.js +1 -1
  10. package/module/utils/types.js +17 -10
  11. package/package.json +2 -2
  12. package/types/{src/client → client}/client.d.ts +0 -0
  13. package/types/{src/client → client}/index.d.ts +0 -0
  14. package/types/{src/context → context}/context.d.ts +0 -0
  15. package/types/{src/context → context}/imports.d.ts +1 -0
  16. package/types/{src/context → context}/index.d.ts +0 -0
  17. package/types/{src/index.d.ts → index.d.ts} +0 -0
  18. package/types/{src/message-composer → message-composer}/index.d.ts +0 -0
  19. package/types/{src/message-composer → message-composer}/message-composer.d.ts +0 -0
  20. package/types/{src/react-query → react-query}/index.d.ts +0 -0
  21. package/types/{src/react-query → react-query}/react-query.d.ts +3 -2
  22. package/types/{src/recoil → recoil}/index.d.ts +0 -0
  23. package/types/{src/recoil → recoil}/recoil.d.ts +0 -0
  24. package/types/{src/types.d.ts → types.d.ts} +1 -1
  25. package/types/{src/utils → utils}/babel.d.ts +1 -1
  26. package/types/{src/utils → utils}/index.d.ts +0 -0
  27. package/types/{src/utils → utils}/types.d.ts +0 -0
  28. package/types/src/client/test/ts-client.cw-named-groups.test.d.ts +0 -1
  29. package/types/src/client/test/ts-client.cw-proposal-single.test.d.ts +0 -1
  30. package/types/test-utils/index.d.ts +0 -2
@@ -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;
@@ -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/')) {
@@ -118,12 +120,16 @@ var getPropertyType = function getPropertyType(context, schema, prop) {
118
120
 
119
121
  if (typeof info.type === 'string') {
120
122
  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);
123
+ if ((0, _typeof2["default"])(info.items) === 'object' && !Array.isArray(info.items)) {
124
+ if (info.items.$ref) {
125
+ type = getArrayTypeFromRef(info.items.$ref);
126
+ } else if (info.items.title) {
127
+ type = t.tsArrayType(t.tsTypeReference(t.identifier(info.items.title)));
128
+ } else if (info.items.type) {
129
+ type = getArrayTypeFromItems(info.items);
130
+ } else {
131
+ throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
132
+ }
127
133
  } else {
128
134
  throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
129
135
  }
@@ -146,7 +152,7 @@ var getPropertyType = function getPropertyType(context, schema, prop) {
146
152
  throw new Error('please report this to maintainers (field type): ' + JSON.stringify(info, null, 2));
147
153
  }
148
154
 
149
- if (_nullableType === 'array') {
155
+ if (_nullableType === 'array' && (0, _typeof2["default"])(info.items) === 'object' && !Array.isArray(info.items)) {
150
156
  type = t.tsArrayType(getType(info.items.type));
151
157
  } else {
152
158
  type = getType(_nullableType);
@@ -188,7 +194,8 @@ function getPropertySignatureFromProp(context, jsonschema, prop, camelize) {
188
194
  if (el.title) return el.title;
189
195
  if (el.$ref) return getTypeStrFromRef(el.$ref);
190
196
  return el.type;
191
- });
197
+ }); // @ts-ignore:next-line
198
+
192
199
  var uniqUnionTypes = (0, _toConsumableArray2["default"])(new Set(unionTypes));
193
200
 
194
201
  if (uniqUnionTypes.length === 1) {
@@ -207,7 +214,8 @@ function getPropertySignatureFromProp(context, jsonschema, prop, camelize) {
207
214
  if (el.title) return el.title;
208
215
  if (el.$ref) return getTypeStrFromRef(el.$ref);
209
216
  return el.type;
210
- });
217
+ }); // @ts-ignore:next-line
218
+
211
219
 
212
220
  var _uniqUnionTypes = (0, _toConsumableArray2["default"])(new Set(_unionTypes));
213
221
 
@@ -248,7 +256,8 @@ var getParamsTypeAnnotation = function getParamsTypeAnnotation(context, jsonsche
248
256
  var typedParams = keys.map(function (prop) {
249
257
  return getPropertySignatureFromProp(context, jsonschema, prop, camelize);
250
258
  });
251
- return t.tsTypeAnnotation(t.tsTypeLiteral((0, _toConsumableArray2["default"])(typedParams)));
259
+ return t.tsTypeAnnotation(t.tsTypeLiteral( // @ts-ignore:next-line
260
+ (0, _toConsumableArray2["default"])(typedParams)));
252
261
  };
253
262
 
254
263
  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;
@@ -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
  };
@@ -86,12 +86,16 @@ export const getPropertyType = (context, schema, prop) => {
86
86
 
87
87
  if (typeof info.type === 'string') {
88
88
  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);
89
+ if (typeof info.items === 'object' && !Array.isArray(info.items)) {
90
+ if (info.items.$ref) {
91
+ type = getArrayTypeFromRef(info.items.$ref);
92
+ } else if (info.items.title) {
93
+ type = t.tsArrayType(t.tsTypeReference(t.identifier(info.items.title)));
94
+ } else if (info.items.type) {
95
+ type = getArrayTypeFromItems(info.items);
96
+ } else {
97
+ throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
98
+ }
95
99
  } else {
96
100
  throw new Error('[info.items] case not handled by transpiler. contact maintainers.');
97
101
  }
@@ -112,7 +116,7 @@ export const getPropertyType = (context, schema, prop) => {
112
116
  throw new Error('please report this to maintainers (field type): ' + JSON.stringify(info, null, 2));
113
117
  }
114
118
 
115
- if (nullableType === 'array') {
119
+ if (nullableType === 'array' && typeof info.items === 'object' && !Array.isArray(info.items)) {
116
120
  type = t.tsArrayType(getType(info.items.type));
117
121
  } else {
118
122
  type = getType(nullableType);
@@ -149,7 +153,8 @@ export function getPropertySignatureFromProp(context, jsonschema, prop, camelize
149
153
  if (el.title) return el.title;
150
154
  if (el.$ref) return getTypeStrFromRef(el.$ref);
151
155
  return el.type;
152
- });
156
+ }); // @ts-ignore:next-line
157
+
153
158
  const uniqUnionTypes = [...new Set(unionTypes)];
154
159
 
155
160
  if (uniqUnionTypes.length === 1) {
@@ -163,7 +168,8 @@ export function getPropertySignatureFromProp(context, jsonschema, prop, camelize
163
168
  if (el.title) return el.title;
164
169
  if (el.$ref) return getTypeStrFromRef(el.$ref);
165
170
  return el.type;
166
- });
171
+ }); // @ts-ignore:next-line
172
+
167
173
  const uniqUnionTypes = [...new Set(unionTypes)];
168
174
 
169
175
  if (uniqUnionTypes.length === 1) {
@@ -195,7 +201,8 @@ export const getParamsTypeAnnotation = (context, jsonschema, camelize = true) =>
195
201
 
196
202
  if (!keys.length) return undefined;
197
203
  const typedParams = keys.map(prop => getPropertySignatureFromProp(context, jsonschema, prop, camelize));
198
- return t.tsTypeAnnotation(t.tsTypeLiteral([...typedParams]));
204
+ return t.tsTypeAnnotation(t.tsTypeLiteral( // @ts-ignore:next-line
205
+ [...typedParams]));
199
206
  };
200
207
  export const createTypedObjectParams = (context, jsonschema, camelize = true) => {
201
208
  const keys = Object.keys(jsonschema.properties ?? {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasm-ast-types",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
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",
@@ -86,5 +86,5 @@
86
86
  "case": "1.6.3",
87
87
  "deepmerge": "4.2.2"
88
88
  },
89
- "gitHead": "09236055739cc020418f89a246d8a954353c7ec3"
89
+ "gitHead": "93256e4c8579d792ca727ef8f1e9ac47a5231726"
90
90
  }
File without changes
File without changes
File without changes
@@ -10,6 +10,7 @@ export declare const UTILS: {
10
10
  MsgExecuteContractEncodeObject: string;
11
11
  Coin: string;
12
12
  toUtf8: string;
13
+ selectorFamily: string;
13
14
  StdFee: string;
14
15
  CosmWasmClient: string;
15
16
  ExecuteResult: string;
File without changes
File without changes
@@ -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 {};
File without changes
File without changes
@@ -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').....
File without changes
File without changes
@@ -1,2 +0,0 @@
1
- export declare const expectCode: (ast: any) => void;
2
- export declare const printCode: (ast: any) => void;