@zenstackhq/tanstack-query 1.0.0-beta.8 → 1.0.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/generator.d.ts +1 -1
- package/generator.js +54 -52
- package/generator.js.map +1 -1
- package/package.json +41 -14
- package/runtime/common-52ab2c3a.d.ts +19 -0
- package/runtime/index.d.mts +18 -0
- package/runtime/index.d.ts +18 -0
- package/runtime/index.js +19 -0
- package/runtime/index.js.map +1 -0
- package/runtime/index.mjs +1 -0
- package/runtime/index.mjs.map +1 -0
- package/runtime/react.d.mts +65 -0
- package/runtime/react.d.ts +65 -0
- package/runtime/react.js +226 -0
- package/runtime/react.js.map +1 -0
- package/runtime/react.mjs +203 -0
- package/runtime/react.mjs.map +1 -0
- package/runtime/svelte.d.mts +61 -0
- package/runtime/svelte.d.ts +61 -0
- package/runtime/svelte.js +216 -0
- package/runtime/svelte.js.map +1 -0
- package/runtime/svelte.mjs +194 -0
- package/runtime/svelte.mjs.map +1 -0
- package/res/marshal-json.ts +0 -12
- package/res/marshal-superjson.ts +0 -20
- package/res/react/helper.ts +0 -164
- package/res/shared.ts +0 -50
- package/res/svelte/helper.ts +0 -155
package/generator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DMMF } from '@prisma/generator-helper';
|
|
1
|
+
import type { DMMF } from '@prisma/generator-helper';
|
|
2
2
|
import { PluginOptions } from '@zenstackhq/sdk';
|
|
3
3
|
import { Model } from '@zenstackhq/sdk/ast';
|
|
4
4
|
export declare function generate(model: Model, options: PluginOptions, dmmf: DMMF.Document): Promise<string[]>;
|
package/generator.js
CHANGED
|
@@ -15,9 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.generate = void 0;
|
|
16
16
|
const sdk_1 = require("@zenstackhq/sdk");
|
|
17
17
|
const change_case_1 = require("change-case");
|
|
18
|
-
const fs_1 = __importDefault(require("fs"));
|
|
19
18
|
const lower_case_first_1 = require("lower-case-first");
|
|
20
19
|
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const semver_1 = __importDefault(require("semver"));
|
|
21
21
|
const ts_morph_1 = require("ts-morph");
|
|
22
22
|
const upper_case_first_1 = require("upper-case-first");
|
|
23
23
|
const _1 = require(".");
|
|
@@ -33,8 +33,7 @@ function generate(model, options, dmmf) {
|
|
|
33
33
|
if (!supportedTargets.includes(target)) {
|
|
34
34
|
throw new sdk_1.PluginError(options.name, `Unsupported target "${target}", supported values: ${supportedTargets.join(', ')}`);
|
|
35
35
|
}
|
|
36
|
-
generateIndex(project, outDir, models);
|
|
37
|
-
generateHelper(target, project, outDir, options.useSuperJson === true);
|
|
36
|
+
generateIndex(project, outDir, models, target);
|
|
38
37
|
models.forEach((dataModel) => {
|
|
39
38
|
const mapping = dmmf.mappings.modelOperations.find((op) => op.model === dataModel.name);
|
|
40
39
|
if (!mapping) {
|
|
@@ -48,14 +47,14 @@ function generate(model, options, dmmf) {
|
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
exports.generate = generate;
|
|
51
|
-
function generateQueryHook(target, sf, model, operation, returnArray, optionalInput, overrideReturnType, overrideInputType, overrideTypeParameters) {
|
|
50
|
+
function generateQueryHook(target, sf, model, operation, returnArray, optionalInput, overrideReturnType, overrideInputType, overrideTypeParameters, infinite = false) {
|
|
52
51
|
const capOperation = (0, upper_case_first_1.upperCaseFirst)(operation);
|
|
53
52
|
const argsType = overrideInputType !== null && overrideInputType !== void 0 ? overrideInputType : `Prisma.${model}${capOperation}Args`;
|
|
54
53
|
const inputType = `Prisma.SelectSubset<T, ${argsType}>`;
|
|
55
54
|
const returnType = overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : (returnArray ? `Array<Prisma.${model}GetPayload<T>>` : `Prisma.${model}GetPayload<T>`);
|
|
56
|
-
const optionsType = makeQueryOptions(target, returnType);
|
|
55
|
+
const optionsType = makeQueryOptions(target, returnType, infinite);
|
|
57
56
|
const func = sf.addFunction({
|
|
58
|
-
name: `use${capOperation}${model}`,
|
|
57
|
+
name: `use${infinite ? 'Infinite' : ''}${capOperation}${model}`,
|
|
59
58
|
typeParameters: overrideTypeParameters !== null && overrideTypeParameters !== void 0 ? overrideTypeParameters : [`T extends ${argsType}`],
|
|
60
59
|
parameters: [
|
|
61
60
|
{
|
|
@@ -71,15 +70,18 @@ function generateQueryHook(target, sf, model, operation, returnArray, optionalIn
|
|
|
71
70
|
});
|
|
72
71
|
func.addStatements([
|
|
73
72
|
makeGetContext(target),
|
|
74
|
-
`return query<${returnType}>('${model}', \`\${endpoint}/${(0, lower_case_first_1.lowerCaseFirst)(model)}/${operation}\`, args, options, fetch);`,
|
|
73
|
+
`return ${infinite ? 'infiniteQuery' : 'query'}<${returnType}>('${model}', \`\${endpoint}/${(0, lower_case_first_1.lowerCaseFirst)(model)}/${operation}\`, args, options, fetch);`,
|
|
75
74
|
]);
|
|
76
75
|
}
|
|
77
|
-
function generateMutationHook(target, sf, model, operation, httpVerb, overrideReturnType) {
|
|
76
|
+
function generateMutationHook(target, sf, model, operation, httpVerb, checkReadBack, overrideReturnType) {
|
|
78
77
|
const capOperation = (0, upper_case_first_1.upperCaseFirst)(operation);
|
|
79
78
|
const argsType = `Prisma.${model}${capOperation}Args`;
|
|
80
79
|
const inputType = `Prisma.SelectSubset<T, ${argsType}>`;
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
let returnType = overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : `CheckSelect<T, ${model}, Prisma.${model}GetPayload<T>>`;
|
|
81
|
+
if (checkReadBack) {
|
|
82
|
+
returnType = `(${returnType} | undefined )`;
|
|
83
|
+
}
|
|
84
|
+
const nonGenericOptionsType = `Omit<${makeMutationOptions(target, checkReadBack ? `(${overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : model} | undefined)` : overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : model, argsType)}, 'mutationFn'>`;
|
|
83
85
|
const optionsType = `Omit<${makeMutationOptions(target, returnType, inputType)}, 'mutationFn'>`;
|
|
84
86
|
const func = sf.addFunction({
|
|
85
87
|
name: `use${capOperation}${model}`,
|
|
@@ -104,7 +106,7 @@ function generateMutationHook(target, sf, model, operation, httpVerb, overrideRe
|
|
|
104
106
|
{
|
|
105
107
|
name: `_mutation`,
|
|
106
108
|
initializer: `
|
|
107
|
-
${httpVerb}Mutation<${argsType}, ${overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : model}>('${model}', \`\${endpoint}/${(0, lower_case_first_1.lowerCaseFirst)(model)}/${operation}\`, options, fetch, invalidateQueries)
|
|
109
|
+
${httpVerb}Mutation<${argsType}, ${overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : model}, ${checkReadBack}>('${model}', \`\${endpoint}/${(0, lower_case_first_1.lowerCaseFirst)(model)}/${operation}\`, options, fetch, invalidateQueries, ${checkReadBack})
|
|
108
110
|
`,
|
|
109
111
|
},
|
|
110
112
|
],
|
|
@@ -164,6 +166,8 @@ function generateMutationHook(target, sf, model, operation, httpVerb, overrideRe
|
|
|
164
166
|
func.addStatements('return mutation;');
|
|
165
167
|
}
|
|
166
168
|
function generateModelHooks(target, project, outDir, model, mapping) {
|
|
169
|
+
const modelNameCap = (0, upper_case_first_1.upperCaseFirst)(model.name);
|
|
170
|
+
const prismaVersion = (0, sdk_1.getPrismaVersion)();
|
|
167
171
|
const fileName = (0, change_case_1.paramCase)(model.name);
|
|
168
172
|
const sf = project.createSourceFile(path_1.default.join(outDir, `${fileName}.ts`), undefined, { overwrite: true });
|
|
169
173
|
sf.addStatements('/* eslint-disable */');
|
|
@@ -177,15 +181,18 @@ function generateModelHooks(target, project, outDir, model, mapping) {
|
|
|
177
181
|
// create is somehow named "createOne" in the DMMF
|
|
178
182
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
183
|
if (mapping.create || mapping.createOne) {
|
|
180
|
-
generateMutationHook(target, sf, model.name, 'create', 'post');
|
|
184
|
+
generateMutationHook(target, sf, model.name, 'create', 'post', true);
|
|
181
185
|
}
|
|
182
186
|
// createMany
|
|
183
187
|
if (mapping.createMany) {
|
|
184
|
-
generateMutationHook(target, sf, model.name, 'createMany', 'post', 'Prisma.BatchPayload');
|
|
188
|
+
generateMutationHook(target, sf, model.name, 'createMany', 'post', false, 'Prisma.BatchPayload');
|
|
185
189
|
}
|
|
186
190
|
// findMany
|
|
187
191
|
if (mapping.findMany) {
|
|
192
|
+
// regular findMany
|
|
188
193
|
generateQueryHook(target, sf, model.name, 'findMany', true, true);
|
|
194
|
+
// infinite findMany
|
|
195
|
+
generateQueryHook(target, sf, model.name, 'findMany', true, true, undefined, undefined, undefined, true);
|
|
189
196
|
}
|
|
190
197
|
// findUnique
|
|
191
198
|
if (mapping.findUnique) {
|
|
@@ -199,40 +206,45 @@ function generateModelHooks(target, project, outDir, model, mapping) {
|
|
|
199
206
|
// update is somehow named "updateOne" in the DMMF
|
|
200
207
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
201
208
|
if (mapping.update || mapping.updateOne) {
|
|
202
|
-
generateMutationHook(target, sf, model.name, 'update', 'put');
|
|
209
|
+
generateMutationHook(target, sf, model.name, 'update', 'put', true);
|
|
203
210
|
}
|
|
204
211
|
// updateMany
|
|
205
212
|
if (mapping.updateMany) {
|
|
206
|
-
generateMutationHook(target, sf, model.name, 'updateMany', 'put', 'Prisma.BatchPayload');
|
|
213
|
+
generateMutationHook(target, sf, model.name, 'updateMany', 'put', false, 'Prisma.BatchPayload');
|
|
207
214
|
}
|
|
208
215
|
// upsert
|
|
209
216
|
// upsert is somehow named "upsertOne" in the DMMF
|
|
210
217
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
211
218
|
if (mapping.upsert || mapping.upsertOne) {
|
|
212
|
-
generateMutationHook(target, sf, model.name, 'upsert', 'post');
|
|
219
|
+
generateMutationHook(target, sf, model.name, 'upsert', 'post', true);
|
|
213
220
|
}
|
|
214
221
|
// del
|
|
215
222
|
// delete is somehow named "deleteOne" in the DMMF
|
|
216
223
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
224
|
if (mapping.delete || mapping.deleteOne) {
|
|
218
|
-
generateMutationHook(target, sf, model.name, 'delete', 'delete');
|
|
225
|
+
generateMutationHook(target, sf, model.name, 'delete', 'delete', true);
|
|
219
226
|
}
|
|
220
227
|
// deleteMany
|
|
221
228
|
if (mapping.deleteMany) {
|
|
222
|
-
generateMutationHook(target, sf, model.name, 'deleteMany', 'delete', 'Prisma.BatchPayload');
|
|
229
|
+
generateMutationHook(target, sf, model.name, 'deleteMany', 'delete', false, 'Prisma.BatchPayload');
|
|
223
230
|
}
|
|
224
231
|
// aggregate
|
|
225
232
|
if (mapping.aggregate) {
|
|
226
|
-
generateQueryHook(target, sf,
|
|
233
|
+
generateQueryHook(target, sf, modelNameCap, 'aggregate', false, false, `Prisma.Get${modelNameCap}AggregateType<T>`);
|
|
227
234
|
}
|
|
228
235
|
// groupBy
|
|
229
236
|
if (mapping.groupBy) {
|
|
237
|
+
let useName = modelNameCap;
|
|
238
|
+
// prisma 4 and 5 different typing for "groupBy" and we have to deal with it separately
|
|
239
|
+
if (prismaVersion && semver_1.default.gte(prismaVersion, '5.0.0')) {
|
|
240
|
+
useName = model.name;
|
|
241
|
+
}
|
|
230
242
|
const typeParameters = [
|
|
231
|
-
`T extends Prisma.${
|
|
243
|
+
`T extends Prisma.${useName}GroupByArgs`,
|
|
232
244
|
`HasSelectOrTake extends Prisma.Or<Prisma.Extends<'skip', Prisma.Keys<T>>, Prisma.Extends<'take', Prisma.Keys<T>>>`,
|
|
233
|
-
`OrderByArg extends Prisma.True extends HasSelectOrTake ? { orderBy: Prisma.${
|
|
245
|
+
`OrderByArg extends Prisma.True extends HasSelectOrTake ? { orderBy: Prisma.${useName}GroupByArgs['orderBy'] }: { orderBy?: Prisma.${useName}GroupByArgs['orderBy'] },`,
|
|
234
246
|
`OrderFields extends Prisma.ExcludeUnderscoreKeys<Prisma.Keys<Prisma.MaybeTupleToUnion<T['orderBy']>>>`,
|
|
235
|
-
`ByFields extends Prisma.
|
|
247
|
+
`ByFields extends Prisma.MaybeTupleToUnion<T['by']>`,
|
|
236
248
|
`ByValid extends Prisma.Has<ByFields, OrderFields>`,
|
|
237
249
|
`HavingFields extends Prisma.GetHavingFields<T['having']>`,
|
|
238
250
|
`HavingValid extends Prisma.Has<ByFields, HavingFields>`,
|
|
@@ -281,46 +293,33 @@ function generateModelHooks(target, project, outDir, model, mapping) {
|
|
|
281
293
|
}[OrderFields]`,
|
|
282
294
|
];
|
|
283
295
|
const returnType = `{} extends InputErrors ?
|
|
284
|
-
Array<
|
|
296
|
+
Array<PickEnumerable<Prisma.${modelNameCap}GroupByOutputType, T['by']> &
|
|
285
297
|
{
|
|
286
|
-
[P in ((keyof T) & (keyof Prisma.${
|
|
298
|
+
[P in ((keyof T) & (keyof Prisma.${modelNameCap}GroupByOutputType))]: P extends '_count'
|
|
287
299
|
? T[P] extends boolean
|
|
288
300
|
? number
|
|
289
|
-
: Prisma.GetScalarType<T[P], Prisma.${
|
|
290
|
-
: Prisma.GetScalarType<T[P], Prisma.${
|
|
301
|
+
: Prisma.GetScalarType<T[P], Prisma.${modelNameCap}GroupByOutputType[P]>
|
|
302
|
+
: Prisma.GetScalarType<T[P], Prisma.${modelNameCap}GroupByOutputType[P]>
|
|
291
303
|
}
|
|
292
304
|
> : InputErrors`;
|
|
293
|
-
generateQueryHook(target, sf, model.name, 'groupBy', false, false, returnType, `Prisma.SubsetIntersection<T, Prisma.${
|
|
305
|
+
generateQueryHook(target, sf, model.name, 'groupBy', false, false, returnType, `Prisma.SubsetIntersection<T, Prisma.${useName}GroupByArgs, OrderByArg> & InputErrors`, typeParameters);
|
|
294
306
|
}
|
|
295
307
|
// somehow dmmf doesn't contain "count" operation, so we unconditionally add it here
|
|
296
308
|
{
|
|
297
|
-
generateQueryHook(target, sf, model.name, 'count', false, true, `T extends { select: any; } ? T['select'] extends true ? number : Prisma.GetScalarType<T['select'], Prisma.${
|
|
309
|
+
generateQueryHook(target, sf, model.name, 'count', false, true, `T extends { select: any; } ? T['select'] extends true ? number : Prisma.GetScalarType<T['select'], Prisma.${modelNameCap}CountAggregateOutputType> : number`);
|
|
298
310
|
}
|
|
299
311
|
}
|
|
300
|
-
function generateIndex(project, outDir, models) {
|
|
312
|
+
function generateIndex(project, outDir, models, target) {
|
|
301
313
|
const sf = project.createSourceFile(path_1.default.join(outDir, 'index.ts'), undefined, { overwrite: true });
|
|
302
314
|
sf.addStatements(models.map((d) => `export * from './${(0, change_case_1.paramCase)(d.name)}';`));
|
|
303
|
-
sf.addStatements(`export * from './_helper';`);
|
|
304
|
-
}
|
|
305
|
-
function generateHelper(target, project, outDir, useSuperJson) {
|
|
306
|
-
let srcFile;
|
|
307
315
|
switch (target) {
|
|
308
316
|
case 'react':
|
|
309
|
-
|
|
317
|
+
sf.addStatements(`export { Provider } from '@zenstackhq/tanstack-query/runtime/react';`);
|
|
310
318
|
break;
|
|
311
319
|
case 'svelte':
|
|
312
|
-
|
|
320
|
+
sf.addStatements(`export { SvelteQueryContextKey } from '@zenstackhq/tanstack-query/runtime/svelte';`);
|
|
313
321
|
break;
|
|
314
|
-
default:
|
|
315
|
-
throw new sdk_1.PluginError(_1.name, `Unsupported target: ${target}`);
|
|
316
322
|
}
|
|
317
|
-
// merge content of `shared.ts`, `helper.ts` and `marshal-?.ts`
|
|
318
|
-
const sharedContent = fs_1.default.readFileSync(path_1.default.join(__dirname, './res/shared.ts'), 'utf-8');
|
|
319
|
-
const helperContent = fs_1.default.readFileSync(srcFile, 'utf-8');
|
|
320
|
-
const marshalContent = fs_1.default.readFileSync(path_1.default.join(__dirname, useSuperJson ? './res/marshal-superjson.ts' : './res/marshal-json.ts'), 'utf-8');
|
|
321
|
-
project.createSourceFile(path_1.default.join(outDir, '_helper.ts'), `${sharedContent}\n${helperContent}\n${marshalContent}`, {
|
|
322
|
-
overwrite: true,
|
|
323
|
-
});
|
|
324
323
|
}
|
|
325
324
|
function makeGetContext(target) {
|
|
326
325
|
switch (target) {
|
|
@@ -333,33 +332,36 @@ function makeGetContext(target) {
|
|
|
333
332
|
}
|
|
334
333
|
}
|
|
335
334
|
function makeBaseImports(target) {
|
|
336
|
-
const shared = [
|
|
335
|
+
const shared = [
|
|
336
|
+
`import { query, infiniteQuery, postMutation, putMutation, deleteMutation } from '@zenstackhq/tanstack-query/runtime/${target}';`,
|
|
337
|
+
`import type { PickEnumerable, CheckSelect } from '@zenstackhq/tanstack-query/runtime';`,
|
|
338
|
+
];
|
|
337
339
|
switch (target) {
|
|
338
340
|
case 'react':
|
|
339
341
|
return [
|
|
340
342
|
`import { useContext } from 'react';`,
|
|
341
|
-
`import type { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';`,
|
|
342
|
-
`import { RequestHandlerContext } from '
|
|
343
|
+
`import type { UseMutationOptions, UseQueryOptions, UseInfiniteQueryOptions } from '@tanstack/react-query';`,
|
|
344
|
+
`import { RequestHandlerContext } from '@zenstackhq/tanstack-query/runtime/${target}';`,
|
|
343
345
|
...shared,
|
|
344
346
|
];
|
|
345
347
|
case 'svelte':
|
|
346
348
|
return [
|
|
347
349
|
`import { getContext } from 'svelte';`,
|
|
348
350
|
`import { derived } from 'svelte/store';`,
|
|
349
|
-
`import type { MutationOptions, QueryOptions } from '@tanstack/svelte-query';`,
|
|
350
|
-
`import { SvelteQueryContextKey, type RequestHandlerContext } from '
|
|
351
|
+
`import type { MutationOptions, QueryOptions, CreateInfiniteQueryOptions } from '@tanstack/svelte-query';`,
|
|
352
|
+
`import { SvelteQueryContextKey, type RequestHandlerContext } from '@zenstackhq/tanstack-query/runtime/${target}';`,
|
|
351
353
|
...shared,
|
|
352
354
|
];
|
|
353
355
|
default:
|
|
354
356
|
throw new sdk_1.PluginError(_1.name, `Unsupported target: ${target}`);
|
|
355
357
|
}
|
|
356
358
|
}
|
|
357
|
-
function makeQueryOptions(target, returnType) {
|
|
359
|
+
function makeQueryOptions(target, returnType, infinite) {
|
|
358
360
|
switch (target) {
|
|
359
361
|
case 'react':
|
|
360
|
-
return `
|
|
362
|
+
return `Use${infinite ? 'Infinite' : ''}QueryOptions<${returnType}>`;
|
|
361
363
|
case 'svelte':
|
|
362
|
-
return
|
|
364
|
+
return `${infinite ? 'CreateInfinite' : ''}QueryOptions<${returnType}>`;
|
|
363
365
|
default:
|
|
364
366
|
throw new sdk_1.PluginError(_1.name, `Unsupported target: ${target}`);
|
|
365
367
|
}
|
package/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,yCAUyB;AAEzB,6CAAwC;AACxC,uDAAkD;AAClD,gDAAwB;AACxB,oDAA4B;AAC5B,uCAAwE;AACxE,uDAAkD;AAClD,wBAAyB;AAEzB,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAG7C,SAAsB,QAAQ,CAAC,KAAY,EAAE,OAAsB,EAAE,IAAmB;;QACpF,IAAI,MAAM,GAAG,IAAA,mBAAa,EAAS,OAAO,EAAE,QAAQ,CAAC,CAAC;QACtD,MAAM,GAAG,IAAA,iBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAEtC,MAAM,OAAO,GAAG,IAAA,mBAAa,GAAE,CAAC;QAChC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAA,mBAAa,EAAC,KAAK,CAAC,CAAC;QAEpC,MAAM,MAAM,GAAG,IAAA,mBAAa,EAAS,OAAO,EAAE,QAAQ,CAAC,CAAC;QACxD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACpC,MAAM,IAAI,iBAAW,C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,OAAO;YACR,OAAO,MAAM,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,gBAAgB,UAAU,GAAG,CAAC;QACzE,KAAK,QAAQ;YACT,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,UAAU,GAAG,CAAC;QAC5E;YACI,MAAM,IAAI,iBAAW,CAAC,OAAI,EAAE,uBAAuB,MAAM,EAAE,CAAC,CAAC;KACpE;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc,EAAE,UAAkB,EAAE,QAAgB;IAC7E,QAAQ,MAAM,EAAE;QACZ,KAAK,OAAO;YACR,OAAO,sBAAsB,UAAU,cAAc,QAAQ,GAAG,CAAC;QACrE,KAAK,QAAQ;YACT,OAAO,mBAAmB,UAAU,cAAc,QAAQ,GAAG,CAAC;QAClE;YACI,MAAM,IAAI,iBAAW,CAAC,OAAI,EAAE,uBAAuB,MAAM,EAAE,CAAC,CAAC;KACpE;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenstackhq/tanstack-query",
|
|
3
3
|
"displayName": "ZenStack plugin for generating tanstack-query hooks",
|
|
4
|
-
"version": "1.0.0
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "ZenStack plugin for generating tanstack-query hooks",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"default": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"./package.json": {
|
|
12
|
+
"default": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"./runtime": {
|
|
15
|
+
"import": "./runtime/index.mjs",
|
|
16
|
+
"require": "./runtime/index.js",
|
|
17
|
+
"default": "./runtime/index.js",
|
|
18
|
+
"types": "./runtime/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./runtime/react": {
|
|
21
|
+
"import": "./runtime/react.mjs",
|
|
22
|
+
"require": "./runtime/react.js",
|
|
23
|
+
"default": "./runtime/react.js",
|
|
24
|
+
"types": "./runtime/react.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./runtime/svelte": {
|
|
27
|
+
"import": "./runtime/svelte.mjs",
|
|
28
|
+
"require": "./runtime/svelte.js",
|
|
29
|
+
"default": "./runtime/svelte.js",
|
|
30
|
+
"types": "./runtime/svelte.d.ts"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
7
33
|
"repository": {
|
|
8
34
|
"type": "git",
|
|
9
35
|
"url": "https://github.com/zenstackhq/zenstack"
|
|
@@ -16,39 +42,40 @@
|
|
|
16
42
|
"author": "ZenStack Team",
|
|
17
43
|
"license": "MIT",
|
|
18
44
|
"dependencies": {
|
|
19
|
-
"@prisma/generator-helper": "
|
|
45
|
+
"@prisma/generator-helper": "^5.0.0",
|
|
20
46
|
"change-case": "^4.1.2",
|
|
21
47
|
"decimal.js": "^10.4.2",
|
|
22
48
|
"lower-case-first": "^2.0.2",
|
|
49
|
+
"semver": "^7.3.8",
|
|
23
50
|
"superjson": "^1.11.0",
|
|
24
51
|
"ts-morph": "^16.0.0",
|
|
25
52
|
"upper-case-first": "^2.0.2",
|
|
26
|
-
"@zenstackhq/sdk": "1.0.0
|
|
53
|
+
"@zenstackhq/sdk": "1.0.0",
|
|
54
|
+
"@zenstackhq/runtime": "1.0.0"
|
|
27
55
|
},
|
|
28
56
|
"devDependencies": {
|
|
29
|
-
"@tanstack/react-query": "
|
|
30
|
-
"@tanstack/svelte-query": "
|
|
57
|
+
"@tanstack/react-query": "4.29.7",
|
|
58
|
+
"@tanstack/svelte-query": "4.29.7",
|
|
31
59
|
"@types/jest": "^29.5.0",
|
|
32
|
-
"@types/
|
|
33
|
-
"@types/react": "
|
|
60
|
+
"@types/node": "^18.0.0",
|
|
61
|
+
"@types/react": "18.2.0",
|
|
62
|
+
"@types/semver": "^7.3.13",
|
|
34
63
|
"@types/tmp": "^0.2.3",
|
|
35
|
-
"@types/upper-case-first": "^1.1.2",
|
|
36
64
|
"copyfiles": "^2.4.1",
|
|
37
65
|
"jest": "^29.5.0",
|
|
38
|
-
"react": "
|
|
39
|
-
"react-dom": "^17.0.2 || ^18",
|
|
66
|
+
"react": "18.2.0",
|
|
40
67
|
"rimraf": "^3.0.2",
|
|
41
68
|
"swr": "^2.0.3",
|
|
42
69
|
"ts-jest": "^29.0.5",
|
|
43
70
|
"typescript": "^4.9.4",
|
|
44
|
-
"@zenstackhq/testtools": "1.0.0
|
|
71
|
+
"@zenstackhq/testtools": "1.0.0"
|
|
45
72
|
},
|
|
46
73
|
"scripts": {
|
|
47
74
|
"clean": "rimraf dist",
|
|
48
|
-
"build": "pnpm lint && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE
|
|
49
|
-
"watch": "tsc --watch",
|
|
75
|
+
"build": "pnpm lint && pnpm clean && tsc && tsup-node && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination '../../../../.build'",
|
|
76
|
+
"watch": "concurrently \"tsc --watch\" \"tsup-node --watch\"",
|
|
50
77
|
"lint": "eslint src --ext ts",
|
|
51
|
-
"test": "jest",
|
|
78
|
+
"test": "ZENSTACK_TEST=1 jest",
|
|
52
79
|
"publish-dev": "pnpm publish --tag dev"
|
|
53
80
|
}
|
|
54
81
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function signature for `fetch`.
|
|
3
|
+
*/
|
|
4
|
+
type FetchFn = (url: string, options?: RequestInit) => Promise<Response>;
|
|
5
|
+
/**
|
|
6
|
+
* Context type for configuring the hooks.
|
|
7
|
+
*/
|
|
8
|
+
type APIContext = {
|
|
9
|
+
/**
|
|
10
|
+
* The endpoint to use for the queries.
|
|
11
|
+
*/
|
|
12
|
+
endpoint: string;
|
|
13
|
+
/**
|
|
14
|
+
* A custom fetch function for sending the HTTP requests.
|
|
15
|
+
*/
|
|
16
|
+
fetch?: FetchFn;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { APIContext as A, FetchFn as F };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type Enumerable<T> = T | Array<T>;
|
|
2
|
+
type _TupleToUnion<T> = T extends (infer E)[] ? E : never;
|
|
3
|
+
type TupleToUnion<K extends readonly any[]> = _TupleToUnion<K>;
|
|
4
|
+
type MaybeTupleToUnion<T> = T extends any[] ? TupleToUnion<T> : T;
|
|
5
|
+
type PickEnumerable<T, K extends Enumerable<keyof T> | keyof T> = Pick<T, MaybeTupleToUnion<K>>;
|
|
6
|
+
type SelectAndInclude = {
|
|
7
|
+
select: any;
|
|
8
|
+
include: any;
|
|
9
|
+
};
|
|
10
|
+
type HasSelect = {
|
|
11
|
+
select: any;
|
|
12
|
+
};
|
|
13
|
+
type HasInclude = {
|
|
14
|
+
include: any;
|
|
15
|
+
};
|
|
16
|
+
type CheckSelect<T, S, U> = T extends SelectAndInclude ? 'Please either choose `select` or `include`' : T extends HasSelect ? U : T extends HasInclude ? U : S;
|
|
17
|
+
|
|
18
|
+
export { CheckSelect, Enumerable, MaybeTupleToUnion, PickEnumerable, TupleToUnion };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type Enumerable<T> = T | Array<T>;
|
|
2
|
+
type _TupleToUnion<T> = T extends (infer E)[] ? E : never;
|
|
3
|
+
type TupleToUnion<K extends readonly any[]> = _TupleToUnion<K>;
|
|
4
|
+
type MaybeTupleToUnion<T> = T extends any[] ? TupleToUnion<T> : T;
|
|
5
|
+
type PickEnumerable<T, K extends Enumerable<keyof T> | keyof T> = Pick<T, MaybeTupleToUnion<K>>;
|
|
6
|
+
type SelectAndInclude = {
|
|
7
|
+
select: any;
|
|
8
|
+
include: any;
|
|
9
|
+
};
|
|
10
|
+
type HasSelect = {
|
|
11
|
+
select: any;
|
|
12
|
+
};
|
|
13
|
+
type HasInclude = {
|
|
14
|
+
include: any;
|
|
15
|
+
};
|
|
16
|
+
type CheckSelect<T, S, U> = T extends SelectAndInclude ? 'Please either choose `select` or `include`' : T extends HasSelect ? U : T extends HasInclude ? U : S;
|
|
17
|
+
|
|
18
|
+
export { CheckSelect, Enumerable, MaybeTupleToUnion, PickEnumerable, TupleToUnion };
|
package/runtime/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/runtime/index.ts
|
|
17
|
+
var runtime_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/index.ts"],"sourcesContent":["export * from './prisma-types';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { UseQueryOptions, UseInfiniteQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { A as APIContext, F as FetchFn } from './common-52ab2c3a.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Context for configuring react hooks.
|
|
8
|
+
*/
|
|
9
|
+
declare const RequestHandlerContext: react.Context<APIContext>;
|
|
10
|
+
/**
|
|
11
|
+
* Context provider.
|
|
12
|
+
*/
|
|
13
|
+
declare const Provider: react.Provider<APIContext>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a react-query query.
|
|
16
|
+
*
|
|
17
|
+
* @param model The name of the model under query.
|
|
18
|
+
* @param url The request URL.
|
|
19
|
+
* @param args The request args object, URL-encoded and appended as "?q=" parameter
|
|
20
|
+
* @param options The react-query options object
|
|
21
|
+
* @returns useQuery hook
|
|
22
|
+
*/
|
|
23
|
+
declare function query<R>(model: string, url: string, args?: unknown, options?: UseQueryOptions<R>, fetch?: FetchFn): _tanstack_react_query.UseQueryResult<R, unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a react-query infinite query.
|
|
26
|
+
*
|
|
27
|
+
* @param model The name of the model under query.
|
|
28
|
+
* @param url The request URL.
|
|
29
|
+
* @param args The initial request args object, URL-encoded and appended as "?q=" parameter
|
|
30
|
+
* @param options The react-query infinite query options object
|
|
31
|
+
* @returns useInfiniteQuery hook
|
|
32
|
+
*/
|
|
33
|
+
declare function infiniteQuery<R>(model: string, url: string, args?: unknown, options?: UseInfiniteQueryOptions<R>, fetch?: FetchFn): _tanstack_react_query.UseInfiniteQueryResult<R, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a POST mutation with react-query.
|
|
36
|
+
*
|
|
37
|
+
* @param model The name of the model under mutation.
|
|
38
|
+
* @param url The request URL.
|
|
39
|
+
* @param options The react-query options.
|
|
40
|
+
* @param invalidateQueries Whether to invalidate queries after mutation.
|
|
41
|
+
* @returns useMutation hooks
|
|
42
|
+
*/
|
|
43
|
+
declare function postMutation<T, R = any, C extends boolean = boolean, Result = C extends true ? R | undefined : R>(model: string, url: string, options?: Omit<UseMutationOptions<Result, unknown, T>, 'mutationFn'>, fetch?: FetchFn, invalidateQueries?: boolean, checkReadBack?: C): _tanstack_react_query.UseMutationResult<Result, unknown, T, unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a PUT mutation with react-query.
|
|
46
|
+
*
|
|
47
|
+
* @param model The name of the model under mutation.
|
|
48
|
+
* @param url The request URL.
|
|
49
|
+
* @param options The react-query options.
|
|
50
|
+
* @param invalidateQueries Whether to invalidate queries after mutation.
|
|
51
|
+
* @returns useMutation hooks
|
|
52
|
+
*/
|
|
53
|
+
declare function putMutation<T, R = any, C extends boolean = boolean, Result = C extends true ? R | undefined : R>(model: string, url: string, options?: Omit<UseMutationOptions<Result, unknown, T>, 'mutationFn'>, fetch?: FetchFn, invalidateQueries?: boolean, checkReadBack?: C): _tanstack_react_query.UseMutationResult<Result, unknown, T, unknown>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a DELETE mutation with react-query.
|
|
56
|
+
*
|
|
57
|
+
* @param model The name of the model under mutation.
|
|
58
|
+
* @param url The request URL.
|
|
59
|
+
* @param options The react-query options.
|
|
60
|
+
* @param invalidateQueries Whether to invalidate queries after mutation.
|
|
61
|
+
* @returns useMutation hooks
|
|
62
|
+
*/
|
|
63
|
+
declare function deleteMutation<T, R = any, C extends boolean = boolean, Result = C extends true ? R | undefined : R>(model: string, url: string, options?: Omit<UseMutationOptions<Result, unknown, T>, 'mutationFn'>, fetch?: FetchFn, invalidateQueries?: boolean, checkReadBack?: C): _tanstack_react_query.UseMutationResult<Result, unknown, T, unknown>;
|
|
64
|
+
|
|
65
|
+
export { Provider, RequestHandlerContext, deleteMutation, infiniteQuery, postMutation, putMutation, query };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { UseQueryOptions, UseInfiniteQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { A as APIContext, F as FetchFn } from './common-52ab2c3a.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Context for configuring react hooks.
|
|
8
|
+
*/
|
|
9
|
+
declare const RequestHandlerContext: react.Context<APIContext>;
|
|
10
|
+
/**
|
|
11
|
+
* Context provider.
|
|
12
|
+
*/
|
|
13
|
+
declare const Provider: react.Provider<APIContext>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a react-query query.
|
|
16
|
+
*
|
|
17
|
+
* @param model The name of the model under query.
|
|
18
|
+
* @param url The request URL.
|
|
19
|
+
* @param args The request args object, URL-encoded and appended as "?q=" parameter
|
|
20
|
+
* @param options The react-query options object
|
|
21
|
+
* @returns useQuery hook
|
|
22
|
+
*/
|
|
23
|
+
declare function query<R>(model: string, url: string, args?: unknown, options?: UseQueryOptions<R>, fetch?: FetchFn): _tanstack_react_query.UseQueryResult<R, unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a react-query infinite query.
|
|
26
|
+
*
|
|
27
|
+
* @param model The name of the model under query.
|
|
28
|
+
* @param url The request URL.
|
|
29
|
+
* @param args The initial request args object, URL-encoded and appended as "?q=" parameter
|
|
30
|
+
* @param options The react-query infinite query options object
|
|
31
|
+
* @returns useInfiniteQuery hook
|
|
32
|
+
*/
|
|
33
|
+
declare function infiniteQuery<R>(model: string, url: string, args?: unknown, options?: UseInfiniteQueryOptions<R>, fetch?: FetchFn): _tanstack_react_query.UseInfiniteQueryResult<R, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a POST mutation with react-query.
|
|
36
|
+
*
|
|
37
|
+
* @param model The name of the model under mutation.
|
|
38
|
+
* @param url The request URL.
|
|
39
|
+
* @param options The react-query options.
|
|
40
|
+
* @param invalidateQueries Whether to invalidate queries after mutation.
|
|
41
|
+
* @returns useMutation hooks
|
|
42
|
+
*/
|
|
43
|
+
declare function postMutation<T, R = any, C extends boolean = boolean, Result = C extends true ? R | undefined : R>(model: string, url: string, options?: Omit<UseMutationOptions<Result, unknown, T>, 'mutationFn'>, fetch?: FetchFn, invalidateQueries?: boolean, checkReadBack?: C): _tanstack_react_query.UseMutationResult<Result, unknown, T, unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a PUT mutation with react-query.
|
|
46
|
+
*
|
|
47
|
+
* @param model The name of the model under mutation.
|
|
48
|
+
* @param url The request URL.
|
|
49
|
+
* @param options The react-query options.
|
|
50
|
+
* @param invalidateQueries Whether to invalidate queries after mutation.
|
|
51
|
+
* @returns useMutation hooks
|
|
52
|
+
*/
|
|
53
|
+
declare function putMutation<T, R = any, C extends boolean = boolean, Result = C extends true ? R | undefined : R>(model: string, url: string, options?: Omit<UseMutationOptions<Result, unknown, T>, 'mutationFn'>, fetch?: FetchFn, invalidateQueries?: boolean, checkReadBack?: C): _tanstack_react_query.UseMutationResult<Result, unknown, T, unknown>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a DELETE mutation with react-query.
|
|
56
|
+
*
|
|
57
|
+
* @param model The name of the model under mutation.
|
|
58
|
+
* @param url The request URL.
|
|
59
|
+
* @param options The react-query options.
|
|
60
|
+
* @param invalidateQueries Whether to invalidate queries after mutation.
|
|
61
|
+
* @returns useMutation hooks
|
|
62
|
+
*/
|
|
63
|
+
declare function deleteMutation<T, R = any, C extends boolean = boolean, Result = C extends true ? R | undefined : R>(model: string, url: string, options?: Omit<UseMutationOptions<Result, unknown, T>, 'mutationFn'>, fetch?: FetchFn, invalidateQueries?: boolean, checkReadBack?: C): _tanstack_react_query.UseMutationResult<Result, unknown, T, unknown>;
|
|
64
|
+
|
|
65
|
+
export { Provider, RequestHandlerContext, deleteMutation, infiniteQuery, postMutation, putMutation, query };
|