@m1212e/rumble 0.11.7 → 0.12.3

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.
@@ -0,0 +1,922 @@
1
+ import { GraphQLError, GraphQLSchema } from "graphql";
2
+ import { Client } from "@urql/core";
3
+ import { drizzle } from "drizzle-orm/bun-sqlite";
4
+ import { drizzle as drizzle$1 } from "drizzle-orm/node-postgres";
5
+ import * as drizzle_orm0 from "drizzle-orm";
6
+ import * as graphql_yoga0 from "graphql-yoga";
7
+ import { YogaServerOptions, createPubSub } from "graphql-yoga";
8
+ import * as fets0 from "fets";
9
+ import * as _pothos_plugin_drizzle0 from "@pothos/plugin-drizzle";
10
+ import * as _pothos_core0 from "@pothos/core";
11
+ import SchemaBuilder from "@pothos/core";
12
+ import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
13
+ import { useSofa } from "sofa-api";
14
+
15
+ //#region lib/client/generate/generate.d.ts
16
+ declare function generateFromSchema({
17
+ outputPath,
18
+ schema,
19
+ rumbleImportPath,
20
+ apiUrl,
21
+ useExternalUrqlClient
22
+ }: {
23
+ schema: GraphQLSchema;
24
+ outputPath: string;
25
+ rumbleImportPath?: string;
26
+ apiUrl?: string;
27
+ useExternalUrqlClient?: boolean | string;
28
+ }): Promise<void>;
29
+ //#endregion
30
+ //#region lib/client/request.d.ts
31
+ declare const argsKey = "__args";
32
+ //#endregion
33
+ //#region lib/client/utilTypes.d.ts
34
+ type UnArray<T> = T extends Array<infer U> ? U : T;
35
+ type RequireAtLeastOneFieldSet<T> = { [K in keyof T]: Required<Pick<T, K>> & Partial<Omit<T, K>> }[keyof T];
36
+ //#endregion
37
+ //#region lib/client/types.d.ts
38
+ /**
39
+ * A gql object defined from the generated types.
40
+ * Most keys are functions that take a selection set and return a promise of the selected data.
41
+ */
42
+ type QueryableObjectFromGeneratedTypes<Q> = { [Key in keyof Q]: QueryableObjectField$1<Q[Key]> };
43
+ type QueryableObjectField$1<T> = T extends ((p: infer QueryArgs) => infer QueryResponse) ? <Selected extends (QueryArgs extends Record<string, any> ?
44
+ // in that case we want to extend the object with an args key property
45
+ ObjectFieldSelection<UnArray<NonNullable<QueryResponse>>> & {
46
+ [argsKey]: QueryArgs;
47
+ } : ObjectFieldSelection<UnArray<NonNullable<QueryResponse>>>)>(s: Selected) => QueryResponse extends null ? Response<QueryResponse extends Array<any> ? ApplySelection<NonNullable<UnArray<QueryResponse>>, Selected>[] : ApplySelection<NonNullable<UnArray<QueryResponse>>, Selected>> | null : Response<QueryResponse extends Array<any> ? ApplySelection<UnArray<QueryResponse>, Selected>[] : ApplySelection<UnArray<QueryResponse>, Selected>> : Response<T>;
48
+ /**
49
+ * The input to select fields for an object
50
+ */
51
+ type ObjectFieldSelection<O> = RequireAtLeastOneFieldSet<{ [Key in keyof O]: NonNullable<UnArray<O[Key]>> extends ((p: infer P) => infer A) ? P extends Record<string, any> ? ObjectFieldSelection<UnArray<NonNullable<A>>> & {
52
+ [argsKey]: P;
53
+ } : ObjectFieldSelection<UnArray<NonNullable<A>>> : boolean }>;
54
+ type ApplySelection<Object, Selection> = { [Key in keyof Selection & keyof Object]: Object[Key] extends ((p: infer _P) => infer _A) ? ReturnType<Object[Key]> extends Array<any> ? Array<ApplySelection<UnArray<ReturnType<Object[Key]>>, Selection[Key]>> : ApplySelection<UnArray<Object[Key]>, Selection[Key]> : Object[Key] };
55
+ type Subscribeable<Data> = {
56
+ subscribe: (subscription: (value: Data) => void) => () => void;
57
+ };
58
+ type Response<Data> = {
59
+ then: (onFulfilled: (value: Subscribeable<Data> & Data) => void) => void;
60
+ } & Subscribeable<Data | undefined>;
61
+ //#endregion
62
+ //#region lib/client/liveQuery.d.ts
63
+ declare function makeLiveQuery<Query extends Record<string, any>>({
64
+ urqlClient,
65
+ availableSubscriptions
66
+ }: {
67
+ urqlClient: Client;
68
+ availableSubscriptions: Set<string>;
69
+ }): QueryableObjectFromGeneratedTypes<Query>;
70
+ //#endregion
71
+ //#region lib/client/mutation.d.ts
72
+ declare function makeMutation<Mutation extends Record<string, any>>({
73
+ urqlClient
74
+ }: {
75
+ urqlClient: Client;
76
+ }): QueryableObjectFromGeneratedTypes<Mutation>;
77
+ //#endregion
78
+ //#region lib/client/query.d.ts
79
+ declare function makeQuery<Query extends Record<string, any>>({
80
+ urqlClient
81
+ }: {
82
+ urqlClient: Client;
83
+ }): QueryableObjectFromGeneratedTypes<Query>;
84
+ //#endregion
85
+ //#region lib/client/subscription.d.ts
86
+ declare function makeSubscription<Subscription extends Record<string, any>>({
87
+ urqlClient
88
+ }: {
89
+ urqlClient: Client;
90
+ }): SubscriptionObject<Subscription>;
91
+ type SubscriptionObject<Q> = { [Key in keyof Q]: QueryableObjectField<Q[Key]> };
92
+ type QueryableObjectField<T> = T extends ((p: infer QueryArgs) => infer QueryResponse) ? <Selected extends (QueryArgs extends Record<string, any> ? ObjectFieldSelection<UnArray<NonNullable<QueryResponse>>> & {
93
+ [argsKey]: QueryArgs;
94
+ } : ObjectFieldSelection<UnArray<NonNullable<QueryResponse>>>)>(s: Selected) => QueryResponse extends null ? Subscribeable<NonNullable<QueryResponse> extends Array<any> ? ApplySelection<UnArray<NonNullable<QueryResponse>>, Selected>[] : ApplySelection<UnArray<NonNullable<QueryResponse>>, Selected>> | null : Subscribeable<QueryResponse extends Array<any> ? ApplySelection<UnArray<QueryResponse>, Selected>[] : ApplySelection<UnArray<QueryResponse>, Selected>> : Subscribeable<T>;
95
+ //#endregion
96
+ //#region lib/helpers/asserts.d.ts
97
+ /**
98
+ *
99
+ * Helper function to map a drizzle findFirst query result,
100
+ * which may be optional, to a correct drizzle type.
101
+ *
102
+ * @throws RumbleError
103
+ *
104
+ * @example
105
+ *
106
+ * ```ts
107
+ * schemaBuilder.queryFields((t) => {
108
+ return {
109
+ findFirstUser: t.drizzleField({
110
+ type: UserRef,
111
+ resolve: (query, root, args, ctx, info) => {
112
+ return (
113
+ db.query.users
114
+ .findFirst({
115
+ ...query,
116
+ where: ctx.abilities.users.filter("read").single.where,
117
+ })
118
+ // note that we need to manually raise an error if the value is not found
119
+ .then(assertFindFirstExists)
120
+ );
121
+ },
122
+ }),
123
+ };
124
+ });
125
+ * ```
126
+ */
127
+ declare const assertFindFirstExists: <T>(value: T | undefined) => T;
128
+ /**
129
+ *
130
+ * Helper function to map a drizzle findFirst query result,
131
+ * which may be optional, to a correct drizzle type.
132
+ *
133
+ * @throws RumbleError
134
+ *
135
+ * @example
136
+ *
137
+ * ```ts
138
+ schemaBuilder.mutationFields((t) => {
139
+ return {
140
+ updateUsername: t.drizzleField({
141
+ type: UserRef,
142
+ args: {
143
+ userId: t.arg.int({ required: true }),
144
+ newName: t.arg.string({ required: true }),
145
+ },
146
+ resolve: (query, root, args, ctx, info) => {
147
+ return db
148
+ .update(schema.users)
149
+ .set({
150
+ name: args.newName,
151
+ })
152
+ .where(
153
+ and(
154
+ eq(schema.users.id, args.userId),
155
+ ctx.abilities.users.filter("update").single.where
156
+ )
157
+ )
158
+ .returning({ id: schema.users.id, name: schema.users.name })
159
+ // note that we need to manually raise an error if the value is not found
160
+ .then(assertFirstEntryExists);
161
+ },
162
+ }),
163
+ };
164
+ });
165
+ * ```
166
+ */
167
+ declare const assertFirstEntryExists: <T>(value: T[]) => T;
168
+ //#endregion
169
+ //#region lib/helpers/mapNullFieldsToUndefined.d.ts
170
+ /**
171
+ * Helper to map null fields to undefined
172
+ * @param obj The object to map
173
+ * @returns The mapped object with all fields of 'null' transformed to 'undefined'
174
+ *
175
+ * This becomes useful for update mutations where you do not want to pass null (unset value in db)
176
+ * but undefined (do not touch value in db) in case of a value not beeing set in the args of said mutation
177
+ * @example
178
+ * ```ts
179
+ * updateUser: t.drizzleField({
180
+ type: User,
181
+ args: {
182
+ id: t.arg.string({ required: true }),
183
+ email: t.arg.string(),
184
+ lastName: t.arg.string(),
185
+ firstName: t.arg.string(),
186
+ },
187
+ resolve: async (query, root, args, ctx, info) => {
188
+ const mappedArgs = mapNullFieldsToUndefined(args);
189
+ const user = await db.transaction(async (tx) => {
190
+ const user = await tx
191
+ .update(schema.user)
192
+ .set({
193
+
194
+ // email: args.email ?? undefined,
195
+ // lastName: args.lastName ?? undefined,
196
+ // firstName: args.firstName ?? undefined,
197
+
198
+ // becomes this
199
+
200
+ email: mappedArgs.email,
201
+ lastName: mappedArgs.lastName,
202
+ firstName: mappedArgs.firstName,
203
+ })
204
+ .returning()
205
+ .then(assertFirstEntryExists);
206
+ return user;
207
+ });
208
+
209
+ pubsub.updated(user.id);
210
+
211
+ return db.query.user
212
+ .findFirst(
213
+ query(
214
+ ctx.abilities.user.filter('read').merge(
215
+ {
216
+ where: { id: user.id },
217
+ }
218
+ 1).query.single,
219
+ ),
220
+ )
221
+ .then(assertFindFirstExists);
222
+ },
223
+ }),
224
+ *
225
+ *
226
+ * ```
227
+ */
228
+ declare function mapNullFieldsToUndefined<T extends object>(obj: T): { [K in keyof T]: T[K] extends null ? undefined : Exclude<T[K], null> };
229
+ //#endregion
230
+ //#region lib/types/drizzleInstanceType.d.ts
231
+ type DrizzleInstance = ReturnType<typeof drizzle$1<any, any, any>> | ReturnType<typeof drizzle<any, any, any>>;
232
+ /**
233
+ * Type representing the query function of a Drizzle instance.
234
+ */
235
+ type DrizzleQueryFunction<DB extends DrizzleInstance> = DB["query"];
236
+ /**
237
+ * Type representing the input parameters for the `findMany` method of a specific table in the Drizzle query function.
238
+ */
239
+ type DrizzleQueryFunctionInput<DB extends DrizzleInstance, QueryField extends keyof DrizzleQueryFunction<DB>> = Parameters<DrizzleQueryFunction<DB>[QueryField]["findMany"]>[0];
240
+ /**
241
+ * Type representing the type of a record in a specific table of the Drizzle instance.
242
+ */
243
+ type DrizzleTableValueType<DB extends DrizzleInstance, QueryField extends keyof DrizzleQueryFunction<DB>> = NonNullable<Awaited<ReturnType<DrizzleQueryFunction<DB>[QueryField]["findFirst"]>>>;
244
+ //#endregion
245
+ //#region lib/runtimeFiltersPlugin/filterTypes.d.ts
246
+ type Filter<Context, T> = (p: {
247
+ context: Context;
248
+ entities: T[];
249
+ }) => T[] | Promise<T[]>;
250
+ //#endregion
251
+ //#region lib/args/whereArgsImplementer.d.ts
252
+ type NumberWhereInputArgument = {
253
+ eq?: number;
254
+ ne?: number;
255
+ gt?: number;
256
+ gte?: number;
257
+ lt?: number;
258
+ lte?: number;
259
+ in?: number[];
260
+ notIn?: number[];
261
+ like?: string;
262
+ ilike?: string;
263
+ notLike?: string;
264
+ notIlike?: string;
265
+ isNull?: boolean;
266
+ isNotNull?: boolean;
267
+ arrayOverlaps?: number[];
268
+ arrayContained?: number[];
269
+ arrayContains?: number[];
270
+ AND?: NumberWhereInputArgument[];
271
+ OR?: NumberWhereInputArgument[];
272
+ NOT?: NumberWhereInputArgument;
273
+ };
274
+ type StringWhereInputArgument = {
275
+ eq?: string;
276
+ ne?: string;
277
+ gt?: string;
278
+ gte?: string;
279
+ lt?: string;
280
+ lte?: string;
281
+ in?: string[];
282
+ notIn?: string[];
283
+ like?: string;
284
+ ilike?: string;
285
+ notLike?: string;
286
+ notIlike?: string;
287
+ isNull?: boolean;
288
+ isNotNull?: boolean;
289
+ arrayOverlaps?: string[];
290
+ arrayContained?: string[];
291
+ arrayContains?: string[];
292
+ AND?: StringWhereInputArgument[];
293
+ OR?: StringWhereInputArgument[];
294
+ NOT?: StringWhereInputArgument;
295
+ };
296
+ type DateWhereInputArgument = {
297
+ eq?: Date;
298
+ ne?: Date;
299
+ gt?: Date;
300
+ gte?: Date;
301
+ lt?: Date;
302
+ lte?: Date;
303
+ in?: Date[];
304
+ notIn?: Date[];
305
+ like?: string;
306
+ ilike?: string;
307
+ notLike?: string;
308
+ notIlike?: string;
309
+ isNull?: boolean;
310
+ isNotNull?: boolean;
311
+ arrayOverlaps?: Date[];
312
+ arrayContained?: Date[];
313
+ arrayContains?: Date[];
314
+ AND?: DateWhereInputArgument[];
315
+ OR?: DateWhereInputArgument[];
316
+ NOT?: DateWhereInputArgument;
317
+ };
318
+ //#endregion
319
+ //#region lib/types/rumbleInput.d.ts
320
+ type CustomRumblePothosConfig = Omit<ConstructorParameters<typeof SchemaBuilder>[0], "smartSubscriptions" | "drizzle">;
321
+ type RumbleInput<UserContext extends Record<string, any>, DB extends DrizzleInstance, RequestEvent extends Record<string, any>, Action extends string, PothosConfig extends CustomRumblePothosConfig> = {
322
+ /**
323
+ * Your drizzle database instance
324
+ */
325
+ db: DB;
326
+ /**
327
+ * A function for providing context for each request based on the incoming HTTP Request.
328
+ * The type of the parameter equals the HTTPRequest type of your chosen server.
329
+ */
330
+ context?: ((event: RequestEvent) => Promise<UserContext> | UserContext) | undefined;
331
+ /**
332
+ * If you only want to disable query, mutation or subscription default objects, you can do so here
333
+ */
334
+ disableDefaultObjects?: {
335
+ mutation?: boolean;
336
+ subscription?: boolean;
337
+ query?: boolean;
338
+ };
339
+ /**
340
+ * The actions that are available
341
+ */
342
+ actions?: Action[];
343
+ /**
344
+ * Customization for subscriptions. See https://the-guild.dev/graphql/yoga-server/docs/features/subscriptions#distributed-pubsub-for-production
345
+ */
346
+ subscriptions?: Parameters<typeof createPubSub>;
347
+ /**
348
+ * Options passed along to the pothos schema builder.
349
+ */
350
+ pothosConfig?: PothosConfig;
351
+ /**
352
+ * Limits the returned amount when querying lists. Set to null to disable.
353
+ * @default 100
354
+ */
355
+ defaultLimit?: number | undefined | null;
356
+ /**
357
+ * rumble supports fuzzy search for the query helpers. This enables the users of your API to search for entities via fuzzy search inputs.
358
+ * This currently only is supported by postgres databases and will fail if enabled on other dialects.
359
+ *
360
+ * Please note that this will install the pg_trgm extension on startup if your database does not have it already installed.
361
+ * https://www.postgresql.org/docs/current/pgtrgm.html
362
+ */
363
+ search?: {
364
+ /**
365
+ * Whether search is enabled
366
+ */
367
+ enabled?: boolean;
368
+ /**
369
+ * The threshold for cutting off non matching results. Defaults to 0.1. Lower = more results.
370
+ */
371
+ threshold?: number;
372
+ } | undefined;
373
+ };
374
+ //#endregion
375
+ //#region lib/rumble.d.ts
376
+ declare const rumble: <UserContext extends Record<string, any>, DB extends DrizzleInstance, RequestEvent extends Record<string, any>, PothosConfig extends CustomRumblePothosConfig, Action extends string = "read" | "update" | "delete">(rumbleInput: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig>) => {
377
+ /**
378
+ * The ability builder. Use it to declare whats allowed for each entity in your DB.
379
+ *
380
+ * @example
381
+ *
382
+ * ```ts
383
+ * // users can edit themselves
384
+ abilityBuilder.users
385
+ .allow(["read", "update", "delete"])
386
+ .when(({ userId }) => ({ where: eq(schema.users.id, userId) }));
387
+
388
+ // everyone can read posts
389
+ abilityBuilder.posts.allow("read");
390
+ *
391
+ * ```
392
+ */
393
+ abilityBuilder: (keyof DrizzleQueryFunction<DB> extends infer T extends keyof DrizzleQueryFunction<DB> ? { [key in T]: {
394
+ allow: (action: Action | Action[]) => {
395
+ when: (queryFilter: DrizzleQueryFunctionInput<DB, key> | ((context: UserContext) => DrizzleQueryFunctionInput<DB, key> | "allow" | undefined)) => void;
396
+ };
397
+ filter: (action: Action | Action[]) => {
398
+ by: (explicitFilter: Filter<UserContext, DrizzleTableValueType<DB, key>>) => void;
399
+ };
400
+ _: {
401
+ runtimeFilters: Map<Action, Filter<UserContext, any>[]>;
402
+ queryFilters: Map<Action, "unrestricted" | (DrizzleQueryFunctionInput<DB, key> | ((context: UserContext) => DrizzleQueryFunctionInput<DB, key> | "allow" | undefined))[]>;
403
+ };
404
+ } } : never) & {
405
+ _: {
406
+ registeredFilters({
407
+ action,
408
+ table
409
+ }: {
410
+ table: keyof DrizzleQueryFunction<DB>;
411
+ action: Action;
412
+ }): Filter<UserContext, DrizzleTableValueType<DB, keyof DrizzleQueryFunction<DB>>>[];
413
+ build(): (ctx: UserContext) => keyof DrizzleQueryFunction<DB> extends infer T_1 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_1]: {
414
+ filter: (action: Action) => {
415
+ query: {
416
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
417
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
418
+ };
419
+ sql: {
420
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
421
+ };
422
+ } & {
423
+ merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key_1>>) => {
424
+ query: {
425
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
426
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
427
+ };
428
+ sql: {
429
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
430
+ };
431
+ };
432
+ };
433
+ } } : never;
434
+ };
435
+ };
436
+ /**
437
+ * The pothos schema builder. See https://pothos-graphql.dev/docs/plugins/drizzle
438
+ */
439
+ schemaBuilder: PothosSchemaTypes.SchemaBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
440
+ Context: Awaited<UserContext & {
441
+ abilities: keyof DrizzleQueryFunction<DB> extends infer T_1 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_1]: {
442
+ filter: (action: Action) => {
443
+ query: {
444
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
445
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
446
+ };
447
+ sql: {
448
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
449
+ };
450
+ } & {
451
+ merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key_1>>) => {
452
+ query: {
453
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
454
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
455
+ };
456
+ sql: {
457
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
458
+ };
459
+ };
460
+ };
461
+ } } : never;
462
+ }>;
463
+ DrizzleRelations: DB["_"]["relations"];
464
+ Scalars: {
465
+ JSON: {
466
+ Input: unknown;
467
+ Output: unknown;
468
+ };
469
+ Date: {
470
+ Input: Date;
471
+ Output: Date;
472
+ };
473
+ DateTime: {
474
+ Input: Date;
475
+ Output: Date;
476
+ };
477
+ };
478
+ Inputs: {
479
+ IntWhereInputArgument: NumberWhereInputArgument;
480
+ FloatWhereInputArgument: NumberWhereInputArgument;
481
+ StringWhereInputArgument: StringWhereInputArgument;
482
+ DateWhereInputArgument: DateWhereInputArgument;
483
+ };
484
+ }>>;
485
+ /**
486
+ * Creates the native yoga instance. Can be used to run an actual HTTP server.
487
+ *
488
+ * @example
489
+ *
490
+ * ```ts
491
+ *
492
+ import { createServer } from "node:http";
493
+ * const server = createServer(createYoga());
494
+ server.listen(3000, () => {
495
+ console.info("Visit http://localhost:3000/graphql");
496
+ });
497
+ * ```
498
+ * https://the-guild.dev/graphql/yoga-server/docs#server
499
+ */
500
+ createYoga: (args?: (Omit<YogaServerOptions<RequestEvent, any>, "schema" | "context"> & {
501
+ /**
502
+ * Determines if the API should disclose various things about its structure.
503
+ * Defaults to `process.env.NODE_ENV === "development"`.
504
+ * If enabled, the api will allow introspection requests, provide the graphiql
505
+ * explorer and will not apply the additional envelop armor plugin.
506
+ */
507
+ enableApiDocs?: boolean;
508
+ }) | undefined) => graphql_yoga0.YogaServerInstance<RequestEvent, {}>;
509
+ /**
510
+ * Creates a sofa instance to offer a REST API.
511
+ ```ts
512
+ import express from 'express';
513
+
514
+ const app = express();
515
+ const sofa = createSofa(...);
516
+
517
+ app.use('/api', useSofa({ schema }));
518
+ ```
519
+ * https://the-guild.dev/graphql/sofa-api/docs#usage
520
+ */
521
+ createSofa: (args: Omit<Parameters<typeof useSofa>[0], "schema" | "context">) => fets0.Router<any, {}, {
522
+ [TKey: string]: never;
523
+ }>;
524
+ /**
525
+ * A function for creating default objects for your schema
526
+ */
527
+ object: <TableName extends keyof DrizzleQueryFunction<DB>, RefName extends string>({
528
+ table,
529
+ refName,
530
+ readAction,
531
+ adjust
532
+ }: {
533
+ table: TableName;
534
+ refName?: RefName | undefined;
535
+ readAction?: Action | undefined;
536
+ adjust?: ((t: _pothos_plugin_drizzle0.DrizzleObjectFieldBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
537
+ Context: Awaited<UserContext & {
538
+ abilities: keyof DrizzleQueryFunction<DB> extends infer T_2 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_2]: {
539
+ filter: (action: Action) => {
540
+ query: {
541
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
542
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
543
+ };
544
+ sql: {
545
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
546
+ };
547
+ } & {
548
+ merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key_1>>) => {
549
+ query: {
550
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
551
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
552
+ };
553
+ sql: {
554
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
555
+ };
556
+ };
557
+ };
558
+ } } : never;
559
+ }>;
560
+ DrizzleRelations: DB["_"]["relations"];
561
+ Scalars: {
562
+ JSON: {
563
+ Input: unknown;
564
+ Output: unknown;
565
+ };
566
+ Date: {
567
+ Input: Date;
568
+ Output: Date;
569
+ };
570
+ DateTime: {
571
+ Input: Date;
572
+ Output: Date;
573
+ };
574
+ };
575
+ Inputs: {
576
+ IntWhereInputArgument: NumberWhereInputArgument;
577
+ FloatWhereInputArgument: NumberWhereInputArgument;
578
+ StringWhereInputArgument: StringWhereInputArgument;
579
+ DateWhereInputArgument: DateWhereInputArgument;
580
+ };
581
+ }>, (DB["_"]["relations"] & {})[TableName], DrizzleTableValueType<DB, TableName>, { [Key in keyof Extract<(DB["_"]["relations"] & {})[TableName]["table"], {
582
+ _: {
583
+ brand: "Table";
584
+ };
585
+ }>["_"]["columns"] & string]: Extract<(DB["_"]["relations"] & {})[TableName]["table"], {
586
+ _: {
587
+ brand: "Table";
588
+ };
589
+ }>["_"]["columns"][Key]["_"]["notNull"] extends true ? Extract<(DB["_"]["relations"] & {})[TableName]["table"], {
590
+ _: {
591
+ brand: "Table";
592
+ };
593
+ }>["_"]["columns"][Key]["_"]["data"] : Extract<(DB["_"]["relations"] & {})[TableName]["table"], {
594
+ _: {
595
+ brand: "Table";
596
+ };
597
+ }>["_"]["columns"][Key]["_"]["data"] | null } extends infer T_3 ? { [K in keyof T_3]: { [Key in keyof Extract<(DB["_"]["relations"] & {})[TableName]["table"], {
598
+ _: {
599
+ brand: "Table";
600
+ };
601
+ }>["_"]["columns"] & string]: Extract<(DB["_"]["relations"] & {})[TableName]["table"], {
602
+ _: {
603
+ brand: "Table";
604
+ };
605
+ }>["_"]["columns"][Key]["_"]["notNull"] extends true ? Extract<(DB["_"]["relations"] & {})[TableName]["table"], {
606
+ _: {
607
+ brand: "Table";
608
+ };
609
+ }>["_"]["columns"][Key]["_"]["data"] : Extract<(DB["_"]["relations"] & {})[TableName]["table"], {
610
+ _: {
611
+ brand: "Table";
612
+ };
613
+ }>["_"]["columns"][Key]["_"]["data"] | null }[K] } : never>) => _pothos_core0.FieldMap) | undefined;
614
+ }) => _pothos_plugin_drizzle0.DrizzleObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
615
+ Context: Awaited<UserContext & {
616
+ abilities: keyof DrizzleQueryFunction<DB> extends infer T_2 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_2]: {
617
+ filter: (action: Action) => {
618
+ query: {
619
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
620
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
621
+ };
622
+ sql: {
623
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
624
+ };
625
+ } & {
626
+ merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key_1>>) => {
627
+ query: {
628
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
629
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
630
+ };
631
+ sql: {
632
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
633
+ };
634
+ };
635
+ };
636
+ } } : never;
637
+ }>;
638
+ DrizzleRelations: DB["_"]["relations"];
639
+ Scalars: {
640
+ JSON: {
641
+ Input: unknown;
642
+ Output: unknown;
643
+ };
644
+ Date: {
645
+ Input: Date;
646
+ Output: Date;
647
+ };
648
+ DateTime: {
649
+ Input: Date;
650
+ Output: Date;
651
+ };
652
+ };
653
+ Inputs: {
654
+ IntWhereInputArgument: NumberWhereInputArgument;
655
+ FloatWhereInputArgument: NumberWhereInputArgument;
656
+ StringWhereInputArgument: StringWhereInputArgument;
657
+ DateWhereInputArgument: DateWhereInputArgument;
658
+ };
659
+ }>, TableName, drizzle_orm0.BuildQueryResult<DB["_"]["relations"] & {}, (DB["_"]["relations"] & {})[TableName], true extends true | drizzle_orm0.DBQueryConfig<"one", DB["_"]["relations"] & {}, (DB["_"]["relations"] & {})[TableName]> ? true : (true | drizzle_orm0.DBQueryConfig<"one", DB["_"]["relations"] & {}, (DB["_"]["relations"] & {})[TableName]>) & {
660
+ columns: {};
661
+ }, drizzle_orm0.Assume<(DB["_"]["relations"] & {})[TableName]["table"], {
662
+ $inferSelect: Record<string, unknown>;
663
+ }>["$inferSelect"]>>;
664
+ /**
665
+ * A function for creating where args to filter entities
666
+ */
667
+ whereArg: <TableName extends keyof DrizzleQueryFunction<DB>, RefName_1 extends string>({
668
+ table,
669
+ refName,
670
+ dbName
671
+ }: Partial<{
672
+ table: TableName;
673
+ refName: RefName_1 | undefined;
674
+ dbName: string;
675
+ }> & ({
676
+ dbName: string;
677
+ } | {
678
+ table: TableName;
679
+ })) => PothosSchemaTypes.InputObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
680
+ Context: Awaited<UserContext & {
681
+ abilities: keyof DrizzleQueryFunction<DB> extends infer T_2 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_2]: {
682
+ filter: (action: Action) => {
683
+ query: {
684
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
685
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
686
+ };
687
+ sql: {
688
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
689
+ };
690
+ } & {
691
+ merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key_1>>) => {
692
+ query: {
693
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
694
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
695
+ };
696
+ sql: {
697
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
698
+ };
699
+ };
700
+ };
701
+ } } : never;
702
+ }>;
703
+ DrizzleRelations: DB["_"]["relations"];
704
+ Scalars: {
705
+ JSON: {
706
+ Input: unknown;
707
+ Output: unknown;
708
+ };
709
+ Date: {
710
+ Input: Date;
711
+ Output: Date;
712
+ };
713
+ DateTime: {
714
+ Input: Date;
715
+ Output: Date;
716
+ };
717
+ };
718
+ Inputs: {
719
+ IntWhereInputArgument: NumberWhereInputArgument;
720
+ FloatWhereInputArgument: NumberWhereInputArgument;
721
+ StringWhereInputArgument: StringWhereInputArgument;
722
+ DateWhereInputArgument: DateWhereInputArgument;
723
+ };
724
+ }>, {
725
+ [x: string]: unknown;
726
+ }>;
727
+ /**
728
+ * A function for creating order args to sort entities
729
+ */
730
+ orderArg: <RefName_2 extends string, TableName extends keyof DrizzleQueryFunction<DB>>({
731
+ table,
732
+ refName,
733
+ dbName
734
+ }: Partial<{
735
+ table: TableName;
736
+ refName: RefName_2 | undefined;
737
+ dbName: string;
738
+ }> & ({
739
+ dbName: string;
740
+ } | {
741
+ table: TableName;
742
+ })) => PothosSchemaTypes.InputObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
743
+ Context: Awaited<UserContext & {
744
+ abilities: keyof DrizzleQueryFunction<DB> extends infer T_2 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_2]: {
745
+ filter: (action: Action) => {
746
+ query: {
747
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
748
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
749
+ };
750
+ sql: {
751
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
752
+ };
753
+ } & {
754
+ merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key_1>>) => {
755
+ query: {
756
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
757
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
758
+ };
759
+ sql: {
760
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
761
+ };
762
+ };
763
+ };
764
+ } } : never;
765
+ }>;
766
+ DrizzleRelations: DB["_"]["relations"];
767
+ Scalars: {
768
+ JSON: {
769
+ Input: unknown;
770
+ Output: unknown;
771
+ };
772
+ Date: {
773
+ Input: Date;
774
+ Output: Date;
775
+ };
776
+ DateTime: {
777
+ Input: Date;
778
+ Output: Date;
779
+ };
780
+ };
781
+ Inputs: {
782
+ IntWhereInputArgument: NumberWhereInputArgument;
783
+ FloatWhereInputArgument: NumberWhereInputArgument;
784
+ StringWhereInputArgument: StringWhereInputArgument;
785
+ DateWhereInputArgument: DateWhereInputArgument;
786
+ };
787
+ }>, {
788
+ [x: string]: unknown;
789
+ }>;
790
+ /**
791
+ * A function for creating default READ queries.
792
+ * Make sure the objects for the table you are creating the queries for are implemented
793
+ */
794
+ query: <TableName_1 extends keyof DrizzleQueryFunction<DB>>({
795
+ table,
796
+ readAction,
797
+ listAction
798
+ }: {
799
+ table: TableName_1;
800
+ readAction?: Action | undefined;
801
+ listAction?: Action | undefined;
802
+ }) => void;
803
+ /**
804
+ * A function for creating a pubsub instance for a table. Use this to publish or subscribe events
805
+ */
806
+ pubsub: <TableName_1 extends keyof DrizzleQueryFunction<DB>>({
807
+ table
808
+ }: {
809
+ table: TableName_1;
810
+ }) => {
811
+ registerOnInstance({
812
+ instance,
813
+ action,
814
+ primaryKeyValue
815
+ }: {
816
+ instance: {
817
+ register: (id: string) => void;
818
+ };
819
+ action: "created" | "removed" | "updated";
820
+ primaryKeyValue?: string;
821
+ }): void;
822
+ created(): void;
823
+ removed(): void;
824
+ updated(primaryKeyValue?: any | any[]): void;
825
+ };
826
+ /**
827
+ * A function to implement enums for graphql usage.
828
+ * The other helpers use this helper internally so in most cases you do not have to
829
+ * call this helper directly, unless you need the reference to an enum type
830
+ */
831
+ enum_: <ExplicitEnumVariableName extends keyof (NonNullable<DB["_"]["relations"]["schema"]> extends infer T_2 ? { [K in keyof T_2 as NonNullable<DB["_"]["relations"]["schema"]>[K] extends drizzle_orm_pg_core0.PgEnum<any> ? K : never]: NonNullable<DB["_"]["relations"]["schema"]>[K] } : never), EnumColumn extends drizzle_orm_pg_core0.PgEnum<any>, RefName_2 extends string>({
832
+ tsName,
833
+ enumColumn,
834
+ refName
835
+ }: Partial<{
836
+ tsName: ExplicitEnumVariableName;
837
+ enumColumn: EnumColumn;
838
+ refName?: RefName_2 | undefined;
839
+ }> & ({
840
+ tsName: ExplicitEnumVariableName;
841
+ } | {
842
+ enumColumn: EnumColumn;
843
+ })) => PothosSchemaTypes.EnumRef<PothosSchemaTypes.ExtendDefaultTypes<{
844
+ Context: Awaited<UserContext & {
845
+ abilities: keyof DrizzleQueryFunction<DB> extends infer T_3 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_3]: {
846
+ filter: (action: Action) => {
847
+ query: {
848
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
849
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
850
+ };
851
+ sql: {
852
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
853
+ };
854
+ } & {
855
+ merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key_1>>) => {
856
+ query: {
857
+ single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
858
+ many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findMany"]>[0]>>, "where" | "limit">;
859
+ };
860
+ sql: {
861
+ readonly where: drizzle_orm0.SQL<unknown> | undefined;
862
+ };
863
+ };
864
+ };
865
+ } } : never;
866
+ }>;
867
+ DrizzleRelations: DB["_"]["relations"];
868
+ Scalars: {
869
+ JSON: {
870
+ Input: unknown;
871
+ Output: unknown;
872
+ };
873
+ Date: {
874
+ Input: Date;
875
+ Output: Date;
876
+ };
877
+ DateTime: {
878
+ Input: Date;
879
+ Output: Date;
880
+ };
881
+ };
882
+ Inputs: {
883
+ IntWhereInputArgument: NumberWhereInputArgument;
884
+ FloatWhereInputArgument: NumberWhereInputArgument;
885
+ StringWhereInputArgument: StringWhereInputArgument;
886
+ DateWhereInputArgument: DateWhereInputArgument;
887
+ };
888
+ }>, any, any>;
889
+ /**
890
+ * Create a client to consume a rumble graphql api at the specified location.
891
+ * Requires GraphQL, does not work with the SOFA REST API.
892
+ */
893
+ clientCreator: ({
894
+ apiUrl,
895
+ outputPath,
896
+ rumbleImportPath,
897
+ useExternalUrqlClient
898
+ }: {
899
+ outputPath: string;
900
+ apiUrl?: string;
901
+ rumbleImportPath?: string;
902
+ useExternalUrqlClient?: string;
903
+ }) => Promise<void>;
904
+ };
905
+ //#endregion
906
+ //#region lib/types/rumbleError.d.ts
907
+ /**
908
+ * An error that gets raised by rumble whenever something does not go according to plan.
909
+ * Mostly internals, configuration errors or other unexpected things.
910
+ */
911
+ declare class RumbleError extends Error {
912
+ constructor(message: string);
913
+ }
914
+ /**
915
+ * An error that gets raised by rumble whenever an error occurs in a resolver, containing
916
+ * information safely exposeable to the user.
917
+ * E.g. the assert helpers issue these.
918
+ */
919
+ declare class RumbleErrorSafe extends GraphQLError {}
920
+ //#endregion
921
+ export { RumbleError, RumbleErrorSafe, assertFindFirstExists, assertFirstEntryExists, generateFromSchema, makeLiveQuery, makeMutation, makeQuery, makeSubscription, mapNullFieldsToUndefined, rumble };
922
+ //# sourceMappingURL=index.d.cts.map