arkormx 2.11.0 → 2.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +257 -44
- package/dist/{index-DggXDBiD.d.cts → index-KPekH7gI.d.mts} +155 -3
- package/dist/{index-DoqUdah-.d.mts → index-WJEmy3Yu.d.cts} +155 -3
- package/dist/index.cjs +349 -49
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +347 -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-CP1xbMOa.mjs → relationship-4S2yHPIH.mjs} +67 -1
- package/dist/{relationship-IC-TAFyG.cjs → relationship-CQbj9Ahg.cjs} +78 -0
- package/package.json +5 -5
|
@@ -1008,6 +1008,49 @@ const getLatestAppliedMigrations = (state, steps) => {
|
|
|
1008
1008
|
return right.index - left.index;
|
|
1009
1009
|
}).slice(0, Math.max(0, steps)).map((entry) => entry.migration);
|
|
1010
1010
|
};
|
|
1011
|
+
/**
|
|
1012
|
+
* Groups the applied migrations into batches, oldest batch first, each batch
|
|
1013
|
+
* holding its migration ids in application order.
|
|
1014
|
+
*
|
|
1015
|
+
* A "batch" is one `migrate` run. When no runs were recorded (e.g. legacy state
|
|
1016
|
+
* written before run tracking), each applied migration is treated as its own
|
|
1017
|
+
* batch so `--step` still behaves predictably.
|
|
1018
|
+
*
|
|
1019
|
+
* @param state
|
|
1020
|
+
* @returns
|
|
1021
|
+
*/
|
|
1022
|
+
const resolveAppliedBatches = (state) => {
|
|
1023
|
+
const runs = state.runs ?? [];
|
|
1024
|
+
if (runs.length > 0) return runs.map((run, index) => ({
|
|
1025
|
+
run,
|
|
1026
|
+
index
|
|
1027
|
+
})).sort((left, right) => {
|
|
1028
|
+
const appliedAtOrder = left.run.appliedAt.localeCompare(right.run.appliedAt);
|
|
1029
|
+
if (appliedAtOrder !== 0) return appliedAtOrder;
|
|
1030
|
+
return left.index - right.index;
|
|
1031
|
+
}).map((entry) => entry.run.migrationIds);
|
|
1032
|
+
return state.migrations.map((migration) => [migration.id]);
|
|
1033
|
+
};
|
|
1034
|
+
/**
|
|
1035
|
+
* Resolves the migrations belonging to the most recent `batches` batches, ordered
|
|
1036
|
+
* for rollback — **reverse of the order they were applied** (most recent batch
|
|
1037
|
+
* first, and within each batch the migration that ran `up()` last runs `down()`
|
|
1038
|
+
* first), so a rollback exactly reverses how the migrations were applied.
|
|
1039
|
+
*
|
|
1040
|
+
* Defaults to a single batch (`migrate:rollback` with no `--step`); `--step=N`
|
|
1041
|
+
* rolls back the last N batches.
|
|
1042
|
+
*
|
|
1043
|
+
* @param state
|
|
1044
|
+
* @param batches
|
|
1045
|
+
* @returns
|
|
1046
|
+
*/
|
|
1047
|
+
const getLastBatchMigrations = (state, batches = 1) => {
|
|
1048
|
+
if (batches < 1) return [];
|
|
1049
|
+
const allBatches = resolveAppliedBatches(state);
|
|
1050
|
+
const selected = allBatches.slice(Math.max(0, allBatches.length - batches));
|
|
1051
|
+
const byId = new Map(state.migrations.map((migration) => [migration.id, migration]));
|
|
1052
|
+
return selected.reverse().flatMap((migrationIds) => [...migrationIds].reverse()).map((id) => byId.get(id)).filter((migration) => Boolean(migration));
|
|
1053
|
+
};
|
|
1011
1054
|
|
|
1012
1055
|
//#endregion
|
|
1013
1056
|
//#region src/database/ForeignKeyBuilder.ts
|
|
@@ -4064,6 +4107,29 @@ const getRuntimeAdapter = () => {
|
|
|
4064
4107
|
if (!runtimeConfigLoaded) loadRuntimeConfigSync();
|
|
4065
4108
|
return runtimeAdapter;
|
|
4066
4109
|
};
|
|
4110
|
+
/**
|
|
4111
|
+
* Releases the database resources held by the configured runtime — the adapter's
|
|
4112
|
+
* connection pool and/or the configured client. Intended for short-lived
|
|
4113
|
+
* processes (the CLI) so the Node event loop drains and the process exits
|
|
4114
|
+
* promptly instead of hanging on pool idle timeouts. Teardown failures are
|
|
4115
|
+
* swallowed because the process is shutting down anyway.
|
|
4116
|
+
*/
|
|
4117
|
+
const disposeArkormRuntime = async () => {
|
|
4118
|
+
let adapterDisposed = false;
|
|
4119
|
+
try {
|
|
4120
|
+
if (runtimeAdapter && typeof runtimeAdapter.dispose === "function") {
|
|
4121
|
+
await runtimeAdapter.dispose();
|
|
4122
|
+
adapterDisposed = true;
|
|
4123
|
+
}
|
|
4124
|
+
} catch {}
|
|
4125
|
+
const client = getRuntimeClient();
|
|
4126
|
+
if (!client) return;
|
|
4127
|
+
try {
|
|
4128
|
+
if (typeof client.$disconnect === "function") await client.$disconnect();
|
|
4129
|
+
else if (!adapterDisposed && typeof client.destroy === "function") await client.destroy();
|
|
4130
|
+
else if (!adapterDisposed && typeof client.end === "function") await client.end();
|
|
4131
|
+
} catch {}
|
|
4132
|
+
};
|
|
4067
4133
|
const getActiveTransactionClient = () => {
|
|
4068
4134
|
return transactionClientStorage.getStore();
|
|
4069
4135
|
};
|
|
@@ -6444,4 +6510,4 @@ var MorphToRelation = class extends Relation {
|
|
|
6444
6510
|
};
|
|
6445
6511
|
|
|
6446
6512
|
//#endregion
|
|
6447
|
-
export {
|
|
6513
|
+
export { resetRuntimeRegistryForTests as $, RuntimeModuleLoader as $n, resolveMigrationClassName as $t, getRuntimePaginationURLDriverFactory as A, val as An, buildIndexLine as At, getRegisteredMigrations as B, getLastBatchMigrations as Bn, deriveRelationAlias as Bt, getActiveTransactionAdapter as C, fn as Cn, applyMigrationRollbackToDatabase as Ct, getRuntimeClient as D, min as Dn, applyOperationsToPrismaSchema as Dt, getRuntimeAdapter as E, max as En, applyMigrationToPrismaSchema as Et, isTransactionCapableClient as F, buildMigrationRunId as Fn, buildRelationLine as Ft, loadMigrationsFrom as G, markMigrationRun as Gn, findModelBlock as Gt, getRegisteredPaths as H, getLatestAppliedMigrations as Hn, deriveSingularFieldName as Ht, loadArkormConfig as I, computeMigrationChecksum as In, buildUniqueConstraintLine as It, registerFactories as J, removeAppliedMigration as Jn, formatRelationAction as Jt, loadModelsFrom as K, readAppliedMigrationsState as Kn, formatDefaultValue as Kt, resetArkormRuntimeForTests as L, createEmptyAppliedMigrationsState as Ln, createMigrationTimestamp as Lt, getUserConfig as M, PrimaryKeyGenerationPlanner as Mn, buildMigrationSource as Mt, isDelegateLike as N, ForeignKeyBuilder as Nn, buildModelBlock as Nt, getRuntimeDebugHandler as O, raw as On, buildEnumBlock as Ot, isQuerySchemaLike as P, buildMigrationIdentity as Pn, buildPrimaryKeyLine as Pt, registerSeeders as Q, writeAppliedMigrationsStateToStore as Qn, resolveEnumName as Qt, runArkormTransaction as R, deleteAppliedMigrationsStateFromStore as Rn, deriveCollectionFieldName as Rt, ensureArkormConfigLoading as S, expressionBuilder as Sn, applyDropTableOperation as St, getDefaultStubsPath as T, json as Tn, applyMigrationToDatabase as Tt, getRegisteredSeeders as U, isMigrationApplied as Un, escapeRegex as Ut, getRegisteredModels as V, getLastMigrationRun as Vn, deriveRelationFieldName as Vt, loadFactoriesFrom as W, markMigrationApplied as Wn, findEnumBlock as Wt, registerModels as X, supportsDatabaseMigrationState as Xn, getMigrationPlan as Xt, registerMigrations as Y, resolveMigrationStateFilePath as Yn, generateMigrationFile as Yt, registerPaths as Z, writeAppliedMigrationsState as Zn, pad as Zt, bindAdapterToModels as _, avg as _n, PRISMA_ENUM_MEMBER_REGEX as _t, HasOneThroughRelation as a, supportsDatabaseMigrationExecution as an, ArkormException as ar, getPersistedEnumTsType as at, disposeArkormRuntime as b, col as bn, applyAlterTableOperation as bt, HasManyRelation as c, toModelName as cn, getPersistedTimestampColumns as ct, BelongsToManyRelation as d, TableBuilder as dn, resetPersistedColumnMappingsCache as dt, resolvePrismaType as en, UnsupportedAdapterFeatureException as er, applyOperationsToPersistedColumnMappingsState as et, Relation as f, resolveGeneratedExpression as fn, resolveColumnMappingsFilePath as ft, awaitConfiguredModelsRegistration as g, JsonExpression as gn, writePersistedColumnMappingsState as gt, URLDriver as h, Expression as hn, validatePersistedMetadataFeaturesForMigrations as ht, MorphManyRelation as i, supportsDatabaseCreation as in, ArkormCollection as ir, getPersistedEnumMap as it, getRuntimePrismaClient as j, where as jn, buildInverseRelationLine as jt, getRuntimePaginationCurrentPageResolver as k, sum as kn, buildFieldLine as kt, BelongsToRelation as l, SchemaBuilder as ln, readPersistedColumnMappingsState as lt, Paginator as m, CaseExpression as mn, syncPersistedColumnMappingsFromState as mt, MorphToManyRelation as n, runPrismaCommand as nn, RelationTableLoader as nr, deletePersistedColumnMappingsState as nt, HasOneRelation as o, supportsDatabaseReset as on, getPersistedPrimaryKeyGeneration as ot, LengthAwarePaginator as p, AggregateExpression as pn, resolvePersistedMetadataFeatures as pt, loadSeedersFrom as q, readAppliedMigrationsStateFromStore as qn, formatEnumDefaultValue as qt, MorphOneRelation as r, stripPrismaSchemaModelsAndEnums as rn, RelationResolutionException as rr, getPersistedColumnMap as rt, HasManyThroughRelation as s, toMigrationFileSlug as sn, getPersistedTableMetadata as st, MorphToRelation as t, runMigrationWithPrisma as tn, SetBasedEagerLoader as tr, createEmptyPersistedColumnMappingsState as tt, SingleResultRelation as u, EnumBuilder as un, rebuildPersistedColumnMappingsState as ut, configureArkormRuntime as v, caseWhen as vn, PRISMA_ENUM_REGEX as vt, getActiveTransactionClient as w, fromExpressionNode as wn, applyMigrationRollbackToPrismaSchema as wt, emitRuntimeDebugEvent as x, count as xn, applyCreateTableOperation as xt, defineConfig as y, coalesce as yn, PRISMA_MODEL_REGEX as yt, getRegisteredFactories as z, findAppliedMigration as zn, deriveInverseRelationAlias as zt };
|
|
@@ -1036,6 +1036,49 @@ const getLatestAppliedMigrations = (state, steps) => {
|
|
|
1036
1036
|
return right.index - left.index;
|
|
1037
1037
|
}).slice(0, Math.max(0, steps)).map((entry) => entry.migration);
|
|
1038
1038
|
};
|
|
1039
|
+
/**
|
|
1040
|
+
* Groups the applied migrations into batches, oldest batch first, each batch
|
|
1041
|
+
* holding its migration ids in application order.
|
|
1042
|
+
*
|
|
1043
|
+
* A "batch" is one `migrate` run. When no runs were recorded (e.g. legacy state
|
|
1044
|
+
* written before run tracking), each applied migration is treated as its own
|
|
1045
|
+
* batch so `--step` still behaves predictably.
|
|
1046
|
+
*
|
|
1047
|
+
* @param state
|
|
1048
|
+
* @returns
|
|
1049
|
+
*/
|
|
1050
|
+
const resolveAppliedBatches = (state) => {
|
|
1051
|
+
const runs = state.runs ?? [];
|
|
1052
|
+
if (runs.length > 0) return runs.map((run, index) => ({
|
|
1053
|
+
run,
|
|
1054
|
+
index
|
|
1055
|
+
})).sort((left, right) => {
|
|
1056
|
+
const appliedAtOrder = left.run.appliedAt.localeCompare(right.run.appliedAt);
|
|
1057
|
+
if (appliedAtOrder !== 0) return appliedAtOrder;
|
|
1058
|
+
return left.index - right.index;
|
|
1059
|
+
}).map((entry) => entry.run.migrationIds);
|
|
1060
|
+
return state.migrations.map((migration) => [migration.id]);
|
|
1061
|
+
};
|
|
1062
|
+
/**
|
|
1063
|
+
* Resolves the migrations belonging to the most recent `batches` batches, ordered
|
|
1064
|
+
* for rollback — **reverse of the order they were applied** (most recent batch
|
|
1065
|
+
* first, and within each batch the migration that ran `up()` last runs `down()`
|
|
1066
|
+
* first), so a rollback exactly reverses how the migrations were applied.
|
|
1067
|
+
*
|
|
1068
|
+
* Defaults to a single batch (`migrate:rollback` with no `--step`); `--step=N`
|
|
1069
|
+
* rolls back the last N batches.
|
|
1070
|
+
*
|
|
1071
|
+
* @param state
|
|
1072
|
+
* @param batches
|
|
1073
|
+
* @returns
|
|
1074
|
+
*/
|
|
1075
|
+
const getLastBatchMigrations = (state, batches = 1) => {
|
|
1076
|
+
if (batches < 1) return [];
|
|
1077
|
+
const allBatches = resolveAppliedBatches(state);
|
|
1078
|
+
const selected = allBatches.slice(Math.max(0, allBatches.length - batches));
|
|
1079
|
+
const byId = new Map(state.migrations.map((migration) => [migration.id, migration]));
|
|
1080
|
+
return selected.reverse().flatMap((migrationIds) => [...migrationIds].reverse()).map((id) => byId.get(id)).filter((migration) => Boolean(migration));
|
|
1081
|
+
};
|
|
1039
1082
|
|
|
1040
1083
|
//#endregion
|
|
1041
1084
|
//#region src/database/ForeignKeyBuilder.ts
|
|
@@ -4092,6 +4135,29 @@ const getRuntimeAdapter = () => {
|
|
|
4092
4135
|
if (!runtimeConfigLoaded) loadRuntimeConfigSync();
|
|
4093
4136
|
return runtimeAdapter;
|
|
4094
4137
|
};
|
|
4138
|
+
/**
|
|
4139
|
+
* Releases the database resources held by the configured runtime — the adapter's
|
|
4140
|
+
* connection pool and/or the configured client. Intended for short-lived
|
|
4141
|
+
* processes (the CLI) so the Node event loop drains and the process exits
|
|
4142
|
+
* promptly instead of hanging on pool idle timeouts. Teardown failures are
|
|
4143
|
+
* swallowed because the process is shutting down anyway.
|
|
4144
|
+
*/
|
|
4145
|
+
const disposeArkormRuntime = async () => {
|
|
4146
|
+
let adapterDisposed = false;
|
|
4147
|
+
try {
|
|
4148
|
+
if (runtimeAdapter && typeof runtimeAdapter.dispose === "function") {
|
|
4149
|
+
await runtimeAdapter.dispose();
|
|
4150
|
+
adapterDisposed = true;
|
|
4151
|
+
}
|
|
4152
|
+
} catch {}
|
|
4153
|
+
const client = getRuntimeClient();
|
|
4154
|
+
if (!client) return;
|
|
4155
|
+
try {
|
|
4156
|
+
if (typeof client.$disconnect === "function") await client.$disconnect();
|
|
4157
|
+
else if (!adapterDisposed && typeof client.destroy === "function") await client.destroy();
|
|
4158
|
+
else if (!adapterDisposed && typeof client.end === "function") await client.end();
|
|
4159
|
+
} catch {}
|
|
4160
|
+
};
|
|
4095
4161
|
const getActiveTransactionClient = () => {
|
|
4096
4162
|
return transactionClientStorage.getStore();
|
|
4097
4163
|
};
|
|
@@ -6922,6 +6988,12 @@ Object.defineProperty(exports, 'deriveSingularFieldName', {
|
|
|
6922
6988
|
return deriveSingularFieldName;
|
|
6923
6989
|
}
|
|
6924
6990
|
});
|
|
6991
|
+
Object.defineProperty(exports, 'disposeArkormRuntime', {
|
|
6992
|
+
enumerable: true,
|
|
6993
|
+
get: function () {
|
|
6994
|
+
return disposeArkormRuntime;
|
|
6995
|
+
}
|
|
6996
|
+
});
|
|
6925
6997
|
Object.defineProperty(exports, 'emitRuntimeDebugEvent', {
|
|
6926
6998
|
enumerable: true,
|
|
6927
6999
|
get: function () {
|
|
@@ -7018,6 +7090,12 @@ Object.defineProperty(exports, 'getDefaultStubsPath', {
|
|
|
7018
7090
|
return getDefaultStubsPath;
|
|
7019
7091
|
}
|
|
7020
7092
|
});
|
|
7093
|
+
Object.defineProperty(exports, 'getLastBatchMigrations', {
|
|
7094
|
+
enumerable: true,
|
|
7095
|
+
get: function () {
|
|
7096
|
+
return getLastBatchMigrations;
|
|
7097
|
+
}
|
|
7098
|
+
});
|
|
7021
7099
|
Object.defineProperty(exports, 'getLastMigrationRun', {
|
|
7022
7100
|
enumerable: true,
|
|
7023
7101
|
get: function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkormx",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.2",
|
|
4
4
|
"description": "Modern TypeScript-first ORM for Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -81,10 +81,10 @@
|
|
|
81
81
|
"node": ">=20.0.0"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@h3ravel/collect.js": "^5.
|
|
85
|
-
"@h3ravel/musket": "^2.
|
|
86
|
-
"@h3ravel/shared": "^2.1
|
|
87
|
-
"@h3ravel/support": "^2.1
|
|
84
|
+
"@h3ravel/collect.js": "^5.4.0",
|
|
85
|
+
"@h3ravel/musket": "^2.2.2",
|
|
86
|
+
"@h3ravel/shared": "^2.2.1",
|
|
87
|
+
"@h3ravel/support": "^2.2.1",
|
|
88
88
|
"dotenv": "^17.3.1",
|
|
89
89
|
"jiti": "^2.7.0",
|
|
90
90
|
"kysely": "^0.28.15",
|