arkormx 2.10.2 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
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-SFhKrphd.mjs";
1
+ import { $ as applyOperationsToPersistedColumnMappingsState, $n as SetBasedEagerLoader, $t as resolvePrismaType, A as getRuntimePrismaClient, An as where, At as buildInverseRelationLine, B as getRegisteredModels, Bn as getLatestAppliedMigrations, Bt as deriveRelationFieldName, C as getActiveTransactionClient, Cn as fromExpressionNode, Ct as applyMigrationRollbackToPrismaSchema, D as getRuntimeDebugHandler, Dn as raw, Dt as buildEnumBlock, E as getRuntimeClient, En as min, Et as applyOperationsToPrismaSchema, F as loadArkormConfig, Fn as computeMigrationChecksum, Ft as buildUniqueConstraintLine, G as loadModelsFrom, Gn as readAppliedMigrationsStateFromStore, Gt as formatDefaultValue, H as getRegisteredSeeders, Hn as markMigrationApplied, Ht as escapeRegex, I as resetArkormRuntimeForTests, In as createEmptyAppliedMigrationsState, It as createMigrationTimestamp, J as registerMigrations, Jn as supportsDatabaseMigrationState, Jt as generateMigrationFile, K as loadSeedersFrom, Kn as removeAppliedMigration, Kt as formatEnumDefaultValue, L as runArkormTransaction, Ln as deleteAppliedMigrationsStateFromStore, Lt as deriveCollectionFieldName, M as isDelegateLike, Mn as ForeignKeyBuilder, Mt as buildModelBlock, N as isQuerySchemaLike, Nn as buildMigrationIdentity, Nt as buildPrimaryKeyLine, O as getRuntimePaginationCurrentPageResolver, On as sum, Ot as buildFieldLine, P as isTransactionCapableClient, Pn as buildMigrationRunId, Pt as buildRelationLine, Q as resetRuntimeRegistryForTests, Qn as UnsupportedAdapterFeatureException, Qt as resolveMigrationClassName, R as getRegisteredFactories, Rn as findAppliedMigration, Rt as deriveInverseRelationAlias, S as getActiveTransactionAdapter, Sn as fn, St as applyMigrationRollbackToDatabase, T as getRuntimeAdapter, Tn as max, Tt as applyMigrationToPrismaSchema, U as loadFactoriesFrom, Un as markMigrationRun, Ut as findEnumBlock, V as getRegisteredPaths, Vn as isMigrationApplied, Vt as deriveSingularFieldName, W as loadMigrationsFrom, Wn as readAppliedMigrationsState, Wt as findModelBlock, X as registerPaths, Xn as writeAppliedMigrationsStateToStore, Xt as pad, Y as registerModels, Yn as writeAppliedMigrationsState, Yt as getMigrationPlan, Z as registerSeeders, Zn as RuntimeModuleLoader, Zt as resolveEnumName, _ as bindAdapterToModels, _n as caseWhen, _t as PRISMA_ENUM_REGEX, a as HasOneThroughRelation, an as supportsDatabaseReset, at as getPersistedPrimaryKeyGeneration, b as emitRuntimeDebugEvent, bn as count, bt as applyCreateTableOperation, c as HasManyRelation, cn as SchemaBuilder, ct as readPersistedColumnMappingsState, d as BelongsToManyRelation, dn as resolveGeneratedExpression, dt as resolveColumnMappingsFilePath, en as runMigrationWithPrisma, et as createEmptyPersistedColumnMappingsState, f as Relation, fn as AggregateExpression, ft as resolvePersistedMetadataFeatures, g as awaitConfiguredModelsRegistration, gn as avg, gt as PRISMA_ENUM_MEMBER_REGEX, h as URLDriver, hn as JsonExpression, ht as writePersistedColumnMappingsState, i as MorphManyRelation, in as supportsDatabaseMigrationExecution, it as getPersistedEnumTsType, j as getUserConfig, jn as PrimaryKeyGenerationPlanner, jt as buildMigrationSource, k as getRuntimePaginationURLDriverFactory, kn as val, kt as buildIndexLine, l as BelongsToRelation, ln as EnumBuilder, lt as rebuildPersistedColumnMappingsState, m as Paginator, mn as Expression, mt as validatePersistedMetadataFeaturesForMigrations, n as MorphToManyRelation, nn as stripPrismaSchemaModelsAndEnums, nr as ArkormCollection, nt as getPersistedColumnMap, o as HasOneRelation, on as toMigrationFileSlug, ot as getPersistedTableMetadata, p as LengthAwarePaginator, pn as CaseExpression, pt as syncPersistedColumnMappingsFromState, q as registerFactories, qn as resolveMigrationStateFilePath, qt as formatRelationAction, r as MorphOneRelation, rn as supportsDatabaseCreation, rr as ArkormException, rt as getPersistedEnumMap, s as HasManyThroughRelation, sn as toModelName, st as getPersistedTimestampColumns, t as MorphToRelation, tn as runPrismaCommand, tr as RelationResolutionException, tt as deletePersistedColumnMappingsState, un as TableBuilder, ut as resetPersistedColumnMappingsCache, v as configureArkormRuntime, vn as coalesce, vt as PRISMA_MODEL_REGEX, w as getDefaultStubsPath, wn as json, wt as applyMigrationToDatabase, x as ensureArkormConfigLoading, xn as expressionBuilder, xt as applyDropTableOperation, y as defineConfig, yn as col, yt as applyAlterTableOperation, z as getRegisteredMigrations, zn as getLastMigrationRun, zt as deriveRelationAlias } from "./relationship-CP1xbMOa.mjs";
2
2
  import { Pool } from "pg";
3
3
  import { join, resolve } from "node:path";
4
4
  import { createRequire } from "module";
@@ -64,7 +64,8 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
64
64
  rawWhere: true,
65
65
  distinct: true,
66
66
  groupBy: true,
67
- joins: true
67
+ joins: true,
68
+ expressions: true
68
69
  };
69
70
  }
70
71
  resolveConfiguredDatabaseName(connectionString) {
@@ -385,6 +386,13 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
385
386
  }
386
387
  buildSchemaColumnDefinition(table, column) {
387
388
  const parts = [this.quoteIdentifier(column.map ?? column.name), this.resolveSchemaColumnType(table, column)];
389
+ if (column.generatedExpression) {
390
+ const storage = column.generatedStored === false ? "" : " stored";
391
+ parts.push(`generated always as (${column.generatedExpression})${storage}`);
392
+ if (column.unique) parts.push("unique");
393
+ if (!column.nullable && !column.primary) parts.push("not null");
394
+ return parts.join(" ");
395
+ }
388
396
  if (this.shouldUseIdentity(column)) parts.push("generated by default as identity");
389
397
  const defaultValue = this.resolveSchemaColumnDefault(column);
390
398
  if (defaultValue && !this.shouldUseIdentity(column)) parts.push(`default ${defaultValue}`);
@@ -642,11 +650,16 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
642
650
  }
643
651
  buildSelectList(target, columns) {
644
652
  if (!columns || columns.length === 0) return sql.raw("*");
645
- return sql.join(columns.map(({ column, alias, raw, wildcard }) => {
653
+ return sql.join(columns.map(({ column, alias, raw, wildcard, expression }) => {
646
654
  if (wildcard) return sql.raw("*");
655
+ if (expression) {
656
+ const compiled = this.buildExpression(target, expression);
657
+ const resultAlias = alias ?? column;
658
+ return resultAlias ? sql`${compiled} as ${sql.id(resultAlias)}` : compiled;
659
+ }
647
660
  if (raw) {
648
- const expression = sql.raw(column);
649
- return alias ? sql`${expression} as ${sql.id(alias)}` : expression;
661
+ const rawExpression = sql.raw(column);
662
+ return alias ? sql`${rawExpression} as ${sql.id(alias)}` : rawExpression;
650
663
  }
651
664
  const mappedColumn = this.mapColumn(target, column);
652
665
  const resultAlias = alias ?? column;
@@ -656,13 +669,18 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
656
669
  }
657
670
  buildOrderBy(target, orderBy) {
658
671
  if (!orderBy || orderBy.length === 0) return sql``;
659
- return sql` order by ${sql.join(orderBy.map(({ column, direction }) => {
660
- return sql`${sql.ref(this.mapColumn(target, column))} ${sql.raw(direction === "desc" ? "desc" : "asc")}`;
672
+ return sql` order by ${sql.join(orderBy.map(({ column, direction, expression }) => {
673
+ return sql`${expression ? this.buildExpression(target, expression) : sql.ref(this.mapColumn(target, column))} ${sql.raw(direction === "desc" ? "desc" : "asc")}`;
661
674
  }), sql`, `)}`;
662
675
  }
663
676
  buildGroupBy(target, groupBy) {
664
677
  if (!groupBy || groupBy.length === 0) return sql``;
665
- return sql` group by ${sql.join(groupBy.map((column) => sql.ref(this.mapColumn(target, column))), sql`, `)}`;
678
+ return sql` group by ${sql.join(groupBy.map((item) => {
679
+ if (typeof item === "string") return sql.ref(this.mapColumn(target, item));
680
+ if ("alias" in item) return sql.ref(item.alias);
681
+ if ("expression" in item) return this.buildExpression(target, item.expression);
682
+ return this.buildRawExpressionFragment(item.raw.sql, item.raw.bindings ?? []);
683
+ }), sql`, `)}`;
666
684
  }
667
685
  buildHavingClause(target, having) {
668
686
  if (!having) return sql``;
@@ -811,6 +829,96 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
811
829
  const contains = sql`${accessor} @> ${jsonValue}::jsonb`;
812
830
  return condition.not ? sql`not (${contains})` : contains;
813
831
  }
832
+ /**
833
+ * Compiles a serialized {@link ExpressionNode} into a parameterized SQL fragment.
834
+ * Shared by expression-backed select columns, `group by`, `order by`, and any
835
+ * boolean expression used as a `where`/`having` predicate.
836
+ *
837
+ * @param target
838
+ * @param node
839
+ * @returns
840
+ */
841
+ buildExpression(target, node) {
842
+ switch (node.kind) {
843
+ case "column": return this.buildExpressionColumn(target, node.name);
844
+ case "value": return sql`${node.value}`;
845
+ case "raw": return this.buildRawExpressionFragment(node.sql, node.bindings);
846
+ case "json": return this.buildJsonValueExpression(target, node);
847
+ case "function": {
848
+ const args = node.args.map((arg) => this.buildExpression(target, arg));
849
+ return sql`${sql.raw(this.sanitizeFunctionName(node.name))}(${sql.join(args, sql`, `)})`;
850
+ }
851
+ case "case": {
852
+ const branches = node.cases.map((branch) => sql`when ${this.buildExpression(target, branch.when)} then ${this.buildExpression(target, branch.then)}`);
853
+ const elseClause = node.else ? sql` else ${this.buildExpression(target, node.else)}` : sql``;
854
+ return sql`case ${sql.join(branches, sql` `)}${elseClause} end`;
855
+ }
856
+ case "binary": return this.buildBinaryExpression(target, node);
857
+ case "in": {
858
+ const operand = this.buildExpression(target, node.operand);
859
+ const values = node.values.map((value) => this.buildExpression(target, value));
860
+ const list = values.length > 0 ? sql.join(values, sql`, `) : sql`null`;
861
+ return node.not ? sql`(${operand} not in (${list}))` : sql`(${operand} in (${list}))`;
862
+ }
863
+ case "null-check": {
864
+ const operand = this.buildExpression(target, node.operand);
865
+ return node.not ? sql`(${operand} is not null)` : sql`(${operand} is null)`;
866
+ }
867
+ case "aggregate": return this.buildAggregateExpression(target, node);
868
+ default: throw new ArkormException(`Unsupported expression node [${node.kind}].`);
869
+ }
870
+ }
871
+ buildExpressionColumn(target, name) {
872
+ if (name.includes(".")) return sql.ref(name);
873
+ return sql.ref(this.mapColumn(target, name));
874
+ }
875
+ buildBinaryExpression(target, node) {
876
+ const left = this.buildExpression(target, node.left);
877
+ const right = this.buildExpression(target, node.right);
878
+ switch (node.operator) {
879
+ case "like": return sql`(${left} like ${right})`;
880
+ case "ilike": return sql`(${left} ilike ${right})`;
881
+ case "not-like": return sql`(${left} not like ${right})`;
882
+ case "not-ilike": return sql`(${left} not ilike ${right})`;
883
+ case "and": return sql`(${left} and ${right})`;
884
+ case "or": return sql`(${left} or ${right})`;
885
+ default: return sql`(${left} ${sql.raw(node.operator)} ${right})`;
886
+ }
887
+ }
888
+ buildAggregateExpression(target, node) {
889
+ const argument = node.arg ? this.buildExpression(target, node.arg) : sql.raw("*");
890
+ const distinctKeyword = node.distinct ? sql`distinct ` : sql``;
891
+ let call = sql`${sql.raw(node.fn)}(${distinctKeyword}${argument})`;
892
+ if (node.filter) call = sql`${call} filter (where ${this.buildExpression(target, node.filter)})`;
893
+ if (node.fn === "sum" || node.fn === "avg") return sql`(${call})::double precision`;
894
+ if (node.fn === "count") return sql`(${call})::bigint`;
895
+ return call;
896
+ }
897
+ buildJsonValueExpression(target, node) {
898
+ const base = sql`${sql.ref(this.mapColumn(target, node.column))}::jsonb`;
899
+ let accessor;
900
+ if (node.path.length === 0) accessor = base;
901
+ else if (node.path.length === 1) accessor = sql`(${base} ->> ${node.path[0]})`;
902
+ else accessor = sql`(${base} #>> ${`{${node.path.join(",")}}`}::text[])`;
903
+ if (node.cast === "number") return sql`(${accessor})::numeric`;
904
+ if (node.cast === "boolean") return sql`(${accessor})::boolean`;
905
+ return accessor;
906
+ }
907
+ buildRawExpressionFragment(rawSql, bindings) {
908
+ const segments = rawSql.split("?");
909
+ if (segments.length !== bindings.length + 1) throw new ArkormException("Raw expression bindings do not match the number of placeholders.");
910
+ const parts = [];
911
+ segments.forEach((segment, index) => {
912
+ if (segment.length > 0) parts.push(sql.raw(this.quoteCamelCaseIdentifiers(segment)));
913
+ if (index < bindings.length) parts.push(sql`${bindings[index]}`);
914
+ });
915
+ if (parts.length === 0) return sql``;
916
+ return sql`${sql.join(parts, sql``)}`;
917
+ }
918
+ sanitizeFunctionName(name) {
919
+ if (!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(name)) throw new ArkormException(`Unsupported SQL function name [${name}].`);
920
+ return name;
921
+ }
814
922
  buildWhereCondition(target, condition) {
815
923
  if (!condition) return sql`1 = 1`;
816
924
  if (condition.type === "comparison") return this.buildComparisonCondition(target, condition);
@@ -820,6 +928,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
820
928
  if (condition.type === "exists") return this.buildExistsCondition(condition);
821
929
  if (condition.type === "full-text") return this.buildFullTextCondition(target, condition);
822
930
  if (condition.type === "json") return this.buildJsonCondition(target, condition);
931
+ if (condition.type === "expression") return sql`${this.buildExpression(target, condition.expression)}`;
823
932
  if (condition.type === "group") {
824
933
  const group = condition;
825
934
  const conditions = group.conditions.map((entry) => {
@@ -1692,6 +1801,7 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
1692
1801
  rawWhere: false,
1693
1802
  distinct: false,
1694
1803
  groupBy: false,
1804
+ expressions: false,
1695
1805
  returning: false
1696
1806
  };
1697
1807
  }
@@ -1727,6 +1837,14 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
1727
1837
  }
1728
1838
  toQuerySelect(columns) {
1729
1839
  if (!columns || columns.length === 0) return void 0;
1840
+ const expressionColumn = columns.find((column) => column.expression);
1841
+ if (expressionColumn) throw new UnsupportedAdapterFeatureException("Expression select columns are not supported by the Prisma compatibility adapter; use a SQL-backed adapter.", {
1842
+ operation: "adapter.select",
1843
+ meta: {
1844
+ feature: "expressions",
1845
+ alias: expressionColumn.alias
1846
+ }
1847
+ });
1730
1848
  const rawColumn = columns.find((column) => column.raw);
1731
1849
  if (rawColumn) throw new UnsupportedAdapterFeatureException("Raw select expressions are not supported by the Prisma compatibility adapter; use a SQL-backed adapter or DB.raw().", {
1732
1850
  operation: "adapter.select",
@@ -1744,6 +1862,10 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
1744
1862
  }
1745
1863
  toQueryOrderBy(orderBy) {
1746
1864
  if (!orderBy || orderBy.length === 0) return void 0;
1865
+ if (orderBy.some((entry) => entry.expression)) throw new UnsupportedAdapterFeatureException("Order-by expressions are not supported by the Prisma compatibility adapter; use a SQL-backed adapter.", {
1866
+ operation: "adapter.select",
1867
+ meta: { feature: "expressions" }
1868
+ });
1747
1869
  return orderBy.map((entry) => ({ [entry.column]: entry.direction }));
1748
1870
  }
1749
1871
  toComparisonWhere(condition) {
@@ -3387,7 +3509,8 @@ var Migration = class {
3387
3509
  //#region src/cli/commands/MigrateCommand.ts
3388
3510
  /**
3389
3511
  * The MigrateCommand class implements the CLI command for applying migration
3390
- * classes to the Prisma schema and running the Prisma workflow.
3512
+ * classes to the database or Prisma schema and running the Prisma workflow when
3513
+ * using the Prisma compatibility driver.
3391
3514
  *
3392
3515
  * @author Legacy (3m1n3nc3)
3393
3516
  * @since 0.1.0
@@ -3398,22 +3521,22 @@ var MigrateCommand = class extends Command {
3398
3521
  this.signature = `migrate
3399
3522
  {name? : Migration class or file name}
3400
3523
  {--all : Run all migrations from the configured migrations directory}
3401
- {--deploy : Use prisma migrate deploy instead of migrate dev}
3402
- {--skip-generate : Skip prisma generate}
3524
+ {--deploy : Use prisma migrate deploy instead of migrate dev (Prisma compatibility driver only)}
3525
+ {--skip-generate : Skip prisma generate (Prisma compatibility driver only)}
3403
3526
  {--skip-migrate : Skip prisma migrate command}
3404
3527
  {--state-file= : Path to applied migration state file}
3405
- {--schema= : Explicit prisma schema path}
3406
- {--migration-name= : Name for prisma migrate dev}
3528
+ {--schema= : Explicit prisma schema path (Prisma compatibility driver only)}
3529
+ {--migration-name= : Name for prisma migrate dev (Prisma compatibility driver only)}
3407
3530
  {--create-database : Create the configured database without prompting}
3408
3531
  `;
3409
- this.description = "Apply migration classes to schema.prisma and run Prisma workflow";
3532
+ this.description = "Apply migration classes to the database or schema.prisma and run Prisma workflow when using the Prisma compatibility driver";
3410
3533
  }
3411
3534
  /**
3412
3535
  * Command handler for the migrate command.
3413
3536
  * This method is responsible for orchestrating the migration
3414
3537
  * process, including loading migration classes, applying them to
3415
- * the Prisma schema, and running the appropriate Prisma commands
3416
- * based on the provided options.
3538
+ * the the database or Prisma schema, and running the appropriate Prisma commands
3539
+ * when using the Prisma compatibility driver based on the provided options.
3417
3540
  *
3418
3541
  * @returns
3419
3542
  */
@@ -3622,10 +3745,10 @@ var MigrateFreshCommand = class extends Command {
3622
3745
  constructor(..._args) {
3623
3746
  super(..._args);
3624
3747
  this.signature = `migrate:fresh
3625
- {--skip-generate : Skip prisma generate}
3626
- {--skip-migrate : Skip prisma database sync}
3748
+ {--skip-generate : Skip prisma generate (Prisma compatibility driver only)}
3749
+ {--skip-migrate : Skip prisma database sync (Prisma compatibility driver only)}
3627
3750
  {--state-file= : Path to applied migration state file}
3628
- {--schema= : Explicit prisma schema path}
3751
+ {--schema= : Explicit prisma schema path (Prisma compatibility driver only)}
3629
3752
  {--create-database : Create the configured database without prompting}
3630
3753
  `;
3631
3754
  this.description = "Reset the database and rerun all migration classes";
@@ -3780,12 +3903,12 @@ var MigrateRollbackCommand = class extends Command {
3780
3903
  this.signature = `migrate:rollback
3781
3904
  {--step= : Number of latest applied migration classes to rollback}
3782
3905
  {--dry-run : Preview rollback targets without applying changes}
3783
- {--deploy : Use prisma migrate deploy instead of migrate dev}
3784
- {--skip-generate : Skip prisma generate}
3785
- {--skip-migrate : Skip prisma migrate command}
3906
+ {--deploy : Use prisma migrate deploy instead of migrate dev (Prisma compatibility driver only)}
3907
+ {--skip-generate : Skip prisma generate (Prisma compatibility driver only)}
3908
+ {--skip-migrate : Skip prisma migrate command (Prisma compatibility driver only)}
3786
3909
  {--state-file= : Path to applied migration state file}
3787
- {--schema= : Explicit prisma schema path}
3788
- {--migration-name= : Name for prisma migrate dev}
3910
+ {--schema= : Explicit prisma schema path (Prisma compatibility driver only)}
3911
+ {--migration-name= : Name for prisma migrate dev (Prisma compatibility driver only)}
3789
3912
  `;
3790
3913
  this.description = "Rollback migration classes from schema.prisma and run Prisma workflow";
3791
3914
  }
@@ -3800,7 +3923,7 @@ var MigrateRollbackCommand = class extends Command {
3800
3923
  const useDatabaseMigrations = supportsDatabaseMigrationExecution(adapter);
3801
3924
  const persistedFeatures = resolvePersistedMetadataFeatures(this.app.getConfig("features"));
3802
3925
  let appliedState = await readAppliedMigrationsStateFromStore(adapter, stateFilePath);
3803
- const stepOption = this.option("step");
3926
+ const stepOption = this.option("step", 1);
3804
3927
  const stepCount = stepOption == null ? void 0 : Number(stepOption);
3805
3928
  if (stepCount != null && (!Number.isFinite(stepCount) || stepCount <= 0 || !Number.isInteger(stepCount))) return void this.error("Error: --step must be a positive integer.");
3806
3929
  const targets = stepCount ? getLatestAppliedMigrations(appliedState, stepCount) : (() => {
@@ -4475,14 +4598,34 @@ var QueryBuilder = class QueryBuilder {
4475
4598
  return Math.max(1, resolvedPage);
4476
4599
  }
4477
4600
  where(whereOrCallback) {
4601
+ if (whereOrCallback instanceof Expression) return this.appendExpressionCondition("AND", whereOrCallback);
4478
4602
  if (typeof whereOrCallback === "function") return this.appendNestedWhere("AND", whereOrCallback);
4479
4603
  return this.addLogicalWhere("AND", whereOrCallback);
4480
4604
  }
4481
4605
  orWhere(whereOrCallback) {
4606
+ if (whereOrCallback instanceof Expression) return this.appendExpressionCondition("OR", whereOrCallback);
4482
4607
  if (typeof whereOrCallback === "function") return this.appendNestedWhere("OR", whereOrCallback);
4483
4608
  return this.addLogicalWhere("OR", whereOrCallback);
4484
4609
  }
4485
4610
  /**
4611
+ * Appends a boolean {@link Expression} as a where predicate. When the query is
4612
+ * using the Prisma-like legacy where representation, the expression is merged in
4613
+ * as a structured condition alongside it.
4614
+ */
4615
+ appendExpressionCondition(boolean, expression) {
4616
+ const condition = {
4617
+ type: "expression",
4618
+ expression: expression.toExpressionNode()
4619
+ };
4620
+ if (this.legacyWhere) {
4621
+ const existing = this.tryBuildQueryCondition(this.legacyWhere);
4622
+ this.legacyWhere = void 0;
4623
+ if (existing) this.queryWhere = existing;
4624
+ }
4625
+ this.appendQueryCondition(boolean, condition);
4626
+ return this;
4627
+ }
4628
+ /**
4486
4629
  * Resolve a callback into a parenthesized group condition and append it.
4487
4630
  */
4488
4631
  appendNestedWhere(boolean, callback) {
@@ -5132,15 +5275,17 @@ var QueryBuilder = class QueryBuilder {
5132
5275
  whereIn(key, values) {
5133
5276
  return this.where({ [key]: { in: values } });
5134
5277
  }
5135
- /**
5136
- * Adds an orderBy clause to the query. This will overwrite any existing orderBy clause.
5137
- *
5138
- * @param orderBy
5139
- * @returns
5140
- */
5141
- orderBy(orderBy) {
5278
+ orderBy(orderByOrExpression, direction = "asc") {
5142
5279
  this.randomOrderEnabled = false;
5143
- const normalized = this.normalizeQueryOrderBy(orderBy);
5280
+ if (orderByOrExpression instanceof Expression) {
5281
+ this.queryOrderBy = [...this.queryOrderBy ?? [], {
5282
+ column: "",
5283
+ direction,
5284
+ expression: orderByOrExpression.toExpressionNode()
5285
+ }];
5286
+ return this;
5287
+ }
5288
+ const normalized = this.normalizeQueryOrderBy(orderByOrExpression);
5144
5289
  if (!normalized) throw new UnsupportedAdapterFeatureException("Order clauses must use Arkorm-normalizable column directions.", {
5145
5290
  operation: "orderBy",
5146
5291
  model: this.model.name
@@ -5149,6 +5294,28 @@ var QueryBuilder = class QueryBuilder {
5149
5294
  return this;
5150
5295
  }
5151
5296
  /**
5297
+ * Appends a raw SQL `order by` fragment (with positional `?` bindings), useful
5298
+ * for ordering by a computed expression the builder does not model directly.
5299
+ *
5300
+ * @param sql
5301
+ * @param bindings
5302
+ * @param direction
5303
+ * @returns
5304
+ */
5305
+ orderByRaw(sql, bindings = [], direction = "asc") {
5306
+ this.randomOrderEnabled = false;
5307
+ this.queryOrderBy = [...this.queryOrderBy ?? [], {
5308
+ column: "",
5309
+ direction,
5310
+ expression: {
5311
+ kind: "raw",
5312
+ sql,
5313
+ bindings
5314
+ }
5315
+ }];
5316
+ return this;
5317
+ }
5318
+ /**
5152
5319
  * Puts the query results in random order.
5153
5320
  *
5154
5321
  * @returns
@@ -5514,12 +5681,6 @@ var QueryBuilder = class QueryBuilder {
5514
5681
  pipe(callback) {
5515
5682
  return callback(this);
5516
5683
  }
5517
- /**
5518
- * Adds a select clause to the query. This will overwrite any existing select clause.
5519
- *
5520
- * @param select
5521
- * @returns
5522
- */
5523
5684
  select(select) {
5524
5685
  const normalized = this.normalizeQuerySelect(select);
5525
5686
  if (normalized === null) throw new UnsupportedAdapterFeatureException("Select clauses must use Arkorm-normalizable column projections.", {
@@ -5529,12 +5690,6 @@ var QueryBuilder = class QueryBuilder {
5529
5690
  this.querySelect = normalized;
5530
5691
  return this;
5531
5692
  }
5532
- /**
5533
- * Appends columns or expressions to the existing select clause.
5534
- *
5535
- * @param select
5536
- * @returns
5537
- */
5538
5693
  addSelect(select) {
5539
5694
  const normalized = this.normalizeQuerySelect(select);
5540
5695
  if (normalized === null) throw new UnsupportedAdapterFeatureException("Select clauses must use Arkorm-normalizable column projections.", {
@@ -5558,6 +5713,8 @@ var QueryBuilder = class QueryBuilder {
5558
5713
  return this;
5559
5714
  }
5560
5715
  groupBy(...columns) {
5716
+ const first = columns[0];
5717
+ if (columns.length === 1 && this.isGroupByAggregateSpec(first)) return this.executeGroupByAggregate(first);
5561
5718
  const normalized = Array.isArray(columns[0]) ? columns[0] : columns;
5562
5719
  if (normalized.length === 0) throw new QueryConstraintException("groupBy requires at least one column.", {
5563
5720
  operation: "groupBy",
@@ -5566,6 +5723,109 @@ var QueryBuilder = class QueryBuilder {
5566
5723
  this.queryGroupBy = [...normalized];
5567
5724
  return this;
5568
5725
  }
5726
+ /**
5727
+ * Appends a raw SQL `group by` fragment (with positional `?` bindings), mirroring
5728
+ * `whereRaw`/`havingRaw`. Combines with any columns/expressions already grouped.
5729
+ *
5730
+ * @param sql
5731
+ * @param bindings
5732
+ * @returns
5733
+ */
5734
+ groupByRaw(sql, bindings = []) {
5735
+ this.queryGroupBy = [...this.queryGroupBy ?? [], { raw: {
5736
+ sql,
5737
+ bindings
5738
+ } }];
5739
+ return this;
5740
+ }
5741
+ /**
5742
+ * Resolves the recorded group-by sources into adapter {@link QueryGroupByItem}s.
5743
+ * A bare string that matches a select-column alias is expanded to that column's
5744
+ * underlying expression (group-by-alias); otherwise it is treated as a column.
5745
+ */
5746
+ buildGroupByItems(selectColumns) {
5747
+ if (!this.queryGroupBy || this.queryGroupBy.length === 0) return void 0;
5748
+ const expressionAliases = /* @__PURE__ */ new Map();
5749
+ selectColumns?.forEach((column) => {
5750
+ if (column.expression && column.alias) expressionAliases.set(JSON.stringify(column.expression), column.alias);
5751
+ });
5752
+ const aliasNames = new Set(expressionAliases.values());
5753
+ return this.queryGroupBy.map((source) => {
5754
+ if (source instanceof Expression) {
5755
+ const node = source.toExpressionNode();
5756
+ const alias = expressionAliases.get(JSON.stringify(node));
5757
+ return alias ? { alias } : { expression: node };
5758
+ }
5759
+ if (typeof source === "object") return { raw: source.raw };
5760
+ return aliasNames.has(source) ? { alias: source } : source;
5761
+ });
5762
+ }
5763
+ isGroupByAggregateSpec(value) {
5764
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Expression) && Array.isArray(value.by);
5765
+ }
5766
+ /**
5767
+ * Executes the query and returns plain, un-hydrated rows keyed by their select
5768
+ * alias — the natural shape for `select` + `groupBy` aggregate reports. Pass a
5769
+ * row type to describe the projection.
5770
+ *
5771
+ * @returns
5772
+ */
5773
+ async getRows() {
5774
+ return await this.executeReadRows();
5775
+ }
5776
+ /**
5777
+ * Runs a Prisma-style grouped aggregate and returns typed rows shaped as
5778
+ * `{ <by columns>, _sum, _avg, _min, _max, _count }`.
5779
+ */
5780
+ async executeGroupByAggregate(spec) {
5781
+ const selectMap = {};
5782
+ spec.by.forEach((column) => {
5783
+ selectMap[column] = true;
5784
+ });
5785
+ const aggregates = [];
5786
+ const register = (group, factory, map, numeric) => {
5787
+ Object.keys(map).forEach((column) => {
5788
+ if (!map[column]) return;
5789
+ const alias = `${group}_${column}`;
5790
+ selectMap[alias] = factory(column);
5791
+ aggregates.push({
5792
+ group,
5793
+ column,
5794
+ alias,
5795
+ numeric
5796
+ });
5797
+ });
5798
+ };
5799
+ if (spec._sum) register("_sum", (column) => sum(column), spec._sum, true);
5800
+ if (spec._avg) register("_avg", (column) => avg(column), spec._avg, true);
5801
+ if (spec._min) register("_min", (column) => min(column), spec._min, false);
5802
+ if (spec._max) register("_max", (column) => max(column), spec._max, false);
5803
+ let countAllAlias;
5804
+ if (spec._count === true) {
5805
+ countAllAlias = "_count_all";
5806
+ selectMap[countAllAlias] = count();
5807
+ } else if (spec._count) register("_count", (column) => count(column), spec._count, true);
5808
+ this.select(selectMap);
5809
+ this.groupBy(spec.by);
5810
+ return (await this.getRows()).map((row) => {
5811
+ const result = {};
5812
+ spec.by.forEach((column) => {
5813
+ result[column] = row[column];
5814
+ });
5815
+ const grouped = {};
5816
+ aggregates.forEach(({ group, column, alias, numeric }) => {
5817
+ grouped[group] ??= {};
5818
+ grouped[group][column] = numeric ? this.coerceNumeric(row[alias]) : row[alias];
5819
+ });
5820
+ Object.assign(result, grouped);
5821
+ if (countAllAlias) result._count = this.coerceNumeric(row[countAllAlias]);
5822
+ return result;
5823
+ });
5824
+ }
5825
+ coerceNumeric(value) {
5826
+ if (value === null || value === void 0) return null;
5827
+ return Number(value);
5828
+ }
5569
5829
  appendHavingCondition(boolean, condition) {
5570
5830
  if (!this.queryHaving) {
5571
5831
  this.queryHaving = condition;
@@ -5586,12 +5846,35 @@ var QueryBuilder = class QueryBuilder {
5586
5846
  value: hasOperator ? maybeValue : operatorOrValue
5587
5847
  };
5588
5848
  }
5589
- having(column, operatorOrValue, maybeValue) {
5590
- this.appendHavingCondition("AND", this.buildHavingComparison(operatorOrValue, maybeValue, column));
5849
+ /**
5850
+ * Resolves the three `having` call shapes into a condition: `having(column, )`,
5851
+ * `having(expression)` (a boolean expression predicate), and
5852
+ * `having(expression, operator, value)` (compare an aggregate to a value).
5853
+ */
5854
+ buildHavingCondition(columnOrExpression, operatorOrValue, maybeValue) {
5855
+ if (columnOrExpression instanceof Expression) return {
5856
+ type: "expression",
5857
+ expression: (operatorOrValue === void 0 ? columnOrExpression : this.compareExpression(columnOrExpression, operatorOrValue, maybeValue)).toExpressionNode()
5858
+ };
5859
+ return this.buildHavingComparison(operatorOrValue, maybeValue, columnOrExpression);
5860
+ }
5861
+ compareExpression(expression, operator, value) {
5862
+ switch (operator) {
5863
+ case "=": return expression.eq(value);
5864
+ case "!=": return expression.ne(value);
5865
+ case ">": return expression.gt(value);
5866
+ case ">=": return expression.gte(value);
5867
+ case "<": return expression.lt(value);
5868
+ case "<=": return expression.lte(value);
5869
+ default: return expression.eq(value);
5870
+ }
5871
+ }
5872
+ having(columnOrExpression, operatorOrValue, maybeValue) {
5873
+ this.appendHavingCondition("AND", this.buildHavingCondition(columnOrExpression, operatorOrValue, maybeValue));
5591
5874
  return this;
5592
5875
  }
5593
- orHaving(column, operatorOrValue, maybeValue) {
5594
- this.appendHavingCondition("OR", this.buildHavingComparison(operatorOrValue, maybeValue, column));
5876
+ orHaving(columnOrExpression, operatorOrValue, maybeValue) {
5877
+ this.appendHavingCondition("OR", this.buildHavingCondition(columnOrExpression, operatorOrValue, maybeValue));
5595
5878
  return this;
5596
5879
  }
5597
5880
  /**
@@ -6749,12 +7032,19 @@ var QueryBuilder = class QueryBuilder {
6749
7032
  }
6750
7033
  if (typeof select !== "object" || !select) return null;
6751
7034
  const entries = Object.entries(select);
6752
- if (entries.some(([, value]) => value !== true && value !== false && value !== void 0 && typeof value !== "string")) return null;
6753
- const columns = entries.filter(([, value]) => value === true || typeof value === "string").map(([column, value]) => typeof value === "string" ? {
6754
- column,
6755
- alias: value,
6756
- raw: true
6757
- } : { column });
7035
+ if (entries.some(([, value]) => value !== true && value !== false && value !== void 0 && typeof value !== "string" && !(value instanceof Expression))) return null;
7036
+ const columns = entries.filter(([, value]) => value === true || typeof value === "string" || value instanceof Expression).map(([column, value]) => {
7037
+ if (value instanceof Expression) return {
7038
+ column,
7039
+ alias: column,
7040
+ expression: value.toExpressionNode()
7041
+ };
7042
+ return typeof value === "string" ? {
7043
+ column,
7044
+ alias: value,
7045
+ raw: true
7046
+ } : { column };
7047
+ });
6758
7048
  return columns.length > 0 ? columns : [];
6759
7049
  }
6760
7050
  normalizeQueryOrderBy(orderBy) {
@@ -6912,7 +7202,7 @@ var QueryBuilder = class QueryBuilder {
6912
7202
  offset: normalizedQuery.offsetValue,
6913
7203
  columns: normalizedQuery.querySelect ? [...normalizedQuery.querySelect] : void 0,
6914
7204
  distinct: normalizedQuery.queryDistinct || void 0,
6915
- groupBy: normalizedQuery.queryGroupBy ? [...normalizedQuery.queryGroupBy] : void 0,
7205
+ groupBy: normalizedQuery.queryGroupBy ? normalizedQuery.queryGroupBy.filter((source) => typeof source === "string") : void 0,
6916
7206
  relationLoads: this.mergeRelationLoadPlans(normalizedQuery.queryRelationLoads ? this.cloneRelationLoads(normalizedQuery.queryRelationLoads) : void 0, this.mergeRelationLoadPlans(callbackRelationLoads, childRelationLoads))
6917
7207
  });
6918
7208
  }
@@ -7176,11 +7466,11 @@ var QueryBuilder = class QueryBuilder {
7176
7466
  if (columns === null || orderBy === null || condition === null) return null;
7177
7467
  if (this.hasRelationFilters() && this.canExecuteRelationFiltersInAdapter() && relationFilters === null) return null;
7178
7468
  if (this.hasRelationAggregates() && this.canExecuteRelationAggregatesInAdapter() && relationAggregates === null) return null;
7179
- return {
7469
+ return this.expandComputedAttributes({
7180
7470
  target: this.buildQueryTarget(),
7181
7471
  columns,
7182
7472
  distinct: this.queryDistinct || void 0,
7183
- groupBy: this.queryGroupBy ? [...this.queryGroupBy] : void 0,
7473
+ groupBy: this.buildGroupByItems(columns ?? void 0),
7184
7474
  having: this.queryHaving,
7185
7475
  joins: this.queryJoins ? [...this.queryJoins] : void 0,
7186
7476
  where: condition,
@@ -7190,7 +7480,86 @@ var QueryBuilder = class QueryBuilder {
7190
7480
  relationLoads: this.queryRelationLoads,
7191
7481
  relationFilters: this.canExecuteRelationFiltersInAdapter() ? relationFilters ?? void 0 : void 0,
7192
7482
  relationAggregates: this.canExecuteRelationAggregatesInAdapter() ? relationAggregates ?? void 0 : void 0
7483
+ });
7484
+ }
7485
+ /** Reads and caches the model's resolved `static computed` expression map. */
7486
+ computedAttributes() {
7487
+ const model = this.model;
7488
+ return typeof model.getComputed === "function" ? model.getComputed() : {};
7489
+ }
7490
+ /**
7491
+ * Expands references to `static computed` attribute names into their backing
7492
+ * expressions across a select spec's columns, group by, order by, where, and
7493
+ * having clauses. A no-op when the model declares no computed attributes.
7494
+ */
7495
+ expandComputedAttributes(spec) {
7496
+ const computed = this.computedAttributes();
7497
+ if (Object.keys(computed).length === 0) return spec;
7498
+ const columns = spec.columns?.map((column) => {
7499
+ if (column.expression || column.raw || column.wildcard) return column;
7500
+ const expression = computed[column.column];
7501
+ return expression ? {
7502
+ ...column,
7503
+ expression,
7504
+ alias: column.alias ?? column.column
7505
+ } : column;
7506
+ });
7507
+ const selectedComputedAliases = new Set(columns?.filter((column) => column.expression && column.alias).map((column) => column.alias));
7508
+ return {
7509
+ ...spec,
7510
+ columns,
7511
+ groupBy: spec.groupBy?.map((item) => {
7512
+ if (typeof item !== "string") return item;
7513
+ const expression = computed[item];
7514
+ if (!expression) return item;
7515
+ return selectedComputedAliases.has(item) ? { alias: item } : { expression };
7516
+ }),
7517
+ orderBy: spec.orderBy?.map((clause) => {
7518
+ if (clause.expression) return clause;
7519
+ const expression = computed[clause.column];
7520
+ return expression ? {
7521
+ ...clause,
7522
+ expression
7523
+ } : clause;
7524
+ }),
7525
+ where: spec.where ? this.expandComputedCondition(spec.where, computed) : spec.where,
7526
+ having: spec.having ? this.expandComputedCondition(spec.having, computed) : spec.having
7527
+ };
7528
+ }
7529
+ expandComputedCondition(condition, computed) {
7530
+ if (condition.type === "comparison" && computed[condition.column]) return {
7531
+ type: "expression",
7532
+ expression: this.computedComparison(computed[condition.column], condition.operator, condition.value)
7533
+ };
7534
+ if (condition.type === "group") return {
7535
+ ...condition,
7536
+ conditions: condition.conditions.map((entry) => this.expandComputedCondition(entry, computed))
7193
7537
  };
7538
+ if (condition.type === "not") return {
7539
+ ...condition,
7540
+ condition: this.expandComputedCondition(condition.condition, computed)
7541
+ };
7542
+ return condition;
7543
+ }
7544
+ /** Converts a where comparison against a computed attribute into an expression. */
7545
+ computedComparison(node, operator, value) {
7546
+ const expression = fromExpressionNode(node);
7547
+ const list = Array.isArray(value) ? value : [];
7548
+ switch (operator) {
7549
+ case "!=": return expression.ne(value).toExpressionNode();
7550
+ case ">": return expression.gt(value).toExpressionNode();
7551
+ case ">=": return expression.gte(value).toExpressionNode();
7552
+ case "<": return expression.lt(value).toExpressionNode();
7553
+ case "<=": return expression.lte(value).toExpressionNode();
7554
+ case "in": return expression.in(list).toExpressionNode();
7555
+ case "not-in": return expression.notIn(list).toExpressionNode();
7556
+ case "is-null": return expression.isNull().toExpressionNode();
7557
+ case "is-not-null": return expression.isNotNull().toExpressionNode();
7558
+ case "contains": return expression.like(`%${String(value)}%`).toExpressionNode();
7559
+ case "starts-with": return expression.like(`${String(value)}%`).toExpressionNode();
7560
+ case "ends-with": return expression.like(`%${String(value)}`).toExpressionNode();
7561
+ default: return expression.eq(value).toExpressionNode();
7562
+ }
7194
7563
  }
7195
7564
  tryBuildAggregateSpec() {
7196
7565
  const condition = this.buildQueryWhereCondition(false);
@@ -7690,6 +8059,9 @@ var Model = class Model {
7690
8059
  static {
7691
8060
  this.castMapCache = /* @__PURE__ */ new WeakMap();
7692
8061
  }
8062
+ static {
8063
+ this.computedCache = /* @__PURE__ */ new WeakMap();
8064
+ }
7693
8065
  static {
7694
8066
  this.emittedDeprecationWarnings = /* @__PURE__ */ new Set();
7695
8067
  }
@@ -7840,6 +8212,19 @@ var Model = class Model {
7840
8212
  return casts;
7841
8213
  }
7842
8214
  /**
8215
+ * Resolves the model's `static computed` declarations into expression nodes,
8216
+ * cached per class. Returns an empty map when no computed attributes exist.
8217
+ */
8218
+ static getComputed() {
8219
+ const cached = Model.computedCache.get(this);
8220
+ if (cached) return cached;
8221
+ const definitions = this.computed;
8222
+ const resolved = {};
8223
+ if (definitions) for (const [name, factory] of Object.entries(definitions)) resolved[name] = factory(expressionBuilder).toExpressionNode();
8224
+ Model.computedCache.set(this, resolved);
8225
+ return resolved;
8226
+ }
8227
+ /**
7843
8228
  * Apply built-in persistence casts (currently `json` serialisation) to a raw
7844
8229
  * attribute payload, without re-running arbitrary custom setters. Used by
7845
8230
  * both instance `save()` and the query-builder insert/update paths so a JS
@@ -9696,4 +10081,4 @@ var PivotModel = class extends Model {
9696
10081
  };
9697
10082
 
9698
10083
  //#endregion
9699
- export { Arkorm, ArkormCollection, ArkormException, Arkormx, Attribute, CliApp, DB, EnumBuilder, ForeignKeyBuilder, InitCommand, InlineFactory, JoinClause, 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 };
10084
+ export { AggregateExpression, Arkorm, ArkormCollection, ArkormException, Arkormx, Attribute, CaseExpression, CliApp, DB, EnumBuilder, Expression, ForeignKeyBuilder, InitCommand, InlineFactory, JoinClause, JsonExpression, 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, avg, awaitConfiguredModelsRegistration, bindAdapterToModels, buildEnumBlock, buildFieldLine, buildIndexLine, buildInverseRelationLine, buildMigrationIdentity, buildMigrationRunId, buildMigrationSource, buildModelBlock, buildPrimaryKeyLine, buildRelationLine, buildUniqueConstraintLine, caseWhen, coalesce, col, computeMigrationChecksum, configureArkormRuntime, count, createEmptyAppliedMigrationsState, createEmptyPersistedColumnMappingsState, createKyselyAdapter, createMigrationTimestamp, createPrismaAdapter, createPrismaCompatibilityAdapter, createPrismaDatabaseAdapter, createPrismaDelegateMap, defineConfig, defineFactory, deleteAppliedMigrationsStateFromStore, deletePersistedColumnMappingsState, deriveCollectionFieldName, deriveInverseRelationAlias, deriveRelationAlias, deriveRelationFieldName, deriveSingularFieldName, emitRuntimeDebugEvent, ensureArkormConfigLoading, escapeRegex, expressionBuilder, findAppliedMigration, findEnumBlock, findModelBlock, fn, formatDefaultValue, formatEnumDefaultValue, formatRelationAction, fromExpressionNode, 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, json, loadArkormConfig, loadFactoriesFrom, loadMigrationsFrom, loadModelsFrom, loadSeedersFrom, markMigrationApplied, markMigrationRun, max, min, pad, raw, readAppliedMigrationsState, readAppliedMigrationsStateFromStore, readPersistedColumnMappingsState, rebuildPersistedColumnMappingsState, registerFactories, registerMigrations, registerModels, registerPaths, registerSeeders, removeAppliedMigration, resetArkormRuntimeForTests, resetPersistedColumnMappingsCache, resetRuntimeRegistryForTests, resolveCast, resolveColumnMappingsFilePath, resolveEnumName, resolveGeneratedExpression, resolveMigrationClassName, resolveMigrationStateFilePath, resolvePersistedMetadataFeatures, resolvePrismaType, resolveRuntimeCompatibilityQuerySchema, resolveRuntimeCompatibilityQuerySchemaOrThrow, runArkormTransaction, runMigrationWithPrisma, runPrismaCommand, stripPrismaSchemaModelsAndEnums, sum, supportsDatabaseCreation, supportsDatabaseMigrationExecution, supportsDatabaseMigrationState, supportsDatabaseReset, syncPersistedColumnMappingsFromState, toMigrationFileSlug, toModelName, val, validatePersistedMetadataFeaturesForMigrations, where, writeAppliedMigrationsState, writeAppliedMigrationsStateToStore, writePersistedColumnMappingsState };