@integromat/module-migrator-core 0.0.1
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/README.md +11 -0
- package/cjs/lib/blueprint-parser.d.ts +7 -0
- package/cjs/lib/blueprint-parser.js +60 -0
- package/cjs/lib/blueprint-parser.js.map +1 -0
- package/cjs/lib/domain/field-entry.d.ts +16 -0
- package/cjs/lib/domain/field-entry.js +36 -0
- package/cjs/lib/domain/field-entry.js.map +1 -0
- package/cjs/lib/domain/field-mapping.d.ts +32 -0
- package/cjs/lib/domain/field-mapping.js +104 -0
- package/cjs/lib/domain/field-mapping.js.map +1 -0
- package/cjs/lib/domain/migration.d.ts +12 -0
- package/cjs/lib/domain/migration.js +19 -0
- package/cjs/lib/domain/migration.js.map +1 -0
- package/cjs/lib/errors/migration-error.d.ts +37 -0
- package/cjs/lib/errors/migration-error.js +53 -0
- package/cjs/lib/errors/migration-error.js.map +1 -0
- package/cjs/lib/expression-parser.d.ts +26 -0
- package/cjs/lib/expression-parser.js +155 -0
- package/cjs/lib/expression-parser.js.map +1 -0
- package/cjs/lib/migrator.d.ts +16 -0
- package/cjs/lib/migrator.js +264 -0
- package/cjs/lib/migrator.js.map +1 -0
- package/cjs/lib/ports/config-repository.d.ts +19 -0
- package/cjs/lib/ports/migration-service.d.ts +28 -0
- package/cjs/lib/schemas.d.ts +246 -0
- package/cjs/lib/types.d.ts +322 -0
- package/cjs/lib/types.js +81 -0
- package/cjs/lib/types.js.map +1 -0
- package/cjs/lib/utils/path.d.ts +25 -0
- package/cjs/lib/utils/path.js +55 -0
- package/cjs/lib/utils/path.js.map +1 -0
- package/cjs/lib/utils/type-guards.d.ts +16 -0
- package/cjs/lib/utils/type-guards.js +22 -0
- package/cjs/lib/utils/type-guards.js.map +1 -0
- package/cjs/lib/validation.d.ts +17 -0
- package/cjs/lib/validation.js +55 -0
- package/cjs/lib/validation.js.map +1 -0
- package/cjs/main.d.ts +9 -0
- package/cjs/main.js +24 -0
- package/cjs/main.js.map +1 -0
- package/esm/lib/blueprint-parser.d.ts +7 -0
- package/esm/lib/blueprint-parser.js +54 -0
- package/esm/lib/blueprint-parser.js.map +1 -0
- package/esm/lib/domain/field-entry.d.ts +16 -0
- package/esm/lib/domain/field-entry.js +32 -0
- package/esm/lib/domain/field-entry.js.map +1 -0
- package/esm/lib/domain/field-mapping.d.ts +32 -0
- package/esm/lib/domain/field-mapping.js +100 -0
- package/esm/lib/domain/field-mapping.js.map +1 -0
- package/esm/lib/domain/migration.d.ts +12 -0
- package/esm/lib/domain/migration.js +17 -0
- package/esm/lib/domain/migration.js.map +1 -0
- package/esm/lib/errors/migration-error.d.ts +37 -0
- package/esm/lib/errors/migration-error.js +50 -0
- package/esm/lib/errors/migration-error.js.map +1 -0
- package/esm/lib/expression-parser.d.ts +26 -0
- package/esm/lib/expression-parser.js +151 -0
- package/esm/lib/expression-parser.js.map +1 -0
- package/esm/lib/migrator.d.ts +16 -0
- package/esm/lib/migrator.js +262 -0
- package/esm/lib/migrator.js.map +1 -0
- package/esm/lib/ports/config-repository.d.ts +19 -0
- package/esm/lib/ports/migration-service.d.ts +28 -0
- package/esm/lib/schemas.d.ts +246 -0
- package/esm/lib/types.d.ts +322 -0
- package/esm/lib/types.js +74 -0
- package/esm/lib/types.js.map +1 -0
- package/esm/lib/utils/path.d.ts +25 -0
- package/esm/lib/utils/path.js +52 -0
- package/esm/lib/utils/path.js.map +1 -0
- package/esm/lib/utils/type-guards.d.ts +16 -0
- package/esm/lib/utils/type-guards.js +20 -0
- package/esm/lib/utils/type-guards.js.map +1 -0
- package/esm/lib/validation.d.ts +17 -0
- package/esm/lib/validation.js +51 -0
- package/esm/lib/validation.js.map +1 -0
- package/esm/main.d.ts +9 -0
- package/esm/main.js +6 -0
- package/esm/main.js.map +1 -0
- package/esm/package.json +3 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# module-migrator-core
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build module-migrator-core` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test module-migrator-core` to execute the unit tests via [Jest](https://jestjs.io).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Blueprint, Bundle, DeprecatedModule, FlowModule } from './types.ts';
|
|
2
|
+
declare const parseBlueprint: (json: string) => Blueprint;
|
|
3
|
+
declare const collectAllModules: (blueprint: Blueprint) => FlowModule[];
|
|
4
|
+
declare const findDeprecatedModules: (blueprint: Blueprint, config: Bundle) => DeprecatedModule[];
|
|
5
|
+
declare const cloneBlueprint: (blueprint: Blueprint) => Blueprint;
|
|
6
|
+
declare const serializeBlueprint: (blueprint: Blueprint) => string;
|
|
7
|
+
export { cloneBlueprint, collectAllModules, findDeprecatedModules, parseBlueprint, serializeBlueprint, };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var migration = require('./domain/migration.js');
|
|
4
|
+
|
|
5
|
+
const parseBlueprint = (json) => {
|
|
6
|
+
const parsed = JSON.parse(json);
|
|
7
|
+
return parsed;
|
|
8
|
+
};
|
|
9
|
+
const collectAllModules = (blueprint) => {
|
|
10
|
+
const modules = [];
|
|
11
|
+
const traverse = (items) => {
|
|
12
|
+
for (const flowModule of items) {
|
|
13
|
+
modules.push(flowModule);
|
|
14
|
+
if (flowModule.routes) {
|
|
15
|
+
for (const route of flowModule.routes) {
|
|
16
|
+
if (route.flow) {
|
|
17
|
+
traverse(route.flow);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
if (blueprint.flow) {
|
|
24
|
+
traverse(blueprint.flow);
|
|
25
|
+
}
|
|
26
|
+
if (blueprint.metadata?.designer?.orphans) {
|
|
27
|
+
traverse(blueprint.metadata.designer.orphans);
|
|
28
|
+
}
|
|
29
|
+
return modules;
|
|
30
|
+
};
|
|
31
|
+
const findDeprecatedModules = (blueprint, config) => {
|
|
32
|
+
const allModules = collectAllModules(blueprint);
|
|
33
|
+
const deprecated = [];
|
|
34
|
+
for (const flowModule of allModules) {
|
|
35
|
+
const migration$1 = migration.findMigration(config, flowModule.module, flowModule.version);
|
|
36
|
+
if (migration$1) {
|
|
37
|
+
deprecated.push({
|
|
38
|
+
id: flowModule.id,
|
|
39
|
+
fromModule: flowModule.module,
|
|
40
|
+
toModule: migration$1.to.module,
|
|
41
|
+
toVersion: migration$1.to.version,
|
|
42
|
+
flowModule,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return deprecated;
|
|
47
|
+
};
|
|
48
|
+
const cloneBlueprint = (blueprint) => {
|
|
49
|
+
return structuredClone(blueprint);
|
|
50
|
+
};
|
|
51
|
+
const serializeBlueprint = (blueprint) => {
|
|
52
|
+
return JSON.stringify(blueprint, undefined, 2);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.cloneBlueprint = cloneBlueprint;
|
|
56
|
+
exports.collectAllModules = collectAllModules;
|
|
57
|
+
exports.findDeprecatedModules = findDeprecatedModules;
|
|
58
|
+
exports.parseBlueprint = parseBlueprint;
|
|
59
|
+
exports.serializeBlueprint = serializeBlueprint;
|
|
60
|
+
//# sourceMappingURL=blueprint-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blueprint-parser.js","sources":["../../src/lib/blueprint-parser.ts"],"sourcesContent":[null],"names":["migration","findMigration"],"mappings":";;;;AAGA,MAAM,cAAc,GAAG,CAAC,IAAY,KAAe;IAClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY;AAC1C,IAAA,OAAO,MAAmB;AAC3B;AAEA,MAAM,iBAAiB,GAAG,CAAC,SAAoB,KAAkB;IAChE,MAAM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U;AACV,aAAA,CAAC;QACH;IACD;AAEA,IAAA,OAAO,UAAU;AAClB;AAEA,MAAM,cAAc,GAAG,CAAC,SAAoB,KAAe;AAC1D,IAAA,OAAO,eAAe,CAAC,SAAS,CAAC;AAClC;AAEA,MAAM,kBAAkB,GAAG,CAAC,SAAoB,KAAY;IAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;AAC/C;;;;;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FieldEntry } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Get the target field name that a field maps to.
|
|
4
|
+
* Returns undefined if the field is removed, otherwise returns the mapped name or original name.
|
|
5
|
+
*/
|
|
6
|
+
declare const getFieldMapsTo: (entry: FieldEntry, fieldName: string) => string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Get the removal note for a field entry, if any.
|
|
9
|
+
* Only RemoveField entries can have notes.
|
|
10
|
+
*/
|
|
11
|
+
declare const getFieldNote: (entry: FieldEntry) => string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a field entry represents a removal.
|
|
14
|
+
*/
|
|
15
|
+
declare const isFieldRemoved: (entry: FieldEntry) => boolean;
|
|
16
|
+
export { getFieldMapsTo, getFieldNote, isFieldRemoved };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the target field name that a field maps to.
|
|
5
|
+
* Returns undefined if the field is removed, otherwise returns the mapped name or original name.
|
|
6
|
+
*/
|
|
7
|
+
const getFieldMapsTo = (entry, fieldName) => {
|
|
8
|
+
if (entry.op === 'remove') {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (entry.op === 'keep') {
|
|
12
|
+
return fieldName;
|
|
13
|
+
}
|
|
14
|
+
return entry.to ?? fieldName;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Get the removal note for a field entry, if any.
|
|
18
|
+
* Only RemoveField entries can have notes.
|
|
19
|
+
*/
|
|
20
|
+
const getFieldNote = (entry) => {
|
|
21
|
+
if (entry.op === 'remove') {
|
|
22
|
+
return entry.note;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Check if a field entry represents a removal.
|
|
28
|
+
*/
|
|
29
|
+
const isFieldRemoved = (entry) => {
|
|
30
|
+
return entry.op === 'remove';
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.getFieldMapsTo = getFieldMapsTo;
|
|
34
|
+
exports.getFieldNote = getFieldNote;
|
|
35
|
+
exports.isFieldRemoved = isFieldRemoved;
|
|
36
|
+
//# sourceMappingURL=field-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-entry.js","sources":["../../../src/lib/domain/field-entry.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;AAGG;AACH,MAAM,cAAc,GAAG,CAAC,KAAiB,EAAE,SAAiB,KAAwB;AACnF,IAAA,IAAI,KAAK,CAAC,EAAE,KAAK,QAAQ,EAAE;AAC1B,QAAA,OAAO,SAAS;IACjB;AACA,IAAA,IAAI,KAAK,CAAC,EAAE,KAAK,MAAM,EAAE;AACxB,QAAA,OAAO,SAAS;IACjB;AACA,IAAA,OAAO,KAAK,CAAC,EAAE,IAAI,SAAS;AAC7B;AAEA;;;AAGG;AACH,MAAM,YAAY,GAAG,CAAC,KAAiB,KAAwB;AAC9D,IAAA,IAAI,KAAK,CAAC,EAAE,KAAK,QAAQ,EAAE;QAC1B,OAAO,KAAK,CAAC,IAAI;IAClB;AACA,IAAA,OAAO,SAAS;AACjB;AAEA;;AAEG;AACH,MAAM,cAAc,GAAG,CAAC,KAAiB,KAAa;AACrD,IAAA,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ;AAC7B;;;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FieldMappings, FlatFieldEntry, ReportMessage } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Flattens nested field mappings into a flat array with full paths.
|
|
4
|
+
* Recursively processes nested fields and items.
|
|
5
|
+
*
|
|
6
|
+
* @param mappings - The field mappings to flatten
|
|
7
|
+
* @param prefix - Current path prefix for nested fields
|
|
8
|
+
* @returns Array of flattened field entries with full paths
|
|
9
|
+
*/
|
|
10
|
+
declare const flattenFieldMappings: (mappings: FieldMappings, prefix?: string) => FlatFieldEntry[];
|
|
11
|
+
/**
|
|
12
|
+
* Builds output field mappings from flattened entries.
|
|
13
|
+
* Creates a lookup map and set of known fields.
|
|
14
|
+
*
|
|
15
|
+
* @param outputs - The output field mappings
|
|
16
|
+
* @returns Object containing fieldMappings lookup and knownFields set
|
|
17
|
+
*/
|
|
18
|
+
declare const buildOutputMappings: (outputs: FieldMappings) => {
|
|
19
|
+
fieldMappings: Record<string, string | undefined>;
|
|
20
|
+
knownFields: Set<string>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Applies field mappings to a source object, returning a new transformed object.
|
|
24
|
+
* Does not mutate the source. Logs removed/renamed fields as messages.
|
|
25
|
+
*
|
|
26
|
+
* @param source - The source object to transform
|
|
27
|
+
* @param mappings - The field mappings to apply
|
|
28
|
+
* @param messages - Array to collect report messages
|
|
29
|
+
* @returns A new object with the mappings applied
|
|
30
|
+
*/
|
|
31
|
+
declare const applyFieldMappings: (source: Record<string, unknown>, mappings: FieldMappings, messages: ReportMessage[]) => Record<string, unknown>;
|
|
32
|
+
export { applyFieldMappings, buildOutputMappings, flattenFieldMappings };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fieldEntry = require('./field-entry.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Flattens nested field mappings into a flat array with full paths.
|
|
7
|
+
* Recursively processes nested fields and items.
|
|
8
|
+
*
|
|
9
|
+
* @param mappings - The field mappings to flatten
|
|
10
|
+
* @param prefix - Current path prefix for nested fields
|
|
11
|
+
* @returns Array of flattened field entries with full paths
|
|
12
|
+
*/
|
|
13
|
+
const flattenFieldMappings = (mappings, prefix = '') => {
|
|
14
|
+
const entries = [];
|
|
15
|
+
for (const [field, entry] of Object.entries(mappings)) {
|
|
16
|
+
const fullField = prefix ? `${prefix}.${field}` : field;
|
|
17
|
+
const localMapsTo = fieldEntry.getFieldMapsTo(entry, field);
|
|
18
|
+
const fullMapsTo = localMapsTo === undefined
|
|
19
|
+
? undefined
|
|
20
|
+
: prefix
|
|
21
|
+
? `${prefix}.${localMapsTo}`
|
|
22
|
+
: localMapsTo;
|
|
23
|
+
entries.push({
|
|
24
|
+
field: fullField,
|
|
25
|
+
mapsTo: fullMapsTo,
|
|
26
|
+
note: fieldEntry.getFieldNote(entry),
|
|
27
|
+
});
|
|
28
|
+
if (entry.op !== 'remove') {
|
|
29
|
+
const childPrefix = fullMapsTo ?? fullField;
|
|
30
|
+
if (entry.fields) {
|
|
31
|
+
entries.push(...flattenFieldMappings(entry.fields, childPrefix));
|
|
32
|
+
}
|
|
33
|
+
if (entry.items) {
|
|
34
|
+
entries.push(...flattenFieldMappings(entry.items, childPrefix));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return entries;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Builds output field mappings from flattened entries.
|
|
42
|
+
* Creates a lookup map and set of known fields.
|
|
43
|
+
*
|
|
44
|
+
* @param outputs - The output field mappings
|
|
45
|
+
* @returns Object containing fieldMappings lookup and knownFields set
|
|
46
|
+
*/
|
|
47
|
+
const buildOutputMappings = (outputs) => {
|
|
48
|
+
const flat = flattenFieldMappings(outputs);
|
|
49
|
+
const fieldMappings = {};
|
|
50
|
+
const knownFields = new Set();
|
|
51
|
+
for (const entry of flat) {
|
|
52
|
+
knownFields.add(entry.field);
|
|
53
|
+
fieldMappings[entry.field] = entry.mapsTo;
|
|
54
|
+
}
|
|
55
|
+
return { fieldMappings, knownFields };
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Applies field mappings to a source object, returning a new transformed object.
|
|
59
|
+
* Does not mutate the source. Logs removed/renamed fields as messages.
|
|
60
|
+
*
|
|
61
|
+
* @param source - The source object to transform
|
|
62
|
+
* @param mappings - The field mappings to apply
|
|
63
|
+
* @param messages - Array to collect report messages
|
|
64
|
+
* @returns A new object with the mappings applied
|
|
65
|
+
*/
|
|
66
|
+
const applyFieldMappings = (source, mappings, messages) => {
|
|
67
|
+
const result = {};
|
|
68
|
+
for (const [key, value] of Object.entries(source)) {
|
|
69
|
+
const entry = mappings[key];
|
|
70
|
+
if (!entry) {
|
|
71
|
+
result[key] = value;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const mapsTo = fieldEntry.getFieldMapsTo(entry, key);
|
|
75
|
+
if (mapsTo === undefined) {
|
|
76
|
+
messages.push({
|
|
77
|
+
type: 'warning',
|
|
78
|
+
category: 'input',
|
|
79
|
+
field: key,
|
|
80
|
+
message: `Input field '${key}' was removed`,
|
|
81
|
+
note: fieldEntry.getFieldNote(entry),
|
|
82
|
+
certain: true,
|
|
83
|
+
});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
result[mapsTo] = value;
|
|
87
|
+
if (mapsTo !== key) {
|
|
88
|
+
messages.push({
|
|
89
|
+
type: 'info',
|
|
90
|
+
category: 'input',
|
|
91
|
+
field: key,
|
|
92
|
+
message: `Input field '${key}' renamed to '${mapsTo}'`,
|
|
93
|
+
certain: true,
|
|
94
|
+
autoFixed: true,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
exports.applyFieldMappings = applyFieldMappings;
|
|
102
|
+
exports.buildOutputMappings = buildOutputMappings;
|
|
103
|
+
exports.flattenFieldMappings = flattenFieldMappings;
|
|
104
|
+
//# sourceMappingURL=field-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-mapping.js","sources":["../../../src/lib/domain/field-mapping.ts"],"sourcesContent":[null],"names":["getFieldMapsTo","getFieldNote"],"mappings":";;;;AAIA;;;;;;;AAOG;AACH,MAAM,oBAAoB,GAAG,CAAC,QAAuB,EAAE,MAAM,GAAG,EAAE,KAAsB;IACvF,MAAM,OAAO,GAAqB,EAAE;AAEpC,IAAA,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AACtD,QAAA,MAAM,SAAS,GAAG,MAAM,GAAG,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,GAAG,KAAK;QACvD,MAAM,WAAW,GAAGA,yBAAc,CAAC,KAAK,EAAE,KAAK,CAAC;AAChD,QAAA,MAAM,UAAU,GACf,WAAW,KAAK;AACf,cAAE;AACF,cAAE;AACD,kBAAE,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,WAAW,CAAA;kBACxB,WAAW;QAEhB,OAAO,CAAC,IAAI,CAAC;AACZ,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,MAAM,EAAE,UAAU;AAClB,YAAA,IAAI,EAAEC,uBAAY,CAAC,KAAK,CAAC;AACzB,SAAA,CAAC;AAEF,QAAA,IAAI,KAAK,CAAC,EAAE,KAAK,QAAQ,EAAE;AAC1B,YAAA,MAAM,WAAW,GAAG,UAAU,IAAI,SAAS;AAC3C,YAAA,IAAI,KAAK,CAAC,MAAM,EAAE;AACjB,gBAAA,OAAO,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACjE;AACA,YAAA,IAAI,KAAK,CAAC,KAAK,EAAE;AAChB,gBAAA,OAAO,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,C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AAI;AACb,aAAA,CAAC;YACF;QACD;AAEA,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK;AAEtB,QAAA,IAAI,MAAM,KAAK,GAAG,EAAE;YACnB,QAAQ,CAAC,IAAI,CAAC;AACb,gBAAA,IAAI,EAAE,MAAM;AACZ,gBAAA,QAAQ,EAAE,OAAO;AACjB,gBAAA,KAAK,EAAE,GAAG;AACV,gBAAA,OAAO,EAAE,CAAA,aAAA,EAAgB,GAAG,CAAA,cAAA,EAAiB,MAAM,CAAA,CAAA,CAAG;AACtD,gBAAA,OAAO,EAAE,IAAI;AACb,gBAAA,SAAS,EAAE,IAAI;AACf,aAAA,CAAC;QACH;IACD;AAEA,IAAA,OAAO,MAAM;AACd;;;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Bundle, MigrationConfigV1 } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Pure function to find a migration config for a module.
|
|
4
|
+
* Matches by module type and version.
|
|
5
|
+
*
|
|
6
|
+
* @param config - The bundle containing all migration configurations
|
|
7
|
+
* @param moduleType - The module type to find (e.g., "google-sheets:addRow")
|
|
8
|
+
* @param moduleVersion - The version number to match
|
|
9
|
+
* @returns The matching migration config, or undefined if not found
|
|
10
|
+
*/
|
|
11
|
+
declare const findMigration: (config: Bundle, moduleType: string, moduleVersion: number) => MigrationConfigV1 | undefined;
|
|
12
|
+
export { findMigration };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pure function to find a migration config for a module.
|
|
5
|
+
* Matches by module type and version.
|
|
6
|
+
*
|
|
7
|
+
* @param config - The bundle containing all migration configurations
|
|
8
|
+
* @param moduleType - The module type to find (e.g., "google-sheets:addRow")
|
|
9
|
+
* @param moduleVersion - The version number to match
|
|
10
|
+
* @returns The matching migration config, or undefined if not found
|
|
11
|
+
*/
|
|
12
|
+
const findMigration = (config, moduleType, moduleVersion) => {
|
|
13
|
+
return config.migrations.find((migration) => {
|
|
14
|
+
return migration.from.module === moduleType && migration.from.version === moduleVersion;
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.findMigration = findMigration;
|
|
19
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.js","sources":["../../../src/lib/domain/migration.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;AAQG;AACH,MAAM,aAAa,GAAG,CACrB,MAAc,EACd,UAAkB,EAClB,aAAqB,KACa;IAClC,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,KAAI;AAC3C,QAAA,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,KAAK,UAAU,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,KAAK,aAAa;AACxF,IAAA,CAAC,CAAC;AACH;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes for migration operations.
|
|
3
|
+
*/
|
|
4
|
+
declare const MigrationErrorCode: {
|
|
5
|
+
/** Blueprint validation failed */
|
|
6
|
+
readonly INVALID_BLUEPRINT: "INVALID_BLUEPRINT";
|
|
7
|
+
/** Bundle/migration config validation failed */
|
|
8
|
+
readonly INVALID_BUNDLE: "INVALID_BUNDLE";
|
|
9
|
+
/** Migration execution failed for a specific module */
|
|
10
|
+
readonly MIGRATION_FAILED: "MIGRATION_FAILED";
|
|
11
|
+
/** Field mapping operation failed */
|
|
12
|
+
readonly FIELD_MAPPING_FAILED: "FIELD_MAPPING_FAILED";
|
|
13
|
+
};
|
|
14
|
+
type MigrationErrorCode = (typeof MigrationErrorCode)[keyof typeof MigrationErrorCode];
|
|
15
|
+
/**
|
|
16
|
+
* Custom error class for migration operations.
|
|
17
|
+
* Provides structured error information including error code,
|
|
18
|
+
* optional module ID, and field context.
|
|
19
|
+
*/
|
|
20
|
+
declare class MigrationError extends Error {
|
|
21
|
+
/** Error code categorizing the type of failure */
|
|
22
|
+
readonly code: MigrationErrorCode;
|
|
23
|
+
/** Module ID where the error occurred, if applicable */
|
|
24
|
+
readonly moduleId?: number;
|
|
25
|
+
/** Field name where the error occurred, if applicable */
|
|
26
|
+
readonly field?: string;
|
|
27
|
+
constructor(code: MigrationErrorCode, message: string, options?: {
|
|
28
|
+
moduleId?: number;
|
|
29
|
+
field?: string;
|
|
30
|
+
cause?: unknown;
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Creates a formatted string representation of the error.
|
|
34
|
+
*/
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
|
37
|
+
export { MigrationError, MigrationErrorCode };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Error codes for migration operations.
|
|
5
|
+
*/
|
|
6
|
+
const MigrationErrorCode = {
|
|
7
|
+
/** Blueprint validation failed */
|
|
8
|
+
INVALID_BLUEPRINT: 'INVALID_BLUEPRINT',
|
|
9
|
+
/** Bundle/migration config validation failed */
|
|
10
|
+
INVALID_BUNDLE: 'INVALID_BUNDLE',
|
|
11
|
+
/** Migration execution failed for a specific module */
|
|
12
|
+
MIGRATION_FAILED: 'MIGRATION_FAILED'};
|
|
13
|
+
/**
|
|
14
|
+
* Custom error class for migration operations.
|
|
15
|
+
* Provides structured error information including error code,
|
|
16
|
+
* optional module ID, and field context.
|
|
17
|
+
*/
|
|
18
|
+
class MigrationError extends Error {
|
|
19
|
+
/** Error code categorizing the type of failure */
|
|
20
|
+
code;
|
|
21
|
+
/** Module ID where the error occurred, if applicable */
|
|
22
|
+
moduleId;
|
|
23
|
+
/** Field name where the error occurred, if applicable */
|
|
24
|
+
field;
|
|
25
|
+
constructor(code, message, options) {
|
|
26
|
+
super(message, { cause: options?.cause });
|
|
27
|
+
this.name = 'MigrationError';
|
|
28
|
+
this.code = code;
|
|
29
|
+
if (options?.moduleId !== undefined) {
|
|
30
|
+
this.moduleId = options.moduleId;
|
|
31
|
+
}
|
|
32
|
+
if (options?.field !== undefined) {
|
|
33
|
+
this.field = options.field;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a formatted string representation of the error.
|
|
38
|
+
*/
|
|
39
|
+
toString() {
|
|
40
|
+
const parts = [`MigrationError [${this.code}]: ${this.message}`];
|
|
41
|
+
if (this.moduleId !== undefined) {
|
|
42
|
+
parts.push(` Module ID: ${this.moduleId}`);
|
|
43
|
+
}
|
|
44
|
+
if (this.field !== undefined) {
|
|
45
|
+
parts.push(` Field: ${this.field}`);
|
|
46
|
+
}
|
|
47
|
+
return parts.join('\n');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
exports.MigrationError = MigrationError;
|
|
52
|
+
exports.MigrationErrorCode = MigrationErrorCode;
|
|
53
|
+
//# sourceMappingURL=migration-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-error.js","sources":["../../../src/lib/errors/migration-error.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;AAEG;AACH,MAAM,kBAAkB,GAAG;;AAE1B,IAAA,iBAAiB,EAAE,mBAAmB;;AAEtC,IAAA,cAAc,EAAE,gBAAgB;;AAEhC,IAAA,gBAAgB,EAAE;AAOnB;;;;AAIG;AACH,MAAM,cAAe,SAAQ,KAAK,CAAA;;AAExB,IAAA,IAAI;;AAEJ,IAAA,QAAQ;;AAER,IAAA,KAAK;AAEd,IAAA,WAAA,CACC,IAAwB,EACxB,OAAe,EACf,OAIC,EAAA;QAED,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AACzC,QAAA,IAAI,CAAC,IAAI,GAAG,gBAAgB;AAC5B,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,OAAO,EAAE,QAAQ,KAAK,SAAS,EAAE;AACpC,YAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ;QACjC;AACA,QAAA,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE;AACjC,YAAA,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK;QAC3B;IACD;AAEA;;AAEG;IACM,QAAQ,GAAA;AAChB,QAAA,MAAM,KAAK,GAAG,CAAC,CAAA,gBAAA,EAAmB,IAAI,CAAC,IAAI,CAAA,GAAA,EAAM,IAAI,CAAC,OAAO,CAAA,CAAE,CAAC;AAChE,QAAA,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,KAAK,CAAC,IAAI,CAAC,CAAA,aAAA,EAAgB,IAAI,CAAC,QAAQ,CAAA,CAAE,CAAC;QAC5C;AACA,QAAA,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC7B,KAAK,CAAC,IAAI,CAAC,CAAA,SAAA,EAAY,IAAI,CAAC,KAAK,CAAA,CAAE,CAAC;QACrC;AACA,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACxB;AACA;;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type FieldReference = {
|
|
2
|
+
moduleId: number;
|
|
3
|
+
fieldPath: string;
|
|
4
|
+
fullMatch: string;
|
|
5
|
+
startIndex: number;
|
|
6
|
+
endIndex: number;
|
|
7
|
+
};
|
|
8
|
+
type FieldChange = {
|
|
9
|
+
from: string;
|
|
10
|
+
to: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
declare const parseExpressions: (value: string) => FieldReference[];
|
|
13
|
+
declare const rewriteReferences: (value: string, moduleId: number, fieldMappings: Record<string, string | undefined>) => {
|
|
14
|
+
newValue: string;
|
|
15
|
+
changes: FieldChange[];
|
|
16
|
+
};
|
|
17
|
+
declare const findAllReferences: (modules: {
|
|
18
|
+
id: number;
|
|
19
|
+
mapper?: Record<string, unknown> | undefined;
|
|
20
|
+
}[], targetModuleId: number) => {
|
|
21
|
+
moduleId: number;
|
|
22
|
+
field: string;
|
|
23
|
+
referencedField: string;
|
|
24
|
+
}[];
|
|
25
|
+
export { findAllReferences, parseExpressions, rewriteReferences };
|
|
26
|
+
export type { FieldReference };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const extractReferencesFromExpression = (content, baseOffset) => {
|
|
4
|
+
const references = [];
|
|
5
|
+
const refPattern = /(\d+)\.([a-zA-Z_][a-zA-Z0-9_]*(?:\[[^\]]*\])?(?:\.[a-zA-Z_][a-zA-Z0-9_]*(?:\[[^\]]*\])?)*)/g;
|
|
6
|
+
let refMatch = refPattern.exec(content);
|
|
7
|
+
while (refMatch !== null) {
|
|
8
|
+
const moduleIdStr = refMatch[1];
|
|
9
|
+
const fieldPath = refMatch[2];
|
|
10
|
+
if (moduleIdStr && fieldPath) {
|
|
11
|
+
const moduleId = Number.parseInt(moduleIdStr, 10);
|
|
12
|
+
references.push({
|
|
13
|
+
moduleId,
|
|
14
|
+
fieldPath,
|
|
15
|
+
fullMatch: refMatch[0],
|
|
16
|
+
startIndex: baseOffset + refMatch.index + 2,
|
|
17
|
+
endIndex: baseOffset + refMatch.index + 2 + refMatch[0].length,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
refMatch = refPattern.exec(content);
|
|
21
|
+
}
|
|
22
|
+
return references;
|
|
23
|
+
};
|
|
24
|
+
const parseExpressions = (value) => {
|
|
25
|
+
const references = [];
|
|
26
|
+
const expressionPattern = /\{\{([^}]+)\}\}/g;
|
|
27
|
+
let match = expressionPattern.exec(value);
|
|
28
|
+
while (match !== null) {
|
|
29
|
+
const expressionContent = match[1];
|
|
30
|
+
if (expressionContent) {
|
|
31
|
+
const innerRefs = extractReferencesFromExpression(expressionContent, match.index);
|
|
32
|
+
references.push(...innerRefs);
|
|
33
|
+
}
|
|
34
|
+
match = expressionPattern.exec(value);
|
|
35
|
+
}
|
|
36
|
+
return references;
|
|
37
|
+
};
|
|
38
|
+
const reconstructWithIndices = (original, deindexed, mapped) => {
|
|
39
|
+
const originalParts = original.split('.');
|
|
40
|
+
const deindexedParts = deindexed.split('.');
|
|
41
|
+
const mappedParts = mapped.split('.');
|
|
42
|
+
if (deindexedParts.length !== mappedParts.length) {
|
|
43
|
+
return mapped;
|
|
44
|
+
}
|
|
45
|
+
return originalParts
|
|
46
|
+
.map((part, index) => {
|
|
47
|
+
const mappedPart = mappedParts[index];
|
|
48
|
+
if (index >= mappedParts.length || mappedPart === undefined) {
|
|
49
|
+
return part;
|
|
50
|
+
}
|
|
51
|
+
const base = part.split('[')[0] ?? '';
|
|
52
|
+
const indices = part.slice(base.length);
|
|
53
|
+
const deindexedPart = deindexedParts[index];
|
|
54
|
+
if (index < deindexedParts.length && deindexedPart === base) {
|
|
55
|
+
return mappedPart + indices;
|
|
56
|
+
}
|
|
57
|
+
return part;
|
|
58
|
+
})
|
|
59
|
+
.join('.');
|
|
60
|
+
};
|
|
61
|
+
const findMapping = (fieldPath, fieldMappings) => {
|
|
62
|
+
// 1. Exact match
|
|
63
|
+
if (fieldPath in fieldMappings) {
|
|
64
|
+
const mapped = fieldMappings[fieldPath];
|
|
65
|
+
return { mappedPath: mapped, matched: true, isRemoved: mapped === undefined };
|
|
66
|
+
}
|
|
67
|
+
// 2. De-indexed match: participants[0].primary_flag → participants.primary_flag
|
|
68
|
+
const deindexed = fieldPath.replaceAll(/\[\d+\]/g, '');
|
|
69
|
+
if (deindexed !== fieldPath && deindexed in fieldMappings) {
|
|
70
|
+
const mapped = fieldMappings[deindexed];
|
|
71
|
+
if (mapped === undefined) {
|
|
72
|
+
return { mappedPath: undefined, matched: true, isRemoved: true };
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
mappedPath: reconstructWithIndices(fieldPath, deindexed, mapped),
|
|
76
|
+
matched: true,
|
|
77
|
+
isRemoved: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// 3. Root field match
|
|
81
|
+
const rootField = fieldPath.split('.')[0]?.split('[')[0];
|
|
82
|
+
if (rootField && rootField in fieldMappings) {
|
|
83
|
+
const mapped = fieldMappings[rootField];
|
|
84
|
+
if (mapped === undefined) {
|
|
85
|
+
return { mappedPath: undefined, matched: true, isRemoved: true };
|
|
86
|
+
}
|
|
87
|
+
const suffix = fieldPath.slice(rootField.length);
|
|
88
|
+
return { mappedPath: mapped + suffix, matched: true, isRemoved: false };
|
|
89
|
+
}
|
|
90
|
+
return { mappedPath: fieldPath, matched: false, isRemoved: false };
|
|
91
|
+
};
|
|
92
|
+
const rewriteReferences = (value, moduleId, fieldMappings) => {
|
|
93
|
+
const changes = [];
|
|
94
|
+
let newValue = value;
|
|
95
|
+
const refs = parseExpressions(value);
|
|
96
|
+
const moduleRefs = refs.filter((ref) => {
|
|
97
|
+
return ref.moduleId === moduleId;
|
|
98
|
+
});
|
|
99
|
+
const sortedRefs = [...moduleRefs].sort((a, b) => {
|
|
100
|
+
return b.startIndex - a.startIndex;
|
|
101
|
+
});
|
|
102
|
+
for (const ref of sortedRefs) {
|
|
103
|
+
const { mappedPath, matched, isRemoved } = findMapping(ref.fieldPath, fieldMappings);
|
|
104
|
+
if (matched) {
|
|
105
|
+
if (isRemoved) {
|
|
106
|
+
changes.push({ from: ref.fieldPath, to: undefined });
|
|
107
|
+
}
|
|
108
|
+
else if (mappedPath !== ref.fieldPath) {
|
|
109
|
+
const newRef = `${moduleId}.${mappedPath}`;
|
|
110
|
+
newValue =
|
|
111
|
+
newValue.slice(0, ref.startIndex) + newRef + newValue.slice(ref.endIndex);
|
|
112
|
+
changes.push({ from: ref.fieldPath, to: mappedPath });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { newValue, changes };
|
|
117
|
+
};
|
|
118
|
+
const scanMapperForReferences = (obj, sourceModuleId, targetModuleId, path, refs) => {
|
|
119
|
+
if (typeof obj === 'string') {
|
|
120
|
+
const parsed = parseExpressions(obj);
|
|
121
|
+
for (const ref of parsed) {
|
|
122
|
+
if (ref.moduleId === targetModuleId) {
|
|
123
|
+
refs.push({
|
|
124
|
+
moduleId: sourceModuleId,
|
|
125
|
+
field: path,
|
|
126
|
+
referencedField: ref.fieldPath,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (Array.isArray(obj)) {
|
|
132
|
+
for (const [index, item] of obj.entries()) {
|
|
133
|
+
scanMapperForReferences(item, sourceModuleId, targetModuleId, `${path}[${index + 1}]`, refs);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else if (obj && typeof obj === 'object') {
|
|
137
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
138
|
+
scanMapperForReferences(val, sourceModuleId, targetModuleId, path ? `${path}.${key}` : key, refs);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const findAllReferences = (modules, targetModuleId) => {
|
|
143
|
+
const allRefs = [];
|
|
144
|
+
for (const flowModule of modules) {
|
|
145
|
+
if (flowModule.mapper) {
|
|
146
|
+
scanMapperForReferences(flowModule.mapper, flowModule.id, targetModuleId, '', allRefs);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return allRefs;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
exports.findAllReferences = findAllReferences;
|
|
153
|
+
exports.parseExpressions = parseExpressions;
|
|
154
|
+
exports.rewriteReferences = rewriteReferences;
|
|
155
|
+
//# sourceMappingURL=expression-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression-parser.js","sources":["../../src/lib/expression-parser.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAaA,MAAM,+BAA+B,GAAG,CAAC,OAAe,EAAE,UAAkB,KAAsB;IACjG,MAAM,UAAU,GAAqB,EAAE;IAEvC,MAAM,UAAU,GACf,6FAA6F;IAC9F,IAAI,QAAQ,GAAG,UAAU,CAAC,IAA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OAAO,GAIP,EAAE;AAER,IAAA,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE;AACjC,QAAA,IAAI,UAAU,CAAC,MAAM,EAAE;AACtB,YAAA,uBAAuB,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,OAAO,CAAC;QACvF;IACD;AAEA,IAAA,OAAO,OAAO;AACf;;;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Blueprint, Bundle, MigrationReport } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Migrates a blueprint by applying module migrations.
|
|
4
|
+
* Validates inputs, applies field mappings, and generates a migration report.
|
|
5
|
+
*
|
|
6
|
+
* @param blueprint - The blueprint to migrate
|
|
7
|
+
* @param selectedModuleIds - IDs of modules to migrate
|
|
8
|
+
* @param config - Bundle containing migration configurations
|
|
9
|
+
* @returns Object containing migrated blueprint and migration report
|
|
10
|
+
* @throws MigrationError if validation fails or migration encounters an error
|
|
11
|
+
*/
|
|
12
|
+
declare const migrateBlueprint: (blueprint: Blueprint, selectedModuleIds: number[], config: Bundle) => {
|
|
13
|
+
migratedBlueprint: Blueprint;
|
|
14
|
+
report: MigrationReport;
|
|
15
|
+
};
|
|
16
|
+
export { migrateBlueprint };
|