|
1 | 1 | import { toCamelCase } from "drizzle-orm/casing"; |
2 | 2 | import { capitalize } from "es-toolkit"; |
3 | | -import { type EnumImplementerType, isEnumSchema } from "./enum"; |
4 | | -import { mapSQLTypeToGraphQLType } from "./helpers/sqlTypes/mapSQLTypeToTSType"; |
5 | | -import type { PossibleSQLType } from "./helpers/sqlTypes/types"; |
6 | | -import { tableHelper } from "./helpers/tableHelpers"; |
7 | | -import type { SchemaBuilderType } from "./schemaBuilder"; |
| 3 | +import { type EnumImplementerType, isEnumSchema } from "../enum"; |
| 4 | +import { mapSQLTypeToGraphQLType } from "../helpers/sqlTypes/mapSQLTypeToTSType"; |
| 5 | +import type { PossibleSQLType } from "../helpers/sqlTypes/types"; |
| 6 | +import { tableHelper } from "../helpers/tableHelpers"; |
8 | 7 | import type { |
9 | 8 | DrizzleInstance, |
10 | 9 | DrizzleQueryFunction, |
11 | | -} from "./types/drizzleInstanceType"; |
12 | | -import { RumbleError } from "./types/rumbleError"; |
| 10 | +} from "../types/drizzleInstanceType"; |
| 11 | +import { RumbleError } from "../types/rumbleError"; |
13 | 12 | import type { |
14 | 13 | CustomRumblePothosConfig, |
15 | 14 | RumbleInput, |
16 | | -} from "./types/rumbleInput"; |
| 15 | +} from "../types/rumbleInput"; |
| 16 | +import type { SchemaBuilderType } from "../types/schemaBuilderType"; |
17 | 17 |
|
18 | 18 | // TODO: in general, several of the filter methods should be more |
19 | 19 | // restrictive in case of explicitly allowed columns |
@@ -214,219 +214,3 @@ export const createWhereArgImplementer = < |
214 | 214 |
|
215 | 215 | return whereArgImplementer; |
216 | 216 | }; |
217 | | - |
218 | | -export type NumberWhereInputArgument = { |
219 | | - eq?: number; |
220 | | - ne?: number; |
221 | | - gt?: number; |
222 | | - gte?: number; |
223 | | - lt?: number; |
224 | | - lte?: number; |
225 | | - in?: number[]; |
226 | | - notIn?: number[]; |
227 | | - like?: string; |
228 | | - ilike?: string; |
229 | | - notLike?: string; |
230 | | - notIlike?: string; |
231 | | - isNull?: boolean; |
232 | | - isNotNull?: boolean; |
233 | | - arrayOverlaps?: number[]; |
234 | | - arrayContained?: number[]; |
235 | | - arrayContains?: number[]; |
236 | | - AND?: NumberWhereInputArgument[]; |
237 | | - OR?: NumberWhereInputArgument[]; |
238 | | - NOT?: NumberWhereInputArgument; |
239 | | -}; |
240 | | - |
241 | | -export type StringWhereInputArgument = { |
242 | | - eq?: string; |
243 | | - ne?: string; |
244 | | - gt?: string; |
245 | | - gte?: string; |
246 | | - lt?: string; |
247 | | - lte?: string; |
248 | | - in?: string[]; |
249 | | - notIn?: string[]; |
250 | | - like?: string; |
251 | | - ilike?: string; |
252 | | - notLike?: string; |
253 | | - notIlike?: string; |
254 | | - isNull?: boolean; |
255 | | - isNotNull?: boolean; |
256 | | - arrayOverlaps?: string[]; |
257 | | - arrayContained?: string[]; |
258 | | - arrayContains?: string[]; |
259 | | - AND?: StringWhereInputArgument[]; |
260 | | - OR?: StringWhereInputArgument[]; |
261 | | - NOT?: StringWhereInputArgument; |
262 | | -}; |
263 | | - |
264 | | -export type DateWhereInputArgument = { |
265 | | - eq?: Date; |
266 | | - ne?: Date; |
267 | | - gt?: Date; |
268 | | - gte?: Date; |
269 | | - lt?: Date; |
270 | | - lte?: Date; |
271 | | - in?: Date[]; |
272 | | - notIn?: Date[]; |
273 | | - like?: string; |
274 | | - ilike?: string; |
275 | | - notLike?: string; |
276 | | - notIlike?: string; |
277 | | - isNull?: boolean; |
278 | | - isNotNull?: boolean; |
279 | | - arrayOverlaps?: Date[]; |
280 | | - arrayContained?: Date[]; |
281 | | - arrayContains?: Date[]; |
282 | | - AND?: DateWhereInputArgument[]; |
283 | | - OR?: DateWhereInputArgument[]; |
284 | | - NOT?: DateWhereInputArgument; |
285 | | -}; |
286 | | - |
287 | | -export function implementDefaultWhereInputArgs< |
288 | | - UserContext extends Record<string, any>, |
289 | | - DB extends DrizzleInstance, |
290 | | - RequestEvent extends Record<string, any>, |
291 | | - Action extends string, |
292 | | - PothosConfig extends CustomRumblePothosConfig, |
293 | | - T extends SchemaBuilderType< |
294 | | - UserContext, |
295 | | - DB, |
296 | | - RequestEvent, |
297 | | - Action, |
298 | | - PothosConfig |
299 | | - >, |
300 | | ->(schemaBuilder: T) { |
301 | | - const IntWhereInputArgument = schemaBuilder |
302 | | - .inputRef<NumberWhereInputArgument>("IntWhereInputArgument") |
303 | | - .implement({ |
304 | | - fields: (t) => ({ |
305 | | - eq: t.int(), |
306 | | - ne: t.int(), |
307 | | - gt: t.int(), |
308 | | - gte: t.int(), |
309 | | - lt: t.int(), |
310 | | - lte: t.int(), |
311 | | - in: t.intList(), |
312 | | - notIn: t.intList(), |
313 | | - like: t.string(), |
314 | | - ilike: t.string(), |
315 | | - notLike: t.string(), |
316 | | - notIlike: t.string(), |
317 | | - isNull: t.boolean(), |
318 | | - isNotNull: t.boolean(), |
319 | | - arrayOverlaps: t.intList(), |
320 | | - arrayContained: t.intList(), |
321 | | - arrayContains: t.intList(), |
322 | | - AND: t.field({ |
323 | | - type: [IntWhereInputArgument], |
324 | | - }), |
325 | | - OR: t.field({ |
326 | | - type: [IntWhereInputArgument], |
327 | | - }), |
328 | | - NOT: t.field({ |
329 | | - type: IntWhereInputArgument, |
330 | | - }), |
331 | | - }), |
332 | | - }); |
333 | | - |
334 | | - const FloatWhereInputArgument = schemaBuilder |
335 | | - .inputRef<NumberWhereInputArgument>("FloatWhereInputArgument") |
336 | | - .implement({ |
337 | | - fields: (t) => ({ |
338 | | - eq: t.float(), |
339 | | - ne: t.float(), |
340 | | - gt: t.float(), |
341 | | - gte: t.float(), |
342 | | - lt: t.float(), |
343 | | - lte: t.float(), |
344 | | - in: t.floatList(), |
345 | | - notIn: t.floatList(), |
346 | | - like: t.string(), |
347 | | - ilike: t.string(), |
348 | | - notLike: t.string(), |
349 | | - notIlike: t.string(), |
350 | | - isNull: t.boolean(), |
351 | | - isNotNull: t.boolean(), |
352 | | - arrayOverlaps: t.floatList(), |
353 | | - arrayContained: t.floatList(), |
354 | | - arrayContains: t.floatList(), |
355 | | - AND: t.field({ |
356 | | - type: [FloatWhereInputArgument], |
357 | | - }), |
358 | | - OR: t.field({ |
359 | | - type: [FloatWhereInputArgument], |
360 | | - }), |
361 | | - NOT: t.field({ |
362 | | - type: FloatWhereInputArgument, |
363 | | - }), |
364 | | - }), |
365 | | - }); |
366 | | - |
367 | | - const StringWhereInputArgument = schemaBuilder |
368 | | - .inputRef<StringWhereInputArgument>("StringWhereInputArgument") |
369 | | - .implement({ |
370 | | - fields: (t) => ({ |
371 | | - eq: t.string(), |
372 | | - ne: t.string(), |
373 | | - gt: t.string(), |
374 | | - gte: t.string(), |
375 | | - lt: t.string(), |
376 | | - lte: t.string(), |
377 | | - in: t.stringList(), |
378 | | - notIn: t.stringList(), |
379 | | - like: t.string(), |
380 | | - ilike: t.string(), |
381 | | - notLike: t.string(), |
382 | | - notIlike: t.string(), |
383 | | - isNull: t.boolean(), |
384 | | - isNotNull: t.boolean(), |
385 | | - arrayOverlaps: t.stringList(), |
386 | | - arrayContained: t.stringList(), |
387 | | - arrayContains: t.stringList(), |
388 | | - AND: t.field({ |
389 | | - type: [StringWhereInputArgument], |
390 | | - }), |
391 | | - OR: t.field({ |
392 | | - type: [StringWhereInputArgument], |
393 | | - }), |
394 | | - NOT: t.field({ |
395 | | - type: StringWhereInputArgument, |
396 | | - }), |
397 | | - }), |
398 | | - }); |
399 | | - |
400 | | - const DateWhereInputArgument = schemaBuilder |
401 | | - .inputRef<DateWhereInputArgument>("DateWhereInputArgument") |
402 | | - .implement({ |
403 | | - fields: (t) => ({ |
404 | | - eq: t.field({ type: "Date" }), |
405 | | - ne: t.field({ type: "Date" }), |
406 | | - gt: t.field({ type: "Date" }), |
407 | | - gte: t.field({ type: "Date" }), |
408 | | - lt: t.field({ type: "Date" }), |
409 | | - lte: t.field({ type: "Date" }), |
410 | | - in: t.field({ type: ["Date"] }), |
411 | | - notIn: t.field({ type: ["Date"] }), |
412 | | - like: t.string(), |
413 | | - ilike: t.string(), |
414 | | - notLike: t.string(), |
415 | | - notIlike: t.string(), |
416 | | - isNull: t.boolean(), |
417 | | - isNotNull: t.boolean(), |
418 | | - arrayOverlaps: t.field({ type: ["Date"] }), |
419 | | - arrayContained: t.field({ type: ["Date"] }), |
420 | | - arrayContains: t.field({ type: ["Date"] }), |
421 | | - AND: t.field({ |
422 | | - type: [DateWhereInputArgument], |
423 | | - }), |
424 | | - OR: t.field({ |
425 | | - type: [DateWhereInputArgument], |
426 | | - }), |
427 | | - NOT: t.field({ |
428 | | - type: DateWhereInputArgument, |
429 | | - }), |
430 | | - }), |
431 | | - }); |
432 | | -} |
0 commit comments