arkormx 1.2.0 → 1.2.2

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
@@ -118,6 +118,7 @@ declare class ArkormCollection<T = any, X = T[]> extends Collection<T, X> {}
118
118
  //#endregion
119
119
  //#region src/types/relationship.d.ts
120
120
  type RelationConstraint<TModel> = (query: QueryBuilder<TModel>) => QueryBuilder<TModel> | void;
121
+ type RelationDefaultValue<TParent, TRelated> = Partial<ModelAttributes<TRelated>> | TRelated | ((parent: TParent) => Partial<ModelAttributes<TRelated>> | TRelated);
121
122
  //#endregion
122
123
  //#region src/relationship/Relation.d.ts
123
124
  /**
@@ -234,6 +235,12 @@ declare abstract class Relation<TModel> {
234
235
  * @returns The query builder instance with the constraint applied, if any.
235
236
  */
236
237
  protected applyConstraint(query: QueryBuilder<TModel>): QueryBuilder<TModel>;
238
+ /**
239
+ * Build the underlying query for the relationship.
240
+ *
241
+ * @returns
242
+ */
243
+ abstract getQuery(): Promise<QueryBuilder<TModel>>;
237
244
  /**
238
245
  * Execute the relationship query and return relation results.
239
246
  *
@@ -246,6 +253,24 @@ declare abstract class Relation<TModel> {
246
253
  * @returns
247
254
  */
248
255
  first(): Promise<TModel | null>;
256
+ /**
257
+ * Count records that match the relationship query.
258
+ *
259
+ * @returns
260
+ */
261
+ count(): Promise<number>;
262
+ /**
263
+ * Determine whether the relationship query has any matching records.
264
+ *
265
+ * @returns
266
+ */
267
+ exists(): Promise<boolean>;
268
+ /**
269
+ * Determine whether the relationship query has no matching records.
270
+ *
271
+ * @returns
272
+ */
273
+ doesntExist(): Promise<boolean>;
249
274
  /**
250
275
  * Get the results of the relationship query.
251
276
  *
@@ -272,6 +297,12 @@ declare class BelongsToManyRelation<TParent, TRelated> extends Relation<TRelated
272
297
  constructor(parent: TParent & {
273
298
  getAttribute: (key: string) => unknown;
274
299
  }, related: RelationshipModelStatic, throughDelegate: string, foreignPivotKey: string, relatedPivotKey: string, parentKey: string, relatedKey: string);
300
+ /**
301
+ * Build the relationship query.
302
+ *
303
+ * @returns
304
+ */
305
+ getQuery(): Promise<QueryBuilder<TRelated>>;
275
306
  /**
276
307
  * Fetches the related models for this relationship.
277
308
  *
@@ -280,6 +311,28 @@ declare class BelongsToManyRelation<TParent, TRelated> extends Relation<TRelated
280
311
  getResults(): Promise<ArkormCollection<TRelated>>;
281
312
  }
282
313
  //#endregion
314
+ //#region src/relationship/SingleResultRelation.d.ts
315
+ /**
316
+ * Base class for relationships that resolve to a single related model.
317
+ *
318
+ * @author Legacy (3m1n3nc3)
319
+ * @since 1.3.0
320
+ */
321
+ declare abstract class SingleResultRelation<TParent, TRelated> extends Relation<TRelated> {
322
+ protected readonly parent: TParent;
323
+ protected readonly related: RelatedModelClass<TRelated>;
324
+ protected defaultValue: RelationDefaultValue<object, TRelated> | undefined;
325
+ protected constructor(parent: TParent, related: RelatedModelClass<TRelated>);
326
+ /**
327
+ * Defines a default value to return when the relationship does not find a related model.
328
+ *
329
+ * @param value The default value or a callback that returns the default value.
330
+ * @returns The current instance for method chaining.
331
+ */
332
+ withDefault(value?: RelationDefaultValue<TParent, TRelated>): this;
333
+ protected resolveDefaultResult(): TRelated | null;
334
+ }
335
+ //#endregion
283
336
  //#region src/relationship/BelongsToRelation.d.ts
284
337
  /**
285
338
  * Defines an inverse one-to-one or many relationship.
@@ -287,14 +340,20 @@ declare class BelongsToManyRelation<TParent, TRelated> extends Relation<TRelated
287
340
  * @author Legacy (3m1n3nc3)
288
341
  * @since 0.1.0
289
342
  */
290
- declare class BelongsToRelation<TParent, TRelated> extends Relation<TRelated> {
291
- private readonly parent;
292
- private readonly related;
343
+ declare class BelongsToRelation<TParent, TRelated> extends SingleResultRelation<TParent & {
344
+ getAttribute: (key: string) => unknown;
345
+ }, TRelated> {
293
346
  private readonly foreignKey;
294
347
  private readonly ownerKey;
295
348
  constructor(parent: TParent & {
296
349
  getAttribute: (key: string) => unknown;
297
- }, related: RelationshipModelStatic, foreignKey: string, ownerKey: string);
350
+ }, related: RelatedModelClass<TRelated>, foreignKey: string, ownerKey: string);
351
+ /**
352
+ * Build the relationship query.
353
+ *
354
+ * @returns
355
+ */
356
+ getQuery(): Promise<QueryBuilder<TRelated>>;
298
357
  /**
299
358
  * Fetches the related models for this relationship.
300
359
  *
@@ -318,6 +377,12 @@ declare class HasManyRelation<TParent, TRelated> extends Relation<TRelated> {
318
377
  constructor(parent: TParent & {
319
378
  getAttribute: (key: string) => unknown;
320
379
  }, related: RelationshipModelStatic, foreignKey: string, localKey: string);
380
+ /**
381
+ * Build the relationship query.
382
+ *
383
+ * @returns
384
+ */
385
+ getQuery(): Promise<QueryBuilder<TRelated>>;
321
386
  /**
322
387
  * Fetches the related models for this relationship.
323
388
  *
@@ -345,6 +410,12 @@ declare class HasManyThroughRelation<TParent, TRelated> extends Relation<TRelate
345
410
  constructor(parent: TParent & {
346
411
  getAttribute: (key: string) => unknown;
347
412
  }, related: RelationshipModelStatic, throughDelegate: string, firstKey: string, secondKey: string, localKey: string, secondLocalKey: string);
413
+ /**
414
+ * Build the relationship query.
415
+ *
416
+ * @returns
417
+ */
418
+ getQuery(): Promise<QueryBuilder<TRelated>>;
348
419
  /**
349
420
  * Fetches the related models for this relationship.
350
421
  *
@@ -360,14 +431,20 @@ declare class HasManyThroughRelation<TParent, TRelated> extends Relation<TRelate
360
431
  * @author Legacy (3m1n3nc3)
361
432
  * @since 0.1.0
362
433
  */
363
- declare class HasOneRelation<TParent, TRelated> extends Relation<TRelated> {
364
- private readonly parent;
365
- private readonly related;
434
+ declare class HasOneRelation<TParent, TRelated> extends SingleResultRelation<TParent & {
435
+ getAttribute: (key: string) => unknown;
436
+ }, TRelated> {
366
437
  private readonly foreignKey;
367
438
  private readonly localKey;
368
439
  constructor(parent: TParent & {
369
440
  getAttribute: (key: string) => unknown;
370
- }, related: RelationshipModelStatic, foreignKey: string, localKey: string);
441
+ }, related: RelatedModelClass<TRelated>, foreignKey: string, localKey: string);
442
+ /**
443
+ * Build the relationship query.
444
+ *
445
+ * @returns
446
+ */
447
+ getQuery(): Promise<QueryBuilder<TRelated>>;
371
448
  /**
372
449
  * Fetches the related models for this relationship.
373
450
  *
@@ -384,9 +461,9 @@ declare class HasOneRelation<TParent, TRelated> extends Relation<TRelated> {
384
461
  * @author Legacy (3m1n3nc3)
385
462
  * @since 0.1.0
386
463
  */
387
- declare class HasOneThroughRelation<TParent, TRelated> extends Relation<TRelated> {
388
- private readonly parent;
389
- private readonly related;
464
+ declare class HasOneThroughRelation<TParent, TRelated> extends SingleResultRelation<TParent & {
465
+ getAttribute: (key: string) => unknown;
466
+ }, TRelated> {
390
467
  private readonly throughDelegate;
391
468
  private readonly firstKey;
392
469
  private readonly secondKey;
@@ -394,7 +471,13 @@ declare class HasOneThroughRelation<TParent, TRelated> extends Relation<TRelated
394
471
  private readonly secondLocalKey;
395
472
  constructor(parent: TParent & {
396
473
  getAttribute: (key: string) => unknown;
397
- }, related: RelationshipModelStatic, throughDelegate: string, firstKey: string, secondKey: string, localKey: string, secondLocalKey: string);
474
+ }, related: RelatedModelClass<TRelated>, throughDelegate: string, firstKey: string, secondKey: string, localKey: string, secondLocalKey: string);
475
+ /**
476
+ * Build the relationship query.
477
+ *
478
+ * @returns
479
+ */
480
+ getQuery(): Promise<QueryBuilder<TRelated>>;
398
481
  /**
399
482
  * Fetches the related models for this relationship.
400
483
  *
@@ -418,6 +501,12 @@ declare class MorphManyRelation<TParent, TRelated> extends Relation<TRelated> {
418
501
  constructor(parent: TParent & {
419
502
  getAttribute: (key: string) => unknown;
420
503
  }, related: RelationshipModelStatic, morphName: string, localKey: string);
504
+ /**
505
+ * Build the relationship query.
506
+ *
507
+ * @returns
508
+ */
509
+ getQuery(): Promise<QueryBuilder<TRelated>>;
421
510
  /**
422
511
  * Fetches the related models for this relationship.
423
512
  *
@@ -433,14 +522,20 @@ declare class MorphManyRelation<TParent, TRelated> extends Relation<TRelated> {
433
522
  * @author Legacy (3m1n3nc3)
434
523
  * @since 0.1.0
435
524
  */
436
- declare class MorphOneRelation<TParent, TRelated> extends Relation<TRelated> {
437
- private readonly parent;
438
- private readonly related;
525
+ declare class MorphOneRelation<TParent, TRelated> extends SingleResultRelation<TParent & {
526
+ getAttribute: (key: string) => unknown;
527
+ }, TRelated> {
439
528
  private readonly morphName;
440
529
  private readonly localKey;
441
530
  constructor(parent: TParent & {
442
531
  getAttribute: (key: string) => unknown;
443
- }, related: RelationshipModelStatic, morphName: string, localKey: string);
532
+ }, related: RelatedModelClass<TRelated>, morphName: string, localKey: string);
533
+ /**
534
+ * Build the relationship query.
535
+ *
536
+ * @returns
537
+ */
538
+ getQuery(): Promise<QueryBuilder<TRelated>>;
444
539
  /**
445
540
  * Fetches the related models for this relationship.
446
541
  *
@@ -467,6 +562,12 @@ declare class MorphToManyRelation<TParent, TRelated> extends Relation<TRelated>
467
562
  constructor(parent: TParent & {
468
563
  getAttribute: (key: string) => unknown;
469
564
  }, related: RelationshipModelStatic, throughDelegate: string, morphName: string, relatedPivotKey: string, parentKey: string, relatedKey: string);
565
+ /**
566
+ * Build the relationship query.
567
+ *
568
+ * @returns
569
+ */
570
+ getQuery(): Promise<QueryBuilder<TRelated>>;
470
571
  /**
471
572
  * Fetches the related models for this relationship.
472
573
  *
@@ -2016,7 +2117,9 @@ interface ModelStatic<TModel, TDelegate extends PrismaDelegateLike = PrismaDeleg
2016
2117
  getSoftDeleteConfig: () => SoftDeleteConfig;
2017
2118
  }
2018
2119
  interface RelationshipModelStatic {
2120
+ new (attributes?: Record<string, unknown>): any;
2019
2121
  query: () => QueryBuilder<any, any>;
2122
+ hydrate: (attributes: Record<string, unknown>) => any;
2020
2123
  getDelegate: (delegate?: string) => PrismaDelegateLike;
2021
2124
  }
2022
2125
  //#endregion
@@ -3281,17 +3384,18 @@ declare const buildIndexLine: (index: SchemaIndex) => string;
3281
3384
  */
3282
3385
  declare const deriveRelationFieldName: (columnName: string) => string;
3283
3386
  /**
3284
- * Derive a relation name for the inverse side of a relation based on the
3387
+ * Derive a relation name for both sides of a relation based on the
3285
3388
  * source and target model names, using an explicit alias if provided or a
3286
- * convention of combining the target model name with the last segment of
3287
- * the source model name.
3389
+ * convention of combining the full source model name with the target model name.
3288
3390
  *
3289
3391
  * @param sourceModelName The name of the source model in the relation.
3290
3392
  * @param targetModelName The name of the target model in the relation.
3291
- * @param explicitAlias An optional explicit alias for the inverse relation.
3292
- * @returns The derived or explicit inverse relation alias.
3393
+ * @param explicitAlias An optional explicit alias for the relation.
3394
+ * @returns The derived or explicit relation alias.
3293
3395
  */
3396
+ declare const deriveRelationAlias: (sourceModelName: string, targetModelName: string, explicitAlias?: string) => string;
3294
3397
  declare const deriveInverseRelationAlias: (sourceModelName: string, targetModelName: string, explicitAlias?: string) => string;
3398
+ declare const deriveSingularFieldName: (modelName: string) => string;
3295
3399
  declare const deriveCollectionFieldName: (modelName: string) => string;
3296
3400
  /**
3297
3401
  * Format a SchemaForeignKeyAction value as a Prisma onDelete action string.
@@ -3307,7 +3411,7 @@ declare const formatRelationAction: (action: SchemaForeignKeyAction) => string;
3307
3411
  * @param foreignKey The foreign key definition to convert to a relation line.
3308
3412
  * @returns The corresponding Prisma schema line for the relation field.
3309
3413
  */
3310
- declare const buildRelationLine: (foreignKey: SchemaForeignKey) => string;
3414
+ declare const buildRelationLine: (sourceModelName: string, foreignKey: SchemaForeignKey, columns?: SchemaColumn[]) => string;
3311
3415
  /**
3312
3416
  * Build a Prisma relation field line for the inverse side of a relation, based
3313
3417
  * on the source and target model names and the foreign key definition, using
@@ -3318,7 +3422,7 @@ declare const buildRelationLine: (foreignKey: SchemaForeignKey) => string;
3318
3422
  * @param foreignKey The foreign key definition for the relation.
3319
3423
  * @returns The Prisma schema line for the inverse relation field.
3320
3424
  */
3321
- declare const buildInverseRelationLine: (sourceModelName: string, targetModelName: string, foreignKey: SchemaForeignKey) => string;
3425
+ declare const buildInverseRelationLine: (sourceModelName: string, targetModelName: string, foreignKey: SchemaForeignKey, columns?: SchemaColumn[]) => string;
3322
3426
  /**
3323
3427
  * Build a Prisma model block string based on a SchemaTableCreateOperation, including
3324
3428
  * all fields and any necessary mapping.
@@ -3598,4 +3702,4 @@ declare class URLDriver {
3598
3702
  url(page: number): string;
3599
3703
  }
3600
3704
  //#endregion
3601
- export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, 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 };
3705
+ export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, 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 };
package/dist/index.d.mts CHANGED
@@ -118,6 +118,7 @@ declare class ArkormCollection<T = any, X = T[]> extends Collection<T, X> {}
118
118
  //#endregion
119
119
  //#region src/types/relationship.d.ts
120
120
  type RelationConstraint<TModel> = (query: QueryBuilder<TModel>) => QueryBuilder<TModel> | void;
121
+ type RelationDefaultValue<TParent, TRelated> = Partial<ModelAttributes<TRelated>> | TRelated | ((parent: TParent) => Partial<ModelAttributes<TRelated>> | TRelated);
121
122
  //#endregion
122
123
  //#region src/relationship/Relation.d.ts
123
124
  /**
@@ -234,6 +235,12 @@ declare abstract class Relation<TModel> {
234
235
  * @returns The query builder instance with the constraint applied, if any.
235
236
  */
236
237
  protected applyConstraint(query: QueryBuilder<TModel>): QueryBuilder<TModel>;
238
+ /**
239
+ * Build the underlying query for the relationship.
240
+ *
241
+ * @returns
242
+ */
243
+ abstract getQuery(): Promise<QueryBuilder<TModel>>;
237
244
  /**
238
245
  * Execute the relationship query and return relation results.
239
246
  *
@@ -246,6 +253,24 @@ declare abstract class Relation<TModel> {
246
253
  * @returns
247
254
  */
248
255
  first(): Promise<TModel | null>;
256
+ /**
257
+ * Count records that match the relationship query.
258
+ *
259
+ * @returns
260
+ */
261
+ count(): Promise<number>;
262
+ /**
263
+ * Determine whether the relationship query has any matching records.
264
+ *
265
+ * @returns
266
+ */
267
+ exists(): Promise<boolean>;
268
+ /**
269
+ * Determine whether the relationship query has no matching records.
270
+ *
271
+ * @returns
272
+ */
273
+ doesntExist(): Promise<boolean>;
249
274
  /**
250
275
  * Get the results of the relationship query.
251
276
  *
@@ -272,6 +297,12 @@ declare class BelongsToManyRelation<TParent, TRelated> extends Relation<TRelated
272
297
  constructor(parent: TParent & {
273
298
  getAttribute: (key: string) => unknown;
274
299
  }, related: RelationshipModelStatic, throughDelegate: string, foreignPivotKey: string, relatedPivotKey: string, parentKey: string, relatedKey: string);
300
+ /**
301
+ * Build the relationship query.
302
+ *
303
+ * @returns
304
+ */
305
+ getQuery(): Promise<QueryBuilder<TRelated>>;
275
306
  /**
276
307
  * Fetches the related models for this relationship.
277
308
  *
@@ -280,6 +311,28 @@ declare class BelongsToManyRelation<TParent, TRelated> extends Relation<TRelated
280
311
  getResults(): Promise<ArkormCollection<TRelated>>;
281
312
  }
282
313
  //#endregion
314
+ //#region src/relationship/SingleResultRelation.d.ts
315
+ /**
316
+ * Base class for relationships that resolve to a single related model.
317
+ *
318
+ * @author Legacy (3m1n3nc3)
319
+ * @since 1.3.0
320
+ */
321
+ declare abstract class SingleResultRelation<TParent, TRelated> extends Relation<TRelated> {
322
+ protected readonly parent: TParent;
323
+ protected readonly related: RelatedModelClass<TRelated>;
324
+ protected defaultValue: RelationDefaultValue<object, TRelated> | undefined;
325
+ protected constructor(parent: TParent, related: RelatedModelClass<TRelated>);
326
+ /**
327
+ * Defines a default value to return when the relationship does not find a related model.
328
+ *
329
+ * @param value The default value or a callback that returns the default value.
330
+ * @returns The current instance for method chaining.
331
+ */
332
+ withDefault(value?: RelationDefaultValue<TParent, TRelated>): this;
333
+ protected resolveDefaultResult(): TRelated | null;
334
+ }
335
+ //#endregion
283
336
  //#region src/relationship/BelongsToRelation.d.ts
284
337
  /**
285
338
  * Defines an inverse one-to-one or many relationship.
@@ -287,14 +340,20 @@ declare class BelongsToManyRelation<TParent, TRelated> extends Relation<TRelated
287
340
  * @author Legacy (3m1n3nc3)
288
341
  * @since 0.1.0
289
342
  */
290
- declare class BelongsToRelation<TParent, TRelated> extends Relation<TRelated> {
291
- private readonly parent;
292
- private readonly related;
343
+ declare class BelongsToRelation<TParent, TRelated> extends SingleResultRelation<TParent & {
344
+ getAttribute: (key: string) => unknown;
345
+ }, TRelated> {
293
346
  private readonly foreignKey;
294
347
  private readonly ownerKey;
295
348
  constructor(parent: TParent & {
296
349
  getAttribute: (key: string) => unknown;
297
- }, related: RelationshipModelStatic, foreignKey: string, ownerKey: string);
350
+ }, related: RelatedModelClass<TRelated>, foreignKey: string, ownerKey: string);
351
+ /**
352
+ * Build the relationship query.
353
+ *
354
+ * @returns
355
+ */
356
+ getQuery(): Promise<QueryBuilder<TRelated>>;
298
357
  /**
299
358
  * Fetches the related models for this relationship.
300
359
  *
@@ -318,6 +377,12 @@ declare class HasManyRelation<TParent, TRelated> extends Relation<TRelated> {
318
377
  constructor(parent: TParent & {
319
378
  getAttribute: (key: string) => unknown;
320
379
  }, related: RelationshipModelStatic, foreignKey: string, localKey: string);
380
+ /**
381
+ * Build the relationship query.
382
+ *
383
+ * @returns
384
+ */
385
+ getQuery(): Promise<QueryBuilder<TRelated>>;
321
386
  /**
322
387
  * Fetches the related models for this relationship.
323
388
  *
@@ -345,6 +410,12 @@ declare class HasManyThroughRelation<TParent, TRelated> extends Relation<TRelate
345
410
  constructor(parent: TParent & {
346
411
  getAttribute: (key: string) => unknown;
347
412
  }, related: RelationshipModelStatic, throughDelegate: string, firstKey: string, secondKey: string, localKey: string, secondLocalKey: string);
413
+ /**
414
+ * Build the relationship query.
415
+ *
416
+ * @returns
417
+ */
418
+ getQuery(): Promise<QueryBuilder<TRelated>>;
348
419
  /**
349
420
  * Fetches the related models for this relationship.
350
421
  *
@@ -360,14 +431,20 @@ declare class HasManyThroughRelation<TParent, TRelated> extends Relation<TRelate
360
431
  * @author Legacy (3m1n3nc3)
361
432
  * @since 0.1.0
362
433
  */
363
- declare class HasOneRelation<TParent, TRelated> extends Relation<TRelated> {
364
- private readonly parent;
365
- private readonly related;
434
+ declare class HasOneRelation<TParent, TRelated> extends SingleResultRelation<TParent & {
435
+ getAttribute: (key: string) => unknown;
436
+ }, TRelated> {
366
437
  private readonly foreignKey;
367
438
  private readonly localKey;
368
439
  constructor(parent: TParent & {
369
440
  getAttribute: (key: string) => unknown;
370
- }, related: RelationshipModelStatic, foreignKey: string, localKey: string);
441
+ }, related: RelatedModelClass<TRelated>, foreignKey: string, localKey: string);
442
+ /**
443
+ * Build the relationship query.
444
+ *
445
+ * @returns
446
+ */
447
+ getQuery(): Promise<QueryBuilder<TRelated>>;
371
448
  /**
372
449
  * Fetches the related models for this relationship.
373
450
  *
@@ -384,9 +461,9 @@ declare class HasOneRelation<TParent, TRelated> extends Relation<TRelated> {
384
461
  * @author Legacy (3m1n3nc3)
385
462
  * @since 0.1.0
386
463
  */
387
- declare class HasOneThroughRelation<TParent, TRelated> extends Relation<TRelated> {
388
- private readonly parent;
389
- private readonly related;
464
+ declare class HasOneThroughRelation<TParent, TRelated> extends SingleResultRelation<TParent & {
465
+ getAttribute: (key: string) => unknown;
466
+ }, TRelated> {
390
467
  private readonly throughDelegate;
391
468
  private readonly firstKey;
392
469
  private readonly secondKey;
@@ -394,7 +471,13 @@ declare class HasOneThroughRelation<TParent, TRelated> extends Relation<TRelated
394
471
  private readonly secondLocalKey;
395
472
  constructor(parent: TParent & {
396
473
  getAttribute: (key: string) => unknown;
397
- }, related: RelationshipModelStatic, throughDelegate: string, firstKey: string, secondKey: string, localKey: string, secondLocalKey: string);
474
+ }, related: RelatedModelClass<TRelated>, throughDelegate: string, firstKey: string, secondKey: string, localKey: string, secondLocalKey: string);
475
+ /**
476
+ * Build the relationship query.
477
+ *
478
+ * @returns
479
+ */
480
+ getQuery(): Promise<QueryBuilder<TRelated>>;
398
481
  /**
399
482
  * Fetches the related models for this relationship.
400
483
  *
@@ -418,6 +501,12 @@ declare class MorphManyRelation<TParent, TRelated> extends Relation<TRelated> {
418
501
  constructor(parent: TParent & {
419
502
  getAttribute: (key: string) => unknown;
420
503
  }, related: RelationshipModelStatic, morphName: string, localKey: string);
504
+ /**
505
+ * Build the relationship query.
506
+ *
507
+ * @returns
508
+ */
509
+ getQuery(): Promise<QueryBuilder<TRelated>>;
421
510
  /**
422
511
  * Fetches the related models for this relationship.
423
512
  *
@@ -433,14 +522,20 @@ declare class MorphManyRelation<TParent, TRelated> extends Relation<TRelated> {
433
522
  * @author Legacy (3m1n3nc3)
434
523
  * @since 0.1.0
435
524
  */
436
- declare class MorphOneRelation<TParent, TRelated> extends Relation<TRelated> {
437
- private readonly parent;
438
- private readonly related;
525
+ declare class MorphOneRelation<TParent, TRelated> extends SingleResultRelation<TParent & {
526
+ getAttribute: (key: string) => unknown;
527
+ }, TRelated> {
439
528
  private readonly morphName;
440
529
  private readonly localKey;
441
530
  constructor(parent: TParent & {
442
531
  getAttribute: (key: string) => unknown;
443
- }, related: RelationshipModelStatic, morphName: string, localKey: string);
532
+ }, related: RelatedModelClass<TRelated>, morphName: string, localKey: string);
533
+ /**
534
+ * Build the relationship query.
535
+ *
536
+ * @returns
537
+ */
538
+ getQuery(): Promise<QueryBuilder<TRelated>>;
444
539
  /**
445
540
  * Fetches the related models for this relationship.
446
541
  *
@@ -467,6 +562,12 @@ declare class MorphToManyRelation<TParent, TRelated> extends Relation<TRelated>
467
562
  constructor(parent: TParent & {
468
563
  getAttribute: (key: string) => unknown;
469
564
  }, related: RelationshipModelStatic, throughDelegate: string, morphName: string, relatedPivotKey: string, parentKey: string, relatedKey: string);
565
+ /**
566
+ * Build the relationship query.
567
+ *
568
+ * @returns
569
+ */
570
+ getQuery(): Promise<QueryBuilder<TRelated>>;
470
571
  /**
471
572
  * Fetches the related models for this relationship.
472
573
  *
@@ -2016,7 +2117,9 @@ interface ModelStatic<TModel, TDelegate extends PrismaDelegateLike = PrismaDeleg
2016
2117
  getSoftDeleteConfig: () => SoftDeleteConfig;
2017
2118
  }
2018
2119
  interface RelationshipModelStatic {
2120
+ new (attributes?: Record<string, unknown>): any;
2019
2121
  query: () => QueryBuilder<any, any>;
2122
+ hydrate: (attributes: Record<string, unknown>) => any;
2020
2123
  getDelegate: (delegate?: string) => PrismaDelegateLike;
2021
2124
  }
2022
2125
  //#endregion
@@ -3281,17 +3384,18 @@ declare const buildIndexLine: (index: SchemaIndex) => string;
3281
3384
  */
3282
3385
  declare const deriveRelationFieldName: (columnName: string) => string;
3283
3386
  /**
3284
- * Derive a relation name for the inverse side of a relation based on the
3387
+ * Derive a relation name for both sides of a relation based on the
3285
3388
  * source and target model names, using an explicit alias if provided or a
3286
- * convention of combining the target model name with the last segment of
3287
- * the source model name.
3389
+ * convention of combining the full source model name with the target model name.
3288
3390
  *
3289
3391
  * @param sourceModelName The name of the source model in the relation.
3290
3392
  * @param targetModelName The name of the target model in the relation.
3291
- * @param explicitAlias An optional explicit alias for the inverse relation.
3292
- * @returns The derived or explicit inverse relation alias.
3393
+ * @param explicitAlias An optional explicit alias for the relation.
3394
+ * @returns The derived or explicit relation alias.
3293
3395
  */
3396
+ declare const deriveRelationAlias: (sourceModelName: string, targetModelName: string, explicitAlias?: string) => string;
3294
3397
  declare const deriveInverseRelationAlias: (sourceModelName: string, targetModelName: string, explicitAlias?: string) => string;
3398
+ declare const deriveSingularFieldName: (modelName: string) => string;
3295
3399
  declare const deriveCollectionFieldName: (modelName: string) => string;
3296
3400
  /**
3297
3401
  * Format a SchemaForeignKeyAction value as a Prisma onDelete action string.
@@ -3307,7 +3411,7 @@ declare const formatRelationAction: (action: SchemaForeignKeyAction) => string;
3307
3411
  * @param foreignKey The foreign key definition to convert to a relation line.
3308
3412
  * @returns The corresponding Prisma schema line for the relation field.
3309
3413
  */
3310
- declare const buildRelationLine: (foreignKey: SchemaForeignKey) => string;
3414
+ declare const buildRelationLine: (sourceModelName: string, foreignKey: SchemaForeignKey, columns?: SchemaColumn[]) => string;
3311
3415
  /**
3312
3416
  * Build a Prisma relation field line for the inverse side of a relation, based
3313
3417
  * on the source and target model names and the foreign key definition, using
@@ -3318,7 +3422,7 @@ declare const buildRelationLine: (foreignKey: SchemaForeignKey) => string;
3318
3422
  * @param foreignKey The foreign key definition for the relation.
3319
3423
  * @returns The Prisma schema line for the inverse relation field.
3320
3424
  */
3321
- declare const buildInverseRelationLine: (sourceModelName: string, targetModelName: string, foreignKey: SchemaForeignKey) => string;
3425
+ declare const buildInverseRelationLine: (sourceModelName: string, targetModelName: string, foreignKey: SchemaForeignKey, columns?: SchemaColumn[]) => string;
3322
3426
  /**
3323
3427
  * Build a Prisma model block string based on a SchemaTableCreateOperation, including
3324
3428
  * all fields and any necessary mapping.
@@ -3598,4 +3702,4 @@ declare class URLDriver {
3598
3702
  url(page: number): string;
3599
3703
  }
3600
3704
  //#endregion
3601
- export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, 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 };
3705
+ export { ArkormCollection, ArkormErrorContext, ArkormException, Attribute, AttributeOptions, CliApp, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, QueryConstraintException, RelationResolutionException, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToPrismaSchema, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildRelationLine, computeMigrationChecksum, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, ensureArkormConfigLoading, escapeRegex, findAppliedMigration, findEnumBlock, findModelBlock, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, generateMigrationFile, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, 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 };