kintone-migrator 0.12.0 → 0.12.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/dist/index.mjs +70 -29
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1571,6 +1571,7 @@ function parseAuth(raw) {
|
|
|
1571
1571
|
password
|
|
1572
1572
|
};
|
|
1573
1573
|
}
|
|
1574
|
+
const ConfigParser$1 = { parse: parseProjectConfig };
|
|
1574
1575
|
|
|
1575
1576
|
//#endregion
|
|
1576
1577
|
//#region src/core/application/projectConfig/loadProjectConfig.ts
|
|
@@ -1581,7 +1582,7 @@ function loadProjectConfig(input) {
|
|
|
1581
1582
|
} catch (cause) {
|
|
1582
1583
|
throw new ValidationError(ValidationErrorCode.InvalidInput, "Invalid YAML syntax in config file", cause);
|
|
1583
1584
|
}
|
|
1584
|
-
return
|
|
1585
|
+
return ConfigParser$1.parse(raw);
|
|
1585
1586
|
}
|
|
1586
1587
|
|
|
1587
1588
|
//#endregion
|
|
@@ -1631,13 +1632,14 @@ function resolveExecutionOrder(apps) {
|
|
|
1631
1632
|
function validateDependencyReferences(apps) {
|
|
1632
1633
|
for (const [name, entry] of apps) for (const dep of entry.dependsOn) if (!apps.has(dep)) throw new BusinessRuleError(ProjectConfigErrorCode.UnknownDependency, `App "${name}" depends on unknown app "${dep}"`);
|
|
1633
1634
|
}
|
|
1635
|
+
const DependencyResolver = { resolve: resolveExecutionOrder };
|
|
1634
1636
|
|
|
1635
1637
|
//#endregion
|
|
1636
1638
|
//#region src/core/application/projectConfig/resolveExecutionPlan.ts
|
|
1637
1639
|
function resolveExecutionPlan(input) {
|
|
1638
1640
|
const { config, appName, all } = input;
|
|
1639
1641
|
if (appName) return resolveSingleApp(config, appName);
|
|
1640
|
-
if (all) return
|
|
1642
|
+
if (all) return DependencyResolver.resolve(config.apps);
|
|
1641
1643
|
throw new ValidationError(ValidationErrorCode.InvalidInput, "At least one mode (appName or all) must be selected");
|
|
1642
1644
|
}
|
|
1643
1645
|
function resolveSingleApp(config, appName) {
|
|
@@ -1938,6 +1940,7 @@ var capture_field_acl_default = define({
|
|
|
1938
1940
|
|
|
1939
1941
|
//#endregion
|
|
1940
1942
|
//#region src/core/domain/customization/services/resourceMerger.ts
|
|
1943
|
+
const MAX_RESOURCES_PER_CATEGORY = 30;
|
|
1941
1944
|
function remoteToResolved(resource) {
|
|
1942
1945
|
if (resource.type === "URL") return resource;
|
|
1943
1946
|
return {
|
|
@@ -1946,17 +1949,22 @@ function remoteToResolved(resource) {
|
|
|
1946
1949
|
name: resource.file.name
|
|
1947
1950
|
};
|
|
1948
1951
|
}
|
|
1949
|
-
const ResourceMerger = {
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
if (
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1952
|
+
const ResourceMerger = {
|
|
1953
|
+
assertResourceCount: (label, resources) => {
|
|
1954
|
+
if (resources.length > MAX_RESOURCES_PER_CATEGORY) throw new BusinessRuleError(CustomizationErrorCode.CzTooManyFiles, `${label} has ${resources.length} resources, exceeding the maximum of ${MAX_RESOURCES_PER_CATEGORY}`);
|
|
1955
|
+
},
|
|
1956
|
+
mergeResources: (current, incoming) => {
|
|
1957
|
+
const incomingFileNames = /* @__PURE__ */ new Set();
|
|
1958
|
+
const incomingUrls = /* @__PURE__ */ new Set();
|
|
1959
|
+
for (const resource of incoming) if (resource.type === "FILE") incomingFileNames.add(resource.name);
|
|
1960
|
+
else incomingUrls.add(resource.url);
|
|
1961
|
+
const kept = [];
|
|
1962
|
+
for (const resource of current) if (resource.type === "FILE") {
|
|
1963
|
+
if (!incomingFileNames.has(resource.file.name)) kept.push(remoteToResolved(resource));
|
|
1964
|
+
} else if (!incomingUrls.has(resource.url)) kept.push(resource);
|
|
1965
|
+
return [...kept, ...incoming];
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1960
1968
|
|
|
1961
1969
|
//#endregion
|
|
1962
1970
|
//#region src/core/domain/customization/services/configParser.ts
|
|
@@ -2037,7 +2045,6 @@ function parseConfigText(rawText) {
|
|
|
2037
2045
|
|
|
2038
2046
|
//#endregion
|
|
2039
2047
|
//#region src/core/application/customization/applyCustomization.ts
|
|
2040
|
-
const MAX_RESOURCES_PER_CATEGORY = 30;
|
|
2041
2048
|
async function resolveResources(platform, basePath, fileUploader) {
|
|
2042
2049
|
const resolveList = async (resources) => {
|
|
2043
2050
|
return Promise.all(resources.map(async (resource) => {
|
|
@@ -2063,9 +2070,6 @@ function mergePlatform(current, incoming) {
|
|
|
2063
2070
|
css: ResourceMerger.mergeResources(current.css, incoming.css)
|
|
2064
2071
|
};
|
|
2065
2072
|
}
|
|
2066
|
-
function validateResourceCount(label, resources) {
|
|
2067
|
-
if (resources.length > MAX_RESOURCES_PER_CATEGORY) throw new BusinessRuleError(CustomizationErrorCode.CzTooManyFiles, `${label} has ${resources.length} resources, exceeding the maximum of ${MAX_RESOURCES_PER_CATEGORY}`);
|
|
2068
|
-
}
|
|
2069
2073
|
async function applyCustomization({ container, input }) {
|
|
2070
2074
|
const result = await container.customizationStorage.get();
|
|
2071
2075
|
if (!result.exists) throw new ValidationError(ValidationErrorCode.InvalidInput, "Customization config file not found");
|
|
@@ -2074,10 +2078,10 @@ async function applyCustomization({ container, input }) {
|
|
|
2074
2078
|
const [resolvedDesktop, resolvedMobile] = await Promise.all([resolveResources(config.desktop, input.basePath, container.fileUploader), resolveResources(config.mobile, input.basePath, container.fileUploader)]);
|
|
2075
2079
|
const mergedDesktop = mergePlatform(currentCustomization.desktop, resolvedDesktop);
|
|
2076
2080
|
const mergedMobile = mergePlatform(currentCustomization.mobile, resolvedMobile);
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
+
ResourceMerger.assertResourceCount("desktop.js", mergedDesktop.js);
|
|
2082
|
+
ResourceMerger.assertResourceCount("desktop.css", mergedDesktop.css);
|
|
2083
|
+
ResourceMerger.assertResourceCount("mobile.js", mergedMobile.js);
|
|
2084
|
+
ResourceMerger.assertResourceCount("mobile.css", mergedMobile.css);
|
|
2081
2085
|
await container.customizationConfigurator.updateCustomization({
|
|
2082
2086
|
scope: config.scope,
|
|
2083
2087
|
desktop: {
|
|
@@ -3118,14 +3122,35 @@ async function executeMigration({ container }) {
|
|
|
3118
3122
|
const added = diff.entries.filter((e) => e.type === "added");
|
|
3119
3123
|
const modified = diff.entries.filter((e) => e.type === "modified");
|
|
3120
3124
|
const deleted = diff.entries.filter((e) => e.type === "deleted");
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3125
|
+
const fieldsToAdd = [];
|
|
3126
|
+
const fieldsToUpdate = [];
|
|
3127
|
+
for (const entry of added) {
|
|
3128
|
+
if (entry.after === void 0) continue;
|
|
3129
|
+
if (subtableInnerCodes.has(entry.fieldCode)) continue;
|
|
3130
|
+
fieldsToAdd.push(entry.after);
|
|
3131
|
+
}
|
|
3132
|
+
for (const entry of modified) {
|
|
3133
|
+
if (entry.after === void 0) continue;
|
|
3134
|
+
if (subtableInnerCodes.has(entry.fieldCode)) continue;
|
|
3135
|
+
const after = entry.after;
|
|
3136
|
+
const before = entry.before;
|
|
3137
|
+
if (after.type === "SUBTABLE" && before !== void 0 && before.type === "SUBTABLE") {
|
|
3138
|
+
const newInnerFields = /* @__PURE__ */ new Map();
|
|
3139
|
+
const existingInnerFields = /* @__PURE__ */ new Map();
|
|
3140
|
+
for (const [code, def] of after.properties.fields) if (before.properties.fields.has(code)) existingInnerFields.set(code, def);
|
|
3141
|
+
else newInnerFields.set(code, def);
|
|
3142
|
+
if (newInnerFields.size > 0) fieldsToAdd.push({
|
|
3143
|
+
...after,
|
|
3144
|
+
properties: { fields: newInnerFields }
|
|
3145
|
+
});
|
|
3146
|
+
if (existingInnerFields.size > 0) fieldsToUpdate.push({
|
|
3147
|
+
...after,
|
|
3148
|
+
properties: { fields: existingInnerFields }
|
|
3149
|
+
});
|
|
3150
|
+
} else fieldsToUpdate.push(after);
|
|
3128
3151
|
}
|
|
3152
|
+
if (fieldsToAdd.length > 0) await container.formConfigurator.addFields(fieldsToAdd);
|
|
3153
|
+
if (fieldsToUpdate.length > 0) await container.formConfigurator.updateFields(fieldsToUpdate);
|
|
3129
3154
|
if (deleted.length > 0) {
|
|
3130
3155
|
const currentSubtableInnerCodes = collectSubtableInnerFieldCodes(currentFields);
|
|
3131
3156
|
const fieldCodes = deleted.filter((e) => !currentSubtableInnerCodes.has(e.fieldCode)).map((e) => e.fieldCode);
|
|
@@ -3245,7 +3270,23 @@ async function forceOverrideForm({ container }) {
|
|
|
3245
3270
|
const toDelete = [];
|
|
3246
3271
|
for (const [fieldCode, schemaDef] of schema.fields) {
|
|
3247
3272
|
if (subtableInnerCodes.has(fieldCode)) continue;
|
|
3248
|
-
if (currentFields.has(fieldCode))
|
|
3273
|
+
if (currentFields.has(fieldCode)) if (schemaDef.type === "SUBTABLE") {
|
|
3274
|
+
const currentDef = currentFields.get(fieldCode);
|
|
3275
|
+
if (currentDef !== void 0 && currentDef.type === "SUBTABLE") {
|
|
3276
|
+
const newInnerFields = /* @__PURE__ */ new Map();
|
|
3277
|
+
const existingInnerFields = /* @__PURE__ */ new Map();
|
|
3278
|
+
for (const [code, def] of schemaDef.properties.fields) if (currentDef.properties.fields.has(code)) existingInnerFields.set(code, def);
|
|
3279
|
+
else newInnerFields.set(code, def);
|
|
3280
|
+
if (newInnerFields.size > 0) toAdd.push({
|
|
3281
|
+
...schemaDef,
|
|
3282
|
+
properties: { fields: newInnerFields }
|
|
3283
|
+
});
|
|
3284
|
+
if (existingInnerFields.size > 0) toUpdate.push({
|
|
3285
|
+
...schemaDef,
|
|
3286
|
+
properties: { fields: existingInnerFields }
|
|
3287
|
+
});
|
|
3288
|
+
} else toUpdate.push(schemaDef);
|
|
3289
|
+
} else toUpdate.push(schemaDef);
|
|
3249
3290
|
else toAdd.push(schemaDef);
|
|
3250
3291
|
}
|
|
3251
3292
|
const currentSubtableInnerCodes = collectSubtableInnerFieldCodes(currentFields);
|