wasm-ast-types 0.13.0 → 0.15.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.
@@ -120,10 +120,11 @@ var createExecuteClass = function createExecuteClass(context, className, impleme
120
120
 
121
121
  [].push.apply(blockStmt, [// client/contract set
122
122
  t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('client'))), t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('sender')), t.identifier('sender'))), t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.identifier('contractAddress')))].concat((0, _toConsumableArray2["default"])(bindings)));
123
+ var noImplicitOverride = context.options.client.noImplicitOverride && extendsClassName && context.options.client.execExtendsQuery;
123
124
  return t.exportNamedDeclaration((0, _utils.classDeclaration)(className, [// client
124
- (0, _utils.classProperty)('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), // sender
125
+ (0, _utils.classProperty)('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient'))), false, false, noImplicitOverride), // sender
125
126
  (0, _utils.classProperty)('sender', t.tsTypeAnnotation(t.tsStringKeyword())), // contractAddress
126
- (0, _utils.classProperty)('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword())), // constructor
127
+ (0, _utils.classProperty)('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword()), false, false, noImplicitOverride), // constructor
127
128
  t.classMethod('constructor', t.identifier('constructor'), [(0, _utils.typedIdentifier)('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), (0, _utils.typedIdentifier)('sender', t.tsTypeAnnotation(t.tsStringKeyword())), (0, _utils.typedIdentifier)('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword()))], t.blockStatement(blockStmt))].concat((0, _toConsumableArray2["default"])(methods)), [t.tSExpressionWithTypeArguments(t.identifier(implementsClassName))], extendsClassName ? t.identifier(extendsClassName) : null));
128
129
  };
129
130
 
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _execute_msg_for__empty = _interopRequireDefault(require("../../../../../__fixtures__/sg721/execute_msg_for__empty.json"));
6
+
7
+ var _client = require("../client");
8
+
9
+ var _testUtils = require("../../../test-utils");
10
+
11
+ var ctx = (0, _testUtils.makeContext)(_execute_msg_for__empty["default"]);
12
+ describe('exec', function () {});
13
+ it('Impl, execExtends, noExtendsClass', function () {
14
+ ctx.options.client.noImplicitOverride = false;
15
+ ctx.options.client.execExtendsQuery = true;
16
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(ctx, 'SG721Client', 'SG721Instance', null, _execute_msg_for__empty["default"]));
17
+ });
18
+ it('Impl, execExtends, ExtendsClass', function () {
19
+ ctx.options.client.noImplicitOverride = false;
20
+ ctx.options.client.execExtendsQuery = true;
21
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(ctx, 'SG721Client', 'SG721Instance', 'ExtendsClassName', _execute_msg_for__empty["default"]));
22
+ });
23
+ it('noImpl, execExtends, ExtendsClass', function () {
24
+ ctx.options.client.noImplicitOverride = true;
25
+ ctx.options.client.execExtendsQuery = true;
26
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(ctx, 'SG721Client', 'SG721Instance', 'ExtendsClassName', _execute_msg_for__empty["default"]));
27
+ });
28
+ it('noImpl, noExecExtends, ExtendsClass', function () {
29
+ ctx.options.client.noImplicitOverride = true;
30
+ ctx.options.client.execExtendsQuery = false;
31
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(ctx, 'SG721Client', 'SG721Instance', 'ExtendsClassName', _execute_msg_for__empty["default"]));
32
+ });
33
+ it('noImpl, noExecExtends, noExtendsClass', function () {
34
+ ctx.options.client.noImplicitOverride = true;
35
+ ctx.options.client.execExtendsQuery = false;
36
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(ctx, 'SG721Client', 'SG721Instance', null, _execute_msg_for__empty["default"]));
37
+ });
@@ -29,7 +29,8 @@ var defaultOptions = {
29
29
  },
30
30
  client: {
31
31
  enabled: true,
32
- execExtendsQuery: true
32
+ execExtendsQuery: true,
33
+ noImplicitOverride: false
33
34
  },
34
35
  recoil: {
35
36
  enabled: false
@@ -49,12 +49,7 @@ var createReactQueryHooks = function createReactQueryHooks(_ref) {
49
49
  }));
50
50
  }
51
51
 
52
- body.push(createReactQueryHookGenericInterface({
53
- context: context,
54
- QueryClient: QueryClient,
55
- genericQueryInterfaceName: genericQueryInterfaceName
56
- }));
57
- body.push.apply(body, (0, _toConsumableArray2["default"])((0, _utils.getMessageProperties)(queryMsg).reduce(function (m, schema) {
52
+ var queryMsgs = (0, _utils.getMessageProperties)(queryMsg).map(function (schema) {
58
53
  // list_voters
59
54
  var underscoreName = Object.keys(schema.properties)[0]; // listVoters
60
55
 
@@ -68,6 +63,39 @@ var createReactQueryHooks = function createReactQueryHooks(_ref) {
68
63
 
69
64
  var getterKey = (0, _case.camel)("".concat(contractName).concat((0, _case.pascal)(methodName)));
70
65
  var jsonschema = schema.properties[underscoreName];
66
+ return {
67
+ underscoreName: underscoreName,
68
+ methodName: methodName,
69
+ hookParamsTypeName: hookParamsTypeName,
70
+ hookName: hookName,
71
+ responseType: responseType,
72
+ getterKey: getterKey,
73
+ jsonschema: jsonschema
74
+ };
75
+ });
76
+ var queryFactoryName = "".concat((0, _case.camel)(contractName), "Queries");
77
+
78
+ if (options.queryFactory) {
79
+ body.push(createReactQueryFactory({
80
+ context: context,
81
+ queryFactoryName: queryFactoryName,
82
+ queryKeysName: queryKeysName,
83
+ queryMsgs: queryMsgs
84
+ }));
85
+ }
86
+
87
+ body.push(createReactQueryHookGenericInterface({
88
+ context: context,
89
+ QueryClient: QueryClient,
90
+ genericQueryInterfaceName: genericQueryInterfaceName
91
+ }));
92
+ body.push.apply(body, (0, _toConsumableArray2["default"])(queryMsgs.reduce(function (m, _ref2) {
93
+ var methodName = _ref2.methodName,
94
+ hookParamsTypeName = _ref2.hookParamsTypeName,
95
+ hookName = _ref2.hookName,
96
+ responseType = _ref2.responseType,
97
+ getterKey = _ref2.getterKey,
98
+ jsonschema = _ref2.jsonschema;
71
99
  return [createReactQueryHookInterface({
72
100
  context: context,
73
101
  hookParamsTypeName: hookParamsTypeName,
@@ -91,20 +119,9 @@ var createReactQueryHooks = function createReactQueryHooks(_ref) {
91
119
 
92
120
  exports.createReactQueryHooks = createReactQueryHooks;
93
121
 
94
- var createReactQueryHook = function createReactQueryHook(_ref2) {
122
+ function buildQueryFn(methodName, jsonschema, options) {
95
123
  var _jsonschema$propertie;
96
124
 
97
- var context = _ref2.context,
98
- hookName = _ref2.hookName,
99
- hookParamsTypeName = _ref2.hookParamsTypeName,
100
- responseType = _ref2.responseType,
101
- hookKeyName = _ref2.hookKeyName,
102
- queryKeysName = _ref2.queryKeysName,
103
- methodName = _ref2.methodName,
104
- jsonschema = _ref2.jsonschema;
105
- context.addUtil('useQuery');
106
- context.addUtil('UseQueryOptions');
107
- var options = context.options.reactQuery;
108
125
  var keys = Object.keys((_jsonschema$propertie = jsonschema.properties) !== null && _jsonschema$propertie !== void 0 ? _jsonschema$propertie : {});
109
126
  var args = [];
110
127
 
@@ -114,13 +131,40 @@ var createReactQueryHook = function createReactQueryHook(_ref2) {
114
131
  })))];
115
132
  }
116
133
 
134
+ var rejectInvalidClient = t.callExpression(t.memberExpression(t.identifier('Promise'), t.identifier('reject')), [t.newExpression(t.identifier('Error'), [t.stringLiteral('Invalid client')])]);
135
+ return t.arrowFunctionExpression([], (0, _babel.optionalConditionalExpression)(t.identifier('client'), t.callExpression(t.memberExpression(t.identifier('client'), t.identifier(methodName)), args), rejectInvalidClient, options.optionalClient), false);
136
+ }
137
+
138
+ var ENABLED_QUERY_OPTION = t.objectProperty(t.identifier('enabled'), t.logicalExpression('&&', t.unaryExpression('!', t.unaryExpression('!', t.identifier('client'))), t.conditionalExpression( // explicitly check for undefined
139
+ 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))));
140
+
141
+ function buildQueryOptions(options) {
142
+ return 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
143
+ 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');
144
+ }
145
+
146
+ var createReactQueryHook = function createReactQueryHook(_ref3) {
147
+ var _jsonschema$propertie2;
148
+
149
+ var context = _ref3.context,
150
+ hookName = _ref3.hookName,
151
+ hookParamsTypeName = _ref3.hookParamsTypeName,
152
+ responseType = _ref3.responseType,
153
+ hookKeyName = _ref3.hookKeyName,
154
+ queryKeysName = _ref3.queryKeysName,
155
+ methodName = _ref3.methodName,
156
+ jsonschema = _ref3.jsonschema;
157
+ context.addUtil('useQuery');
158
+ context.addUtil('UseQueryOptions');
159
+ var options = context.options.reactQuery;
160
+ var keys = Object.keys((_jsonschema$propertie2 = jsonschema.properties) !== null && _jsonschema$propertie2 !== void 0 ? _jsonschema$propertie2 : {});
117
161
  var props = ['client', 'options'];
118
162
 
119
163
  if (keys.length) {
120
164
  props = ['client', 'args', 'options'];
121
165
  }
122
166
 
123
- var selectResponseGenericTypeName = 'TData';
167
+ var selectResponseGenericTypeName = GENERIC_SELECT_RESPONSE_NAME;
124
168
  var queryFunctionDeclaration = t.functionDeclaration(t.identifier(hookName), [(0, _utils.tsObjectPattern)((0, _toConsumableArray2["default"])(props.map(function (prop) {
125
169
  return t.objectProperty(t.identifier(prop), t.identifier(prop), false, true);
126
170
  })), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(selectResponseGenericTypeName))]))))], t.blockStatement([t.returnStatement((0, _utils.callExpression)(t.identifier('useQuery'), [generateUseQueryQueryKey({
@@ -129,8 +173,7 @@ var createReactQueryHook = function createReactQueryHook(_ref2) {
129
173
  methodName: methodName,
130
174
  props: props,
131
175
  options: options
132
- }), 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
133
- 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(selectResponseGenericTypeName))])))])); // Add the TData type parameters
176
+ }), buildQueryFn(methodName, jsonschema, options), buildQueryOptions(options)], t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(selectResponseGenericTypeName))])))])); // Add the TData type parameters
134
177
 
135
178
  queryFunctionDeclaration.typeParameters = t.tsTypeParameterDeclaration([t.tsTypeParameter(undefined, t.tSTypeReference(t.identifier(responseType)), selectResponseGenericTypeName)]);
136
179
  return t.exportNamedDeclaration(queryFunctionDeclaration);
@@ -154,12 +197,12 @@ export interface Cw4UpdateMembersMutation {
154
197
  }
155
198
  ```
156
199
  */
157
- var createReactQueryMutationArgsInterface = function createReactQueryMutationArgsInterface(_ref3) {
158
- var context = _ref3.context,
159
- ExecuteClient = _ref3.ExecuteClient,
160
- mutationHookParamsTypeName = _ref3.mutationHookParamsTypeName,
161
- useMutationTypeParameter = _ref3.useMutationTypeParameter,
162
- jsonschema = _ref3.jsonschema;
200
+ var createReactQueryMutationArgsInterface = function createReactQueryMutationArgsInterface(_ref4) {
201
+ var context = _ref4.context,
202
+ ExecuteClient = _ref4.ExecuteClient,
203
+ mutationHookParamsTypeName = _ref4.mutationHookParamsTypeName,
204
+ useMutationTypeParameter = _ref4.useMutationTypeParameter,
205
+ jsonschema = _ref4.jsonschema;
163
206
  var typedUseMutationOptions = t.tsTypeReference(t.identifier('UseMutationOptions'), useMutationTypeParameter);
164
207
  var body = [(0, _utils.tsPropertySignature)(t.identifier('client'), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(ExecuteClient))), false)];
165
208
  var msgType = (0, _types2.getParamsTypeAnnotation)(context, jsonschema);
@@ -183,14 +226,14 @@ var createReactQueryMutationArgsInterface = function createReactQueryMutationArg
183
226
 
184
227
  exports.createReactQueryMutationArgsInterface = createReactQueryMutationArgsInterface;
185
228
 
186
- var createReactQueryMutationHooks = function createReactQueryMutationHooks(_ref4) {
187
- var context = _ref4.context,
188
- execMsg = _ref4.execMsg,
189
- contractName = _ref4.contractName,
190
- ExecuteClient = _ref4.ExecuteClient;
229
+ var createReactQueryMutationHooks = function createReactQueryMutationHooks(_ref5) {
230
+ var context = _ref5.context,
231
+ execMsg = _ref5.execMsg,
232
+ contractName = _ref5.contractName,
233
+ ExecuteClient = _ref5.ExecuteClient;
191
234
  // merge the user options with the defaults
192
235
  return (0, _utils.getMessageProperties)(execMsg).reduce(function (m, schema) {
193
- var _jsonschema$propertie2, _Object$keys;
236
+ var _jsonschema$propertie3, _Object$keys;
194
237
 
195
238
  // update_members
196
239
  var execMethodUnderscoreName = Object.keys(schema.properties)[0]; // updateMembers
@@ -201,7 +244,7 @@ var createReactQueryMutationHooks = function createReactQueryMutationHooks(_ref4
201
244
 
202
245
  var mutationHookName = "use".concat(mutationHookParamsTypeName);
203
246
  var jsonschema = schema.properties[execMethodUnderscoreName];
204
- var properties = (_jsonschema$propertie2 = jsonschema.properties) !== null && _jsonschema$propertie2 !== void 0 ? _jsonschema$propertie2 : {}; // TODO: there should be a better way to do this
247
+ var properties = (_jsonschema$propertie3 = jsonschema.properties) !== null && _jsonschema$propertie3 !== void 0 ? _jsonschema$propertie3 : {}; // TODO: there should be a better way to do this
205
248
 
206
249
  var hasMsg = !!((_Object$keys = Object.keys(properties)) !== null && _Object$keys !== void 0 && _Object$keys.length || jsonschema !== null && jsonschema !== void 0 && jsonschema.$ref); // <ExecuteResult, Error, Cw4UpdateMembersMutation>
207
250
 
@@ -248,13 +291,13 @@ export const useCw4UpdateMembersMutation = ({ client, options }: Omit<Cw4UpdateM
248
291
  )
249
292
  ```
250
293
  */
251
- var createReactQueryMutationHook = function createReactQueryMutationHook(_ref5) {
252
- var context = _ref5.context,
253
- mutationHookName = _ref5.mutationHookName,
254
- mutationHookParamsTypeName = _ref5.mutationHookParamsTypeName,
255
- execMethodName = _ref5.execMethodName,
256
- useMutationTypeParameter = _ref5.useMutationTypeParameter,
257
- hasMsg = _ref5.hasMsg;
294
+ var createReactQueryMutationHook = function createReactQueryMutationHook(_ref6) {
295
+ var context = _ref6.context,
296
+ mutationHookName = _ref6.mutationHookName,
297
+ mutationHookParamsTypeName = _ref6.mutationHookParamsTypeName,
298
+ execMethodName = _ref6.execMethodName,
299
+ useMutationTypeParameter = _ref6.useMutationTypeParameter,
300
+ hasMsg = _ref6.hasMsg;
258
301
  context.addUtil('useMutation');
259
302
  context.addUtil('UseMutationOptions');
260
303
  var useMutationFunctionArgs = [(0, _babel.shorthandProperty)('client')];
@@ -270,11 +313,11 @@ var createReactQueryMutationHook = function createReactQueryMutationHook(_ref5)
270
313
 
271
314
  exports.createReactQueryMutationHook = createReactQueryMutationHook;
272
315
 
273
- function createReactQueryKeys(_ref6) {
274
- var context = _ref6.context,
275
- queryKeysName = _ref6.queryKeysName,
276
- camelContractName = _ref6.camelContractName,
277
- underscoreNames = _ref6.underscoreNames;
316
+ function createReactQueryKeys(_ref7) {
317
+ var context = _ref7.context,
318
+ queryKeysName = _ref7.queryKeysName,
319
+ camelContractName = _ref7.camelContractName,
320
+ underscoreNames = _ref7.underscoreNames;
278
321
  var options = context.options.reactQuery;
279
322
  var contractAddressTypeAnnotation = t.tsTypeAnnotation(options.optionalClient ? t.tsUnionType([t.tsStringKeyword(), t.tsUndefinedKeyword()]) : t.tSStringKeyword());
280
323
  return t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(t.identifier(queryKeysName), t.objectExpression([// 1: contract
@@ -293,29 +336,56 @@ function createReactQueryKeys(_ref6) {
293
336
  })))))]));
294
337
  }
295
338
 
296
- function createReactQueryHookGenericInterface(_ref7) {
297
- var context = _ref7.context,
298
- QueryClient = _ref7.QueryClient,
299
- genericQueryInterfaceName = _ref7.genericQueryInterfaceName;
339
+ function createReactQueryFactory(_ref8) {
340
+ var context = _ref8.context,
341
+ queryFactoryName = _ref8.queryFactoryName,
342
+ queryKeysName = _ref8.queryKeysName,
343
+ queryMsgs = _ref8.queryMsgs;
344
+ var options = context.options.reactQuery;
345
+ return t.exportNamedDeclaration(t.variableDeclaration('const', [t.variableDeclarator(t.identifier(queryFactoryName), t.objectExpression((0, _toConsumableArray2["default"])(queryMsgs.map(function (_ref9) {
346
+ var _jsonschema$propertie4;
347
+
348
+ var methodName = _ref9.methodName,
349
+ hookParamsTypeName = _ref9.hookParamsTypeName,
350
+ responseType = _ref9.responseType,
351
+ jsonschema = _ref9.jsonschema;
352
+ var hasArgs = Object.keys((_jsonschema$propertie4 = jsonschema.properties) !== null && _jsonschema$propertie4 !== void 0 ? _jsonschema$propertie4 : {}).length > 0;
353
+ var methodQueryOptionsFn = t.arrowFunctionExpression([(0, _utils.tsObjectPattern)([(0, _babel.shorthandProperty)('client')].concat((0, _toConsumableArray2["default"])(hasArgs ? [(0, _babel.shorthandProperty)('args')] : []), [(0, _babel.shorthandProperty)('options')]), t.tsTypeAnnotation(t.tsTypeReference(t.identifier(hookParamsTypeName), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(GENERIC_SELECT_RESPONSE_NAME))]))))], t.objectExpression([// 1: queryKey
354
+ t.objectProperty(t.identifier('queryKey'), t.callExpression(t.memberExpression(t.identifier(queryKeysName), t.identifier(methodName)), [t.optionalMemberExpression(t.identifier('client'), t.identifier('contractAddress'), false, true)].concat((0, _toConsumableArray2["default"])(hasArgs ? [t.identifier('args')] : [])))), // 2: queryFn
355
+ t.objectProperty(t.identifier('queryFn'), buildQueryFn(methodName, jsonschema, options)), // 3: spread options
356
+ t.spreadElement(t.identifier('options')), // 4. enabled
357
+ ENABLED_QUERY_OPTION]));
358
+ methodQueryOptionsFn.typeParameters = t.tsTypeParameterDeclaration([t.tsTypeParameter(undefined, t.tsTypeReference(t.identifier(responseType)), GENERIC_SELECT_RESPONSE_NAME)]);
359
+ methodQueryOptionsFn.returnType = t.tsTypeAnnotation(t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(responseType)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(GENERIC_SELECT_RESPONSE_NAME))])));
360
+ return t.objectProperty( // key id is the camel method name
361
+ t.identifier((0, _case.camel)(methodName)), methodQueryOptionsFn);
362
+ }))))]));
363
+ }
364
+
365
+ var GENERIC_SELECT_RESPONSE_NAME = 'TData';
366
+
367
+ function createReactQueryHookGenericInterface(_ref10) {
368
+ var context = _ref10.context,
369
+ QueryClient = _ref10.QueryClient,
370
+ genericQueryInterfaceName = _ref10.genericQueryInterfaceName;
300
371
  var options = context.options.reactQuery;
301
372
  var genericResponseTypeName = 'TResponse';
302
- var genericSelectResponseTypeName = 'TData';
303
373
  context.addUtil('UseQueryOptions'); // UseQueryOptions<TResponse, Error, TData>,
304
374
 
305
- var typedUseQueryOptions = t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(genericResponseTypeName)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(genericSelectResponseTypeName))]));
375
+ var typedUseQueryOptions = t.tsTypeReference(t.identifier('UseQueryOptions'), t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier(genericResponseTypeName)), t.tsTypeReference(t.identifier('Error')), t.tsTypeReference(t.identifier(GENERIC_SELECT_RESPONSE_NAME))]));
306
376
  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)];
307
377
  return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(genericQueryInterfaceName), t.tsTypeParameterDeclaration([// 1: TResponse
308
378
  t.tsTypeParameter(undefined, undefined, genericResponseTypeName), // 2: TData
309
- t.tsTypeParameter(undefined, t.tSTypeReference(t.identifier(genericResponseTypeName)), genericSelectResponseTypeName)]), [], t.tSInterfaceBody(body)));
379
+ t.tsTypeParameter(undefined, t.tSTypeReference(t.identifier(genericResponseTypeName)), GENERIC_SELECT_RESPONSE_NAME)]), [], t.tSInterfaceBody(body)));
310
380
  }
311
381
 
312
- var createReactQueryHookInterface = function createReactQueryHookInterface(_ref8) {
313
- var context = _ref8.context,
314
- QueryClient = _ref8.QueryClient,
315
- hookParamsTypeName = _ref8.hookParamsTypeName,
316
- queryInterfaceName = _ref8.queryInterfaceName,
317
- responseType = _ref8.responseType,
318
- jsonschema = _ref8.jsonschema;
382
+ var createReactQueryHookInterface = function createReactQueryHookInterface(_ref11) {
383
+ var context = _ref11.context,
384
+ QueryClient = _ref11.QueryClient,
385
+ hookParamsTypeName = _ref11.hookParamsTypeName,
386
+ queryInterfaceName = _ref11.queryInterfaceName,
387
+ responseType = _ref11.responseType,
388
+ jsonschema = _ref11.jsonschema;
319
389
  // merge the user options with the defaults
320
390
  var options = context.options.reactQuery;
321
391
  var body = [];
@@ -326,17 +396,17 @@ var createReactQueryHookInterface = function createReactQueryHookInterface(_ref8
326
396
  t.tsTypeLiteral(props))));
327
397
  }
328
398
 
329
- return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), t.tsTypeParameterDeclaration([t.tSTypeParameter(undefined, undefined, 'TData')]), [t.tSExpressionWithTypeArguments(t.identifier(queryInterfaceName), t.tsTypeParameterInstantiation([// 1: response
399
+ return t.exportNamedDeclaration(t.tsInterfaceDeclaration(t.identifier(hookParamsTypeName), t.tsTypeParameterDeclaration([t.tSTypeParameter(undefined, undefined, GENERIC_SELECT_RESPONSE_NAME)]), [t.tSExpressionWithTypeArguments(t.identifier(queryInterfaceName), t.tsTypeParameterInstantiation([// 1: response
330
400
  t.tsTypeReference(t.identifier(responseType)), // 2: select generic
331
- t.tSTypeReference(t.identifier('TData'))]))], t.tsInterfaceBody(body)));
401
+ t.tSTypeReference(t.identifier(GENERIC_SELECT_RESPONSE_NAME))]))], t.tsInterfaceBody(body)));
332
402
  };
333
403
 
334
404
  exports.createReactQueryHookInterface = createReactQueryHookInterface;
335
405
 
336
406
  var getProps = function getProps(context, jsonschema) {
337
- var _jsonschema$propertie3;
407
+ var _jsonschema$propertie5;
338
408
 
339
- var keys = Object.keys((_jsonschema$propertie3 = jsonschema.properties) !== null && _jsonschema$propertie3 !== void 0 ? _jsonschema$propertie3 : {});
409
+ var keys = Object.keys((_jsonschema$propertie5 = jsonschema.properties) !== null && _jsonschema$propertie5 !== void 0 ? _jsonschema$propertie5 : {});
340
410
  if (!keys.length) return [];
341
411
  return keys.map(function (prop) {
342
412
  var _getPropertyType = (0, _types2.getPropertyType)(context, jsonschema, prop),
@@ -347,12 +417,12 @@ var getProps = function getProps(context, jsonschema) {
347
417
  });
348
418
  };
349
419
 
350
- var generateUseQueryQueryKey = function generateUseQueryQueryKey(_ref9) {
351
- var hookKeyName = _ref9.hookKeyName,
352
- queryKeysName = _ref9.queryKeysName,
353
- methodName = _ref9.methodName,
354
- props = _ref9.props,
355
- options = _ref9.options;
420
+ var generateUseQueryQueryKey = function generateUseQueryQueryKey(_ref12) {
421
+ var hookKeyName = _ref12.hookKeyName,
422
+ queryKeysName = _ref12.queryKeysName,
423
+ methodName = _ref12.methodName,
424
+ props = _ref12.props,
425
+ options = _ref12.options;
356
426
  var optionalClient = options.optionalClient,
357
427
  queryKeys = options.queryKeys;
358
428
  var hasArgs = props.includes('args');
@@ -58,6 +58,19 @@ it('createReactQueryHooks', function () {
58
58
  contractName: 'Sg721',
59
59
  QueryClient: 'Sg721QueryClient'
60
60
  })));
61
+ (0, _testUtils.expectCode)(t.program((0, _reactQuery.createReactQueryHooks)({
62
+ context: (0, _testUtils.makeContext)(_query_msg["default"], {
63
+ reactQuery: {
64
+ optionalClient: true,
65
+ version: 'v4',
66
+ queryKeys: true,
67
+ queryFactory: true
68
+ }
69
+ }),
70
+ queryMsg: _query_msg["default"],
71
+ contractName: 'Sg721',
72
+ QueryClient: 'Sg721QueryClient'
73
+ })));
61
74
  (0, _testUtils.expectCode)(t.program((0, _reactQuery.createReactQueryMutationHooks)({
62
75
  context: execCtx,
63
76
  execMsg: _execute_msg_for__empty["default"],
@@ -125,10 +125,12 @@ var classProperty = function classProperty(name) {
125
125
  var typeAnnotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
126
126
  var isReadonly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
127
127
  var isStatic = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
128
+ var noImplicitOverride = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
128
129
  var prop = t.classProperty(t.identifier(name));
129
130
  if (isReadonly) prop.readonly = true;
130
131
  if (isStatic) prop["static"] = true;
131
132
  if (typeAnnotation) prop.typeAnnotation = typeAnnotation;
133
+ if (noImplicitOverride) prop.override = true;
132
134
  return prop;
133
135
  };
134
136
 
@@ -71,10 +71,11 @@ export const createExecuteClass = (context, className, implementsClassName, exte
71
71
 
72
72
  [].push.apply(blockStmt, [// client/contract set
73
73
  t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('client')), t.identifier('client'))), t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('sender')), t.identifier('sender'))), t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('contractAddress')), t.identifier('contractAddress'))), ...bindings]);
74
+ const noImplicitOverride = context.options.client.noImplicitOverride && extendsClassName && context.options.client.execExtendsQuery;
74
75
  return t.exportNamedDeclaration(classDeclaration(className, [// client
75
- classProperty('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), // sender
76
+ classProperty('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient'))), false, false, noImplicitOverride), // sender
76
77
  classProperty('sender', t.tsTypeAnnotation(t.tsStringKeyword())), // contractAddress
77
- classProperty('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword())), // constructor
78
+ classProperty('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword()), false, false, noImplicitOverride), // constructor
78
79
  t.classMethod('constructor', t.identifier('constructor'), [typedIdentifier('client', t.tsTypeAnnotation(t.tsTypeReference(t.identifier('SigningCosmWasmClient')))), typedIdentifier('sender', t.tsTypeAnnotation(t.tsStringKeyword())), typedIdentifier('contractAddress', t.tsTypeAnnotation(t.tsStringKeyword()))], t.blockStatement(blockStmt)), ...methods], [t.tSExpressionWithTypeArguments(t.identifier(implementsClassName))], extendsClassName ? t.identifier(extendsClassName) : null));
79
80
  };
80
81
  export const createExecuteInterface = (context, className, extendsClassName, execMsg) => {
@@ -0,0 +1,30 @@
1
+ import execute_msg_for__empty from '../../../../../__fixtures__/sg721/execute_msg_for__empty.json';
2
+ import { createExecuteClass } from '../client';
3
+ import { expectCode, makeContext } from '../../../test-utils';
4
+ const ctx = makeContext(execute_msg_for__empty);
5
+ describe('exec', () => {});
6
+ it('Impl, execExtends, noExtendsClass', () => {
7
+ ctx.options.client.noImplicitOverride = false;
8
+ ctx.options.client.execExtendsQuery = true;
9
+ expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', null, execute_msg_for__empty));
10
+ });
11
+ it('Impl, execExtends, ExtendsClass', () => {
12
+ ctx.options.client.noImplicitOverride = false;
13
+ ctx.options.client.execExtendsQuery = true;
14
+ expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', 'ExtendsClassName', execute_msg_for__empty));
15
+ });
16
+ it('noImpl, execExtends, ExtendsClass', () => {
17
+ ctx.options.client.noImplicitOverride = true;
18
+ ctx.options.client.execExtendsQuery = true;
19
+ expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', 'ExtendsClassName', execute_msg_for__empty));
20
+ });
21
+ it('noImpl, noExecExtends, ExtendsClass', () => {
22
+ ctx.options.client.noImplicitOverride = true;
23
+ ctx.options.client.execExtendsQuery = false;
24
+ expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', 'ExtendsClassName', execute_msg_for__empty));
25
+ });
26
+ it('noImpl, noExecExtends, noExtendsClass', () => {
27
+ ctx.options.client.noImplicitOverride = true;
28
+ ctx.options.client.execExtendsQuery = false;
29
+ expectCode(createExecuteClass(ctx, 'SG721Client', 'SG721Instance', null, execute_msg_for__empty));
30
+ });
@@ -15,7 +15,8 @@ export const defaultOptions = {
15
15
  },
16
16
  client: {
17
17
  enabled: true,
18
- execExtendsQuery: true
18
+ execExtendsQuery: true,
19
+ noImplicitOverride: false
19
20
  },
20
21
  recoil: {
21
22
  enabled: false