wasm-ast-types 0.11.0 → 0.11.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.
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _accountNft = _interopRequireDefault(require("../../../../../__fixtures__/idl-version/accounts-nft/account-nft.json"));
6
+
7
+ var _client = require("../client");
8
+
9
+ var _testUtils = require("../../../test-utils");
10
+
11
+ var message = _accountNft["default"].query;
12
+ var ctx = (0, _testUtils.makeContext)(message);
13
+ it('execute_msg_for__empty', function () {
14
+ (0, _testUtils.expectCode)((0, _client.createTypeInterface)(ctx, message));
15
+ });
16
+ it('query classes', function () {
17
+ (0, _testUtils.expectCode)((0, _client.createQueryClass)(ctx, 'SG721QueryClient', 'SG721ReadOnlyInstance', message));
18
+ });
19
+ it('execute classes array types', function () {
20
+ (0, _testUtils.expectCode)((0, _client.createExecuteClass)(ctx, 'SG721Client', 'SG721Instance', null, message));
21
+ });
22
+ it('execute interfaces no extends', function () {
23
+ (0, _testUtils.expectCode)((0, _client.createExecuteInterface)(ctx, 'SG721Instance', null, message));
24
+ });
@@ -70,6 +70,12 @@ var getTypeOrRef = function getTypeOrRef(obj) {
70
70
  };
71
71
 
72
72
  var getArrayTypeFromItems = function getArrayTypeFromItems(items) {
73
+ // passing in [{"type":"string"}]
74
+ if (Array.isArray(items)) {
75
+ return t.tsArrayType(t.tsArrayType(getTypeOrRef(items[0])));
76
+ } // passing in {"items": [{"type":"string"}]}
77
+
78
+
73
79
  var detect = detectType(items.type);
74
80
 
75
81
  if (detect.type === 'array') {
@@ -193,7 +199,15 @@ var getTypeInfo = function getTypeInfo(info) {
193
199
 
194
200
  optional = _detect.optional;
195
201
  } else {
196
- type = getType(_nullableType);
202
+ var _detect2 = detectType(_nullableType);
203
+
204
+ optional = _detect2.optional;
205
+
206
+ if (_detect2.type === 'array') {
207
+ type = getArrayTypeFromItems(info.items);
208
+ } else {
209
+ type = getType(_detect2.type);
210
+ }
197
211
  }
198
212
 
199
213
  optional = true;
@@ -322,7 +336,7 @@ function getPropertySignatureFromProp(context, jsonschema, prop, camelize) {
322
336
  getPropertyType(context, jsonschema, prop);
323
337
  } catch (e) {
324
338
  console.log(e);
325
- console.log(jsonschema, prop);
339
+ console.log(JSON.stringify(jsonschema, null, 2), prop);
326
340
  }
327
341
 
328
342
  var _getPropertyType = getPropertyType(context, jsonschema, prop),
@@ -0,0 +1,17 @@
1
+ import contract from '../../../../../__fixtures__/idl-version/accounts-nft/account-nft.json';
2
+ import { createQueryClass, createExecuteClass, createExecuteInterface, createTypeInterface } from '../client';
3
+ import { expectCode, makeContext } from '../../../test-utils';
4
+ const message = contract.query;
5
+ const ctx = makeContext(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
+ });
@@ -37,6 +37,12 @@ const getTypeOrRef = obj => {
37
37
  };
38
38
 
39
39
  const getArrayTypeFromItems = items => {
40
+ // passing in [{"type":"string"}]
41
+ if (Array.isArray(items)) {
42
+ return t.tsArrayType(t.tsArrayType(getTypeOrRef(items[0])));
43
+ } // passing in {"items": [{"type":"string"}]}
44
+
45
+
40
46
  const detect = detectType(items.type);
41
47
 
42
48
  if (detect.type === 'array') {
@@ -151,7 +157,14 @@ export const getTypeInfo = info => {
151
157
 
152
158
  optional = detect.optional;
153
159
  } else {
154
- type = getType(nullableType);
160
+ const detect = detectType(nullableType);
161
+ optional = detect.optional;
162
+
163
+ if (detect.type === 'array') {
164
+ type = getArrayTypeFromItems(info.items);
165
+ } else {
166
+ type = getType(detect.type);
167
+ }
155
168
  }
156
169
 
157
170
  optional = true;
@@ -259,7 +272,7 @@ export function getPropertySignatureFromProp(context, jsonschema, prop, camelize
259
272
  getPropertyType(context, jsonschema, prop);
260
273
  } catch (e) {
261
274
  console.log(e);
262
- console.log(jsonschema, prop);
275
+ console.log(JSON.stringify(jsonschema, null, 2), prop);
263
276
  }
264
277
 
265
278
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasm-ast-types",
3
- "version": "0.11.0",
3
+ "version": "0.11.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",
@@ -86,5 +86,5 @@
86
86
  "case": "1.6.3",
87
87
  "deepmerge": "4.2.2"
88
88
  },
89
- "gitHead": "d7f8c715f76edac8c5c2762e58fe8c73351d2af5"
89
+ "gitHead": "4d6287ab9d17ea8cef91b183c00e9bae6e8529e1"
90
90
  }