@m1212e/rumble 0.23.10 → 0.23.13

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/out/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { GraphQLError, GraphQLSchema } from "graphql";
2
+ import { Table } from "drizzle-orm";
2
3
  import { MySqlAsyncDatabase } from "drizzle-orm/mysql-core";
3
4
  import { PgAsyncDatabase } from "drizzle-orm/pg-core";
4
5
  import { SQLiteAsyncDatabase } from "drizzle-orm/sqlite-core";
@@ -153,6 +154,12 @@ type DrizzleInstance = PgAsyncDatabase<any, any> | SQLiteAsyncDatabase<any, any,
153
154
  * Type representing the query function of a Drizzle instance.
154
155
  */
155
156
  type DrizzleQueryFunction<DB extends DrizzleInstance> = DB["query"];
157
+ /**
158
+ * Names of relations backed by a genuine drizzle Table
159
+ */
160
+ type TableRelationNames<DB extends DrizzleInstance> = { [K in keyof DB["_"]["relations"]]: DB["_"]["relations"][K] extends {
161
+ table: infer TTable;
162
+ } ? TTable extends Table<any> ? K : never : never }[keyof DB["_"]["relations"]] & keyof DrizzleQueryFunction<DB>;
156
163
  /**
157
164
  * Type representing the input parameters for the `findMany` method of a specific table in the Drizzle query function.
158
165
  */
@@ -4369,7 +4376,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4369
4376
  *
4370
4377
  * ```
4371
4378
  */
4372
- abilityBuilder: (keyof DrizzleQueryFunction<DB> extends infer T extends keyof DrizzleQueryFunction<DB> ? { [key in T]: {
4379
+ abilityBuilder: { [key in TableRelationNames<DB>]: {
4373
4380
  allow: (action: Action | Action[]) => {
4374
4381
  when: (queryFilter: DrizzleQueryFunctionInput<DB, key> | ((context: UserContext) => DrizzleQueryFunctionInput<DB, key> | "allow" | undefined)) => void;
4375
4382
  };
@@ -4383,16 +4390,16 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4383
4390
  runtimeFilters: Map<Action, FilterPrefetchCombo<UserContext, any, any>[]>;
4384
4391
  queryFilters: Map<Action, "unrestricted" | (DrizzleQueryFunctionInput<DB, key> | ((context: UserContext) => DrizzleQueryFunctionInput<DB, key> | "allow" | undefined))[]>;
4385
4392
  };
4386
- } } : never) & {
4393
+ } } & {
4387
4394
  _: {
4388
4395
  registeredFilters({
4389
4396
  action,
4390
4397
  table
4391
4398
  }: {
4392
- table: keyof DrizzleQueryFunction<DB>;
4399
+ table: TableRelationNames<DB>;
4393
4400
  action: Action;
4394
- }): Filter<UserContext, DrizzleTableValueType<DB, keyof DrizzleQueryFunction<DB>>>[];
4395
- build(): (ctx: UserContext) => keyof DrizzleQueryFunction<DB> extends infer T_1 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_1]: {
4401
+ }): Filter<UserContext, DrizzleTableValueType<DB, TableRelationNames<DB>>>[];
4402
+ build(): (ctx: UserContext) => { [key_1 in TableRelationNames<DB>]: {
4396
4403
  filter: (action: Action) => {
4397
4404
  query: {
4398
4405
  single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
@@ -4412,7 +4419,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4412
4419
  };
4413
4420
  };
4414
4421
  };
4415
- } } : never;
4422
+ } };
4416
4423
  };
4417
4424
  };
4418
4425
  /**
@@ -4420,7 +4427,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4420
4427
  */
4421
4428
  schemaBuilder: PothosSchemaTypes.SchemaBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
4422
4429
  Context: Awaited<UserContext & {
4423
- abilities: keyof DrizzleQueryFunction<DB> extends infer T_1 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_1]: {
4430
+ abilities: { [key_1 in TableRelationNames<DB>]: {
4424
4431
  filter: (action: Action) => {
4425
4432
  query: {
4426
4433
  single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
@@ -4440,7 +4447,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4440
4447
  };
4441
4448
  };
4442
4449
  };
4443
- } } : never;
4450
+ } };
4444
4451
  }>;
4445
4452
  DrizzleRelations: DB["_"]["relations"];
4446
4453
  Scalars: {
@@ -4551,7 +4558,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4551
4558
  /**
4552
4559
  * A function for creating default objects for your schema
4553
4560
  */
4554
- object: <TableName extends keyof DrizzleQueryFunction<DB>, RefName extends string>({
4561
+ object: <TableName extends TableRelationNames<DB>, RefName extends string>({
4555
4562
  table,
4556
4563
  refName,
4557
4564
  readAction,
@@ -4562,7 +4569,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4562
4569
  readAction?: Action | undefined;
4563
4570
  adjust?: ((t: import("@pothos/plugin-drizzle").DrizzleObjectFieldBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
4564
4571
  Context: Awaited<UserContext & {
4565
- abilities: keyof DrizzleQueryFunction<DB> extends infer T_2 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_2]: {
4572
+ abilities: { [key_1 in TableRelationNames<DB>]: {
4566
4573
  filter: (action: Action) => {
4567
4574
  query: {
4568
4575
  single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
@@ -4582,7 +4589,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4582
4589
  };
4583
4590
  };
4584
4591
  };
4585
- } } : never;
4592
+ } };
4586
4593
  }>;
4587
4594
  DrizzleRelations: DB["_"]["relations"];
4588
4595
  Scalars: {
@@ -4635,10 +4642,10 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4635
4642
  _: {
4636
4643
  brand: "Table";
4637
4644
  };
4638
- }>["_"]["columns"][Key]["_"]["data"] | null } extends infer T_3 ? { [K in keyof T_3]: T_3[K] } : never>) => import("@pothos/core").FieldMap) | undefined;
4645
+ }>["_"]["columns"][Key]["_"]["data"] | null } extends infer T ? { [K in keyof T]: T[K] } : never>) => import("@pothos/core").FieldMap) | undefined;
4639
4646
  }) => import("@pothos/plugin-drizzle").DrizzleObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
4640
4647
  Context: Awaited<UserContext & {
4641
- abilities: keyof DrizzleQueryFunction<DB> extends infer T_2 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_2]: {
4648
+ abilities: { [key_1 in TableRelationNames<DB>]: {
4642
4649
  filter: (action: Action) => {
4643
4650
  query: {
4644
4651
  single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
@@ -4658,7 +4665,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4658
4665
  };
4659
4666
  };
4660
4667
  };
4661
- } } : never;
4668
+ } };
4662
4669
  }>;
4663
4670
  DrizzleRelations: DB["_"]["relations"];
4664
4671
  Scalars: {
@@ -4733,7 +4740,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4733
4740
  table: TableName;
4734
4741
  })) => PothosSchemaTypes.InputObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
4735
4742
  Context: Awaited<UserContext & {
4736
- abilities: keyof DrizzleQueryFunction<DB> extends infer T_2 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_2]: {
4743
+ abilities: { [key_1 in TableRelationNames<DB>]: {
4737
4744
  filter: (action: Action) => {
4738
4745
  query: {
4739
4746
  single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
@@ -4753,7 +4760,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4753
4760
  };
4754
4761
  };
4755
4762
  };
4756
- } } : never;
4763
+ } };
4757
4764
  }>;
4758
4765
  DrizzleRelations: DB["_"]["relations"];
4759
4766
  Scalars: {
@@ -4797,7 +4804,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4797
4804
  * A function for creating default READ queries.
4798
4805
  * Make sure the objects for the table you are creating the queries for are implemented
4799
4806
  */
4800
- query: <TableName_1 extends keyof DrizzleQueryFunction<DB>>({
4807
+ query: <TableName_1 extends TableRelationNames<DB>>({
4801
4808
  table,
4802
4809
  readAction,
4803
4810
  listAction,
@@ -4862,7 +4869,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4862
4869
  enum?: never;
4863
4870
  })) => PothosSchemaTypes.EnumRef<PothosSchemaTypes.ExtendDefaultTypes<{
4864
4871
  Context: Awaited<UserContext & {
4865
- abilities: keyof DrizzleQueryFunction<DB> extends infer T_2 extends keyof DrizzleQueryFunction<DB> ? { [key_1 in T_2]: {
4872
+ abilities: { [key_1 in TableRelationNames<DB>]: {
4866
4873
  filter: (action: Action) => {
4867
4874
  query: {
4868
4875
  single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key_1]["findFirst"]>[0]>>, "where">;
@@ -4882,7 +4889,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4882
4889
  };
4883
4890
  };
4884
4891
  };
4885
- } } : never;
4892
+ } };
4886
4893
  }>;
4887
4894
  DrizzleRelations: DB["_"]["relations"];
4888
4895
  Scalars: {
@@ -4919,9 +4926,9 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4919
4926
  JSONWhereInputArgument: JSONWhereInputArgument;
4920
4927
  };
4921
4928
  DefaultFieldNullability: false;
4922
- }>, [EnumColumn] extends [never] ? [EnumArg] extends [never] ? [TsName] extends [never] ? string : TsName extends keyof Schema ? (Schema[TsName] extends infer T_3 ? T_3 extends Schema[TsName] ? T_3 extends import("drizzle-orm/pg-core").PgEnum<infer V extends [string, ...string[]]> ? V : T_3 extends import("drizzle-orm/pg-core").PgEnumObject<infer O extends object> ? readonly (O[keyof O] & string)[] : readonly [string, ...string[]] : never : never)[number] : string : (EnumArg extends import("drizzle-orm/pg-core").PgEnum<infer V extends [string, ...string[]]> ? V : EnumArg extends import("drizzle-orm/pg-core").PgEnumObject<infer O extends object> ? readonly (O[keyof O] & string)[] : readonly [string, ...string[]])[number] : EnumColumn extends {
4929
+ }>, [EnumColumn] extends [never] ? [EnumArg] extends [never] ? [TsName] extends [never] ? string : TsName extends keyof Schema ? (Schema[TsName] extends infer T ? T extends Schema[TsName] ? T extends import("drizzle-orm/pg-core").PgEnum<infer V extends [string, ...string[]]> ? V : T extends import("drizzle-orm/pg-core").PgEnumObject<infer O extends object> ? readonly (O[keyof O] & string)[] : readonly [string, ...string[]] : never : never)[number] : string : (EnumArg extends import("drizzle-orm/pg-core").PgEnum<infer V extends [string, ...string[]]> ? V : EnumArg extends import("drizzle-orm/pg-core").PgEnumObject<infer O extends object> ? readonly (O[keyof O] & string)[] : readonly [string, ...string[]])[number] : EnumColumn extends {
4923
4930
  enumValues: infer CV extends readonly [string, ...string[]];
4924
- } ? CV[number] : string, [EnumColumn] extends [never] ? [EnumArg] extends [never] ? [TsName] extends [never] ? string : TsName extends keyof Schema ? (Schema[TsName] extends infer T_4 ? T_4 extends Schema[TsName] ? T_4 extends import("drizzle-orm/pg-core").PgEnum<infer V extends [string, ...string[]]> ? V : T_4 extends import("drizzle-orm/pg-core").PgEnumObject<infer O extends object> ? readonly (O[keyof O] & string)[] : readonly [string, ...string[]] : never : never)[number] : string : (EnumArg extends import("drizzle-orm/pg-core").PgEnum<infer V extends [string, ...string[]]> ? V : EnumArg extends import("drizzle-orm/pg-core").PgEnumObject<infer O extends object> ? readonly (O[keyof O] & string)[] : readonly [string, ...string[]])[number] : EnumColumn extends {
4931
+ } ? CV[number] : string, [EnumColumn] extends [never] ? [EnumArg] extends [never] ? [TsName] extends [never] ? string : TsName extends keyof Schema ? (Schema[TsName] extends infer T_1 ? T_1 extends Schema[TsName] ? T_1 extends import("drizzle-orm/pg-core").PgEnum<infer V extends [string, ...string[]]> ? V : T_1 extends import("drizzle-orm/pg-core").PgEnumObject<infer O extends object> ? readonly (O[keyof O] & string)[] : readonly [string, ...string[]] : never : never)[number] : string : (EnumArg extends import("drizzle-orm/pg-core").PgEnum<infer V extends [string, ...string[]]> ? V : EnumArg extends import("drizzle-orm/pg-core").PgEnumObject<infer O extends object> ? readonly (O[keyof O] & string)[] : readonly [string, ...string[]])[number] : EnumColumn extends {
4925
4932
  enumValues: infer CV extends readonly [string, ...string[]];
4926
4933
  } ? CV[number] : string>;
4927
4934
  /**
@@ -4948,7 +4955,7 @@ declare const rumble: <UserContext extends Record<string, any>, DB extends Drizz
4948
4955
  /**
4949
4956
  * A function for creating count queries for your tables
4950
4957
  */
4951
- countQuery: <TableName_1 extends keyof DrizzleQueryFunction<DB>>({
4958
+ countQuery: <TableName_1 extends TableRelationNames<DB>>({
4952
4959
  table,
4953
4960
  listAction,
4954
4961
  isAllowed