@cosmwasm/ts-codegen 0.19.0 → 0.20.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.
- package/README.md +3 -0
- package/main/commands/generate.js +29 -9
- package/module/commands/generate.js +19 -2
- package/package.json +3 -3
- package/src/commands/generate.ts +16 -1
package/README.md
CHANGED
@@ -10,6 +10,7 @@ Generate TypeScript SDKs for your CosmWasm smart contracts
|
|
10
10
|
<a href="https://github.com/CosmWasm/ts-codegen/actions/workflows/run-tests.yaml">
|
11
11
|
<img height="20" src="https://github.com/CosmWasm/ts-codegen/actions/workflows/run-tests.yaml/badge.svg" />
|
12
12
|
</a>
|
13
|
+
<a href="https://www.npmjs.com/package/@cosmwasm/ts-codegen"><img height="20" src="https://img.shields.io/npm/dt/@cosmwasm/ts-codegen"></a>
|
13
14
|
<a href="https://github.com/CosmWasm/ts-codegen/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
|
14
15
|
<a href="https://github.com/CosmWasm/ts-codegen/blob/main/LICENSE-Apache"><img height="20" src="https://img.shields.io/badge/license-Apache-blue.svg"></a>
|
15
16
|
<a href="https://www.npmjs.com/package/@cosmwasm/ts-codegen"><img height="20" src="https://img.shields.io/github/package-json/v/CosmWasm/ts-codegen?filename=packages%2Fts-codegen%2Fpackage.json"></a>
|
@@ -110,6 +111,7 @@ codegen({
|
|
110
111
|
version: 'v4',
|
111
112
|
mutations: true,
|
112
113
|
queryKeys: true,
|
114
|
+
queryFactory: true,
|
113
115
|
},
|
114
116
|
recoil: {
|
115
117
|
enabled: false
|
@@ -170,6 +172,7 @@ Generate [react-query v3](https://react-query-v3.tanstack.com/) or [react-query
|
|
170
172
|
| `reactQuery.enabled` | enable the react-query plugin |
|
171
173
|
| `reactQuery.optionalClient` | allows contract client to be undefined as the component renders |
|
172
174
|
| `reactQuery.queryKeys` | generates a const queryKeys object for use with invalidations and set values |
|
175
|
+
| `reactQuery.queryFactory` | generates a const queryFactory object for useQueries and prefetchQueries use |
|
173
176
|
| `reactQuery.version` | `v4` uses `@tanstack/react-query` and `v3` uses `react-query` |
|
174
177
|
| `reactQuery.mutations` | also generate mutations |
|
175
178
|
| `reactQuery.camelize` | use camelCase style for property names |
|
@@ -17,7 +17,7 @@ var _index = _interopRequireDefault(require("../index"));
|
|
17
17
|
|
18
18
|
var _default = /*#__PURE__*/function () {
|
19
19
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(argv) {
|
20
|
-
var questions, _yield$prompt, schema, out, name, plugin, bundle, questions2, _yield$prompt2, optionalClient, version, queryKeys, questions3, _yield$prompt3, mutations,
|
20
|
+
var questions, _yield$prompt, schema, out, name, plugin, bundle, questions2, _yield$prompt2, optionalClient, version, queryKeys, questions3, _yield$prompt3, mutations, queryFactoryQuestions, _yield$prompt4, queryFactory, questions4, _yield$prompt5, bundleFile, bundleScope, options;
|
21
21
|
|
22
22
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
23
23
|
while (1) {
|
@@ -118,6 +118,25 @@ var _default = /*#__PURE__*/function () {
|
|
118
118
|
case 25:
|
119
119
|
_yield$prompt3 = _context.sent;
|
120
120
|
mutations = _yield$prompt3.mutations;
|
121
|
+
queryFactoryQuestions = [];
|
122
|
+
|
123
|
+
if (queryKeys) {
|
124
|
+
[].push.apply(queryFactoryQuestions, [// Only can use queryFactory if queryKeys is enabled
|
125
|
+
{
|
126
|
+
type: 'confirm',
|
127
|
+
name: 'queryFactory',
|
128
|
+
message: 'queryFactory? ',
|
129
|
+
"default": false
|
130
|
+
}]);
|
131
|
+
}
|
132
|
+
|
133
|
+
;
|
134
|
+
_context.next = 32;
|
135
|
+
return (0, _prompt.prompt)(queryFactoryQuestions, argv);
|
136
|
+
|
137
|
+
case 32:
|
138
|
+
_yield$prompt4 = _context.sent;
|
139
|
+
queryFactory = _yield$prompt4.queryFactory;
|
121
140
|
///////// END REACT QUERY
|
122
141
|
///////// BUNDLE
|
123
142
|
questions4 = [];
|
@@ -137,13 +156,13 @@ var _default = /*#__PURE__*/function () {
|
|
137
156
|
}
|
138
157
|
|
139
158
|
;
|
140
|
-
_context.next =
|
159
|
+
_context.next = 39;
|
141
160
|
return (0, _prompt.prompt)(questions4, argv);
|
142
161
|
|
143
|
-
case
|
144
|
-
_yield$
|
145
|
-
bundleFile = _yield$
|
146
|
-
bundleScope = _yield$
|
162
|
+
case 39:
|
163
|
+
_yield$prompt5 = _context.sent;
|
164
|
+
bundleFile = _yield$prompt5.bundleFile;
|
165
|
+
bundleScope = _yield$prompt5.bundleScope;
|
147
166
|
///////// END BUNDLE
|
148
167
|
options = {
|
149
168
|
types: {
|
@@ -157,7 +176,8 @@ var _default = /*#__PURE__*/function () {
|
|
157
176
|
optionalClient: optionalClient,
|
158
177
|
queryKeys: queryKeys,
|
159
178
|
version: version,
|
160
|
-
mutations: mutations
|
179
|
+
mutations: mutations,
|
180
|
+
queryFactory: queryFactory
|
161
181
|
},
|
162
182
|
recoil: {
|
163
183
|
enabled: plugin.includes('recoil')
|
@@ -171,7 +191,7 @@ var _default = /*#__PURE__*/function () {
|
|
171
191
|
bundleFile: bundleFile
|
172
192
|
}
|
173
193
|
};
|
174
|
-
_context.next =
|
194
|
+
_context.next = 45;
|
175
195
|
return (0, _index["default"])({
|
176
196
|
contracts: [{
|
177
197
|
name: name,
|
@@ -181,7 +201,7 @@ var _default = /*#__PURE__*/function () {
|
|
181
201
|
options: options
|
182
202
|
});
|
183
203
|
|
184
|
-
case
|
204
|
+
case 45:
|
185
205
|
case "end":
|
186
206
|
return _context.stop();
|
187
207
|
}
|
@@ -86,7 +86,23 @@ export default (async argv => {
|
|
86
86
|
;
|
87
87
|
const {
|
88
88
|
mutations
|
89
|
-
} = await prompt(questions3, argv);
|
89
|
+
} = await prompt(questions3, argv);
|
90
|
+
const queryFactoryQuestions = [];
|
91
|
+
|
92
|
+
if (queryKeys) {
|
93
|
+
[].push.apply(queryFactoryQuestions, [// Only can use queryFactory if queryKeys is enabled
|
94
|
+
{
|
95
|
+
type: 'confirm',
|
96
|
+
name: 'queryFactory',
|
97
|
+
message: 'queryFactory? ',
|
98
|
+
default: false
|
99
|
+
}]);
|
100
|
+
}
|
101
|
+
|
102
|
+
;
|
103
|
+
const {
|
104
|
+
queryFactory
|
105
|
+
} = await prompt(queryFactoryQuestions, argv); ///////// END REACT QUERY
|
90
106
|
///////// BUNDLE
|
91
107
|
|
92
108
|
const questions4 = [];
|
@@ -123,7 +139,8 @@ export default (async argv => {
|
|
123
139
|
optionalClient,
|
124
140
|
queryKeys,
|
125
141
|
version,
|
126
|
-
mutations
|
142
|
+
mutations,
|
143
|
+
queryFactory
|
127
144
|
},
|
128
145
|
recoil: {
|
129
146
|
enabled: plugin.includes('recoil')
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@cosmwasm/ts-codegen",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.20.0",
|
4
4
|
"description": "@cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.",
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
6
6
|
"homepage": "https://github.com/cosmwasm/ts-codegen",
|
@@ -96,7 +96,7 @@
|
|
96
96
|
"parse-package-name": "1.0.0",
|
97
97
|
"rimraf": "3.0.2",
|
98
98
|
"shelljs": "0.8.5",
|
99
|
-
"wasm-ast-types": "^0.
|
99
|
+
"wasm-ast-types": "^0.14.0"
|
100
100
|
},
|
101
|
-
"gitHead": "
|
101
|
+
"gitHead": "e58a660b6265fc94bdd11f311afe9fac11708c51"
|
102
102
|
}
|
package/src/commands/generate.ts
CHANGED
@@ -90,6 +90,20 @@ export default async (argv) => {
|
|
90
90
|
])
|
91
91
|
};
|
92
92
|
const { mutations } = await prompt(questions3, argv);
|
93
|
+
|
94
|
+
const queryFactoryQuestions = [];
|
95
|
+
if (queryKeys) {
|
96
|
+
[].push.apply(queryFactoryQuestions, [
|
97
|
+
// Only can use queryFactory if queryKeys is enabled
|
98
|
+
{
|
99
|
+
type: 'confirm',
|
100
|
+
name: 'queryFactory',
|
101
|
+
message: 'queryFactory? ',
|
102
|
+
default: false
|
103
|
+
}
|
104
|
+
])
|
105
|
+
};
|
106
|
+
const { queryFactory } = await prompt(queryFactoryQuestions, argv);
|
93
107
|
///////// END REACT QUERY
|
94
108
|
|
95
109
|
///////// BUNDLE
|
@@ -128,7 +142,8 @@ export default async (argv) => {
|
|
128
142
|
optionalClient,
|
129
143
|
queryKeys,
|
130
144
|
version,
|
131
|
-
mutations
|
145
|
+
mutations,
|
146
|
+
queryFactory
|
132
147
|
},
|
133
148
|
recoil: {
|
134
149
|
enabled: plugin.includes('recoil'),
|