@oliasoft-open-source/node-json-migrator 3.1.0-beta-2 → 3.1.0-beta-3
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.cjs +10 -9
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +10 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9027,7 +9027,7 @@ const getVersions = async (db, entity) => {
|
|
|
9027
9027
|
};
|
|
9028
9028
|
return db.any(query, params);
|
|
9029
9029
|
};
|
|
9030
|
-
const getRecordList = async (db, entity, entityColumnNames, latestVersion, latestVersionPlanLength) => {
|
|
9030
|
+
const getRecordList = async (db, entity, entityTableName, entityColumnNames, latestVersion, latestVersionPlanLength) => {
|
|
9031
9031
|
const query = `
|
|
9032
9032
|
SELECT
|
|
9033
9033
|
$(entityIdColumn:name) AS id,
|
|
@@ -9053,7 +9053,7 @@ const getRecordList = async (db, entity, entityColumnNames, latestVersion, lates
|
|
|
9053
9053
|
)
|
|
9054
9054
|
`;
|
|
9055
9055
|
const params = {
|
|
9056
|
-
entityTable:
|
|
9056
|
+
entityTable: entityTableName,
|
|
9057
9057
|
entityVersionsTable: `${entity}_versions`,
|
|
9058
9058
|
entityIdColumn: entityColumnNames.id,
|
|
9059
9059
|
entityCreatedColumn: entityColumnNames.created,
|
|
@@ -9062,20 +9062,20 @@ const getRecordList = async (db, entity, entityColumnNames, latestVersion, lates
|
|
|
9062
9062
|
};
|
|
9063
9063
|
return db.any(query, params);
|
|
9064
9064
|
};
|
|
9065
|
-
const getRecord = async (t,
|
|
9065
|
+
const getRecord = async (t, entityTableName, entityColumnNames, entityId) => {
|
|
9066
9066
|
const query = `
|
|
9067
9067
|
SELECT *
|
|
9068
9068
|
FROM $(entityTable:name)
|
|
9069
9069
|
WHERE $(entityIdColumn:name) = $(entityId)
|
|
9070
9070
|
`;
|
|
9071
9071
|
const params = {
|
|
9072
|
-
entityTable:
|
|
9072
|
+
entityTable: entityTableName,
|
|
9073
9073
|
entityId,
|
|
9074
9074
|
entityIdColumn: entityColumnNames.id
|
|
9075
9075
|
};
|
|
9076
9076
|
return t.one(query, params);
|
|
9077
9077
|
};
|
|
9078
|
-
const updateRecord = async (t,
|
|
9078
|
+
const updateRecord = async (t, entityTableName, entityColumnNames, entityId, currentVersion, nextData, nextVersion, etag) => {
|
|
9079
9079
|
const useEtag = typeof etag === "number";
|
|
9080
9080
|
const query = `
|
|
9081
9081
|
UPDATE $(entityTable:name)
|
|
@@ -9088,7 +9088,7 @@ const updateRecord = async (t, entity, entityColumnNames, entityId, currentVersi
|
|
|
9088
9088
|
RETURNING *
|
|
9089
9089
|
`;
|
|
9090
9090
|
const params = {
|
|
9091
|
-
entityTable:
|
|
9091
|
+
entityTable: entityTableName,
|
|
9092
9092
|
entityId,
|
|
9093
9093
|
entityIdColumn: entityColumnNames.id,
|
|
9094
9094
|
currentVersion,
|
|
@@ -9672,7 +9672,7 @@ const migrateRecord = async ({
|
|
|
9672
9672
|
await config.database.tx(async (transaction) => {
|
|
9673
9673
|
const currentRecord = await getRecord(
|
|
9674
9674
|
transaction,
|
|
9675
|
-
config.
|
|
9675
|
+
config.entityTableName,
|
|
9676
9676
|
config.entityColumnNames,
|
|
9677
9677
|
record.id
|
|
9678
9678
|
);
|
|
@@ -9692,8 +9692,8 @@ const migrateRecord = async ({
|
|
|
9692
9692
|
if (!dry) {
|
|
9693
9693
|
const nextRecord = await updateRecord(
|
|
9694
9694
|
transaction,
|
|
9695
|
-
config?.
|
|
9696
|
-
config
|
|
9695
|
+
config?.entityTableName,
|
|
9696
|
+
config?.entityColumnNames,
|
|
9697
9697
|
record.id,
|
|
9698
9698
|
currentVersion,
|
|
9699
9699
|
nextData,
|
|
@@ -9786,6 +9786,7 @@ const migrateAll = async ({
|
|
|
9786
9786
|
const recordList = await getRecordList(
|
|
9787
9787
|
config?.database,
|
|
9788
9788
|
config?.entity,
|
|
9789
|
+
config?.entityTableName,
|
|
9789
9790
|
config?.entityColumnNames,
|
|
9790
9791
|
latestVersion,
|
|
9791
9792
|
latestVersionPlanLength
|
package/dist/index.d.cts
CHANGED
|
@@ -34,8 +34,8 @@ type TConfig = {
|
|
|
34
34
|
database?: IDatabase<unknown>;
|
|
35
35
|
pgpHelpers?: IHelpers;
|
|
36
36
|
entity?: string;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
entityTableName?: string;
|
|
38
|
+
entityColumnNames?: TEntityColumnNames;
|
|
39
39
|
version?: string;
|
|
40
40
|
printPendingFileNames?: boolean;
|
|
41
41
|
force?: boolean;
|
package/dist/index.d.mts
CHANGED
|
@@ -34,8 +34,8 @@ type TConfig = {
|
|
|
34
34
|
database?: IDatabase<unknown>;
|
|
35
35
|
pgpHelpers?: IHelpers;
|
|
36
36
|
entity?: string;
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
entityTableName?: string;
|
|
38
|
+
entityColumnNames?: TEntityColumnNames;
|
|
39
39
|
version?: string;
|
|
40
40
|
printPendingFileNames?: boolean;
|
|
41
41
|
force?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -9006,7 +9006,7 @@ const getVersions = async (db, entity) => {
|
|
|
9006
9006
|
};
|
|
9007
9007
|
return db.any(query, params);
|
|
9008
9008
|
};
|
|
9009
|
-
const getRecordList = async (db, entity, entityColumnNames, latestVersion, latestVersionPlanLength) => {
|
|
9009
|
+
const getRecordList = async (db, entity, entityTableName, entityColumnNames, latestVersion, latestVersionPlanLength) => {
|
|
9010
9010
|
const query = `
|
|
9011
9011
|
SELECT
|
|
9012
9012
|
$(entityIdColumn:name) AS id,
|
|
@@ -9032,7 +9032,7 @@ const getRecordList = async (db, entity, entityColumnNames, latestVersion, lates
|
|
|
9032
9032
|
)
|
|
9033
9033
|
`;
|
|
9034
9034
|
const params = {
|
|
9035
|
-
entityTable:
|
|
9035
|
+
entityTable: entityTableName,
|
|
9036
9036
|
entityVersionsTable: `${entity}_versions`,
|
|
9037
9037
|
entityIdColumn: entityColumnNames.id,
|
|
9038
9038
|
entityCreatedColumn: entityColumnNames.created,
|
|
@@ -9041,20 +9041,20 @@ const getRecordList = async (db, entity, entityColumnNames, latestVersion, lates
|
|
|
9041
9041
|
};
|
|
9042
9042
|
return db.any(query, params);
|
|
9043
9043
|
};
|
|
9044
|
-
const getRecord = async (t,
|
|
9044
|
+
const getRecord = async (t, entityTableName, entityColumnNames, entityId) => {
|
|
9045
9045
|
const query = `
|
|
9046
9046
|
SELECT *
|
|
9047
9047
|
FROM $(entityTable:name)
|
|
9048
9048
|
WHERE $(entityIdColumn:name) = $(entityId)
|
|
9049
9049
|
`;
|
|
9050
9050
|
const params = {
|
|
9051
|
-
entityTable:
|
|
9051
|
+
entityTable: entityTableName,
|
|
9052
9052
|
entityId,
|
|
9053
9053
|
entityIdColumn: entityColumnNames.id
|
|
9054
9054
|
};
|
|
9055
9055
|
return t.one(query, params);
|
|
9056
9056
|
};
|
|
9057
|
-
const updateRecord = async (t,
|
|
9057
|
+
const updateRecord = async (t, entityTableName, entityColumnNames, entityId, currentVersion, nextData, nextVersion, etag) => {
|
|
9058
9058
|
const useEtag = typeof etag === "number";
|
|
9059
9059
|
const query = `
|
|
9060
9060
|
UPDATE $(entityTable:name)
|
|
@@ -9067,7 +9067,7 @@ const updateRecord = async (t, entity, entityColumnNames, entityId, currentVersi
|
|
|
9067
9067
|
RETURNING *
|
|
9068
9068
|
`;
|
|
9069
9069
|
const params = {
|
|
9070
|
-
entityTable:
|
|
9070
|
+
entityTable: entityTableName,
|
|
9071
9071
|
entityId,
|
|
9072
9072
|
entityIdColumn: entityColumnNames.id,
|
|
9073
9073
|
currentVersion,
|
|
@@ -9651,7 +9651,7 @@ const migrateRecord = async ({
|
|
|
9651
9651
|
await config.database.tx(async (transaction) => {
|
|
9652
9652
|
const currentRecord = await getRecord(
|
|
9653
9653
|
transaction,
|
|
9654
|
-
config.
|
|
9654
|
+
config.entityTableName,
|
|
9655
9655
|
config.entityColumnNames,
|
|
9656
9656
|
record.id
|
|
9657
9657
|
);
|
|
@@ -9671,8 +9671,8 @@ const migrateRecord = async ({
|
|
|
9671
9671
|
if (!dry) {
|
|
9672
9672
|
const nextRecord = await updateRecord(
|
|
9673
9673
|
transaction,
|
|
9674
|
-
config?.
|
|
9675
|
-
config
|
|
9674
|
+
config?.entityTableName,
|
|
9675
|
+
config?.entityColumnNames,
|
|
9676
9676
|
record.id,
|
|
9677
9677
|
currentVersion,
|
|
9678
9678
|
nextData,
|
|
@@ -9765,6 +9765,7 @@ const migrateAll = async ({
|
|
|
9765
9765
|
const recordList = await getRecordList(
|
|
9766
9766
|
config?.database,
|
|
9767
9767
|
config?.entity,
|
|
9768
|
+
config?.entityTableName,
|
|
9768
9769
|
config?.entityColumnNames,
|
|
9769
9770
|
latestVersion,
|
|
9770
9771
|
latestVersionPlanLength
|
package/package.json
CHANGED