arkormx 2.11.1 → 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-43R9yWVX.d.mts → index-KPekH7gI.d.mts} +67 -1
- package/dist/{index-DLNIbeRi.d.cts → index-WJEmy3Yu.d.cts} +67 -1
- package/dist/index.cjs +182 -49
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +180 -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 +2 -2
|
@@ -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",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@h3ravel/collect.js": "^5.4.0",
|
|
85
|
-
"@h3ravel/musket": "^2.2.
|
|
85
|
+
"@h3ravel/musket": "^2.2.2",
|
|
86
86
|
"@h3ravel/shared": "^2.2.1",
|
|
87
87
|
"@h3ravel/support": "^2.2.1",
|
|
88
88
|
"dotenv": "^17.3.1",
|