@m1212e/rumble 0.5.3 → 0.6.0

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/index.d.ts CHANGED
@@ -1,12 +1,11 @@
1
- import * as drizzle_orm_mysql_core from 'drizzle-orm/mysql-core';
2
- import * as drizzle_orm_singlestore_core from 'drizzle-orm/singlestore-core';
3
1
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
2
+ import * as SchemaBuilder from '@pothos/core';
3
+ import SchemaBuilder__default, { SchemaTypes, BasePlugin, PothosOutputFieldConfig } from '@pothos/core';
4
4
  import * as _pothos_plugin_drizzle from '@pothos/plugin-drizzle';
5
5
  import { DrizzleClient } from '@pothos/plugin-drizzle';
6
6
  import * as graphql_yoga from 'graphql-yoga';
7
7
  import { createPubSub, YogaServerOptions } from 'graphql-yoga';
8
8
  import * as drizzle_orm from 'drizzle-orm';
9
- import SchemaBuilder, { SchemaTypes, BasePlugin, PothosOutputFieldConfig } from '@pothos/core';
10
9
  import { GraphQLFieldResolver, GraphQLError } from 'graphql';
11
10
 
12
11
  declare const pluginName = "ManualFiltersPlugin";
@@ -32,7 +31,7 @@ declare global {
32
31
  }
33
32
  }
34
33
 
35
- type QueryConditionObject = Partial<{
34
+ type QueryFilterObject = Partial<{
36
35
  where: any;
37
36
  columns: any;
38
37
  limit: any;
@@ -40,13 +39,13 @@ type QueryConditionObject = Partial<{
40
39
  type GenericDrizzleDbTypeConstraints = {
41
40
  query: {
42
41
  [key: string]: {
43
- findMany: (P: QueryConditionObject) => any;
44
- findFirst: (P: QueryConditionObject) => any;
42
+ findMany: (P: QueryFilterObject) => any;
43
+ findFirst: (P: QueryFilterObject) => any;
45
44
  };
46
45
  };
47
46
  } & DrizzleClient;
48
47
 
49
- type CustomRumblePothosConfig = Omit<ConstructorParameters<typeof SchemaBuilder>[0], "smartSubscriptions" | "drizzle">;
48
+ type CustomRumblePothosConfig = Omit<ConstructorParameters<typeof SchemaBuilder__default>[0], "smartSubscriptions" | "drizzle">;
50
49
  type RumbleInput<UserContext extends Record<string, any>, DB extends GenericDrizzleDbTypeConstraints, RequestEvent extends Record<string, any>, Action extends string, PothosConfig extends CustomRumblePothosConfig> = {
51
50
  /**
52
51
  * Your drizzle database instance
@@ -103,38 +102,33 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Gener
103
102
  */
104
103
  abilityBuilder: (keyof DB["query"] extends infer T extends keyof DB["query"] ? { [key in T]: {
105
104
  allow: (action: Action | Action[]) => {
106
- when: (condition: Parameters<DB["query"][keyof DB["query"]]["findMany"]>[0] | ((context: UserContext) => "allow" | Parameters<DB["query"][keyof DB["query"]]["findMany"]>[0] | undefined)) => void;
105
+ when: (queryFilter: Parameters<DB["query"][key]["findMany"]>[0] | ((context: UserContext) => "allow" | Parameters<DB["query"][key]["findMany"]>[0] | undefined)) => void;
107
106
  };
108
107
  filter: (action: Action | Action[]) => {
109
108
  by: (explicitFilter: Filter<UserContext, NonNullable<Awaited<ReturnType<DB["query"][key]["findFirst"]>>>>) => void;
110
109
  };
111
110
  }; } : never) & {
112
- registeredConditions: keyof DB["query"] extends infer T_1 extends keyof DB["query"] ? { [key_1 in T_1]: { [key_2 in Action]: "wildcard" | (Partial<{
113
- where: any;
114
- columns: any;
115
- limit: any;
116
- }> | ((context: UserContext) => "allow" | Partial<{
117
- where: any;
118
- columns: any;
119
- limit: any;
120
- }> | undefined))[]; }; } : never;
111
+ registeredQueryFilters: keyof DB["query"] extends infer T_1 extends keyof DB["query"] ? { [key_1 in T_1]: { [key_2 in Action]: any[] | "unspecified"; }; } : never;
121
112
  registeredFilters: keyof DB["query"] extends infer T_2 extends keyof DB["query"] ? { [key_3 in T_2]: { [key_4 in Action]: Filter<UserContext, any>[]; }; } : never;
122
113
  buildWithUserContext: (userContext: UserContext) => keyof DB["query"] extends infer T_3 extends keyof DB["query"] ? { [key_5 in T_3]: {
123
- filter: (action: Action, options?: {
124
- inject?: Partial<{
125
- where: any;
126
- columns: any;
127
- limit: any;
128
- }> | undefined;
114
+ filter: <Injection extends Parameters<DB["query"][key_5]["findMany"]>[0]>(action: Action, options?: {
115
+ inject?: Injection | undefined;
129
116
  } | undefined) => {
130
- single: {
131
- where: drizzle_orm.SQL<unknown> | undefined;
132
- columns: Record<string, any> | undefined;
117
+ query: {
118
+ single: {
119
+ readonly where: any;
120
+ readonly columns: undefined;
121
+ };
122
+ many: {
123
+ readonly where: any;
124
+ readonly columns: undefined;
125
+ readonly limit: any;
126
+ };
133
127
  };
134
- many: {
135
- where: drizzle_orm.SQL<unknown> | undefined;
136
- columns: Record<string, any> | undefined;
137
- limit: number | undefined;
128
+ sql: {
129
+ readonly where: drizzle_orm.SQL<unknown> | undefined;
130
+ readonly columns: undefined;
131
+ readonly limit: any;
138
132
  };
139
133
  };
140
134
  explicitFilters: (action: Action) => (keyof DB["query"] extends infer T_4 extends keyof DB["query"] ? { [key_3 in T_4]: { [key_4 in Action]: Filter<UserContext, any>[]; }; } : never)[key_5][Action];
@@ -146,27 +140,30 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Gener
146
140
  schemaBuilder: PothosSchemaTypes.SchemaBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
147
141
  Context: Awaited<UserContext & {
148
142
  abilities: keyof DB["query"] extends infer T_3 extends keyof DB["query"] ? { [key_5 in T_3]: {
149
- filter: (action: Action, options?: {
150
- inject?: Partial<{
151
- where: any;
152
- columns: any;
153
- limit: any;
154
- }> | undefined;
143
+ filter: <Injection extends Parameters<DB["query"][key_5]["findMany"]>[0]>(action: Action, options?: {
144
+ inject?: Injection | undefined;
155
145
  } | undefined) => {
156
- single: {
157
- where: drizzle_orm.SQL<unknown> | undefined;
158
- columns: Record<string, any> | undefined;
146
+ query: {
147
+ single: {
148
+ readonly where: any;
149
+ readonly columns: undefined;
150
+ };
151
+ many: {
152
+ readonly where: any;
153
+ readonly columns: undefined;
154
+ readonly limit: any;
155
+ };
159
156
  };
160
- many: {
161
- where: drizzle_orm.SQL<unknown> | undefined;
162
- columns: Record<string, any> | undefined;
163
- limit: number | undefined;
157
+ sql: {
158
+ readonly where: drizzle_orm.SQL<unknown> | undefined;
159
+ readonly columns: undefined;
160
+ readonly limit: any;
164
161
  };
165
162
  };
166
163
  explicitFilters: (action: Action) => (keyof DB["query"] extends infer T_4 extends keyof DB["query"] ? { [key_3 in T_4]: { [key_4 in Action]: Filter<UserContext, any>[]; }; } : never)[key_5][Action];
167
164
  }; } : never;
168
165
  }>;
169
- DrizzleSchema: DB["_"]["fullSchema"];
166
+ DrizzleRelations: DB["_"]["relations"];
170
167
  Scalars: {
171
168
  JSON: {
172
169
  Input: unknown;
@@ -199,34 +196,79 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Gener
199
196
  /**
200
197
  * A function for creating default objects for your schema
201
198
  */
202
- object: <ExplicitTableName extends keyof NonNullable<DB["_"]["schema"]>, RefName extends string>({ tableName, name, readAction, }: {
203
- tableName: ExplicitTableName;
204
- name?: RefName | undefined;
199
+ object: <ExplicitTableName extends keyof NonNullable<DB["_"]["relations"]["schema"]>, RefName extends string>({ table, refName, readAction, extend, }: {
200
+ table: ExplicitTableName;
201
+ refName?: RefName | undefined;
205
202
  readAction?: Action | undefined;
203
+ extend?: ((t: _pothos_plugin_drizzle.DrizzleObjectFieldBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
204
+ Context: Awaited<UserContext & {
205
+ abilities: keyof DB["query"] extends infer T_4 extends keyof DB["query"] ? { [key_5 in T_4]: {
206
+ filter: <Injection extends Parameters<DB["query"][key_5]["findMany"]>[0]>(action: Action, options?: {
207
+ inject?: Injection | undefined;
208
+ } | undefined) => {
209
+ query: {
210
+ single: {
211
+ readonly where: any;
212
+ readonly columns: undefined;
213
+ };
214
+ many: {
215
+ readonly where: any;
216
+ readonly columns: undefined;
217
+ readonly limit: any;
218
+ };
219
+ };
220
+ sql: {
221
+ readonly where: drizzle_orm.SQL<unknown> | undefined;
222
+ readonly columns: undefined;
223
+ readonly limit: any;
224
+ };
225
+ };
226
+ explicitFilters: (action: Action) => (keyof DB["query"] extends infer T_5 extends keyof DB["query"] ? { [key_3 in T_5]: { [key_4 in Action]: Filter<UserContext, any>[]; }; } : never)[key_5][Action];
227
+ }; } : never;
228
+ }>;
229
+ DrizzleRelations: DB["_"]["relations"];
230
+ Scalars: {
231
+ JSON: {
232
+ Input: unknown;
233
+ Output: unknown;
234
+ };
235
+ Date: {
236
+ Input: Date;
237
+ Output: Date;
238
+ };
239
+ DateTime: {
240
+ Input: Date;
241
+ Output: Date;
242
+ };
243
+ };
244
+ }>, any, any, any>) => SchemaBuilder.FieldMap) | undefined;
206
245
  }) => _pothos_plugin_drizzle.DrizzleObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
207
246
  Context: Awaited<UserContext & {
208
247
  abilities: keyof DB["query"] extends infer T_4 extends keyof DB["query"] ? { [key_5 in T_4]: {
209
- filter: (action: Action, options?: {
210
- inject?: Partial<{
211
- where: any;
212
- columns: any;
213
- limit: any;
214
- }> | undefined;
248
+ filter: <Injection extends Parameters<DB["query"][key_5]["findMany"]>[0]>(action: Action, options?: {
249
+ inject?: Injection | undefined;
215
250
  } | undefined) => {
216
- single: {
217
- where: drizzle_orm.SQL<unknown> | undefined;
218
- columns: Record<string, any> | undefined;
251
+ query: {
252
+ single: {
253
+ readonly where: any;
254
+ readonly columns: undefined;
255
+ };
256
+ many: {
257
+ readonly where: any;
258
+ readonly columns: undefined;
259
+ readonly limit: any;
260
+ };
219
261
  };
220
- many: {
221
- where: drizzle_orm.SQL<unknown> | undefined;
222
- columns: Record<string, any> | undefined;
223
- limit: number | undefined;
262
+ sql: {
263
+ readonly where: drizzle_orm.SQL<unknown> | undefined;
264
+ readonly columns: undefined;
265
+ readonly limit: any;
224
266
  };
225
267
  };
226
268
  explicitFilters: (action: Action) => (keyof DB["query"] extends infer T_5 extends keyof DB["query"] ? { [key_3 in T_5]: { [key_4 in Action]: Filter<UserContext, any>[]; }; } : never)[key_5][Action];
227
269
  }; } : never;
228
270
  }>;
229
- DrizzleSchema: DB["_"]["fullSchema"];
271
+ DrizzleRelations: DB["_"]["relations"];
230
272
  Scalars: {
231
273
  JSON: {
232
274
  Input: unknown;
@@ -241,74 +283,76 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Gener
241
283
  Output: Date;
242
284
  };
243
285
  };
244
- }>, ExplicitTableName, ({ [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; } | undefined extends Record<string, unknown> ? { [Key in (drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]) & string as Key]: { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["notNull"] extends true ? { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["data"] : { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["data"] | null; } extends infer T_8 ? { [K_2 in keyof T_8]: { [Key in (drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]) & string as Key]: { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["notNull"] extends true ? { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["data"] : { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["data"] | null; }[K_2]; } : never : { [Key_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] & string as Key_1]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["notNull"] extends true ? drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["data"] : drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["data"] | null; } extends infer T_9 ? { [K_5 in keyof T_9]: { [Key_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] & string as Key_1]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["notNull"] extends true ? drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["data"] : drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["data"] | null; }[K_5]; } : never) & {} & ({ [K_6 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"]]?: true | drizzle_orm.DBQueryConfig<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"][K_6] extends drizzle_orm.One<string, boolean> ? "one" : "many", false, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, drizzle_orm.FindTableByDBName<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"][K_6]["referencedTableName"]>> | undefined; } | undefined extends Record<string, unknown> ? drizzle_orm.BuildRelationResult<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, Record<string, unknown> & { [K_6 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"]]?: true | drizzle_orm.DBQueryConfig<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"][K_6] extends drizzle_orm.One<string, boolean> ? "one" : "many", false, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, drizzle_orm.FindTableByDBName<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"][K_6]["referencedTableName"]>> | undefined; }, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"]> : {}) extends infer T_5 ? { [K in keyof T_5]: (({ [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; } | undefined extends Record<string, unknown> ? { [Key in (drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]) & string as Key]: { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["notNull"] extends true ? { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["data"] : { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["data"] | null; } extends infer T_6 ? { [K_2 in keyof T_6]: { [Key in (drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]) & string as Key]: { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["notNull"] extends true ? { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["data"] : { [K_4 in drizzle_orm.Equal<Exclude<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] | (string & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"])], undefined>, false> extends true ? Exclude<keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"], drizzle_orm.NonUndefinedKeysOnly<Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; }>> : { [K_3 in keyof (Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })]: drizzle_orm.Equal<(Record<string, unknown> & { [K_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]?: boolean | undefined; })[K_3], true> extends true ? K_3 : never; }[string | keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]] & keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"]]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][K_4]; }[Key]["_"]["data"] | null; }[K_2]; } : never : { [Key_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] & string as Key_1]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["notNull"] extends true ? drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["data"] : drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["data"] | null; } extends infer T_7 ? { [K_5 in keyof T_7]: { [Key_1 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"] & string as Key_1]: drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["notNull"] extends true ? drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["data"] : drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["columns"][Key_1]["_"]["data"] | null; }[K_5]; } : never) & {} & ({ [K_6 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"]]?: true | drizzle_orm.DBQueryConfig<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"][K_6] extends drizzle_orm.One<string, boolean> ? "one" : "many", false, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, drizzle_orm.FindTableByDBName<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"][K_6]["referencedTableName"]>> | undefined; } | undefined extends Record<string, unknown> ? drizzle_orm.BuildRelationResult<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, Record<string, unknown> & { [K_6 in keyof drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"]]?: true | drizzle_orm.DBQueryConfig<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"][K_6] extends drizzle_orm.One<string, boolean> ? "one" : "many", false, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, drizzle_orm.FindTableByDBName<drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"][K_6]["referencedTableName"]>> | undefined; }, drizzle_orm.ExtractTablesWithRelations<DB["_"]["fullSchema"] & {}>[ExplicitTableName]["relations"]> : {}))[K]; } : never>;
286
+ }>, ExplicitTableName, drizzle_orm.BuildQueryResult<drizzle_orm.ExtractTablesWithRelations<DB["_"]["relations"] & {}, (DB["_"]["relations"] & {})["tables"]>, drizzle_orm.ExtractTablesWithRelations<DB["_"]["relations"] & {}, (DB["_"]["relations"] & {})["tables"]>[ExplicitTableName], true | drizzle_orm.DBQueryConfig<"one", drizzle_orm.ExtractTablesWithRelations<DB["_"]["relations"] & {}, (DB["_"]["relations"] & {})["tables"]>, drizzle_orm.ExtractTablesWithRelations<DB["_"]["relations"] & {}, (DB["_"]["relations"] & {})["tables"]>[ExplicitTableName]>>>;
245
287
  /**
246
288
  * A function for creating where args to filter entities
247
289
  */
248
- arg: <ExplicitTableName extends keyof NonNullable<DB["_"]["schema"]>, RefName_1 extends string>({ tableName, name, nativeTableName, }: {
249
- tableName: ExplicitTableName;
250
- name?: RefName_1 | undefined;
251
- nativeTableName?: string;
252
- }) => {
253
- inputType: PothosSchemaTypes.InputObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
254
- Context: Awaited<UserContext & {
255
- abilities: keyof DB["query"] extends infer T_4 extends keyof DB["query"] ? { [key_5 in T_4]: {
256
- filter: (action: Action, options?: {
257
- inject?: Partial<{
258
- where: any;
259
- columns: any;
260
- limit: any;
261
- }> | undefined;
262
- } | undefined) => {
290
+ arg: <ExplicitTableName extends keyof NonNullable<DB["_"]["relations"]["schema"]>, RefName_1 extends string>({ table, refName, dbName, }: Partial<{
291
+ table: ExplicitTableName;
292
+ refName: RefName_1 | undefined;
293
+ dbName: string;
294
+ }> & ({
295
+ dbName: string;
296
+ } | {
297
+ table: ExplicitTableName;
298
+ })) => PothosSchemaTypes.InputObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
299
+ Context: Awaited<UserContext & {
300
+ abilities: keyof DB["query"] extends infer T_4 extends keyof DB["query"] ? { [key_5 in T_4]: {
301
+ filter: <Injection extends Parameters<DB["query"][key_5]["findMany"]>[0]>(action: Action, options?: {
302
+ inject?: Injection | undefined;
303
+ } | undefined) => {
304
+ query: {
263
305
  single: {
264
- where: drizzle_orm.SQL<unknown> | undefined;
265
- columns: Record<string, any> | undefined;
306
+ readonly where: any;
307
+ readonly columns: undefined;
266
308
  };
267
309
  many: {
268
- where: drizzle_orm.SQL<unknown> | undefined;
269
- columns: Record<string, any> | undefined;
270
- limit: number | undefined;
310
+ readonly where: any;
311
+ readonly columns: undefined;
312
+ readonly limit: any;
271
313
  };
272
314
  };
273
- explicitFilters: (action: Action) => (keyof DB["query"] extends infer T_5 extends keyof DB["query"] ? { [key_3 in T_5]: { [key_4 in Action]: Filter<UserContext, any>[]; }; } : never)[key_5][Action];
274
- }; } : never;
275
- }>;
276
- DrizzleSchema: DB["_"]["fullSchema"];
277
- Scalars: {
278
- JSON: {
279
- Input: unknown;
280
- Output: unknown;
281
- };
282
- Date: {
283
- Input: Date;
284
- Output: Date;
285
- };
286
- DateTime: {
287
- Input: Date;
288
- Output: Date;
315
+ sql: {
316
+ readonly where: drizzle_orm.SQL<unknown> | undefined;
317
+ readonly columns: undefined;
318
+ readonly limit: any;
319
+ };
289
320
  };
290
- };
291
- }>, {
292
- [x: string]: unknown;
321
+ explicitFilters: (action: Action) => (keyof DB["query"] extends infer T_5 extends keyof DB["query"] ? { [key_3 in T_5]: { [key_4 in Action]: Filter<UserContext, any>[]; }; } : never)[key_5][Action];
322
+ }; } : never;
293
323
  }>;
294
- transformArgumentToQueryCondition: <T_5 extends {
295
- [x: string]: unknown;
296
- }>(arg: T_5 | null | undefined) => drizzle_orm.SQL<unknown> | undefined;
297
- };
324
+ DrizzleRelations: DB["_"]["relations"];
325
+ Scalars: {
326
+ JSON: {
327
+ Input: unknown;
328
+ Output: unknown;
329
+ };
330
+ Date: {
331
+ Input: Date;
332
+ Output: Date;
333
+ };
334
+ DateTime: {
335
+ Input: Date;
336
+ Output: Date;
337
+ };
338
+ };
339
+ }>, {
340
+ [x: string]: unknown;
341
+ }>;
298
342
  /**
299
343
  * A function for creating default READ queries.
300
344
  * Make sure the objects for the table you are creating the queries for are implemented
301
345
  */
302
- query: <ExplicitTableName extends keyof NonNullable<DB["_"]["schema"]>>({ tableName, readAction, listAction, }: {
303
- tableName: ExplicitTableName;
346
+ query: <ExplicitTableName extends keyof NonNullable<DB["_"]["relations"]["schema"]>>({ table, readAction, listAction, }: {
347
+ table: ExplicitTableName;
304
348
  readAction?: Action | undefined;
305
349
  listAction?: Action | undefined;
306
350
  }) => void;
307
351
  /**
308
352
  * A function for creating a pubsub instance for a table. Use this to publish or subscribe events
309
353
  */
310
- pubsub: <ExplicitTableName extends keyof NonNullable<DB["_"]["schema"]>>({ tableName, }: {
311
- tableName: ExplicitTableName;
354
+ pubsub: <ExplicitTableName extends keyof NonNullable<DB["_"]["relations"]["schema"]>>({ table, }: {
355
+ table: ExplicitTableName;
312
356
  }) => {
313
357
  registerOnInstance({ instance, action, primaryKeyValue, }: {
314
358
  instance: {
@@ -318,46 +362,49 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Gener
318
362
  primaryKeyValue?: string;
319
363
  }): void;
320
364
  created(): void;
321
- removed(primaryKeyValue?: NonNullable<DB["_"]["schema"]>[ExplicitTableName]["primaryKey"][number]["_"]["data"] | NonNullable<DB["_"]["schema"]>[ExplicitTableName]["primaryKey"][number]["_"]["data"][] | undefined): void;
322
- updated(primaryKeyValue?: NonNullable<DB["_"]["schema"]>[ExplicitTableName]["primaryKey"][number]["_"]["data"] | NonNullable<DB["_"]["schema"]>[ExplicitTableName]["primaryKey"][number]["_"]["data"][] | undefined): void;
365
+ removed(primaryKeyValue?: any | any[]): void;
366
+ updated(primaryKeyValue?: any | any[]): void;
323
367
  };
324
368
  /**
325
369
  * A function to implement enums for graphql usage.
326
370
  * The other helpers use this helper internally so in most cases you do not have to
327
371
  * call this helper directly, unless you need the reference to an enum type
328
372
  */
329
- enum_: <ExplicitEnumVariableName extends keyof (NonNullable<DB["_"]["fullSchema"]> extends infer T_4 ? { [K in keyof T_4 as NonNullable<DB["_"]["fullSchema"]>[K] extends drizzle_orm_pg_core.PgEnum<any> | drizzle_orm_singlestore_core.SingleStoreEnumColumnBuilderInitial<any, any> | drizzle_orm_mysql_core.MySqlEnumColumnBuilderInitial<any, any> ? K : never]: NonNullable<DB["_"]["fullSchema"]>[K]; } : never), RefName_2 extends string, EnumName extends string>({ enumVariableName, name, enumName, }: Partial<{
330
- enumVariableName: ExplicitEnumVariableName;
331
- enumName: EnumName;
332
- name: RefName_2 | undefined;
333
- } & ({
334
- enumVariableName: ExplicitEnumVariableName;
373
+ enum_: <ExplicitEnumVariableName extends keyof (NonNullable<DB["_"]["relations"]["schema"]> extends infer T_4 ? { [K in keyof T_4 as NonNullable<DB["_"]["relations"]["schema"]>[K] extends drizzle_orm_pg_core.PgEnum<any> ? K : never]: NonNullable<DB["_"]["relations"]["schema"]>[K]; } : never), EnumColumn extends drizzle_orm_pg_core.PgEnum<any>, RefName_2 extends string>({ tsName, enumColumn, refName, }: Partial<{
374
+ tsName: ExplicitEnumVariableName;
375
+ enumColumn: EnumColumn;
376
+ refName?: RefName_2 | undefined;
377
+ }> & ({
378
+ tsName: ExplicitEnumVariableName;
335
379
  } | {
336
- enumName: EnumName;
337
- })>) => PothosSchemaTypes.EnumRef<PothosSchemaTypes.ExtendDefaultTypes<{
380
+ enumColumn: EnumColumn;
381
+ })) => PothosSchemaTypes.EnumRef<PothosSchemaTypes.ExtendDefaultTypes<{
338
382
  Context: Awaited<UserContext & {
339
383
  abilities: keyof DB["query"] extends infer T_5 extends keyof DB["query"] ? { [key_5 in T_5]: {
340
- filter: (action: Action, options?: {
341
- inject?: Partial<{
342
- where: any;
343
- columns: any;
344
- limit: any;
345
- }> | undefined;
384
+ filter: <Injection extends Parameters<DB["query"][key_5]["findMany"]>[0]>(action: Action, options?: {
385
+ inject?: Injection | undefined;
346
386
  } | undefined) => {
347
- single: {
348
- where: drizzle_orm.SQL<unknown> | undefined;
349
- columns: Record<string, any> | undefined;
387
+ query: {
388
+ single: {
389
+ readonly where: any;
390
+ readonly columns: undefined;
391
+ };
392
+ many: {
393
+ readonly where: any;
394
+ readonly columns: undefined;
395
+ readonly limit: any;
396
+ };
350
397
  };
351
- many: {
352
- where: drizzle_orm.SQL<unknown> | undefined;
353
- columns: Record<string, any> | undefined;
354
- limit: number | undefined;
398
+ sql: {
399
+ readonly where: drizzle_orm.SQL<unknown> | undefined;
400
+ readonly columns: undefined;
401
+ readonly limit: any;
355
402
  };
356
403
  };
357
404
  explicitFilters: (action: Action) => (keyof DB["query"] extends infer T_6 extends keyof DB["query"] ? { [key_3 in T_6]: { [key_4 in Action]: Filter<UserContext, any>[]; }; } : never)[key_5][Action];
358
405
  }; } : never;
359
406
  }>;
360
- DrizzleSchema: DB["_"]["fullSchema"];
407
+ DrizzleRelations: DB["_"]["relations"];
361
408
  Scalars: {
362
409
  JSON: {
363
410
  Input: unknown;
package/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import {createYoga,createPubSub}from'graphql-yoga';import {One,or,and,eq}from'drizzle-orm';import {toCamelCase}from'drizzle-orm/casing';import Te,{BasePlugin}from'@pothos/core';import De from'@pothos/plugin-drizzle';import Ee,{subscribeOptionsFromIterator}from'@pothos/plugin-smart-subscriptions';import {JSONResolver,DateResolver,DateTimeISOResolver}from'graphql-scalars';function Q(e){return typeof e=="object"&&e!==null}function k(e,t){throw new Error("Unexpected invariant triggered.")}var se=/\r\n|[\n\r]/g;function F(e,t){let l=0,p=1;for(let n of e.body.matchAll(se)){if(typeof n.index=="number"||k(),n.index>=t)break;l=n.index+n[0].length,p+=1;}return {line:p,column:t+1-l}}function j(e){return q(e.source,F(e.source,e.start))}function q(e,t){let l=e.locationOffset.column-1,p="".padStart(l)+e.body,n=t.line-1,d=e.locationOffset.line-1,i=t.line+d,y=t.line===1?l:0,r=t.column+y,s=`${e.name}:${i}:${r}
2
- `,o=p.split(/\r\n|[\n\r]/g),f=o[n];if(f.length>120){let a=Math.floor(r/80),c=r%80,m=[];for(let x=0;x<f.length;x+=80)m.push(f.slice(x,x+80));return s+G([[`${i} |`,m[0]],...m.slice(1,a+1).map(x=>["|",x]),["|","^".padStart(c)],["|",m[a+1]]])}return s+G([[`${i-1} |`,o[n-1]],[`${i} |`,f],["|","^".padStart(r)],[`${i+1} |`,o[n+1]]])}function G(e){let t=e.filter(([p,n])=>n!==void 0),l=Math.max(...t.map(([p])=>p.length));return t.map(([p,n])=>p.padStart(l)+(n?" "+n:"")).join(`
3
- `)}function ae(e){let t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}var B=class e extends Error{constructor(t,...l){var p,n,d;let{nodes:i,source:y,positions:r,path:s,originalError:o,extensions:f}=ae(l);super(t),this.name="GraphQLError",this.path=s??void 0,this.originalError=o??void 0,this.nodes=_(Array.isArray(i)?i:i?[i]:void 0);let a=_((p=this.nodes)===null||p===void 0?void 0:p.map(m=>m.loc).filter(m=>m!=null));this.source=y??(a==null||(n=a[0])===null||n===void 0?void 0:n.source),this.positions=r??a?.map(m=>m.start),this.locations=r&&y?r.map(m=>F(y,m)):a?.map(m=>F(m.source,m.start));let c=Q(o?.extensions)?o?.extensions:void 0;this.extensions=(d=f??c)!==null&&d!==void 0?d:Object.create(null),Object.defineProperties(this,{message:{writable:true,enumerable:true},name:{enumerable:false},nodes:{enumerable:false},source:{enumerable:false},positions:{enumerable:false},originalError:{enumerable:false}}),o!=null&&o.stack?Object.defineProperty(this,"stack",{value:o.stack,writable:true,configurable:true}):Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:Error().stack,writable:true,configurable:true});}get[Symbol.toStringTag](){return "GraphQLError"}toString(){let t=this.message;if(this.nodes)for(let l of this.nodes)l.loc&&(t+=`
1
+ import {createYoga,createPubSub}from'graphql-yoga';import {One,relationsFilterToSQL}from'drizzle-orm';import {toCamelCase}from'drizzle-orm/casing';import {PgEnumColumn}from'drizzle-orm/pg-core';import Ee,{BasePlugin}from'@pothos/core';import Ae from'@pothos/plugin-drizzle';import ve,{subscribeOptionsFromIterator}from'@pothos/plugin-smart-subscriptions';import {JSONResolver,DateResolver,DateTimeISOResolver}from'graphql-scalars';function N(e){let t,m=false;return ()=>(m||(t=e(),m=true),t)}function _(e){return typeof e=="object"&&e!==null}function V(e,t){throw new Error("Unexpected invariant triggered.")}var pe=/\r\n|[\n\r]/g;function z(e,t){let m=0,u=1;for(let n of e.body.matchAll(pe)){if(typeof n.index=="number"||V(),n.index>=t)break;m=n.index+n[0].length,u+=1;}return {line:u,column:t+1-m}}function $(e){return k(e.source,z(e.source,e.start))}function k(e,t){let m=e.locationOffset.column-1,u="".padStart(m)+e.body,n=t.line-1,a=e.locationOffset.line-1,i=t.line+a,l=t.line===1?m:0,o=t.column+l,p=`${e.name}:${i}:${o}
2
+ `,r=u.split(/\r\n|[\n\r]/g),f=r[n];if(f.length>120){let s=Math.floor(o/80),d=o%80,c=[];for(let b=0;b<f.length;b+=80)c.push(f.slice(b,b+80));return p+M([[`${i} |`,c[0]],...c.slice(1,s+1).map(b=>["|",b]),["|","^".padStart(d)],["|",c[s+1]]])}return p+M([[`${i-1} |`,r[n-1]],[`${i} |`,f],["|","^".padStart(o)],[`${i+1} |`,r[n+1]]])}function M(e){let t=e.filter(([u,n])=>n!==void 0),m=Math.max(...t.map(([u])=>u.length));return t.map(([u,n])=>u.padStart(m)+(n?" "+n:"")).join(`
3
+ `)}function me(e){let t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}var v=class e extends Error{constructor(t,...m){var u,n,a;let{nodes:i,source:l,positions:o,path:p,originalError:r,extensions:f}=me(m);super(t),this.name="GraphQLError",this.path=p??void 0,this.originalError=r??void 0,this.nodes=H(Array.isArray(i)?i:i?[i]:void 0);let s=H((u=this.nodes)===null||u===void 0?void 0:u.map(c=>c.loc).filter(c=>c!=null));this.source=l??(s==null||(n=s[0])===null||n===void 0?void 0:n.source),this.positions=o??s?.map(c=>c.start),this.locations=o&&l?o.map(c=>z(l,c)):s?.map(c=>z(c.source,c.start));let d=_(r?.extensions)?r?.extensions:void 0;this.extensions=(a=f??d)!==null&&a!==void 0?a:Object.create(null),Object.defineProperties(this,{message:{writable:true,enumerable:true},name:{enumerable:false},nodes:{enumerable:false},source:{enumerable:false},positions:{enumerable:false},originalError:{enumerable:false}}),r!=null&&r.stack?Object.defineProperty(this,"stack",{value:r.stack,writable:true,configurable:true}):Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:Error().stack,writable:true,configurable:true});}get[Symbol.toStringTag](){return "GraphQLError"}toString(){let t=this.message;if(this.nodes)for(let m of this.nodes)m.loc&&(t+=`
4
4
 
5
- `+j(l.loc));else if(this.source&&this.locations)for(let l of this.locations)t+=`
5
+ `+$(m.loc));else if(this.source&&this.locations)for(let m of this.locations)t+=`
6
6
 
7
- `+q(this.source,l);return t}toJSON(){let t={message:this.message};return this.locations!=null&&(t.locations=this.locations),this.path!=null&&(t.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(t.extensions=this.extensions),t}};function _(e){return e===void 0||e.length===0?void 0:e}var R=class extends Error{constructor(t){super(t),this.name="RumbleError";}},A=class extends B{};var U=(e,t)=>new R(`RumbleError: Unknown SQL type '${e}'. Please open an issue (https://github.com/m1212e/rumble/issues) so it can be added. (${t})`);function K(e){if(["serial","int","integer","tinyint","smallint","mediumint"].includes(e))return {value1:1,value2:2};if(["real","decimal","double","float"].includes(e))return {value1:1.1,value2:2.2};if(["string","text","varchar","char","text(256)"].includes(e))return {value1:"a",value2:"b"};if(["uuid"].includes(e))return {value1:"fba31870-5528-42d7-b27e-2e5ee657aea5",value2:"fc65db81-c2d1-483d-8a25-a30e2cf6e02d"};if(["boolean"].includes(e))return {value1:true,value2:false};if(["timestamp","datetime"].includes(e))return {value1:new Date(2022,1,1),value2:new Date(2022,1,2)};if(["date"].includes(e))return {value1:new Date(2022,1,1),value2:new Date(2022,1,2)};if(["json"].includes(e))return {value1:{a:1},value2:{b:2}};throw U(e,"Distinct")}function me(e){return typeof e!="function"}function ce(e){return typeof e=="function"&&e.constructor.name!=="AsyncFunction"}var M=({db:e,actions:t,defaultLimit:l})=>{let p=e._.schema,n={},d={},i={},y=r=>{for(let s of t)i[r]||(i[r]={}),i[r][s]||(i[r][s]=[]);return {allow:s=>{let o=d[r];o||(o={},d[r]=o);let f=Array.isArray(s)?s:[s];for(let a of f){let c=o[a];c||(c="wildcard",o[a]=c);}return {when:a=>{for(let c of f)o[c]==="wildcard"&&(o[c]=[]),o[c].push(a);}}},filter:s=>{let o=Array.isArray(s)?s:[s];return {by:f=>{for(let a of o)i[r][a].push(f);}}}}};for(let r of Object.keys(e.query))n[r]=y(r);return {...n,registeredConditions:d,registeredFilters:i,buildWithUserContext:r=>{let s={},o=f=>({filter:(a,c)=>{let m=d[f];m||(m={});let x=m[a];if(x==="wildcard")return {single:{where:c?.inject?.where,columns:c?.inject?.columns},many:{where:c?.inject?.where,columns:c?.inject?.columns,limit:c?.inject?.limit??l??void 0}};let C=()=>{let b=p[f].primaryKey.at(0);if(!b)throw new R(`No primary key found for entity ${f.toString()}`);let N=K(b.getSQLType());return {where:and(eq(b,N.value1),eq(b,N.value2))}};(!m||!x)&&(x=[C()]);let T=x.filter(me),u=x.filter(ce).map(b=>b(r)),g=u.some(b=>b==="allow"),h=[...T,...u];h.filter(b=>b!==void 0).length===0&&h.push(C());let S;for(let b of h)b!=="allow"&&b?.limit&&(S===void 0||b.limit>S)&&(S=b.limit);c?.inject?.limit&&S&&S<c.inject.limit&&(S=c.inject.limit);let D;for(let b of [...h,c?.inject??{}])b!=="allow"&&b?.columns&&(D===void 0?D=b.columns:D={...D,...b.columns});let v=g?[]:h.filter(b=>b!=="allow"&&b?.where).map(b=>b?.where),P=v.length>0?or(...v):void 0;return c?.inject?.where&&(P=P?and(P,c.inject.where):c.inject.where),{single:{where:P,columns:D},many:{where:P,columns:D,limit:S??l??void 0}}},explicitFilters:a=>i[f][a]});for(let f of Object.keys(e.query))s[f]=o(f);return s}}};var W=({context:e,abilityBuilder:t})=>async l=>{let p=e?await e(l):{};return {...p,abilities:t.buildWithUserContext(p)}};function E(e){return String(e).charAt(0).toUpperCase()+String(e).slice(1)}function L(e){let t=I(e);return t.enumValues!==void 0&&t.enumName!==void 0&&typeof t.enumName=="string"&&Array.isArray(t.enumValues)}function I(e){return e.enum??e}var J=({db:e,schemaBuilder:t})=>{let l=new Map;return ({enumVariableName:n,name:d,enumName:i})=>{let y=e._.fullSchema,r;if(n?r=y[n]:i&&(r=Object.values(y).filter(L).map(I).find(a=>a.enumName===i)),!r)throw new R(`Could not determine enum structure! (${String(n)}, ${enumValuesParam}, ${i})`);let s=d??`${E(toCamelCase(r.enumName.toString()))}Enum`,o=l.get(s);return o||(o=t.enumType(s,{values:r.enumValues}),l.set(s,o),o)}};function w(e){let t;if(["serial","int","integer","tinyint","smallint","mediumint"].includes(e)&&(t="Int"),["real","decimal","double","float"].includes(e)&&(t="Float"),["string","text","varchar","char","text(256)"].includes(e)&&(t="String"),["uuid"].includes(e)&&(t="ID"),["boolean"].includes(e)&&(t="Boolean"),["timestamp","datetime"].includes(e)&&(t="DateTime"),["date"].includes(e)&&(t="Date"),["json"].includes(e)&&(t="JSON"),t!==void 0)return t;throw U(e,"SQL to GQL")}var de="RUMBLE_SUBSCRIPTION_NOTIFICATION",fe="REMOVED",he="UPDATED",ge="CREATED",H=({subscriptions:e,db:t})=>{let l=e?createPubSub(...e):createPubSub();return {pubsub:l,makePubSubInstance:({tableName:n})=>{function d({action:i,tableName:y,primaryKeyValue:r}){let s;switch(i){case "created":s=ge;break;case "removed":s=fe;break;case "updated":s=he;break;default:throw new Error(`Unknown action: ${i}`)}return `${de}/${y}${r?`/${r}`:""}/${s}`}return {registerOnInstance({instance:i,action:y,primaryKeyValue:r}){let s=d({tableName:n.toString(),action:y,primaryKeyValue:r});i.register(s);},created(){let i=d({tableName:n.toString(),action:"created"});return l.publish(i)},removed(i){let y=d({tableName:n.toString(),action:"removed"});return l.publish(y)},updated(i){let r=(Array.isArray(i)?i:[i]).map(o=>d({tableName:n.toString(),action:"updated",primaryKeyValue:o})),s=Array.from(new Set(r));for(let o of s)l.publish(o);}}}}};var X=({db:e,schemaBuilder:t,makePubSubInstance:l,argImplementer:p,enumImplementer:n,abilityBuilder:d})=>({tableName:i,name:y,readAction:r="read"})=>{let s=e._.schema[i];if(!s)throw new R(`Could not find schema for ${i.toString()} (object)`);let o=s.primaryKey.at(0)?.name;o||console.warn(`Could not find primary key for ${i.toString()}. Cannot register subscriptions!`);let{registerOnInstance:f}=l({tableName:i});return t.drizzleObject(i,{name:y??E(i.toString()),subscribe:(a,c,m)=>{if(!o)return;let x=c[o];if(!x){console.warn(`Could not find primary key value for ${JSON.stringify(c)}. Cannot register subscription!`);return}f({instance:a,action:"updated",primaryKeyValue:x});},applyFilters:d?.registeredFilters?.[i]?.[r],fields:a=>{let c=(C,T,u)=>{let g=w(C);switch(g){case "Int":return a.exposeInt(T,{nullable:u});case "String":return a.exposeString(T,{nullable:u});case "Boolean":return a.exposeBoolean(T,{nullable:u});case "Date":return a.field({type:"Date",resolve:h=>h[T],nullable:u});case "DateTime":return a.field({type:"DateTime",resolve:h=>h[T],nullable:u});case "Float":return a.exposeFloat(T,{nullable:u});case "ID":return a.exposeID(T,{nullable:u});case "JSON":return a.field({type:"JSON",resolve:h=>h[T],nullable:u});default:throw new R(`Unsupported object type ${g} for column ${T}`)}},m=Object.entries(s.columns).reduce((C,[T,u])=>{if(L(u)){let g=I(u),h=n({enumName:g.enumName});C[T]=a.field({type:h,resolve:S=>S[T],nullable:!u.notNull});}else C[T]=c(u.getSQLType(),T,!u.notNull);return C},{}),x=Object.entries(s.relations).reduce((C,[T,u])=>{let {inputType:g,transformArgumentToQueryCondition:h}=p({tableName:u.referencedTableName,nativeTableName:u.referencedTableName}),S=false,v="many";return u instanceof One&&(S=!u.isNullable,v="single"),C[T]=a.relation(T,{args:{where:a.arg({type:g,required:false})},nullable:S,query:(P,b)=>{let N=Object.entries(e._.schema).find(([qe,ie])=>ie.dbName===u.referencedTableName)?.at(0);if(!N)throw new R(`Could not find table ${u.referencedTableName} in schema object`);return b.abilities[N].filter(r,{inject:{where:h(P.where)}})[v]}}),C},{});return {...m,...x}}})};var O=e=>{if(!e)throw new A("Value not found but required (findFirst)");return e},xe=e=>{let t=e.at(0);if(!t)throw new A("Value not found but required (firstEntry)");return t},Z=async({filters:e,entities:t,context:l})=>(await Promise.all(e.map(p=>p({context:l,entities:t})))).reduce((p,n)=>(p.push(...n),p),[]);var ee=({db:e,schemaBuilder:t,argImplementer:l,makePubSubInstance:p})=>({tableName:n,readAction:d="read",listAction:i="read"})=>{let y=e._.schema[n];if(!y)throw new R(`Could not find schema for ${n.toString()} (query)`);y.primaryKey.at(0)?.name||console.warn(`Could not find primary key for ${n.toString()}. Cannot register subscriptions!`);let{inputType:s,transformArgumentToQueryCondition:o}=l({tableName:n}),{registerOnInstance:f}=p({tableName:n});return t.queryFields(a=>({[`findMany${E(n.toString())}`]:a.drizzleField({type:[n],nullable:false,smartSubscription:true,subscribe:(c,m,x,C,T)=>{f({instance:c,action:"created"}),f({instance:c,action:"removed"});},args:{where:a.arg({type:s,required:false})},resolve:(c,m,x,C,T)=>{let u=C.abilities[n].filter(i,{inject:{where:o(x.where)}}).many,g=c(u);return u.columns&&(g.columns=u.columns),e.query[n].findMany(g)}}),[`findFirst${E(n.toString())}`]:a.drizzleField({type:n,nullable:false,smartSubscription:true,args:{where:a.arg({type:s,required:false})},resolve:(c,m,x,C,T)=>{let u=C.abilities[n].filter(d,{inject:{where:o(x.where)}}).single,g=c(u);return u.columns&&(g.columns=u.columns),e.query[n].findFirst(g).then(O)}})}))};var te="ManualFiltersPlugin",ne=te,Se="applyFilters",z=class extends BasePlugin{wrapResolve(t,l){return async(p,n,d,i)=>{let y=(l?.type).type?.ref.currentConfig.pothosOptions[Se];if(!y||!Array.isArray(y)||y.length===0)return t(p,n,d,i);let r=await t(p,n,d,i),s=Array.isArray(r)?r:[r],o=Array.isArray(y)?y:[y],f=await Z({filters:o,entities:s,context:d});return Array.isArray(r)?f:f[0]??null}}};Te.registerPlugin(te,z);var re=({db:e,disableDefaultObjects:t,pubsub:l,pothosConfig:p})=>{let n=new Te({plugins:[ne,De,Ee,...p?.plugins??[]],...p,drizzle:{client:e},smartSubscriptions:{...subscribeOptionsFromIterator((d,i)=>l.subscribe(d))}});return n.addScalarType("JSON",JSONResolver),n.addScalarType("Date",DateResolver),n.addScalarType("DateTime",DateTimeISOResolver),t?.query||n.queryType({}),t?.subscription||n.subscriptionType({}),t?.mutation||n.mutationType({}),{schemaBuilder:n}};var Le=e=>`${E(toCamelCase(e.toString()))}WhereInputArgument`,oe=({db:e,schemaBuilder:t,enumImplementer:l})=>{let p=new Map,n=({tableName:d,name:i,nativeTableName:y})=>{let r=e._.schema[d];if(y){let a=Object.values(e._.schema).find(c=>c.dbName===y);a&&(r=a);}if(!r)throw new R(`Could not find schema for ${d.toString()} (whereArg)`);let s=i??Le(r.dbName),o=p.get(s);return o||(o={inputType:t.inputType(s,{fields:m=>{let x=u=>{let g=w(u);switch(g){case "Int":return m.int({required:false});case "String":return m.string({required:false});case "Boolean":return m.boolean({required:false});case "Date":return m.field({type:"Date",required:false});case "DateTime":return m.field({type:"DateTime",required:false});case "Float":return m.float({required:false});case "ID":return m.id({required:false});case "JSON":return m.field({type:"JSON",required:false});default:throw new R(`Unsupported argument type ${g} for column ${u}`)}},C=Object.entries(r.columns).reduce((u,[g,h])=>{if(L(h)){let S=I(h),D=l({enumName:S.enumName});u[g]=m.field({type:D,required:false});}else u[g]=x(h.getSQLType());return u},{}),T=Object.entries(r.relations).reduce((u,[g,h])=>{let S=n({tableName:h.referencedTableName,nativeTableName:h.referencedTableName});return u[g]=m.field({type:S.inputType,required:false}),u},{});return {...C,...T}}}),transformArgumentToQueryCondition:m=>{if(!m)return;let x=u=>{let g=r.columns[u],h=m[u];if(h)return eq(g,h)},C=u=>{let g=r.relations[u],h=m[u];if(!h)return;let S=n({tableName:g.referencedTableName,nativeTableName:g.referencedTableName}).transformArgumentToQueryCondition;return S(h)},T=[...Object.keys(r.columns).map(x),...Object.keys(r.relations).map(C)];return and(...T)}},p.set(s,o),o)};return n};var we=e=>{e.actions||(e.actions=["read","update","delete"]),e.defaultLimit===void 0&&(e.defaultLimit=100);let t=M(e),l=W({...e,abilityBuilder:t}),{makePubSubInstance:p,pubsub:n}=H({...e}),{schemaBuilder:d}=re({...e,pubsub:n}),i=J({...e,schemaBuilder:d}),y=oe({...e,schemaBuilder:d,enumImplementer:i}),r=X({...e,schemaBuilder:d,makePubSubInstance:p,argImplementer:y,enumImplementer:i,abilityBuilder:t}),s=ee({...e,schemaBuilder:d,argImplementer:y,makePubSubInstance:p});return {abilityBuilder:t,schemaBuilder:d,createYoga:f=>createYoga({...f,schema:d.toSchema(),context:l}),object:r,arg:y,query:s,pubsub:p,enum_:i}};
8
- export{R as RumbleError,A as RumbleErrorSafe,O as assertFindFirstExists,xe as assertFirstEntryExists,we as rumble};//# sourceMappingURL=index.js.map
7
+ `+k(this.source,m);return t}toJSON(){let t={message:this.message};return this.locations!=null&&(t.locations=this.locations),this.path!=null&&(t.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(t.extensions=this.extensions),t}};function H(e){return e===void 0||e.length===0?void 0:e}var C=class extends Error{constructor(t){super(t),this.name="RumbleError";}},F=class extends v{};var O=(e,t)=>new C(`RumbleError: Unknown SQL type '${e}'. Please open an issue (https://github.com/m1212e/rumble/issues) so it can be added. (${t})`);function J(e){if(["serial","int","integer","tinyint","smallint","mediumint"].includes(e))return {value1:1,value2:2};if(["real","decimal","double","float"].includes(e))return {value1:1.1,value2:2.2};if(["string","text","varchar","char","text(256)"].includes(e))return {value1:"a",value2:"b"};if(["uuid"].includes(e))return {value1:"fba31870-5528-42d7-b27e-2e5ee657aea5",value2:"fc65db81-c2d1-483d-8a25-a30e2cf6e02d"};if(["boolean"].includes(e))return {value1:true,value2:false};if(["timestamp","datetime"].includes(e))return {value1:new Date(2022,1,1),value2:new Date(2022,1,2)};if(["date"].includes(e))return {value1:new Date(2022,1,1),value2:new Date(2022,1,2)};if(["json"].includes(e))return {value1:{a:1},value2:{b:2}};throw O(e,"Distinct")}var G=Symbol.for("drizzle:Name"),W=Symbol.for("drizzle:Columns");function E({dbName:e,tsName:t,table:m,db:u}){let n=m;if(t&&(n=u._.relations.schema[t]),e&&(n=Object.values(u._.relations.schema).find(a=>a[G]===e)),!n)throw new C(`Could not find schema for ${JSON.stringify({tsName:t,dbName:e,table:m?.[G]}).toString()}`);return {tableSchema:n,columns:n[W],get primaryColumns(){return Object.entries(n[W]).filter(([a,i])=>i.primary).reduce((a,[i,l])=>(a[i]=l,a),{})},relations:u._.relations.config[t],dbName:n[G],get tsName(){return Object.entries(u._.relations.schema).find(([a,i])=>i===n).at(0)}}}function fe(e){return typeof e!="function"}function Te(e){return typeof e=="function"&&e.constructor.name!=="AsyncFunction"}var Y=({db:e,actions:t,defaultLimit:m})=>{let u={},n={},a={},i=l=>{for(let o of t)a[l]||(a[l]={}),a[l][o]||(a[l][o]=[]);return {allow:o=>{let p=n[l];p||(p={},n[l]=p);let r=Array.isArray(o)?o:[o];for(let f of r){let s=p[f];s||(s="unspecified",p[f]=s);}return {when:f=>{for(let s of r)p[s]==="unspecified"&&(p[s]=[]),p[s].push(f);}}},filter:o=>{let p=Array.isArray(o)?o:[o];return {by:r=>{for(let f of p)a[l][f].push(r);}}}}};for(let l of Object.keys(e.query))u[l]=i(l);return {...u,registeredQueryFilters:n,registeredFilters:a,buildWithUserContext:l=>{let o={},p=r=>({filter:(f,s)=>{let d=y=>{let B=N(()=>{if(!(!y?.where&&!s?.inject?.where))return s?.inject?.where?{AND:[y?.where,s?.inject?.where]}:y?.where}),A=N(()=>{let P=B();if(!P)return;let ue=E({tsName:r,db:e});return relationsFilterToSQL(ue.tableSchema,P)}),q=N(()=>{let P=y?.limit??m;return s?.inject?.limit&&(!P||P>s.inject.limit)&&(P=s.inject.limit),y?.limit&&(!P||y.limit>P)&&(P=y.limit),P??void 0}),w=N(()=>{if(!(!y?.columns&&!s?.inject?.columns))return {...y?.columns,...s?.inject?.columns}});return {query:{single:{get where(){return B()},get columns(){return w()}},many:{get where(){return B()},get columns(){return w()},get limit(){return q()}}},sql:{get where(){return A()},get columns(){return w()},get limit(){return q()}}}},c=()=>{let y=E({db:e,tsName:r});if(Object.keys(y.primaryColumns).length===0)throw new C(`No primary key found for entity ${r.toString()}`);let B=Object.values(y.primaryColumns)[0],A=J(B.getSQLType());return {where:{AND:[{[B.name]:A.value1},{[B.name]:A.value2}]}}},b=n?.[r]?.[f];if(b==="unspecified")return d();b||(b=[c()]);let x=b.filter(fe),D=b.filter(Te).map(y=>y(l)),h=D.some(y=>y==="allow"),T=[...x,...D].filter(y=>y!==void 0).filter(y=>y!=="allow");!h&&T.length===0&&(T=[c()]);let g;for(let y of T)y?.limit&&(g===void 0||y.limit>g)&&(g=y.limit);let S;for(let y of [...T,s?.inject])y?.columns&&(S===void 0?S=y.columns:S={...S,...y.columns});let R=h?[]:T.filter(y=>y?.where).map(y=>y.where),L=R.length>0?{OR:R}:void 0;return d({where:L,columns:S,limit:g})},explicitFilters:f=>a[r][f]});for(let r of Object.keys(e.query))o[r]=p(r);return o}}};var X=({context:e,abilityBuilder:t})=>async m=>{let u=e?await e(m):{};return {...u,abilities:t.buildWithUserContext(u)}};function I(e){return String(e).charAt(0).toUpperCase()+String(e).slice(1)}function U(e){return e instanceof PgEnumColumn}var Z=({db:e,schemaBuilder:t})=>{let m=new Map;return ({tsName:n,enumColumn:a,refName:i})=>{let l,o;if(n){let s=E({db:e,tsName:n});l=n.toString();let d=Object.values(e._.relations.schema).filter(c=>typeof c=="object").map(c=>Object.values(c[Symbol.for("drizzle:Columns")])).flat(2).find(c=>c.config?.enum===s);if(!d)throw new C(`Could not find applied enum column for ${n.toString()}.
8
+ Please ensure that you use the enum at least once as a column of a table!`);o=d.enumValues;}else if(a){let s=Object.entries(e._.relations.schema).find(([d,c])=>c===a.config.enum);if(!s)throw new C(`Could not find enum in schema for ${a.name}!`);l=s[0],o=a.enumValues;}if(!l||!o)throw new C("Could not determine enum structure!");let p=i??`${I(toCamelCase(l))}Enum`,r=m.get(p);return r||(r=t.enumType(p,{values:o}),m.set(p,r),r)}};function Q(e){let t;if(["serial","int","integer","tinyint","smallint","mediumint"].includes(e)&&(t="Int"),["real","decimal","double","float"].includes(e)&&(t="Float"),["string","text","varchar","char","text(256)"].includes(e)&&(t="String"),["uuid"].includes(e)&&(t="ID"),["boolean"].includes(e)&&(t="Boolean"),["timestamp","datetime"].includes(e)&&(t="DateTime"),["date"].includes(e)&&(t="Date"),["json"].includes(e)&&(t="JSON"),t!==void 0)return t;throw O(e,"SQL to GQL")}var ee=({db:e,schemaBuilder:t,makePubSubInstance:m,argImplementer:u,enumImplementer:n,abilityBuilder:a})=>({table:i,refName:l,readAction:o="read",extend:p})=>{let r=E({db:e,tsName:i});Object.keys(r.primaryColumns).length===0&&console.warn(`Could not find primary key for ${i.toString()}. Cannot register subscriptions!`);let f=Object.values(r.primaryColumns)[0],{registerOnInstance:s}=m({table:i});return t.drizzleObject(i,{name:l??I(i.toString()),subscribe:(d,c,b)=>{if(!f)return;let x=c[f.name];if(!x){console.warn(`Could not find primary key value for ${JSON.stringify(c)}. Cannot register subscription!`);return}s({instance:d,action:"updated",primaryKeyValue:x});},applyFilters:a?.registeredFilters?.[i]?.[o],fields:d=>{let c=r.columns,b=(h,T,g)=>{let S=Q(h);switch(S){case "Int":return d.exposeInt(T,{nullable:g});case "String":return d.exposeString(T,{nullable:g});case "Boolean":return d.exposeBoolean(T,{nullable:g});case "Date":return d.field({type:"Date",resolve:R=>R[T],nullable:g});case "DateTime":return d.field({type:"DateTime",resolve:R=>R[T],nullable:g});case "Float":return d.exposeFloat(T,{nullable:g});case "ID":return d.exposeID(T,{nullable:g});case "JSON":return d.field({type:"JSON",resolve:R=>R[T],nullable:g});default:throw new C(`Unsupported object type ${S} for column ${T}`)}},x=Object.entries(c).reduce((h,[T,g])=>{if(U(g)){let S=n({enumColumn:g});h[T]=d.field({type:S,resolve:R=>R[T],nullable:!g.notNull});}else h[T]=b(g.getSQLType(),T,!g.notNull);return h},{}),D=Object.entries(r.relations).reduce((h,[T,g])=>{let S=E({db:e,table:g.targetTable}),R=u({dbName:S.dbName}),L=false,B="many";return g instanceof One&&(L=g.optional,B="single"),h[T]=d.relation(T,{args:{where:d.arg({type:R,required:false})},nullable:L,query:(A,q)=>q.abilities[S.tsName].filter(o,{inject:{where:A.where}}).query[B]}),h},{});return p?{...x,...D,...p(d)??{}}:{...x,...D}}})};var he="RUMBLE_SUBSCRIPTION_NOTIFICATION",Ce="REMOVED",De="UPDATED",Se="CREATED",ne=({subscriptions:e,db:t})=>{let m=e?createPubSub(...e):createPubSub();return {pubsub:m,makePubSubInstance:({table:n})=>{function a({action:i,tableName:l,primaryKeyValue:o}){let p;switch(i){case "created":p=Se;break;case "removed":p=Ce;break;case "updated":p=De;break;default:throw new Error(`Unknown action: ${i}`)}return `${he}/${l}${o?`/${o}`:""}/${p}`}return {registerOnInstance({instance:i,action:l,primaryKeyValue:o}){let p=a({tableName:n.toString(),action:l,primaryKeyValue:o});i.register(p);},created(){let i=a({tableName:n.toString(),action:"created"});return m.publish(i)},removed(i){let l=a({tableName:n.toString(),action:"removed"});return m.publish(l)},updated(i){let o=(Array.isArray(i)?i:[i]).map(r=>a({tableName:n.toString(),action:"updated",primaryKeyValue:r})),p=Array.from(new Set(o));for(let r of p)m.publish(r);}}}}};var j=e=>{if(!e)throw new F("Value not found but required (findFirst)");return e},Re=e=>{let t=e.at(0);if(!t)throw new F("Value not found but required (firstEntry)");return t},re=async({filters:e,entities:t,context:m})=>(await Promise.all(e.map(u=>u({context:m,entities:t})))).reduce((u,n)=>(u.push(...n),u),[]);var ie=({db:e,schemaBuilder:t,argImplementer:m,makePubSubInstance:u})=>({table:n,readAction:a="read",listAction:i="read"})=>{let l=m({table:n}),{registerOnInstance:o}=u({table:n});return t.queryFields(p=>({[`findMany${I(n.toString())}`]:p.drizzleField({type:[n],nullable:false,smartSubscription:true,subscribe:(r,f,s,d,c)=>{o({instance:r,action:"created"}),o({instance:r,action:"removed"});},args:{where:p.arg({type:l,required:false})},resolve:(r,f,s,d,c)=>{let b=d.abilities[n].filter(i,{inject:{where:s.where}}).query.many,x=r(b);return b.columns&&(x.columns=b.columns),e.query[n].findMany(x)}}),[`findFirst${I(n.toString())}`]:p.drizzleField({type:n,nullable:false,smartSubscription:true,args:{where:p.arg({type:l,required:false})},resolve:(r,f,s,d,c)=>{let b=d.abilities[n].filter(a,{inject:{where:s.where}}).query.single,x=r(b);return b.columns&&(x.columns=b.columns),e.query[n].findFirst(x).then(j)}})}))};var oe="ManualFiltersPlugin",se=oe,Pe="applyFilters",K=class extends BasePlugin{wrapResolve(t,m){return async(u,n,a,i)=>{let l=(m?.type).type?.ref.currentConfig.pothosOptions[Pe];if(!l||!Array.isArray(l)||l.length===0)return t(u,n,a,i);let o=await t(u,n,a,i),p=Array.isArray(o)?o:[o],r=Array.isArray(l)?l:[l],f=await re({filters:r,entities:p,context:a});return Array.isArray(o)?f:f[0]??null}}};Ee.registerPlugin(oe,K);var ae=({db:e,disableDefaultObjects:t,pubsub:m,pothosConfig:u})=>{let n=new Ee({plugins:[se,Ae,ve,...u?.plugins??[]],...u,drizzle:{client:e,relations:e._.relations,getTableConfig(a){return {columns:Object.values(a[Symbol.for("drizzle:Columns")]),primaryKeys:Object.values(a[Symbol.for("drizzle:Columns")]).filter(i=>i.primary)}}},smartSubscriptions:{...subscribeOptionsFromIterator((a,i)=>m.subscribe(a))}});return n.addScalarType("JSON",JSONResolver),n.addScalarType("Date",DateResolver),n.addScalarType("DateTime",DateTimeISOResolver),t?.query||n.queryType({}),t?.subscription||n.subscriptionType({}),t?.mutation||n.mutationType({}),{schemaBuilder:n}};var Oe=e=>`${I(toCamelCase(e.toString()))}WhereInputArgument`,le=({db:e,schemaBuilder:t,enumImplementer:m})=>{let u=new Map,n=({table:a,refName:i,dbName:l})=>{let o=E({db:e,dbName:l,tsName:a}),p=i??Oe(o.tsName),r=u.get(p);return r||(r=t.inputType(p,{fields:s=>{let d=x=>{let D=Q(x);switch(D){case "Int":return s.int({required:false});case "String":return s.string({required:false});case "Boolean":return s.boolean({required:false});case "Date":return s.field({type:"Date",required:false});case "DateTime":return s.field({type:"DateTime",required:false});case "Float":return s.float({required:false});case "ID":return s.id({required:false});case "JSON":return s.field({type:"JSON",required:false});default:throw new C(`Unsupported argument type ${D} for column ${x}`)}},c=Object.entries(o.columns).reduce((x,[D,h])=>{if(U(h)){let T=m({enumColumn:h});x[D]=s.field({type:T,required:false});}else x[D]=d(h.getSQLType());return x},{}),b=Object.entries(o.relations).reduce((x,[D,h])=>{let T=E({db:e,table:h.targetTable}),g=n({dbName:T.dbName});return x[D]=s.field({type:g,required:false}),x},{});return {...c,...b}}}),u.set(p,r),r)};return n};var Qe=e=>{e.actions||(e.actions=["read","update","delete"]),e.defaultLimit===void 0&&(e.defaultLimit=100);let t=Y(e),m=X({...e,abilityBuilder:t}),{makePubSubInstance:u,pubsub:n}=ne({...e}),{schemaBuilder:a}=ae({...e,pubsub:n}),i=Z({...e,schemaBuilder:a}),l=le({...e,schemaBuilder:a,enumImplementer:i}),o=ee({...e,schemaBuilder:a,makePubSubInstance:u,argImplementer:l,enumImplementer:i,abilityBuilder:t}),p=ie({...e,schemaBuilder:a,argImplementer:l,makePubSubInstance:u});return {abilityBuilder:t,schemaBuilder:a,createYoga:f=>createYoga({...f,schema:a.toSchema(),context:m}),object:o,arg:l,query:p,pubsub:u,enum_:i}};export{C as RumbleError,F as RumbleErrorSafe,j as assertFindFirstExists,Re as assertFirstEntryExists,Qe as rumble};//# sourceMappingURL=index.js.map
9
9
  //# sourceMappingURL=index.js.map