@zenstackhq/tanstack-query 2.21.0 → 3.0.0-beta.17

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.
Files changed (93) hide show
  1. package/.turbo/turbo-build.log +31 -0
  2. package/LICENSE +1 -1
  3. package/dist/react.cjs +1238 -0
  4. package/dist/react.cjs.map +1 -0
  5. package/dist/react.d.cts +696 -0
  6. package/dist/react.d.ts +696 -0
  7. package/dist/react.js +1195 -0
  8. package/dist/react.js.map +1 -0
  9. package/eslint.config.js +4 -0
  10. package/package.json +56 -109
  11. package/scripts/generate.ts +27 -0
  12. package/src/react.ts +531 -0
  13. package/src/utils/common.ts +457 -0
  14. package/src/utils/mutator.ts +441 -0
  15. package/src/utils/nested-read-visitor.ts +61 -0
  16. package/src/utils/nested-write-visitor.ts +359 -0
  17. package/src/utils/query-analysis.ts +116 -0
  18. package/src/utils/serialization.ts +39 -0
  19. package/src/utils/types.ts +19 -0
  20. package/test/react-query.test.tsx +1787 -0
  21. package/test/schemas/basic/input.ts +70 -0
  22. package/test/schemas/basic/models.ts +12 -0
  23. package/test/schemas/basic/schema-lite.ts +124 -0
  24. package/test/schemas/basic/schema.zmodel +25 -0
  25. package/tsconfig.json +7 -0
  26. package/tsconfig.test.json +8 -0
  27. package/tsup.config.ts +13 -0
  28. package/vitest.config.ts +11 -0
  29. package/README.md +0 -5
  30. package/generator.d.ts +0 -6
  31. package/generator.js +0 -578
  32. package/generator.js.map +0 -1
  33. package/index.d.ts +0 -4
  34. package/index.js +0 -22
  35. package/index.js.map +0 -1
  36. package/runtime/common-CXlL7vTW.d.mts +0 -121
  37. package/runtime/common-CXlL7vTW.d.ts +0 -121
  38. package/runtime/index.d.mts +0 -20
  39. package/runtime/index.d.ts +0 -20
  40. package/runtime/index.js +0 -44
  41. package/runtime/index.js.map +0 -1
  42. package/runtime/index.mjs +0 -21
  43. package/runtime/index.mjs.map +0 -1
  44. package/runtime/react.d.mts +0 -322
  45. package/runtime/react.d.ts +0 -322
  46. package/runtime/react.js +0 -408
  47. package/runtime/react.js.map +0 -1
  48. package/runtime/react.mjs +0 -380
  49. package/runtime/react.mjs.map +0 -1
  50. package/runtime/svelte.d.mts +0 -322
  51. package/runtime/svelte.d.ts +0 -322
  52. package/runtime/svelte.js +0 -407
  53. package/runtime/svelte.js.map +0 -1
  54. package/runtime/svelte.mjs +0 -379
  55. package/runtime/svelte.mjs.map +0 -1
  56. package/runtime/vue.d.mts +0 -330
  57. package/runtime/vue.d.ts +0 -330
  58. package/runtime/vue.js +0 -418
  59. package/runtime/vue.js.map +0 -1
  60. package/runtime/vue.mjs +0 -390
  61. package/runtime/vue.mjs.map +0 -1
  62. package/runtime-v5/angular.d.mts +0 -59
  63. package/runtime-v5/angular.d.ts +0 -59
  64. package/runtime-v5/angular.js +0 -425
  65. package/runtime-v5/angular.js.map +0 -1
  66. package/runtime-v5/angular.mjs +0 -397
  67. package/runtime-v5/angular.mjs.map +0 -1
  68. package/runtime-v5/common-CXlL7vTW.d.mts +0 -121
  69. package/runtime-v5/common-CXlL7vTW.d.ts +0 -121
  70. package/runtime-v5/index.d.mts +0 -20
  71. package/runtime-v5/index.d.ts +0 -20
  72. package/runtime-v5/index.js +0 -44
  73. package/runtime-v5/index.js.map +0 -1
  74. package/runtime-v5/index.mjs +0 -21
  75. package/runtime-v5/index.mjs.map +0 -1
  76. package/runtime-v5/react.d.mts +0 -474
  77. package/runtime-v5/react.d.ts +0 -474
  78. package/runtime-v5/react.js +0 -440
  79. package/runtime-v5/react.js.map +0 -1
  80. package/runtime-v5/react.mjs +0 -412
  81. package/runtime-v5/react.mjs.map +0 -1
  82. package/runtime-v5/svelte.d.mts +0 -386
  83. package/runtime-v5/svelte.d.ts +0 -386
  84. package/runtime-v5/svelte.js +0 -436
  85. package/runtime-v5/svelte.js.map +0 -1
  86. package/runtime-v5/svelte.mjs +0 -408
  87. package/runtime-v5/svelte.mjs.map +0 -1
  88. package/runtime-v5/vue.d.mts +0 -330
  89. package/runtime-v5/vue.d.ts +0 -330
  90. package/runtime-v5/vue.js +0 -420
  91. package/runtime-v5/vue.js.map +0 -1
  92. package/runtime-v5/vue.mjs +0 -392
  93. package/runtime-v5/vue.mjs.map +0 -1
@@ -0,0 +1,70 @@
1
+ //////////////////////////////////////////////////////////////////////////////////////////////
2
+ // DO NOT MODIFY THIS FILE //
3
+ // This file is automatically generated by ZenStack CLI and should not be manually updated. //
4
+ //////////////////////////////////////////////////////////////////////////////////////////////
5
+
6
+ /* eslint-disable */
7
+
8
+ import { type SchemaType as $Schema } from "./schema-lite";
9
+ import type { FindManyArgs as $FindManyArgs, FindUniqueArgs as $FindUniqueArgs, FindFirstArgs as $FindFirstArgs, CreateArgs as $CreateArgs, CreateManyArgs as $CreateManyArgs, CreateManyAndReturnArgs as $CreateManyAndReturnArgs, UpdateArgs as $UpdateArgs, UpdateManyArgs as $UpdateManyArgs, UpdateManyAndReturnArgs as $UpdateManyAndReturnArgs, UpsertArgs as $UpsertArgs, DeleteArgs as $DeleteArgs, DeleteManyArgs as $DeleteManyArgs, CountArgs as $CountArgs, AggregateArgs as $AggregateArgs, GroupByArgs as $GroupByArgs, WhereInput as $WhereInput, SelectInput as $SelectInput, IncludeInput as $IncludeInput, OmitInput as $OmitInput } from "@zenstackhq/orm";
10
+ import type { SimplifiedModelResult as $SimplifiedModelResult, SelectIncludeOmit as $SelectIncludeOmit } from "@zenstackhq/orm";
11
+ export type UserFindManyArgs = $FindManyArgs<$Schema, "User">;
12
+ export type UserFindUniqueArgs = $FindUniqueArgs<$Schema, "User">;
13
+ export type UserFindFirstArgs = $FindFirstArgs<$Schema, "User">;
14
+ export type UserCreateArgs = $CreateArgs<$Schema, "User">;
15
+ export type UserCreateManyArgs = $CreateManyArgs<$Schema, "User">;
16
+ export type UserCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "User">;
17
+ export type UserUpdateArgs = $UpdateArgs<$Schema, "User">;
18
+ export type UserUpdateManyArgs = $UpdateManyArgs<$Schema, "User">;
19
+ export type UserUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "User">;
20
+ export type UserUpsertArgs = $UpsertArgs<$Schema, "User">;
21
+ export type UserDeleteArgs = $DeleteArgs<$Schema, "User">;
22
+ export type UserDeleteManyArgs = $DeleteManyArgs<$Schema, "User">;
23
+ export type UserCountArgs = $CountArgs<$Schema, "User">;
24
+ export type UserAggregateArgs = $AggregateArgs<$Schema, "User">;
25
+ export type UserGroupByArgs = $GroupByArgs<$Schema, "User">;
26
+ export type UserWhereInput = $WhereInput<$Schema, "User">;
27
+ export type UserSelect = $SelectInput<$Schema, "User">;
28
+ export type UserInclude = $IncludeInput<$Schema, "User">;
29
+ export type UserOmit = $OmitInput<$Schema, "User">;
30
+ export type UserGetPayload<Args extends $SelectIncludeOmit<$Schema, "User", true>> = $SimplifiedModelResult<$Schema, "User", Args>;
31
+ export type PostFindManyArgs = $FindManyArgs<$Schema, "Post">;
32
+ export type PostFindUniqueArgs = $FindUniqueArgs<$Schema, "Post">;
33
+ export type PostFindFirstArgs = $FindFirstArgs<$Schema, "Post">;
34
+ export type PostCreateArgs = $CreateArgs<$Schema, "Post">;
35
+ export type PostCreateManyArgs = $CreateManyArgs<$Schema, "Post">;
36
+ export type PostCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Post">;
37
+ export type PostUpdateArgs = $UpdateArgs<$Schema, "Post">;
38
+ export type PostUpdateManyArgs = $UpdateManyArgs<$Schema, "Post">;
39
+ export type PostUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Post">;
40
+ export type PostUpsertArgs = $UpsertArgs<$Schema, "Post">;
41
+ export type PostDeleteArgs = $DeleteArgs<$Schema, "Post">;
42
+ export type PostDeleteManyArgs = $DeleteManyArgs<$Schema, "Post">;
43
+ export type PostCountArgs = $CountArgs<$Schema, "Post">;
44
+ export type PostAggregateArgs = $AggregateArgs<$Schema, "Post">;
45
+ export type PostGroupByArgs = $GroupByArgs<$Schema, "Post">;
46
+ export type PostWhereInput = $WhereInput<$Schema, "Post">;
47
+ export type PostSelect = $SelectInput<$Schema, "Post">;
48
+ export type PostInclude = $IncludeInput<$Schema, "Post">;
49
+ export type PostOmit = $OmitInput<$Schema, "Post">;
50
+ export type PostGetPayload<Args extends $SelectIncludeOmit<$Schema, "Post", true>> = $SimplifiedModelResult<$Schema, "Post", Args>;
51
+ export type CategoryFindManyArgs = $FindManyArgs<$Schema, "Category">;
52
+ export type CategoryFindUniqueArgs = $FindUniqueArgs<$Schema, "Category">;
53
+ export type CategoryFindFirstArgs = $FindFirstArgs<$Schema, "Category">;
54
+ export type CategoryCreateArgs = $CreateArgs<$Schema, "Category">;
55
+ export type CategoryCreateManyArgs = $CreateManyArgs<$Schema, "Category">;
56
+ export type CategoryCreateManyAndReturnArgs = $CreateManyAndReturnArgs<$Schema, "Category">;
57
+ export type CategoryUpdateArgs = $UpdateArgs<$Schema, "Category">;
58
+ export type CategoryUpdateManyArgs = $UpdateManyArgs<$Schema, "Category">;
59
+ export type CategoryUpdateManyAndReturnArgs = $UpdateManyAndReturnArgs<$Schema, "Category">;
60
+ export type CategoryUpsertArgs = $UpsertArgs<$Schema, "Category">;
61
+ export type CategoryDeleteArgs = $DeleteArgs<$Schema, "Category">;
62
+ export type CategoryDeleteManyArgs = $DeleteManyArgs<$Schema, "Category">;
63
+ export type CategoryCountArgs = $CountArgs<$Schema, "Category">;
64
+ export type CategoryAggregateArgs = $AggregateArgs<$Schema, "Category">;
65
+ export type CategoryGroupByArgs = $GroupByArgs<$Schema, "Category">;
66
+ export type CategoryWhereInput = $WhereInput<$Schema, "Category">;
67
+ export type CategorySelect = $SelectInput<$Schema, "Category">;
68
+ export type CategoryInclude = $IncludeInput<$Schema, "Category">;
69
+ export type CategoryOmit = $OmitInput<$Schema, "Category">;
70
+ export type CategoryGetPayload<Args extends $SelectIncludeOmit<$Schema, "Category", true>> = $SimplifiedModelResult<$Schema, "Category", Args>;
@@ -0,0 +1,12 @@
1
+ //////////////////////////////////////////////////////////////////////////////////////////////
2
+ // DO NOT MODIFY THIS FILE //
3
+ // This file is automatically generated by ZenStack CLI and should not be manually updated. //
4
+ //////////////////////////////////////////////////////////////////////////////////////////////
5
+
6
+ /* eslint-disable */
7
+
8
+ import { type SchemaType as $Schema } from "./schema-lite";
9
+ import { type ModelResult as $ModelResult } from "@zenstackhq/orm";
10
+ export type User = $ModelResult<$Schema, "User">;
11
+ export type Post = $ModelResult<$Schema, "Post">;
12
+ export type Category = $ModelResult<$Schema, "Category">;
@@ -0,0 +1,124 @@
1
+ //////////////////////////////////////////////////////////////////////////////////////////////
2
+ // DO NOT MODIFY THIS FILE //
3
+ // This file is automatically generated by ZenStack CLI and should not be manually updated. //
4
+ //////////////////////////////////////////////////////////////////////////////////////////////
5
+
6
+ /* eslint-disable */
7
+
8
+ import { type SchemaDef, ExpressionUtils } from "@zenstackhq/orm/schema";
9
+ export const schema = {
10
+ provider: {
11
+ type: "sqlite"
12
+ },
13
+ models: {
14
+ User: {
15
+ name: "User",
16
+ fields: {
17
+ id: {
18
+ name: "id",
19
+ type: "String",
20
+ id: true,
21
+ default: ExpressionUtils.call("cuid")
22
+ },
23
+ email: {
24
+ name: "email",
25
+ type: "String",
26
+ unique: true
27
+ },
28
+ name: {
29
+ name: "name",
30
+ type: "String",
31
+ optional: true
32
+ },
33
+ posts: {
34
+ name: "posts",
35
+ type: "Post",
36
+ array: true,
37
+ relation: { opposite: "owner" }
38
+ }
39
+ },
40
+ idFields: ["id"],
41
+ uniqueFields: {
42
+ id: { type: "String" },
43
+ email: { type: "String" }
44
+ }
45
+ },
46
+ Post: {
47
+ name: "Post",
48
+ fields: {
49
+ id: {
50
+ name: "id",
51
+ type: "String",
52
+ id: true,
53
+ default: ExpressionUtils.call("cuid")
54
+ },
55
+ title: {
56
+ name: "title",
57
+ type: "String"
58
+ },
59
+ owner: {
60
+ name: "owner",
61
+ type: "User",
62
+ optional: true,
63
+ relation: { opposite: "posts", fields: ["ownerId"], references: ["id"] }
64
+ },
65
+ ownerId: {
66
+ name: "ownerId",
67
+ type: "String",
68
+ optional: true,
69
+ foreignKeyFor: [
70
+ "owner"
71
+ ]
72
+ },
73
+ category: {
74
+ name: "category",
75
+ type: "Category",
76
+ optional: true,
77
+ relation: { opposite: "posts", fields: ["categoryId"], references: ["id"] }
78
+ },
79
+ categoryId: {
80
+ name: "categoryId",
81
+ type: "String",
82
+ optional: true,
83
+ foreignKeyFor: [
84
+ "category"
85
+ ]
86
+ }
87
+ },
88
+ idFields: ["id"],
89
+ uniqueFields: {
90
+ id: { type: "String" }
91
+ }
92
+ },
93
+ Category: {
94
+ name: "Category",
95
+ fields: {
96
+ id: {
97
+ name: "id",
98
+ type: "String",
99
+ id: true,
100
+ default: ExpressionUtils.call("cuid")
101
+ },
102
+ name: {
103
+ name: "name",
104
+ type: "String",
105
+ unique: true
106
+ },
107
+ posts: {
108
+ name: "posts",
109
+ type: "Post",
110
+ array: true,
111
+ relation: { opposite: "category" }
112
+ }
113
+ },
114
+ idFields: ["id"],
115
+ uniqueFields: {
116
+ id: { type: "String" },
117
+ name: { type: "String" }
118
+ }
119
+ }
120
+ },
121
+ authType: "User",
122
+ plugins: {}
123
+ } as const satisfies SchemaDef;
124
+ export type SchemaType = typeof schema;
@@ -0,0 +1,25 @@
1
+ datasource db {
2
+ provider = 'sqlite'
3
+ }
4
+
5
+ model User {
6
+ id String @id @default(cuid())
7
+ email String @unique
8
+ name String?
9
+ posts Post[]
10
+ }
11
+
12
+ model Post {
13
+ id String @id @default(cuid())
14
+ title String
15
+ owner User? @relation(fields: [ownerId], references: [id])
16
+ ownerId String?
17
+ category Category? @relation(fields: [categoryId], references: [id])
18
+ categoryId String?
19
+ }
20
+
21
+ model Category {
22
+ id String @id @default(cuid())
23
+ name String @unique
24
+ posts Post[]
25
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@zenstackhq/typescript-config/base.json",
3
+ "include": ["src/**/*.ts"],
4
+ "compilerOptions": {
5
+ "lib": ["ESNext"]
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "@zenstackhq/typescript-config/base.json",
3
+ "include": ["src/**/*.ts", "test/**/*.ts", "test/**/*.tsx"],
4
+ "compilerOptions": {
5
+ "lib": ["ESNext"],
6
+ "jsx": "react"
7
+ }
8
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ react: 'src/react.ts',
6
+ },
7
+ outDir: 'dist',
8
+ splitting: false,
9
+ sourcemap: true,
10
+ clean: true,
11
+ dts: true,
12
+ format: ['cjs', 'esm'],
13
+ });
@@ -0,0 +1,11 @@
1
+ import base from '@zenstackhq/vitest-config/base';
2
+ import { defineConfig, mergeConfig } from 'vitest/config';
3
+
4
+ export default mergeConfig(
5
+ base,
6
+ defineConfig({
7
+ test: {
8
+ include: ['test/**/*.test.ts', 'test/**/*.test.tsx'],
9
+ },
10
+ }),
11
+ );
package/README.md DELETED
@@ -1,5 +0,0 @@
1
- # ZenStack tanstack-query plugin & runtime
2
-
3
- This package contains ZenStack plugin for generating [tanstack-query](https://tanstack.com/query/latest) hooks.
4
-
5
- Visit [Homepage](https://zenstack.dev) for more details.
package/generator.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { PluginOptions } from '@zenstackhq/sdk';
2
- import { Model } from '@zenstackhq/sdk/ast';
3
- import { type DMMF } from '@zenstackhq/sdk/prisma';
4
- export declare function generate(model: Model, options: PluginOptions, dmmf: DMMF.Document): Promise<{
5
- warnings: string[];
6
- }>;