@oliasoft-open-source/node-json-migrator 5.4.0-beta-1 → 5.4.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.d.mts +1 -8
- package/dist/index.mjs +10 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -100,7 +100,6 @@ declare const getPlannedMigrations: ({
|
|
|
100
100
|
}[];
|
|
101
101
|
nextVersion: string;
|
|
102
102
|
}>;
|
|
103
|
-
type TPreparedPlan = Awaited<ReturnType<typeof getPlannedMigrations>>;
|
|
104
103
|
//#endregion
|
|
105
104
|
//#region src/plan/planned-version.d.ts
|
|
106
105
|
declare const getPlannedVersion: ({
|
|
@@ -112,21 +111,15 @@ declare const getPlannedVersion: ({
|
|
|
112
111
|
//#region src/migrate/migrate.d.ts
|
|
113
112
|
/**
|
|
114
113
|
* Migrates a payload
|
|
115
|
-
*
|
|
116
|
-
* There are two ways to use this function:
|
|
117
|
-
* i) function looks up the pending migrations for you (default)
|
|
118
|
-
* ii) reuse a prepared plan while resolving pending migrations for the current payload version
|
|
119
114
|
*/
|
|
120
115
|
declare const migrate: ({
|
|
121
116
|
payload,
|
|
122
117
|
config,
|
|
123
|
-
metaData
|
|
124
|
-
preparedPlan
|
|
118
|
+
metaData
|
|
125
119
|
}: {
|
|
126
120
|
payload: TPayload;
|
|
127
121
|
config: TConfig;
|
|
128
122
|
metaData?: TMetaData;
|
|
129
|
-
preparedPlan?: TPreparedPlan;
|
|
130
123
|
}) => Promise<{
|
|
131
124
|
nextPayload: TPayload;
|
|
132
125
|
nextVersion: string;
|
package/dist/index.mjs
CHANGED
|
@@ -4767,12 +4767,15 @@ const getPendingMigrators = async ({ config, preparedPlan }) => {
|
|
|
4767
4767
|
//#region src/migrate/migrate.ts
|
|
4768
4768
|
/**
|
|
4769
4769
|
* Migrates a payload
|
|
4770
|
-
*
|
|
4771
|
-
* There are two ways to use this function:
|
|
4772
|
-
* i) function looks up the pending migrations for you (default)
|
|
4773
|
-
* ii) reuse a prepared plan while resolving pending migrations for the current payload version
|
|
4774
4770
|
*/
|
|
4775
|
-
const migrate = async ({ payload, config, metaData
|
|
4771
|
+
const migrate = async ({ payload, config, metaData }) => {
|
|
4772
|
+
return migrateWithPlan({
|
|
4773
|
+
payload,
|
|
4774
|
+
config,
|
|
4775
|
+
metaData
|
|
4776
|
+
});
|
|
4777
|
+
};
|
|
4778
|
+
const migrateWithPlan = async ({ payload, config, metaData, preparedPlan }) => {
|
|
4776
4779
|
const { pendingMigrators, nextVersion } = await getPendingMigrators({
|
|
4777
4780
|
config,
|
|
4778
4781
|
preparedPlan
|
|
@@ -4800,7 +4803,7 @@ const migrateRecord = async ({ record, config, preparedPlan, beforeMigrateRecord
|
|
|
4800
4803
|
transaction,
|
|
4801
4804
|
dry
|
|
4802
4805
|
});
|
|
4803
|
-
const { nextPayload: nextData, nextVersion } = await
|
|
4806
|
+
const { nextPayload: nextData, nextVersion } = await migrateWithPlan({
|
|
4804
4807
|
payload,
|
|
4805
4808
|
preparedPlan,
|
|
4806
4809
|
config: {
|
|
@@ -4872,7 +4875,7 @@ const migrateRecords = async ({ recordList, config, preparedPlan, beforeMigrateR
|
|
|
4872
4875
|
* Migrate all records (only use via command line interface)
|
|
4873
4876
|
*/
|
|
4874
4877
|
const migrateAll = async ({ config, beforeMigrateRecord, afterMigrateRecord, onMigrationErrors }) => {
|
|
4875
|
-
const preparedPlan = await getPlannedMigrations({ config });
|
|
4878
|
+
const preparedPlan = await PlanModule.getPlannedMigrations({ config });
|
|
4876
4879
|
const { validatedPlan: latestPlan, nextVersion: latestVersion } = preparedPlan;
|
|
4877
4880
|
await migrateRecords({
|
|
4878
4881
|
config,
|
package/package.json
CHANGED