arkormx 2.0.0-next.2 → 2.0.0-next.21

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/dist/index.d.cts CHANGED
@@ -3,6 +3,113 @@ import { PrismaClient } from "@prisma/client";
3
3
  import { Collection } from "@h3ravel/collect.js";
4
4
  import { Command } from "@h3ravel/musket";
5
5
 
6
+ //#region src/types/migrations.d.ts
7
+ type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'boolean' | 'json' | 'date' | 'timestamp';
8
+ interface PrimaryKeyGeneration {
9
+ strategy: 'uuid';
10
+ prismaDefault?: string;
11
+ databaseDefault?: string;
12
+ runtimeFactory?: 'uuid';
13
+ }
14
+ interface TimestampColumnBehavior {
15
+ column: string;
16
+ default?: 'now()';
17
+ updatedAt?: boolean;
18
+ }
19
+ interface SchemaColumn {
20
+ name: string;
21
+ type: SchemaColumnType;
22
+ enumName?: string;
23
+ enumValues?: string[];
24
+ map?: string;
25
+ nullable?: boolean;
26
+ unique?: boolean;
27
+ primary?: boolean;
28
+ autoIncrement?: boolean;
29
+ after?: string;
30
+ default?: unknown;
31
+ updatedAt?: boolean;
32
+ primaryKeyGeneration?: PrimaryKeyGeneration;
33
+ }
34
+ interface SchemaIndex {
35
+ columns: string[];
36
+ name?: string;
37
+ }
38
+ type SchemaForeignKeyAction = 'cascade' | 'restrict' | 'setNull' | 'noAction' | 'setDefault';
39
+ interface SchemaForeignKey {
40
+ column: string;
41
+ referencesTable: string;
42
+ referencesColumn: string;
43
+ onDelete?: SchemaForeignKeyAction;
44
+ relationAlias?: string;
45
+ inverseRelationAlias?: string;
46
+ fieldAlias?: string;
47
+ }
48
+ interface SchemaTableCreateOperation {
49
+ type: 'createTable';
50
+ table: string;
51
+ columns: SchemaColumn[];
52
+ indexes: SchemaIndex[];
53
+ foreignKeys: SchemaForeignKey[];
54
+ }
55
+ interface SchemaTableAlterOperation {
56
+ type: 'alterTable';
57
+ table: string;
58
+ addColumns: SchemaColumn[];
59
+ dropColumns: string[];
60
+ addIndexes: SchemaIndex[];
61
+ addForeignKeys: SchemaForeignKey[];
62
+ }
63
+ interface SchemaTableDropOperation {
64
+ type: 'dropTable';
65
+ table: string;
66
+ }
67
+ type SchemaOperation = SchemaTableCreateOperation | SchemaTableAlterOperation | SchemaTableDropOperation;
68
+ interface GenerateMigrationOptions {
69
+ directory?: string;
70
+ extension?: 'ts' | 'js';
71
+ write?: boolean;
72
+ }
73
+ interface GeneratedMigrationFile {
74
+ fileName: string;
75
+ filePath: string;
76
+ className: string;
77
+ content: string;
78
+ }
79
+ interface PrismaSchemaSyncOptions {
80
+ schemaPath?: string;
81
+ write?: boolean;
82
+ }
83
+ interface PrismaMigrationWorkflowOptions extends PrismaSchemaSyncOptions {
84
+ cwd?: string;
85
+ runGenerate?: boolean;
86
+ runMigrate?: boolean;
87
+ migrateMode?: 'dev' | 'deploy';
88
+ migrationName?: string;
89
+ }
90
+ type MigrationInstanceLike = {
91
+ up: (...args: any[]) => Promise<void> | void;
92
+ down: (...args: any[]) => Promise<void> | void;
93
+ };
94
+ interface AppliedMigrationEntry {
95
+ id: string;
96
+ file: string;
97
+ className: string;
98
+ appliedAt: string;
99
+ checksum?: string;
100
+ }
101
+ interface AppliedMigrationRun {
102
+ id: string;
103
+ appliedAt: string;
104
+ migrationIds: string[];
105
+ }
106
+ interface AppliedMigrationsState {
107
+ version: 1;
108
+ migrations: AppliedMigrationEntry[];
109
+ runs?: AppliedMigrationRun[];
110
+ }
111
+ type MigrationClass = new () => MigrationInstanceLike;
112
+ //#endregion
6
113
  //#region src/types/core.d.ts
7
114
  type CastType = 'string' | 'number' | 'boolean' | 'date' | 'json' | 'array';
8
115
  interface CastHandler<T = unknown> {
@@ -29,6 +136,26 @@ interface ArkormBootContext {
29
136
  prisma?: PrismaClientLike;
30
137
  bindAdapter: (adapter: DatabaseAdapter, models: AdapterBindableModel[]) => DatabaseAdapter;
31
138
  }
139
+ interface AdapterQueryInspection {
140
+ adapter: string;
141
+ operation: string;
142
+ target?: string;
143
+ sql?: string;
144
+ parameters?: ReadonlyArray<unknown>;
145
+ detail?: Record<string, unknown>;
146
+ }
147
+ interface ArkormDebugEvent {
148
+ type: 'query';
149
+ phase: 'before' | 'after' | 'error';
150
+ adapter: string;
151
+ operation: string;
152
+ target?: string;
153
+ inspection?: AdapterQueryInspection | null;
154
+ meta?: Record<string, unknown>;
155
+ durationMs?: number;
156
+ error?: unknown;
157
+ }
158
+ type ArkormDebugHandler = (event: ArkormDebugEvent) => void;
32
159
  interface ArkormConfig {
33
160
  /**
34
161
  * @property prisma Optional Prisma client instance or resolver used for compatibility, CLI flows, and Prisma-backed transactions.
@@ -42,6 +169,11 @@ interface ArkormConfig {
42
169
  * @property boot Optional synchronous runtime boot hook for central adapter binding.
43
170
  */
44
171
  boot?: (context: ArkormBootContext) => void;
172
+ /**
173
+ * @property debug Optional runtime query debugging. `true` logs through Arkorm's default logger;
174
+ * a callback receives structured debug events for custom handling.
175
+ */
176
+ debug?: boolean | ArkormDebugHandler;
45
177
  /**
46
178
  * @property pagination Configuration options related to pagination behavior and URL generation.
47
179
  */
@@ -49,6 +181,21 @@ interface ArkormConfig {
49
181
  urlDriver?: PaginationURLDriverFactory;
50
182
  resolveCurrentPage?: PaginationCurrentPageResolver;
51
183
  };
184
+ /**
185
+ * @property features Optional feature flags for persisted non-Prisma runtime metadata.
186
+ */
187
+ features?: {
188
+ /**
189
+ * @property persistedColumnMappings Persist migration-defined column mappings for non-Prisma adapters.
190
+ * Defaults to true.
191
+ */
192
+ persistedColumnMappings?: boolean;
193
+ /**
194
+ * @property persistedEnums Persist migration-defined enum values for non-Prisma adapters.
195
+ * Defaults to true.
196
+ */
197
+ persistedEnums?: boolean;
198
+ };
52
199
  /**
53
200
  * @property paths Optional custom paths for various generated files.
54
201
  */
@@ -210,11 +357,17 @@ type Serializable = Record<string, unknown>;
210
357
  //#endregion
211
358
  //#region src/types/metadata.d.ts
212
359
  type ColumnMap = Record<string, string>;
360
+ interface PivotModelStatic {
361
+ new (attributes?: Record<string, unknown>): any;
362
+ hydrate?: (attributes: Record<string, unknown>) => any;
363
+ }
213
364
  interface ModelMetadata {
214
365
  table: string;
215
366
  primaryKey: string;
216
367
  columns: ColumnMap;
217
368
  softDelete: SoftDeleteConfig;
369
+ primaryKeyGeneration?: PrimaryKeyGeneration;
370
+ timestampColumns?: TimestampColumnBehavior[];
218
371
  }
219
372
  type RelationMetadataType = 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany' | 'hasOneThrough' | 'hasManyThrough' | 'morphOne' | 'morphMany' | 'morphToMany';
220
373
  interface BaseRelationMetadata {
@@ -243,6 +396,12 @@ interface BelongsToManyRelationMetadata extends BaseRelationMetadata {
243
396
  relatedPivotKey: string;
244
397
  parentKey: string;
245
398
  relatedKey: string;
399
+ pivotAccessor?: string;
400
+ pivotColumns?: string[];
401
+ pivotCreatedAtColumn?: string;
402
+ pivotUpdatedAtColumn?: string;
403
+ pivotWhere?: QueryCondition;
404
+ pivotModel?: PivotModelStatic;
246
405
  }
247
406
  interface HasOneThroughRelationMetadata extends BaseRelationMetadata {
248
407
  type: 'hasOneThrough';
@@ -286,6 +445,22 @@ interface MorphToManyRelationMetadata extends BaseRelationMetadata {
286
445
  }
287
446
  type RelationMetadata = HasOneRelationMetadata | HasManyRelationMetadata | BelongsToRelationMetadata | BelongsToManyRelationMetadata | HasOneThroughRelationMetadata | HasManyThroughRelationMetadata | MorphOneRelationMetadata | MorphManyRelationMetadata | MorphToManyRelationMetadata;
288
447
  //#endregion
448
+ //#region src/types/db.d.ts
449
+ interface DatabaseTablePersistedMetadataOptions {
450
+ cwd?: string;
451
+ configuredPath?: string;
452
+ strict?: boolean;
453
+ }
454
+ interface DatabaseTableOptions {
455
+ adapter?: DatabaseAdapter;
456
+ primaryKey?: string;
457
+ columns?: Record<string, string>;
458
+ softDelete?: SoftDeleteConfig;
459
+ primaryKeyGeneration?: PrimaryKeyGeneration;
460
+ persistedMetadata?: boolean | DatabaseTablePersistedMetadataOptions;
461
+ timestampColumns?: TimestampColumnBehavior[];
462
+ }
463
+ //#endregion
289
464
  //#region src/types/factories.d.ts
290
465
  type FactoryAttributes = Record<string, unknown>;
291
466
  interface FactoryModelConstructor<TModel> {
@@ -294,101 +469,6 @@ interface FactoryModelConstructor<TModel> {
294
469
  type FactoryDefinition<TAttributes extends FactoryAttributes> = (sequence: number) => TAttributes;
295
470
  type FactoryState<TAttributes extends FactoryAttributes> = (attributes: TAttributes, sequence: number) => TAttributes;
296
471
  //#endregion
297
- //#region src/types/migrations.d.ts
298
- type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'boolean' | 'json' | 'date' | 'timestamp';
299
- interface SchemaColumn {
300
- name: string;
301
- type: SchemaColumnType;
302
- enumName?: string;
303
- enumValues?: string[];
304
- map?: string;
305
- nullable?: boolean;
306
- unique?: boolean;
307
- primary?: boolean;
308
- autoIncrement?: boolean;
309
- after?: string;
310
- default?: unknown;
311
- updatedAt?: boolean;
312
- }
313
- interface SchemaIndex {
314
- columns: string[];
315
- name?: string;
316
- }
317
- type SchemaForeignKeyAction = 'cascade' | 'restrict' | 'setNull' | 'noAction' | 'setDefault';
318
- interface SchemaForeignKey {
319
- column: string;
320
- referencesTable: string;
321
- referencesColumn: string;
322
- onDelete?: SchemaForeignKeyAction;
323
- relationAlias?: string;
324
- inverseRelationAlias?: string;
325
- fieldAlias?: string;
326
- }
327
- interface SchemaTableCreateOperation {
328
- type: 'createTable';
329
- table: string;
330
- columns: SchemaColumn[];
331
- indexes: SchemaIndex[];
332
- foreignKeys: SchemaForeignKey[];
333
- }
334
- interface SchemaTableAlterOperation {
335
- type: 'alterTable';
336
- table: string;
337
- addColumns: SchemaColumn[];
338
- dropColumns: string[];
339
- addIndexes: SchemaIndex[];
340
- addForeignKeys: SchemaForeignKey[];
341
- }
342
- interface SchemaTableDropOperation {
343
- type: 'dropTable';
344
- table: string;
345
- }
346
- type SchemaOperation = SchemaTableCreateOperation | SchemaTableAlterOperation | SchemaTableDropOperation;
347
- interface GenerateMigrationOptions {
348
- directory?: string;
349
- extension?: 'ts' | 'js';
350
- write?: boolean;
351
- }
352
- interface GeneratedMigrationFile {
353
- fileName: string;
354
- filePath: string;
355
- className: string;
356
- content: string;
357
- }
358
- interface PrismaSchemaSyncOptions {
359
- schemaPath?: string;
360
- write?: boolean;
361
- }
362
- interface PrismaMigrationWorkflowOptions extends PrismaSchemaSyncOptions {
363
- cwd?: string;
364
- runGenerate?: boolean;
365
- runMigrate?: boolean;
366
- migrateMode?: 'dev' | 'deploy';
367
- migrationName?: string;
368
- }
369
- type MigrationInstanceLike = {
370
- up: (...args: any[]) => Promise<void> | void;
371
- down: (...args: any[]) => Promise<void> | void;
372
- };
373
- interface AppliedMigrationEntry {
374
- id: string;
375
- file: string;
376
- className: string;
377
- appliedAt: string;
378
- checksum?: string;
379
- }
380
- interface AppliedMigrationRun {
381
- id: string;
382
- appliedAt: string;
383
- migrationIds: string[];
384
- }
385
- interface AppliedMigrationsState {
386
- version: 1;
387
- migrations: AppliedMigrationEntry[];
388
- runs?: AppliedMigrationRun[];
389
- }
390
- type MigrationClass = new () => MigrationInstanceLike;
391
- //#endregion
392
472
  //#region src/Collection.d.ts
393
473
  declare class ArkormCollection<T = any, X = T[]> extends Collection<T, X> {}
394
474
  //#endregion
@@ -610,9 +690,203 @@ declare class BelongsToManyRelation<TParent, TRelated> extends Relation<TRelated
610
690
  private readonly relatedPivotKey;
611
691
  private readonly parentKey;
612
692
  private readonly relatedKey;
693
+ private static readonly queryDecorationMarker;
694
+ private pivotColumns;
695
+ private pivotAccessor;
696
+ private pivotCreatedAtColumn;
697
+ private pivotUpdatedAtColumn;
698
+ private pivotWhere;
699
+ private pivotModel;
700
+ private shouldAttachPivot;
613
701
  constructor(parent: TParent & {
614
702
  getAttribute: (key: string) => unknown;
615
703
  }, related: RelationshipModelStatic, throughDelegate: string, foreignPivotKey: string, relatedPivotKey: string, parentKey: string, relatedKey: string);
704
+ /**
705
+ * Specifies additional pivot columns to include on the related models.
706
+ *
707
+ * @param columns The pivot columns to include on the related models.
708
+ * @returns
709
+ */
710
+ withPivot(...columns: Array<string | string[]>): this;
711
+ /**
712
+ * Specifies that the pivot table contains timestamp columns and optionally
713
+ * allows customizing the names of those columns.
714
+ *
715
+ * @param createdAtColumn The name of the "created at" timestamp column.
716
+ * @param updatedAtColumn The name of the "updated at" timestamp column.
717
+ * @returns The current instance of the relationship.
718
+ */
719
+ withTimestamps(createdAtColumn?: string, updatedAtColumn?: string): this;
720
+ /**
721
+ * Specifies a custom accessor name for the pivot attributes on the related models.
722
+ * By default, pivot attributes are accessible via the `pivot` property on the
723
+ * related models.
724
+ *
725
+ * @param accessor The custom accessor name for the pivot attributes.
726
+ * @returns The current instance of the relationship.
727
+ */
728
+ as(accessor: string): this;
729
+ /**
730
+ * Specifies a custom pivot model to use for the pivot records. The pivot model can
731
+ * be used to define custom behavior or methods on the pivot records, as well as to
732
+ * specify a custom hydration method for the pivot records.
733
+ *
734
+ * @param pivotModel The custom pivot model to use.
735
+ * @returns The current instance of the relationship.
736
+ */
737
+ using(pivotModel: PivotModelStatic): this;
738
+ /**
739
+ * Adds a "pivot column" condition to the relationship query.
740
+ *
741
+ * @param column The pivot column to apply the condition on.
742
+ * @param value The value to compare the pivot column against.
743
+ */
744
+ wherePivot(column: string, value: unknown): this;
745
+ /**
746
+ * Adds a "pivot column" condition to the relationship query.
747
+ *
748
+ * @param column The pivot column to apply the condition on.
749
+ * @param operator The operator to use for the comparison.
750
+ * @param value The value to compare the pivot column against.
751
+ */
752
+ wherePivot(column: string, operator: QueryComparisonOperator, value: unknown): this;
753
+ /**
754
+ * Adds a "pivot column in" condition to the relationship query.
755
+ *
756
+ * @param column
757
+ * @param values
758
+ * @returns
759
+ */
760
+ wherePivotNotIn(column: string, values: unknown[]): this;
761
+ /**
762
+ * Adds a "pivot column between" condition to the relationship query.
763
+ *
764
+ * @param column
765
+ * @param range
766
+ * @returns
767
+ */
768
+ wherePivotBetween(column: string, range: [unknown, unknown]): this;
769
+ /**
770
+ * Adds a "pivot column not between" condition to the relationship query.
771
+ *
772
+ * @param column
773
+ * @param range
774
+ * @returns
775
+ */
776
+ wherePivotNotBetween(column: string, range: [unknown, unknown]): this;
777
+ /**
778
+ * Adds a "pivot column is null" condition to the relationship query.
779
+ *
780
+ * @param column
781
+ * @returns
782
+ */
783
+ wherePivotNull(column: string): this;
784
+ /**
785
+ * Adds a "pivot column is not null" condition to the relationship query.
786
+ *
787
+ * @param column
788
+ * @returns
789
+ */
790
+ wherePivotNotNull(column: string): this;
791
+ private addPivotWhere;
792
+ private makePivotComparison;
793
+ private buildPivotWhere;
794
+ private buildPivotTarget;
795
+ private buildRelatedPivotCondition;
796
+ private buildPivotMutationWhere;
797
+ private normalizeIdentifierValue;
798
+ private isPlainObject;
799
+ private isModelLike;
800
+ private normalizeRelatedItems;
801
+ private normalizeSyncEntries;
802
+ private resolveParentPivotValue;
803
+ private resolveRelatedPivotValue;
804
+ private buildPivotInsertValues;
805
+ private attachPivotToSingleResult;
806
+ private insertPivotRow;
807
+ private selectPivotRows;
808
+ private deletePivotRows;
809
+ private buildPivotUpdateValues;
810
+ private updatePivotRows;
811
+ /**
812
+ * Creates a new instance of the related model with the given attributes and attaches
813
+ * pivot attributes if pivot attributes should be included.
814
+ *
815
+ * @param attributes The attributes to initialize the related model with.
816
+ * @returns A new instance of the related model.
817
+ */
818
+ make(attributes?: Record<string, unknown>): TRelated;
819
+ /**
820
+ * Creates a new related model record with the given attributes, creates a pivot record
821
+ * with the given pivot attributes, and attaches pivot attributes if pivot attributes
822
+ * should be included.
823
+ *
824
+ * @param attributes The attributes to initialize the related model with.
825
+ * @param pivotAttributes The attributes to initialize the pivot record with.
826
+ * @returns A new instance of the related model with pivot attributes attached.
827
+ */
828
+ create(attributes?: Record<string, unknown>, pivotAttributes?: Record<string, unknown>): Promise<TRelated>;
829
+ /**
830
+ * Saves a related model record, creates a pivot record with the given pivot attributes
831
+ * if the related model was not previously persisted, and attaches pivot attributes if
832
+ * pivot attributes should be included.
833
+ *
834
+ * @param related The related model instance to save.
835
+ * @param pivotAttributes The attributes to initialize the pivot record with.
836
+ * @returns A new instance of the related model with pivot attributes attached.
837
+ */
838
+ save(related: TRelated, pivotAttributes?: Record<string, unknown>): Promise<TRelated>;
839
+ /**
840
+ * Attaches one or more related model records to the parent model by creating pivot
841
+ * records with the given pivot attributes if pivot attributes should be included.
842
+ *
843
+ * @param related The related model instance(s) to attach.
844
+ * @param pivotAttributes The attributes to initialize the pivot record with.
845
+ * @returns The number of related model records attached.
846
+ */
847
+ attach(related: TRelated | unknown | Array<TRelated | unknown>, pivotAttributes?: Record<string, unknown>): Promise<number>;
848
+ /**
849
+ * Detaches one or more related model records from the parent model by deleting
850
+ * matching pivot rows. When no related value is provided, all matching pivot rows
851
+ * for the parent are removed.
852
+ *
853
+ * @param related
854
+ * @returns
855
+ */
856
+ detach(related?: TRelated | unknown | Array<TRelated | unknown>): Promise<number>;
857
+ /**
858
+ * Synchronizes the pivot table so only the provided related values remain attached.
859
+ * Existing matching rows can receive updated pivot attributes during the operation.
860
+ *
861
+ * @param related
862
+ * @param pivotAttributes
863
+ * @returns
864
+ */
865
+ sync(related: TRelated | unknown | Array<TRelated | unknown> | Record<string, Record<string, unknown>>, pivotAttributes?: Record<string, unknown>): Promise<{
866
+ attached: number;
867
+ detached: number;
868
+ updated: number;
869
+ }>;
870
+ private shouldAttachPivotAttributes;
871
+ private getPivotColumnSelection;
872
+ /**
873
+ * Creates a pivot record from a row of data.
874
+ *
875
+ * @param row The row of data containing pivot attributes.
876
+ * @returns The pivot record.
877
+ */
878
+ private createPivotRecord;
879
+ /**
880
+ * Attaches pivot attributes to the related models if pivot attributes should be included.
881
+ *
882
+ * @param results
883
+ * @param pivotRows
884
+ * @returns
885
+ */
886
+ private attachPivotToResults;
887
+ private attachPivotToModel;
888
+ private decorateQueryBuilder;
889
+ private loadPivotRowsForParent;
616
890
  /**
617
891
  * Build the relationship query.
618
892
  *
@@ -1145,7 +1419,7 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
1145
1419
  * @param this
1146
1420
  * @returns
1147
1421
  */
1148
- static query<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
1422
+ static query<TThis extends abstract new (attributes?: Record<string, unknown>) => unknown, TModel extends Model<any, any> = InstanceType<TThis> & Model<any, any>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
1149
1423
  /**
1150
1424
  * Boot hook for subclasses to register scopes or perform one-time setup.
1151
1425
  */
@@ -1160,14 +1434,14 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
1160
1434
  * @param this
1161
1435
  * @returns
1162
1436
  */
1163
- static withTrashed<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
1437
+ static withTrashed<TThis extends abstract new (attributes?: Record<string, unknown>) => unknown, TModel extends Model<any, any> = InstanceType<TThis> & Model<any, any>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
1164
1438
  /**
1165
1439
  * Get a query builder instance that only includes soft-deleted records.
1166
1440
  *
1167
1441
  * @param this
1168
1442
  * @returns
1169
1443
  */
1170
- static onlyTrashed<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
1444
+ static onlyTrashed<TThis extends abstract new (attributes?: Record<string, unknown>) => unknown, TModel extends Model<any, any> = InstanceType<TThis> & Model<any, any>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis): QueryBuilder<TModel, TDelegate>;
1171
1445
  /**
1172
1446
  * Get a query builder instance that excludes soft-deleted records.
1173
1447
  * This is the default behavior of the query builder, but this method can be used
@@ -1178,7 +1452,7 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
1178
1452
  * @param args
1179
1453
  * @returns
1180
1454
  */
1181
- static scope<TThis extends abstract new (attributes?: Record<string, unknown>) => Model<any>, TModel extends InstanceType<TThis> = InstanceType<TThis>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis, name: string, ...args: unknown[]): QueryBuilder<TModel, TDelegate>;
1455
+ static scope<TThis extends abstract new (attributes?: Record<string, unknown>) => unknown, TModel extends Model<any, any> = InstanceType<TThis> & Model<any, any>, TDelegate extends PrismaDelegateLike = DelegateForModelSchema<TModel extends Model<infer TSchema, any> ? TSchema : Record<string, any>, TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>>>(this: TThis, name: string, ...args: unknown[]): QueryBuilder<TModel, TDelegate>;
1182
1456
  /**
1183
1457
  * Get the soft delete configuration for the model, including whether
1184
1458
  * soft deletes are enabled and the name of the deleted at column.
@@ -1233,7 +1507,7 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
1233
1507
  * @param key
1234
1508
  * @returns
1235
1509
  */
1236
- getAttribute<TKey extends keyof TAttributes & string>(key: TKey): TAttributes[TKey];
1510
+ getAttribute<TSelf extends this, TKey extends string>(this: TSelf, key: TKey): ModelAttributeValue<TSelf, TAttributes, TKey>;
1237
1511
  getAttribute(key: string): unknown;
1238
1512
  /**
1239
1513
  * Set the value of an attribute, applying any set mutators or casts if defined.
@@ -1242,7 +1516,7 @@ declare abstract class Model<TSchema extends PrismaDelegateLike | Record<string,
1242
1516
  * @param value
1243
1517
  * @returns
1244
1518
  */
1245
- setAttribute<TKey extends keyof TAttributes & string>(key: TKey, value: TAttributes[TKey]): this;
1519
+ setAttribute<TSelf extends this, TKey extends string>(this: TSelf, key: TKey, value: ModelAttributeValue<TSelf, TAttributes, TKey>): this;
1246
1520
  setAttribute(key: string, value: unknown): this;
1247
1521
  /**
1248
1522
  * Save the model to the database.
@@ -1667,6 +1941,14 @@ interface AttributeSchemaDelegate<TAttributes extends Record<string, unknown>> e
1667
1941
  type DelegateForModelSchema<TSchema extends PrismaDelegateLike | Record<string, unknown> | string, TAttributes extends Record<string, unknown> = ModelAttributesOf<TSchema>> = TSchema extends PrismaDelegateLike ? TSchema : TSchema extends string ? DelegateFromPrismaClient<TSchema> extends PrismaDelegateLike ? DelegateFromPrismaClient<TSchema> : PrismaDelegateLike : AttributeSchemaDelegate<TAttributes>;
1668
1942
  type ModelAttributesOf<TSchema extends PrismaDelegateLike | Record<string, unknown> | string> = TSchema extends PrismaDelegateLike ? DelegateRow<TSchema> extends Record<string, unknown> ? DelegateRow<TSchema> : Record<string, any> : TSchema extends string ? DelegateFromPrismaClient<TSchema> extends PrismaDelegateLike ? DelegateRow<DelegateFromPrismaClient<TSchema>> extends Record<string, unknown> ? DelegateRow<DelegateFromPrismaClient<TSchema>> : Record<string, any> : Record<string, any> : TSchema extends Record<string, unknown> ? TSchema : Record<string, any>;
1669
1943
  type ModelAttributes<TModel> = TModel extends Model<any, infer TAttributes> ? TAttributes : Record<string, any>;
1944
+ type BaseModelInstance = Model<any, any>;
1945
+ type ModelDeclaredAttributeKey<TModel> = { [TKey in keyof TModel & string]: TKey extends keyof BaseModelInstance ? never : TModel[TKey] extends ((...args: any[]) => any) ? never : TKey }[keyof TModel & string];
1946
+ type RelationshipResultProvider<TResult = unknown> = {
1947
+ getResults: (...args: any[]) => Promise<TResult>;
1948
+ };
1949
+ type ModelRelationshipKey<TModel> = { [TKey in keyof TModel & string]: TKey extends keyof BaseModelInstance ? never : TModel[TKey] extends ((...args: any[]) => infer TReturn) ? Parameters<TModel[TKey]> extends [] ? TReturn extends RelationshipResultProvider<any> ? TKey : never : never : never }[keyof TModel & string];
1950
+ type ModelRelationshipResult<TModel, TKey extends ModelRelationshipKey<TModel>> = TModel[TKey] extends ((...args: any[]) => infer TReturn) ? TReturn extends RelationshipResultProvider<infer TResult> ? TResult : never : never;
1951
+ type ModelAttributeValue<TModel, TAttributes extends Record<string, unknown>, TKey extends string> = TKey extends ModelRelationshipKey<TModel> ? ModelRelationshipResult<TModel, TKey> : TKey extends ModelDeclaredAttributeKey<TModel> ? TModel[TKey] : TKey extends keyof TAttributes & string ? TAttributes[TKey] : unknown;
1670
1952
  type ModelCreateData<TModel, TDelegate extends PrismaDelegateLike> = TModel extends Model<any, infer TAttributes> ? TDelegate extends AttributeSchemaDelegate<TAttributes> ? AttributeCreateInput<TAttributes> : DelegateCreateData<TDelegate> : DelegateCreateData<TDelegate>;
1671
1953
  type ModelUpdateData<TModel, TDelegate extends PrismaDelegateLike> = TModel extends Model<any, infer TAttributes> ? TDelegate extends AttributeSchemaDelegate<TAttributes> ? AttributeUpdateInput<TAttributes> : DelegateUpdateData<TDelegate> : DelegateUpdateData<TDelegate>;
1672
1954
  type RelatedModelClass<TInstance = unknown> = (abstract new (attributes?: Record<string, unknown>) => TInstance) & RelationshipModelStatic;
@@ -2206,6 +2488,13 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
2206
2488
  * @returns
2207
2489
  */
2208
2490
  limit(value: number): this;
2491
+ /**
2492
+ * Returns a representation of the query that can be used for debugging or logging purposes.
2493
+ *
2494
+ * @param operation
2495
+ * @returns
2496
+ */
2497
+ inspect(operation?: Extract<AdapterQueryOperation, 'select' | 'selectOne' | 'count' | 'exists'>): AdapterQueryInspection | null;
2209
2498
  /**
2210
2499
  * Sets offset/limit for a 1-based page.
2211
2500
  *
@@ -2392,6 +2681,7 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
2392
2681
  */
2393
2682
  doesntExist(): Promise<boolean>;
2394
2683
  private normalizeInsertPayloads;
2684
+ private normalizeUpdatePayload;
2395
2685
  private resolveAffectedCount;
2396
2686
  private resolveInsertUsingRows;
2397
2687
  private resolveInsertUsingSource;
@@ -2613,6 +2903,8 @@ interface QueryTarget<TModel = unknown> {
2613
2903
  modelName?: string;
2614
2904
  table?: string;
2615
2905
  primaryKey?: string;
2906
+ primaryKeyGeneration?: PrimaryKeyGeneration;
2907
+ timestampColumns?: TimestampColumnBehavior[];
2616
2908
  columns?: Record<string, string>;
2617
2909
  softDelete?: SoftDeleteConfig;
2618
2910
  alias?: string;
@@ -2735,6 +3027,47 @@ interface RelationLoadSpec<TModel = unknown> {
2735
3027
  models: TModel[];
2736
3028
  relations: RelationLoadPlan[];
2737
3029
  }
3030
+ type AdapterQueryOperation = 'select' | 'selectOne' | 'count' | 'exists' | 'insert' | 'insertMany' | 'upsert' | 'update' | 'updateFirst' | 'updateMany' | 'delete' | 'deleteFirst' | 'deleteMany';
3031
+ type AdapterInspectionRequest<TModel = unknown> = {
3032
+ operation: 'select';
3033
+ spec: SelectSpec<TModel>;
3034
+ } | {
3035
+ operation: 'selectOne';
3036
+ spec: SelectSpec<TModel>;
3037
+ } | {
3038
+ operation: 'count';
3039
+ spec: AggregateSpec<TModel>;
3040
+ } | {
3041
+ operation: 'exists';
3042
+ spec: SelectSpec<TModel>;
3043
+ } | {
3044
+ operation: 'insert';
3045
+ spec: InsertSpec<TModel>;
3046
+ } | {
3047
+ operation: 'insertMany';
3048
+ spec: InsertManySpec<TModel>;
3049
+ } | {
3050
+ operation: 'upsert';
3051
+ spec: UpsertSpec<TModel>;
3052
+ } | {
3053
+ operation: 'update';
3054
+ spec: UpdateSpec<TModel>;
3055
+ } | {
3056
+ operation: 'updateFirst';
3057
+ spec: UpdateSpec<TModel>;
3058
+ } | {
3059
+ operation: 'updateMany';
3060
+ spec: UpdateManySpec<TModel>;
3061
+ } | {
3062
+ operation: 'delete';
3063
+ spec: DeleteSpec<TModel>;
3064
+ } | {
3065
+ operation: 'deleteFirst';
3066
+ spec: DeleteSpec<TModel>;
3067
+ } | {
3068
+ operation: 'deleteMany';
3069
+ spec: DeleteManySpec<TModel>;
3070
+ };
2738
3071
  interface AdapterTransactionContext {
2739
3072
  isolationLevel?: string;
2740
3073
  readOnly?: boolean;
@@ -2770,7 +3103,12 @@ interface DatabaseAdapter {
2770
3103
  count: <TModel = unknown>(spec: AggregateSpec<TModel>) => Promise<number>;
2771
3104
  exists?: <TModel = unknown>(spec: SelectSpec<TModel>) => Promise<boolean>;
2772
3105
  loadRelations?: <TModel = unknown>(spec: RelationLoadSpec<TModel>) => Promise<void>;
3106
+ inspectQuery?: <TModel = unknown>(request: AdapterInspectionRequest<TModel>) => AdapterQueryInspection | null;
2773
3107
  introspectModels?: (options?: AdapterModelIntrospectionOptions) => Promise<AdapterModelStructure[]>;
3108
+ executeSchemaOperations?: (operations: SchemaOperation[]) => Promise<void>;
3109
+ resetDatabase?: () => Promise<void>;
3110
+ readAppliedMigrationsState?: () => Promise<AppliedMigrationsState>;
3111
+ writeAppliedMigrationsState?: (state: AppliedMigrationsState) => Promise<void>;
2774
3112
  transaction: <TResult = unknown>(callback: (adapter: DatabaseAdapter) => TResult | Promise<TResult>, context?: AdapterTransactionContext) => Promise<TResult>;
2775
3113
  }
2776
3114
  //#endregion
@@ -2787,8 +3125,31 @@ type KyselyTableMapping = Record<string, string>;
2787
3125
  declare class KyselyDatabaseAdapter implements DatabaseAdapter {
2788
3126
  private readonly db;
2789
3127
  private readonly mapping;
3128
+ private static readonly migrationStateTable;
3129
+ private static readonly migrationRunTable;
2790
3130
  readonly capabilities: AdapterCapabilities;
2791
3131
  constructor(db: KyselyExecutor, mapping?: KyselyTableMapping);
3132
+ private quoteIdentifier;
3133
+ private quoteLiteral;
3134
+ private executeRawStatement;
3135
+ private resolveSchemaColumnName;
3136
+ private resolveSchemaIndexName;
3137
+ private resolveSchemaForeignKeyName;
3138
+ private resolveSchemaEnumName;
3139
+ private resolveSchemaColumnType;
3140
+ private resolveSchemaColumnDefault;
3141
+ private shouldUseIdentity;
3142
+ private buildSchemaColumnDefinition;
3143
+ private buildSchemaForeignKeyConstraint;
3144
+ private buildSchemaIndexStatement;
3145
+ private ensureEnumTypes;
3146
+ private executeCreateTableOperation;
3147
+ private executeAlterTableOperation;
3148
+ private executeDropTableOperation;
3149
+ private ensureMigrationStateTables;
3150
+ private writeAppliedMigrationsStateInternal;
3151
+ private resetDatabaseInternal;
3152
+ private normalizeIntrospectionEnumValues;
2792
3153
  private introspectionTypeToTs;
2793
3154
  private resolveTable;
2794
3155
  private resolvePrimaryKey;
@@ -2818,6 +3179,14 @@ declare class KyselyDatabaseAdapter implements DatabaseAdapter {
2818
3179
  private buildCombinedWhereClause;
2819
3180
  private buildSingleRowTargetCte;
2820
3181
  private assertNoRelationLoads;
3182
+ private buildSelectStatement;
3183
+ private buildCountStatement;
3184
+ private buildExistsStatement;
3185
+ private compileInspection;
3186
+ private emitDebugQuery;
3187
+ private wrapExecutionError;
3188
+ private executeWithDebug;
3189
+ inspectQuery<TModel = unknown>(request: AdapterInspectionRequest<TModel>): AdapterQueryInspection | null;
2821
3190
  /**
2822
3191
  * Selects records from the database matching the specified criteria and returns
2823
3192
  * them as an array of database rows.
@@ -2914,6 +3283,10 @@ declare class KyselyDatabaseAdapter implements DatabaseAdapter {
2914
3283
  */
2915
3284
  exists<TModel = unknown>(spec: SelectSpec<TModel>): Promise<boolean>;
2916
3285
  introspectModels(options?: AdapterModelIntrospectionOptions): Promise<AdapterModelStructure[]>;
3286
+ executeSchemaOperations(operations: SchemaOperation[]): Promise<void>;
3287
+ resetDatabase(): Promise<void>;
3288
+ readAppliedMigrationsState(): Promise<AppliedMigrationsState>;
3289
+ writeAppliedMigrationsState(state: AppliedMigrationsState): Promise<void>;
2917
3290
  /**
2918
3291
  * Executes a series of database operations within a transaction.
2919
3292
  * The provided callback function is called with a new instance of the
@@ -2960,6 +3333,10 @@ declare class PrismaDatabaseAdapter implements DatabaseAdapter {
2960
3333
  private toComparisonWhere;
2961
3334
  private toQueryWhere;
2962
3335
  private buildFindArgs;
3336
+ private emitDebugQuery;
3337
+ private wrapExecutionError;
3338
+ private runWithDebug;
3339
+ inspectQuery<TModel = unknown>(_request: AdapterInspectionRequest<TModel>): AdapterQueryInspection | null;
2963
3340
  private toQueryInclude;
2964
3341
  introspectModels(options?: AdapterModelIntrospectionOptions): Promise<AdapterModelStructure[]>;
2965
3342
  private resolveDelegate;
@@ -3112,6 +3489,7 @@ declare class CliApp {
3112
3489
  * @returns The entire configuration object or the value of the specified key
3113
3490
  */
3114
3491
  getConfig: GetUserConfig;
3492
+ private isUsingPrismaAdapter;
3115
3493
  /**
3116
3494
  * Utility to ensure directory exists
3117
3495
  *
@@ -3226,13 +3604,14 @@ declare class CliApp {
3226
3604
  factory?: boolean;
3227
3605
  seeder?: boolean;
3228
3606
  migration?: boolean;
3607
+ pivot?: boolean;
3229
3608
  all?: boolean;
3230
3609
  }): {
3231
3610
  model: {
3232
3611
  name: string;
3233
3612
  path: string;
3234
3613
  };
3235
- prisma: {
3614
+ prisma?: {
3236
3615
  path: string;
3237
3616
  updated: boolean;
3238
3617
  };
@@ -3279,12 +3658,13 @@ declare class CliApp {
3279
3658
  private syncPrismaEnumImports;
3280
3659
  private parseModelSyncSource;
3281
3660
  private syncModelFiles;
3661
+ private applyPersistedFieldMetadata;
3282
3662
  /**
3283
3663
  * Parse Prisma enum definitions from a schema and return their member names.
3284
3664
  *
3285
3665
  * @param schema The Prisma schema source.
3286
3666
  * @returns A map of enum names to their declared member names.
3287
- */
3667
+ */
3288
3668
  private parsePrismaEnums;
3289
3669
  /**
3290
3670
  * Resolve the generated TypeScript declaration type for a Prisma field.
@@ -3473,6 +3853,15 @@ declare class MigrateCommand extends Command<CliApp> {
3473
3853
  private loadMigrationClassesFromFile;
3474
3854
  }
3475
3855
  //#endregion
3856
+ //#region src/cli/commands/MigrateFreshCommand.d.ts
3857
+ declare class MigrateFreshCommand extends Command<CliApp> {
3858
+ protected signature: string;
3859
+ protected description: string;
3860
+ handle(): Promise<undefined>;
3861
+ private loadAllMigrations;
3862
+ private loadMigrationClassesFromFile;
3863
+ }
3864
+ //#endregion
3476
3865
  //#region src/cli/commands/MigrateRollbackCommand.d.ts
3477
3866
  /**
3478
3867
  * Rollback migration classes from the Prisma schema and run Prisma workflow.
@@ -3506,7 +3895,7 @@ declare class MigrationHistoryCommand extends Command<CliApp> {
3506
3895
  declare class ModelsSyncCommand extends Command<CliApp> {
3507
3896
  protected signature: string;
3508
3897
  protected description: string;
3509
- handle(): Promise<void>;
3898
+ handle(): Promise<undefined>;
3510
3899
  }
3511
3900
  //#endregion
3512
3901
  //#region src/cli/commands/SeedCommand.d.ts
@@ -4035,6 +4424,22 @@ declare abstract class Seeder {
4035
4424
  private static runSeeders;
4036
4425
  }
4037
4426
  //#endregion
4427
+ //#region src/DB.d.ts
4428
+ declare class DB {
4429
+ private static adapter?;
4430
+ private readonly scopedAdapter?;
4431
+ private constructor();
4432
+ static setAdapter(adapter?: DatabaseAdapter): void;
4433
+ static getAdapter(): DatabaseAdapter | undefined;
4434
+ getAdapter(): DatabaseAdapter | undefined;
4435
+ static table<TRow extends Record<string, unknown> = Record<string, unknown>>(table: string, options?: DatabaseTableOptions): QueryBuilder<TRow, PrismaDelegateLike>;
4436
+ table<TRow extends Record<string, unknown> = Record<string, unknown>>(table: string, options?: DatabaseTableOptions): QueryBuilder<TRow, PrismaDelegateLike>;
4437
+ static transaction<TResult>(callback: (db: DB) => TResult | Promise<TResult>, context?: AdapterTransactionContext): Promise<TResult>;
4438
+ transaction<TResult>(callback: (db: DB) => TResult | Promise<TResult>, context?: AdapterTransactionContext): Promise<TResult>;
4439
+ private static createTableModel;
4440
+ private static resolvePersistedTableMetadata;
4441
+ }
4442
+ //#endregion
4038
4443
  //#region src/Exceptions/ArkormException.d.ts
4039
4444
  /**
4040
4445
  * The ArkormException class is a custom error type for handling
@@ -4092,6 +4497,16 @@ declare class QueryConstraintException extends ArkormException {
4092
4497
  constructor(message: string, context?: ArkormErrorContext);
4093
4498
  }
4094
4499
  //#endregion
4500
+ //#region src/Exceptions/QueryExecutionException.d.ts
4501
+ interface QueryExecutionExceptionContext extends ArkormErrorContext {
4502
+ inspection?: AdapterQueryInspection | null;
4503
+ }
4504
+ declare class QueryExecutionException extends ArkormException {
4505
+ readonly inspection?: AdapterQueryInspection | null;
4506
+ constructor(message?: string, context?: QueryExecutionExceptionContext);
4507
+ getInspection(): AdapterQueryInspection | null | undefined;
4508
+ }
4509
+ //#endregion
4095
4510
  //#region src/Exceptions/RelationResolutionException.d.ts
4096
4511
  declare class RelationResolutionException extends ArkormException {
4097
4512
  constructor(message: string, context?: ArkormErrorContext);
@@ -4112,12 +4527,81 @@ declare class UnsupportedAdapterFeatureException extends ArkormException {
4112
4527
  constructor(message: string, context?: ArkormErrorContext);
4113
4528
  }
4114
4529
  //#endregion
4530
+ //#region src/helpers/column-mappings.d.ts
4531
+ interface PersistedMetadataFeatures {
4532
+ persistedColumnMappings: boolean;
4533
+ persistedEnums: boolean;
4534
+ }
4535
+ interface PersistedTableMetadata {
4536
+ columns: Record<string, string>;
4537
+ enums: Record<string, string[]>;
4538
+ primaryKeyGeneration?: PersistedPrimaryKeyGeneration;
4539
+ timestampColumns?: PersistedTimestampColumn[];
4540
+ }
4541
+ interface PersistedPrimaryKeyGeneration extends PrimaryKeyGeneration {
4542
+ column: string;
4543
+ }
4544
+ interface PersistedTimestampColumn extends TimestampColumnBehavior {
4545
+ column: string;
4546
+ }
4547
+ interface PersistedColumnMappingsState {
4548
+ version: 1;
4549
+ tables: Record<string, PersistedTableMetadata>;
4550
+ }
4551
+ declare const resolvePersistedMetadataFeatures: (features?: ArkormConfig["features"]) => PersistedMetadataFeatures;
4552
+ declare const createEmptyPersistedColumnMappingsState: () => PersistedColumnMappingsState;
4553
+ declare const resolveColumnMappingsFilePath: (cwd: string, configuredPath?: string) => string;
4554
+ declare const resetPersistedColumnMappingsCache: () => void;
4555
+ declare const readPersistedColumnMappingsState: (filePath: string) => PersistedColumnMappingsState;
4556
+ declare const writePersistedColumnMappingsState: (filePath: string, state: PersistedColumnMappingsState) => void;
4557
+ declare const deletePersistedColumnMappingsState: (filePath: string) => void;
4558
+ declare const getPersistedTableMetadata: (table: string, options?: {
4559
+ cwd?: string;
4560
+ configuredPath?: string;
4561
+ features?: PersistedMetadataFeatures;
4562
+ strict?: boolean;
4563
+ }) => PersistedTableMetadata;
4564
+ declare const getPersistedColumnMap: (table: string, options?: {
4565
+ cwd?: string;
4566
+ configuredPath?: string;
4567
+ features?: PersistedMetadataFeatures;
4568
+ strict?: boolean;
4569
+ }) => Record<string, string>;
4570
+ declare const getPersistedEnumMap: (table: string, options?: {
4571
+ cwd?: string;
4572
+ configuredPath?: string;
4573
+ features?: PersistedMetadataFeatures;
4574
+ strict?: boolean;
4575
+ }) => Record<string, string[]>;
4576
+ declare const getPersistedPrimaryKeyGeneration: (table: string, options?: {
4577
+ cwd?: string;
4578
+ configuredPath?: string;
4579
+ features?: PersistedMetadataFeatures;
4580
+ strict?: boolean;
4581
+ }) => PersistedPrimaryKeyGeneration | undefined;
4582
+ declare const getPersistedTimestampColumns: (table: string, options?: {
4583
+ cwd?: string;
4584
+ configuredPath?: string;
4585
+ features?: PersistedMetadataFeatures;
4586
+ strict?: boolean;
4587
+ }) => PersistedTimestampColumn[];
4588
+ declare const applyOperationsToPersistedColumnMappingsState: (state: PersistedColumnMappingsState, operations: SchemaOperation[], features?: PersistedMetadataFeatures) => PersistedColumnMappingsState;
4589
+ declare const rebuildPersistedColumnMappingsState: (state: AppliedMigrationsState, availableMigrations: [MigrationClass, string][], features?: PersistedMetadataFeatures) => Promise<PersistedColumnMappingsState>;
4590
+ declare const syncPersistedColumnMappingsFromState: (cwd: string, state: AppliedMigrationsState, availableMigrations: [MigrationClass, string][], features?: PersistedMetadataFeatures) => Promise<void>;
4591
+ declare const validatePersistedMetadataFeaturesForMigrations: (migrations: [MigrationClass, string][], features?: PersistedMetadataFeatures) => Promise<void>;
4592
+ declare const getPersistedEnumTsType: (values: string[]) => string;
4593
+ //#endregion
4115
4594
  //#region src/helpers/migration-history.d.ts
4595
+ declare const createEmptyAppliedMigrationsState: () => AppliedMigrationsState;
4596
+ declare const supportsDatabaseMigrationState: (adapter?: DatabaseAdapter) => adapter is DatabaseAdapter & Required<Pick<DatabaseAdapter, "readAppliedMigrationsState" | "writeAppliedMigrationsState">>;
4116
4597
  declare const resolveMigrationStateFilePath: (cwd: string, configuredPath?: string) => string;
4117
4598
  declare const buildMigrationIdentity: (filePath: string, className: string) => string;
4118
4599
  declare const computeMigrationChecksum: (filePath: string) => string;
4119
4600
  declare const readAppliedMigrationsState: (stateFilePath: string) => AppliedMigrationsState;
4601
+ declare const readAppliedMigrationsStateFromStore: (adapter: DatabaseAdapter | undefined, stateFilePath: string) => Promise<AppliedMigrationsState>;
4120
4602
  declare const writeAppliedMigrationsState: (stateFilePath: string, state: AppliedMigrationsState) => void;
4603
+ declare const writeAppliedMigrationsStateToStore: (adapter: DatabaseAdapter | undefined, stateFilePath: string, state: AppliedMigrationsState) => Promise<void>;
4604
+ declare const deleteAppliedMigrationsStateFromStore: (adapter: DatabaseAdapter | undefined, stateFilePath: string) => Promise<"database" | "file" | "missing-file">;
4121
4605
  declare const isMigrationApplied: (state: AppliedMigrationsState, identity: string, checksum?: string) => boolean;
4122
4606
  declare const findAppliedMigration: (state: AppliedMigrationsState, identity: string) => AppliedMigrationEntry | undefined;
4123
4607
  declare const markMigrationApplied: (state: AppliedMigrationsState, entry: AppliedMigrationEntry) => AppliedMigrationsState;
@@ -4372,6 +4856,15 @@ declare const generateMigrationFile: (name: string, options?: GenerateMigrationO
4372
4856
  * @returns A promise that resolves to an array of schema operations that would be performed.
4373
4857
  */
4374
4858
  declare const getMigrationPlan: (migration: Migration | (new () => Migration), direction?: "up" | "down") => Promise<SchemaOperation[]>;
4859
+ declare const supportsDatabaseMigrationExecution: (adapter?: DatabaseAdapter) => adapter is DatabaseAdapter & Required<Pick<DatabaseAdapter, "executeSchemaOperations">>;
4860
+ declare const supportsDatabaseReset: (adapter?: DatabaseAdapter) => adapter is DatabaseAdapter & Required<Pick<DatabaseAdapter, "resetDatabase">>;
4861
+ declare const stripPrismaSchemaModelsAndEnums: (schema: string) => string;
4862
+ declare const applyMigrationToDatabase: (adapter: DatabaseAdapter, migration: Migration | (new () => Migration)) => Promise<{
4863
+ operations: SchemaOperation[];
4864
+ }>;
4865
+ declare const applyMigrationRollbackToDatabase: (adapter: DatabaseAdapter, migration: Migration | (new () => Migration)) => Promise<{
4866
+ operations: SchemaOperation[];
4867
+ }>;
4375
4868
  /**
4376
4869
  * Apply the schema operations defined in a migration to a Prisma schema
4377
4870
  * file, updating the file on disk if specified, and return the updated
@@ -4412,6 +4905,12 @@ declare const runMigrationWithPrisma: (migration: Migration | (new () => Migrati
4412
4905
  operations: SchemaOperation[];
4413
4906
  }>;
4414
4907
  //#endregion
4908
+ //#region src/helpers/PrimaryKeyGenerationPlanner.d.ts
4909
+ declare class PrimaryKeyGenerationPlanner {
4910
+ static plan(column: Pick<SchemaColumn, 'type' | 'primary' | 'default'>): PrimaryKeyGeneration | undefined;
4911
+ static generate(generation: PrimaryKeyGeneration | undefined): unknown;
4912
+ }
4913
+ //#endregion
4415
4914
  //#region src/helpers/runtime-config.d.ts
4416
4915
  /**
4417
4916
  * Define the ArkORM runtime configuration. This function can be used to provide.
@@ -4479,6 +4978,8 @@ declare const getRuntimePaginationURLDriverFactory: () => PaginationURLDriverFac
4479
4978
  * @returns
4480
4979
  */
4481
4980
  declare const getRuntimePaginationCurrentPageResolver: () => PaginationCurrentPageResolver | undefined;
4981
+ declare const getRuntimeDebugHandler: () => ArkormDebugHandler | undefined;
4982
+ declare const emitRuntimeDebugEvent: (event: ArkormDebugEvent) => void;
4482
4983
  /**
4483
4984
  * Check if a given value is a Prisma delegate-like object
4484
4985
  * by verifying the presence of common delegate methods.
@@ -4525,6 +5026,20 @@ declare class RuntimeModuleLoader {
4525
5026
  static load<T = unknown>(filePath: string): Promise<T>;
4526
5027
  }
4527
5028
  //#endregion
5029
+ //#region src/PivotModel.d.ts
5030
+ /**
5031
+ * Base pivot class that all pivot models should extend.
5032
+ *
5033
+ * @template TModel The type of the model extending this base class.
5034
+ *
5035
+ * @author Legacy (3m1n3nc3)
5036
+ * @since 2.0.0-next.18
5037
+ */
5038
+ declare class PivotModel extends Model {
5039
+ protected readonly attributes: Record<string, unknown>;
5040
+ constructor(attributes?: Record<string, unknown>);
5041
+ }
5042
+ //#endregion
4528
5043
  //#region src/URLDriver.d.ts
4529
5044
  /**
4530
5045
  * URLDriver builds pagination URLs from paginator options.
@@ -4543,4 +5058,4 @@ declare class URLDriver {
4543
5058
  url(page: number): string;
4544
5059
  }
4545
5060
  //#endregion
4546
- export { AdapterBindableModel, AdapterCapabilities, AdapterCapability, AdapterModelFieldStructure, AdapterModelIntrospectionOptions, AdapterModelStructure, AdapterTransactionContext, AggregateOperation, AggregateSelection, AggregateSpec, AppliedMigrationEntry, AppliedMigrationRun, AppliedMigrationsState, ArkormBootContext, ArkormCollection, ArkormConfig, ArkormErrorContext, ArkormException, Attribute, AttributeCreateInput, AttributeOptions, AttributeOrderBy, AttributeSchemaDelegate, AttributeSelect, AttributeUpdateInput, AttributeWhereInput, BelongsToManyRelationMetadata, BelongsToRelationMetadata, CastDefinition, CastHandler, CastMap, CastType, CliApp, ClientResolver, ColumnMap, DatabaseAdapter, DatabasePrimitive, DatabaseRow, DatabaseRows, DatabaseValue, DelegateCreateData, DelegateFindManyArgs, DelegateForModelSchema, DelegateInclude, DelegateOrderBy, DelegateRow, DelegateRows, DelegateSelect, DelegateUniqueWhere, DelegateUpdateArgs, DelegateUpdateData, DelegateWhere, DeleteManySpec, DeleteSpec, EagerLoadConstraint, EagerLoadMap, EnumBuilder, FactoryAttributes, FactoryDefinition, FactoryModelConstructor, FactoryState, ForeignKeyBuilder, GenerateMigrationOptions, GeneratedMigrationFile, GetUserConfig, GlobalScope, HasManyRelationMetadata, HasManyThroughRelationMetadata, HasOneRelationMetadata, HasOneThroughRelationMetadata, InitCommand, InlineFactory, InsertManySpec, InsertSpec, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationClass, MigrationHistoryCommand, MigrationInstanceLike, MissingDelegateException, Model, ModelAttributes, ModelAttributesOf, ModelCreateData, ModelEventDispatcher, ModelEventHandler, ModelEventHandlerConstructor, ModelEventListener, ModelEventName, ModelFactory, ModelLifecycleState, ModelMetadata, ModelNotFoundException, ModelStatic, ModelUpdateData, ModelsSyncCommand, MorphManyRelationMetadata, MorphOneRelationMetadata, MorphToManyRelationMetadata, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, PaginationCurrentPageResolver, PaginationMeta, PaginationOptions, PaginationURLDriver, PaginationURLDriverFactory, Paginator, PrismaClientLike, PrismaDatabaseAdapter, PrismaDelegateLike, PrismaDelegateMap, PrismaDelegateNameMapping, PrismaFindManyArgsLike, PrismaLikeInclude, PrismaLikeOrderBy, PrismaLikeScalarFilter, PrismaLikeSelect, PrismaLikeSortOrder, PrismaLikeWhereInput, PrismaMigrationWorkflowOptions, PrismaSchemaSyncOptions, PrismaTransactionCallback, PrismaTransactionCapableClient, PrismaTransactionOptions, QueryBuilder, QueryComparisonCondition, QueryComparisonOperator, QueryCondition, QueryConstraintException, QueryGroupCondition, QueryLogicalOperator, QueryNotCondition, QueryOrderBy, QueryRawCondition, QuerySelectColumn, QueryTarget, RelatedModelClass, RelationAggregateSpec, RelationColumnLookupSpec, RelationConstraint, RelationDefaultResolver, RelationDefaultValue, RelationFilterSpec, RelationLoadPlan, RelationLoadSpec, RelationMetadata, RelationMetadataProvider, RelationMetadataType, RelationResolutionException, RelationTableLookupSpec, RelationshipModelStatic, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, SchemaColumn, SchemaColumnType, SchemaForeignKey, SchemaForeignKeyAction, SchemaIndex, SchemaOperation, SchemaTableAlterOperation, SchemaTableCreateOperation, SchemaTableDropOperation, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, SelectSpec, Serializable, SimplePaginationMeta, SoftDeleteConfig, SoftDeleteQueryMode, SortDirection, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, UpdateManySpec, UpdateSpec, UpsertSpec, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getRuntimeAdapter, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, removeAppliedMigration, resetArkormRuntimeForTests, resolveCast, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName, writeAppliedMigrationsState };
5061
+ export { AdapterBindableModel, AdapterCapabilities, AdapterCapability, AdapterInspectionRequest, AdapterModelFieldStructure, AdapterModelIntrospectionOptions, AdapterModelStructure, AdapterQueryInspection, AdapterQueryOperation, AdapterTransactionContext, AggregateOperation, AggregateSelection, AggregateSpec, AppliedMigrationEntry, AppliedMigrationRun, AppliedMigrationsState, ArkormBootContext, ArkormCollection, ArkormConfig, ArkormDebugEvent, ArkormDebugHandler, ArkormErrorContext, ArkormException, Attribute, AttributeCreateInput, AttributeOptions, AttributeOrderBy, AttributeSchemaDelegate, AttributeSelect, AttributeUpdateInput, AttributeWhereInput, BelongsToManyRelationMetadata, BelongsToRelationMetadata, CastDefinition, CastHandler, CastMap, CastType, CliApp, ClientResolver, ColumnMap, DB, DatabaseAdapter, DatabasePrimitive, DatabaseRow, DatabaseRows, DatabaseTableOptions, DatabaseTablePersistedMetadataOptions, DatabaseValue, DelegateCreateData, DelegateFindManyArgs, DelegateForModelSchema, DelegateInclude, DelegateOrderBy, DelegateRow, DelegateRows, DelegateSelect, DelegateUniqueWhere, DelegateUpdateArgs, DelegateUpdateData, DelegateWhere, DeleteManySpec, DeleteSpec, EagerLoadConstraint, EagerLoadMap, EnumBuilder, FactoryAttributes, FactoryDefinition, FactoryModelConstructor, FactoryState, ForeignKeyBuilder, GenerateMigrationOptions, GeneratedMigrationFile, GetUserConfig, GlobalScope, HasManyRelationMetadata, HasManyThroughRelationMetadata, HasOneRelationMetadata, HasOneThroughRelationMetadata, InitCommand, InlineFactory, InsertManySpec, InsertSpec, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationClass, MigrationHistoryCommand, MigrationInstanceLike, MissingDelegateException, Model, ModelAttributeValue, ModelAttributes, ModelAttributesOf, ModelCreateData, ModelDeclaredAttributeKey, ModelEventDispatcher, ModelEventHandler, ModelEventHandlerConstructor, ModelEventListener, ModelEventName, ModelFactory, ModelLifecycleState, ModelMetadata, ModelNotFoundException, ModelRelationshipKey, ModelRelationshipResult, ModelStatic, ModelUpdateData, ModelsSyncCommand, MorphManyRelationMetadata, MorphOneRelationMetadata, MorphToManyRelationMetadata, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, PaginationCurrentPageResolver, PaginationMeta, PaginationOptions, PaginationURLDriver, PaginationURLDriverFactory, Paginator, PersistedColumnMappingsState, PersistedMetadataFeatures, PersistedPrimaryKeyGeneration, PersistedTableMetadata, PersistedTimestampColumn, PivotModel, PivotModelStatic, PrimaryKeyGeneration, PrimaryKeyGenerationPlanner, PrismaClientLike, PrismaDatabaseAdapter, PrismaDelegateLike, PrismaDelegateMap, PrismaDelegateNameMapping, PrismaFindManyArgsLike, PrismaLikeInclude, PrismaLikeOrderBy, PrismaLikeScalarFilter, PrismaLikeSelect, PrismaLikeSortOrder, PrismaLikeWhereInput, PrismaMigrationWorkflowOptions, PrismaSchemaSyncOptions, PrismaTransactionCallback, PrismaTransactionCapableClient, PrismaTransactionOptions, QueryBuilder, QueryComparisonCondition, QueryComparisonOperator, QueryCondition, QueryConstraintException, QueryExecutionException, QueryExecutionExceptionContext, QueryGroupCondition, QueryLogicalOperator, QueryNotCondition, QueryOrderBy, QueryRawCondition, QuerySelectColumn, QueryTarget, RelatedModelClass, RelationAggregateSpec, RelationColumnLookupSpec, RelationConstraint, RelationDefaultResolver, RelationDefaultValue, RelationFilterSpec, RelationLoadPlan, RelationLoadSpec, RelationMetadata, RelationMetadataProvider, RelationMetadataType, RelationResolutionException, RelationTableLookupSpec, RelationshipModelStatic, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, SchemaColumn, SchemaColumnType, SchemaForeignKey, SchemaForeignKeyAction, SchemaIndex, SchemaOperation, SchemaTableAlterOperation, SchemaTableCreateOperation, SchemaTableDropOperation, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, SelectSpec, Serializable, SimplePaginationMeta, SoftDeleteConfig, SoftDeleteQueryMode, SortDirection, TableBuilder, TimestampColumnBehavior, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, UpdateManySpec, UpdateSpec, UpsertSpec, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, emitRuntimeDebugEvent, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRuntimeAdapter, getRuntimeDebugHandler, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isTransactionCapableClient, loadArkormConfig, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };