zenstack 0.3.6 → 0.3.8
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/bundle/cli/index.js +83 -83
- package/package.json +2 -2
- package/src/cli/index.ts +1 -1
- package/src/generator/react-hooks/index.ts +12 -5
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publisher": "zenstack",
|
|
4
4
|
"displayName": "ZenStack Language Tools",
|
|
5
5
|
"description": "A toolkit for modeling data and access policies in full-stack development with Next.js and Typescript",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.8",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "ZenStack Team"
|
|
9
9
|
},
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"main": "./bundle/extension.js",
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@zenstackhq/internal": "0.3.
|
|
68
|
+
"@zenstackhq/internal": "0.3.8",
|
|
69
69
|
"async-exit-hook": "^2.0.1",
|
|
70
70
|
"change-case": "^4.1.2",
|
|
71
71
|
"chevrotain": "^9.1.0",
|
package/src/cli/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { paramCase } from 'change-case';
|
|
|
5
5
|
import { DataModel } from '@lang/generated/ast';
|
|
6
6
|
import colors from 'colors';
|
|
7
7
|
import { extractDataModelsWithAllowRules } from '../ast-utils';
|
|
8
|
-
import { API_ROUTE_NAME
|
|
8
|
+
import { API_ROUTE_NAME } from '../constants';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Generate react data query hooks code
|
|
@@ -51,8 +51,7 @@ export default class ReactHooksGenerator implements Generator {
|
|
|
51
51
|
moduleSpecifier: '../../.prisma',
|
|
52
52
|
});
|
|
53
53
|
sf.addStatements([
|
|
54
|
-
`import { request, validate } from '
|
|
55
|
-
`import { ServerErrorCode } from '@zenstackhq/runtime/client';`,
|
|
54
|
+
`import { request, validate, ServerErrorCode, RequestOptions } from '@zenstackhq/runtime/client';`,
|
|
56
55
|
`import { type SWRResponse } from 'swr';`,
|
|
57
56
|
`import { ${this.getValidator(
|
|
58
57
|
model,
|
|
@@ -119,11 +118,15 @@ export default class ReactHooksGenerator implements Generator {
|
|
|
119
118
|
name: 'args?',
|
|
120
119
|
type: `P.SelectSubset<T, P.${model.name}FindManyArgs>`,
|
|
121
120
|
},
|
|
121
|
+
{
|
|
122
|
+
name: 'options?',
|
|
123
|
+
type: 'RequestOptions',
|
|
124
|
+
},
|
|
122
125
|
],
|
|
123
126
|
})
|
|
124
127
|
.addBody()
|
|
125
128
|
.addStatements([
|
|
126
|
-
`return request.get<P.CheckSelect<T, Array<${model.name}>, Array<P.${model.name}GetPayload<T>>>>(endpoint, args);`,
|
|
129
|
+
`return request.get<P.CheckSelect<T, Array<${model.name}>, Array<P.${model.name}GetPayload<T>>>>(endpoint, args, options);`,
|
|
127
130
|
]);
|
|
128
131
|
|
|
129
132
|
// get
|
|
@@ -141,11 +144,15 @@ export default class ReactHooksGenerator implements Generator {
|
|
|
141
144
|
name: 'args?',
|
|
142
145
|
type: `P.SelectSubset<T, P.Subset<P.${model.name}FindFirstArgs, 'select' | 'include'>>`,
|
|
143
146
|
},
|
|
147
|
+
{
|
|
148
|
+
name: 'options?',
|
|
149
|
+
type: 'RequestOptions',
|
|
150
|
+
},
|
|
144
151
|
],
|
|
145
152
|
})
|
|
146
153
|
.addBody()
|
|
147
154
|
.addStatements([
|
|
148
|
-
`return request.get<P.CheckSelect<T, ${model.name}, P.${model.name}GetPayload<T>>>(id ? \`\${endpoint}/\${id}\`: null, args);`,
|
|
155
|
+
`return request.get<P.CheckSelect<T, ${model.name}, P.${model.name}GetPayload<T>>>(id ? \`\${endpoint}/\${id}\`: null, args, options);`,
|
|
149
156
|
]);
|
|
150
157
|
|
|
151
158
|
// update
|