arkormx 2.12.7 → 2.12.9
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/cli.mjs +82 -57
- package/dist/{index-CdzU8tME.d.mts → index-Lxl6NdHS.d.cts} +186 -24
- package/dist/{index-DmAEofZM.d.cts → index-O3-Mi7hj.d.mts} +186 -24
- package/dist/index.cjs +93 -50
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +93 -50
- package/dist/relationship/index.cjs +1 -1
- package/dist/relationship/index.d.cts +1 -1
- package/dist/relationship/index.d.mts +1 -1
- package/dist/relationship/index.mjs +1 -1
- package/dist/{relationship-BuHgK3wO.cjs → relationship-D7MhPUIX.cjs} +239 -31
- package/dist/{relationship-D1VAPbxZ.mjs → relationship-DZ4WJ0Si.mjs} +238 -30
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as buildPrimaryKeyLine, $n as readAppliedMigrationsState, $t as bindAdapterToModels, A as resetPersistedColumnMappingsCache, An as registerFactories, At as EnumBuilder, B as applyCreateTableOperation, Bn as ForeignKeyBuilder, Bt as col, C as getPersistedEnumMap, Cn as getRegisteredModels, Ct as supportsDatabaseCreation, D as getPersistedTimestampColumns, Dn as loadMigrationsFrom, Dt as toModelName, E as getPersistedTableMetadata, En as loadFactoriesFrom, Et as toMigrationFileSlug, F as writePersistedColumnMappingsState, Fn as resetRuntimeRegistryForTests, Ft as Expression, G as applyMigrationToPrismaSchema, Gn as deleteAppliedMigrationsStateFromStore, Gt as json, H as applyMigrationRollbackToDatabase, Hn as buildMigrationRunId, Ht as expressionBuilder, I as PRISMA_ENUM_MEMBER_REGEX, In as resolveRegisteredModel, It as JsonExpression, J as buildFieldLine, Jn as getLastMigrationRun, Jt as raw, K as applyOperationsToPrismaSchema, Kn as findAppliedMigration, Kt as max, L as PRISMA_ENUM_REGEX, Ln as UnsupportedAdapterFeatureException, Lt as avg, M as resolvePersistedMetadataFeatures, Mn as registerModels, Mt as resolveGeneratedExpression, N as syncPersistedColumnMappingsFromState, Nn as registerPaths, Nt as AggregateExpression, O as readPersistedColumnMappingsState, On as loadModelsFrom, Ot as isMigrationPlanningActive, P as validatePersistedMetadataFeaturesForMigrations, Pn as registerSeeders, Pt as CaseExpression, Q as buildModelBlock, Qn as markMigrationRun, Qt as awaitConfiguredModelsRegistration, R as PRISMA_MODEL_REGEX, Rn as RuntimeModuleLoader, Rt as caseWhen, S as getPersistedColumnMap, Sn as getRegisteredMigrations, St as stripPrismaSchemaModelsAndEnums, T as getPersistedPrimaryKeyGeneration, Tn as getRegisteredSeeders, Tt as supportsDatabaseReset, U as applyMigrationRollbackToPrismaSchema, Un as computeMigrationChecksum, Ut as fn, V as applyDropTableOperation, Vn as buildMigrationIdentity, Vt as count, W as applyMigrationToDatabase, Wn as createEmptyAppliedMigrationsState, Wt as fromExpressionNode, X as buildInverseRelationLine, Xn as isMigrationApplied, Xt as val, Y as buildIndexLine, Yn as getLatestAppliedMigrations, Yt as sum, Z as buildMigrationSource, Zn as markMigrationApplied, Zt as where, _ as SetBasedEagerLoader, _n as isTransactionCapableClient, _t as resolveEnumName, a as MorphManyRelation, an as getActiveTransactionAdapter, ar as writeAppliedMigrationsStateToStore, at as deriveRelationAlias, b as createEmptyPersistedColumnMappingsState, bn as runArkormTransaction, bt as runMigrationWithPrisma, c as HasManyThroughRelation, cn as getRuntimeAdapter, cr as ArkormException, ct as escapeRegex, dn as getRuntimePaginationCurrentPageResolver, dt as formatDefaultValue, en as configureArkormRuntime, er as readAppliedMigrationsStateFromStore, et as buildRelationLine, f as BelongsToManyRelation, fn as getRuntimePaginationURLDriverFactory, ft as formatEnumDefaultValue, g as URLDriver, gn as isQuerySchemaLike, gt as pad, h as Paginator, hn as isDelegateLike, ht as getMigrationPlan, i as MorphOneRelation, in as ensureArkormConfigLoading, ir as writeAppliedMigrationsState, it as deriveInverseRelationAlias, j as resolveColumnMappingsFilePath, jn as registerMigrations, jt as TableBuilder, k as rebuildPersistedColumnMappingsState, kn as loadSeedersFrom, kt as SchemaBuilder, l as HasManyRelation, ln as getRuntimeClient, lt as findEnumBlock, m as LengthAwarePaginator, mn as getUserConfig, mt as generateMigrationFile, n as MorphedByManyRelation, nn as disposeArkormRuntime, nr as resolveMigrationStateFilePath, nt as createMigrationTimestamp, o as HasOneThroughRelation, on as getActiveTransactionClient, or as RelationResolutionException, ot as deriveRelationFieldName, p as Relation, pn as getRuntimePrismaClient, pt as formatRelationAction, q as buildEnumBlock, qn as getLastBatchMigrations, qt as min, r as MorphToManyRelation, rn as emitRuntimeDebugEvent, rr as supportsDatabaseMigrationState, rt as deriveCollectionFieldName, s as HasOneRelation, sn as getDefaultStubsPath, sr as ArkormCollection, st as deriveSingularFieldName, t as MorphToRelation, tn as defineConfig, tr as removeAppliedMigration, tt as buildUniqueConstraintLine, u as BelongsToRelation, un as getRuntimeDebugHandler, ut as findModelBlock, vn as loadArkormConfig, vt as resolveMigrationClassName, w as getPersistedEnumTsType, wn as getRegisteredPaths, wt as supportsDatabaseMigrationExecution, x as deletePersistedColumnMappingsState, xn as getRegisteredFactories, xt as runPrismaCommand, y as applyOperationsToPersistedColumnMappingsState, yn as resetArkormRuntimeForTests, yt as resolvePrismaType, z as applyAlterTableOperation, zn as PrimaryKeyGenerationPlanner, zt as coalesce } from "./relationship-
|
|
1
|
+
import { $ as buildPrimaryKeyLine, $n as readAppliedMigrationsState, $t as bindAdapterToModels, A as resetPersistedColumnMappingsCache, An as registerFactories, At as EnumBuilder, B as applyCreateTableOperation, Bn as ForeignKeyBuilder, Bt as col, C as getPersistedEnumMap, Cn as getRegisteredModels, Ct as supportsDatabaseCreation, D as getPersistedTimestampColumns, Dn as loadMigrationsFrom, Dt as toModelName, E as getPersistedTableMetadata, En as loadFactoriesFrom, Et as toMigrationFileSlug, F as writePersistedColumnMappingsState, Fn as resetRuntimeRegistryForTests, Ft as Expression, G as applyMigrationToPrismaSchema, Gn as deleteAppliedMigrationsStateFromStore, Gt as json, H as applyMigrationRollbackToDatabase, Hn as buildMigrationRunId, Ht as expressionBuilder, I as PRISMA_ENUM_MEMBER_REGEX, In as resolveRegisteredModel, It as JsonExpression, J as buildFieldLine, Jn as getLastMigrationRun, Jt as raw, K as applyOperationsToPrismaSchema, Kn as findAppliedMigration, Kt as max, L as PRISMA_ENUM_REGEX, Ln as UnsupportedAdapterFeatureException, Lt as avg, M as resolvePersistedMetadataFeatures, Mn as registerModels, Mt as resolveGeneratedExpression, N as syncPersistedColumnMappingsFromState, Nn as registerPaths, Nt as AggregateExpression, O as readPersistedColumnMappingsState, On as loadModelsFrom, Ot as isMigrationPlanningActive, P as validatePersistedMetadataFeaturesForMigrations, Pn as registerSeeders, Pt as CaseExpression, Q as buildModelBlock, Qn as markMigrationRun, Qt as awaitConfiguredModelsRegistration, R as PRISMA_MODEL_REGEX, Rn as RuntimeModuleLoader, Rt as caseWhen, S as getPersistedColumnMap, Sn as getRegisteredMigrations, St as stripPrismaSchemaModelsAndEnums, T as getPersistedPrimaryKeyGeneration, Tn as getRegisteredSeeders, Tt as supportsDatabaseReset, U as applyMigrationRollbackToPrismaSchema, Un as computeMigrationChecksum, Ut as fn, V as applyDropTableOperation, Vn as buildMigrationIdentity, Vt as count, W as applyMigrationToDatabase, Wn as createEmptyAppliedMigrationsState, Wt as fromExpressionNode, X as buildInverseRelationLine, Xn as isMigrationApplied, Xt as val, Y as buildIndexLine, Yn as getLatestAppliedMigrations, Yt as sum, Z as buildMigrationSource, Zn as markMigrationApplied, Zt as where, _ as SetBasedEagerLoader, _n as isTransactionCapableClient, _t as resolveEnumName, a as MorphManyRelation, an as getActiveTransactionAdapter, ar as writeAppliedMigrationsStateToStore, at as deriveRelationAlias, b as createEmptyPersistedColumnMappingsState, bn as runArkormTransaction, bt as runMigrationWithPrisma, c as HasManyThroughRelation, cn as getRuntimeAdapter, cr as ArkormException, ct as escapeRegex, dn as getRuntimePaginationCurrentPageResolver, dt as formatDefaultValue, en as configureArkormRuntime, er as readAppliedMigrationsStateFromStore, et as buildRelationLine, f as BelongsToManyRelation, fn as getRuntimePaginationURLDriverFactory, ft as formatEnumDefaultValue, g as URLDriver, gn as isQuerySchemaLike, gt as pad, h as Paginator, hn as isDelegateLike, ht as getMigrationPlan, i as MorphOneRelation, in as ensureArkormConfigLoading, ir as writeAppliedMigrationsState, it as deriveInverseRelationAlias, j as resolveColumnMappingsFilePath, jn as registerMigrations, jt as TableBuilder, k as rebuildPersistedColumnMappingsState, kn as loadSeedersFrom, kt as SchemaBuilder, l as HasManyRelation, ln as getRuntimeClient, lt as findEnumBlock, m as LengthAwarePaginator, mn as getUserConfig, mt as generateMigrationFile, n as MorphedByManyRelation, nn as disposeArkormRuntime, nr as resolveMigrationStateFilePath, nt as createMigrationTimestamp, o as HasOneThroughRelation, on as getActiveTransactionClient, or as RelationResolutionException, ot as deriveRelationFieldName, p as Relation, pn as getRuntimePrismaClient, pt as formatRelationAction, q as buildEnumBlock, qn as getLastBatchMigrations, qt as min, r as MorphToManyRelation, rn as emitRuntimeDebugEvent, rr as supportsDatabaseMigrationState, rt as deriveCollectionFieldName, s as HasOneRelation, sn as getDefaultStubsPath, sr as ArkormCollection, st as deriveSingularFieldName, t as MorphToRelation, tn as defineConfig, tr as removeAppliedMigration, tt as buildUniqueConstraintLine, u as BelongsToRelation, un as getRuntimeDebugHandler, ut as findModelBlock, vn as loadArkormConfig, vt as resolveMigrationClassName, w as getPersistedEnumTsType, wn as getRegisteredPaths, wt as supportsDatabaseMigrationExecution, x as deletePersistedColumnMappingsState, xn as getRegisteredFactories, xt as runPrismaCommand, y as applyOperationsToPersistedColumnMappingsState, yn as resetArkormRuntimeForTests, yt as resolvePrismaType, z as applyAlterTableOperation, zn as PrimaryKeyGenerationPlanner, zt as coalesce } from "./relationship-DZ4WJ0Si.mjs";
|
|
2
2
|
import { Pool } from "pg";
|
|
3
3
|
import { extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
4
|
import { existsSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -10,8 +10,8 @@ import { dirname as dirname$1, extname as extname$1, join as join$1, relative as
|
|
|
10
10
|
import { DateTime, str } from "@h3ravel/support";
|
|
11
11
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
|
+
import { Application, Command } from "@h3ravel/musket";
|
|
13
14
|
import { Logger } from "@h3ravel/shared";
|
|
14
|
-
import { Command } from "@h3ravel/musket";
|
|
15
15
|
|
|
16
16
|
//#region src/Exceptions/QueryExecutionException.ts
|
|
17
17
|
var QueryExecutionException = class extends ArkormException {
|
|
@@ -692,7 +692,8 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
692
692
|
buildOrderBy(target, orderBy, qualifyColumns = false) {
|
|
693
693
|
if (!orderBy || orderBy.length === 0) return sql``;
|
|
694
694
|
return sql` order by ${sql.join(orderBy.map(({ column, direction, expression }) => {
|
|
695
|
-
|
|
695
|
+
const reference = expression ? this.buildExpression(target, expression) : qualifyColumns ? this.buildColumnReference(this.resolveTable(target), this.mapColumn(target, column)) : sql.ref(this.mapColumn(target, column));
|
|
696
|
+
return sql`${reference} ${sql.raw(direction === "desc" ? "desc" : "asc")}`;
|
|
696
697
|
}), sql`, `)}`;
|
|
697
698
|
}
|
|
698
699
|
buildGroupBy(target, groupBy) {
|
|
@@ -793,7 +794,8 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
793
794
|
if (condition.operator === "contains") return sql`${column} like ${`%${String(condition.value ?? "")}%`}`;
|
|
794
795
|
if (condition.operator === "starts-with") return sql`${column} like ${`${String(condition.value ?? "")}%`}`;
|
|
795
796
|
if (condition.operator === "ends-with") return sql`${column} like ${`%${String(condition.value ?? "")}`}`;
|
|
796
|
-
|
|
797
|
+
const operator = condition.operator === "!=" ? sql.raw("!=") : sql.raw(condition.operator);
|
|
798
|
+
return sql`${column} ${operator} ${condition.value}`;
|
|
797
799
|
}
|
|
798
800
|
buildRawWhereCondition(condition) {
|
|
799
801
|
const segments = condition.sql.split("?");
|
|
@@ -813,10 +815,12 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
813
815
|
return sql`${left} ${sql.raw(condition.operator)} ${right}`;
|
|
814
816
|
}
|
|
815
817
|
buildTimeCondition(target, condition) {
|
|
816
|
-
|
|
818
|
+
const column = sql.ref(this.mapColumn(target, condition.column));
|
|
819
|
+
return sql`${column}::time ${sql.raw(condition.operator)} ${condition.value}::time`;
|
|
817
820
|
}
|
|
818
821
|
buildDayCondition(target, condition) {
|
|
819
|
-
|
|
822
|
+
const column = sql.ref(this.mapColumn(target, condition.column));
|
|
823
|
+
return sql`extract(day from ${column}) ${sql.raw(condition.operator)} ${condition.value}`;
|
|
820
824
|
}
|
|
821
825
|
buildExistsCondition(condition) {
|
|
822
826
|
const target = condition.query.target;
|
|
@@ -829,19 +833,24 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
829
833
|
}
|
|
830
834
|
buildFullTextCondition(target, condition) {
|
|
831
835
|
const language = sql.raw(`'${condition.language ?? "simple"}'`);
|
|
832
|
-
|
|
836
|
+
const document = sql.join(condition.columns.map((column) => {
|
|
833
837
|
return sql`coalesce(${sql.ref(this.mapColumn(target, column))}::text, '')`;
|
|
834
|
-
}), sql` || ' ' || `)
|
|
838
|
+
}), sql` || ' ' || `);
|
|
839
|
+
return sql`to_tsvector(${language}, ${document}) @@ plainto_tsquery(${language}, ${condition.value})`;
|
|
835
840
|
}
|
|
836
841
|
buildJsonAccessor(target, column, path) {
|
|
837
842
|
const base = sql`${sql.ref(this.mapColumn(target, column))}::jsonb`;
|
|
838
843
|
if (!path || path.length === 0) return base;
|
|
839
|
-
|
|
844
|
+
const pathLiteral = `{${path.join(",")}}`;
|
|
845
|
+
return sql`(${base} #> ${pathLiteral}::text[])`;
|
|
840
846
|
}
|
|
841
847
|
buildJsonCondition(target, condition) {
|
|
842
848
|
const accessor = this.buildJsonAccessor(target, condition.column, condition.path);
|
|
843
849
|
if (condition.kind === "contains-key") return condition.not ? sql`${accessor} is null` : sql`${accessor} is not null`;
|
|
844
|
-
if (condition.kind === "length")
|
|
850
|
+
if (condition.kind === "length") {
|
|
851
|
+
const operator = sql.raw(condition.operator ?? "=");
|
|
852
|
+
return sql`jsonb_array_length(${accessor}) ${operator} ${condition.value}`;
|
|
853
|
+
}
|
|
845
854
|
const jsonValue = JSON.stringify(condition.value ?? null);
|
|
846
855
|
if (condition.kind === "overlaps") return sql`exists (
|
|
847
856
|
select 1
|
|
@@ -921,7 +930,10 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
921
930
|
let accessor;
|
|
922
931
|
if (node.path.length === 0) accessor = base;
|
|
923
932
|
else if (node.path.length === 1) accessor = sql`(${base} ->> ${node.path[0]})`;
|
|
924
|
-
else
|
|
933
|
+
else {
|
|
934
|
+
const pathLiteral = `{${node.path.join(",")}}`;
|
|
935
|
+
accessor = sql`(${base} #>> ${pathLiteral}::text[])`;
|
|
936
|
+
}
|
|
925
937
|
if (node.cast === "number") return sql`(${accessor})::numeric`;
|
|
926
938
|
if (node.cast === "boolean") return sql`(${accessor})::boolean`;
|
|
927
939
|
return accessor;
|
|
@@ -1086,11 +1098,13 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1086
1098
|
buildRelationFilterExpression(target, filter) {
|
|
1087
1099
|
if (filter.morph) return this.buildMorphRelationFilterExpression(target, filter);
|
|
1088
1100
|
const { relatedTarget, from, condition } = this.buildRelatedJoinCondition(target, filter.relation);
|
|
1101
|
+
const whereCondition = this.combineConditions([condition, filter.where ? this.buildWhereCondition(relatedTarget, filter.where) : void 0]);
|
|
1102
|
+
const operator = filter.operator === "!=" ? sql.raw("!=") : sql.raw(filter.operator);
|
|
1089
1103
|
return sql`(
|
|
1090
1104
|
select count(*)::int
|
|
1091
1105
|
from ${from}
|
|
1092
|
-
where ${
|
|
1093
|
-
) ${
|
|
1106
|
+
where ${whereCondition}
|
|
1107
|
+
) ${operator} ${filter.count}`;
|
|
1094
1108
|
}
|
|
1095
1109
|
buildMorphRelationFilterExpression(outerTarget, filter) {
|
|
1096
1110
|
const morph = filter.morph;
|
|
@@ -1156,8 +1170,9 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1156
1170
|
where ${whereCondition}
|
|
1157
1171
|
) as ${sql.id(aggregate.alias ?? `${aggregate.relation}Exists`)}`;
|
|
1158
1172
|
const selectedColumn = aggregate.column ? this.buildColumnReference(relatedTable, this.mapColumn(relatedTarget, aggregate.column)) : sql.raw("*");
|
|
1173
|
+
const aggregateExpression = aggregate.type === "count" ? sql`count(*)::int` : aggregate.type === "sum" ? sql`sum(${selectedColumn})::double precision` : aggregate.type === "avg" ? sql`avg(${selectedColumn})::double precision` : aggregate.type === "min" ? sql`min(${selectedColumn})` : sql`max(${selectedColumn})`;
|
|
1159
1174
|
return sql`, (
|
|
1160
|
-
select ${
|
|
1175
|
+
select ${aggregateExpression}
|
|
1161
1176
|
from ${from}
|
|
1162
1177
|
where ${whereCondition}
|
|
1163
1178
|
) as ${sql.id(aggregate.alias ?? `${aggregate.relation}${aggregate.type}`)}`;
|
|
@@ -1643,6 +1658,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1643
1658
|
}
|
|
1644
1659
|
async introspectModels(options = {}) {
|
|
1645
1660
|
const tables = options.tables?.filter(Boolean) ?? [];
|
|
1661
|
+
const tableFilter = tables.length > 0 ? sql` and cls.relname in (${sql.join(tables)})` : sql``;
|
|
1646
1662
|
const result = await sql`
|
|
1647
1663
|
select
|
|
1648
1664
|
cls.relname as table_name,
|
|
@@ -1667,7 +1683,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
|
|
|
1667
1683
|
and att.attnum > 0
|
|
1668
1684
|
and not att.attisdropped
|
|
1669
1685
|
and ns.nspname not in ('pg_catalog', 'information_schema')
|
|
1670
|
-
${
|
|
1686
|
+
${tableFilter}
|
|
1671
1687
|
order by cls.relname asc, att.attnum asc
|
|
1672
1688
|
`.execute(this.db);
|
|
1673
1689
|
const models = /* @__PURE__ */ new Map();
|
|
@@ -2448,9 +2464,11 @@ const loadModel = (modelName, exportName) => {
|
|
|
2448
2464
|
sourceMaps: true
|
|
2449
2465
|
});
|
|
2450
2466
|
for (const directory of getModelDirectories()) {
|
|
2451
|
-
const
|
|
2467
|
+
const sourcePath = join(directory, modelName);
|
|
2468
|
+
const modulePath = resolveRuntimeModelPath(sourcePath);
|
|
2452
2469
|
if (!existsSync(modulePath)) continue;
|
|
2453
|
-
const
|
|
2470
|
+
const module = jiti(modulePath);
|
|
2471
|
+
const model = resolveModelExport(module, exportName);
|
|
2454
2472
|
if (!isModelConstructor(model)) continue;
|
|
2455
2473
|
registerModels(model);
|
|
2456
2474
|
return model;
|
|
@@ -2728,12 +2746,18 @@ function resolveCast(definition) {
|
|
|
2728
2746
|
* @author Legacy (3m1n3nc3)
|
|
2729
2747
|
* @since 0.1.0
|
|
2730
2748
|
*/
|
|
2731
|
-
var CliApp = class {
|
|
2749
|
+
var CliApp = class extends Application {
|
|
2732
2750
|
constructor() {
|
|
2751
|
+
super();
|
|
2733
2752
|
this.config = {};
|
|
2734
2753
|
this.getConfig = getUserConfig;
|
|
2735
2754
|
this.config = getUserConfig();
|
|
2736
2755
|
}
|
|
2756
|
+
registerMusketListeners(musket) {
|
|
2757
|
+
musket.afterHandle.on(async () => {
|
|
2758
|
+
await disposeArkormRuntime();
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2737
2761
|
isUsingPrismaAdapter() {
|
|
2738
2762
|
return this.getConfig("adapter") instanceof PrismaDatabaseAdapter;
|
|
2739
2763
|
}
|
|
@@ -2870,7 +2894,8 @@ var CliApp = class {
|
|
|
2870
2894
|
* @returns
|
|
2871
2895
|
*/
|
|
2872
2896
|
resolveStubPath(stubName) {
|
|
2873
|
-
|
|
2897
|
+
const stubsDir = this.resolveConfigPath("stubs", getDefaultStubsPath());
|
|
2898
|
+
return join$1(stubsDir, stubName);
|
|
2874
2899
|
}
|
|
2875
2900
|
/**
|
|
2876
2901
|
* Generate a factory file for a given model name.
|
|
@@ -2884,7 +2909,8 @@ var CliApp = class {
|
|
|
2884
2909
|
const factoryName = `${baseName}Factory`;
|
|
2885
2910
|
const modelName = options.modelName ? str(options.modelName).pascal() : baseName;
|
|
2886
2911
|
const outputExt = this.resolveOutputExt();
|
|
2887
|
-
const
|
|
2912
|
+
const factoriesDir = this.resolveConfigPath("factories", join$1(process.cwd(), "database", "factories"));
|
|
2913
|
+
const outputPath = join$1(factoriesDir, `${factoryName}.${outputExt}`);
|
|
2888
2914
|
const modelPath = join$1(this.resolveConfigPath("models", join$1(process.cwd(), "src", "models")), `${modelName}.${outputExt}`);
|
|
2889
2915
|
const relativeImport = options.modelImportPath ?? `./${this.stripKnownSourceExtension(relative$1(dirname$1(outputPath), modelPath).replace(/\\/g, "/"))}${outputExt === "js" ? ".js" : ""}`;
|
|
2890
2916
|
const stubPath = this.resolveStubPath(outputExt === "js" ? "factory.js.stub" : "factory.stub");
|
|
@@ -2907,7 +2933,8 @@ var CliApp = class {
|
|
|
2907
2933
|
makeSeeder(name, options = {}) {
|
|
2908
2934
|
const seederName = `${str(name.replace(/Seeder$/, "")).pascal()}Seeder`;
|
|
2909
2935
|
const outputExt = this.resolveOutputExt();
|
|
2910
|
-
const
|
|
2936
|
+
const seedersDir = this.resolveConfigPath("seeders", join$1(process.cwd(), "database", "seeders"));
|
|
2937
|
+
const outputPath = join$1(seedersDir, `${seederName}.${outputExt}`);
|
|
2911
2938
|
const stubPath = this.resolveStubPath(outputExt === "js" ? "seeder.js.stub" : "seeder.stub");
|
|
2912
2939
|
return {
|
|
2913
2940
|
name: seederName,
|
|
@@ -2921,8 +2948,9 @@ var CliApp = class {
|
|
|
2921
2948
|
* @returns An object containing the name and path of the generated migration file.
|
|
2922
2949
|
*/
|
|
2923
2950
|
makeMigration(name) {
|
|
2951
|
+
const migrationsDir = this.resolveConfigPath("migrations", join$1(process.cwd(), "database", "migrations"));
|
|
2924
2952
|
const generated = generateMigrationFile(name, {
|
|
2925
|
-
directory:
|
|
2953
|
+
directory: migrationsDir,
|
|
2926
2954
|
extension: this.resolveOutputExt()
|
|
2927
2955
|
});
|
|
2928
2956
|
return {
|
|
@@ -2942,7 +2970,8 @@ var CliApp = class {
|
|
|
2942
2970
|
const modelName = `${baseName}`;
|
|
2943
2971
|
const tableName = str(baseName).camel().plural().toString();
|
|
2944
2972
|
const outputExt = this.resolveOutputExt();
|
|
2945
|
-
const
|
|
2973
|
+
const modelsDir = this.resolveConfigPath("models", join$1(process.cwd(), "src", "models"));
|
|
2974
|
+
const outputPath = join$1(modelsDir, `${modelName}.${outputExt}`);
|
|
2946
2975
|
const shouldBuildFactory = options.all || options.factory;
|
|
2947
2976
|
const shouldBuildSeeder = options.all || options.seeder;
|
|
2948
2977
|
const shouldBuildMigration = options.all || options.migration;
|
|
@@ -2996,7 +3025,7 @@ var CliApp = class {
|
|
|
2996
3025
|
path: schemaPath,
|
|
2997
3026
|
updated: false
|
|
2998
3027
|
};
|
|
2999
|
-
|
|
3028
|
+
const updated = applyCreateTableOperation(source, {
|
|
3000
3029
|
type: "createTable",
|
|
3001
3030
|
table: tableName,
|
|
3002
3031
|
columns: [{
|
|
@@ -3006,7 +3035,8 @@ var CliApp = class {
|
|
|
3006
3035
|
}],
|
|
3007
3036
|
indexes: [],
|
|
3008
3037
|
foreignKeys: []
|
|
3009
|
-
})
|
|
3038
|
+
});
|
|
3039
|
+
writeFileSync$1(schemaPath, updated);
|
|
3010
3040
|
return {
|
|
3011
3041
|
path: schemaPath,
|
|
3012
3042
|
updated: true
|
|
@@ -3204,7 +3234,7 @@ var CliApp = class {
|
|
|
3204
3234
|
const existingImport = modelSource.match(importRegex);
|
|
3205
3235
|
if (existingImport) {
|
|
3206
3236
|
const existingTypes = existingImport[1].split(",").map((value) => value.trim()).filter(Boolean);
|
|
3207
|
-
const mergedTypes = [
|
|
3237
|
+
const mergedTypes = [.../* @__PURE__ */ new Set([...existingTypes, ...enumTypes])].sort((left, right) => left.localeCompare(right));
|
|
3208
3238
|
return modelSource.replace(importRegex, `import type { ${mergedTypes.join(", ")} } from '@prisma/client'`);
|
|
3209
3239
|
}
|
|
3210
3240
|
const lines = modelSource.split("\n");
|
|
@@ -3252,7 +3282,8 @@ var CliApp = class {
|
|
|
3252
3282
|
return readdirSync$1(modelsDir).filter((file) => file.endsWith(".ts")).map((file) => join$1(modelsDir, file));
|
|
3253
3283
|
}
|
|
3254
3284
|
syncModelRegistryTypes(modelFiles) {
|
|
3255
|
-
const
|
|
3285
|
+
const cwd = realpathSync(process.cwd());
|
|
3286
|
+
const registryDir = join$1(cwd, ".arkormx");
|
|
3256
3287
|
const registryPath = join$1(registryDir, "models.d.ts");
|
|
3257
3288
|
const models = modelFiles.map((filePath) => {
|
|
3258
3289
|
const parsed = this.parseModelSyncSource(readFileSync$1(filePath, "utf-8"));
|
|
@@ -3371,7 +3402,7 @@ var CliApp = class {
|
|
|
3371
3402
|
const models = [];
|
|
3372
3403
|
const enumDefinitions = this.parsePrismaEnums(schema);
|
|
3373
3404
|
const modelRegex = /model\s+(\w+)\s*\{([\s\S]*?)\n\}/g;
|
|
3374
|
-
const scalarTypes = new Set([
|
|
3405
|
+
const scalarTypes = /* @__PURE__ */ new Set([
|
|
3375
3406
|
"Int",
|
|
3376
3407
|
"Float",
|
|
3377
3408
|
"Decimal",
|
|
@@ -4054,12 +4085,15 @@ var MigrateCommand = class extends Command {
|
|
|
4054
4085
|
}
|
|
4055
4086
|
if (!useDatabaseMigrations && !this.option("skip-generate")) runPrismaCommand(["generate"], process.cwd());
|
|
4056
4087
|
if (!useDatabaseMigrations && !this.option("skip-migrate")) if (this.option("deploy")) runPrismaCommand(["migrate", "deploy"], process.cwd());
|
|
4057
|
-
else
|
|
4058
|
-
"
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4088
|
+
else {
|
|
4089
|
+
const name = this.option("migration-name") ? String(this.option("migration-name")) : `arkorm_cli_${Date.now()}`;
|
|
4090
|
+
runPrismaCommand([
|
|
4091
|
+
"migrate",
|
|
4092
|
+
"dev",
|
|
4093
|
+
"--name",
|
|
4094
|
+
name
|
|
4095
|
+
], process.cwd());
|
|
4096
|
+
}
|
|
4063
4097
|
this.success(`Applied ${pending.length} migration(s).`);
|
|
4064
4098
|
pending.forEach(([_, file]) => this.success(this.app.splitLogger("Migrated", file)));
|
|
4065
4099
|
this.syncModelRegistryIfRequested();
|
|
@@ -4216,7 +4250,8 @@ var MigrateFreshCommand = class extends Command {
|
|
|
4216
4250
|
if (!(await this.runWithDatabaseCreationRetry(adapter, () => adapter.resetDatabase())).ok) return;
|
|
4217
4251
|
} else {
|
|
4218
4252
|
if (!existsSync(schemaPath)) return void this.error(`Error: Prisma schema file not found: ${this.app.formatPathForLog(schemaPath)}`);
|
|
4219
|
-
|
|
4253
|
+
const source = readFileSync(schemaPath, "utf-8");
|
|
4254
|
+
writeFileSync(schemaPath, stripPrismaSchemaModelsAndEnums(source));
|
|
4220
4255
|
}
|
|
4221
4256
|
let appliedState = createEmptyAppliedMigrationsState();
|
|
4222
4257
|
if (!(await this.runWithDatabaseCreationRetry(adapter, () => writeAppliedMigrationsStateToStore(adapter, stateFilePath, appliedState))).ok) return;
|
|
@@ -4401,12 +4436,15 @@ var MigrateRollbackCommand = class extends Command {
|
|
|
4401
4436
|
}
|
|
4402
4437
|
if (!useDatabaseMigrations && !this.option("skip-generate")) runPrismaCommand(["generate"], process.cwd());
|
|
4403
4438
|
if (!useDatabaseMigrations && !this.option("skip-migrate")) if (this.option("deploy")) runPrismaCommand(["migrate", "deploy"], process.cwd());
|
|
4404
|
-
else
|
|
4405
|
-
"
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4439
|
+
else {
|
|
4440
|
+
const name = this.option("migration-name") ? String(this.option("migration-name")) : `arkorm_cli_rollback_${Date.now()}`;
|
|
4441
|
+
runPrismaCommand([
|
|
4442
|
+
"migrate",
|
|
4443
|
+
"dev",
|
|
4444
|
+
"--name",
|
|
4445
|
+
name
|
|
4446
|
+
], process.cwd());
|
|
4447
|
+
}
|
|
4410
4448
|
this.success(`Rolled back ${rollbackClasses.length} migration(s).`);
|
|
4411
4449
|
rollbackClasses.forEach(([_, file]) => this.success(this.app.splitLogger("RolledBack", file)));
|
|
4412
4450
|
}
|
|
@@ -5016,7 +5054,7 @@ var QueryBuilder = class QueryBuilder {
|
|
|
5016
5054
|
* condition and appends it.
|
|
5017
5055
|
*/
|
|
5018
5056
|
addPositionalWhere(boolean, column, argCount, operatorOrValue, value) {
|
|
5019
|
-
const unaryOperators = new Set(["is-null", "is-not-null"]);
|
|
5057
|
+
const unaryOperators = /* @__PURE__ */ new Set(["is-null", "is-not-null"]);
|
|
5020
5058
|
let operator;
|
|
5021
5059
|
let resolvedValue;
|
|
5022
5060
|
if (argCount >= 3) {
|
|
@@ -7113,7 +7151,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7113
7151
|
async pluck(column, key) {
|
|
7114
7152
|
const rows = await this.executeReadRows();
|
|
7115
7153
|
if (!key) return new ArkormCollection(rows.map((row) => row[column]));
|
|
7116
|
-
|
|
7154
|
+
const keyedValues = rows.sort((leftRow, rightRow) => String(leftRow[key]).localeCompare(String(rightRow[key]))).map((row) => row[column]);
|
|
7155
|
+
return new ArkormCollection(keyedValues);
|
|
7117
7156
|
}
|
|
7118
7157
|
/**
|
|
7119
7158
|
* Creates a new record with the specified data and returns it as a model instance.
|
|
@@ -7615,11 +7654,13 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7615
7654
|
const pageSize = Math.max(1, perPage);
|
|
7616
7655
|
const rows = (await this.get()).all();
|
|
7617
7656
|
const start = (currentPage - 1) * pageSize;
|
|
7618
|
-
|
|
7657
|
+
const slice = new ArkormCollection(rows.slice(start, start + pageSize));
|
|
7658
|
+
return new LengthAwarePaginator(slice, rows.length, pageSize, currentPage, options);
|
|
7619
7659
|
}
|
|
7620
7660
|
const pageSize = Math.max(1, perPage);
|
|
7621
7661
|
const total = await this.count();
|
|
7622
|
-
|
|
7662
|
+
const items = await this.clone().skip((currentPage - 1) * pageSize).take(pageSize).get();
|
|
7663
|
+
return new LengthAwarePaginator(items, total, pageSize, currentPage, options);
|
|
7623
7664
|
}
|
|
7624
7665
|
/**
|
|
7625
7666
|
* Paginates results without calculating total row count.
|
|
@@ -7641,7 +7682,8 @@ var QueryBuilder = class QueryBuilder {
|
|
|
7641
7682
|
const pageSize = Math.max(1, perPage);
|
|
7642
7683
|
const items = await this.clone().skip((currentPage - 1) * pageSize).take(pageSize + 1).get();
|
|
7643
7684
|
const hasMorePages = items.all().length > pageSize;
|
|
7644
|
-
|
|
7685
|
+
const data = hasMorePages ? new ArkormCollection(items.all().slice(0, pageSize)) : items;
|
|
7686
|
+
return new Paginator(data, pageSize, currentPage, hasMorePages, options);
|
|
7645
7687
|
}
|
|
7646
7688
|
/**
|
|
7647
7689
|
* Creates a clone of the current query builder instance with the same state.
|
|
@@ -8366,7 +8408,7 @@ var QueryBuilder = class QueryBuilder {
|
|
|
8366
8408
|
const adapter = this.requireAdapter();
|
|
8367
8409
|
const payloads = this.normalizeInsertPayloads(values);
|
|
8368
8410
|
const timestampUpdateColumns = (this.model.getModelMetadata().timestampColumns ?? []).filter((column) => column.updatedAt).map((column) => column.column);
|
|
8369
|
-
const normalizedUpdateColumns = updateColumns ? Array.from(new Set([...updateColumns, ...timestampUpdateColumns])) : updateColumns;
|
|
8411
|
+
const normalizedUpdateColumns = updateColumns ? Array.from(/* @__PURE__ */ new Set([...updateColumns, ...timestampUpdateColumns])) : updateColumns;
|
|
8370
8412
|
if (typeof adapter.upsert !== "function") throw new UnsupportedAdapterFeatureException("Upsert is not supported by the current adapter.", {
|
|
8371
8413
|
operation: "query.upsert",
|
|
8372
8414
|
model: this.model.name
|
|
@@ -9260,12 +9302,13 @@ var Model = class Model {
|
|
|
9260
9302
|
Model.emitDeprecationWarning("ARKORM_GET_DELEGATE_DEPRECATED", "Model.getDelegate() is deprecated and will be removed in Arkorm 3.0. Use Model.getAdapter() and adapter-backed execution instead.");
|
|
9261
9303
|
ensureArkormConfigLoading();
|
|
9262
9304
|
const key = delegate || this.delegate || this.getTable();
|
|
9263
|
-
|
|
9305
|
+
const candidates = [
|
|
9264
9306
|
key,
|
|
9265
9307
|
`${str(key).camel()}`,
|
|
9266
9308
|
`${str(key).singular()}`,
|
|
9267
9309
|
`${str(key).camel().singular()}`
|
|
9268
|
-
]
|
|
9310
|
+
];
|
|
9311
|
+
return resolveRuntimeCompatibilityQuerySchemaOrThrow(key, candidates, this.name, this.client);
|
|
9269
9312
|
}
|
|
9270
9313
|
static getAdapter() {
|
|
9271
9314
|
ensureArkormConfigLoading();
|
|
@@ -10003,7 +10046,7 @@ var Model = class Model {
|
|
|
10003
10046
|
*/
|
|
10004
10047
|
getDirtyAttributes(keys) {
|
|
10005
10048
|
const requestedKeys = this.normalizeAttributeKeys(keys);
|
|
10006
|
-
return (requestedKeys.length > 0 ? requestedKeys : Array.from(new Set([...Object.keys(this.original), ...this.touchedAttributes]))).reduce((dirty, key) => {
|
|
10049
|
+
return (requestedKeys.length > 0 ? requestedKeys : Array.from(/* @__PURE__ */ new Set([...Object.keys(this.original), ...this.touchedAttributes]))).reduce((dirty, key) => {
|
|
10007
10050
|
const currentValue = this.attributes[key];
|
|
10008
10051
|
const originalValue = this.original[key];
|
|
10009
10052
|
const hasCurrent = Object.prototype.hasOwnProperty.call(this.attributes, key);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_relationship = require('../relationship-
|
|
2
|
+
const require_relationship = require('../relationship-D7MhPUIX.cjs');
|
|
3
3
|
|
|
4
4
|
exports.BelongsToManyRelation = require_relationship.BelongsToManyRelation;
|
|
5
5
|
exports.BelongsToRelation = require_relationship.BelongsToRelation;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Cs as Relation, Ss as BelongsToManyRelation, _s as HasOneRelation, bs as BelongsToRelation, ds as MorphToRelation, fs as MorphedByManyRelation, gs as HasOneThroughRelation, hs as MorphManyRelation, ms as MorphOneRelation, ps as MorphToManyRelation, us as SetBasedEagerLoader, vs as HasManyThroughRelation, ws as RelationTableLoader, xs as SingleResultRelation, ys as HasManyRelation } from "../index-
|
|
1
|
+
import { Cs as Relation, Ss as BelongsToManyRelation, _s as HasOneRelation, bs as BelongsToRelation, ds as MorphToRelation, fs as MorphedByManyRelation, gs as HasOneThroughRelation, hs as MorphManyRelation, ms as MorphOneRelation, ps as MorphToManyRelation, us as SetBasedEagerLoader, vs as HasManyThroughRelation, ws as RelationTableLoader, xs as SingleResultRelation, ys as HasManyRelation } from "../index-Lxl6NdHS.cjs";
|
|
2
2
|
export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, MorphedByManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Cs as Relation, Ss as BelongsToManyRelation, _s as HasOneRelation, bs as BelongsToRelation, ds as MorphToRelation, fs as MorphedByManyRelation, gs as HasOneThroughRelation, hs as MorphManyRelation, ms as MorphOneRelation, ps as MorphToManyRelation, us as SetBasedEagerLoader, vs as HasManyThroughRelation, ws as RelationTableLoader, xs as SingleResultRelation, ys as HasManyRelation } from "../index-
|
|
1
|
+
import { Cs as Relation, Ss as BelongsToManyRelation, _s as HasOneRelation, bs as BelongsToRelation, ds as MorphToRelation, fs as MorphedByManyRelation, gs as HasOneThroughRelation, hs as MorphManyRelation, ms as MorphOneRelation, ps as MorphToManyRelation, us as SetBasedEagerLoader, vs as HasManyThroughRelation, ws as RelationTableLoader, xs as SingleResultRelation, ys as HasManyRelation } from "../index-O3-Mi7hj.mjs";
|
|
2
2
|
export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, MorphedByManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as SetBasedEagerLoader, a as MorphManyRelation, c as HasManyThroughRelation, d as SingleResultRelation, f as BelongsToManyRelation, i as MorphOneRelation, l as HasManyRelation, n as MorphedByManyRelation, o as HasOneThroughRelation, p as Relation, r as MorphToManyRelation, s as HasOneRelation, t as MorphToRelation, u as BelongsToRelation, v as RelationTableLoader } from "../relationship-
|
|
1
|
+
import { _ as SetBasedEagerLoader, a as MorphManyRelation, c as HasManyThroughRelation, d as SingleResultRelation, f as BelongsToManyRelation, i as MorphOneRelation, l as HasManyRelation, n as MorphedByManyRelation, o as HasOneThroughRelation, p as Relation, r as MorphToManyRelation, s as HasOneRelation, t as MorphToRelation, u as BelongsToRelation, v as RelationTableLoader } from "../relationship-DZ4WJ0Si.mjs";
|
|
2
2
|
|
|
3
3
|
export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, MorphedByManyRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
|