arkormx 2.5.2 → 2.5.4

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as deletePersistedColumnMappingsState, $t as runPrismaCommand, A as isDelegateLike, An as UnsupportedAdapterFeatureException, At as buildModelBlock, B as getRegisteredSeeders, Bt as escapeRegex, C as getRuntimeAdapter, Cn as readAppliedMigrationsStateFromStore, Ct as applyMigrationToPrismaSchema, D as getRuntimePaginationURLDriverFactory, Dn as writeAppliedMigrationsState, Dt as buildIndexLine, E as getRuntimePaginationCurrentPageResolver, En as supportsDatabaseMigrationState, Et as buildFieldLine, F as runArkormTransaction, Fn as ArkormException, Ft as deriveCollectionFieldName, G as registerFactories, Gt as formatRelationAction, H as loadMigrationsFrom, Ht as findModelBlock, I as getRegisteredFactories, It as deriveInverseRelationAlias, J as registerPaths, Jt as pad, K as registerMigrations, Kt as generateMigrationFile, L as getRegisteredMigrations, Lt as deriveRelationAlias, M as isTransactionCapableClient, Mt as buildRelationLine, N as loadArkormConfig, Nn as RelationResolutionException, Nt as buildUniqueConstraintLine, O as getRuntimePrismaClient, On as writeAppliedMigrationsStateToStore, Ot as buildInverseRelationLine, P as resetArkormRuntimeForTests, Pn as ArkormCollection, Pt as createMigrationTimestamp, Q as createEmptyPersistedColumnMappingsState, Qt as runMigrationWithPrisma, R as getRegisteredModels, Rt as deriveRelationFieldName, S as getDefaultStubsPath, Sn as readAppliedMigrationsState, St as applyMigrationToDatabase, T as getRuntimeDebugHandler, Tn as resolveMigrationStateFilePath, Tt as buildEnumBlock, U as loadModelsFrom, Ut as formatDefaultValue, V as loadFactoriesFrom, Vt as findEnumBlock, W as loadSeedersFrom, Wt as formatEnumDefaultValue, X as resetRuntimeRegistryForTests, Xt as resolveMigrationClassName, Y as registerSeeders, Yt as resolveEnumName, Z as applyOperationsToPersistedColumnMappingsState, Zt as resolvePrismaType, _ as defineConfig, _n as getLastMigrationRun, _t as applyAlterTableOperation, a as HasOneRelation, an as toModelName, at as getPersistedTimestampColumns, b as getActiveTransactionAdapter, bn as markMigrationApplied, bt as applyMigrationRollbackToDatabase, c as BelongsToRelation, cn as TableBuilder, ct as resetPersistedColumnMappingsCache, d as Relation, dn as buildMigrationIdentity, dt as syncPersistedColumnMappingsFromState, en as stripPrismaSchemaModelsAndEnums, et as getPersistedColumnMap, f as LengthAwarePaginator, fn as buildMigrationRunId, ft as validatePersistedMetadataFeaturesForMigrations, g as configureArkormRuntime, gn as findAppliedMigration, gt as PRISMA_MODEL_REGEX, h as bindAdapterToModels, hn as deleteAppliedMigrationsStateFromStore, ht as PRISMA_ENUM_REGEX, i as HasOneThroughRelation, in as toMigrationFileSlug, it as getPersistedTableMetadata, j as isQuerySchemaLike, jn as SetBasedEagerLoader, jt as buildPrimaryKeyLine, k as getUserConfig, kn as RuntimeModuleLoader, kt as buildMigrationSource, ln as PrimaryKeyGenerationPlanner, lt as resolveColumnMappingsFilePath, m as URLDriver, mn as createEmptyAppliedMigrationsState, mt as PRISMA_ENUM_MEMBER_REGEX, n as MorphOneRelation, nn as supportsDatabaseMigrationExecution, nt as getPersistedEnumTsType, o as HasManyThroughRelation, on as SchemaBuilder, ot as readPersistedColumnMappingsState, p as Paginator, pn as computeMigrationChecksum, pt as writePersistedColumnMappingsState, q as registerModels, qt as getMigrationPlan, r as MorphManyRelation, rn as supportsDatabaseReset, rt as getPersistedPrimaryKeyGeneration, s as HasManyRelation, sn as EnumBuilder, st as rebuildPersistedColumnMappingsState, t as MorphToManyRelation, tn as supportsDatabaseCreation, tt as getPersistedEnumMap, u as BelongsToManyRelation, un as ForeignKeyBuilder, ut as resolvePersistedMetadataFeatures, v as emitRuntimeDebugEvent, vn as getLatestAppliedMigrations, vt as applyCreateTableOperation, w as getRuntimeClient, wn as removeAppliedMigration, wt as applyOperationsToPrismaSchema, x as getActiveTransactionClient, xn as markMigrationRun, xt as applyMigrationRollbackToPrismaSchema, y as ensureArkormConfigLoading, yn as isMigrationApplied, yt as applyDropTableOperation, z as getRegisteredPaths, zt as deriveSingularFieldName } from "./relationship-6Los0yWA.mjs";
1
+ import { $ as applyOperationsToPersistedColumnMappingsState, $t as resolvePrismaType, A as getRuntimePrismaClient, An as writeAppliedMigrationsStateToStore, At as buildInverseRelationLine, B as getRegisteredModels, Bt as deriveRelationFieldName, C as getActiveTransactionClient, Cn as markMigrationRun, Ct as applyMigrationRollbackToPrismaSchema, D as getRuntimeDebugHandler, Dn as resolveMigrationStateFilePath, Dt as buildEnumBlock, E as getRuntimeClient, En as removeAppliedMigration, Et as applyOperationsToPrismaSchema, F as loadArkormConfig, Fn as RelationResolutionException, Ft as buildUniqueConstraintLine, G as loadModelsFrom, Gt as formatDefaultValue, H as getRegisteredSeeders, Ht as escapeRegex, I as resetArkormRuntimeForTests, In as ArkormCollection, It as createMigrationTimestamp, J as registerMigrations, Jt as generateMigrationFile, K as loadSeedersFrom, Kt as formatEnumDefaultValue, L as runArkormTransaction, Ln as ArkormException, Lt as deriveCollectionFieldName, M as isDelegateLike, Mn as UnsupportedAdapterFeatureException, Mt as buildModelBlock, N as isQuerySchemaLike, Nn as SetBasedEagerLoader, Nt as buildPrimaryKeyLine, O as getRuntimePaginationCurrentPageResolver, On as supportsDatabaseMigrationState, Ot as buildFieldLine, P as isTransactionCapableClient, Pt as buildRelationLine, Q as resetRuntimeRegistryForTests, Qt as resolveMigrationClassName, R as getRegisteredFactories, Rt as deriveInverseRelationAlias, S as getActiveTransactionAdapter, Sn as markMigrationApplied, St as applyMigrationRollbackToDatabase, T as getRuntimeAdapter, Tn as readAppliedMigrationsStateFromStore, Tt as applyMigrationToPrismaSchema, U as loadFactoriesFrom, Ut as findEnumBlock, V as getRegisteredPaths, Vt as deriveSingularFieldName, W as loadMigrationsFrom, Wt as findModelBlock, X as registerPaths, Xt as pad, Y as registerModels, Yt as getMigrationPlan, Z as registerSeeders, Zt as resolveEnumName, _ as bindAdapterToModels, _n as deleteAppliedMigrationsStateFromStore, _t as PRISMA_ENUM_REGEX, a as HasOneThroughRelation, an as supportsDatabaseReset, at as getPersistedPrimaryKeyGeneration, b as emitRuntimeDebugEvent, bn as getLatestAppliedMigrations, bt as applyCreateTableOperation, c as HasManyRelation, cn as SchemaBuilder, ct as readPersistedColumnMappingsState, d as BelongsToManyRelation, dn as PrimaryKeyGenerationPlanner, dt as resolveColumnMappingsFilePath, en as runMigrationWithPrisma, et as createEmptyPersistedColumnMappingsState, f as Relation, fn as ForeignKeyBuilder, ft as resolvePersistedMetadataFeatures, g as awaitConfiguredModelsRegistration, gn as createEmptyAppliedMigrationsState, gt as PRISMA_ENUM_MEMBER_REGEX, h as URLDriver, hn as computeMigrationChecksum, ht as writePersistedColumnMappingsState, i as MorphManyRelation, in as supportsDatabaseMigrationExecution, it as getPersistedEnumTsType, j as getUserConfig, jn as RuntimeModuleLoader, jt as buildMigrationSource, k as getRuntimePaginationURLDriverFactory, kn as writeAppliedMigrationsState, kt as buildIndexLine, l as BelongsToRelation, ln as EnumBuilder, lt as rebuildPersistedColumnMappingsState, m as Paginator, mn as buildMigrationRunId, mt as validatePersistedMetadataFeaturesForMigrations, n as MorphToManyRelation, nn as stripPrismaSchemaModelsAndEnums, nt as getPersistedColumnMap, o as HasOneRelation, on as toMigrationFileSlug, ot as getPersistedTableMetadata, p as LengthAwarePaginator, pn as buildMigrationIdentity, pt as syncPersistedColumnMappingsFromState, q as registerFactories, qt as formatRelationAction, r as MorphOneRelation, rn as supportsDatabaseCreation, rt as getPersistedEnumMap, s as HasManyThroughRelation, sn as toModelName, st as getPersistedTimestampColumns, t as MorphToRelation, tn as runPrismaCommand, tt as deletePersistedColumnMappingsState, un as TableBuilder, ut as resetPersistedColumnMappingsCache, v as configureArkormRuntime, vn as findAppliedMigration, vt as PRISMA_MODEL_REGEX, w as getDefaultStubsPath, wn as readAppliedMigrationsState, wt as applyMigrationToDatabase, x as ensureArkormConfigLoading, xn as isMigrationApplied, xt as applyDropTableOperation, y as defineConfig, yn as getLastMigrationRun, yt as applyAlterTableOperation, z as getRegisteredMigrations, zt as deriveRelationAlias } from "./relationship-7rzMKbqq.mjs";
2
2
  import { Pool } from "pg";
3
3
  import { join, resolve } from "node:path";
4
4
  import { createRequire } from "module";
@@ -5457,7 +5457,8 @@ var QueryBuilder = class QueryBuilder {
5457
5457
  const toPlans = (owner, nodes) => {
5458
5458
  const plans = [];
5459
5459
  for (const [relation, node] of nodes.entries()) {
5460
- const relatedModel = owner.getRelationMetadata(relation)?.relatedModel;
5460
+ const metadata = owner.getRelationMetadata(relation);
5461
+ const relatedModel = metadata && "relatedModel" in metadata ? metadata.relatedModel : void 0;
5461
5462
  if (!relatedModel) return null;
5462
5463
  const relatedQuery = relatedModel.query();
5463
5464
  const constrained = node.constraint ? node.constraint(relatedQuery) : relatedQuery;
@@ -6059,7 +6060,8 @@ var QueryBuilder = class QueryBuilder {
6059
6060
  tryBuildRelationConstraintWhere(relation, callback) {
6060
6061
  const metadata = this.model.getRelationMetadata(relation);
6061
6062
  if (!this.isSqlRelationFeatureMetadata(metadata)) return null;
6062
- const relatedQuery = metadata?.relatedModel.query();
6063
+ if (!metadata || !("relatedModel" in metadata)) return null;
6064
+ const relatedQuery = metadata.relatedModel.query();
6063
6065
  if (!relatedQuery) return null;
6064
6066
  if (callback) {
6065
6067
  const constrained = callback(relatedQuery);
@@ -7159,6 +7161,12 @@ var Model = class Model {
7159
7161
  const columns = this.resolveMorphColumns(morphName, idColumn, typeColumn);
7160
7162
  return new MorphManyRelation(this, related, morphName, columns.idColumn, columns.typeColumn, localKey ?? constructor.getPrimaryKey());
7161
7163
  }
7164
+ morphTo(morphName, typeColumnOrRelated, idColumn, ownerKey) {
7165
+ const related = typeof typeColumnOrRelated === "function" ? typeColumnOrRelated : void 0;
7166
+ const typeColumn = typeof typeColumnOrRelated === "string" ? typeColumnOrRelated : void 0;
7167
+ const columns = this.resolveMorphColumns(morphName, idColumn, typeColumn);
7168
+ return new MorphToRelation(this, morphName, columns.typeColumn, columns.idColumn, ownerKey, related);
7169
+ }
7162
7170
  /**
7163
7171
  * Define a polymorphic many to many relationship.
7164
7172
  *
@@ -8065,4 +8073,4 @@ var PivotModel = class extends Model {
8065
8073
  };
8066
8074
 
8067
8075
  //#endregion
8068
- export { Arkorm, ArkormCollection, ArkormException, Arkormx, Attribute, CliApp, DB, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PivotModel, PrimaryKeyGenerationPlanner, PrismaDatabaseAdapter, QueryBuilder, QueryConstraintException, QueryExecutionException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildPrimaryKeyLine, buildRelationLine, buildUniqueConstraintLine, 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, getActiveTransactionAdapter, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRegisteredFactories, getRegisteredMigrations, getRegisteredModels, getRegisteredPaths, getRegisteredSeeders, getRuntimeAdapter, getRuntimeClient, getRuntimeCompatibilityAdapter, getRuntimeDebugHandler, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isQuerySchemaLike, isTransactionCapableClient, loadArkormConfig, loadFactoriesFrom, loadMigrationsFrom, loadModelsFrom, loadSeedersFrom, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, registerFactories, registerMigrations, registerModels, registerPaths, registerSeeders, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resetRuntimeRegistryForTests, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, resolveRuntimeCompatibilityQuerySchema, resolveRuntimeCompatibilityQuerySchemaOrThrow, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseCreation, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
8076
+ export { Arkorm, ArkormCollection, ArkormException, Arkormx, Attribute, CliApp, DB, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, KyselyDatabaseAdapter, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateFreshCommand, MigrateRollbackCommand, Migration, MigrationHistoryCommand, MissingDelegateException, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_ENUM_MEMBER_REGEX, PRISMA_ENUM_REGEX, PRISMA_MODEL_REGEX, Paginator, PivotModel, PrimaryKeyGenerationPlanner, PrismaDatabaseAdapter, QueryBuilder, QueryConstraintException, QueryExecutionException, RelationResolutionException, RuntimeModuleLoader, SEEDER_BRAND, SchemaBuilder, ScopeNotDefinedException, SeedCommand, Seeder, TableBuilder, URLDriver, UniqueConstraintResolutionException, UnsupportedAdapterFeatureException, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationRollbackToDatabase, applyMigrationRollbackToPrismaSchema, applyMigrationToDatabase, applyMigrationToPrismaSchema, applyOperationsToPersistedColumnMappingsState, applyOperationsToPrismaSchema, awaitConfiguredModelsRegistration, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildPrimaryKeyLine, buildRelationLine, buildUniqueConstraintLine, 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, getActiveTransactionAdapter, getActiveTransactionClient, getDefaultStubsPath, getLastMigrationRun, getLatestAppliedMigrations, getMigrationPlan, getPersistedColumnMap, getPersistedEnumMap, getPersistedEnumTsType, getPersistedPrimaryKeyGeneration, getPersistedTableMetadata, getPersistedTimestampColumns, getRegisteredFactories, getRegisteredMigrations, getRegisteredModels, getRegisteredPaths, getRegisteredSeeders, getRuntimeAdapter, getRuntimeClient, getRuntimeCompatibilityAdapter, getRuntimeDebugHandler, getRuntimePaginationCurrentPageResolver, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, isMigrationApplied, isQuerySchemaLike, isTransactionCapableClient, loadArkormConfig, loadFactoriesFrom, loadMigrationsFrom, loadModelsFrom, loadSeedersFrom, markMigrationApplied, markMigrationRun, pad, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, registerFactories, registerMigrations, registerModels, registerPaths, registerSeeders, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resetRuntimeRegistryForTests, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, resolveRuntimeCompatibilityQuerySchema, resolveRuntimeCompatibilityQuerySchemaOrThrow, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, supportsDatabaseCreation, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, validatePersistedMetadataFeaturesForMigrations, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_relationship = require('../relationship-BOPI6ila.cjs');
2
+ const require_relationship = require('../relationship-BS1AHptf.cjs');
3
3
 
4
4
  exports.BelongsToManyRelation = require_relationship.BelongsToManyRelation;
5
5
  exports.BelongsToRelation = require_relationship.BelongsToRelation;
@@ -10,6 +10,7 @@ exports.HasOneThroughRelation = require_relationship.HasOneThroughRelation;
10
10
  exports.MorphManyRelation = require_relationship.MorphManyRelation;
11
11
  exports.MorphOneRelation = require_relationship.MorphOneRelation;
12
12
  exports.MorphToManyRelation = require_relationship.MorphToManyRelation;
13
+ exports.MorphToRelation = require_relationship.MorphToRelation;
13
14
  exports.Relation = require_relationship.Relation;
14
15
  exports.RelationTableLoader = require_relationship.RelationTableLoader;
15
16
  exports.SetBasedEagerLoader = require_relationship.SetBasedEagerLoader;
@@ -1,2 +1,2 @@
1
- import { ao as MorphManyRelation, co as HasManyThroughRelation, do as SingleResultRelation, fo as BelongsToManyRelation, io as MorphOneRelation, lo as HasManyRelation, mo as RelationTableLoader, no as SetBasedEagerLoader, oo as HasOneThroughRelation, po as Relation, ro as MorphToManyRelation, so as HasOneRelation, uo as BelongsToRelation } from "../index-DsqCSA9u.cjs";
2
- export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
1
+ import { _o as BelongsToManyRelation, co as MorphToManyRelation, do as HasOneThroughRelation, fo as HasOneRelation, go as SingleResultRelation, ho as BelongsToRelation, lo as MorphOneRelation, mo as HasManyRelation, oo as SetBasedEagerLoader, po as HasManyThroughRelation, so as MorphToRelation, uo as MorphManyRelation, vo as Relation, yo as RelationTableLoader } from "../index-DDpAZm-_.cjs";
2
+ export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -1,2 +1,2 @@
1
- import { ao as MorphManyRelation, co as HasManyThroughRelation, do as SingleResultRelation, fo as BelongsToManyRelation, io as MorphOneRelation, lo as HasManyRelation, mo as RelationTableLoader, no as SetBasedEagerLoader, oo as HasOneThroughRelation, po as Relation, ro as MorphToManyRelation, so as HasOneRelation, uo as BelongsToRelation } from "../index-Does1dxC.mjs";
2
- export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
1
+ import { _o as BelongsToManyRelation, co as MorphToManyRelation, do as HasOneThroughRelation, fo as HasOneRelation, go as SingleResultRelation, ho as BelongsToRelation, lo as MorphOneRelation, mo as HasManyRelation, oo as SetBasedEagerLoader, po as HasManyThroughRelation, so as MorphToRelation, uo as MorphManyRelation, vo as Relation, yo as RelationTableLoader } from "../index-CnwdCOkd.mjs";
2
+ export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -1,3 +1,3 @@
1
- import { Mn as RelationTableLoader, a as HasOneRelation, c as BelongsToRelation, d as Relation, i as HasOneThroughRelation, jn as SetBasedEagerLoader, l as SingleResultRelation, n as MorphOneRelation, o as HasManyThroughRelation, r as MorphManyRelation, s as HasManyRelation, t as MorphToManyRelation, u as BelongsToManyRelation } from "../relationship-6Los0yWA.mjs";
1
+ import { Nn as SetBasedEagerLoader, Pn as RelationTableLoader, a as HasOneThroughRelation, c as HasManyRelation, d as BelongsToManyRelation, f as Relation, i as MorphManyRelation, l as BelongsToRelation, n as MorphToManyRelation, o as HasOneRelation, r as MorphOneRelation, s as HasManyThroughRelation, t as MorphToRelation, u as SingleResultRelation } from "../relationship-7rzMKbqq.mjs";
2
2
 
3
- export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
3
+ export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -4,7 +4,7 @@ import { createJiti } from "jiti";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import { dirname, extname, join, resolve } from "node:path";
6
6
  import { createRequire } from "module";
7
- import { existsSync } from "fs";
7
+ import { existsSync, readdirSync } from "fs";
8
8
  import { fileURLToPath } from "url";
9
9
  import path from "path";
10
10
  import { existsSync as existsSync$1, mkdirSync as mkdirSync$1, readFileSync as readFileSync$1, rmSync as rmSync$1, writeFileSync as writeFileSync$1 } from "node:fs";
@@ -2905,6 +2905,8 @@ const userConfig = {
2905
2905
  };
2906
2906
  let runtimeConfigLoaded = false;
2907
2907
  let runtimeConfigLoadingPromise;
2908
+ let runtimeModelRegistrationPromise;
2909
+ let runtimeModelRegistrationGeneration = 0;
2908
2910
  let runtimeClientResolver;
2909
2911
  let runtimeAdapter;
2910
2912
  let runtimePaginationURLDriverFactory;
@@ -2970,6 +2972,51 @@ const mergeFeatureConfig = (features) => {
2970
2972
  ...features ?? {}
2971
2973
  };
2972
2974
  };
2975
+ const resolveRuntimeModelsDirectory = (directory) => {
2976
+ if (existsSync(directory)) return directory;
2977
+ const buildOutput = userConfig.paths?.buildOutput;
2978
+ if (typeof buildOutput !== "string" || buildOutput.trim().length === 0) return directory;
2979
+ const relativeSource = path.relative(process.cwd(), directory);
2980
+ if (!relativeSource || relativeSource.startsWith("..")) return directory;
2981
+ const mappedDirectory = path.join(buildOutput, relativeSource);
2982
+ return existsSync(mappedDirectory) ? mappedDirectory : directory;
2983
+ };
2984
+ const collectRuntimeModelFiles = (directory) => {
2985
+ if (!existsSync(directory)) return [];
2986
+ return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
2987
+ const entryPath = path.join(directory, entry.name);
2988
+ if (entry.isDirectory()) return collectRuntimeModelFiles(entryPath);
2989
+ if (!entry.isFile() || !/\.(ts|tsx|mts|cts|js|mjs|cjs)$/i.test(entry.name)) return [];
2990
+ if (/\.d\.(ts|mts|cts)$/i.test(entry.name)) return [];
2991
+ return [entryPath];
2992
+ });
2993
+ };
2994
+ const isModelConstructor = (value) => {
2995
+ if (typeof value !== "function") return false;
2996
+ const candidate = value;
2997
+ return typeof candidate.query === "function" && typeof candidate.hydrate === "function" && typeof candidate.getTable === "function" && typeof candidate.getPrimaryKey === "function";
2998
+ };
2999
+ const registerConfiguredModels = async (generation) => {
3000
+ const configured = userConfig.paths?.models;
3001
+ const additional = getRegisteredPaths("models");
3002
+ const files = [...typeof configured === "string" ? [configured] : [], ...additional].map((directory) => resolveRuntimeModelsDirectory(path.isAbsolute(directory) ? directory : path.resolve(process.cwd(), directory))).filter((directory, index, all) => all.indexOf(directory) === index).flatMap(collectRuntimeModelFiles);
3003
+ const models = (await Promise.all(files.map(async (file) => {
3004
+ try {
3005
+ return await RuntimeModuleLoader.load(file);
3006
+ } catch {
3007
+ return null;
3008
+ }
3009
+ }))).flatMap((module) => module ? Object.values(module).filter(isModelConstructor) : []);
3010
+ if (generation === runtimeModelRegistrationGeneration) registerModels(models);
3011
+ };
3012
+ const scheduleConfiguredModelRegistration = () => {
3013
+ const generation = runtimeModelRegistrationGeneration;
3014
+ runtimeModelRegistrationPromise = (runtimeModelRegistrationPromise ?? Promise.resolve()).then(async () => await registerConfiguredModels(generation));
3015
+ return runtimeModelRegistrationPromise;
3016
+ };
3017
+ const awaitConfiguredModelsRegistration = async () => {
3018
+ if (runtimeModelRegistrationPromise) await runtimeModelRegistrationPromise;
3019
+ };
2973
3020
  /**
2974
3021
  * Define the ArkORM runtime configuration. This function can be used to provide.
2975
3022
  *
@@ -3030,6 +3077,7 @@ const configureArkormRuntime = (client, options = {}) => {
3030
3077
  runtimePaginationURLDriverFactory = nextConfig.pagination?.urlDriver;
3031
3078
  runtimePaginationCurrentPageResolver = nextConfig.pagination?.resolveCurrentPage;
3032
3079
  runtimeDebugHandler = resolveDebugHandler(nextConfig.debug);
3080
+ scheduleConfiguredModelRegistration();
3033
3081
  const bootClient = resolveClient(resolvedClient);
3034
3082
  options.boot?.({
3035
3083
  client: bootClient,
@@ -3050,6 +3098,8 @@ const resetArkormRuntimeForTests = () => {
3050
3098
  });
3051
3099
  runtimeConfigLoaded = false;
3052
3100
  runtimeConfigLoadingPromise = void 0;
3101
+ runtimeModelRegistrationPromise = void 0;
3102
+ runtimeModelRegistrationGeneration++;
3053
3103
  runtimeClientResolver = void 0;
3054
3104
  runtimeAdapter = void 0;
3055
3105
  runtimePaginationURLDriverFactory = void 0;
@@ -3126,21 +3176,30 @@ const loadRuntimeConfigSync = () => {
3126
3176
  * @returns
3127
3177
  */
3128
3178
  const loadArkormConfig = async () => {
3129
- if (runtimeConfigLoaded) return;
3179
+ if (runtimeConfigLoaded) {
3180
+ await awaitConfiguredModelsRegistration();
3181
+ return;
3182
+ }
3130
3183
  if (runtimeConfigLoadingPromise) return await runtimeConfigLoadingPromise;
3131
- if (loadRuntimeConfigSync()) return;
3184
+ if (loadRuntimeConfigSync()) {
3185
+ await awaitConfiguredModelsRegistration();
3186
+ return;
3187
+ }
3132
3188
  runtimeConfigLoadingPromise = (async () => {
3133
3189
  const configPaths = [path.join(process.cwd(), "arkormx.config.js"), path.join(process.cwd(), "arkormx.config.ts")];
3134
3190
  for (const configPath of configPaths) {
3135
3191
  if (!existsSync(configPath)) continue;
3136
3192
  try {
3137
3193
  resolveAndApplyConfig(await importConfigFile(configPath));
3194
+ await awaitConfiguredModelsRegistration();
3138
3195
  return;
3139
3196
  } catch {
3140
3197
  continue;
3141
3198
  }
3142
3199
  }
3143
3200
  runtimeConfigLoaded = true;
3201
+ await scheduleConfiguredModelRegistration();
3202
+ await awaitConfiguredModelsRegistration();
3144
3203
  })();
3145
3204
  await runtimeConfigLoadingPromise;
3146
3205
  };
@@ -3525,6 +3584,77 @@ var Relation = class {
3525
3584
  return this.constrain((query) => query.where(where));
3526
3585
  }
3527
3586
  /**
3587
+ * Adds an OR where clause to the query.
3588
+ *
3589
+ * @param where
3590
+ * @returns
3591
+ */
3592
+ orWhere(where) {
3593
+ return this.constrain((query) => query.orWhere(where));
3594
+ }
3595
+ /**
3596
+ * Adds a NOT where clause to the query.
3597
+ *
3598
+ * @param where
3599
+ * @returns
3600
+ */
3601
+ whereNot(where) {
3602
+ return this.constrain((query) => query.whereNot(where));
3603
+ }
3604
+ /**
3605
+ * Adds an OR NOT where clause to the query.
3606
+ *
3607
+ * @param where
3608
+ * @returns
3609
+ */
3610
+ orWhereNot(where) {
3611
+ return this.constrain((query) => query.orWhereNot(where));
3612
+ }
3613
+ /**
3614
+ * Adds a null check for a key.
3615
+ *
3616
+ * @param key
3617
+ * @returns
3618
+ */
3619
+ whereNull(key) {
3620
+ return this.constrain((query) => query.whereNull(key));
3621
+ }
3622
+ /**
3623
+ * Adds a not-null check for a key.
3624
+ *
3625
+ * @param key
3626
+ * @returns
3627
+ */
3628
+ whereNotNull(key) {
3629
+ return this.constrain((query) => query.whereNotNull(key));
3630
+ }
3631
+ /**
3632
+ * Adds a between range clause for a key.
3633
+ *
3634
+ * @param key
3635
+ * @param range
3636
+ * @returns
3637
+ */
3638
+ whereBetween(key, range) {
3639
+ return this.constrain((query) => query.whereBetween(key, range));
3640
+ }
3641
+ /**
3642
+ * Adds a date-only equality clause for a date-like key.
3643
+ *
3644
+ * @param key
3645
+ * @param value
3646
+ * @returns
3647
+ */
3648
+ whereDate(key, value) {
3649
+ return this.constrain((query) => query.whereDate(key, value));
3650
+ }
3651
+ whereMonth(key, month, year) {
3652
+ return this.constrain((query) => query.whereMonth(key, month, year));
3653
+ }
3654
+ whereYear(key, year) {
3655
+ return this.constrain((query) => query.whereYear(key, year));
3656
+ }
3657
+ /**
3528
3658
  * Add a strongly-typed where key clause to the relationship query.
3529
3659
  *
3530
3660
  * @param key
@@ -3535,6 +3665,16 @@ var Relation = class {
3535
3665
  return this.constrain((query) => query.whereKey(key, value));
3536
3666
  }
3537
3667
  /**
3668
+ * Adds a strongly-typed inequality where clause for a single attribute key.
3669
+ *
3670
+ * @param key
3671
+ * @param value
3672
+ * @returns
3673
+ */
3674
+ whereKeyNot(key, value) {
3675
+ return this.constrain((query) => query.whereKeyNot(key, value));
3676
+ }
3677
+ /**
3538
3678
  * Add a strongly-typed where in clause to the relationship query.
3539
3679
  *
3540
3680
  * @param key
@@ -3545,6 +3685,36 @@ var Relation = class {
3545
3685
  return this.constrain((query) => query.whereIn(key, values));
3546
3686
  }
3547
3687
  /**
3688
+ * Adds a strongly-typed OR IN where clause for a single attribute key.
3689
+ *
3690
+ * @param key
3691
+ * @param values
3692
+ * @returns
3693
+ */
3694
+ orWhereIn(key, values) {
3695
+ return this.constrain((query) => query.orWhereIn(key, values));
3696
+ }
3697
+ /**
3698
+ * Adds a strongly-typed NOT IN where clause for a single attribute key.
3699
+ *
3700
+ * @param key
3701
+ * @param values
3702
+ * @returns
3703
+ */
3704
+ whereNotIn(key, values) {
3705
+ return this.constrain((query) => query.whereNotIn(key, values));
3706
+ }
3707
+ /**
3708
+ * Adds a strongly-typed OR NOT IN where clause for a single attribute key.
3709
+ *
3710
+ * @param key
3711
+ * @param values
3712
+ * @returns
3713
+ */
3714
+ orWhereNotIn(key, values) {
3715
+ return this.constrain((query) => query.orWhereNotIn(key, values));
3716
+ }
3717
+ /**
3548
3718
  * Add a string contains clause to the relationship query.
3549
3719
  *
3550
3720
  * @param key
@@ -3584,6 +3754,42 @@ var Relation = class {
3584
3754
  return this.constrain((query) => query.orderBy(orderBy));
3585
3755
  }
3586
3756
  /**
3757
+ * Puts the query results in random order.
3758
+ *
3759
+ * @returns
3760
+ */
3761
+ inRandomOrder() {
3762
+ return this.constrain((query) => query.inRandomOrder());
3763
+ }
3764
+ /**
3765
+ * Removes existing order clauses and optionally applies a new one.
3766
+ *
3767
+ * @param column
3768
+ * @param direction
3769
+ * @returns
3770
+ */
3771
+ reorder(column, direction = "asc") {
3772
+ return this.constrain((query) => query.reorder(column, direction));
3773
+ }
3774
+ /**
3775
+ * Adds an orderBy descending clause for a timestamp-like column.
3776
+ *
3777
+ * @param column
3778
+ * @returns
3779
+ */
3780
+ latest(column = "createdAt") {
3781
+ return this.constrain((query) => query.latest(column));
3782
+ }
3783
+ /**
3784
+ * Adds an orderBy ascending clause for a timestamp-like column.
3785
+ *
3786
+ * @param column
3787
+ * @returns
3788
+ */
3789
+ oldest(column = "createdAt") {
3790
+ return this.constrain((query) => query.oldest(column));
3791
+ }
3792
+ /**
3587
3793
  * Add an include clause to the relationship query.
3588
3794
  *
3589
3795
  * @param include
@@ -3610,6 +3816,9 @@ var Relation = class {
3610
3816
  select(select) {
3611
3817
  return this.constrain((query) => query.select(select));
3612
3818
  }
3819
+ addSelect(select) {
3820
+ return this.constrain((query) => query.addSelect(select));
3821
+ }
3613
3822
  /**
3614
3823
  * Add a skip clause to the relationship query.
3615
3824
  *
@@ -3619,6 +3828,9 @@ var Relation = class {
3619
3828
  skip(skip) {
3620
3829
  return this.constrain((query) => query.skip(skip));
3621
3830
  }
3831
+ offset(value) {
3832
+ return this.constrain((query) => query.offset(value));
3833
+ }
3622
3834
  /**
3623
3835
  * Add a take clause to the relationship query.
3624
3836
  *
@@ -3629,6 +3841,45 @@ var Relation = class {
3629
3841
  return this.constrain((query) => query.take(take));
3630
3842
  }
3631
3843
  /**
3844
+ * Alias for take.
3845
+ *
3846
+ * @param value
3847
+ * @returns
3848
+ */
3849
+ limit(value) {
3850
+ return this.constrain((query) => query.limit(value));
3851
+ }
3852
+ /**
3853
+ * Sets offset/limit for a 1-based page.
3854
+ *
3855
+ * @param page
3856
+ * @param perPage
3857
+ * @returns
3858
+ */
3859
+ forPage(page, perPage = 15) {
3860
+ return this.constrain((query) => query.forPage(page, perPage));
3861
+ }
3862
+ /**
3863
+ * Adds a raw where clause when supported by the adapter.
3864
+ *
3865
+ * @param sql
3866
+ * @param bindings
3867
+ * @returns
3868
+ */
3869
+ whereRaw(sql, bindings = []) {
3870
+ return this.constrain((query) => query.whereRaw(sql, bindings));
3871
+ }
3872
+ /**
3873
+ * Adds a raw OR where clause when supported by the adapter.
3874
+ *
3875
+ * @param sql
3876
+ * @param bindings
3877
+ * @returns
3878
+ */
3879
+ orWhereRaw(sql, bindings = []) {
3880
+ return this.constrain((query) => query.orWhereRaw(sql, bindings));
3881
+ }
3882
+ /**
3632
3883
  * Include soft-deleted records in the relationship query.
3633
3884
  *
3634
3885
  * @returns
@@ -5007,4 +5258,76 @@ var MorphToManyRelation = class extends Relation {
5007
5258
  };
5008
5259
 
5009
5260
  //#endregion
5010
- export { deletePersistedColumnMappingsState as $, runPrismaCommand as $t, isDelegateLike as A, UnsupportedAdapterFeatureException as An, buildModelBlock as At, getRegisteredSeeders as B, escapeRegex as Bt, getRuntimeAdapter as C, readAppliedMigrationsStateFromStore as Cn, applyMigrationToPrismaSchema as Ct, getRuntimePaginationURLDriverFactory as D, writeAppliedMigrationsState as Dn, buildIndexLine as Dt, getRuntimePaginationCurrentPageResolver as E, supportsDatabaseMigrationState as En, buildFieldLine as Et, runArkormTransaction as F, ArkormException as Fn, deriveCollectionFieldName as Ft, registerFactories as G, formatRelationAction as Gt, loadMigrationsFrom as H, findModelBlock as Ht, getRegisteredFactories as I, deriveInverseRelationAlias as It, registerPaths as J, pad as Jt, registerMigrations as K, generateMigrationFile as Kt, getRegisteredMigrations as L, deriveRelationAlias as Lt, isTransactionCapableClient as M, RelationTableLoader as Mn, buildRelationLine as Mt, loadArkormConfig as N, RelationResolutionException as Nn, buildUniqueConstraintLine as Nt, getRuntimePrismaClient as O, writeAppliedMigrationsStateToStore as On, buildInverseRelationLine as Ot, resetArkormRuntimeForTests as P, ArkormCollection as Pn, createMigrationTimestamp as Pt, createEmptyPersistedColumnMappingsState as Q, runMigrationWithPrisma as Qt, getRegisteredModels as R, deriveRelationFieldName as Rt, getDefaultStubsPath as S, readAppliedMigrationsState as Sn, applyMigrationToDatabase as St, getRuntimeDebugHandler as T, resolveMigrationStateFilePath as Tn, buildEnumBlock as Tt, loadModelsFrom as U, formatDefaultValue as Ut, loadFactoriesFrom as V, findEnumBlock as Vt, loadSeedersFrom as W, formatEnumDefaultValue as Wt, resetRuntimeRegistryForTests as X, resolveMigrationClassName as Xt, registerSeeders as Y, resolveEnumName as Yt, applyOperationsToPersistedColumnMappingsState as Z, resolvePrismaType as Zt, defineConfig as _, getLastMigrationRun as _n, applyAlterTableOperation as _t, HasOneRelation as a, toModelName as an, getPersistedTimestampColumns as at, getActiveTransactionAdapter as b, markMigrationApplied as bn, applyMigrationRollbackToDatabase as bt, BelongsToRelation as c, TableBuilder as cn, resetPersistedColumnMappingsCache as ct, Relation as d, buildMigrationIdentity as dn, syncPersistedColumnMappingsFromState as dt, stripPrismaSchemaModelsAndEnums as en, getPersistedColumnMap as et, LengthAwarePaginator as f, buildMigrationRunId as fn, validatePersistedMetadataFeaturesForMigrations as ft, configureArkormRuntime as g, findAppliedMigration as gn, PRISMA_MODEL_REGEX as gt, bindAdapterToModels as h, deleteAppliedMigrationsStateFromStore as hn, PRISMA_ENUM_REGEX as ht, HasOneThroughRelation as i, toMigrationFileSlug as in, getPersistedTableMetadata as it, isQuerySchemaLike as j, SetBasedEagerLoader as jn, buildPrimaryKeyLine as jt, getUserConfig as k, RuntimeModuleLoader as kn, buildMigrationSource as kt, SingleResultRelation as l, PrimaryKeyGenerationPlanner as ln, resolveColumnMappingsFilePath as lt, URLDriver as m, createEmptyAppliedMigrationsState as mn, PRISMA_ENUM_MEMBER_REGEX as mt, MorphOneRelation as n, supportsDatabaseMigrationExecution as nn, getPersistedEnumTsType as nt, HasManyThroughRelation as o, SchemaBuilder as on, readPersistedColumnMappingsState as ot, Paginator as p, computeMigrationChecksum as pn, writePersistedColumnMappingsState as pt, registerModels as q, getMigrationPlan as qt, MorphManyRelation as r, supportsDatabaseReset as rn, getPersistedPrimaryKeyGeneration as rt, HasManyRelation as s, EnumBuilder as sn, rebuildPersistedColumnMappingsState as st, MorphToManyRelation as t, supportsDatabaseCreation as tn, getPersistedEnumMap as tt, BelongsToManyRelation as u, ForeignKeyBuilder as un, resolvePersistedMetadataFeatures as ut, emitRuntimeDebugEvent as v, getLatestAppliedMigrations as vn, applyCreateTableOperation as vt, getRuntimeClient as w, removeAppliedMigration as wn, applyOperationsToPrismaSchema as wt, getActiveTransactionClient as x, markMigrationRun as xn, applyMigrationRollbackToPrismaSchema as xt, ensureArkormConfigLoading as y, isMigrationApplied as yn, applyDropTableOperation as yt, getRegisteredPaths as z, deriveSingularFieldName as zt };
5261
+ //#region src/relationship/MorphToRelation.ts
5262
+ /**
5263
+ * Defines the inverse side of a polymorphic one-to-one or one-to-many relationship.
5264
+ *
5265
+ * Related models are resolved from ArkORM's runtime model registry using the value
5266
+ * stored in the morph type column.
5267
+ *
5268
+ * @author Legacy (3m1n3nc3)
5269
+ * @since 2.6.0
5270
+ */
5271
+ var MorphToRelation = class extends Relation {
5272
+ constructor(parent, morphName, morphTypeColumn, morphIdColumn, ownerKey, relatedModel) {
5273
+ super();
5274
+ this.parent = parent;
5275
+ this.morphName = morphName;
5276
+ this.morphTypeColumn = morphTypeColumn;
5277
+ this.morphIdColumn = morphIdColumn;
5278
+ this.ownerKey = ownerKey;
5279
+ this.relatedModel = relatedModel;
5280
+ }
5281
+ get related() {
5282
+ return this.resolveRelatedModel();
5283
+ }
5284
+ /**
5285
+ * Build the relationship query.
5286
+ *
5287
+ * @returns
5288
+ */
5289
+ async getQuery() {
5290
+ await awaitConfiguredModelsRegistration();
5291
+ const related = this.resolveRelatedModel();
5292
+ const resolvedOwnerKey = this.ownerKey ?? related.getPrimaryKey();
5293
+ const morphId = this.parent.getAttribute(this.morphIdColumn);
5294
+ return this.applyConstraint(related.query().where({ [resolvedOwnerKey]: morphId }));
5295
+ }
5296
+ getMetadata() {
5297
+ return {
5298
+ type: "morphTo",
5299
+ morphName: this.morphName,
5300
+ morphIdColumn: this.morphIdColumn,
5301
+ morphTypeColumn: this.morphTypeColumn,
5302
+ ownerKey: this.ownerKey
5303
+ };
5304
+ }
5305
+ /**
5306
+ * Fetch the polymorphic parent model.
5307
+ *
5308
+ * @returns
5309
+ */
5310
+ async getResults() {
5311
+ const morphType = this.parent.getAttribute(this.morphTypeColumn);
5312
+ const morphId = this.parent.getAttribute(this.morphIdColumn);
5313
+ if (morphType == null || morphId == null) return null;
5314
+ return await (await this.getQuery()).first();
5315
+ }
5316
+ resolveRelatedModel() {
5317
+ const morphType = this.parent.getAttribute(this.morphTypeColumn);
5318
+ if (typeof morphType !== "string" || morphType.trim().length === 0) throw new RelationResolutionException(`Morph type column [${this.morphTypeColumn}] does not contain a model name.`, {
5319
+ operation: "morphTo",
5320
+ relation: this.morphName
5321
+ });
5322
+ const related = this.relatedModel?.name === morphType ? this.relatedModel : getRegisteredModels().find((model) => model.name === morphType);
5323
+ if (!related) throw new RelationResolutionException(`Morph model [${morphType}] is not registered. Register it with Arkorm.registerModels().`, {
5324
+ operation: "morphTo",
5325
+ model: morphType,
5326
+ relation: this.morphName
5327
+ });
5328
+ return related;
5329
+ }
5330
+ };
5331
+
5332
+ //#endregion
5333
+ export { applyOperationsToPersistedColumnMappingsState as $, resolvePrismaType as $t, getRuntimePrismaClient as A, writeAppliedMigrationsStateToStore as An, buildInverseRelationLine as At, getRegisteredModels as B, deriveRelationFieldName as Bt, getActiveTransactionClient as C, markMigrationRun as Cn, applyMigrationRollbackToPrismaSchema as Ct, getRuntimeDebugHandler as D, resolveMigrationStateFilePath as Dn, buildEnumBlock as Dt, getRuntimeClient as E, removeAppliedMigration as En, applyOperationsToPrismaSchema as Et, loadArkormConfig as F, RelationResolutionException as Fn, buildUniqueConstraintLine as Ft, loadModelsFrom as G, formatDefaultValue as Gt, getRegisteredSeeders as H, escapeRegex as Ht, resetArkormRuntimeForTests as I, ArkormCollection as In, createMigrationTimestamp as It, registerMigrations as J, generateMigrationFile as Jt, loadSeedersFrom as K, formatEnumDefaultValue as Kt, runArkormTransaction as L, ArkormException as Ln, deriveCollectionFieldName as Lt, isDelegateLike as M, UnsupportedAdapterFeatureException as Mn, buildModelBlock as Mt, isQuerySchemaLike as N, SetBasedEagerLoader as Nn, buildPrimaryKeyLine as Nt, getRuntimePaginationCurrentPageResolver as O, supportsDatabaseMigrationState as On, buildFieldLine as Ot, isTransactionCapableClient as P, RelationTableLoader as Pn, buildRelationLine as Pt, resetRuntimeRegistryForTests as Q, resolveMigrationClassName as Qt, getRegisteredFactories as R, deriveInverseRelationAlias as Rt, getActiveTransactionAdapter as S, markMigrationApplied as Sn, applyMigrationRollbackToDatabase as St, getRuntimeAdapter as T, readAppliedMigrationsStateFromStore as Tn, applyMigrationToPrismaSchema as Tt, loadFactoriesFrom as U, findEnumBlock as Ut, getRegisteredPaths as V, deriveSingularFieldName as Vt, loadMigrationsFrom as W, findModelBlock as Wt, registerPaths as X, pad as Xt, registerModels as Y, getMigrationPlan as Yt, registerSeeders as Z, resolveEnumName as Zt, bindAdapterToModels as _, deleteAppliedMigrationsStateFromStore as _n, PRISMA_ENUM_REGEX as _t, HasOneThroughRelation as a, supportsDatabaseReset as an, getPersistedPrimaryKeyGeneration as at, emitRuntimeDebugEvent as b, getLatestAppliedMigrations as bn, applyCreateTableOperation as bt, HasManyRelation as c, SchemaBuilder as cn, readPersistedColumnMappingsState as ct, BelongsToManyRelation as d, PrimaryKeyGenerationPlanner as dn, resolveColumnMappingsFilePath as dt, runMigrationWithPrisma as en, createEmptyPersistedColumnMappingsState as et, Relation as f, ForeignKeyBuilder as fn, resolvePersistedMetadataFeatures as ft, awaitConfiguredModelsRegistration as g, createEmptyAppliedMigrationsState as gn, PRISMA_ENUM_MEMBER_REGEX as gt, URLDriver as h, computeMigrationChecksum as hn, writePersistedColumnMappingsState as ht, MorphManyRelation as i, supportsDatabaseMigrationExecution as in, getPersistedEnumTsType as it, getUserConfig as j, RuntimeModuleLoader as jn, buildMigrationSource as jt, getRuntimePaginationURLDriverFactory as k, writeAppliedMigrationsState as kn, buildIndexLine as kt, BelongsToRelation as l, EnumBuilder as ln, rebuildPersistedColumnMappingsState as lt, Paginator as m, buildMigrationRunId as mn, validatePersistedMetadataFeaturesForMigrations as mt, MorphToManyRelation as n, stripPrismaSchemaModelsAndEnums as nn, getPersistedColumnMap as nt, HasOneRelation as o, toMigrationFileSlug as on, getPersistedTableMetadata as ot, LengthAwarePaginator as p, buildMigrationIdentity as pn, syncPersistedColumnMappingsFromState as pt, registerFactories as q, formatRelationAction as qt, MorphOneRelation as r, supportsDatabaseCreation as rn, getPersistedEnumMap as rt, HasManyThroughRelation as s, toModelName as sn, getPersistedTimestampColumns as st, MorphToRelation as t, runPrismaCommand as tn, deletePersistedColumnMappingsState as tt, SingleResultRelation as u, TableBuilder as un, resetPersistedColumnMappingsCache as ut, configureArkormRuntime as v, findAppliedMigration as vn, PRISMA_MODEL_REGEX as vt, getDefaultStubsPath as w, readAppliedMigrationsState as wn, applyMigrationToDatabase as wt, ensureArkormConfigLoading as x, isMigrationApplied as xn, applyDropTableOperation as xt, defineConfig as y, getLastMigrationRun as yn, applyAlterTableOperation as yt, getRegisteredMigrations as z, deriveRelationAlias as zt };