appflare 0.2.30 → 0.2.32
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/Documentation.md +758 -758
- package/cli/commands/index.ts +238 -238
- package/cli/generate.ts +243 -178
- package/cli/index.ts +120 -120
- package/cli/load-config.ts +184 -184
- package/cli/schema-compiler.ts +1183 -1183
- package/cli/templates/auth/README.md +156 -156
- package/cli/templates/auth/config.ts +61 -61
- package/cli/templates/auth/route-config.ts +1 -1
- package/cli/templates/auth/route-handler.ts +1 -1
- package/cli/templates/auth/route-request-utils.ts +5 -5
- package/cli/templates/auth/route.config.ts +18 -18
- package/cli/templates/auth/route.handler.ts +18 -18
- package/cli/templates/auth/route.request-utils.ts +55 -55
- package/cli/templates/auth/route.ts +14 -14
- package/cli/templates/core/README.md +266 -266
- package/cli/templates/core/app-creation.ts +19 -19
- package/cli/templates/core/client/appflare.ts +112 -112
- package/cli/templates/core/client/handlers/index.ts +748 -748
- package/cli/templates/core/client/handlers.ts +1 -1
- package/cli/templates/core/client/index.ts +7 -7
- package/cli/templates/core/client/storage.ts +195 -195
- package/cli/templates/core/client/types.ts +186 -186
- package/cli/templates/core/client-modules/appflare.ts +1 -1
- package/cli/templates/core/client-modules/handlers.ts +1 -1
- package/cli/templates/core/client-modules/index.ts +1 -1
- package/cli/templates/core/client-modules/storage.ts +1 -1
- package/cli/templates/core/client-modules/types.ts +1 -1
- package/cli/templates/core/client.artifacts.ts +39 -39
- package/cli/templates/core/client.ts +4 -4
- package/cli/templates/core/drizzle.ts +15 -15
- package/cli/templates/core/export.ts +14 -14
- package/cli/templates/core/handlers.route.ts +24 -24
- package/cli/templates/core/handlers.ts +1 -1
- package/cli/templates/core/imports.ts +9 -9
- package/cli/templates/core/server.ts +38 -38
- package/cli/templates/core/types.ts +6 -6
- package/cli/templates/core/wrangler.ts +109 -109
- package/cli/templates/dashboard/builders/functions/index.ts +17 -17
- package/cli/templates/dashboard/builders/functions/render-page/header.ts +20 -20
- package/cli/templates/dashboard/builders/functions/render-page/index.ts +33 -33
- package/cli/templates/dashboard/builders/functions/render-page/request-panel.ts +171 -171
- package/cli/templates/dashboard/builders/functions/render-page/result-panel.ts +85 -85
- package/cli/templates/dashboard/builders/functions/render-page/scripts.ts +554 -554
- package/cli/templates/dashboard/builders/navigation.ts +122 -122
- package/cli/templates/dashboard/builders/storage/index.ts +13 -13
- package/cli/templates/dashboard/builders/storage/routes/create-directory-route.ts +29 -29
- package/cli/templates/dashboard/builders/storage/routes/delete-route.ts +18 -18
- package/cli/templates/dashboard/builders/storage/routes/download-route.ts +23 -23
- package/cli/templates/dashboard/builders/storage/routes/index.ts +22 -22
- package/cli/templates/dashboard/builders/storage/routes/list-route.ts +25 -25
- package/cli/templates/dashboard/builders/storage/routes/preview-route.ts +21 -21
- package/cli/templates/dashboard/builders/storage/routes/upload-route.ts +21 -21
- package/cli/templates/dashboard/builders/storage/runtime/helpers.ts +72 -72
- package/cli/templates/dashboard/builders/storage/runtime/storage-page.ts +130 -130
- package/cli/templates/dashboard/builders/table-routes/common/drawer-panel.ts +27 -27
- package/cli/templates/dashboard/builders/table-routes/common/pagination.ts +30 -30
- package/cli/templates/dashboard/builders/table-routes/common/search-bar.ts +23 -23
- package/cli/templates/dashboard/builders/table-routes/fragments.ts +217 -217
- package/cli/templates/dashboard/builders/table-routes/helpers.ts +45 -45
- package/cli/templates/dashboard/builders/table-routes/index.ts +8 -8
- package/cli/templates/dashboard/builders/table-routes/table/actions-cell.ts +71 -71
- package/cli/templates/dashboard/builders/table-routes/table/get-route.ts +291 -291
- package/cli/templates/dashboard/builders/table-routes/table/index.ts +80 -80
- package/cli/templates/dashboard/builders/table-routes/table/post-routes.ts +163 -163
- package/cli/templates/dashboard/builders/table-routes/table-route.ts +7 -7
- package/cli/templates/dashboard/builders/table-routes/users/get-route.ts +69 -69
- package/cli/templates/dashboard/builders/table-routes/users/html/modals.ts +57 -57
- package/cli/templates/dashboard/builders/table-routes/users/html/page.ts +27 -27
- package/cli/templates/dashboard/builders/table-routes/users/html/table.ts +128 -128
- package/cli/templates/dashboard/builders/table-routes/users/index.ts +32 -32
- package/cli/templates/dashboard/builders/table-routes/users/post-routes.ts +150 -150
- package/cli/templates/dashboard/builders/table-routes/users/redirect.ts +14 -14
- package/cli/templates/dashboard/builders/table-routes/users-route.ts +10 -10
- package/cli/templates/dashboard/components/dashboard-home.ts +23 -23
- package/cli/templates/dashboard/components/layout.ts +388 -388
- package/cli/templates/dashboard/components/login-page.ts +65 -65
- package/cli/templates/dashboard/index.ts +61 -61
- package/cli/templates/dashboard/types.ts +9 -9
- package/cli/templates/handlers/README.md +353 -353
- package/cli/templates/handlers/auth.ts +37 -37
- package/cli/templates/handlers/execution.ts +42 -42
- package/cli/templates/handlers/generators/context/context-creation.ts +101 -101
- package/cli/templates/handlers/generators/context/error-helpers.ts +11 -11
- package/cli/templates/handlers/generators/context/scheduler.ts +24 -24
- package/cli/templates/handlers/generators/context/storage-api.ts +82 -82
- package/cli/templates/handlers/generators/context/storage-helpers.ts +59 -59
- package/cli/templates/handlers/generators/context/types.ts +40 -40
- package/cli/templates/handlers/generators/context.ts +43 -43
- package/cli/templates/handlers/generators/execution.ts +15 -15
- package/cli/templates/handlers/generators/handlers.ts +13 -13
- package/cli/templates/handlers/generators/registration/modules/cron.ts +26 -26
- package/cli/templates/handlers/generators/registration/modules/realtime/auth.ts +75 -75
- package/cli/templates/handlers/generators/registration/modules/realtime/durable-object.ts +144 -144
- package/cli/templates/handlers/generators/registration/modules/realtime/index.ts +14 -14
- package/cli/templates/handlers/generators/registration/modules/realtime/publisher.ts +102 -102
- package/cli/templates/handlers/generators/registration/modules/realtime/routes.ts +164 -164
- package/cli/templates/handlers/generators/registration/modules/realtime/types.ts +30 -30
- package/cli/templates/handlers/generators/registration/modules/realtime/utils.ts +516 -516
- package/cli/templates/handlers/generators/registration/modules/scheduler.ts +56 -56
- package/cli/templates/handlers/generators/registration/modules/storage.ts +199 -199
- package/cli/templates/handlers/generators/registration/sections.ts +210 -210
- package/cli/templates/handlers/generators/types/context.ts +92 -92
- package/cli/templates/handlers/generators/types/core.ts +106 -106
- package/cli/templates/handlers/generators/types/operations.ts +135 -135
- package/cli/templates/handlers/generators/types/query-definitions/filter-and-where-types.ts +281 -259
- package/cli/templates/handlers/generators/types/query-definitions/query-api-types.ts +135 -135
- package/cli/templates/handlers/generators/types/query-definitions/query-helper-functions.ts +1103 -1031
- package/cli/templates/handlers/generators/types/query-definitions/schema-and-table-types.ts +278 -246
- package/cli/templates/handlers/generators/types/query-definitions.ts +13 -13
- package/cli/templates/handlers/generators/types/query-runtime/handled-error.ts +13 -13
- package/cli/templates/handlers/generators/types/query-runtime/runtime-aggregate-and-footer.ts +174 -174
- package/cli/templates/handlers/generators/types/query-runtime/runtime-read.ts +157 -121
- package/cli/templates/handlers/generators/types/query-runtime/runtime-setup.ts +45 -45
- package/cli/templates/handlers/generators/types/query-runtime/runtime-write.ts +697 -697
- package/cli/templates/handlers/generators/types/query-runtime.ts +15 -15
- package/cli/templates/handlers/index.ts +43 -43
- package/cli/templates/handlers/operations.ts +116 -116
- package/cli/templates/handlers/registration.ts +91 -91
- package/cli/templates/handlers/types.ts +15 -15
- package/cli/templates/handlers/utils.ts +48 -48
- package/cli/types.ts +110 -110
- package/cli/utils/handler-discovery.ts +466 -466
- package/cli/utils/json-utils.ts +24 -24
- package/cli/utils/path-utils.ts +19 -19
- package/cli/utils/schema-discovery.ts +399 -399
- package/dist/cli/index.d.mts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +366 -203
- package/dist/cli/index.mjs +366 -203
- package/index.ts +18 -18
- package/package.json +58 -58
- package/react/index.ts +5 -5
- package/react/use-infinite-query.ts +252 -252
- package/react/use-mutation.ts +89 -89
- package/react/use-query.ts +207 -207
- package/schema.ts +415 -415
- package/test-better-auth-hash.ts +2 -2
- package/tsconfig.json +6 -6
- package/tsup.config.ts +82 -82
|
@@ -1,259 +1,281 @@
|
|
|
1
|
-
export function generateFilterAndWhereTypesSection(): string {
|
|
2
|
-
return `type Primitive = string | number | boolean | Date;
|
|
3
|
-
type NonNil<T> = Exclude<T, null | undefined>;
|
|
4
|
-
type Friendly<T> = T extends Date ? Date | number : T;
|
|
5
|
-
type Comparable<T> = Friendly<Extract<NonNil<T>, Primitive>>;
|
|
6
|
-
type RegexOperand<T> = T extends string ? string : never;
|
|
7
|
-
|
|
8
|
-
type GeoPoint = {
|
|
9
|
-
latitude: number;
|
|
10
|
-
longitude: number;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type GeoCoordinates = {
|
|
14
|
-
type?: "Point";
|
|
15
|
-
coordinates: [number, number] | readonly [number, number];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type GeoWithinOperand = {
|
|
19
|
-
$geometry: GeoPoint | GeoCoordinates;
|
|
20
|
-
latitudeField?: string;
|
|
21
|
-
longitudeField?: string;
|
|
22
|
-
$minDistance?: number;
|
|
23
|
-
$maxDistance?: number;
|
|
24
|
-
gt?: number;
|
|
25
|
-
gte?: number;
|
|
26
|
-
lt?: number;
|
|
27
|
-
lte?: number;
|
|
28
|
-
$gt?: number;
|
|
29
|
-
$gte?: number;
|
|
30
|
-
$lt?: number;
|
|
31
|
-
$lte?: number;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
type GeoWithinOperandForField<TFieldKey extends string> = Omit<
|
|
35
|
-
GeoWithinOperand,
|
|
36
|
-
"latitudeField" | "longitudeField"
|
|
37
|
-
> & {
|
|
38
|
-
latitudeField?: TFieldKey;
|
|
39
|
-
longitudeField?: TFieldKey;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type FieldOperators<T, TFieldKey extends string = string> = {
|
|
43
|
-
eq?: Friendly<NonNil<T>>;
|
|
44
|
-
$eq?: Friendly<NonNil<T>>;
|
|
45
|
-
ne?: Friendly<NonNil<T>>;
|
|
46
|
-
$ne?: Friendly<NonNil<T>>;
|
|
47
|
-
in?: ReadonlyArray<Friendly<NonNil<T>>>;
|
|
48
|
-
$in?: ReadonlyArray<Friendly<NonNil<T>>>;
|
|
49
|
-
nin?: ReadonlyArray<Friendly<NonNil<T>>>;
|
|
50
|
-
$nin?: ReadonlyArray<Friendly<NonNil<T>>>;
|
|
51
|
-
gt?: Comparable<T>;
|
|
52
|
-
$gt?: Comparable<T>;
|
|
53
|
-
gte?: Comparable<T>;
|
|
54
|
-
$gte?: Comparable<T>;
|
|
55
|
-
lt?: Comparable<T>;
|
|
56
|
-
$lt?: Comparable<T>;
|
|
57
|
-
lte?: Comparable<T>;
|
|
58
|
-
$lte?: Comparable<T>;
|
|
59
|
-
exists?: boolean;
|
|
60
|
-
regex?: RegexOperand<T>;
|
|
61
|
-
$options?: string;
|
|
62
|
-
geoWithin?: GeoWithinOperandForField<TFieldKey>;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
type WhereFieldValue<T, TFieldKey extends string> =
|
|
66
|
-
| Friendly<NonNil<T>>
|
|
67
|
-
| FieldOperators<T, TFieldKey>;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
[K in keyof TModel]?:
|
|
71
|
-
TModel[K],
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
geoWithin?: GeoWithinOperandForField<Extract<keyof TModel, string>>;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
:
|
|
92
|
-
|
|
93
|
-
type
|
|
94
|
-
|
|
95
|
-
?
|
|
96
|
-
?
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
:
|
|
100
|
-
:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
type
|
|
132
|
-
| true
|
|
133
|
-
| (
|
|
134
|
-
|
|
135
|
-
where
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
type
|
|
187
|
-
| TableModel<
|
|
188
|
-
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
TRelationName
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
1
|
+
export function generateFilterAndWhereTypesSection(): string {
|
|
2
|
+
return `type Primitive = string | number | boolean | Date;
|
|
3
|
+
type NonNil<T> = Exclude<T, null | undefined>;
|
|
4
|
+
type Friendly<T> = T extends Date ? Date | number : T;
|
|
5
|
+
type Comparable<T> = Friendly<Extract<NonNil<T>, Primitive>>;
|
|
6
|
+
type RegexOperand<T> = T extends string ? string : never;
|
|
7
|
+
|
|
8
|
+
type GeoPoint = {
|
|
9
|
+
latitude: number;
|
|
10
|
+
longitude: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type GeoCoordinates = {
|
|
14
|
+
type?: "Point";
|
|
15
|
+
coordinates: [number, number] | readonly [number, number];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type GeoWithinOperand = {
|
|
19
|
+
$geometry: GeoPoint | GeoCoordinates;
|
|
20
|
+
latitudeField?: string;
|
|
21
|
+
longitudeField?: string;
|
|
22
|
+
$minDistance?: number;
|
|
23
|
+
$maxDistance?: number;
|
|
24
|
+
gt?: number;
|
|
25
|
+
gte?: number;
|
|
26
|
+
lt?: number;
|
|
27
|
+
lte?: number;
|
|
28
|
+
$gt?: number;
|
|
29
|
+
$gte?: number;
|
|
30
|
+
$lt?: number;
|
|
31
|
+
$lte?: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type GeoWithinOperandForField<TFieldKey extends string> = Omit<
|
|
35
|
+
GeoWithinOperand,
|
|
36
|
+
"latitudeField" | "longitudeField"
|
|
37
|
+
> & {
|
|
38
|
+
latitudeField?: TFieldKey;
|
|
39
|
+
longitudeField?: TFieldKey;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type FieldOperators<T, TFieldKey extends string = string> = {
|
|
43
|
+
eq?: Friendly<NonNil<T>>;
|
|
44
|
+
$eq?: Friendly<NonNil<T>>;
|
|
45
|
+
ne?: Friendly<NonNil<T>>;
|
|
46
|
+
$ne?: Friendly<NonNil<T>>;
|
|
47
|
+
in?: ReadonlyArray<Friendly<NonNil<T>>>;
|
|
48
|
+
$in?: ReadonlyArray<Friendly<NonNil<T>>>;
|
|
49
|
+
nin?: ReadonlyArray<Friendly<NonNil<T>>>;
|
|
50
|
+
$nin?: ReadonlyArray<Friendly<NonNil<T>>>;
|
|
51
|
+
gt?: Comparable<T>;
|
|
52
|
+
$gt?: Comparable<T>;
|
|
53
|
+
gte?: Comparable<T>;
|
|
54
|
+
$gte?: Comparable<T>;
|
|
55
|
+
lt?: Comparable<T>;
|
|
56
|
+
$lt?: Comparable<T>;
|
|
57
|
+
lte?: Comparable<T>;
|
|
58
|
+
$lte?: Comparable<T>;
|
|
59
|
+
exists?: boolean;
|
|
60
|
+
regex?: RegexOperand<T>;
|
|
61
|
+
$options?: string;
|
|
62
|
+
geoWithin?: GeoWithinOperandForField<TFieldKey>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type WhereFieldValue<T, TFieldKey extends string> =
|
|
66
|
+
| Friendly<NonNil<T>>
|
|
67
|
+
| FieldOperators<T, TFieldKey>;
|
|
68
|
+
|
|
69
|
+
type RelationWhereInput<TModel extends Record<string, unknown>, TName extends TableName | any = any> = {
|
|
70
|
+
[K in keyof TModel]?:
|
|
71
|
+
| WhereFieldValue<TModel[K], Extract<keyof TModel, string>>
|
|
72
|
+
| (TModel[K] extends Record<string, unknown> ? RelationWhereInput<TModel[K]> : never);
|
|
73
|
+
} & {
|
|
74
|
+
geoWithin?: GeoWithinOperandForField<Extract<keyof TModel, string>>;
|
|
75
|
+
$geoWithin?: GeoWithinOperandForField<Extract<keyof TModel, string>>;
|
|
76
|
+
} & (TName extends TableName ? {
|
|
77
|
+
[TRelation in keyof NativeFindManyWith<TName>]?: NativeFindManyWith<TName>[TRelation] extends infer TRelationConfig
|
|
78
|
+
? TRelationConfig extends Record<string, unknown>
|
|
79
|
+
? RelationWhereInput<
|
|
80
|
+
RelationModelFromConfig<TRelationConfig>,
|
|
81
|
+
any
|
|
82
|
+
>
|
|
83
|
+
: never
|
|
84
|
+
: never;
|
|
85
|
+
} : {});
|
|
86
|
+
|
|
87
|
+
export type WhereInput<TModel extends Record<string, unknown>, TName extends TableName | any = any> = RelationWhereInput<TModel, TName>;
|
|
88
|
+
|
|
89
|
+
type ColumnData<TColumn> = TColumn extends { _: { data: infer TData } }
|
|
90
|
+
? TData
|
|
91
|
+
: unknown;
|
|
92
|
+
|
|
93
|
+
type InferRelationWhereFields<TConfig> = TConfig extends { where?: infer TWhere }
|
|
94
|
+
? TWhere extends (...args: infer TArgs) => unknown
|
|
95
|
+
? TArgs extends [infer TFields, ...unknown[]]
|
|
96
|
+
? TFields extends Record<string, unknown>
|
|
97
|
+
? TFields
|
|
98
|
+
: never
|
|
99
|
+
: never
|
|
100
|
+
: never
|
|
101
|
+
: never;
|
|
102
|
+
|
|
103
|
+
type InferRelationNativeWith<TConfig> = TConfig extends { with?: infer TWith }
|
|
104
|
+
? TWith
|
|
105
|
+
: never;
|
|
106
|
+
|
|
107
|
+
type RelationModelFromConfig<TConfig extends Record<string, unknown>> =
|
|
108
|
+
InferRelationWhereFields<TConfig> extends infer TFields
|
|
109
|
+
? TFields extends Record<string, unknown>
|
|
110
|
+
? {
|
|
111
|
+
[K in Extract<keyof TFields, string>]: ColumnData<TFields[K]>;
|
|
112
|
+
}
|
|
113
|
+
: Record<string, unknown>
|
|
114
|
+
: Record<string, unknown>;
|
|
115
|
+
|
|
116
|
+
type NumericModelFieldKey<TModel extends Record<string, unknown>> = Extract<
|
|
117
|
+
{
|
|
118
|
+
[K in keyof TModel]-?: NonNullable<TModel[K]> extends number ? K : never;
|
|
119
|
+
}[keyof TModel],
|
|
120
|
+
string
|
|
121
|
+
>;
|
|
122
|
+
|
|
123
|
+
type RelationAvgSelectionInput<TModel extends Record<string, unknown>> =
|
|
124
|
+
Partial<Record<NumericModelFieldKey<TModel>, boolean>>;
|
|
125
|
+
|
|
126
|
+
type RelationAggregateSelectionInput<TModel extends Record<string, unknown>> = {
|
|
127
|
+
_count?: boolean;
|
|
128
|
+
_avg?: RelationAvgSelectionInput<TModel>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type QueryNativeWithRelationInput<TEntry, TTargetTable> =
|
|
132
|
+
| (Extract<TEntry, true> extends never ? never : true)
|
|
133
|
+
| (Extract<TEntry, Record<string, unknown>> extends infer TRelation
|
|
134
|
+
? TRelation extends Record<string, unknown>
|
|
135
|
+
? Omit<TRelation, "where" | "with" | "_count" | "_avg"> &
|
|
136
|
+
RelationAggregateSelectionInput<RelationModelFromConfig<TRelation>> & {
|
|
137
|
+
where?: WhereInput<RelationModelFromConfig<TRelation>, Extract<TTargetTable, TableName>>;
|
|
138
|
+
with?: TRelation extends { with?: infer TNestedWith }
|
|
139
|
+
? QueryWithInputForTable<Extract<TTargetTable, TableName>, TNestedWith>
|
|
140
|
+
: never;
|
|
141
|
+
}
|
|
142
|
+
: never
|
|
143
|
+
: never);
|
|
144
|
+
|
|
145
|
+
type QueryManyToManyWithRelationInput<TTargetTable extends TableName> =
|
|
146
|
+
| true
|
|
147
|
+
| (Omit<NonNullable<TableFindManyArgs<TTargetTable>>, "where" | "with"> &
|
|
148
|
+
RelationAggregateSelectionInput<TableModel<TTargetTable>> & {
|
|
149
|
+
where?: WhereInput<TableModel<TTargetTable>, TTargetTable>;
|
|
150
|
+
with?: QueryWithInputForTable<
|
|
151
|
+
TTargetTable,
|
|
152
|
+
NativeFindManyWith<TTargetTable>
|
|
153
|
+
>;
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
type QueryWithRelationInputForTable<
|
|
157
|
+
TSourceTable extends TableName,
|
|
158
|
+
TRelationName extends string,
|
|
159
|
+
TEntry,
|
|
160
|
+
> = [ManyToManyTargetTableName<TSourceTable, TRelationName>] extends [never]
|
|
161
|
+
? QueryNativeWithRelationInput<TEntry, RuntimeRelationTargetTable<TSourceTable, TRelationName>>
|
|
162
|
+
: QueryManyToManyWithRelationInput<
|
|
163
|
+
Extract<ManyToManyTargetTableName<TSourceTable, TRelationName>, TableName>
|
|
164
|
+
>;
|
|
165
|
+
|
|
166
|
+
type QueryWithInputForTable<
|
|
167
|
+
TSourceTable extends TableName,
|
|
168
|
+
TWith,
|
|
169
|
+
> = TWith extends Record<string, unknown>
|
|
170
|
+
? {
|
|
171
|
+
[K in keyof TWith]?: QueryWithRelationInputForTable<
|
|
172
|
+
TSourceTable,
|
|
173
|
+
Extract<K, string>,
|
|
174
|
+
TWith[K]
|
|
175
|
+
>;
|
|
176
|
+
}
|
|
177
|
+
: TWith;
|
|
178
|
+
|
|
179
|
+
type QueryWithInput<TName extends TableName, TWith> = QueryWithInputForTable<
|
|
180
|
+
TName,
|
|
181
|
+
TWith
|
|
182
|
+
>;
|
|
183
|
+
|
|
184
|
+
export type OrderByDirection = "asc" | "desc";
|
|
185
|
+
|
|
186
|
+
export type OrderByInput<TName extends TableName> =
|
|
187
|
+
| { column: Extract<keyof TableModel<TName>, string>; direction?: OrderByDirection }
|
|
188
|
+
| Array<{ column: Extract<keyof TableModel<TName>, string>; direction?: OrderByDirection }>;
|
|
189
|
+
|
|
190
|
+
export type QueryFindManyArgs<TName extends TableName> = Omit<
|
|
191
|
+
NonNullable<TableFindManyArgs<TName>>,
|
|
192
|
+
"where" | "with" | "orderBy"
|
|
193
|
+
> & {
|
|
194
|
+
where?: WhereInput<TableModel<TName>, TName>;
|
|
195
|
+
with?: QueryWithInput<TName, NativeFindManyWith<TName>>;
|
|
196
|
+
orderBy?: OrderByInput<TName>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export type QueryFindFirstArgs<TName extends TableName> = Omit<
|
|
200
|
+
NonNullable<TableFindFirstArgs<TName>>,
|
|
201
|
+
"where" | "with" | "orderBy"
|
|
202
|
+
> & {
|
|
203
|
+
where?: WhereInput<TableModel<TName>, TName>;
|
|
204
|
+
with?: QueryWithInput<TName, NativeFindFirstWith<TName>>;
|
|
205
|
+
orderBy?: OrderByInput<TName>;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
type RelationInsertItem<TTargetTable extends TableName> =
|
|
209
|
+
| TableModel<TTargetTable>
|
|
210
|
+
| TableInsertModel<TTargetTable>
|
|
211
|
+
| ("id" extends keyof TableModel<TTargetTable>
|
|
212
|
+
? TableModel<TTargetTable>["id"]
|
|
213
|
+
: never);
|
|
214
|
+
|
|
215
|
+
type RelationInsertValue<
|
|
216
|
+
TSourceTable extends TableName,
|
|
217
|
+
TRelationName extends RuntimeRelationName<TSourceTable>,
|
|
218
|
+
> = RuntimeRelationTargetTable<TSourceTable, TRelationName> extends infer TTargetTable
|
|
219
|
+
? TTargetTable extends TableName
|
|
220
|
+
? RuntimeRelationKind<TSourceTable, TRelationName> extends "one"
|
|
221
|
+
? RelationInsertItem<TTargetTable>
|
|
222
|
+
: RelationInsertItem<TTargetTable> | Array<RelationInsertItem<TTargetTable>>
|
|
223
|
+
: never
|
|
224
|
+
: never;
|
|
225
|
+
|
|
226
|
+
type RelationInsertFields<TName extends TableName> = {
|
|
227
|
+
[TRelationName in RuntimeRelationName<TName>]?: RelationInsertValue<
|
|
228
|
+
TName,
|
|
229
|
+
TRelationName
|
|
230
|
+
>;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
type QueryInsertValue<TName extends TableName> = TableInsertScalarModel<TName> &
|
|
234
|
+
RelationInsertFields<TName>;
|
|
235
|
+
|
|
236
|
+
type InsertItemValue<TArgs> = TArgs extends { values: infer TValue }
|
|
237
|
+
? TValue extends Array<infer TItem>
|
|
238
|
+
? TItem
|
|
239
|
+
: TValue
|
|
240
|
+
: never;
|
|
241
|
+
|
|
242
|
+
type InsertRelationNameFromArgs<
|
|
243
|
+
TName extends TableName,
|
|
244
|
+
TArgs,
|
|
245
|
+
> = Extract<keyof InsertItemValue<TArgs>, RuntimeRelationName<TName>>;
|
|
246
|
+
|
|
247
|
+
type InsertRelationResultValue<
|
|
248
|
+
TSourceTable extends TableName,
|
|
249
|
+
TRelationName extends RuntimeRelationName<TSourceTable>,
|
|
250
|
+
> = RuntimeRelationTargetTable<TSourceTable, TRelationName> extends infer TTargetTable
|
|
251
|
+
? TTargetTable extends TableName
|
|
252
|
+
? RuntimeRelationKind<TSourceTable, TRelationName> extends "one"
|
|
253
|
+
? TableModel<TTargetTable> | null
|
|
254
|
+
: Array<TableModel<TTargetTable>>
|
|
255
|
+
: never
|
|
256
|
+
: never;
|
|
257
|
+
|
|
258
|
+
export type QueryInsertResultRow<
|
|
259
|
+
TName extends TableName,
|
|
260
|
+
TArgs extends QueryInsertArgs<TName>,
|
|
261
|
+
> = TableModel<TName> & {
|
|
262
|
+
[TRelationName in InsertRelationNameFromArgs<TName, TArgs>]:
|
|
263
|
+
InsertRelationResultValue<TName, TRelationName>;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export type QueryInsertArgs<TName extends TableName> = {
|
|
267
|
+
values: QueryInsertValue<TName> | Array<QueryInsertValue<TName>>;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
export type QueryUpdateArgs<TName extends TableName> = {
|
|
271
|
+
set: Partial<TableInsertModel<TName>>;
|
|
272
|
+
where?: WhereInput<TableModel<TName>, TName>;
|
|
273
|
+
limit?: number;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export type QueryDeleteArgs<TName extends TableName> = {
|
|
277
|
+
where?: WhereInput<TableModel<TName>, TName>;
|
|
278
|
+
limit?: number;
|
|
279
|
+
};
|
|
280
|
+
`;
|
|
281
|
+
}
|