kintone-migrator 0.35.8 → 0.36.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/README.md +40 -2
- package/dist/index.mjs +394 -63
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1386,16 +1386,6 @@ function sanitizeForDisplay$1(s) {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
//#endregion
|
|
1388
1388
|
//#region src/core/domain/formSchema/valueObject.ts
|
|
1389
|
-
const LookupRelatedApp = {
|
|
1390
|
-
/**
|
|
1391
|
-
* kintone returns `code: ""` for a related app without an app code, while a
|
|
1392
|
-
* schema leaves `code` out for the same app. Both build a related app
|
|
1393
|
-
* without `code`, so only a non-empty `code` is kept.
|
|
1394
|
-
*/
|
|
1395
|
-
create: (app, code) => code === void 0 || code === "" ? { app } : {
|
|
1396
|
-
app,
|
|
1397
|
-
code
|
|
1398
|
-
} };
|
|
1399
1389
|
function hasInvalidFieldCodeChars(code) {
|
|
1400
1390
|
if (hasControlChars(code)) return true;
|
|
1401
1391
|
for (let i = 0; i < code.length; i++) {
|
|
@@ -1409,6 +1399,14 @@ const FieldCode = { create: (code) => {
|
|
|
1409
1399
|
if (hasInvalidFieldCodeChars(code)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidFieldCode, `Field code "${sanitizeForDisplay$1(code)}" contains invalid characters`);
|
|
1410
1400
|
return code;
|
|
1411
1401
|
} };
|
|
1402
|
+
const LOOKUP_CAPABLE_TYPES = /* @__PURE__ */ new Set([
|
|
1403
|
+
"SINGLE_LINE_TEXT",
|
|
1404
|
+
"NUMBER",
|
|
1405
|
+
"LINK"
|
|
1406
|
+
]);
|
|
1407
|
+
function isLookupCapableField(field) {
|
|
1408
|
+
return LOOKUP_CAPABLE_TYPES.has(field.type);
|
|
1409
|
+
}
|
|
1412
1410
|
//#endregion
|
|
1413
1411
|
//#region src/core/adapters/kintone/formConfigurator.ts
|
|
1414
1412
|
const KNOWN_FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -1500,12 +1498,23 @@ function readKintoneQueryClause(value, fieldPath) {
|
|
|
1500
1498
|
assertString(value, fieldPath);
|
|
1501
1499
|
return value;
|
|
1502
1500
|
}
|
|
1501
|
+
/** Reads `relatedApp`; a missing `code` is `""`, as for an app without one. */
|
|
1502
|
+
function fromKintoneRelatedApp(value, fieldPath) {
|
|
1503
|
+
assertRecord(value, fieldPath);
|
|
1504
|
+
assertString(value.app, `${fieldPath}.app`);
|
|
1505
|
+
if (value.code === void 0) return {
|
|
1506
|
+
app: value.app,
|
|
1507
|
+
code: ""
|
|
1508
|
+
};
|
|
1509
|
+
assertString(value.code, `${fieldPath}.code`);
|
|
1510
|
+
return {
|
|
1511
|
+
app: value.app,
|
|
1512
|
+
code: value.code
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1503
1515
|
function fromKintoneLookup(value, fieldPath) {
|
|
1504
1516
|
assertRecord(value, fieldPath);
|
|
1505
|
-
|
|
1506
|
-
const { app, code } = value.relatedApp;
|
|
1507
|
-
assertString(app, `${fieldPath}.relatedApp.app`);
|
|
1508
|
-
if (code !== void 0) assertString(code, `${fieldPath}.relatedApp.code`);
|
|
1517
|
+
const relatedApp = fromKintoneRelatedApp(value.relatedApp, `${fieldPath}.relatedApp`);
|
|
1509
1518
|
assertString(value.relatedKeyField, `${fieldPath}.relatedKeyField`);
|
|
1510
1519
|
const fieldMappings = readKintoneLookupList(value.fieldMappings, `${fieldPath}.fieldMappings`).map((mapping, i) => {
|
|
1511
1520
|
const mappingPath = `${fieldPath}.fieldMappings[${i}]`;
|
|
@@ -1520,7 +1529,7 @@ function fromKintoneLookup(value, fieldPath) {
|
|
|
1520
1529
|
const lookupPickerFields = readKintoneLookupList(value.lookupPickerFields, `${fieldPath}.lookupPickerFields`);
|
|
1521
1530
|
assertStringArray(lookupPickerFields, `${fieldPath}.lookupPickerFields`);
|
|
1522
1531
|
return {
|
|
1523
|
-
relatedApp
|
|
1532
|
+
relatedApp,
|
|
1524
1533
|
relatedKeyField: value.relatedKeyField,
|
|
1525
1534
|
fieldMappings,
|
|
1526
1535
|
lookupPickerFields,
|
|
@@ -1558,13 +1567,11 @@ function fromKintoneProperty(prop) {
|
|
|
1558
1567
|
assertString(condition.relatedField, "REFERENCE_TABLE.referenceTable.condition.relatedField");
|
|
1559
1568
|
assertStringArray(rt.displayFields, "REFERENCE_TABLE.referenceTable.displayFields");
|
|
1560
1569
|
const displayFields = rt.displayFields.map((f) => FieldCode.create(f));
|
|
1561
|
-
assertRecord(rt.relatedApp, "REFERENCE_TABLE.referenceTable.relatedApp");
|
|
1562
|
-
assertString(rt.relatedApp.app, "REFERENCE_TABLE.referenceTable.relatedApp.app");
|
|
1563
1570
|
return {
|
|
1564
1571
|
...base,
|
|
1565
1572
|
type: "REFERENCE_TABLE",
|
|
1566
1573
|
properties: { referenceTable: {
|
|
1567
|
-
relatedApp:
|
|
1574
|
+
relatedApp: fromKintoneRelatedApp(rt.relatedApp, "REFERENCE_TABLE.referenceTable.relatedApp"),
|
|
1568
1575
|
condition: {
|
|
1569
1576
|
field: FieldCode.create(condition.field),
|
|
1570
1577
|
relatedField: FieldCode.create(condition.relatedField)
|
|
@@ -2932,6 +2939,23 @@ function printFieldDiffResult(result, title) {
|
|
|
2932
2939
|
function printAppHeader(appName, appId) {
|
|
2933
2940
|
p.log.step(`\n=== [${pc.bold(appName)}] (app: ${appId}) ===`);
|
|
2934
2941
|
}
|
|
2942
|
+
function printDeployState(state) {
|
|
2943
|
+
switch (state.kind) {
|
|
2944
|
+
case "upToDate":
|
|
2945
|
+
p.log.success(`No undeployed changes (preview and published are both at revision ${state.revision}).`);
|
|
2946
|
+
return;
|
|
2947
|
+
case "pending":
|
|
2948
|
+
p.log.warn(`Undeployed changes are pending: preview is at revision ${state.previewRevision}, published is at revision ${state.publishedRevision}. A deploy would publish them.\nA deploy that is still in progress also shows up this way.`);
|
|
2949
|
+
return;
|
|
2950
|
+
case "neverDeployed":
|
|
2951
|
+
p.log.warn(`The app has never been deployed (preview revision ${state.previewRevision}). A deploy would publish its entire configuration.`);
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
function printAppsWithUndeployedChanges(appNames) {
|
|
2956
|
+
if (appNames.length === 0) return;
|
|
2957
|
+
p.log.warn(`Undeployed changes in ${appNames.length} app(s): ${appNames.map((name) => pc.cyan(name)).join(", ")}`);
|
|
2958
|
+
}
|
|
2935
2959
|
function printMultiAppResult(result) {
|
|
2936
2960
|
p.log.step("");
|
|
2937
2961
|
for (const r of result.results) switch (r.status) {
|
|
@@ -3070,7 +3094,8 @@ async function routeMultiApp(values, handlers) {
|
|
|
3070
3094
|
return;
|
|
3071
3095
|
}
|
|
3072
3096
|
if (target.mode === "list-apps") {
|
|
3073
|
-
|
|
3097
|
+
if (handlers.noAppSelected) await handlers.noAppSelected(target.config);
|
|
3098
|
+
else printAvailableApps(target.config);
|
|
3074
3099
|
return;
|
|
3075
3100
|
}
|
|
3076
3101
|
if (target.mode === "single-app") {
|
|
@@ -5862,6 +5887,109 @@ function collectSubtableInnerFieldCodes(fields) {
|
|
|
5862
5887
|
return innerCodes;
|
|
5863
5888
|
}
|
|
5864
5889
|
//#endregion
|
|
5890
|
+
//#region src/core/domain/formSchema/services/relatedAppProjection.ts
|
|
5891
|
+
function mapLookupProperties(properties, fieldCode, replace) {
|
|
5892
|
+
const { lookup, ...rest } = properties;
|
|
5893
|
+
if (lookup === void 0) return rest;
|
|
5894
|
+
return {
|
|
5895
|
+
...rest,
|
|
5896
|
+
lookup: {
|
|
5897
|
+
...lookup,
|
|
5898
|
+
relatedApp: replace(lookup.relatedApp, fieldCode)
|
|
5899
|
+
}
|
|
5900
|
+
};
|
|
5901
|
+
}
|
|
5902
|
+
/**
|
|
5903
|
+
* Rebuilds `field` with each related app replaced by `replace`, including those
|
|
5904
|
+
* of the fields inside a subtable.
|
|
5905
|
+
*/
|
|
5906
|
+
function mapFieldRelatedApps(field, replace) {
|
|
5907
|
+
switch (field.type) {
|
|
5908
|
+
case "SINGLE_LINE_TEXT": return {
|
|
5909
|
+
...field,
|
|
5910
|
+
properties: mapLookupProperties(field.properties, field.code, replace)
|
|
5911
|
+
};
|
|
5912
|
+
case "NUMBER": return {
|
|
5913
|
+
...field,
|
|
5914
|
+
properties: mapLookupProperties(field.properties, field.code, replace)
|
|
5915
|
+
};
|
|
5916
|
+
case "LINK": return {
|
|
5917
|
+
...field,
|
|
5918
|
+
properties: mapLookupProperties(field.properties, field.code, replace)
|
|
5919
|
+
};
|
|
5920
|
+
case "REFERENCE_TABLE": {
|
|
5921
|
+
const { referenceTable } = field.properties;
|
|
5922
|
+
return {
|
|
5923
|
+
...field,
|
|
5924
|
+
properties: { referenceTable: {
|
|
5925
|
+
...referenceTable,
|
|
5926
|
+
relatedApp: replace(referenceTable.relatedApp, field.code)
|
|
5927
|
+
} }
|
|
5928
|
+
};
|
|
5929
|
+
}
|
|
5930
|
+
case "SUBTABLE": return {
|
|
5931
|
+
...field,
|
|
5932
|
+
properties: { fields: mapFieldsRelatedApps(field.properties.fields, replace) }
|
|
5933
|
+
};
|
|
5934
|
+
default: return field;
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
/** Rebuilds `fields` with each related app replaced by `replace`. */
|
|
5938
|
+
function mapFieldsRelatedApps(fields, replace) {
|
|
5939
|
+
return new Map(Array.from(fields, ([code, field]) => [code, mapFieldRelatedApps(field, replace)]));
|
|
5940
|
+
}
|
|
5941
|
+
function relatedAppOf(field) {
|
|
5942
|
+
if (isLookupCapableField(field)) return field.properties.lookup?.relatedApp;
|
|
5943
|
+
return field.type === "REFERENCE_TABLE" ? field.properties.referenceTable.relatedApp : void 0;
|
|
5944
|
+
}
|
|
5945
|
+
/**
|
|
5946
|
+
* The related app of each field that has one, keyed by field code. A schema
|
|
5947
|
+
* and a remote field map both hold subtable inner fields at the top level too,
|
|
5948
|
+
* and field codes are unique across the form, so the top level covers them.
|
|
5949
|
+
*/
|
|
5950
|
+
function relatedAppsByField(fields) {
|
|
5951
|
+
const result = /* @__PURE__ */ new Map();
|
|
5952
|
+
for (const [code, field] of fields) {
|
|
5953
|
+
const relatedApp = relatedAppOf(field);
|
|
5954
|
+
if (relatedApp !== void 0) result.set(code, relatedApp);
|
|
5955
|
+
}
|
|
5956
|
+
return result;
|
|
5957
|
+
}
|
|
5958
|
+
/**
|
|
5959
|
+
* Refers to the remote related app the way `reference` does: by app code when
|
|
5960
|
+
* `reference` does and the app has one, by app ID otherwise.
|
|
5961
|
+
*/
|
|
5962
|
+
function projectRelatedApp(remote, reference) {
|
|
5963
|
+
return reference?.code !== void 0 && remote.code !== "" ? { code: remote.code } : { app: remote.app };
|
|
5964
|
+
}
|
|
5965
|
+
/** Whether `relatedApp` refers to the app `remote` reports. */
|
|
5966
|
+
function refersTo(relatedApp, remote) {
|
|
5967
|
+
return relatedApp.code !== void 0 ? relatedApp.code === remote.code : relatedApp.app === remote.app;
|
|
5968
|
+
}
|
|
5969
|
+
/**
|
|
5970
|
+
* Turns the remote fields into schema fields, referring to each related app the
|
|
5971
|
+
* way the same-code field of `reference` does (see {@link projectRelatedApp}).
|
|
5972
|
+
* Without a `reference`, every related app is referred to by app ID.
|
|
5973
|
+
*/
|
|
5974
|
+
function projectRemoteFields(remote, reference) {
|
|
5975
|
+
const referenceApps = reference === void 0 ? /* @__PURE__ */ new Map() : relatedAppsByField(reference);
|
|
5976
|
+
return mapFieldsRelatedApps(remote, (relatedApp, code) => projectRelatedApp(relatedApp, referenceApps.get(code)));
|
|
5977
|
+
}
|
|
5978
|
+
/**
|
|
5979
|
+
* Restates the base fields the way {@link projectRemoteFields} states the remote
|
|
5980
|
+
* ones, so that a base and a remote referring to the same app compare equal
|
|
5981
|
+
* however each was written. A base related app that does not refer to the app
|
|
5982
|
+
* of the same-code remote field is a real difference and stays as it is.
|
|
5983
|
+
*/
|
|
5984
|
+
function restateBaseFields(base, remote, reference) {
|
|
5985
|
+
const remoteApps = relatedAppsByField(remote);
|
|
5986
|
+
const referenceApps = reference === void 0 ? /* @__PURE__ */ new Map() : relatedAppsByField(reference);
|
|
5987
|
+
return mapFieldsRelatedApps(base, (relatedApp, code) => {
|
|
5988
|
+
const remoteApp = remoteApps.get(code);
|
|
5989
|
+
return remoteApp !== void 0 && refersTo(relatedApp, remoteApp) ? projectRelatedApp(remoteApp, referenceApps.get(code)) : relatedApp;
|
|
5990
|
+
});
|
|
5991
|
+
}
|
|
5992
|
+
//#endregion
|
|
5865
5993
|
//#region src/core/domain/formSchema/services/subtableFieldSplitter.ts
|
|
5866
5994
|
function splitSubtableInnerFields(desired, current) {
|
|
5867
5995
|
const newInnerFields = /* @__PURE__ */ new Map();
|
|
@@ -5904,7 +6032,8 @@ function processModifiedEntry(after, before, fieldsToUpdate, innerFieldsToDelete
|
|
|
5904
6032
|
* concurrent change yields a 409 conflict.
|
|
5905
6033
|
*/
|
|
5906
6034
|
async function applySchemaChanges(schema, { container, expectedRevision }) {
|
|
5907
|
-
const [
|
|
6035
|
+
const [remoteFields, currentLayout] = await Promise.all([container.formConfigurator.getFields(), container.formConfigurator.getLayout()]);
|
|
6036
|
+
const currentFields = projectRemoteFields(remoteFields, schema.fields);
|
|
5908
6037
|
const diff = DiffDetector.detect(schema, currentFields);
|
|
5909
6038
|
const enrichedCurrentLayout = enrichLayoutWithFields(currentLayout, currentFields);
|
|
5910
6039
|
const hasLayoutChanges = DiffDetector.detectLayoutChanges(schema.layout, enrichedCurrentLayout);
|
|
@@ -5959,17 +6088,9 @@ const VALID_REFERENCE_TABLE_SIZES = /* @__PURE__ */ new Set([
|
|
|
5959
6088
|
"40",
|
|
5960
6089
|
"50"
|
|
5961
6090
|
]);
|
|
5962
|
-
const LOOKUP_FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
5963
|
-
"SINGLE_LINE_TEXT",
|
|
5964
|
-
"NUMBER",
|
|
5965
|
-
"LINK"
|
|
5966
|
-
]);
|
|
5967
6091
|
function isSelectionField(field) {
|
|
5968
6092
|
return SELECTION_TYPES.has(field.type);
|
|
5969
6093
|
}
|
|
5970
|
-
function isLookupCapableField(field) {
|
|
5971
|
-
return LOOKUP_FIELD_TYPES.has(field.type);
|
|
5972
|
-
}
|
|
5973
6094
|
function issue(severity, fieldCode, fieldType, rule, message) {
|
|
5974
6095
|
return {
|
|
5975
6096
|
severity,
|
|
@@ -6023,12 +6144,18 @@ function validateReferenceTableSize(field) {
|
|
|
6023
6144
|
if (size !== void 0 && !VALID_REFERENCE_TABLE_SIZES.has(size)) return [issue("error", field.code, field.type, "INVALID_REFERENCE_TABLE_SIZE", `Field "${field.code}" has invalid referenceTable.size "${size}". Valid values: ${[...VALID_REFERENCE_TABLE_SIZES].join(", ")}`)];
|
|
6024
6145
|
return [];
|
|
6025
6146
|
}
|
|
6147
|
+
/** The key `relatedApp` refers to the related app by, when its value is empty. */
|
|
6148
|
+
function emptyRelatedAppKey(relatedApp) {
|
|
6149
|
+
const [key, value] = relatedApp.code !== void 0 ? ["code", relatedApp.code] : ["app", relatedApp.app];
|
|
6150
|
+
return value.trim().length === 0 ? key : void 0;
|
|
6151
|
+
}
|
|
6026
6152
|
function validateLookupStructure(field) {
|
|
6027
6153
|
if (!isLookupCapableField(field)) return [];
|
|
6028
6154
|
const { lookup } = field.properties;
|
|
6029
6155
|
if (lookup === void 0) return [];
|
|
6030
6156
|
const issues = [];
|
|
6031
|
-
|
|
6157
|
+
const emptyKey = emptyRelatedAppKey(lookup.relatedApp);
|
|
6158
|
+
if (emptyKey !== void 0) issues.push(issue("error", field.code, field.type, "INVALID_LOOKUP", `Field "${field.code}" lookup must have a non-empty "relatedApp.${emptyKey}"`));
|
|
6032
6159
|
if (lookup.relatedKeyField.trim().length === 0) issues.push(issue("error", field.code, field.type, "INVALID_LOOKUP", `Field "${field.code}" lookup must have a non-empty "relatedKeyField"`));
|
|
6033
6160
|
lookup.fieldMappings.forEach((mapping, i) => {
|
|
6034
6161
|
for (const key of ["field", "relatedField"]) if (mapping[key].trim().length === 0) issues.push(issue("error", field.code, field.type, "INVALID_LOOKUP", `Field "${field.code}" lookup must have a non-empty "fieldMappings[${i}].${key}"`));
|
|
@@ -6037,8 +6164,8 @@ function validateLookupStructure(field) {
|
|
|
6037
6164
|
}
|
|
6038
6165
|
function validateReferenceTableRelatedApp(field) {
|
|
6039
6166
|
if (field.type !== "REFERENCE_TABLE") return [];
|
|
6040
|
-
const
|
|
6041
|
-
if (
|
|
6167
|
+
const emptyKey = emptyRelatedAppKey(field.properties.referenceTable.relatedApp);
|
|
6168
|
+
if (emptyKey !== void 0) return [issue("error", field.code, field.type, "EMPTY_RELATED_APP", `Field "${field.code}" referenceTable.relatedApp.${emptyKey} must be non-empty`)];
|
|
6042
6169
|
return [];
|
|
6043
6170
|
}
|
|
6044
6171
|
function validateSubtableHasInnerFields(field) {
|
|
@@ -6096,6 +6223,7 @@ const Schema = { create: (fields, layout) => {
|
|
|
6096
6223
|
} };
|
|
6097
6224
|
//#endregion
|
|
6098
6225
|
//#region src/core/domain/formSchema/services/schemaParser.ts
|
|
6226
|
+
const SCHEMA_FILE_OPTIONS = { relatedAppWithBothKeys: "reject" };
|
|
6099
6227
|
const VALID_UNIT_POSITIONS = /* @__PURE__ */ new Set(["BEFORE", "AFTER"]);
|
|
6100
6228
|
const VALID_CALC_FORMATS = /* @__PURE__ */ new Set([
|
|
6101
6229
|
"NUMBER",
|
|
@@ -6335,7 +6463,19 @@ function optionalLookupList(code, key, value) {
|
|
|
6335
6463
|
if (list === void 0) throw invalidLookup(code, `must have a "${key}" array`);
|
|
6336
6464
|
return list;
|
|
6337
6465
|
}
|
|
6338
|
-
|
|
6466
|
+
/**
|
|
6467
|
+
* Reads `relatedApp` (written at `path`), which refers to the related app by
|
|
6468
|
+
* exactly one of `app` and `code`. A key whose value is omitted or `null` is not
|
|
6469
|
+
* written.
|
|
6470
|
+
*/
|
|
6471
|
+
function parseRelatedApp(raw, path, { relatedAppWithBothKeys }, invalid) {
|
|
6472
|
+
const app = optionalString(raw.app);
|
|
6473
|
+
const code = optionalString(raw.code);
|
|
6474
|
+
if (app !== void 0 && (code === void 0 || relatedAppWithBothKeys === "app")) return { app };
|
|
6475
|
+
if (code !== void 0 && app === void 0) return { code };
|
|
6476
|
+
throw invalid(app === void 0 ? `must have "${path}.app" or "${path}.code"` : `must have only one of "${path}.app" and "${path}.code"`);
|
|
6477
|
+
}
|
|
6478
|
+
function parseLookup(code, raw, options) {
|
|
6339
6479
|
if (!isRecord(raw)) throw invalidLookup(code, "must be an object");
|
|
6340
6480
|
if (!isRecord(raw.relatedApp)) throw invalidLookup(code, "must have a \"relatedApp\" object");
|
|
6341
6481
|
const rawFieldMappings = optionalLookupList(code, "fieldMappings", raw.fieldMappings);
|
|
@@ -6348,7 +6488,7 @@ function parseLookup(code, raw) {
|
|
|
6348
6488
|
};
|
|
6349
6489
|
});
|
|
6350
6490
|
return {
|
|
6351
|
-
relatedApp:
|
|
6491
|
+
relatedApp: parseRelatedApp(raw.relatedApp, "relatedApp", options, (detail) => invalidLookup(code, detail)),
|
|
6352
6492
|
relatedKeyField: String(raw.relatedKeyField ?? ""),
|
|
6353
6493
|
fieldMappings,
|
|
6354
6494
|
lookupPickerFields,
|
|
@@ -6356,7 +6496,7 @@ function parseLookup(code, raw) {
|
|
|
6356
6496
|
sort: optionalQueryClause(raw.sort)
|
|
6357
6497
|
};
|
|
6358
6498
|
}
|
|
6359
|
-
function parseReferenceTableField(raw, code, base) {
|
|
6499
|
+
function parseReferenceTableField(raw, code, base, options) {
|
|
6360
6500
|
if (!isRecord(raw.referenceTable)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have a "referenceTable" property`);
|
|
6361
6501
|
const refTable = raw.referenceTable;
|
|
6362
6502
|
if (!isRecord(refTable.relatedApp)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have "referenceTable.relatedApp"`);
|
|
@@ -6364,7 +6504,6 @@ function parseReferenceTableField(raw, code, base) {
|
|
|
6364
6504
|
if (!Array.isArray(refTable.displayFields)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have "referenceTable.displayFields" array`);
|
|
6365
6505
|
const condition = refTable.condition;
|
|
6366
6506
|
const displayFields = refTable.displayFields.map((f) => FieldCode.create(f));
|
|
6367
|
-
const relatedApp = refTable.relatedApp;
|
|
6368
6507
|
const conditionField = String(condition.field ?? "");
|
|
6369
6508
|
const conditionRelatedField = String(condition.relatedField ?? "");
|
|
6370
6509
|
const size = optionalString(refTable.size);
|
|
@@ -6374,7 +6513,7 @@ function parseReferenceTableField(raw, code, base) {
|
|
|
6374
6513
|
...base,
|
|
6375
6514
|
type: "REFERENCE_TABLE",
|
|
6376
6515
|
properties: { referenceTable: {
|
|
6377
|
-
relatedApp:
|
|
6516
|
+
relatedApp: parseRelatedApp(refTable.relatedApp, "referenceTable.relatedApp", options, (detail) => new BusinessRuleError(FormSchemaErrorCode.FsInvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE ${detail}`)),
|
|
6378
6517
|
condition: {
|
|
6379
6518
|
field: FieldCode.create(conditionField),
|
|
6380
6519
|
relatedField: FieldCode.create(conditionRelatedField)
|
|
@@ -6386,7 +6525,7 @@ function parseReferenceTableField(raw, code, base) {
|
|
|
6386
6525
|
} }
|
|
6387
6526
|
};
|
|
6388
6527
|
}
|
|
6389
|
-
function parseFieldDefinitionFromFlat(raw) {
|
|
6528
|
+
function parseFieldDefinitionFromFlat(raw, options) {
|
|
6390
6529
|
const code = String(raw.code);
|
|
6391
6530
|
const type = String(raw.type);
|
|
6392
6531
|
if (!VALID_FIELD_TYPES.has(type)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidFieldType, `Invalid field type "${type}" for field "${code}"`);
|
|
@@ -6401,7 +6540,7 @@ function parseFieldDefinitionFromFlat(raw) {
|
|
|
6401
6540
|
const rawFields = Array.isArray(raw.fields) ? raw.fields : [];
|
|
6402
6541
|
const subFields = /* @__PURE__ */ new Map();
|
|
6403
6542
|
for (const subRaw of rawFields) {
|
|
6404
|
-
const subDef = parseFieldDefinitionFromFlat(subRaw);
|
|
6543
|
+
const subDef = parseFieldDefinitionFromFlat(subRaw, options);
|
|
6405
6544
|
subFields.set(subDef.code, subDef);
|
|
6406
6545
|
}
|
|
6407
6546
|
return {
|
|
@@ -6410,11 +6549,11 @@ function parseFieldDefinitionFromFlat(raw) {
|
|
|
6410
6549
|
properties: { fields: subFields }
|
|
6411
6550
|
};
|
|
6412
6551
|
}
|
|
6413
|
-
if (fieldType === "REFERENCE_TABLE") return parseReferenceTableField(raw, code, base);
|
|
6552
|
+
if (fieldType === "REFERENCE_TABLE") return parseReferenceTableField(raw, code, base, options);
|
|
6414
6553
|
const { lookup, ...others } = extractProperties(raw);
|
|
6415
6554
|
const properties = lookup === void 0 ? others : {
|
|
6416
6555
|
...others,
|
|
6417
|
-
lookup: parseLookup(code, lookup)
|
|
6556
|
+
lookup: parseLookup(code, lookup, options)
|
|
6418
6557
|
};
|
|
6419
6558
|
validateFieldProperties(code, fieldType, properties);
|
|
6420
6559
|
return buildFieldDefinition(base, fieldType, properties);
|
|
@@ -6446,7 +6585,7 @@ function parseDecorationElement(raw) {
|
|
|
6446
6585
|
default: throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidDecorationElement, `Unknown decoration element type: "${type}"`);
|
|
6447
6586
|
}
|
|
6448
6587
|
}
|
|
6449
|
-
function parseLayoutElement(raw) {
|
|
6588
|
+
function parseLayoutElement(raw, options) {
|
|
6450
6589
|
const type = String(raw.type);
|
|
6451
6590
|
if (DECORATION_TYPES.has(type)) return parseDecorationElement(raw);
|
|
6452
6591
|
if (SYSTEM_FIELD_TYPES.has(type)) return {
|
|
@@ -6455,7 +6594,7 @@ function parseLayoutElement(raw) {
|
|
|
6455
6594
|
type,
|
|
6456
6595
|
...raw.size !== void 0 ? { size: parseSize(raw.size) } : {}
|
|
6457
6596
|
};
|
|
6458
|
-
const field = parseFieldDefinitionFromFlat(raw);
|
|
6597
|
+
const field = parseFieldDefinitionFromFlat(raw, options);
|
|
6459
6598
|
const size = parseSize(raw.size);
|
|
6460
6599
|
return {
|
|
6461
6600
|
kind: "field",
|
|
@@ -6463,12 +6602,12 @@ function parseLayoutElement(raw) {
|
|
|
6463
6602
|
...size !== void 0 ? { size } : {}
|
|
6464
6603
|
};
|
|
6465
6604
|
}
|
|
6466
|
-
function parseLayoutRow(raw) {
|
|
6605
|
+
function parseLayoutRow(raw, options) {
|
|
6467
6606
|
if (raw.type !== "ROW") throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidLayoutStructure, `Expected layout row type "ROW", got "${String(raw.type)}"`);
|
|
6468
6607
|
if (raw.fields !== void 0 && !Array.isArray(raw.fields)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidLayoutStructure, `ROW "fields" must be an array, got ${typeof raw.fields}`);
|
|
6469
6608
|
return {
|
|
6470
6609
|
type: "ROW",
|
|
6471
|
-
fields: (Array.isArray(raw.fields) ? raw.fields : []).map(parseLayoutElement)
|
|
6610
|
+
fields: (Array.isArray(raw.fields) ? raw.fields : []).map((r) => parseLayoutElement(r, options))
|
|
6472
6611
|
};
|
|
6473
6612
|
}
|
|
6474
6613
|
function collectFieldsFromElements(elements) {
|
|
@@ -6490,7 +6629,7 @@ function mergeFieldMaps(target, source) {
|
|
|
6490
6629
|
}
|
|
6491
6630
|
return merged;
|
|
6492
6631
|
}
|
|
6493
|
-
function parseGroupLayoutItem(raw) {
|
|
6632
|
+
function parseGroupLayoutItem(raw, options) {
|
|
6494
6633
|
const code = FieldCode.create(String(raw.code));
|
|
6495
6634
|
const label = String(raw.label ?? "");
|
|
6496
6635
|
const noLabel = typeof raw.noLabel === "boolean" ? raw.noLabel : void 0;
|
|
@@ -6499,7 +6638,7 @@ function parseGroupLayoutItem(raw) {
|
|
|
6499
6638
|
let groupFields = /* @__PURE__ */ new Map();
|
|
6500
6639
|
const layout = [];
|
|
6501
6640
|
for (const r of rawLayout) {
|
|
6502
|
-
const row = parseLayoutRow(r);
|
|
6641
|
+
const row = parseLayoutRow(r, options);
|
|
6503
6642
|
const rowFields = collectFieldsFromElements(row.fields);
|
|
6504
6643
|
groupFields = mergeFieldMaps(groupFields, rowFields);
|
|
6505
6644
|
layout.push(row);
|
|
@@ -6525,11 +6664,11 @@ function parseGroupLayoutItem(raw) {
|
|
|
6525
6664
|
fields: groupFields
|
|
6526
6665
|
};
|
|
6527
6666
|
}
|
|
6528
|
-
function parseSubtableLayoutItem(raw) {
|
|
6667
|
+
function parseSubtableLayoutItem(raw, options) {
|
|
6529
6668
|
const code = FieldCode.create(String(raw.code));
|
|
6530
6669
|
const label = String(raw.label ?? "");
|
|
6531
6670
|
const noLabel = typeof raw.noLabel === "boolean" ? raw.noLabel : void 0;
|
|
6532
|
-
const elements = (Array.isArray(raw.fields) ? raw.fields : []).map(parseLayoutElement);
|
|
6671
|
+
const elements = (Array.isArray(raw.fields) ? raw.fields : []).map((r) => parseLayoutElement(r, options));
|
|
6533
6672
|
const subFields = collectFieldsFromElements(elements);
|
|
6534
6673
|
const subtableDef = {
|
|
6535
6674
|
code,
|
|
@@ -6552,23 +6691,23 @@ function parseSubtableLayoutItem(raw) {
|
|
|
6552
6691
|
fields: allFields
|
|
6553
6692
|
};
|
|
6554
6693
|
}
|
|
6555
|
-
function parseLayoutItem(raw) {
|
|
6694
|
+
function parseLayoutItem(raw, options) {
|
|
6556
6695
|
const type = String(raw.type);
|
|
6557
6696
|
switch (type) {
|
|
6558
6697
|
case "ROW": {
|
|
6559
|
-
const row = parseLayoutRow(raw);
|
|
6698
|
+
const row = parseLayoutRow(raw, options);
|
|
6560
6699
|
return {
|
|
6561
6700
|
item: row,
|
|
6562
6701
|
fields: collectFieldsFromElements(row.fields)
|
|
6563
6702
|
};
|
|
6564
6703
|
}
|
|
6565
|
-
case "GROUP": return parseGroupLayoutItem(raw);
|
|
6566
|
-
case "SUBTABLE": return parseSubtableLayoutItem(raw);
|
|
6704
|
+
case "GROUP": return parseGroupLayoutItem(raw, options);
|
|
6705
|
+
case "SUBTABLE": return parseSubtableLayoutItem(raw, options);
|
|
6567
6706
|
case "REFERENCE_TABLE": {
|
|
6568
6707
|
const code = FieldCode.create(String(raw.code));
|
|
6569
6708
|
const label = String(raw.label ?? "");
|
|
6570
6709
|
const noLabel = typeof raw.noLabel === "boolean" ? raw.noLabel : void 0;
|
|
6571
|
-
const fieldDef = parseFieldDefinitionFromFlat(raw);
|
|
6710
|
+
const fieldDef = parseFieldDefinitionFromFlat(raw, options);
|
|
6572
6711
|
const allFields = /* @__PURE__ */ new Map();
|
|
6573
6712
|
allFields.set(code, fieldDef);
|
|
6574
6713
|
return {
|
|
@@ -6584,7 +6723,7 @@ function parseLayoutItem(raw) {
|
|
|
6584
6723
|
default: throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidLayoutStructure, `Unknown layout item type: "${type}"`);
|
|
6585
6724
|
}
|
|
6586
6725
|
}
|
|
6587
|
-
const SchemaParser = { parse: (parsed) => {
|
|
6726
|
+
const SchemaParser = { parse: (parsed, options = SCHEMA_FILE_OPTIONS) => {
|
|
6588
6727
|
if (!isRecord(parsed)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidSchemaStructure, "Schema must be an object");
|
|
6589
6728
|
const obj = parsed;
|
|
6590
6729
|
if ("fields" in obj && !("layout" in obj)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidSchemaStructure, "\"fields\" key detected. Schema format has changed. Please use \"capture\" to generate a new format schema.");
|
|
@@ -6595,7 +6734,7 @@ const SchemaParser = { parse: (parsed) => {
|
|
|
6595
6734
|
for (let i = 0; i < rawLayout.length; i++) {
|
|
6596
6735
|
const rawItem = rawLayout[i];
|
|
6597
6736
|
if (!isRecord(rawItem)) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidLayoutStructure, `Layout item at index ${i} must be an object`);
|
|
6598
|
-
const result = parseLayoutItem(rawItem);
|
|
6737
|
+
const result = parseLayoutItem(rawItem, options);
|
|
6599
6738
|
layout.push(result.item);
|
|
6600
6739
|
fieldMap = mergeFieldMaps(fieldMap, result.fields);
|
|
6601
6740
|
}
|
|
@@ -9426,7 +9565,8 @@ async function detectDiff({ container, input }) {
|
|
|
9426
9565
|
const result = await container.schemaStorage.get();
|
|
9427
9566
|
if (!result.exists) throw new ValidationError(ValidationErrorCode.InvalidInput, "Schema file not found");
|
|
9428
9567
|
const schema = parseSchemaText(container.configCodec, result.content);
|
|
9429
|
-
const [
|
|
9568
|
+
const [remoteFields, currentLayout] = await Promise.all([container.formConfigurator.getFields(target), container.formConfigurator.getLayout(target)]);
|
|
9569
|
+
const currentFields = projectRemoteFields(remoteFields, schema.fields);
|
|
9430
9570
|
const diff = DiffDetector.detect(schema, currentFields);
|
|
9431
9571
|
const enrichedCurrentLayout = enrichLayoutWithFields(currentLayout, currentFields);
|
|
9432
9572
|
const hasLayoutChanges = DiffDetector.detectLayoutChanges(schema.layout, enrichedCurrentLayout);
|
|
@@ -11329,12 +11469,30 @@ const SchemaSerializer = { serialize: (layout, fields) => {
|
|
|
11329
11469
|
} };
|
|
11330
11470
|
//#endregion
|
|
11331
11471
|
//#region src/core/application/formSchema/captureSchema.ts
|
|
11472
|
+
/**
|
|
11473
|
+
* The existing schema file, which decides how the captured related apps are
|
|
11474
|
+
* referred to; `undefined` when there is none or it cannot be parsed.
|
|
11475
|
+
*/
|
|
11476
|
+
function readReferenceSchema(container, existing) {
|
|
11477
|
+
if (!existing.exists) return void 0;
|
|
11478
|
+
try {
|
|
11479
|
+
return parseSchemaText(container.configCodec, existing.content);
|
|
11480
|
+
} catch (error) {
|
|
11481
|
+
if (isValidationError(error)) return void 0;
|
|
11482
|
+
throw error;
|
|
11483
|
+
}
|
|
11484
|
+
}
|
|
11332
11485
|
async function captureSchema({ container }) {
|
|
11333
|
-
const [
|
|
11486
|
+
const [remoteFields, currentLayout, existingResult] = await Promise.all([
|
|
11487
|
+
container.formConfigurator.getFields(),
|
|
11488
|
+
container.formConfigurator.getLayout(),
|
|
11489
|
+
container.schemaStorage.get()
|
|
11490
|
+
]);
|
|
11491
|
+
const currentFields = projectRemoteFields(remoteFields, readReferenceSchema(container, existingResult)?.fields);
|
|
11334
11492
|
const enrichedLayout = enrichLayoutWithFields(currentLayout, currentFields);
|
|
11335
11493
|
return {
|
|
11336
11494
|
schemaText: stringifyConfig(container.configCodec, SchemaSerializer.serialize(enrichedLayout, currentFields)),
|
|
11337
|
-
hasExistingSchema:
|
|
11495
|
+
hasExistingSchema: existingResult.exists
|
|
11338
11496
|
};
|
|
11339
11497
|
}
|
|
11340
11498
|
//#endregion
|
|
@@ -11938,6 +12096,169 @@ var capture_default$11 = define({
|
|
|
11938
12096
|
}
|
|
11939
12097
|
});
|
|
11940
12098
|
//#endregion
|
|
12099
|
+
//#region src/core/domain/appRevision/services/deployStateEvaluator.ts
|
|
12100
|
+
const DeployStateEvaluator = {
|
|
12101
|
+
/** Derives the {@link DeployState} from the revisions of both generations. */
|
|
12102
|
+
evaluate: ({ preview, published }) => {
|
|
12103
|
+
if (published.kind === "neverDeployed") return {
|
|
12104
|
+
kind: "neverDeployed",
|
|
12105
|
+
previewRevision: preview
|
|
12106
|
+
};
|
|
12107
|
+
if (published.revision === preview) return {
|
|
12108
|
+
kind: "upToDate",
|
|
12109
|
+
revision: preview
|
|
12110
|
+
};
|
|
12111
|
+
return {
|
|
12112
|
+
kind: "pending",
|
|
12113
|
+
previewRevision: preview,
|
|
12114
|
+
publishedRevision: published.revision
|
|
12115
|
+
};
|
|
12116
|
+
},
|
|
12117
|
+
/** True when a deploy would publish something that is waiting in preview. */
|
|
12118
|
+
hasUndeployedChanges: (state) => state.kind !== "upToDate"
|
|
12119
|
+
};
|
|
12120
|
+
//#endregion
|
|
12121
|
+
//#region src/core/application/appRevision/checkDeployState.ts
|
|
12122
|
+
/** Tells whether the app's preview holds changes a deploy would publish. */
|
|
12123
|
+
async function checkDeployState({ container }) {
|
|
12124
|
+
const generations = await container.appRevisionGenerationsReader.read();
|
|
12125
|
+
return DeployStateEvaluator.evaluate(generations);
|
|
12126
|
+
}
|
|
12127
|
+
//#endregion
|
|
12128
|
+
//#region src/core/adapters/kintone/appRevisionGenerationsReader.ts
|
|
12129
|
+
const KINTONE_APP_NOT_FOUND_CODE = "GAIA_AP01";
|
|
12130
|
+
/**
|
|
12131
|
+
* Reads both generations' revisions through `getAppAcl`.
|
|
12132
|
+
*
|
|
12133
|
+
* The app revision is shared by every settings endpoint, so any getter would
|
|
12134
|
+
* do. `getAppAcl` is documented to need only app management permission for
|
|
12135
|
+
* both generations, whereas published getters such as `getFormFields`,
|
|
12136
|
+
* `getViews` and `getAppSettings` are documented to need record view (or add)
|
|
12137
|
+
* permission; an API token with app management permission alone is refused
|
|
12138
|
+
* by several of them (`GAIA_NO01`).
|
|
12139
|
+
*/
|
|
12140
|
+
var KintoneAppRevisionGenerationsReader = class {
|
|
12141
|
+
client;
|
|
12142
|
+
appId;
|
|
12143
|
+
constructor(client, appId) {
|
|
12144
|
+
this.client = client;
|
|
12145
|
+
this.appId = appId;
|
|
12146
|
+
}
|
|
12147
|
+
async read() {
|
|
12148
|
+
const preview = await this.readPreview();
|
|
12149
|
+
const published = await this.readPublished();
|
|
12150
|
+
if (published.kind === "neverDeployed") await this.readPreview();
|
|
12151
|
+
return {
|
|
12152
|
+
preview,
|
|
12153
|
+
published
|
|
12154
|
+
};
|
|
12155
|
+
}
|
|
12156
|
+
async readPreview() {
|
|
12157
|
+
try {
|
|
12158
|
+
return await this.fetchRevision(true);
|
|
12159
|
+
} catch (error) {
|
|
12160
|
+
throw wrapKintoneError(error, "Failed to get the preview app revision");
|
|
12161
|
+
}
|
|
12162
|
+
}
|
|
12163
|
+
async readPublished() {
|
|
12164
|
+
try {
|
|
12165
|
+
return {
|
|
12166
|
+
kind: "deployed",
|
|
12167
|
+
revision: await this.fetchRevision(false)
|
|
12168
|
+
};
|
|
12169
|
+
} catch (error) {
|
|
12170
|
+
if (error instanceof KintoneRestAPIError && error.code === KINTONE_APP_NOT_FOUND_CODE) return { kind: "neverDeployed" };
|
|
12171
|
+
throw wrapKintoneError(error, "Failed to get the published app revision");
|
|
12172
|
+
}
|
|
12173
|
+
}
|
|
12174
|
+
async fetchRevision(preview) {
|
|
12175
|
+
const { revision } = await this.client.app.getAppAcl({
|
|
12176
|
+
app: this.appId,
|
|
12177
|
+
preview
|
|
12178
|
+
});
|
|
12179
|
+
if (!revision) throw new SystemError(SystemErrorCode.ExternalApiError, "kintone API did not return an app revision");
|
|
12180
|
+
return revision;
|
|
12181
|
+
}
|
|
12182
|
+
};
|
|
12183
|
+
//#endregion
|
|
12184
|
+
//#region src/core/application/container/deployStateCli.ts
|
|
12185
|
+
function createDeployStateCliContainer(config) {
|
|
12186
|
+
return { appRevisionGenerationsReader: new KintoneAppRevisionGenerationsReader(config.client ?? createKintoneClient(config), config.appId) };
|
|
12187
|
+
}
|
|
12188
|
+
//#endregion
|
|
12189
|
+
//#region src/cli/commands/check-pending.ts
|
|
12190
|
+
const checkPendingArgs = {
|
|
12191
|
+
domain: kintoneArgs.domain,
|
|
12192
|
+
username: kintoneArgs.username,
|
|
12193
|
+
password: kintoneArgs.password,
|
|
12194
|
+
"api-token": kintoneArgs["api-token"],
|
|
12195
|
+
"app-id": kintoneArgs["app-id"],
|
|
12196
|
+
"guest-space-id": kintoneArgs["guest-space-id"],
|
|
12197
|
+
...multiAppArgs
|
|
12198
|
+
};
|
|
12199
|
+
async function runCheck(config) {
|
|
12200
|
+
const container = createDeployStateCliContainer(config);
|
|
12201
|
+
const s = p.spinner();
|
|
12202
|
+
s.start("Checking for undeployed changes...");
|
|
12203
|
+
let state;
|
|
12204
|
+
try {
|
|
12205
|
+
state = await checkDeployState({ container });
|
|
12206
|
+
} catch (error) {
|
|
12207
|
+
s.stop("Check failed.");
|
|
12208
|
+
throw error;
|
|
12209
|
+
}
|
|
12210
|
+
s.stop("Check complete.");
|
|
12211
|
+
printDeployState(state);
|
|
12212
|
+
return state;
|
|
12213
|
+
}
|
|
12214
|
+
async function runSingleCheck(config) {
|
|
12215
|
+
const state = await runCheck(config);
|
|
12216
|
+
if (DeployStateEvaluator.hasUndeployedChanges(state)) process.exitCode = 1;
|
|
12217
|
+
}
|
|
12218
|
+
var check_pending_default = define({
|
|
12219
|
+
name: "check-pending",
|
|
12220
|
+
description: "Check whether the kintone app has undeployed changes that a deploy would publish",
|
|
12221
|
+
args: checkPendingArgs,
|
|
12222
|
+
run: async (ctx) => {
|
|
12223
|
+
try {
|
|
12224
|
+
const values = ctx.values;
|
|
12225
|
+
await routeMultiApp(values, {
|
|
12226
|
+
singleLegacy: async () => {
|
|
12227
|
+
await runSingleCheck(resolveConfig(values));
|
|
12228
|
+
},
|
|
12229
|
+
singleApp: async (app, projectConfig) => {
|
|
12230
|
+
await runSingleCheck(resolveAppCliConfig(app, projectConfig, values));
|
|
12231
|
+
},
|
|
12232
|
+
multiApp: async (plan, projectConfig) => {
|
|
12233
|
+
const appsWithUndeployedChanges = [];
|
|
12234
|
+
try {
|
|
12235
|
+
await runMultiAppWithHeaders(plan, async (app) => {
|
|
12236
|
+
const state = await runCheck(resolveAppCliConfig(app, projectConfig, values));
|
|
12237
|
+
if (DeployStateEvaluator.hasUndeployedChanges(state)) appsWithUndeployedChanges.push(app.name);
|
|
12238
|
+
});
|
|
12239
|
+
} catch (error) {
|
|
12240
|
+
printAppsWithUndeployedChanges(appsWithUndeployedChanges);
|
|
12241
|
+
throw error;
|
|
12242
|
+
}
|
|
12243
|
+
if (appsWithUndeployedChanges.length > 0) {
|
|
12244
|
+
printAppsWithUndeployedChanges(appsWithUndeployedChanges);
|
|
12245
|
+
process.exitCode = 1;
|
|
12246
|
+
return;
|
|
12247
|
+
}
|
|
12248
|
+
p.log.success("No undeployed changes in any app.");
|
|
12249
|
+
},
|
|
12250
|
+
noAppSelected: async (projectConfig) => {
|
|
12251
|
+
printAvailableApps(projectConfig);
|
|
12252
|
+
p.log.error(`No app was checked. Pass ${pc.cyan("--app <name>")} or ${pc.cyan("--all")} to check for undeployed changes.`);
|
|
12253
|
+
process.exitCode = 1;
|
|
12254
|
+
}
|
|
12255
|
+
});
|
|
12256
|
+
} catch (error) {
|
|
12257
|
+
handleCliError(error);
|
|
12258
|
+
}
|
|
12259
|
+
}
|
|
12260
|
+
});
|
|
12261
|
+
//#endregion
|
|
11941
12262
|
//#region src/cli/customizeConfig.ts
|
|
11942
12263
|
const CUSTOMIZE_STATE_FILE = "customize.yaml";
|
|
11943
12264
|
const customizeArgs = {
|
|
@@ -15597,6 +15918,7 @@ function resolveFieldEntry(entry, resolution) {
|
|
|
15597
15918
|
}
|
|
15598
15919
|
//#endregion
|
|
15599
15920
|
//#region src/core/domain/formSchema/services/schemaStateParser.ts
|
|
15921
|
+
const STATE_OPTIONS = { relatedAppWithBothKeys: "app" };
|
|
15600
15922
|
/**
|
|
15601
15923
|
* Parses pre-parsed (codec-decoded) data into a {@link SchemaState}.
|
|
15602
15924
|
*
|
|
@@ -15607,7 +15929,9 @@ function resolveFieldEntry(entry, resolution) {
|
|
|
15607
15929
|
* `revision` field alongside the captured `layout`. revision is now stored
|
|
15608
15930
|
* separately in `state/<appName>/revision.yaml`, so any residual top-level
|
|
15609
15931
|
* `revision` is stripped and ignored here — the snapshot is parsed from the
|
|
15610
|
-
* remainder.
|
|
15932
|
+
* remainder. Older state files also hold a lookup's `relatedApp` as both `app`
|
|
15933
|
+
* and `code`; it is read by `app` (see {@link SchemaParseOptions}). The domain
|
|
15934
|
+
* layer does not depend on YAML; the application layer
|
|
15611
15935
|
* handles codec decoding before calling this.
|
|
15612
15936
|
*/
|
|
15613
15937
|
const SchemaStateParser = { parse: (parsed) => {
|
|
@@ -15615,7 +15939,7 @@ const SchemaStateParser = { parse: (parsed) => {
|
|
|
15615
15939
|
const { revision: _legacyRevision, ...withoutRevision } = parsed;
|
|
15616
15940
|
return withoutRevision;
|
|
15617
15941
|
})() : parsed;
|
|
15618
|
-
return { schema: SchemaParser.parse(rest) };
|
|
15942
|
+
return { schema: SchemaParser.parse(rest, STATE_OPTIONS) };
|
|
15619
15943
|
} };
|
|
15620
15944
|
//#endregion
|
|
15621
15945
|
//#region src/core/domain/formSchema/services/schemaStateSerializer.ts
|
|
@@ -15672,14 +15996,20 @@ async function loadThreeWayInputs(container) {
|
|
|
15672
15996
|
container.formConfigurator.getRevision()
|
|
15673
15997
|
]);
|
|
15674
15998
|
const local = localResult.exists ? parseSchemaText(container.configCodec, localResult.content) : void 0;
|
|
15675
|
-
const
|
|
15999
|
+
const projectedRemoteFields = projectRemoteFields(remoteFields, local?.fields);
|
|
16000
|
+
const enrichedRemoteLayout = enrichLayoutWithFields(remoteLayout, projectedRemoteFields);
|
|
16001
|
+
const remote = Schema.create(projectedRemoteFields, enrichedRemoteLayout);
|
|
15676
16002
|
return {
|
|
15677
|
-
state,
|
|
16003
|
+
state: state === void 0 ? void 0 : { schema: restateBase(state.schema, remoteFields, local) },
|
|
15678
16004
|
local,
|
|
15679
|
-
remote
|
|
16005
|
+
remote,
|
|
15680
16006
|
remoteRevision
|
|
15681
16007
|
};
|
|
15682
16008
|
}
|
|
16009
|
+
function restateBase(base, remoteFields, local) {
|
|
16010
|
+
const fields = restateBaseFields(base.fields, remoteFields, local?.fields);
|
|
16011
|
+
return Schema.create(fields, enrichLayoutWithFields(base.layout, fields));
|
|
16012
|
+
}
|
|
15683
16013
|
//#endregion
|
|
15684
16014
|
//#region src/core/application/formSchema/pullSchema.ts
|
|
15685
16015
|
function serializeSchema(container, schema) {
|
|
@@ -19511,6 +19841,7 @@ await cli(process.argv.slice(2), main, {
|
|
|
19511
19841
|
diff: diff_default$9,
|
|
19512
19842
|
pull: pull_default$5,
|
|
19513
19843
|
push: push_default$6,
|
|
19844
|
+
"check-pending": check_pending_default,
|
|
19514
19845
|
schema: schema_default,
|
|
19515
19846
|
seed: seed_default,
|
|
19516
19847
|
customize: customize_default,
|