@zenstackhq/tanstack-query 1.0.0-beta.1 → 1.0.0-beta.10
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 +31 -39
- package/generator.js.map +1 -1
- package/package.json +30 -14
- package/runtime/common-52ab2c3a.d.ts +19 -0
- package/runtime/index.d.mts +7 -0
- package/runtime/index.d.ts +7 -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 +55 -0
- package/runtime/react.d.ts +55 -0
- package/runtime/react.js +216 -0
- package/runtime/react.js.map +1 -0
- package/runtime/react.mjs +193 -0
- package/runtime/react.mjs.map +1 -0
- package/runtime/svelte.d.mts +51 -0
- package/runtime/svelte.d.ts +51 -0
- package/runtime/svelte.js +208 -0
- package/runtime/svelte.js.map +1 -0
- package/runtime/svelte.mjs +186 -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 -148
- package/res/shared.ts +0 -36
- package/res/svelte/helper.ts +0 -140
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,7 +15,6 @@ 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"));
|
|
21
20
|
const ts_morph_1 = require("ts-morph");
|
|
@@ -33,8 +32,7 @@ function generate(model, options, dmmf) {
|
|
|
33
32
|
if (!supportedTargets.includes(target)) {
|
|
34
33
|
throw new sdk_1.PluginError(options.name, `Unsupported target "${target}", supported values: ${supportedTargets.join(', ')}`);
|
|
35
34
|
}
|
|
36
|
-
generateIndex(project, outDir, models);
|
|
37
|
-
generateHelper(target, project, outDir, options.useSuperJson === true);
|
|
35
|
+
generateIndex(project, outDir, models, target);
|
|
38
36
|
models.forEach((dataModel) => {
|
|
39
37
|
const mapping = dmmf.mappings.modelOperations.find((op) => op.model === dataModel.name);
|
|
40
38
|
if (!mapping) {
|
|
@@ -71,15 +69,18 @@ function generateQueryHook(target, sf, model, operation, returnArray, optionalIn
|
|
|
71
69
|
});
|
|
72
70
|
func.addStatements([
|
|
73
71
|
makeGetContext(target),
|
|
74
|
-
`return query<${returnType}>('${model}', \`\${endpoint}/${(0, lower_case_first_1.lowerCaseFirst)(model)}/${operation}\`, args, options);`,
|
|
72
|
+
`return query<${returnType}>('${model}', \`\${endpoint}/${(0, lower_case_first_1.lowerCaseFirst)(model)}/${operation}\`, args, options, fetch);`,
|
|
75
73
|
]);
|
|
76
74
|
}
|
|
77
|
-
function generateMutationHook(target, sf, model, operation, httpVerb, overrideReturnType) {
|
|
75
|
+
function generateMutationHook(target, sf, model, operation, httpVerb, checkReadBack, overrideReturnType) {
|
|
78
76
|
const capOperation = (0, upper_case_first_1.upperCaseFirst)(operation);
|
|
79
77
|
const argsType = `Prisma.${model}${capOperation}Args`;
|
|
80
78
|
const inputType = `Prisma.SelectSubset<T, ${argsType}>`;
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
let returnType = overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : `Prisma.CheckSelect<T, ${model}, Prisma.${model}GetPayload<T>>`;
|
|
80
|
+
if (checkReadBack) {
|
|
81
|
+
returnType = `(${returnType} | undefined )`;
|
|
82
|
+
}
|
|
83
|
+
const nonGenericOptionsType = `Omit<${makeMutationOptions(target, checkReadBack ? `(${overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : model} | undefined)` : overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : model, argsType)}, 'mutationFn'>`;
|
|
83
84
|
const optionsType = `Omit<${makeMutationOptions(target, returnType, inputType)}, 'mutationFn'>`;
|
|
84
85
|
const func = sf.addFunction({
|
|
85
86
|
name: `use${capOperation}${model}`,
|
|
@@ -104,7 +105,7 @@ function generateMutationHook(target, sf, model, operation, httpVerb, overrideRe
|
|
|
104
105
|
{
|
|
105
106
|
name: `_mutation`,
|
|
106
107
|
initializer: `
|
|
107
|
-
${httpVerb}Mutation<${argsType}, ${overrideReturnType !== null && overrideReturnType !== void 0 ? overrideReturnType : model}>('${model}', \`\${endpoint}/${(0, lower_case_first_1.lowerCaseFirst)(model)}/${operation}\`, options, invalidateQueries)
|
|
108
|
+
${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
109
|
`,
|
|
109
110
|
},
|
|
110
111
|
],
|
|
@@ -167,20 +168,21 @@ function generateModelHooks(target, project, outDir, model, mapping) {
|
|
|
167
168
|
const fileName = (0, change_case_1.paramCase)(model.name);
|
|
168
169
|
const sf = project.createSourceFile(path_1.default.join(outDir, `${fileName}.ts`), undefined, { overwrite: true });
|
|
169
170
|
sf.addStatements('/* eslint-disable */');
|
|
171
|
+
const prismaImport = (0, sdk_1.getPrismaClientImportSpec)(model.$container, outDir);
|
|
170
172
|
sf.addImportDeclaration({
|
|
171
173
|
namedImports: ['Prisma', model.name],
|
|
172
174
|
isTypeOnly: true,
|
|
173
|
-
moduleSpecifier:
|
|
175
|
+
moduleSpecifier: prismaImport,
|
|
174
176
|
});
|
|
175
177
|
sf.addStatements(makeBaseImports(target));
|
|
176
178
|
// create is somehow named "createOne" in the DMMF
|
|
177
179
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
178
180
|
if (mapping.create || mapping.createOne) {
|
|
179
|
-
generateMutationHook(target, sf, model.name, 'create', 'post');
|
|
181
|
+
generateMutationHook(target, sf, model.name, 'create', 'post', true);
|
|
180
182
|
}
|
|
181
183
|
// createMany
|
|
182
184
|
if (mapping.createMany) {
|
|
183
|
-
generateMutationHook(target, sf, model.name, 'createMany', 'post', 'Prisma.BatchPayload');
|
|
185
|
+
generateMutationHook(target, sf, model.name, 'createMany', 'post', false, 'Prisma.BatchPayload');
|
|
184
186
|
}
|
|
185
187
|
// findMany
|
|
186
188
|
if (mapping.findMany) {
|
|
@@ -198,27 +200,27 @@ function generateModelHooks(target, project, outDir, model, mapping) {
|
|
|
198
200
|
// update is somehow named "updateOne" in the DMMF
|
|
199
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
202
|
if (mapping.update || mapping.updateOne) {
|
|
201
|
-
generateMutationHook(target, sf, model.name, 'update', 'put');
|
|
203
|
+
generateMutationHook(target, sf, model.name, 'update', 'put', true);
|
|
202
204
|
}
|
|
203
205
|
// updateMany
|
|
204
206
|
if (mapping.updateMany) {
|
|
205
|
-
generateMutationHook(target, sf, model.name, 'updateMany', 'put', 'Prisma.BatchPayload');
|
|
207
|
+
generateMutationHook(target, sf, model.name, 'updateMany', 'put', false, 'Prisma.BatchPayload');
|
|
206
208
|
}
|
|
207
209
|
// upsert
|
|
208
210
|
// upsert is somehow named "upsertOne" in the DMMF
|
|
209
211
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
210
212
|
if (mapping.upsert || mapping.upsertOne) {
|
|
211
|
-
generateMutationHook(target, sf, model.name, 'upsert', 'post');
|
|
213
|
+
generateMutationHook(target, sf, model.name, 'upsert', 'post', true);
|
|
212
214
|
}
|
|
213
215
|
// del
|
|
214
216
|
// delete is somehow named "deleteOne" in the DMMF
|
|
215
217
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
218
|
if (mapping.delete || mapping.deleteOne) {
|
|
217
|
-
generateMutationHook(target, sf, model.name, 'delete', 'delete');
|
|
219
|
+
generateMutationHook(target, sf, model.name, 'delete', 'delete', true);
|
|
218
220
|
}
|
|
219
221
|
// deleteMany
|
|
220
222
|
if (mapping.deleteMany) {
|
|
221
|
-
generateMutationHook(target, sf, model.name, 'deleteMany', 'delete', 'Prisma.BatchPayload');
|
|
223
|
+
generateMutationHook(target, sf, model.name, 'deleteMany', 'delete', false, 'Prisma.BatchPayload');
|
|
222
224
|
}
|
|
223
225
|
// aggregate
|
|
224
226
|
if (mapping.aggregate) {
|
|
@@ -231,7 +233,7 @@ function generateModelHooks(target, project, outDir, model, mapping) {
|
|
|
231
233
|
`HasSelectOrTake extends Prisma.Or<Prisma.Extends<'skip', Prisma.Keys<T>>, Prisma.Extends<'take', Prisma.Keys<T>>>`,
|
|
232
234
|
`OrderByArg extends Prisma.True extends HasSelectOrTake ? { orderBy: Prisma.${model.name}GroupByArgs['orderBy'] }: { orderBy?: Prisma.${model.name}GroupByArgs['orderBy'] },`,
|
|
233
235
|
`OrderFields extends Prisma.ExcludeUnderscoreKeys<Prisma.Keys<Prisma.MaybeTupleToUnion<T['orderBy']>>>`,
|
|
234
|
-
`ByFields extends Prisma.
|
|
236
|
+
`ByFields extends Prisma.MaybeTupleToUnion<T['by']>`,
|
|
235
237
|
`ByValid extends Prisma.Has<ByFields, OrderFields>`,
|
|
236
238
|
`HavingFields extends Prisma.GetHavingFields<T['having']>`,
|
|
237
239
|
`HavingValid extends Prisma.Has<ByFields, HavingFields>`,
|
|
@@ -280,7 +282,7 @@ function generateModelHooks(target, project, outDir, model, mapping) {
|
|
|
280
282
|
}[OrderFields]`,
|
|
281
283
|
];
|
|
282
284
|
const returnType = `{} extends InputErrors ?
|
|
283
|
-
Array<
|
|
285
|
+
Array<PickEnumerable<Prisma.${model.name}GroupByOutputType, T['by']> &
|
|
284
286
|
{
|
|
285
287
|
[P in ((keyof T) & (keyof Prisma.${model.name}GroupByOutputType))]: P extends '_count'
|
|
286
288
|
? T[P] extends boolean
|
|
@@ -296,49 +298,39 @@ function generateModelHooks(target, project, outDir, model, mapping) {
|
|
|
296
298
|
generateQueryHook(target, sf, model.name, 'count', false, true, `T extends { select: any; } ? T['select'] extends true ? number : Prisma.GetScalarType<T['select'], Prisma.${model.name}CountAggregateOutputType> : number`);
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
|
-
function generateIndex(project, outDir, models) {
|
|
301
|
+
function generateIndex(project, outDir, models, target) {
|
|
300
302
|
const sf = project.createSourceFile(path_1.default.join(outDir, 'index.ts'), undefined, { overwrite: true });
|
|
301
303
|
sf.addStatements(models.map((d) => `export * from './${(0, change_case_1.paramCase)(d.name)}';`));
|
|
302
|
-
sf.addStatements(`export * from './_helper';`);
|
|
303
|
-
}
|
|
304
|
-
function generateHelper(target, project, outDir, useSuperJson) {
|
|
305
|
-
let srcFile;
|
|
306
304
|
switch (target) {
|
|
307
305
|
case 'react':
|
|
308
|
-
|
|
306
|
+
sf.addStatements(`export { Provider } from '@zenstackhq/tanstack-query/runtime/react';`);
|
|
309
307
|
break;
|
|
310
308
|
case 'svelte':
|
|
311
|
-
|
|
309
|
+
sf.addStatements(`export { SvelteQueryContextKey } from '@zenstackhq/tanstack-query/runtime/svelte';`);
|
|
312
310
|
break;
|
|
313
|
-
default:
|
|
314
|
-
throw new sdk_1.PluginError(_1.name, `Unsupported target: ${target}`);
|
|
315
311
|
}
|
|
316
|
-
// merge content of `shared.ts`, `helper.ts` and `marshal-?.ts`
|
|
317
|
-
const sharedContent = fs_1.default.readFileSync(path_1.default.join(__dirname, './res/shared.ts'), 'utf-8');
|
|
318
|
-
const helperContent = fs_1.default.readFileSync(srcFile, 'utf-8');
|
|
319
|
-
const marshalContent = fs_1.default.readFileSync(path_1.default.join(__dirname, useSuperJson ? './res/marshal-superjson.ts' : './res/marshal-json.ts'), 'utf-8');
|
|
320
|
-
project.createSourceFile(path_1.default.join(outDir, '_helper.ts'), `${sharedContent}\n${helperContent}\n${marshalContent}`, {
|
|
321
|
-
overwrite: true,
|
|
322
|
-
});
|
|
323
312
|
}
|
|
324
313
|
function makeGetContext(target) {
|
|
325
314
|
switch (target) {
|
|
326
315
|
case 'react':
|
|
327
|
-
return 'const { endpoint } = useContext(RequestHandlerContext);';
|
|
316
|
+
return 'const { endpoint, fetch } = useContext(RequestHandlerContext);';
|
|
328
317
|
case 'svelte':
|
|
329
|
-
return `const { endpoint } = getContext<RequestHandlerContext>(SvelteQueryContextKey);`;
|
|
318
|
+
return `const { endpoint, fetch } = getContext<RequestHandlerContext>(SvelteQueryContextKey);`;
|
|
330
319
|
default:
|
|
331
320
|
throw new sdk_1.PluginError(_1.name, `Unsupported target "${target}"`);
|
|
332
321
|
}
|
|
333
322
|
}
|
|
334
323
|
function makeBaseImports(target) {
|
|
335
|
-
const shared = [
|
|
324
|
+
const shared = [
|
|
325
|
+
`import { query, postMutation, putMutation, deleteMutation } from '@zenstackhq/tanstack-query/runtime/${target}';`,
|
|
326
|
+
`import type { PickEnumerable } from '@zenstackhq/tanstack-query/runtime';`,
|
|
327
|
+
];
|
|
336
328
|
switch (target) {
|
|
337
329
|
case 'react':
|
|
338
330
|
return [
|
|
339
331
|
`import { useContext } from 'react';`,
|
|
340
332
|
`import type { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';`,
|
|
341
|
-
`import { RequestHandlerContext } from '
|
|
333
|
+
`import { RequestHandlerContext } from '@zenstackhq/tanstack-query/runtime/${target}';`,
|
|
342
334
|
...shared,
|
|
343
335
|
];
|
|
344
336
|
case 'svelte':
|
|
@@ -346,7 +338,7 @@ function makeBaseImports(target) {
|
|
|
346
338
|
`import { getContext } from 'svelte';`,
|
|
347
339
|
`import { derived } from 'svelte/store';`,
|
|
348
340
|
`import type { MutationOptions, QueryOptions } from '@tanstack/svelte-query';`,
|
|
349
|
-
`import { SvelteQueryContextKey, type RequestHandlerContext } from '
|
|
341
|
+
`import { SvelteQueryContextKey, type RequestHandlerContext } from '@zenstackhq/tanstack-query/runtime/${target}';`,
|
|
350
342
|
...shared,
|
|
351
343
|
];
|
|
352
344
|
default:
|
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,yCASyB;AAEzB,6CAAwC;AACxC,uDAAkD;AAClD,gDAAwB;AACxB,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,CACjB,OAAO,CAAC,IAAI,EACZ,uBAAuB,MAAM,wBAAwB,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrF,CAAC;SACL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ZenStack plugin for generating tanstack-query hooks",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.10",
|
|
5
5
|
"description": "ZenStack plugin for generating tanstack-query hooks",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"default": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"./runtime/react": {
|
|
12
|
+
"import": "./runtime/react.mjs",
|
|
13
|
+
"require": "./runtime/react.js",
|
|
14
|
+
"default": "./runtime/react.js",
|
|
15
|
+
"types": "./runtime/react.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./runtime/svelte": {
|
|
18
|
+
"import": "./runtime/svelte.mjs",
|
|
19
|
+
"require": "./runtime/svelte.js",
|
|
20
|
+
"default": "./runtime/svelte.js",
|
|
21
|
+
"types": "./runtime/svelte.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
7
24
|
"repository": {
|
|
8
25
|
"type": "git",
|
|
9
26
|
"url": "https://github.com/zenstackhq/zenstack"
|
|
@@ -16,39 +33,38 @@
|
|
|
16
33
|
"author": "ZenStack Team",
|
|
17
34
|
"license": "MIT",
|
|
18
35
|
"dependencies": {
|
|
19
|
-
"@prisma/generator-helper": "^
|
|
36
|
+
"@prisma/generator-helper": "^5.0.0",
|
|
20
37
|
"change-case": "^4.1.2",
|
|
21
38
|
"decimal.js": "^10.4.2",
|
|
22
39
|
"lower-case-first": "^2.0.2",
|
|
23
40
|
"superjson": "^1.11.0",
|
|
24
41
|
"ts-morph": "^16.0.0",
|
|
25
42
|
"upper-case-first": "^2.0.2",
|
|
26
|
-
"@zenstackhq/sdk": "1.0.0-beta.
|
|
43
|
+
"@zenstackhq/sdk": "1.0.0-beta.10",
|
|
44
|
+
"@zenstackhq/runtime": "1.0.0-beta.10"
|
|
27
45
|
},
|
|
28
46
|
"devDependencies": {
|
|
29
|
-
"@tanstack/react-query": "
|
|
30
|
-
"@tanstack/svelte-query": "
|
|
47
|
+
"@tanstack/react-query": "4.29.7",
|
|
48
|
+
"@tanstack/svelte-query": "4.29.7",
|
|
31
49
|
"@types/jest": "^29.5.0",
|
|
32
|
-
"@types/
|
|
33
|
-
"@types/react": "
|
|
50
|
+
"@types/node": "^18.0.0",
|
|
51
|
+
"@types/react": "18.2.0",
|
|
34
52
|
"@types/tmp": "^0.2.3",
|
|
35
|
-
"@types/upper-case-first": "^1.1.2",
|
|
36
53
|
"copyfiles": "^2.4.1",
|
|
37
54
|
"jest": "^29.5.0",
|
|
38
|
-
"react": "
|
|
39
|
-
"react-dom": "^17.0.2 || ^18",
|
|
55
|
+
"react": "18.2.0",
|
|
40
56
|
"rimraf": "^3.0.2",
|
|
41
57
|
"swr": "^2.0.3",
|
|
42
58
|
"ts-jest": "^29.0.5",
|
|
43
59
|
"typescript": "^4.9.4",
|
|
44
|
-
"@zenstackhq/testtools": "1.0.0-beta.
|
|
60
|
+
"@zenstackhq/testtools": "1.0.0-beta.10"
|
|
45
61
|
},
|
|
46
62
|
"scripts": {
|
|
47
63
|
"clean": "rimraf dist",
|
|
48
|
-
"build": "pnpm lint && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE '
|
|
49
|
-
"watch": "tsc --watch",
|
|
64
|
+
"build": "pnpm lint && pnpm clean && tsc && tsup-node && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination '../../../../.build'",
|
|
65
|
+
"watch": "concurrently \"tsc --watch\" \"tsup-node --watch\"",
|
|
50
66
|
"lint": "eslint src --ext ts",
|
|
51
|
-
"test": "jest",
|
|
67
|
+
"test": "ZENSTACK_TEST=1 jest",
|
|
52
68
|
"publish-dev": "pnpm publish --tag dev"
|
|
53
69
|
}
|
|
54
70
|
}
|
|
@@ -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,7 @@
|
|
|
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
|
+
|
|
7
|
+
export { Enumerable, MaybeTupleToUnion, PickEnumerable, TupleToUnion };
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
|
|
7
|
+
export { 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,55 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { UseQueryOptions, 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 POST mutation with react-query.
|
|
26
|
+
*
|
|
27
|
+
* @param model The name of the model under mutation.
|
|
28
|
+
* @param url The request URL.
|
|
29
|
+
* @param options The react-query options.
|
|
30
|
+
* @param invalidateQueries Whether to invalidate queries after mutation.
|
|
31
|
+
* @returns useMutation hooks
|
|
32
|
+
*/
|
|
33
|
+
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>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a PUT 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 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>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a DELETE 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 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>;
|
|
54
|
+
|
|
55
|
+
export { Provider, RequestHandlerContext, deleteMutation, postMutation, putMutation, query };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { UseQueryOptions, 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 POST mutation with react-query.
|
|
26
|
+
*
|
|
27
|
+
* @param model The name of the model under mutation.
|
|
28
|
+
* @param url The request URL.
|
|
29
|
+
* @param options The react-query options.
|
|
30
|
+
* @param invalidateQueries Whether to invalidate queries after mutation.
|
|
31
|
+
* @returns useMutation hooks
|
|
32
|
+
*/
|
|
33
|
+
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>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a PUT 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 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>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a DELETE 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 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>;
|
|
54
|
+
|
|
55
|
+
export { Provider, RequestHandlerContext, deleteMutation, postMutation, putMutation, query };
|