@magmonium/cli 0.10.23 → 0.10.26
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/bin/cli.js +3 -0
- package/bin/commands/findings.js +263 -0
- package/bin/commands/gesture.js +2 -0
- package/bin/commands/validate.js +8 -3
- package/codegen/control-configs.json +4 -0
- package/codegen/finding-catalog.js +310 -0
- package/codegen/gesture-catalog.js +3339 -265
- package/codegen/index.js +38 -2
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (
|
|
6
|
+
var __export = (target2, all) => {
|
|
7
7
|
for (var name in all)
|
|
8
|
-
__defProp(
|
|
8
|
+
__defProp(target2, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -163,7 +163,7 @@ var SCORE_SET_SEED = [
|
|
|
163
163
|
{ key: "volume", label: "volume", value: 41 }
|
|
164
164
|
];
|
|
165
165
|
function addControlTree(input) {
|
|
166
|
-
const { type, parentId, genId:
|
|
166
|
+
const { type, parentId, genId: genId3 } = input;
|
|
167
167
|
const currentMap = input.controlMap;
|
|
168
168
|
const seeded = [];
|
|
169
169
|
const targetParent = parentId ? currentMap[parentId] : void 0;
|
|
@@ -174,7 +174,7 @@ function addControlTree(input) {
|
|
|
174
174
|
return { refusal: "router-outlet-refused", seeded };
|
|
175
175
|
}
|
|
176
176
|
const bornScreenBranch = type === import_codegen3.ControlType.VARIANT_BRANCH && input.screenKind !== "feature";
|
|
177
|
-
const id =
|
|
177
|
+
const id = genId3();
|
|
178
178
|
const variants = (0, import_codegen3.canCarryVariants)(type) ? (0, import_codegen3.variantsForNewControl)(
|
|
179
179
|
currentMap,
|
|
180
180
|
parentId,
|
|
@@ -224,7 +224,7 @@ function addControlTree(input) {
|
|
|
224
224
|
if (type === import_codegen3.ControlType.STAT) {
|
|
225
225
|
const slotIds = [import_codegen3.ControlType.STAT_VALUE, import_codegen3.ControlType.STAT_CORNER].map(
|
|
226
226
|
(slotType) => {
|
|
227
|
-
const slotId =
|
|
227
|
+
const slotId = genId3();
|
|
228
228
|
updatedControlMap[slotId] = {
|
|
229
229
|
id: slotId,
|
|
230
230
|
type: slotType,
|
|
@@ -240,7 +240,7 @@ function addControlTree(input) {
|
|
|
240
240
|
}
|
|
241
241
|
if (type === import_codegen3.ControlType.SCORE_SET) {
|
|
242
242
|
const itemIds = SCORE_SET_SEED.map((configs) => {
|
|
243
|
-
const itemId =
|
|
243
|
+
const itemId = genId3();
|
|
244
244
|
updatedControlMap[itemId] = {
|
|
245
245
|
id: itemId,
|
|
246
246
|
type: import_codegen3.ControlType.SCORE_SET_ITEM,
|
|
@@ -258,8 +258,8 @@ function addControlTree(input) {
|
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
260
|
if (type === import_codegen3.ControlType.SECTION_TABLE) {
|
|
261
|
-
const repeatId =
|
|
262
|
-
const rowId =
|
|
261
|
+
const repeatId = genId3();
|
|
262
|
+
const rowId = genId3();
|
|
263
263
|
updatedControlMap[repeatId] = {
|
|
264
264
|
id: repeatId,
|
|
265
265
|
type: import_codegen3.ControlType.REPEAT,
|
|
@@ -270,7 +270,7 @@ function addControlTree(input) {
|
|
|
270
270
|
};
|
|
271
271
|
Object.assign(
|
|
272
272
|
updatedControlMap,
|
|
273
|
-
(0, import_codegen3.seedSectionTableRow)(rowId, repeatId, import_codegen3.SECTION_TABLE_SEED_COLUMNS,
|
|
273
|
+
(0, import_codegen3.seedSectionTableRow)(rowId, repeatId, import_codegen3.SECTION_TABLE_SEED_COLUMNS, genId3)
|
|
274
274
|
);
|
|
275
275
|
updatedControlMap[id] = { ...newControl, childrens: [repeatId] };
|
|
276
276
|
seeded.push(import_codegen3.ControlType.REPEAT, import_codegen3.ControlType.SECTION_TABLE_ROW);
|
|
@@ -280,7 +280,7 @@ function addControlTree(input) {
|
|
|
280
280
|
const columns = (0, import_codegen3.toSectionTableColumns)(
|
|
281
281
|
table?.configs?.[import_codegen3.SECTION_TABLE_COLUMNS_KEY]
|
|
282
282
|
);
|
|
283
|
-
const seededRow = (0, import_codegen3.seedSectionTableRow)(id, parentId, columns.length,
|
|
283
|
+
const seededRow = (0, import_codegen3.seedSectionTableRow)(id, parentId, columns.length, genId3);
|
|
284
284
|
Object.assign(updatedControlMap, seededRow);
|
|
285
285
|
if (columns.length) seeded.push(import_codegen3.ControlType.SECTION_TABLE_CELL);
|
|
286
286
|
}
|
|
@@ -353,8 +353,8 @@ function dropControlSubtree(input) {
|
|
|
353
353
|
deleteRecursive(id);
|
|
354
354
|
let clearedSubmitTargets = 0;
|
|
355
355
|
for (const ctrl of Object.values(updatedControlMap)) {
|
|
356
|
-
const
|
|
357
|
-
if (typeof
|
|
356
|
+
const target2 = ctrl.configs?.[import_codegen3.SUBMIT_TARGET_KEY];
|
|
357
|
+
if (typeof target2 !== "string" || updatedControlMap[target2]) continue;
|
|
358
358
|
clearedSubmitTargets++;
|
|
359
359
|
updatedControlMap[ctrl.id] = {
|
|
360
360
|
...ctrl,
|
|
@@ -484,9 +484,9 @@ var controlMove = {
|
|
|
484
484
|
siblingNeighbour(controlMap, rootControlIds, controlId, direction),
|
|
485
485
|
direction === "up" ? "before" : "after"
|
|
486
486
|
] : out ? [controlMap[controlId].parentId, "after"] : [targetId, position ?? "inside"];
|
|
487
|
-
const [
|
|
488
|
-
if (!
|
|
489
|
-
const result = applyMove(controlMap, rootControlIds, controlId,
|
|
487
|
+
const [target2, at] = aim;
|
|
488
|
+
if (!target2) return refuse("move-refused");
|
|
489
|
+
const result = applyMove(controlMap, rootControlIds, controlId, target2, at);
|
|
490
490
|
if (!result) return refuse("move-refused");
|
|
491
491
|
const patch = movePatch(result, controlId);
|
|
492
492
|
const rebased = patch.controlMap ?? result.controlMap;
|
|
@@ -634,6 +634,13 @@ var OUTPUT_MAP_FIELDS = [
|
|
|
634
634
|
"outputCalls",
|
|
635
635
|
"outputArms"
|
|
636
636
|
];
|
|
637
|
+
var wiredOutputKeys = (control) => [
|
|
638
|
+
...new Set(
|
|
639
|
+
OUTPUT_MAP_FIELDS.flatMap(
|
|
640
|
+
(field) => Object.keys(control[field] ?? {}).map(import_codegen4.outputArmBaseKey)
|
|
641
|
+
)
|
|
642
|
+
)
|
|
643
|
+
];
|
|
637
644
|
var CLEARED_OUTPUT_WIRING = Object.fromEntries(
|
|
638
645
|
OUTPUT_MAP_FIELDS.map((field) => [field, void 0])
|
|
639
646
|
);
|
|
@@ -731,11 +738,11 @@ function featureReachEdges(maps, screens) {
|
|
|
731
738
|
for (const screen of screens) {
|
|
732
739
|
if (!(0, import_codegen5.isFeatureScreen)(screen)) continue;
|
|
733
740
|
for (const id of embeddedScreenIds(maps[screen.id] ?? {})) {
|
|
734
|
-
const
|
|
735
|
-
if (!
|
|
736
|
-
if (
|
|
741
|
+
const target2 = byId.get(id);
|
|
742
|
+
if (!target2 || !(0, import_codegen5.isFeatureScreen)(target2)) continue;
|
|
743
|
+
if (target2.featureId === screen.featureId) continue;
|
|
737
744
|
const reached = edges.get(screen.featureId) ?? /* @__PURE__ */ new Set();
|
|
738
|
-
reached.add(
|
|
745
|
+
reached.add(target2.featureId);
|
|
739
746
|
edges.set(screen.featureId, reached);
|
|
740
747
|
}
|
|
741
748
|
}
|
|
@@ -761,6 +768,60 @@ function screensEmbedding(screenId, maps) {
|
|
|
761
768
|
([, controlMap]) => embeddedScreenIds(controlMap).includes(screenId)
|
|
762
769
|
).map(([hostId]) => hostId).sort();
|
|
763
770
|
}
|
|
771
|
+
function screenEmbedProblems(host, maps, screens) {
|
|
772
|
+
const byId = new Map(screens.map((screen) => [screen.id, screen]));
|
|
773
|
+
const problems = [];
|
|
774
|
+
const featureEdges = featureReachEdges(maps, screens);
|
|
775
|
+
for (const control of Object.values(maps[host.id] ?? {})) {
|
|
776
|
+
if (!isScreenControl(control)) continue;
|
|
777
|
+
const target2 = byId.get(control.screenId);
|
|
778
|
+
if (!target2) {
|
|
779
|
+
problems.push({
|
|
780
|
+
kind: "missing-screen",
|
|
781
|
+
controlId: control.id,
|
|
782
|
+
screenId: control.screenId
|
|
783
|
+
});
|
|
784
|
+
continue;
|
|
785
|
+
}
|
|
786
|
+
if (!(0, import_codegen5.canEmbedScreen)(host, target2)) {
|
|
787
|
+
problems.push({
|
|
788
|
+
kind: "illegal-target",
|
|
789
|
+
controlId: control.id,
|
|
790
|
+
screenId: target2.id
|
|
791
|
+
});
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
if ((0, import_codegen5.isFeatureScreen)(host) && (0, import_codegen5.isFeatureScreen)(target2) && wouldCycleFeatures(host.featureId, target2.featureId, featureEdges)) {
|
|
795
|
+
problems.push({
|
|
796
|
+
kind: "feature-cycle",
|
|
797
|
+
controlId: control.id,
|
|
798
|
+
screenId: target2.id,
|
|
799
|
+
featureId: target2.featureId
|
|
800
|
+
});
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
const bound = control.screenInputs ?? {};
|
|
804
|
+
for (const input of Object.values(target2.inputs ?? {})) {
|
|
805
|
+
if (!input.required) continue;
|
|
806
|
+
const binding = bound[input.id];
|
|
807
|
+
if (!binding || binding.kind === "output") {
|
|
808
|
+
problems.push({
|
|
809
|
+
kind: "required-unbound",
|
|
810
|
+
controlId: control.id,
|
|
811
|
+
screenId: target2.id,
|
|
812
|
+
input: input.name
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
for (const screenId of duplicateFeatureEmbeds(host.id, maps, screens)) {
|
|
818
|
+
problems.push({ kind: "duplicate-feature-screen", screenId });
|
|
819
|
+
}
|
|
820
|
+
if (reachableScreenIds(host.id, maps).has(host.id)) {
|
|
821
|
+
problems.push({ kind: "cycle", screenId: host.id });
|
|
822
|
+
}
|
|
823
|
+
return problems;
|
|
824
|
+
}
|
|
764
825
|
|
|
765
826
|
// apps/m-one-ui/src/app/pages/design/lib/gestures/config-gestures.ts
|
|
766
827
|
var mergeConfigs = (current, incoming) => {
|
|
@@ -856,7 +917,7 @@ function embedTargetsFor(host, screens, allMaps, hostControlMap, exceptControlId
|
|
|
856
917
|
}
|
|
857
918
|
const featureEdges = featureReachEdges(maps, screens);
|
|
858
919
|
const targets = screens.filter(
|
|
859
|
-
(
|
|
920
|
+
(target2) => (0, import_codegen6.canEmbedScreen)(host, target2) && !wouldCycle(host.id, target2.id, maps) && !((0, import_codegen6.isFeatureScreen)(host) && (0, import_codegen6.isFeatureScreen)(target2) && wouldCycleFeatures(host.featureId, target2.featureId, featureEdges))
|
|
860
921
|
);
|
|
861
922
|
if (!exceptControlId) return targets;
|
|
862
923
|
const control = hostControlMap[exceptControlId];
|
|
@@ -867,12 +928,12 @@ function embedTargetsFor(host, screens, allMaps, hostControlMap, exceptControlId
|
|
|
867
928
|
new Set(duplicateFeatureEmbeds(screen.id, maps, screens))
|
|
868
929
|
])
|
|
869
930
|
);
|
|
870
|
-
return targets.filter((
|
|
931
|
+
return targets.filter((target2) => {
|
|
871
932
|
const replaced = {
|
|
872
933
|
...maps,
|
|
873
934
|
[host.id]: {
|
|
874
935
|
...maps[host.id],
|
|
875
|
-
[exceptControlId]: { ...control, screenId:
|
|
936
|
+
[exceptControlId]: { ...control, screenId: target2.id }
|
|
876
937
|
}
|
|
877
938
|
};
|
|
878
939
|
return screens.every(
|
|
@@ -963,10 +1024,10 @@ var screenControlTarget = {
|
|
|
963
1024
|
const control = slot.state.controlMap[controlId];
|
|
964
1025
|
if (!control || control.type !== import_codegen6.ControlType.SCREEN)
|
|
965
1026
|
return refuse2("not-a-screen-control");
|
|
966
|
-
const
|
|
967
|
-
if (!
|
|
1027
|
+
const target2 = ctx.screenOf(targetScreenId);
|
|
1028
|
+
if (!target2) return refuse2("target-missing");
|
|
968
1029
|
if (control.screenId === targetScreenId) return refuse2("target-unchanged");
|
|
969
|
-
if ((0, import_codegen6.embedShapeBlocked)(slot.meta,
|
|
1030
|
+
if ((0, import_codegen6.embedShapeBlocked)(slot.meta, target2.meta))
|
|
970
1031
|
return refuse2("embed-shape-blocked");
|
|
971
1032
|
const screens = ctx.source.screens.map(({ meta }) => meta);
|
|
972
1033
|
const maps = Object.fromEntries(
|
|
@@ -976,7 +1037,7 @@ var screenControlTarget = {
|
|
|
976
1037
|
const allowed = embedTargetsFor(slot.meta, screens, maps, slot.state.controlMap, except);
|
|
977
1038
|
if (!allowed.some(({ id }) => id === targetScreenId))
|
|
978
1039
|
return refuse2("embed-refused", {
|
|
979
|
-
why: (0, import_codegen6.canEmbedScreen)(slot.meta,
|
|
1040
|
+
why: (0, import_codegen6.canEmbedScreen)(slot.meta, target2.meta) ? "cycle-or-duplicate" : "direction"
|
|
980
1041
|
});
|
|
981
1042
|
return {
|
|
982
1043
|
ok: true,
|
|
@@ -1349,6 +1410,15 @@ var CODE_AREA_ROOTS = [
|
|
|
1349
1410
|
];
|
|
1350
1411
|
|
|
1351
1412
|
// apps/m-one-ui/src/app/pages/design/lib/function-register.ts
|
|
1413
|
+
var everyFunction = (appFunctions, features) => [
|
|
1414
|
+
...(0, import_codegen11.listFunctions)(appFunctions).map((fn) => ({ fn })),
|
|
1415
|
+
...(0, import_codegen11.listFeatures)(features).flatMap(
|
|
1416
|
+
(feature) => (0, import_codegen11.listFunctions)(feature.functions).map((fn) => ({
|
|
1417
|
+
fn,
|
|
1418
|
+
featureId: feature.id
|
|
1419
|
+
}))
|
|
1420
|
+
)
|
|
1421
|
+
];
|
|
1352
1422
|
var canonical = (value) => {
|
|
1353
1423
|
if (Array.isArray(value)) return value.map(canonical);
|
|
1354
1424
|
if (!value || typeof value !== "object") return value;
|
|
@@ -1365,7 +1435,7 @@ var looseSignatureKey = (fn) => JSON.stringify(
|
|
|
1365
1435
|
fn.returnAsync === true
|
|
1366
1436
|
])
|
|
1367
1437
|
);
|
|
1368
|
-
var standsInFor = (candidate,
|
|
1438
|
+
var standsInFor = (candidate, target2) => looseSignatureKey(candidate) === looseSignatureKey(target2) && target2.params.every(
|
|
1369
1439
|
(param, index) => param.acceptsUndefined !== true || candidate.params[index]?.acceptsUndefined === true
|
|
1370
1440
|
);
|
|
1371
1441
|
var reachesHolders = (candidate, holders) => !candidate.featureId || holders.every((holder) => holder.featureId === candidate.featureId);
|
|
@@ -1611,8 +1681,8 @@ function screenMoveBlockers(screen, featureId, maps, screens, navMap) {
|
|
|
1611
1681
|
const navIds = (0, import_codegen13.navsReferencingScreen)(navMap, screen.id, "component");
|
|
1612
1682
|
if (navIds.length) blockers.push({ kind: "nav-bound", navIds });
|
|
1613
1683
|
const embeds = embeddedScreenIds(maps[screen.id] ?? {}).filter((id) => {
|
|
1614
|
-
const
|
|
1615
|
-
return !!
|
|
1684
|
+
const target2 = byId.get(id);
|
|
1685
|
+
return !!target2 && !(0, import_codegen13.canEmbedScreen)(moved, target2);
|
|
1616
1686
|
});
|
|
1617
1687
|
if (embeds.length) {
|
|
1618
1688
|
blockers.push({ kind: "embeds", screenIds: [...new Set(embeds)].sort() });
|
|
@@ -1741,14 +1811,14 @@ var screenRefile = {
|
|
|
1741
1811
|
notes: [],
|
|
1742
1812
|
patch: { screens: { [screenId]: { ...slot, meta: { ...slot.meta, name } } } }
|
|
1743
1813
|
};
|
|
1744
|
-
const
|
|
1745
|
-
const meta = { ...slot.meta, name, featureId:
|
|
1814
|
+
const target2 = destination;
|
|
1815
|
+
const meta = { ...slot.meta, name, featureId: target2, kind: "feature" };
|
|
1746
1816
|
const nextScreens = screens.map((entry) => entry.id === screenId ? meta : entry);
|
|
1747
1817
|
const features = pruneEmptyFeatures(ctx.source.features, nextScreens);
|
|
1748
1818
|
const pruned = Object.keys(ctx.source.features).filter((id) => !features[id]);
|
|
1749
1819
|
const controlMap = stripUnknownVariants(
|
|
1750
1820
|
slot.state.controlMap,
|
|
1751
|
-
ctx.source.features[
|
|
1821
|
+
ctx.source.features[target2].variants ?? {}
|
|
1752
1822
|
);
|
|
1753
1823
|
const stripped = Object.keys(controlMap).filter(
|
|
1754
1824
|
(id) => controlMap[id] !== slot.state.controlMap[id]
|
|
@@ -1767,223 +1837,3226 @@ var screenRefile = {
|
|
|
1767
1837
|
}
|
|
1768
1838
|
};
|
|
1769
1839
|
|
|
1770
|
-
// apps/m-one-ui/src/app/pages/design/lib/
|
|
1840
|
+
// apps/m-one-ui/src/app/pages/design/lib/gestures/finding-gestures.ts
|
|
1841
|
+
var import_codegen65 = require("./index.js");
|
|
1842
|
+
|
|
1843
|
+
// apps/m-one-ui/src/app/pages/design/lib/finding.ts
|
|
1771
1844
|
var import_codegen15 = require("./index.js");
|
|
1845
|
+
var segment = (part) => encodeURIComponent(String(part)).replace(/%3A/g, ":");
|
|
1846
|
+
var keyOf = (source, kind, ids) => [
|
|
1847
|
+
source,
|
|
1848
|
+
kind,
|
|
1849
|
+
...ids.filter((id) => id !== void 0 && id !== "")
|
|
1850
|
+
].map(segment).join("/");
|
|
1851
|
+
var violationFindingKey = (violation) => keyOf("violation", violation.invariant, violation.id.split("::").slice(1));
|
|
1772
1852
|
|
|
1773
|
-
// apps/m-one-ui/src/app/pages/design/lib/
|
|
1774
|
-
var
|
|
1775
|
-
var
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
interface Object {
|
|
1788
|
-
toString(): string;
|
|
1789
|
-
valueOf(): Object;
|
|
1790
|
-
hasOwnProperty(v: string): boolean;
|
|
1791
|
-
}
|
|
1792
|
-
interface ObjectConstructor {
|
|
1793
|
-
keys(o: object): string[];
|
|
1794
|
-
values<T>(o: { [s: string]: T } | ArrayLike<T>): T[];
|
|
1795
|
-
entries<T>(o: { [s: string]: T } | ArrayLike<T>): [string, T][];
|
|
1796
|
-
fromEntries<T>(entries: Iterable<readonly [PropertyKey, T]>): { [k: string]: T };
|
|
1797
|
-
assign<T, U>(target: T, source: U): T & U;
|
|
1798
|
-
freeze<T>(o: T): Readonly<T>;
|
|
1853
|
+
// apps/m-one-ui/src/app/pages/design/lib/finding-catalog.ts
|
|
1854
|
+
var CAST = { id: "cast", label: "fix-cast" };
|
|
1855
|
+
var PRUNE = { id: "prune", label: "fix-prune" };
|
|
1856
|
+
var REMOVE = { id: "remove", label: "fix-remove-method" };
|
|
1857
|
+
var isShadowGap = (finding) => finding.source === "gap" && finding.gap.message === "emit-gap-shape-shadowed" && !!finding.gap.anchor && !!finding.gap.methodId;
|
|
1858
|
+
function applyFixesOf(finding) {
|
|
1859
|
+
switch (finding.source) {
|
|
1860
|
+
case "drift":
|
|
1861
|
+
return finding.row.repair === "cast" ? [CAST] : finding.row.repair === "prune" ? [PRUNE] : finding.row.repair === "remove" ? [REMOVE] : [];
|
|
1862
|
+
case "violation":
|
|
1863
|
+
return finding.violation.computedFix ? [{ id: "computed-fix", label: "fix-retype-parameters" }] : finding.violation.routeInputFix ? [{ id: "route-input-fix", label: "fix-route-inputs" }] : [];
|
|
1864
|
+
case "gap":
|
|
1865
|
+
return isShadowGap(finding) ? [CAST] : [];
|
|
1866
|
+
}
|
|
1799
1867
|
}
|
|
1800
|
-
declare var Object: ObjectConstructor;
|
|
1801
1868
|
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
charAt(pos: number): string;
|
|
1805
|
-
charCodeAt(index: number): number;
|
|
1806
|
-
codePointAt(pos: number): number | undefined;
|
|
1807
|
-
concat(...strings: string[]): string;
|
|
1808
|
-
endsWith(searchString: string, endPosition?: number): boolean;
|
|
1809
|
-
includes(searchString: string, position?: number): boolean;
|
|
1810
|
-
indexOf(searchString: string, position?: number): number;
|
|
1811
|
-
lastIndexOf(searchString: string, position?: number): number;
|
|
1812
|
-
localeCompare(that: string): number;
|
|
1813
|
-
match(regexp: string | RegExp): RegExpMatchArray | null;
|
|
1814
|
-
normalize(form?: string): string;
|
|
1815
|
-
padEnd(maxLength: number, fillString?: string): string;
|
|
1816
|
-
padStart(maxLength: number, fillString?: string): string;
|
|
1817
|
-
repeat(count: number): string;
|
|
1818
|
-
replace(searchValue: string | RegExp, replaceValue: string): string;
|
|
1819
|
-
replaceAll(searchValue: string | RegExp, replaceValue: string): string;
|
|
1820
|
-
search(regexp: string | RegExp): number;
|
|
1821
|
-
slice(start?: number, end?: number): string;
|
|
1822
|
-
split(separator: string | RegExp, limit?: number): string[];
|
|
1823
|
-
startsWith(searchString: string, position?: number): boolean;
|
|
1824
|
-
substring(start: number, end?: number): string;
|
|
1825
|
-
toLowerCase(): string;
|
|
1826
|
-
toUpperCase(): string;
|
|
1827
|
-
toLocaleLowerCase(locales?: string | string[]): string;
|
|
1828
|
-
toLocaleUpperCase(locales?: string | string[]): string;
|
|
1829
|
-
trim(): string;
|
|
1830
|
-
trimStart(): string;
|
|
1831
|
-
trimEnd(): string;
|
|
1832
|
-
toString(): string;
|
|
1833
|
-
valueOf(): string;
|
|
1834
|
-
readonly [index: number]: string;
|
|
1835
|
-
}
|
|
1836
|
-
interface StringConstructor {
|
|
1837
|
-
(value?: unknown): string;
|
|
1838
|
-
fromCharCode(...codes: number[]): string;
|
|
1839
|
-
raw(template: { raw: readonly string[] | ArrayLike<string> }, ...substitutions: unknown[]): string;
|
|
1840
|
-
}
|
|
1841
|
-
declare var String: StringConstructor;
|
|
1869
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariant-catalog.ts
|
|
1870
|
+
var import_codegen64 = require("./index.js");
|
|
1842
1871
|
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1872
|
+
// apps/m-one-ui/src/app/pages/design/model/invariant.ts
|
|
1873
|
+
var targetKey = (target2) => {
|
|
1874
|
+
switch (target2.kind) {
|
|
1875
|
+
case "panel":
|
|
1876
|
+
return `panel:${target2.panel}${target2.featureId ? `:${target2.featureId}` : ""}${target2.subStoreId ? `:${target2.subStoreId}` : ""}${target2.memberId ? `:${target2.memberId}` : ""}`;
|
|
1877
|
+
case "nav":
|
|
1878
|
+
return `nav:${target2.navId}`;
|
|
1879
|
+
case "screen":
|
|
1880
|
+
return `screen:${target2.screenId}${target2.computedId ? `:${target2.computedId}` : ""}${target2.memberId ? `:${target2.memberId}` : ""}`;
|
|
1881
|
+
case "compare":
|
|
1882
|
+
return `compare:${target2.tab}:${target2.item.id}`;
|
|
1883
|
+
case "function":
|
|
1884
|
+
return `function:${target2.functionId}`;
|
|
1885
|
+
case "control":
|
|
1886
|
+
return `control:${target2.screenId}:${target2.controlId}${target2.inputId ? `:${target2.inputId}` : ""}`;
|
|
1887
|
+
}
|
|
1888
|
+
};
|
|
1889
|
+
var defineInvariant = (def) => ({
|
|
1890
|
+
name: def.name,
|
|
1891
|
+
severity: def.severity,
|
|
1892
|
+
deps: def.deps,
|
|
1893
|
+
run: (scope) => {
|
|
1894
|
+
const view = {};
|
|
1895
|
+
def.deps.forEach((dep) => {
|
|
1896
|
+
view[dep] = scope[dep];
|
|
1897
|
+
});
|
|
1898
|
+
return def.validate(view).map(
|
|
1899
|
+
({
|
|
1900
|
+
message,
|
|
1901
|
+
subject,
|
|
1902
|
+
target: target2,
|
|
1903
|
+
computedFix,
|
|
1904
|
+
routeInputFix,
|
|
1905
|
+
screenRetarget
|
|
1906
|
+
}) => ({
|
|
1907
|
+
id: `${def.name}::${targetKey(target2)}${computedFix ? `::${computedFix.computedId}` : ""}${routeInputFix ? `::${routeInputFix.navId}` : ""}`,
|
|
1908
|
+
invariant: def.name,
|
|
1909
|
+
message: message ?? def.message,
|
|
1910
|
+
subject,
|
|
1911
|
+
severity: def.severity,
|
|
1912
|
+
target: target2,
|
|
1913
|
+
...computedFix ? { computedFix } : {},
|
|
1914
|
+
...routeInputFix ? { routeInputFix } : {},
|
|
1915
|
+
...screenRetarget ? { screenRetarget } : {}
|
|
1916
|
+
})
|
|
1917
|
+
);
|
|
1918
|
+
}
|
|
1919
|
+
});
|
|
1869
1920
|
|
|
1870
|
-
|
|
1871
|
-
|
|
1921
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/backend-url-declared.ts
|
|
1922
|
+
var backendUrlDeclared = defineInvariant({
|
|
1923
|
+
name: "backend-url-declared",
|
|
1924
|
+
message: "invariant-backend-url-blank",
|
|
1925
|
+
severity: "blocking",
|
|
1926
|
+
deps: ["appTarget", "features"],
|
|
1927
|
+
validate: ({ appTarget, features }) => {
|
|
1928
|
+
const drawsMethods = Object.values(features).some(
|
|
1929
|
+
(feature) => Object.keys(feature.methods ?? {}).length > 0
|
|
1930
|
+
);
|
|
1931
|
+
if (!drawsMethods) return [];
|
|
1932
|
+
const { preset, hosts } = appTarget.environment;
|
|
1933
|
+
if (hosts.backendUrl.trim()) return [];
|
|
1934
|
+
return [
|
|
1935
|
+
{
|
|
1936
|
+
subject: preset,
|
|
1937
|
+
target: { kind: "panel", panel: "environment" }
|
|
1938
|
+
}
|
|
1939
|
+
];
|
|
1940
|
+
}
|
|
1941
|
+
});
|
|
1872
1942
|
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1943
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/dynamic-nav-input-declared.ts
|
|
1944
|
+
var import_codegen16 = require("./index.js");
|
|
1945
|
+
var dynamicNavInputDeclared = defineInvariant({
|
|
1946
|
+
name: "dynamic-nav-input-declared",
|
|
1947
|
+
message: "invariant-dynamic-nav-input-missing",
|
|
1948
|
+
severity: "blocking",
|
|
1949
|
+
deps: ["navMap", "screens"],
|
|
1950
|
+
validate: ({ navMap, screens }) => Object.values(navMap).filter(
|
|
1951
|
+
(nav) => nav.linkKind === "url" && nav.presentation === "dynamic" && !!nav.pageId
|
|
1952
|
+
).flatMap((nav) => {
|
|
1953
|
+
const routed = screens.find(
|
|
1954
|
+
(screen) => screen.id === nav.pageId && (0, import_codegen16.isRoutableScreen)(screen)
|
|
1955
|
+
);
|
|
1956
|
+
if (!routed) return [];
|
|
1957
|
+
const param = (0, import_codegen16.navParam)(nav);
|
|
1958
|
+
const declared = Object.values(routed.inputs ?? {}).some(
|
|
1959
|
+
(input) => input.name === param
|
|
1960
|
+
);
|
|
1961
|
+
if (declared) return [];
|
|
1962
|
+
return [
|
|
1963
|
+
{
|
|
1964
|
+
// The parameter is named in the subject: with the name authorable,
|
|
1965
|
+
// "this Page is missing an input" is only half of what the User has
|
|
1966
|
+
// to know to fix it.
|
|
1967
|
+
subject: `${nav.navId} \u2192 ${routed.name} (:${param})`,
|
|
1968
|
+
routeInputFix: {
|
|
1969
|
+
navId: nav.navId,
|
|
1970
|
+
screenId: routed.id,
|
|
1971
|
+
name: param
|
|
1972
|
+
},
|
|
1973
|
+
target: {
|
|
1974
|
+
kind: "screen",
|
|
1975
|
+
screenId: routed.id,
|
|
1976
|
+
panel: "screen"
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
];
|
|
1980
|
+
})
|
|
1981
|
+
});
|
|
1902
1982
|
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
}
|
|
1934
|
-
interface DateConstructor {
|
|
1935
|
-
new (value?: number | string | Date): Date;
|
|
1936
|
-
new (year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date;
|
|
1937
|
-
now(): number;
|
|
1938
|
-
parse(s: string): number;
|
|
1939
|
-
UTC(year: number, monthIndex?: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
|
|
1940
|
-
}
|
|
1941
|
-
declare var Date: DateConstructor;
|
|
1983
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/nav-tail-input-declared.ts
|
|
1984
|
+
var import_codegen17 = require("./index.js");
|
|
1985
|
+
var navTailInputDeclared = defineInvariant({
|
|
1986
|
+
name: "nav-tail-input-declared",
|
|
1987
|
+
message: "invariant-nav-tail-input-missing",
|
|
1988
|
+
severity: "blocking",
|
|
1989
|
+
deps: ["navMap", "screens"],
|
|
1990
|
+
validate: ({ navMap, screens }) => Object.values(navMap).filter(
|
|
1991
|
+
(nav) => nav.tail !== void 0 && nav.linkKind === "url" && !!nav.pageId
|
|
1992
|
+
).flatMap((nav) => {
|
|
1993
|
+
const routed = screens.find(
|
|
1994
|
+
(screen) => screen.id === nav.pageId && (0, import_codegen17.isRoutableScreen)(screen)
|
|
1995
|
+
);
|
|
1996
|
+
if (!routed) return [];
|
|
1997
|
+
const declared = Object.values(routed.inputs ?? {}).some(
|
|
1998
|
+
(input) => input.name === nav.tail
|
|
1999
|
+
);
|
|
2000
|
+
if (declared) return [];
|
|
2001
|
+
return [
|
|
2002
|
+
{
|
|
2003
|
+
subject: `${nav.navId} \u2192 ${routed.name} (*${nav.tail})`,
|
|
2004
|
+
target: {
|
|
2005
|
+
kind: "screen",
|
|
2006
|
+
screenId: routed.id,
|
|
2007
|
+
panel: "screen"
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
];
|
|
2011
|
+
})
|
|
2012
|
+
});
|
|
1942
2013
|
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2014
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/nav-tail-childless.ts
|
|
2015
|
+
var navTailChildless = defineInvariant({
|
|
2016
|
+
name: "nav-tail-childless",
|
|
2017
|
+
message: "invariant-nav-tail-has-children",
|
|
2018
|
+
severity: "blocking",
|
|
2019
|
+
deps: ["navMap"],
|
|
2020
|
+
validate: ({ navMap }) => Object.values(navMap).filter((nav) => nav.tail !== void 0 && nav.children.length > 0).map((nav) => ({
|
|
2021
|
+
subject: nav.navId,
|
|
2022
|
+
target: { kind: "nav", navId: nav.navId }
|
|
2023
|
+
}))
|
|
2024
|
+
});
|
|
1948
2025
|
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2026
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/nav-variant-on-chain.ts
|
|
2027
|
+
var import_codegen18 = require("./index.js");
|
|
2028
|
+
var navVariantOnChain = defineInvariant({
|
|
2029
|
+
name: "nav-variant-on-chain",
|
|
2030
|
+
message: "invariant-nav-variant-off-chain",
|
|
2031
|
+
severity: "blocking",
|
|
2032
|
+
deps: ["screens", "navMap"],
|
|
2033
|
+
validate: ({ screens, navMap }) => screens.flatMap((screen) => {
|
|
2034
|
+
const chain = (0, import_codegen18.navVariantNavIds)(navMap, screen.id);
|
|
2035
|
+
return Object.values(screen.variants ?? {}).filter(
|
|
2036
|
+
(variant) => (0, import_codegen18.variantNavIds)(variant).some((navId) => !chain.includes(navId))
|
|
2037
|
+
).map((variant) => ({
|
|
2038
|
+
subject: `${screen.name}.${variant.name}`,
|
|
2039
|
+
target: { kind: "screen", screenId: screen.id }
|
|
2040
|
+
}));
|
|
2041
|
+
})
|
|
2042
|
+
});
|
|
2043
|
+
|
|
2044
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/computed-nav-on-chain.ts
|
|
2045
|
+
var import_codegen19 = require("./index.js");
|
|
2046
|
+
var computedNavOnChain = defineInvariant({
|
|
2047
|
+
name: "computed-nav-on-chain",
|
|
2048
|
+
message: "invariant-computed-nav-off-chain",
|
|
2049
|
+
severity: "blocking",
|
|
2050
|
+
deps: ["screens", "navMap"],
|
|
2051
|
+
validate: ({ screens, navMap }) => screens.flatMap((screen) => {
|
|
2052
|
+
const chain = (0, import_codegen19.navVariantNavIds)(navMap, screen.id);
|
|
2053
|
+
return Object.values(screen.computeds ?? {}).filter(
|
|
2054
|
+
(computed) => (0, import_codegen19.screenComputedNavIds)(computed).some((navId) => !chain.includes(navId))
|
|
2055
|
+
).map((computed) => ({
|
|
2056
|
+
subject: `${screen.name}.${computed.name}`,
|
|
2057
|
+
// The computed's own editor is where its Nav argument is repointed,
|
|
2058
|
+
// so the reveal opens the Screen panel with it docked alongside.
|
|
2059
|
+
target: {
|
|
2060
|
+
kind: "screen",
|
|
2061
|
+
screenId: screen.id,
|
|
2062
|
+
panel: "screen",
|
|
2063
|
+
computedId: computed.id
|
|
2064
|
+
}
|
|
2065
|
+
}));
|
|
2066
|
+
})
|
|
2067
|
+
});
|
|
2068
|
+
|
|
2069
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/computed-one-function-known.ts
|
|
2070
|
+
var import_codegen20 = require("./index.js");
|
|
2071
|
+
var computedOneFunctionKnown = defineInvariant({
|
|
2072
|
+
name: "computed-one-function-known",
|
|
2073
|
+
message: "invariant-computed-one-function-unknown",
|
|
2074
|
+
severity: "blocking",
|
|
2075
|
+
deps: ["screens", "features"],
|
|
2076
|
+
validate: ({ screens, features }) => [
|
|
2077
|
+
...screens.flatMap(
|
|
2078
|
+
(screen) => Object.values(screen.computeds ?? {}).filter(
|
|
2079
|
+
(computed) => (0, import_codegen20.isOneFunctionComputed)(computed) && !(0, import_codegen20.oneFunctionOf)(computed.oneFunction)?.reach.includes(
|
|
2080
|
+
"screen-computed"
|
|
2081
|
+
)
|
|
2082
|
+
).map((computed) => ({
|
|
2083
|
+
subject: `${screen.name}.${computed.name}`,
|
|
2084
|
+
target: {
|
|
2085
|
+
kind: "screen",
|
|
2086
|
+
screenId: screen.id,
|
|
2087
|
+
panel: "screen",
|
|
2088
|
+
computedId: computed.id
|
|
2089
|
+
}
|
|
2090
|
+
}))
|
|
2091
|
+
),
|
|
2092
|
+
...Object.values(features).flatMap(
|
|
2093
|
+
(feature) => (0, import_codegen20.storesOf)(feature).flatMap(
|
|
2094
|
+
(owned) => Object.values(owned.computeds).filter(
|
|
2095
|
+
(computed) => (0, import_codegen20.isOneFunctionStateComputed)(computed) && !(0, import_codegen20.oneFunctionOf)(computed.oneFunction)?.reach.includes(
|
|
2096
|
+
"state-computed"
|
|
2097
|
+
)
|
|
2098
|
+
).map((computed) => ({
|
|
2099
|
+
subject: `${feature.name}.${computed.name}`,
|
|
2100
|
+
target: {
|
|
2101
|
+
kind: "panel",
|
|
2102
|
+
panel: "store",
|
|
2103
|
+
featureId: feature.id,
|
|
2104
|
+
...owned.subStore ? { subStoreId: owned.subStore.id } : {},
|
|
2105
|
+
memberId: computed.id
|
|
2106
|
+
}
|
|
2107
|
+
}))
|
|
2108
|
+
)
|
|
2109
|
+
)
|
|
2110
|
+
]
|
|
2111
|
+
});
|
|
2112
|
+
|
|
2113
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/remote-control-url.ts
|
|
2114
|
+
var import_codegen21 = require("./index.js");
|
|
2115
|
+
var remotesOf = (maps) => Object.entries(maps).flatMap(
|
|
2116
|
+
([screenId, map]) => Object.values(map ?? {}).filter((control) => control.type === import_codegen21.ControlType.REMOTE).map((control) => ({ screenId, control }))
|
|
2117
|
+
);
|
|
2118
|
+
var urlModeOf = ({ control }) => (0, import_codegen21.remoteUrlModeOf)(control.configs);
|
|
2119
|
+
var subjectOf = ({ control }) => (0, import_codegen21.remoteMountName)(control) || "remote-unnamed";
|
|
2120
|
+
var target = ({ screenId, control }) => ({
|
|
2121
|
+
kind: "control",
|
|
2122
|
+
screenId,
|
|
2123
|
+
controlId: control.id
|
|
2124
|
+
});
|
|
2125
|
+
var remoteTailSingle = defineInvariant({
|
|
2126
|
+
name: "remote-tail-single",
|
|
2127
|
+
message: "invariant-remote-tail-single",
|
|
2128
|
+
severity: "blocking",
|
|
2129
|
+
deps: ["screenControlMaps"],
|
|
2130
|
+
validate: ({ screenControlMaps }) => {
|
|
2131
|
+
const tails = remotesOf(screenControlMaps).filter(
|
|
2132
|
+
(f) => urlModeOf(f) === "tail"
|
|
2133
|
+
);
|
|
2134
|
+
const byScreen = /* @__PURE__ */ new Map();
|
|
2135
|
+
tails.forEach(
|
|
2136
|
+
(f) => byScreen.set(f.screenId, [...byScreen.get(f.screenId) ?? [], f])
|
|
2137
|
+
);
|
|
2138
|
+
return [...byScreen.values()].filter((found) => found.length > 1).map((found) => ({
|
|
2139
|
+
subject: subjectOf(found[1]),
|
|
2140
|
+
target: target(found[1])
|
|
2141
|
+
}));
|
|
2142
|
+
}
|
|
2143
|
+
});
|
|
2144
|
+
var tailableNavOf = (screenId, navMap) => Object.values(navMap).find(
|
|
2145
|
+
(nav) => nav.pageId === screenId && (0, import_codegen21.routesNavTail)(nav)
|
|
2146
|
+
);
|
|
2147
|
+
var remoteTailRouted = defineInvariant({
|
|
2148
|
+
name: "remote-tail-routed",
|
|
2149
|
+
message: "invariant-remote-tail-unrouted",
|
|
2150
|
+
severity: "blocking",
|
|
2151
|
+
deps: ["screenControlMaps", "navMap"],
|
|
2152
|
+
validate: ({ screenControlMaps, navMap }) => {
|
|
2153
|
+
const tailed = new Set(
|
|
2154
|
+
Object.values(navMap).filter((nav) => nav.tail !== void 0 && nav.pageId).map((nav) => nav.pageId)
|
|
2155
|
+
);
|
|
2156
|
+
return remotesOf(screenControlMaps).filter((f) => urlModeOf(f) === "tail" && !tailed.has(f.screenId)).map((f) => {
|
|
2157
|
+
const nav = tailableNavOf(f.screenId, navMap);
|
|
2158
|
+
return {
|
|
2159
|
+
subject: subjectOf(f),
|
|
2160
|
+
target: nav ? { kind: "nav", navId: nav.navId } : target(f)
|
|
2161
|
+
};
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
var remoteNameUnique = defineInvariant({
|
|
2166
|
+
name: "remote-name-unique",
|
|
2167
|
+
message: "invariant-remote-name-taken",
|
|
2168
|
+
severity: "blocking",
|
|
2169
|
+
deps: ["screenControlMaps"],
|
|
2170
|
+
validate: ({ screenControlMaps }) => {
|
|
2171
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2172
|
+
return remotesOf(screenControlMaps).flatMap((f) => {
|
|
2173
|
+
const key = `${f.screenId}::${(0, import_codegen21.remoteMountName)(f.control)}`;
|
|
2174
|
+
if (!(0, import_codegen21.remoteMountName)(f.control) || !seen.has(key)) {
|
|
2175
|
+
seen.add(key);
|
|
2176
|
+
return [];
|
|
2177
|
+
}
|
|
2178
|
+
return [{ subject: (0, import_codegen21.remoteMountName)(f.control), target: target(f) }];
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
});
|
|
2182
|
+
var remoteMountPatternValid = defineInvariant({
|
|
2183
|
+
name: "remote-mount-pattern",
|
|
2184
|
+
message: "invariant-remote-mount-pattern",
|
|
2185
|
+
severity: "blocking",
|
|
2186
|
+
deps: ["screenControlMaps"],
|
|
2187
|
+
validate: ({ screenControlMaps }) => remotesOf(screenControlMaps).filter((f) => (0, import_codegen21.remoteMountProblemOf)(f.control.configs)).map((f) => ({ subject: subjectOf(f), target: target(f) }))
|
|
2188
|
+
});
|
|
2189
|
+
var remoteMountMatchesRoute = defineInvariant({
|
|
2190
|
+
name: "remote-mount-route",
|
|
2191
|
+
message: "invariant-remote-mount-route",
|
|
2192
|
+
severity: "blocking",
|
|
2193
|
+
deps: ["screenControlMaps", "navMap"],
|
|
2194
|
+
validate: ({ screenControlMaps, navMap }) => remotesOf(screenControlMaps).filter((f) => {
|
|
2195
|
+
if ((0, import_codegen21.remoteMountProblemOf)(f.control.configs)) return false;
|
|
2196
|
+
if ((0, import_codegen21.remoteMountTextOf)(f.control.configs) === void 0) return false;
|
|
2197
|
+
const paths = (0, import_codegen21.navTailPathsOf)(f.screenId, navMap);
|
|
2198
|
+
const pattern = (0, import_codegen21.remoteMountPatternOf)(f.control.configs);
|
|
2199
|
+
return paths.length > 0 && !paths.some((p) => (0, import_codegen21.mountAgreesWithRoute)(pattern, p));
|
|
2200
|
+
}).map((f) => ({ subject: subjectOf(f), target: target(f) }))
|
|
2201
|
+
});
|
|
2202
|
+
|
|
2203
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/landing-page-bound.ts
|
|
2204
|
+
var import_codegen22 = require("./index.js");
|
|
2205
|
+
var landingPageBound = defineInvariant({
|
|
2206
|
+
name: "landing-page-bound",
|
|
2207
|
+
message: "invariant-landing-page-unbound",
|
|
2208
|
+
severity: "advisory",
|
|
2209
|
+
deps: ["navMap", "screens"],
|
|
2210
|
+
validate: ({ navMap, screens }) => {
|
|
2211
|
+
if (!screens.some(import_codegen22.isRoutableScreen)) return [];
|
|
2212
|
+
const navId = (0, import_codegen22.landingNavId)(navMap);
|
|
2213
|
+
const landing = navMap[navId];
|
|
2214
|
+
if (!landing) return [];
|
|
2215
|
+
const bound = landing.linkKind === "url" && !!landing.pageId && screens.some(
|
|
2216
|
+
(screen) => screen.id === landing.pageId && (0, import_codegen22.isRoutableScreen)(screen)
|
|
2217
|
+
);
|
|
2218
|
+
if (bound) return [];
|
|
2219
|
+
return [{ subject: navId, target: { kind: "nav", navId } }];
|
|
2220
|
+
}
|
|
2221
|
+
});
|
|
2222
|
+
|
|
2223
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/nav-visibility-resolvable.ts
|
|
2224
|
+
var import_codegen23 = require("./index.js");
|
|
2225
|
+
var navVisibilityResolvable = defineInvariant({
|
|
2226
|
+
name: "nav-visibility-resolvable",
|
|
2227
|
+
message: "invariant-nav-visibility-unresolvable",
|
|
2228
|
+
severity: "blocking",
|
|
2229
|
+
deps: ["navMap", "features"],
|
|
2230
|
+
validate: ({ navMap, features }) => Object.values(navMap).filter((nav) => !!nav.visibilitySource).flatMap((nav) => {
|
|
2231
|
+
const source = nav.visibilitySource;
|
|
2232
|
+
if (!source) return [];
|
|
2233
|
+
const target2 = { kind: "nav", navId: nav.navId };
|
|
2234
|
+
if (!source.hidesRow && !source.guardsRoute) {
|
|
2235
|
+
return [{ subject: `${nav.navId} \u2014 no effect`, target: target2 }];
|
|
2236
|
+
}
|
|
2237
|
+
const feature = source.featureId ? features[source.featureId] : void 0;
|
|
2238
|
+
if (!feature) {
|
|
2239
|
+
return [{ subject: `${nav.navId} \u2014 feature gone`, target: target2 }];
|
|
2240
|
+
}
|
|
2241
|
+
const fn = source.functionId ? feature.functions?.[source.functionId] : void 0;
|
|
2242
|
+
if (!fn) {
|
|
2243
|
+
return [{ subject: `${nav.navId} \u2014 function gone`, target: target2 }];
|
|
2244
|
+
}
|
|
2245
|
+
if (!(0, import_codegen23.isNavVisibilityFunction)(fn)) {
|
|
2246
|
+
return [
|
|
2247
|
+
{ subject: `${nav.navId} \u2192 ${fn.name} \u2014 not a boolean`, target: target2 }
|
|
2248
|
+
];
|
|
2249
|
+
}
|
|
2250
|
+
const unmapped = fn.params.filter((param) => !source.args?.[param.id]).map((param) => param.name);
|
|
2251
|
+
if (unmapped.length) {
|
|
2252
|
+
return [
|
|
2253
|
+
{
|
|
2254
|
+
subject: `${nav.navId} \u2192 ${fn.name} \u2014 unmapped: ${unmapped.join(
|
|
2255
|
+
", "
|
|
2256
|
+
)}`,
|
|
2257
|
+
target: target2
|
|
2258
|
+
}
|
|
2259
|
+
];
|
|
2260
|
+
}
|
|
2261
|
+
if (source.methodId && !Object.values(feature.methods ?? {}).some(
|
|
2262
|
+
(method) => method.id === source.methodId
|
|
2263
|
+
) && !Object.values(feature.subStores ?? {}).some(
|
|
2264
|
+
(sub) => Object.values(sub.methods ?? {}).some(
|
|
2265
|
+
(method) => method.id === source.methodId
|
|
2266
|
+
)
|
|
2267
|
+
)) {
|
|
2268
|
+
return [{ subject: `${nav.navId} \u2014 load method gone`, target: target2 }];
|
|
2269
|
+
}
|
|
2270
|
+
return [];
|
|
2271
|
+
})
|
|
2272
|
+
});
|
|
2273
|
+
|
|
2274
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/method-variant-no-landing.ts
|
|
2275
|
+
var import_codegen24 = require("./index.js");
|
|
2276
|
+
var methodVariantNoLanding = defineInvariant({
|
|
2277
|
+
name: "method-variant-no-landing",
|
|
2278
|
+
message: "invariant-method-variant-no-landing",
|
|
2279
|
+
severity: "advisory",
|
|
2280
|
+
deps: ["features", "screens"],
|
|
2281
|
+
validate: ({ features, screens }) => Object.values(features).flatMap((feature) => {
|
|
2282
|
+
const screenId = screens.find((screen) => screen.featureId === feature.id)?.id ?? "";
|
|
2283
|
+
return (0, import_codegen24.storesOf)(feature).flatMap(
|
|
2284
|
+
(store) => Object.values(store.methods).flatMap((method) => {
|
|
2285
|
+
if (!(method.variants ?? []).length) return [];
|
|
2286
|
+
const mappings = method.response ?? [];
|
|
2287
|
+
const codes = [...new Set(mappings.map((m) => m.code))];
|
|
2288
|
+
return codes.filter((code) => {
|
|
2289
|
+
const rows = mappings.filter((m) => m.code === code);
|
|
2290
|
+
return rows.length && rows.every((row) => !!row.landsWhen);
|
|
2291
|
+
}).map((code) => ({
|
|
2292
|
+
subject: `${feature.name}.${method.name} \u2192 ${code}`,
|
|
2293
|
+
target: { kind: "screen", screenId }
|
|
2294
|
+
}));
|
|
2295
|
+
})
|
|
2296
|
+
);
|
|
2297
|
+
})
|
|
2298
|
+
});
|
|
2299
|
+
|
|
2300
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/method-variant-unused.ts
|
|
2301
|
+
var import_codegen25 = require("./index.js");
|
|
2302
|
+
var methodVariantUnused = defineInvariant({
|
|
2303
|
+
name: "method-variant-unused",
|
|
2304
|
+
message: "invariant-method-variant-unused",
|
|
2305
|
+
severity: "advisory",
|
|
2306
|
+
deps: ["features", "screens"],
|
|
2307
|
+
validate: ({ features, screens }) => Object.values(features).flatMap((feature) => {
|
|
2308
|
+
const screenId = screens.find((screen) => screen.featureId === feature.id)?.id ?? "";
|
|
2309
|
+
return (0, import_codegen25.storesOf)(feature).flatMap(
|
|
2310
|
+
(store) => Object.values(store.methods).flatMap((method) => {
|
|
2311
|
+
const named2 = new Set(
|
|
2312
|
+
(method.response ?? []).map((mapping) => mapping.landsWhen).filter((id) => !!id)
|
|
2313
|
+
);
|
|
2314
|
+
return (method.variants ?? []).filter((variant) => !named2.has(variant.id)).map((variant) => ({
|
|
2315
|
+
subject: `${feature.name}.${method.name} \u2192 ${variant.name}`,
|
|
2316
|
+
target: { kind: "screen", screenId }
|
|
2317
|
+
}));
|
|
2318
|
+
})
|
|
2319
|
+
);
|
|
2320
|
+
})
|
|
2321
|
+
});
|
|
2322
|
+
|
|
2323
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/overlay-body-bound.ts
|
|
2324
|
+
var import_codegen26 = require("./index.js");
|
|
2325
|
+
var overlayBodyBound = defineInvariant({
|
|
2326
|
+
name: "overlay-body-bound",
|
|
2327
|
+
message: "invariant-overlay-body-unbound",
|
|
2328
|
+
severity: "advisory",
|
|
2329
|
+
deps: ["screens", "screenControlMaps"],
|
|
2330
|
+
validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
|
|
2331
|
+
const controlMap = screenControlMaps[screen.id] ?? {};
|
|
2332
|
+
return Object.values(controlMap).flatMap((control) => {
|
|
2333
|
+
const unbound = Object.entries(control.directives ?? {}).some(
|
|
2334
|
+
([name, directive]) => {
|
|
2335
|
+
if (!(0, import_codegen26.isOverlayDirectiveName)(name)) return false;
|
|
2336
|
+
const configs = directive.overlayId ? controlMap[directive.overlayId]?.configs : directive.configs;
|
|
2337
|
+
const component = configs?.["component"];
|
|
2338
|
+
return component === import_codegen26.NEW_SCREEN || typeof component !== "string" || !component;
|
|
2339
|
+
}
|
|
2340
|
+
);
|
|
2341
|
+
if (!unbound) return [];
|
|
2342
|
+
return [
|
|
2343
|
+
{
|
|
2344
|
+
subject: `${screen.name} \u2192 ${String(control.configs["name"] ?? control.id)}`,
|
|
2345
|
+
target: {
|
|
2346
|
+
kind: "control",
|
|
2347
|
+
screenId: screen.id,
|
|
2348
|
+
controlId: control.id
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
];
|
|
2352
|
+
});
|
|
2353
|
+
})
|
|
2354
|
+
});
|
|
2355
|
+
|
|
2356
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/page-input-routable.ts
|
|
2357
|
+
var import_codegen27 = require("./index.js");
|
|
2358
|
+
var pageInputRoutable = defineInvariant({
|
|
2359
|
+
name: "page-input-routable",
|
|
2360
|
+
message: "invariant-page-input-unroutable",
|
|
2361
|
+
severity: "advisory",
|
|
2362
|
+
deps: ["navMap", "screens"],
|
|
2363
|
+
validate: ({ navMap, screens }) => screens.filter((screen) => screen.kind === "page").flatMap((page) => {
|
|
2364
|
+
const navs = Object.values(navMap).filter(
|
|
2365
|
+
(nav) => nav.linkKind === "url" && nav.pageId === page.id
|
|
2366
|
+
);
|
|
2367
|
+
if (!navs.length) return [];
|
|
2368
|
+
const routed = new Set(
|
|
2369
|
+
navs.flatMap((nav) => (0, import_codegen27.navRouteParams)(nav.navId, navMap))
|
|
2370
|
+
);
|
|
2371
|
+
const unfillable = Object.values(page.inputs ?? {}).filter((input) => input.origin !== "card").filter(
|
|
2372
|
+
(input) => !routed.has(input.name) || input.dataType.type === "enum"
|
|
2373
|
+
).map((input) => input.name);
|
|
2374
|
+
if (!unfillable.length) return [];
|
|
2375
|
+
return [
|
|
2376
|
+
{
|
|
2377
|
+
subject: `${page.name} \u2192 ${unfillable.join(", ")}`,
|
|
2378
|
+
target: {
|
|
2379
|
+
kind: "screen",
|
|
2380
|
+
screenId: page.id,
|
|
2381
|
+
panel: "screen"
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
];
|
|
2385
|
+
})
|
|
2386
|
+
});
|
|
2387
|
+
|
|
2388
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/app-scaffold-complete.ts
|
|
2389
|
+
var appScaffoldComplete = defineInvariant({
|
|
2390
|
+
name: "app-scaffold-complete",
|
|
2391
|
+
message: "app-scaffold-incomplete",
|
|
2392
|
+
severity: "blocking",
|
|
2393
|
+
deps: ["appTarget", "screens"],
|
|
2394
|
+
validate: ({ appTarget, screens }) => {
|
|
2395
|
+
if (!screens.length) return [];
|
|
2396
|
+
const missing = [];
|
|
2397
|
+
if (!appTarget.appName.trim()) missing.push("app-name");
|
|
2398
|
+
if (!missing.length) return [];
|
|
2399
|
+
return [
|
|
2400
|
+
{
|
|
2401
|
+
subject: missing.join(", "),
|
|
2402
|
+
target: { kind: "panel", panel: "config" }
|
|
2403
|
+
}
|
|
2404
|
+
];
|
|
2405
|
+
}
|
|
2406
|
+
});
|
|
2407
|
+
|
|
2408
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/binding-resolves.ts
|
|
2409
|
+
var import_codegen28 = require("./index.js");
|
|
2410
|
+
var bindingResolves = defineInvariant({
|
|
2411
|
+
name: "binding-resolves",
|
|
2412
|
+
message: "invariant-binding-unresolved",
|
|
2413
|
+
severity: "blocking",
|
|
2414
|
+
deps: ["features", "screens", "screenControlMaps", "functions"],
|
|
2415
|
+
validate: ({ features, screens, screenControlMaps, functions }) => screens.flatMap((screen) => {
|
|
2416
|
+
const feature = (0, import_codegen28.isFeatureScreen)(screen) ? features[screen.featureId] : void 0;
|
|
2417
|
+
const controlMap = screenControlMaps[screen.id] ?? {};
|
|
2418
|
+
const readable = feature ? (0, import_codegen28.readableMembers)(feature, import_codegen28.MAIN_STORE_OWNER) : void 0;
|
|
2419
|
+
const scope = {
|
|
2420
|
+
properties: readable?.properties,
|
|
2421
|
+
shapes: feature?.shapes,
|
|
2422
|
+
computeds: readable?.computeds,
|
|
2423
|
+
inputs: screen.inputs,
|
|
2424
|
+
screenComputeds: screen.computeds,
|
|
2425
|
+
screenVariables: screen.variables,
|
|
2426
|
+
// Screen-owned and read off the meta, as emit reads them (ADR 0127):
|
|
2427
|
+
// without them every form-value read judged dangling.
|
|
2428
|
+
formModels: screen.formModels,
|
|
2429
|
+
functions: { ...functions, ...feature?.functions },
|
|
2430
|
+
constants: screen.constants,
|
|
2431
|
+
storeProp: (0, import_codegen28.isFeatureScreen)(screen) ? "store" : void 0,
|
|
2432
|
+
controlMap
|
|
2433
|
+
};
|
|
2434
|
+
return Object.values(controlMap).flatMap((control) => {
|
|
2435
|
+
const screenInputBindings = Object.values(
|
|
2436
|
+
control.screenInputs ?? {}
|
|
2437
|
+
).flatMap(
|
|
2438
|
+
(binding) => binding.kind === "data" ? [binding.binding] : []
|
|
2439
|
+
);
|
|
2440
|
+
const broken = [
|
|
2441
|
+
...Object.values(control.bindings ?? {}),
|
|
2442
|
+
...(0, import_codegen28.formatPipeBindings)(control),
|
|
2443
|
+
...screenInputBindings
|
|
2444
|
+
].some((binding) => !(0, import_codegen28.bindingExpression)(binding, scope));
|
|
2445
|
+
if (!broken) return [];
|
|
2446
|
+
return [
|
|
2447
|
+
{
|
|
2448
|
+
subject: `${screen.name} \u2192 ${String(control.configs["name"] ?? control.id)}`,
|
|
2449
|
+
target: {
|
|
2450
|
+
kind: "control",
|
|
2451
|
+
screenId: screen.id,
|
|
2452
|
+
controlId: control.id
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
];
|
|
2456
|
+
});
|
|
2457
|
+
})
|
|
2458
|
+
});
|
|
2459
|
+
|
|
2460
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/binding-resolves-outputs.ts
|
|
2461
|
+
var import_codegen29 = require("./index.js");
|
|
2462
|
+
var writesGone = (value, state) => {
|
|
2463
|
+
if (Array.isArray(value)) return value.some((item) => writesGone(item, state));
|
|
2464
|
+
if (!value || typeof value !== "object") return false;
|
|
2465
|
+
const record = value;
|
|
2466
|
+
if (typeof record.propertyId === "string" && "value" in record && !state.has(record.propertyId))
|
|
2467
|
+
return true;
|
|
2468
|
+
return Object.values(value).some((item) => writesGone(item, state));
|
|
2469
|
+
};
|
|
2470
|
+
var bindingResolvesOutputs = defineInvariant({
|
|
2471
|
+
name: "binding-resolves-outputs",
|
|
2472
|
+
message: "invariant-state-write-unresolved",
|
|
2473
|
+
severity: "blocking",
|
|
2474
|
+
deps: ["features", "screens", "screenControlMaps"],
|
|
2475
|
+
validate: ({ features, screens, screenControlMaps }) => {
|
|
2476
|
+
const state = new Set(
|
|
2477
|
+
Object.values(features).flatMap(
|
|
2478
|
+
(feature) => (0, import_codegen29.storesOf)(feature).flatMap((store) => Object.keys(store.properties ?? {}))
|
|
2479
|
+
)
|
|
2480
|
+
);
|
|
2481
|
+
const found = [];
|
|
2482
|
+
for (const screen of screens) {
|
|
2483
|
+
const map = screenControlMaps[screen.id] ?? {};
|
|
2484
|
+
for (const control of Object.values(map)) {
|
|
2485
|
+
if (writesGone([control.outputWrites, control.outputOutcomes], state))
|
|
2486
|
+
found.push({
|
|
2487
|
+
subject: `${screen.name} \u2192 ${String(control.configs?.["name"] ?? control.id)}`,
|
|
2488
|
+
target: { kind: "control", screenId: screen.id, controlId: control.id }
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2491
|
+
if (writesGone([screen.methods, screen.autoCalls], state))
|
|
2492
|
+
found.push({
|
|
2493
|
+
subject: `${screen.name} \u2192 ScreenMethod / AutoCall`,
|
|
2494
|
+
target: { kind: "screen", screenId: screen.id, panel: "screen" }
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
return found;
|
|
2498
|
+
}
|
|
2499
|
+
});
|
|
2500
|
+
|
|
2501
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/control-rules.ts
|
|
2502
|
+
var import_codegen30 = require("./index.js");
|
|
2503
|
+
var nameOf = (map, id) => String(map[id]?.configs?.["name"] ?? id);
|
|
2504
|
+
var routerOutletPlaced = defineInvariant({
|
|
2505
|
+
name: "router-outlet-placed",
|
|
2506
|
+
message: "invariant-router-outlet-misplaced",
|
|
2507
|
+
severity: "blocking",
|
|
2508
|
+
deps: ["screens", "screenControlMaps"],
|
|
2509
|
+
validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
|
|
2510
|
+
const outlets = Object.values(screenControlMaps[screen.id] ?? {}).filter(
|
|
2511
|
+
(control) => control.type === import_codegen30.ControlType.ROUTER_OUTLET
|
|
2512
|
+
);
|
|
2513
|
+
const misplaced = (0, import_codegen30.isRoutableKind)(screen.kind) ? outlets.slice(1) : outlets;
|
|
2514
|
+
return misplaced.map((control) => ({
|
|
2515
|
+
subject: `${screen.name} \u2192 ${nameOf(screenControlMaps[screen.id], control.id)}`,
|
|
2516
|
+
target: { kind: "control", screenId: screen.id, controlId: control.id }
|
|
2517
|
+
}));
|
|
2518
|
+
})
|
|
2519
|
+
});
|
|
2520
|
+
var controlIdUnique = defineInvariant({
|
|
2521
|
+
name: "control-id-unique",
|
|
2522
|
+
message: "invariant-control-id-duplicate",
|
|
2523
|
+
severity: "blocking",
|
|
2524
|
+
deps: ["screens", "screenControlMaps"],
|
|
2525
|
+
validate: ({ screens, screenControlMaps }) => {
|
|
2526
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2527
|
+
const found = [];
|
|
2528
|
+
for (const screen of screens) {
|
|
2529
|
+
for (const id of Object.keys(screenControlMaps[screen.id] ?? {})) {
|
|
2530
|
+
const first = seen.get(id);
|
|
2531
|
+
if (first === void 0) {
|
|
2532
|
+
seen.set(id, screen.name);
|
|
2533
|
+
continue;
|
|
2534
|
+
}
|
|
2535
|
+
found.push({
|
|
2536
|
+
subject: `${screen.name} \u2192 ${nameOf(screenControlMaps[screen.id], id)}, also on ${first}`,
|
|
2537
|
+
target: { kind: "control", screenId: screen.id, controlId: id }
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
return found;
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
var fieldKeyTypeAgrees = defineInvariant({
|
|
2545
|
+
name: "field-key-type-agrees",
|
|
2546
|
+
message: "invariant-field-key-type-split",
|
|
2547
|
+
severity: "blocking",
|
|
2548
|
+
deps: ["screens", "screenControlMaps"],
|
|
2549
|
+
validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
|
|
2550
|
+
const map = screenControlMaps[screen.id] ?? {};
|
|
2551
|
+
return Object.values(map).filter((control) => control.type === import_codegen30.ControlType.FIELD).filter((field) => (0, import_codegen30.fieldKeyClashes)(map, field.id, field.configs).length > 0).map((field) => ({
|
|
2552
|
+
subject: `${screen.name} \u2192 ${nameOf(map, field.id)}`,
|
|
2553
|
+
target: { kind: "control", screenId: screen.id, controlId: field.id }
|
|
2554
|
+
}));
|
|
2555
|
+
})
|
|
2556
|
+
});
|
|
2557
|
+
var submitTargetResolves = defineInvariant({
|
|
2558
|
+
name: "submit-target-resolves",
|
|
2559
|
+
message: "invariant-submit-target-unresolved",
|
|
2560
|
+
severity: "blocking",
|
|
2561
|
+
deps: ["screens", "screenControlMaps"],
|
|
2562
|
+
validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
|
|
2563
|
+
const map = screenControlMaps[screen.id] ?? {};
|
|
2564
|
+
return Object.values(map).filter((control) => {
|
|
2565
|
+
const target2 = control.configs?.[import_codegen30.SUBMIT_TARGET_KEY];
|
|
2566
|
+
return typeof target2 === "string" && !map[target2];
|
|
2567
|
+
}).map((control) => ({
|
|
2568
|
+
subject: `${screen.name} \u2192 ${nameOf(map, control.id)}`,
|
|
2569
|
+
target: { kind: "control", screenId: screen.id, controlId: control.id }
|
|
2570
|
+
}));
|
|
2571
|
+
})
|
|
2572
|
+
});
|
|
2573
|
+
var formResetResolves = defineInvariant({
|
|
2574
|
+
name: "form-reset-resolves",
|
|
2575
|
+
message: "invariant-form-reset-unresolved",
|
|
2576
|
+
severity: "blocking",
|
|
2577
|
+
deps: ["screens", "screenControlMaps"],
|
|
2578
|
+
validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
|
|
2579
|
+
const map = screenControlMaps[screen.id] ?? {};
|
|
2580
|
+
const onControls = Object.values(map).filter(
|
|
2581
|
+
(control) => Object.values(control.outputOutcomes ?? {}).some(
|
|
2582
|
+
(outcome) => !!(0, import_codegen30.repairCallOutcome)(map, outcome)
|
|
2583
|
+
)
|
|
2584
|
+
).map((control) => ({
|
|
2585
|
+
subject: `${screen.name} \u2192 ${nameOf(map, control.id)}`,
|
|
2586
|
+
target: { kind: "control", screenId: screen.id, controlId: control.id }
|
|
2587
|
+
}));
|
|
2588
|
+
const onSites = (0, import_codegen30.repairClassCallSites)(map, {
|
|
2589
|
+
methods: screen.methods,
|
|
2590
|
+
autoCalls: screen.autoCalls
|
|
2591
|
+
}) ? [
|
|
2592
|
+
{
|
|
2593
|
+
subject: `${screen.name} \u2192 ScreenMethod / AutoCall`,
|
|
2594
|
+
target: { kind: "screen", screenId: screen.id, panel: "screen" }
|
|
2595
|
+
}
|
|
2596
|
+
] : [];
|
|
2597
|
+
return [...onControls, ...onSites];
|
|
2598
|
+
})
|
|
2599
|
+
});
|
|
2600
|
+
var ruleFieldResolves = defineInvariant({
|
|
2601
|
+
name: "rule-field-resolves",
|
|
2602
|
+
message: "invariant-rule-field-unresolved",
|
|
2603
|
+
severity: "blocking",
|
|
2604
|
+
deps: ["screens", "screenControlMaps"],
|
|
2605
|
+
validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
|
|
2606
|
+
const map = screenControlMaps[screen.id] ?? {};
|
|
2607
|
+
const models = /* @__PURE__ */ new Set([
|
|
2608
|
+
...Object.keys(screen.formModels ?? {}),
|
|
2609
|
+
...Object.values(screen.formModels ?? {}).map((model) => model.id)
|
|
2610
|
+
]);
|
|
2611
|
+
if (!models.size) return [];
|
|
2612
|
+
const readsGone = (node) => {
|
|
2613
|
+
if (Array.isArray(node)) return node.some(readsGone);
|
|
2614
|
+
if (!node || typeof node !== "object") return false;
|
|
2615
|
+
const path = node.path;
|
|
2616
|
+
if (node.kind === "check" && Array.isArray(path) && typeof path[0] === "string" && models.has(path[0]) && typeof path[1] === "string" && !map[path[1]]) {
|
|
2617
|
+
return true;
|
|
2618
|
+
}
|
|
2619
|
+
return Object.values(node).some(readsGone);
|
|
2620
|
+
};
|
|
2621
|
+
return Object.values(screen.variants ?? {}).filter((variant) => readsGone(variant.rule)).map((variant) => ({
|
|
2622
|
+
subject: `${screen.name} \u2192 variant ${variant.name}`,
|
|
2623
|
+
target: { kind: "screen", screenId: screen.id, panel: "screen", memberId: variant.id }
|
|
2624
|
+
}));
|
|
2625
|
+
})
|
|
2626
|
+
});
|
|
2627
|
+
var embedShapeWithinFeature = defineInvariant({
|
|
2628
|
+
name: "embed-shape-within-feature",
|
|
2629
|
+
message: "invariant-embed-shape-crosses-feature",
|
|
2630
|
+
severity: "blocking",
|
|
2631
|
+
deps: ["screens", "screenControlMaps"],
|
|
2632
|
+
validate: ({ screens, screenControlMaps }) => {
|
|
2633
|
+
const byId = new Map(screens.map((screen) => [screen.id, screen]));
|
|
2634
|
+
return screens.flatMap(
|
|
2635
|
+
(host) => Object.values(screenControlMaps[host.id] ?? {}).flatMap((control) => {
|
|
2636
|
+
const target2 = control.screenId ? byId.get(control.screenId) : void 0;
|
|
2637
|
+
if (!target2 || !(0, import_codegen30.embedShapeBlocked)(host, target2)) return [];
|
|
2638
|
+
return [
|
|
2639
|
+
{
|
|
2640
|
+
subject: `${host.name} \u2192 ${target2.name}`,
|
|
2641
|
+
target: { kind: "control", screenId: host.id, controlId: control.id }
|
|
2642
|
+
}
|
|
2643
|
+
];
|
|
2644
|
+
})
|
|
2645
|
+
);
|
|
2646
|
+
}
|
|
2647
|
+
});
|
|
2648
|
+
|
|
2649
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/function-rules.ts
|
|
2650
|
+
var import_codegen31 = require("./index.js");
|
|
2651
|
+
var functionNameUnshadowed = defineInvariant({
|
|
2652
|
+
name: "function-name-unshadowed",
|
|
2653
|
+
message: "invariant-function-name-shadowed",
|
|
2654
|
+
severity: "blocking",
|
|
2655
|
+
deps: ["features", "functions"],
|
|
2656
|
+
validate: ({ features, functions }) => {
|
|
2657
|
+
const appNames = new Set(Object.values(functions).map((fn) => fn.name));
|
|
2658
|
+
return Object.values(features).flatMap(
|
|
2659
|
+
(feature) => Object.values(feature.functions ?? {}).filter((fn) => appNames.has(fn.name)).map((fn) => ({
|
|
2660
|
+
subject: `${feature.name} \xB7 ${fn.name}`,
|
|
2661
|
+
target: { kind: "function", featureId: feature.id, functionId: fn.id }
|
|
2662
|
+
}))
|
|
2663
|
+
);
|
|
2664
|
+
}
|
|
2665
|
+
});
|
|
2666
|
+
var functionTierFiled = defineInvariant({
|
|
2667
|
+
name: "function-tier-filed",
|
|
2668
|
+
message: "invariant-function-tier-misfiled",
|
|
2669
|
+
severity: "blocking",
|
|
2670
|
+
deps: ["features", "functions", "sharedShapes"],
|
|
2671
|
+
validate: ({ features, functions, sharedShapes }) => {
|
|
2672
|
+
const found = Object.values(functions).filter((fn) => (0, import_codegen31.tierOf)(fn) === "feature" && !fn.tier).filter((fn) => (0, import_codegen31.featureShapeIds)(fn).some((id) => !sharedShapes[id])).map((fn) => ({
|
|
2673
|
+
subject: `shared \xB7 ${fn.name}`,
|
|
2674
|
+
target: { kind: "function", functionId: fn.id }
|
|
2675
|
+
}));
|
|
2676
|
+
for (const feature of Object.values(features)) {
|
|
2677
|
+
const foreign = (fn) => (0, import_codegen31.featureShapeIds)(fn).some((id) => !feature.shapes[id] && !sharedShapes[id]);
|
|
2678
|
+
for (const fn of Object.values(feature.functions ?? {}).filter(foreign))
|
|
2679
|
+
found.push({
|
|
2680
|
+
subject: `${feature.name} \xB7 ${fn.name}`,
|
|
2681
|
+
target: { kind: "function", featureId: feature.id, functionId: fn.id }
|
|
2682
|
+
});
|
|
2683
|
+
}
|
|
2684
|
+
return found;
|
|
2685
|
+
}
|
|
2686
|
+
});
|
|
2687
|
+
var namesBoth = (value) => {
|
|
2688
|
+
if (Array.isArray(value)) return value.some(namesBoth);
|
|
2689
|
+
if (!value || typeof value !== "object") return false;
|
|
2690
|
+
const record = value;
|
|
2691
|
+
if (typeof record.functionId === "string" && record.functionId !== "" && typeof record.oneFunction === "string" && record.oneFunction !== "") {
|
|
2692
|
+
return true;
|
|
2693
|
+
}
|
|
2694
|
+
return Object.values(value).some(namesBoth);
|
|
2695
|
+
};
|
|
2696
|
+
var functionRefExclusive = defineInvariant({
|
|
2697
|
+
name: "function-ref-exclusive",
|
|
2698
|
+
message: "invariant-function-ref-both",
|
|
2699
|
+
severity: "blocking",
|
|
2700
|
+
deps: ["features", "screens"],
|
|
2701
|
+
validate: ({ features, screens }) => [
|
|
2702
|
+
...Object.values(features).filter((feature) => namesBoth(feature.computeds) || namesBoth(feature.methods) || namesBoth(feature.subStores)).map((feature) => ({
|
|
2703
|
+
subject: feature.name,
|
|
2704
|
+
target: { kind: "panel", panel: "store", featureId: feature.id }
|
|
2705
|
+
})),
|
|
2706
|
+
...screens.filter((screen) => namesBoth(screen.computeds) || namesBoth(screen.methods)).map((screen) => ({
|
|
2707
|
+
subject: screen.name,
|
|
2708
|
+
target: { kind: "screen", screenId: screen.id, panel: "screen" }
|
|
2709
|
+
}))
|
|
2710
|
+
]
|
|
2711
|
+
});
|
|
2712
|
+
|
|
2713
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/store-rules.ts
|
|
2714
|
+
var import_codegen32 = require("./index.js");
|
|
2715
|
+
var storeNameReserved = defineInvariant({
|
|
2716
|
+
name: "store-name-reserved",
|
|
2717
|
+
message: "invariant-store-name-reserved",
|
|
2718
|
+
severity: "blocking",
|
|
2719
|
+
deps: ["features"],
|
|
2720
|
+
validate: ({ features }) => Object.values(features).flatMap((feature) => {
|
|
2721
|
+
const at = { kind: "panel", panel: "store", featureId: feature.id };
|
|
2722
|
+
return (0, import_codegen32.storesOf)(feature).flatMap((store) => {
|
|
2723
|
+
const subStoreId = store.subStore?.id;
|
|
2724
|
+
const owner = subStoreId ? { ...at, subStoreId } : at;
|
|
2725
|
+
const found = Object.values(store.methods ?? {}).filter((method) => import_codegen32.RESERVED_METHOD_NAMES.includes(method.name)).map((method) => ({
|
|
2726
|
+
subject: `${feature.name} \u2192 method ${method.name}`,
|
|
2727
|
+
target: { ...owner, memberId: method.id }
|
|
2728
|
+
}));
|
|
2729
|
+
if (store.subStore && store.subStore.name === import_codegen32.MAIN_STORE_VALUE)
|
|
2730
|
+
found.push({ subject: `${feature.name} \u2192 store ${store.subStore.name}`, target: owner });
|
|
2731
|
+
return found;
|
|
2732
|
+
});
|
|
2733
|
+
})
|
|
2734
|
+
});
|
|
2735
|
+
var storeMemberNameUnique = defineInvariant({
|
|
2736
|
+
name: "store-member-name-unique",
|
|
2737
|
+
message: "invariant-store-member-name-taken",
|
|
2738
|
+
severity: "blocking",
|
|
2739
|
+
deps: ["features"],
|
|
2740
|
+
validate: ({ features }) => Object.values(features).flatMap((feature) => {
|
|
2741
|
+
const at = { kind: "panel", panel: "store", featureId: feature.id };
|
|
2742
|
+
return (0, import_codegen32.storesOf)(feature).flatMap((store) => {
|
|
2743
|
+
const subStoreId = store.subStore?.id;
|
|
2744
|
+
const owner = subStoreId ? { ...at, subStoreId } : at;
|
|
2745
|
+
const others = /* @__PURE__ */ new Set([
|
|
2746
|
+
...Object.values(store.methods ?? {}).map((member) => member.name),
|
|
2747
|
+
...Object.values(store.computeds ?? {}).map((member) => member.name)
|
|
2748
|
+
]);
|
|
2749
|
+
return Object.values(store.properties ?? {}).filter((property) => others.has(property.name)).map((property) => ({
|
|
2750
|
+
subject: `${feature.name} \u2192 ${property.name}`,
|
|
2751
|
+
target: { ...owner, memberId: property.id }
|
|
2752
|
+
}));
|
|
2753
|
+
});
|
|
2754
|
+
})
|
|
2755
|
+
});
|
|
2756
|
+
|
|
2757
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/screen-control-reachable.ts
|
|
2758
|
+
var screenControlReachable = defineInvariant({
|
|
2759
|
+
name: "screen-control-reachable",
|
|
2760
|
+
message: "invariant-screen-control-unreachable",
|
|
2761
|
+
severity: "blocking",
|
|
2762
|
+
deps: ["screens", "screenControlMaps"],
|
|
2763
|
+
// `screenControlMaps` already holds the open Screen live (ADR 0163), so a
|
|
2764
|
+
// Screen edited since its last slot write is validated as it stands.
|
|
2765
|
+
validate: ({ screens, screenControlMaps: maps }) => {
|
|
2766
|
+
const byId = new Map(screens.map((screen) => [screen.id, screen]));
|
|
2767
|
+
const findings = screens.flatMap(
|
|
2768
|
+
(host) => screenEmbedProblems(host, maps, screens).flatMap(
|
|
2769
|
+
(problem) => {
|
|
2770
|
+
const subject = `${host.name} \u2192 ${byId.get(problem.screenId)?.name ?? problem.screenId}`;
|
|
2771
|
+
if (problem.kind === "illegal-target" || problem.kind === "feature-cycle") {
|
|
2772
|
+
return [
|
|
2773
|
+
{
|
|
2774
|
+
subject,
|
|
2775
|
+
screenRetarget: true,
|
|
2776
|
+
target: {
|
|
2777
|
+
kind: "control",
|
|
2778
|
+
screenId: host.id,
|
|
2779
|
+
controlId: problem.controlId
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
];
|
|
2783
|
+
}
|
|
2784
|
+
if (problem.kind === "duplicate-feature-screen") {
|
|
2785
|
+
const mountName = (mount) => {
|
|
2786
|
+
const control = maps[mount.hostId]?.[mount.controlId];
|
|
2787
|
+
return `${byId.get(mount.hostId)?.name ?? mount.hostId}.${String(control?.configs["name"] ?? mount.controlId)}`;
|
|
2788
|
+
};
|
|
2789
|
+
const mounts = duplicateFeatureEmbedControls(
|
|
2790
|
+
host.id,
|
|
2791
|
+
maps,
|
|
2792
|
+
screens
|
|
2793
|
+
).filter((mount) => mount.screenId === problem.screenId);
|
|
2794
|
+
return mounts.map((mount) => ({
|
|
2795
|
+
message: "invariant-screen-control-duplicate",
|
|
2796
|
+
subject: `${mountName(mount)} \u2192 ${byId.get(mount.screenId)?.name ?? mount.screenId}, also at ${mounts.filter((other) => other !== mount).map(mountName).join(", ")}`,
|
|
2797
|
+
target: {
|
|
2798
|
+
kind: "control",
|
|
2799
|
+
screenId: mount.hostId,
|
|
2800
|
+
controlId: mount.controlId
|
|
2801
|
+
}
|
|
2802
|
+
}));
|
|
2803
|
+
}
|
|
2804
|
+
if (problem.kind === "missing-screen") {
|
|
2805
|
+
return [
|
|
2806
|
+
{
|
|
2807
|
+
subject: `${host.name} \u2192 missing Screen ${problem.screenId}`,
|
|
2808
|
+
screenRetarget: true,
|
|
2809
|
+
target: {
|
|
2810
|
+
kind: "control",
|
|
2811
|
+
screenId: host.id,
|
|
2812
|
+
controlId: problem.controlId
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
];
|
|
2816
|
+
}
|
|
2817
|
+
if (problem.kind === "cycle") {
|
|
2818
|
+
return [
|
|
2819
|
+
{
|
|
2820
|
+
subject: `${host.name} \u2192 embeds itself through its ScreenControls`,
|
|
2821
|
+
target: { kind: "screen", screenId: host.id, panel: "screen" }
|
|
2822
|
+
}
|
|
2823
|
+
];
|
|
2824
|
+
}
|
|
2825
|
+
return [];
|
|
2826
|
+
}
|
|
2827
|
+
)
|
|
2828
|
+
);
|
|
2829
|
+
const unique = /* @__PURE__ */ new Map();
|
|
2830
|
+
findings.forEach((finding) => {
|
|
2831
|
+
const key = targetKey(finding.target);
|
|
2832
|
+
if (!unique.has(key) || !finding.message) unique.set(key, finding);
|
|
2833
|
+
});
|
|
2834
|
+
return [...unique.values()];
|
|
2835
|
+
}
|
|
2836
|
+
});
|
|
2837
|
+
|
|
2838
|
+
// apps/m-one-ui/src/app/pages/design/lib/screen-input-binding-check.ts
|
|
2839
|
+
var import_codegen33 = require("./index.js");
|
|
2840
|
+
var staticFits = (input, value) => {
|
|
2841
|
+
const primitive = (0, import_codegen33.inputPrimitive)(input);
|
|
2842
|
+
if (!primitive) return false;
|
|
2843
|
+
if (input.cardinality === "many") {
|
|
2844
|
+
return (0, import_codegen33.fixedItems)(value).every(
|
|
2845
|
+
(item) => staticFits({ ...input, cardinality: "one" }, item)
|
|
2846
|
+
);
|
|
2847
|
+
}
|
|
2848
|
+
if (input.cardinality !== "one") return false;
|
|
2849
|
+
if (primitive === "number")
|
|
2850
|
+
return value.trim() !== "" && !isNaN(Number(value));
|
|
2851
|
+
if (primitive === "boolean") return value === "true" || value === "false";
|
|
2852
|
+
return true;
|
|
2853
|
+
};
|
|
2854
|
+
var outputFits = (input, binding, controlMap, screens) => {
|
|
2855
|
+
if (input.required) return false;
|
|
2856
|
+
const sibling = controlMap[binding.controlId];
|
|
2857
|
+
if (!sibling || sibling.type !== import_codegen33.ControlType.SCREEN) return false;
|
|
2858
|
+
const siblingScreen = screens.find(
|
|
2859
|
+
(screen) => screen.id === sibling.screenId
|
|
2860
|
+
);
|
|
2861
|
+
if (!siblingScreen) return false;
|
|
2862
|
+
const output = (0, import_codegen33.listScreenOutputs)(siblingScreen.outputs).find(
|
|
2863
|
+
(entry) => entry.id === binding.outputId
|
|
2864
|
+
);
|
|
2865
|
+
const primitive = (0, import_codegen33.inputPrimitive)(input);
|
|
2866
|
+
return !!output && !!primitive && output.payload?.dataType === primitive && output.payload?.cardinality === input.cardinality;
|
|
2867
|
+
};
|
|
2868
|
+
var sourceScope = (host, control, controlMap, features, functions, enums) => {
|
|
2869
|
+
const feature = (0, import_codegen33.isFeatureScreen)(host) ? features[host.featureId] : void 0;
|
|
2870
|
+
const readable = feature ? (0, import_codegen33.readableMembers)(feature, import_codegen33.MAIN_STORE_OWNER) : void 0;
|
|
2871
|
+
const inScope = { ...functions, ...feature?.functions };
|
|
2872
|
+
const properties = readable?.properties ?? {};
|
|
2873
|
+
return {
|
|
2874
|
+
inputs: host.inputs ?? {},
|
|
2875
|
+
variables: host.variables ?? {},
|
|
2876
|
+
constants: host.constants ?? {},
|
|
2877
|
+
computeds: host.computeds ?? {},
|
|
2878
|
+
enums,
|
|
2879
|
+
functions: inScope,
|
|
2880
|
+
data: {
|
|
2881
|
+
controlId: control.id,
|
|
2882
|
+
controlMap,
|
|
2883
|
+
roots: (0, import_codegen33.propertiesWithComputeds)(
|
|
2884
|
+
properties,
|
|
2885
|
+
readable?.computeds ?? {},
|
|
2886
|
+
inScope
|
|
2887
|
+
),
|
|
2888
|
+
properties,
|
|
2889
|
+
shapes: feature?.shapes ?? {},
|
|
2890
|
+
inputs: host.inputs,
|
|
2891
|
+
screenComputeds: host.computeds,
|
|
2892
|
+
screenVariables: host.variables,
|
|
2893
|
+
functions: inScope
|
|
2894
|
+
}
|
|
2895
|
+
};
|
|
2896
|
+
};
|
|
2897
|
+
function screenInputProblems(host, controlMap, screens, features, functions, enums) {
|
|
2898
|
+
const byId = new Map(screens.map((screen) => [screen.id, screen]));
|
|
2899
|
+
const problems = [];
|
|
2900
|
+
for (const control of Object.values(controlMap)) {
|
|
2901
|
+
if (!isScreenControl(control)) continue;
|
|
2902
|
+
const target2 = byId.get(control.screenId);
|
|
2903
|
+
if (!target2) continue;
|
|
2904
|
+
const bound = control.screenInputs ?? {};
|
|
2905
|
+
const scope = sourceScope(
|
|
2906
|
+
host,
|
|
2907
|
+
control,
|
|
2908
|
+
controlMap,
|
|
2909
|
+
features,
|
|
2910
|
+
functions,
|
|
2911
|
+
enums
|
|
2912
|
+
);
|
|
2913
|
+
for (const input of (0, import_codegen33.listScreenInputs)(target2.inputs)) {
|
|
2914
|
+
if (input.origin) continue;
|
|
2915
|
+
const binding = bound[input.id];
|
|
2916
|
+
const row = {
|
|
2917
|
+
controlId: control.id,
|
|
2918
|
+
targetScreenId: target2.id,
|
|
2919
|
+
inputId: input.id,
|
|
2920
|
+
inputName: input.name
|
|
2921
|
+
};
|
|
2922
|
+
if (!binding || binding.kind === "output" && input.required) {
|
|
2923
|
+
if (input.required) problems.push({ kind: "required-unbound", ...row });
|
|
2924
|
+
continue;
|
|
2925
|
+
}
|
|
2926
|
+
const fits = binding.kind === "static" ? staticFits(input, binding.value) : binding.kind === "output" ? outputFits(input, binding, controlMap, screens) : (0, import_codegen33.screenInputSourceOptions)(scope, {
|
|
2927
|
+
dataType: (0, import_codegen33.inputPrimitive)(input),
|
|
2928
|
+
cardinality: input.cardinality,
|
|
2929
|
+
declared: input.dataType,
|
|
2930
|
+
required: input.required
|
|
2931
|
+
}).some(
|
|
2932
|
+
(option) => option.value === (0, import_codegen33.screenInputSourceValue)(binding)
|
|
2933
|
+
);
|
|
2934
|
+
if (!fits) problems.push({ kind: "unfit", ...row });
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
return problems;
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/screen-input-bound.ts
|
|
2941
|
+
var screenInputBound = defineInvariant({
|
|
2942
|
+
name: "screen-input-bound",
|
|
2943
|
+
message: "invariant-screen-input-unbound",
|
|
2944
|
+
severity: "blocking",
|
|
2945
|
+
deps: [
|
|
2946
|
+
"screens",
|
|
2947
|
+
"screenControlMaps",
|
|
2948
|
+
"features",
|
|
2949
|
+
"functions",
|
|
2950
|
+
"enums"
|
|
2951
|
+
],
|
|
2952
|
+
validate: ({ screens, screenControlMaps, features, functions, enums }) => screens.flatMap((host) => {
|
|
2953
|
+
const controlMap = screenControlMaps[host.id] ?? {};
|
|
2954
|
+
const byId = new Map(screens.map((screen) => [screen.id, screen]));
|
|
2955
|
+
return screenInputProblems(
|
|
2956
|
+
host,
|
|
2957
|
+
controlMap,
|
|
2958
|
+
screens,
|
|
2959
|
+
features,
|
|
2960
|
+
functions,
|
|
2961
|
+
enums
|
|
2962
|
+
).map((problem) => ({
|
|
2963
|
+
message: problem.kind === "unfit" ? "invariant-screen-input-unfit" : "invariant-screen-input-unbound",
|
|
2964
|
+
subject: `${host.name} \u2192 ${byId.get(problem.targetScreenId)?.name ?? problem.targetScreenId}: ${problem.inputName}`,
|
|
2965
|
+
target: {
|
|
2966
|
+
kind: "control",
|
|
2967
|
+
screenId: host.id,
|
|
2968
|
+
controlId: problem.controlId,
|
|
2969
|
+
inputId: problem.inputId
|
|
2970
|
+
}
|
|
2971
|
+
}));
|
|
2972
|
+
})
|
|
2973
|
+
});
|
|
2974
|
+
|
|
2975
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/per-screen.ts
|
|
2976
|
+
function perScreen(judge) {
|
|
2977
|
+
const held = /* @__PURE__ */ new Map();
|
|
2978
|
+
const sameDeps = (a, b) => Object.keys(b).every((key) => a[key] === b[key]);
|
|
2979
|
+
return (screens, controlMaps, deps) => screens.flatMap((screen) => {
|
|
2980
|
+
const controlMap = controlMaps[screen.id];
|
|
2981
|
+
if (!controlMap) return [];
|
|
2982
|
+
const kept = held.get(screen.id);
|
|
2983
|
+
if (kept && kept.controlMap === controlMap && kept.screen === screen && sameDeps(kept.deps, deps)) {
|
|
2984
|
+
return kept.answer;
|
|
2985
|
+
}
|
|
2986
|
+
const answer = judge(controlMap, screen, deps);
|
|
2987
|
+
held.set(screen.id, { controlMap, screen, deps, answer });
|
|
2988
|
+
return answer;
|
|
2989
|
+
});
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/branch-arm-reachable.ts
|
|
2993
|
+
var import_codegen34 = require("./index.js");
|
|
2994
|
+
var ATOM_CAP = 12;
|
|
2995
|
+
var foldText = (arm, names) => (0, import_codegen34.controlVariants)(arm).map((entry, index) => {
|
|
2996
|
+
const name = names.get(entry.id) ?? entry.id;
|
|
2997
|
+
const term = (0, import_codegen34.variantJoinIsNot)(entry.join) ? `!${name}` : name;
|
|
2998
|
+
if (index === 0) return term;
|
|
2999
|
+
return `${(0, import_codegen34.variantJoinIsAnd)(entry.join) ? "&&" : "||"} ${term}`;
|
|
3000
|
+
}).join(" ");
|
|
3001
|
+
var armSubject = (arm, names) => (0, import_codegen34.armKind)(arm) === "default" ? import_codegen34.ARM_KIND_LABEL.default : foldText(arm, names) || import_codegen34.ARM_KIND_LABEL.branch;
|
|
3002
|
+
var variantNames = (features, screens, currentScreenId) => {
|
|
3003
|
+
const screen = screens.find((one) => one.id === currentScreenId);
|
|
3004
|
+
const feature = screen?.featureId ? features[screen.featureId] : void 0;
|
|
3005
|
+
const names = /* @__PURE__ */ new Map();
|
|
3006
|
+
Object.values(feature?.variants ?? {}).forEach(
|
|
3007
|
+
(variant) => names.set(variant.id, variant.name)
|
|
3008
|
+
);
|
|
3009
|
+
return names;
|
|
3010
|
+
};
|
|
3011
|
+
var unreachableArmIds = (branchId, controlMap) => {
|
|
3012
|
+
const arms = (0, import_codegen34.orderedArms)(branchId, controlMap).filter(
|
|
3013
|
+
(arm) => (0, import_codegen34.armKind)(arm) === "default" || (0, import_codegen34.controlVariants)(arm).length > 0
|
|
3014
|
+
);
|
|
3015
|
+
if (arms.length < 2) return [];
|
|
3016
|
+
const atoms = [
|
|
3017
|
+
...new Set(
|
|
3018
|
+
arms.flatMap((arm) => (0, import_codegen34.controlVariants)(arm).map((entry) => entry.id))
|
|
3019
|
+
)
|
|
3020
|
+
];
|
|
3021
|
+
if (atoms.length > ATOM_CAP) return [];
|
|
3022
|
+
const reached = /* @__PURE__ */ new Set();
|
|
3023
|
+
const rows = 1 << atoms.length;
|
|
3024
|
+
for (let row = 0; row < rows; row++) {
|
|
3025
|
+
const on = atoms.filter((_, index) => row & 1 << index);
|
|
3026
|
+
for (const arm of arms) {
|
|
3027
|
+
if ((0, import_codegen34.armKind)(arm) === "default" || (0, import_codegen34.evaluateVariantGate)((0, import_codegen34.controlVariants)(arm), on)) {
|
|
3028
|
+
reached.add(arm.id);
|
|
3029
|
+
break;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
return arms.filter((arm) => !reached.has(arm.id)).map((arm) => arm.id);
|
|
3034
|
+
};
|
|
3035
|
+
var unreachableArms = perScreen(
|
|
3036
|
+
(controlMap, screen, { features, screens }) => {
|
|
3037
|
+
const names = variantNames(features, screens, screen.id);
|
|
3038
|
+
return Object.entries(controlMap).flatMap(([branchId, control]) => {
|
|
3039
|
+
if (control.type !== import_codegen34.ControlType.VARIANT_BRANCH) return [];
|
|
3040
|
+
return unreachableArmIds(branchId, controlMap).map((armId) => ({
|
|
3041
|
+
subject: armSubject(controlMap[armId], names),
|
|
3042
|
+
target: {
|
|
3043
|
+
kind: "control",
|
|
3044
|
+
screenId: screen.id,
|
|
3045
|
+
controlId: armId
|
|
3046
|
+
}
|
|
3047
|
+
}));
|
|
3048
|
+
});
|
|
3049
|
+
}
|
|
3050
|
+
);
|
|
3051
|
+
var branchArmReachable = defineInvariant({
|
|
3052
|
+
name: "branch-arm-reachable",
|
|
3053
|
+
message: "invariant-branch-arm-unreachable",
|
|
3054
|
+
severity: "advisory",
|
|
3055
|
+
// Every Screen, each judged again only when its own Controls move (ADR 0192).
|
|
3056
|
+
deps: ["screenControlMaps", "features", "screens"],
|
|
3057
|
+
validate: ({ screenControlMaps, features, screens }) => unreachableArms(screens, screenControlMaps, { features, screens })
|
|
3058
|
+
});
|
|
3059
|
+
|
|
3060
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/computed-args-bound.ts
|
|
3061
|
+
var import_codegen35 = require("./index.js");
|
|
3062
|
+
var computedArgsBound = defineInvariant({
|
|
3063
|
+
name: "computed-args-bound",
|
|
3064
|
+
message: "invariant-computed-args-unbound",
|
|
3065
|
+
severity: "advisory",
|
|
3066
|
+
deps: ["features", "screens", "functions"],
|
|
3067
|
+
validate: ({ features, screens, functions }) => {
|
|
3068
|
+
const scopeFor = (featureId) => featureId ? { ...functions, ...features[featureId]?.functions ?? {} } : functions;
|
|
3069
|
+
const broken = (fn, args) => !fn || !(0, import_codegen35.argsComplete)(fn, args);
|
|
3070
|
+
const stateFindings = Object.values(features).flatMap((feature) => {
|
|
3071
|
+
const fns = scopeFor(feature.id);
|
|
3072
|
+
const screenId = screens.find((screen) => screen.featureId === feature.id)?.id ?? "";
|
|
3073
|
+
return Object.values(feature.computeds ?? {}).filter((computed) => broken((0, import_codegen35.stateComputedFunction)(computed, fns), computed.args)).map((computed) => ({
|
|
3074
|
+
subject: `${feature.name}.${computed.name}`,
|
|
3075
|
+
target: { kind: "screen", screenId }
|
|
3076
|
+
}));
|
|
3077
|
+
});
|
|
3078
|
+
const screenFindings = screens.flatMap((screen) => {
|
|
3079
|
+
const fns = scopeFor(
|
|
3080
|
+
(0, import_codegen35.isFeatureScreen)(screen) ? screen.featureId : void 0
|
|
3081
|
+
);
|
|
3082
|
+
return Object.values(screen.computeds ?? {}).filter(
|
|
3083
|
+
(computed) => broken((0, import_codegen35.screenComputedFunction)(computed, fns), computed.args)
|
|
3084
|
+
).map((computed) => ({
|
|
3085
|
+
subject: `${screen.name}.${computed.name}`,
|
|
3086
|
+
target: { kind: "screen", screenId: screen.id }
|
|
3087
|
+
}));
|
|
3088
|
+
});
|
|
3089
|
+
return [...stateFindings, ...screenFindings];
|
|
3090
|
+
}
|
|
3091
|
+
});
|
|
3092
|
+
|
|
3093
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/computed-args-typed.ts
|
|
3094
|
+
var import_codegen36 = require("./index.js");
|
|
3095
|
+
var computedArgsTyped = defineInvariant({
|
|
3096
|
+
name: "computed-args-typed",
|
|
3097
|
+
message: "invariant-computed-args-mistyped",
|
|
3098
|
+
severity: "blocking",
|
|
3099
|
+
deps: ["features", "screens", "screenControlMaps", "functions"],
|
|
3100
|
+
validate: ({ features, screens, screenControlMaps, functions }) => {
|
|
3101
|
+
const scopeFor = (featureId) => featureId ? { ...functions, ...features[featureId]?.functions ?? {} } : functions;
|
|
3102
|
+
const stateFindings = Object.values(features).flatMap((feature) => {
|
|
3103
|
+
const fns = scopeFor(feature.id);
|
|
3104
|
+
const screenId = screens.find((screen) => screen.featureId === feature.id)?.id ?? "";
|
|
3105
|
+
const roots = (0, import_codegen36.propertiesWithComputeds)(
|
|
3106
|
+
feature.properties,
|
|
3107
|
+
feature.computeds,
|
|
3108
|
+
fns
|
|
3109
|
+
);
|
|
3110
|
+
return Object.values(feature.computeds ?? {}).flatMap(
|
|
3111
|
+
(computed) => (
|
|
3112
|
+
// A OneFunction call has no signature to repair; its own Invariant
|
|
3113
|
+
// raises it (`one-function-arg-mismatch`, ADR 0218).
|
|
3114
|
+
computed.functionId ? [{ ...computed, functionId: computed.functionId }] : []
|
|
3115
|
+
)
|
|
3116
|
+
).filter((computed) => {
|
|
3117
|
+
const fn = fns[computed.functionId];
|
|
3118
|
+
return !!fn && (0, import_codegen36.mistypedStateArgs)(fn, computed.args, roots, feature.shapes).length > 0;
|
|
3119
|
+
}).map((computed) => ({
|
|
3120
|
+
subject: `${feature.name}.${computed.name}`,
|
|
3121
|
+
target: { kind: "screen", screenId },
|
|
3122
|
+
computedFix: {
|
|
3123
|
+
computedId: computed.id,
|
|
3124
|
+
featureId: feature.id,
|
|
3125
|
+
functionId: computed.functionId,
|
|
3126
|
+
params: fns[computed.functionId].params.map((param) => {
|
|
3127
|
+
const held = (0, import_codegen36.stateComputedArgHeldType)(
|
|
3128
|
+
computed.args[param.id],
|
|
3129
|
+
roots,
|
|
3130
|
+
feature.shapes
|
|
3131
|
+
);
|
|
3132
|
+
return held && !(0, import_codegen36.argAnswersParam)(held, param, feature.shapes) ? { ...param, ...held } : param;
|
|
3133
|
+
})
|
|
3134
|
+
}
|
|
3135
|
+
}));
|
|
3136
|
+
});
|
|
3137
|
+
const screenFindings = screens.flatMap((screen) => {
|
|
3138
|
+
const featureId = (0, import_codegen36.isFeatureScreen)(screen) ? screen.featureId : void 0;
|
|
3139
|
+
const fns = scopeFor(featureId);
|
|
3140
|
+
const feature = featureId ? features[featureId] : void 0;
|
|
3141
|
+
const scope = {
|
|
3142
|
+
constants: screen.constants,
|
|
3143
|
+
variables: (0, import_codegen36.withVariableEnums)(
|
|
3144
|
+
screen.variables ?? {},
|
|
3145
|
+
screenControlMaps[screen.id] ?? {}
|
|
3146
|
+
),
|
|
3147
|
+
properties: feature ? (0, import_codegen36.propertiesWithComputeds)(
|
|
3148
|
+
feature.properties,
|
|
3149
|
+
feature.computeds,
|
|
3150
|
+
fns
|
|
3151
|
+
) : {},
|
|
3152
|
+
shapes: feature?.shapes ?? {}
|
|
3153
|
+
};
|
|
3154
|
+
return Object.values(screen.computeds ?? {}).filter((computed) => {
|
|
3155
|
+
if ((0, import_codegen36.isOneFunctionComputed)(computed)) return false;
|
|
3156
|
+
const fn = (0, import_codegen36.screenComputedFunction)(computed, fns);
|
|
3157
|
+
return !!fn && (0, import_codegen36.mistypedScreenArgs)(
|
|
3158
|
+
fn,
|
|
3159
|
+
computed.args,
|
|
3160
|
+
screen.inputs ?? {},
|
|
3161
|
+
screen.computeds ?? {},
|
|
3162
|
+
fns,
|
|
3163
|
+
scope
|
|
3164
|
+
).length > 0;
|
|
3165
|
+
}).map((computed) => {
|
|
3166
|
+
const fn = (0, import_codegen36.screenComputedFunction)(computed, fns);
|
|
3167
|
+
const params = fn.params.map((param) => {
|
|
3168
|
+
const arg = computed.args[param.id];
|
|
3169
|
+
const shapeId = arg?.source === "options" ? (0, import_codegen36.findOptionRowShapeId)(scope.shapes) : void 0;
|
|
3170
|
+
const held = shapeId ? {
|
|
3171
|
+
dataType: { type: "shape", shapeId },
|
|
3172
|
+
cardinality: "many"
|
|
3173
|
+
} : (0, import_codegen36.screenComputedArgHeldType)(
|
|
3174
|
+
arg,
|
|
3175
|
+
screen.inputs ?? {},
|
|
3176
|
+
screen.computeds ?? {},
|
|
3177
|
+
fns,
|
|
3178
|
+
scope
|
|
3179
|
+
);
|
|
3180
|
+
return held && !(0, import_codegen36.argAnswersParam)(held, param, scope.shapes) ? { ...param, ...held } : param;
|
|
3181
|
+
});
|
|
3182
|
+
const repaired = { ...fn, params };
|
|
3183
|
+
const canFix = !(0, import_codegen36.isPassthroughComputed)(computed) && !(0, import_codegen36.isOneFunctionComputed)(computed) && (0, import_codegen36.mistypedScreenArgs)(
|
|
3184
|
+
repaired,
|
|
3185
|
+
computed.args,
|
|
3186
|
+
screen.inputs ?? {},
|
|
3187
|
+
screen.computeds ?? {},
|
|
3188
|
+
fns,
|
|
3189
|
+
scope
|
|
3190
|
+
).length === 0;
|
|
3191
|
+
return {
|
|
3192
|
+
subject: `${screen.name}.${computed.name}`,
|
|
3193
|
+
target: { kind: "screen", screenId: screen.id },
|
|
3194
|
+
...canFix ? {
|
|
3195
|
+
computedFix: {
|
|
3196
|
+
computedId: computed.id,
|
|
3197
|
+
featureId,
|
|
3198
|
+
functionId: fn.id,
|
|
3199
|
+
params
|
|
3200
|
+
}
|
|
3201
|
+
} : {}
|
|
3202
|
+
};
|
|
3203
|
+
});
|
|
3204
|
+
});
|
|
3205
|
+
return [...stateFindings, ...screenFindings];
|
|
3206
|
+
}
|
|
3207
|
+
});
|
|
3208
|
+
|
|
3209
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/one-function-arg-mismatch.ts
|
|
3210
|
+
var import_codegen37 = require("./index.js");
|
|
3211
|
+
var sameDataType = (a, b) => a.type === "shape" ? b.type === "shape" && a.shapeId === b.shapeId : a.type === "form" ? b.type === "form" && a.formId === b.formId : a.type === b.type;
|
|
3212
|
+
var oneFunctionArgMismatch = defineInvariant({
|
|
3213
|
+
name: "one-function-arg-mismatch",
|
|
3214
|
+
message: "invariant-one-function-arg-mismatch",
|
|
3215
|
+
severity: "blocking",
|
|
3216
|
+
deps: ["features", "screens", "functions"],
|
|
3217
|
+
validate: ({ features, screens, functions }) => [
|
|
3218
|
+
...screens.flatMap((screen) => {
|
|
3219
|
+
const featureId = (0, import_codegen37.isFeatureScreen)(screen) ? screen.featureId : void 0;
|
|
3220
|
+
const feature = featureId ? features[featureId] : void 0;
|
|
3221
|
+
const fns = feature ? { ...functions, ...feature.functions ?? {} } : functions;
|
|
3222
|
+
const scope = {
|
|
3223
|
+
constants: screen.constants,
|
|
3224
|
+
variables: screen.variables,
|
|
3225
|
+
properties: feature ? (0, import_codegen37.propertiesWithComputeds)(feature.properties, feature.computeds, fns) : {},
|
|
3226
|
+
shapes: feature?.shapes ?? {}
|
|
3227
|
+
};
|
|
3228
|
+
return Object.values(screen.computeds ?? {}).filter(import_codegen37.isOneFunctionComputed).filter((computed) => {
|
|
3229
|
+
const entry = (0, import_codegen37.oneFunctionOf)(computed.oneFunction);
|
|
3230
|
+
const returns = computed.returns;
|
|
3231
|
+
if (!entry || !returns) return false;
|
|
3232
|
+
if (!feature) return true;
|
|
3233
|
+
return entry.params.some((param) => {
|
|
3234
|
+
const arg = computed.args[param.id];
|
|
3235
|
+
if (!arg) return false;
|
|
3236
|
+
const held = (0, import_codegen37.screenComputedArgHeldType)(
|
|
3237
|
+
arg,
|
|
3238
|
+
screen.inputs ?? {},
|
|
3239
|
+
screen.computeds ?? {},
|
|
3240
|
+
fns,
|
|
3241
|
+
scope
|
|
3242
|
+
);
|
|
3243
|
+
if (!held) return false;
|
|
3244
|
+
if (!(0, import_codegen37.oneFunctionArgFits)(param, held, arg.source === "path"))
|
|
3245
|
+
return true;
|
|
3246
|
+
return entry.returnsRow && param.id === entry.rowParamId && (!sameDataType(held.dataType, returns.dataType) || // A `map` turned `map-many` (or back) moves the return
|
|
3247
|
+
// between the row and the row list (ADR 0205).
|
|
3248
|
+
(0, import_codegen37.oneFunctionReturns)(entry, held.dataType, held.cardinality).cardinality !== returns.cardinality);
|
|
3249
|
+
});
|
|
3250
|
+
}).map((computed) => ({
|
|
3251
|
+
subject: `${screen.name}.${computed.name}`,
|
|
3252
|
+
// Its own editor is where the binding is re-saved.
|
|
3253
|
+
target: {
|
|
3254
|
+
kind: "screen",
|
|
3255
|
+
screenId: screen.id,
|
|
3256
|
+
panel: "screen",
|
|
3257
|
+
computedId: computed.id
|
|
3258
|
+
}
|
|
3259
|
+
}));
|
|
3260
|
+
}),
|
|
3261
|
+
...Object.values(features).flatMap(
|
|
3262
|
+
(feature) => conditionFindings(feature, functions)
|
|
3263
|
+
),
|
|
3264
|
+
...Object.values(features).flatMap(
|
|
3265
|
+
(feature) => stateComputedFindings(feature, functions)
|
|
3266
|
+
)
|
|
3267
|
+
]
|
|
3268
|
+
});
|
|
3269
|
+
function stateComputedFindings(feature, functions) {
|
|
3270
|
+
const fns = { ...functions, ...feature.functions ?? {} };
|
|
3271
|
+
const stores = (0, import_codegen37.storesOf)(feature);
|
|
3272
|
+
const roots = Object.assign(
|
|
3273
|
+
{},
|
|
3274
|
+
...stores.map(
|
|
3275
|
+
(owned) => (0, import_codegen37.propertiesWithComputeds)(owned.properties, owned.computeds, fns)
|
|
3276
|
+
)
|
|
3277
|
+
);
|
|
3278
|
+
return stores.flatMap(
|
|
3279
|
+
(owned) => Object.values(owned.computeds).filter(import_codegen37.isOneFunctionStateComputed).filter((computed) => {
|
|
3280
|
+
const entry = (0, import_codegen37.oneFunctionOf)(computed.oneFunction);
|
|
3281
|
+
const returns = computed.returns;
|
|
3282
|
+
if (!entry?.reach.includes("state-computed") || !returns) return false;
|
|
3283
|
+
const rowArg = computed.args[entry.rowParamId];
|
|
3284
|
+
const row = rowArg?.source === "path" ? (0, import_codegen37.statePathHeldType)(rowArg.path, roots, feature.shapes) : void 0;
|
|
3285
|
+
const fits = entry.params.every((param) => {
|
|
3286
|
+
const arg = computed.args[param.id];
|
|
3287
|
+
if (!arg) return true;
|
|
3288
|
+
const held = arg.source === "fixed" ? (0, import_codegen37.oneParamFixedHeld)(param, arg.value) : (0, import_codegen37.statePathHeldType)(arg.path, roots, feature.shapes);
|
|
3289
|
+
if (arg.source === "path" && !held) return true;
|
|
3290
|
+
return (0, import_codegen37.oneFunctionArgFits)(param, held, arg.source === "path");
|
|
3291
|
+
});
|
|
3292
|
+
if (!fits) return true;
|
|
3293
|
+
if (entry.returnsRow && row && (!sameDataType(row.dataType, returns.dataType) || (0, import_codegen37.oneFunctionReturns)(entry, row.dataType, row.cardinality).cardinality !== returns.cardinality))
|
|
3294
|
+
return true;
|
|
3295
|
+
const key = computed.args[import_codegen37.ONE_FUNCTION_KEY_PARAM];
|
|
3296
|
+
if (key?.source === "fixed" && entry.params.some((param) => param.id === import_codegen37.ONE_FUNCTION_KEY_PARAM) && row?.dataType.type === "shape") {
|
|
3297
|
+
const shape = feature.shapes[row.dataType.shapeId];
|
|
3298
|
+
return !!shape && !shape.keys.some(
|
|
3299
|
+
(member) => member.name === key.value && member.cardinality === "one" && member.dataType.type === "string"
|
|
3300
|
+
);
|
|
3301
|
+
}
|
|
3302
|
+
return false;
|
|
3303
|
+
}).map((computed) => ({
|
|
3304
|
+
subject: `${feature.name}.${computed.name}`,
|
|
3305
|
+
target: {
|
|
3306
|
+
kind: "panel",
|
|
3307
|
+
panel: "store",
|
|
3308
|
+
featureId: feature.id,
|
|
3309
|
+
...owned.subStore ? { subStoreId: owned.subStore.id } : {},
|
|
3310
|
+
memberId: computed.id
|
|
3311
|
+
}
|
|
3312
|
+
}))
|
|
3313
|
+
);
|
|
3314
|
+
}
|
|
3315
|
+
function conditionFindings(feature, functions) {
|
|
3316
|
+
const fns = { ...functions, ...feature.functions ?? {} };
|
|
3317
|
+
const stores = (0, import_codegen37.storesOf)(feature);
|
|
3318
|
+
const roots = Object.assign(
|
|
3319
|
+
{},
|
|
3320
|
+
...stores.map(
|
|
3321
|
+
(owned) => (0, import_codegen37.propertiesWithComputeds)(owned.properties, owned.computeds, fns)
|
|
3322
|
+
)
|
|
3323
|
+
);
|
|
3324
|
+
const mismatched = (condition) => {
|
|
3325
|
+
if (!condition.oneFunction) return false;
|
|
3326
|
+
const entry = (0, import_codegen37.oneFunctionOf)(condition.oneFunction);
|
|
3327
|
+
if (!entry?.reach.includes("call-condition")) return true;
|
|
3328
|
+
return entry.params.some((param) => {
|
|
3329
|
+
const binding = condition.args[param.id];
|
|
3330
|
+
if (binding?.source !== "store") return false;
|
|
3331
|
+
const held = (0, import_codegen37.statePathHeldType)(binding.path, roots, feature.shapes);
|
|
3332
|
+
return !!held && !(0, import_codegen37.oneFunctionArgFits)(param, held, true);
|
|
3333
|
+
});
|
|
3334
|
+
};
|
|
3335
|
+
const computeMismatched = (compute) => {
|
|
3336
|
+
if (!compute.oneFunction) return false;
|
|
3337
|
+
const entry = (0, import_codegen37.oneFunctionOf)(compute.oneFunction);
|
|
3338
|
+
if (!entry?.reach.includes("call-compute") || !compute.returns) return true;
|
|
3339
|
+
const returns = compute.returns;
|
|
3340
|
+
return entry.params.some((param) => {
|
|
3341
|
+
const binding = compute.args[param.id];
|
|
3342
|
+
if (binding?.source !== "store") return false;
|
|
3343
|
+
const held = (0, import_codegen37.statePathHeldType)(binding.path, roots, feature.shapes);
|
|
3344
|
+
if (!held) return false;
|
|
3345
|
+
if (!(0, import_codegen37.oneFunctionArgFits)(param, held, true)) return true;
|
|
3346
|
+
return entry.returnsRow && param.id === entry.rowParamId && (!sameDataType(held.dataType, returns.dataType) || (0, import_codegen37.oneFunctionReturns)(entry, held.dataType, held.cardinality).cardinality !== returns.cardinality);
|
|
3347
|
+
});
|
|
3348
|
+
};
|
|
3349
|
+
return stores.flatMap(
|
|
3350
|
+
(owned) => Object.values(owned.methods).filter(
|
|
3351
|
+
(method) => (method.conditions ?? []).some(mismatched) || (method.computes ?? []).some(computeMismatched)
|
|
3352
|
+
).map((method) => ({
|
|
3353
|
+
subject: `${feature.name}.${method.name}`,
|
|
3354
|
+
target: {
|
|
3355
|
+
kind: "panel",
|
|
3356
|
+
panel: "store",
|
|
3357
|
+
featureId: feature.id,
|
|
3358
|
+
...owned.subStore ? { subStoreId: owned.subStore.id } : {},
|
|
3359
|
+
memberId: method.id
|
|
3360
|
+
}
|
|
3361
|
+
}))
|
|
3362
|
+
);
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3365
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/one-function-required-param.ts
|
|
3366
|
+
var import_codegen38 = require("./index.js");
|
|
3367
|
+
var requiresParam = (method, name) => (method.params ?? []).some(
|
|
3368
|
+
(param) => param.name === name && param.required === true
|
|
3369
|
+
) || method.inputs.some(
|
|
3370
|
+
(mapping) => mapping.source === "args" && mapping.arg === name && mapping.target[0] === "path"
|
|
3371
|
+
);
|
|
3372
|
+
var oneFunctionRequiredParam = defineInvariant({
|
|
3373
|
+
name: "one-function-required-param",
|
|
3374
|
+
message: "invariant-one-function-required-param",
|
|
3375
|
+
severity: "blocking",
|
|
3376
|
+
deps: ["features", "screens", "screenControlMaps"],
|
|
3377
|
+
validate: ({ features, screens, screenControlMaps }) => screens.flatMap((screen) => {
|
|
3378
|
+
if (!(0, import_codegen38.isFeatureScreen)(screen)) return [];
|
|
3379
|
+
const feature = features[screen.featureId];
|
|
3380
|
+
if (!feature) return [];
|
|
3381
|
+
const methods = Object.assign(
|
|
3382
|
+
{},
|
|
3383
|
+
...(0, import_codegen38.storesOf)(feature).map((owned) => owned.methods)
|
|
3384
|
+
);
|
|
3385
|
+
const computeds = screen.computeds ?? {};
|
|
3386
|
+
return Object.values(screenControlMaps[screen.id] ?? {}).flatMap(
|
|
3387
|
+
(control) => Object.entries(control.outputs ?? {}).flatMap(
|
|
3388
|
+
([output, methodId]) => {
|
|
3389
|
+
const method = methods[methodId];
|
|
3390
|
+
if (!method) return [];
|
|
3391
|
+
return (control.outputArgs?.[output] ?? []).filter((row) => {
|
|
3392
|
+
const root = row.binding?.root;
|
|
3393
|
+
if (row.source !== "binding" || root?.kind !== "screen_computed")
|
|
3394
|
+
return false;
|
|
3395
|
+
const computed = computeds[root.id];
|
|
3396
|
+
const name = row.target[0];
|
|
3397
|
+
return !!computed && (0, import_codegen38.isOneFunctionComputed)(computed) && (0, import_codegen38.screenComputedFunction)(computed, {})?.returnUndefined === true && !!name && requiresParam(method, name);
|
|
3398
|
+
}).map((row) => ({
|
|
3399
|
+
subject: `${screen.name}.${method.name}(${row.target[0]})`,
|
|
3400
|
+
target: {
|
|
3401
|
+
kind: "control",
|
|
3402
|
+
screenId: screen.id,
|
|
3403
|
+
controlId: control.id
|
|
3404
|
+
}
|
|
3405
|
+
}));
|
|
3406
|
+
}
|
|
3407
|
+
)
|
|
3408
|
+
);
|
|
3409
|
+
})
|
|
3410
|
+
});
|
|
3411
|
+
|
|
3412
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/confirm-unattended-call.ts
|
|
3413
|
+
var import_codegen39 = require("./index.js");
|
|
3414
|
+
var confirmUnattendedCall = defineInvariant({
|
|
3415
|
+
name: "confirm-unattended-call",
|
|
3416
|
+
message: "invariant-confirm-unattended",
|
|
3417
|
+
severity: "advisory",
|
|
3418
|
+
deps: ["features", "screens"],
|
|
3419
|
+
validate: ({ features, screens }) => {
|
|
3420
|
+
const featureScreen = (featureId) => screens.find((screen) => screen.featureId === featureId)?.id ?? "";
|
|
3421
|
+
return Object.values(features).flatMap((feature) => {
|
|
3422
|
+
const asking = new Set(
|
|
3423
|
+
Object.values(feature.methods).filter((method) => !!(0, import_codegen39.drawnConfirm)(method)).map((method) => method.id)
|
|
3424
|
+
);
|
|
3425
|
+
if (!asking.size) return [];
|
|
3426
|
+
const named2 = (methodId) => feature.methods[methodId]?.name ?? methodId;
|
|
3427
|
+
const fromHook = (feature.hook?.calls ?? []).filter((call) => asking.has(call.methodId)).map((call) => ({
|
|
3428
|
+
subject: `${feature.name}.${named2(call.methodId)}`,
|
|
3429
|
+
target: {
|
|
3430
|
+
kind: "screen",
|
|
3431
|
+
screenId: featureScreen(feature.id)
|
|
3432
|
+
}
|
|
3433
|
+
}));
|
|
3434
|
+
const fromTimers = Object.values(feature.timers ?? {}).flatMap(
|
|
3435
|
+
(timer) => timer.calls.filter((call) => asking.has(call.methodId)).map((call) => ({
|
|
3436
|
+
subject: `${feature.name}.${timer.name} \u2192 ${named2(call.methodId)}`,
|
|
3437
|
+
target: {
|
|
3438
|
+
kind: "screen",
|
|
3439
|
+
screenId: featureScreen(feature.id)
|
|
3440
|
+
}
|
|
3441
|
+
}))
|
|
3442
|
+
);
|
|
3443
|
+
const fromAutoCalls = screens.filter((screen) => screen.featureId === feature.id).flatMap(
|
|
3444
|
+
(screen) => (screen.autoCalls ?? []).flatMap(
|
|
3445
|
+
(call) => call.methodId && asking.has(call.methodId) ? [call.methodId] : []
|
|
3446
|
+
).map((methodId) => ({
|
|
3447
|
+
subject: `${screen.name} \u2192 ${named2(methodId)}`,
|
|
3448
|
+
target: { kind: "screen", screenId: screen.id }
|
|
3449
|
+
}))
|
|
3450
|
+
);
|
|
3451
|
+
return [...fromHook, ...fromTimers, ...fromAutoCalls];
|
|
3452
|
+
});
|
|
3453
|
+
}
|
|
3454
|
+
});
|
|
3455
|
+
|
|
3456
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/close-overlay-off-overlay.ts
|
|
3457
|
+
var import_codegen41 = require("./index.js");
|
|
3458
|
+
|
|
3459
|
+
// apps/m-one-ui/src/app/pages/design/lib/screen-link.ts
|
|
3460
|
+
var import_codegen40 = require("./index.js");
|
|
3461
|
+
function overlayLinks(fromScreenId, map) {
|
|
3462
|
+
const links = [];
|
|
3463
|
+
Object.values(map).forEach((control) => {
|
|
3464
|
+
Object.entries(control.directives ?? {}).forEach(([name, directive]) => {
|
|
3465
|
+
if (!(0, import_codegen40.isOverlayDirectiveName)(name)) return;
|
|
3466
|
+
const configs = directive.overlayId ? map[directive.overlayId]?.configs : directive.configs;
|
|
3467
|
+
const component = configs?.["component"];
|
|
3468
|
+
if (typeof component !== "string" || !component) return;
|
|
3469
|
+
links.push({
|
|
3470
|
+
kind: "overlay-component",
|
|
3471
|
+
fromScreenId,
|
|
3472
|
+
controlId: directive.overlayId ?? control.id,
|
|
3473
|
+
toScreenId: component
|
|
3474
|
+
});
|
|
3475
|
+
});
|
|
3476
|
+
});
|
|
3477
|
+
return links;
|
|
3478
|
+
}
|
|
3479
|
+
var cardKind = (control) => control.type === import_codegen40.ControlType.SECTION_CAROUSEL ? "carousel-element" : "card-element";
|
|
3480
|
+
function controlMapLinks(fromScreenId, map) {
|
|
3481
|
+
const links = [];
|
|
3482
|
+
Object.values(map).forEach((control) => {
|
|
3483
|
+
if (isScreenControl(control)) {
|
|
3484
|
+
links.push({
|
|
3485
|
+
kind: "screen-control",
|
|
3486
|
+
fromScreenId,
|
|
3487
|
+
controlId: control.id,
|
|
3488
|
+
toScreenId: control.screenId
|
|
3489
|
+
});
|
|
3490
|
+
}
|
|
3491
|
+
const cardScreenId = control.cards?.screenId;
|
|
3492
|
+
if (cardScreenId) {
|
|
3493
|
+
links.push({
|
|
3494
|
+
kind: cardKind(control),
|
|
3495
|
+
fromScreenId,
|
|
3496
|
+
controlId: control.id,
|
|
3497
|
+
toScreenId: cardScreenId
|
|
3498
|
+
});
|
|
3499
|
+
}
|
|
3500
|
+
Object.keys(control.outputOpens ?? {}).forEach((output) => {
|
|
3501
|
+
const screenId = (0, import_codegen40.outputOpenOf)(control.outputOpens, output)?.screenId;
|
|
3502
|
+
if (!screenId) return;
|
|
3503
|
+
links.push({
|
|
3504
|
+
kind: "output-open",
|
|
3505
|
+
fromScreenId,
|
|
3506
|
+
controlId: control.id,
|
|
3507
|
+
toScreenId: screenId
|
|
3508
|
+
});
|
|
3509
|
+
});
|
|
3510
|
+
const searchScreenId = control.search?.screenId;
|
|
3511
|
+
if (searchScreenId) {
|
|
3512
|
+
links.push({
|
|
3513
|
+
kind: "search-results",
|
|
3514
|
+
fromScreenId,
|
|
3515
|
+
controlId: control.id,
|
|
3516
|
+
toScreenId: searchScreenId
|
|
3517
|
+
});
|
|
3518
|
+
}
|
|
3519
|
+
});
|
|
3520
|
+
return [...links, ...overlayLinks(fromScreenId, map)];
|
|
3521
|
+
}
|
|
3522
|
+
function navLinks(navMap) {
|
|
3523
|
+
const links = [];
|
|
3524
|
+
Object.values(navMap).forEach((nav) => {
|
|
3525
|
+
if (nav.pageId) {
|
|
3526
|
+
links.push({
|
|
3527
|
+
kind: "nav-url",
|
|
3528
|
+
fromNavId: nav.navId,
|
|
3529
|
+
toScreenId: nav.pageId
|
|
3530
|
+
});
|
|
3531
|
+
}
|
|
3532
|
+
if (nav.componentKey) {
|
|
3533
|
+
links.push({
|
|
3534
|
+
kind: "nav-component",
|
|
3535
|
+
fromNavId: nav.navId,
|
|
3536
|
+
toScreenId: nav.componentKey
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
if (nav.rowSource?.kind === "screen" && nav.rowSource.screenId) {
|
|
3540
|
+
links.push({
|
|
3541
|
+
kind: "nav-rows",
|
|
3542
|
+
fromNavId: nav.navId,
|
|
3543
|
+
toScreenId: nav.rowSource.screenId
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
if (nav.searchAnswer?.kind === "screen" && nav.searchAnswer.screenId) {
|
|
3547
|
+
links.push({
|
|
3548
|
+
kind: "search-answer",
|
|
3549
|
+
fromNavId: nav.navId,
|
|
3550
|
+
toScreenId: nav.searchAnswer.screenId
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
});
|
|
3554
|
+
return links;
|
|
3555
|
+
}
|
|
3556
|
+
function methodLinks(features) {
|
|
3557
|
+
const links = [];
|
|
3558
|
+
Object.values(features).forEach((feature) => {
|
|
3559
|
+
const stores = [
|
|
3560
|
+
{ subStoreId: void 0, methods: feature.methods },
|
|
3561
|
+
...Object.values(feature.subStores ?? {}).map((sub) => ({
|
|
3562
|
+
subStoreId: sub.id,
|
|
3563
|
+
methods: sub.methods
|
|
3564
|
+
}))
|
|
3565
|
+
];
|
|
3566
|
+
stores.forEach(({ subStoreId, methods }) => {
|
|
3567
|
+
Object.values(methods).forEach((method) => {
|
|
3568
|
+
const screenId = method.open?.screenId;
|
|
3569
|
+
if (!screenId) return;
|
|
3570
|
+
links.push({
|
|
3571
|
+
kind: "method-open",
|
|
3572
|
+
fromFeatureId: feature.id,
|
|
3573
|
+
methodId: method.id,
|
|
3574
|
+
...subStoreId ? { subStoreId } : {},
|
|
3575
|
+
toScreenId: screenId
|
|
3576
|
+
});
|
|
3577
|
+
});
|
|
3578
|
+
});
|
|
3579
|
+
});
|
|
3580
|
+
return links;
|
|
3581
|
+
}
|
|
3582
|
+
function screenLinks(maps, navMap, features = {}) {
|
|
3583
|
+
const fromControls = Object.entries(maps).flatMap(
|
|
3584
|
+
([screenId, map]) => controlMapLinks(screenId, map)
|
|
3585
|
+
);
|
|
3586
|
+
return [...fromControls, ...navLinks(navMap), ...methodLinks(features)];
|
|
3587
|
+
}
|
|
3588
|
+
var inboundLinks = (links, screenId) => links.filter((link) => link.toScreenId === screenId);
|
|
3589
|
+
|
|
3590
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/close-overlay-off-overlay.ts
|
|
3591
|
+
var OVERLAY_KINDS = [
|
|
3592
|
+
"overlay-component",
|
|
3593
|
+
"output-open",
|
|
3594
|
+
"method-open"
|
|
3595
|
+
];
|
|
3596
|
+
var closeOverlayOffOverlay = defineInvariant({
|
|
3597
|
+
name: "close-overlay-off-overlay",
|
|
3598
|
+
message: "invariant-close-overlay-off-overlay",
|
|
3599
|
+
severity: "advisory",
|
|
3600
|
+
// The link index's own dependencies. Read on a coarse change, the habit
|
|
3601
|
+
// ADR 0126 keeps: what opens a Screen is not this Screen's own business.
|
|
3602
|
+
deps: ["screens", "screenControlMaps", "navMap", "features"],
|
|
3603
|
+
validate: ({ screens, screenControlMaps, navMap, features }) => {
|
|
3604
|
+
const closing = screens.map((screen) => ({
|
|
3605
|
+
screen,
|
|
3606
|
+
controls: Object.values(screenControlMaps[screen.id] ?? {}).filter(
|
|
3607
|
+
import_codegen41.controlUsesOverlayRef
|
|
3608
|
+
)
|
|
3609
|
+
})).filter(({ controls }) => controls.length);
|
|
3610
|
+
if (!closing.length) return [];
|
|
3611
|
+
const links = screenLinks(screenControlMaps, navMap, features);
|
|
3612
|
+
return closing.flatMap(
|
|
3613
|
+
({ screen, controls }) => inboundLinks(links, screen.id).some(
|
|
3614
|
+
(link) => OVERLAY_KINDS.includes(link.kind)
|
|
3615
|
+
) ? [] : controls.map((control) => ({
|
|
3616
|
+
subject: `${screen.name} \u2192 ${String(
|
|
3617
|
+
control.configs["name"] ?? control.id
|
|
3618
|
+
)}`,
|
|
3619
|
+
target: {
|
|
3620
|
+
kind: "control",
|
|
3621
|
+
screenId: screen.id,
|
|
3622
|
+
controlId: control.id
|
|
3623
|
+
}
|
|
3624
|
+
}))
|
|
3625
|
+
);
|
|
3626
|
+
}
|
|
3627
|
+
});
|
|
3628
|
+
|
|
3629
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/outcome-unattended-call.ts
|
|
3630
|
+
var import_codegen42 = require("./index.js");
|
|
3631
|
+
var outcomeUnattendedCall = defineInvariant({
|
|
3632
|
+
name: "outcome-on-unattended-call",
|
|
3633
|
+
message: "invariant-outcome-unattended",
|
|
3634
|
+
severity: "advisory",
|
|
3635
|
+
// Every Screen's Controls rather than the open one's: a hook fires a method
|
|
3636
|
+
// some other Screen's button armed, and the finding belongs to the Feature.
|
|
3637
|
+
// Read on a coarse change, which is what this dependency already costs.
|
|
3638
|
+
deps: ["features", "screens", "screenControlMaps"],
|
|
3639
|
+
validate: ({ features, screens, screenControlMaps }) => {
|
|
3640
|
+
const featureScreen = (featureId) => screens.find((screen) => screen.featureId === featureId)?.id ?? "";
|
|
3641
|
+
return Object.values(features).flatMap((feature) => {
|
|
3642
|
+
const armed = (0, import_codegen42.methodArms)(
|
|
3643
|
+
screens.filter((screen) => screen.featureId === feature.id).map((screen) => screenControlMaps[screen.id] ?? {})
|
|
3644
|
+
);
|
|
3645
|
+
const wired = new Set(Object.keys(armed));
|
|
3646
|
+
if (!wired.size) return [];
|
|
3647
|
+
const named2 = (methodId) => feature.methods[methodId]?.name ?? methodId;
|
|
3648
|
+
const fromHook = (feature.hook?.calls ?? []).filter((call) => wired.has(call.methodId)).map((call) => ({
|
|
3649
|
+
subject: `${feature.name}.${named2(call.methodId)}`,
|
|
3650
|
+
target: {
|
|
3651
|
+
kind: "screen",
|
|
3652
|
+
screenId: featureScreen(feature.id)
|
|
3653
|
+
}
|
|
3654
|
+
}));
|
|
3655
|
+
const fromTimers = Object.values(feature.timers ?? {}).flatMap(
|
|
3656
|
+
(timer) => timer.calls.filter((call) => wired.has(call.methodId)).map((call) => ({
|
|
3657
|
+
subject: `${feature.name}.${timer.name} \u2192 ${named2(call.methodId)}`,
|
|
3658
|
+
target: {
|
|
3659
|
+
kind: "screen",
|
|
3660
|
+
screenId: featureScreen(feature.id)
|
|
3661
|
+
}
|
|
3662
|
+
}))
|
|
3663
|
+
);
|
|
3664
|
+
const fromAutoCalls = screens.filter((screen) => screen.featureId === feature.id).flatMap(
|
|
3665
|
+
(screen) => (screen.autoCalls ?? []).flatMap(
|
|
3666
|
+
(call) => call.methodId && wired.has(call.methodId) ? [call.methodId] : []
|
|
3667
|
+
).map((methodId) => ({
|
|
3668
|
+
subject: `${screen.name} \u2192 ${named2(methodId)}`,
|
|
3669
|
+
target: { kind: "screen", screenId: screen.id }
|
|
3670
|
+
}))
|
|
3671
|
+
);
|
|
3672
|
+
return [...fromHook, ...fromTimers, ...fromAutoCalls];
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
});
|
|
3676
|
+
|
|
3677
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/outcome-call-nested.ts
|
|
3678
|
+
var import_codegen43 = require("./index.js");
|
|
3679
|
+
var outcomeCallNested = defineInvariant({
|
|
3680
|
+
name: "outcome-call-nested",
|
|
3681
|
+
message: "invariant-outcome-call-nested",
|
|
3682
|
+
severity: "advisory",
|
|
3683
|
+
deps: ["screens", "screenControlMaps"],
|
|
3684
|
+
validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
|
|
3685
|
+
const onScreen = (outcomes) => outcomes.flatMap(import_codegen43.nestedOutcomeCalls).map((id) => ({
|
|
3686
|
+
subject: `${screen.name} \u2192 ${id}`,
|
|
3687
|
+
target: { kind: "screen", screenId: screen.id }
|
|
3688
|
+
}));
|
|
3689
|
+
const onControls = Object.values(
|
|
3690
|
+
screenControlMaps[screen.id] ?? {}
|
|
3691
|
+
).flatMap(
|
|
3692
|
+
(control) => Object.values(control.outputOutcomes ?? {}).flatMap(import_codegen43.nestedOutcomeCalls).map((id) => ({
|
|
3693
|
+
subject: `${screen.name} \u2192 ${control.id} \u2192 ${id}`,
|
|
3694
|
+
target: {
|
|
3695
|
+
kind: "control",
|
|
3696
|
+
screenId: screen.id,
|
|
3697
|
+
controlId: control.id
|
|
3698
|
+
}
|
|
3699
|
+
}))
|
|
3700
|
+
);
|
|
3701
|
+
return [
|
|
3702
|
+
...onControls,
|
|
3703
|
+
...onScreen([
|
|
3704
|
+
...Object.values(screen.methods ?? {}).flatMap((handler) => [
|
|
3705
|
+
handler.outcome,
|
|
3706
|
+
...(handler.calls ?? []).map((one) => one.outcome)
|
|
3707
|
+
]),
|
|
3708
|
+
...(screen.autoCalls ?? []).map((call) => call.outcome)
|
|
3709
|
+
])
|
|
3710
|
+
];
|
|
3711
|
+
})
|
|
3712
|
+
});
|
|
3713
|
+
|
|
3714
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/reaction-writes-own-watch.ts
|
|
3715
|
+
var reactionWritesOwnWatch = defineInvariant({
|
|
3716
|
+
name: "reaction-writes-own-watch",
|
|
3717
|
+
message: "invariant-reaction-writes-own-watch",
|
|
3718
|
+
severity: "blocking",
|
|
3719
|
+
deps: ["screens"],
|
|
3720
|
+
validate: ({ screens }) => screens.flatMap(
|
|
3721
|
+
(screen) => (screen.autoCalls ?? []).flatMap((call) => {
|
|
3722
|
+
const watched = new Set(
|
|
3723
|
+
(call.reads ?? []).filter((read) => !read.path.length).map(
|
|
3724
|
+
(read) => read.root.kind === "screen_variable" || read.root.kind === "property" ? `${read.root.kind}:${read.root.id}` : ""
|
|
3725
|
+
).filter(Boolean)
|
|
3726
|
+
);
|
|
3727
|
+
if (!watched.size) return [];
|
|
3728
|
+
const written = [
|
|
3729
|
+
...(call.screenWrites ?? []).map((row) => ({
|
|
3730
|
+
key: `screen_variable:${row.variableId}`,
|
|
3731
|
+
name: screen.variables?.[row.variableId]?.name ?? row.variableId
|
|
3732
|
+
})),
|
|
3733
|
+
...(call.writes ?? []).map((row) => ({
|
|
3734
|
+
key: `property:${row.propertyId}`,
|
|
3735
|
+
name: row.propertyId
|
|
3736
|
+
}))
|
|
3737
|
+
];
|
|
3738
|
+
return written.filter((row) => watched.has(row.key)).map((row) => ({
|
|
3739
|
+
subject: `${screen.name} \u2192 ${row.name}`,
|
|
3740
|
+
target: { kind: "screen", screenId: screen.id }
|
|
3741
|
+
}));
|
|
3742
|
+
})
|
|
3743
|
+
)
|
|
3744
|
+
});
|
|
3745
|
+
|
|
3746
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/outcome-nav-complete.ts
|
|
3747
|
+
var import_codegen44 = require("./index.js");
|
|
3748
|
+
var outcomeNavComplete = defineInvariant({
|
|
3749
|
+
name: "outcome-nav-complete",
|
|
3750
|
+
message: "invariant-outcome-nav-incomplete",
|
|
3751
|
+
severity: "advisory",
|
|
3752
|
+
deps: ["screens", "screenControlMaps", "navMap"],
|
|
3753
|
+
validate: ({ screens, screenControlMaps, navMap }) => screens.flatMap((screen) => {
|
|
3754
|
+
const controlMap = screenControlMaps[screen.id] ?? {};
|
|
3755
|
+
return Object.values(controlMap).flatMap((control) => {
|
|
3756
|
+
const broken = Object.values(control.outputOutcomes ?? {}).some(
|
|
3757
|
+
(outcome) => import_codegen44.OUTCOME_ARMS.some(
|
|
3758
|
+
(arm) => !!(0, import_codegen44.validateOutcomeNav)(outcome?.[arm]?.nav, navMap)
|
|
3759
|
+
)
|
|
3760
|
+
) || (0, import_codegen44.controlNavReferences)(control).some(
|
|
3761
|
+
(row) => row.some((navId) => !navMap[navId])
|
|
3762
|
+
);
|
|
3763
|
+
if (!broken) return [];
|
|
3764
|
+
return [
|
|
3765
|
+
{
|
|
3766
|
+
subject: `${screen.name} \u2192 ${String(control.configs["name"] ?? control.id)}`,
|
|
3767
|
+
target: {
|
|
3768
|
+
kind: "control",
|
|
3769
|
+
screenId: screen.id,
|
|
3770
|
+
controlId: control.id
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
];
|
|
3774
|
+
});
|
|
3775
|
+
})
|
|
3776
|
+
});
|
|
3777
|
+
|
|
3778
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/field-check-bound.ts
|
|
3779
|
+
var import_codegen45 = require("./index.js");
|
|
3780
|
+
var fieldCheckBound = defineInvariant({
|
|
3781
|
+
name: "field-check-bound",
|
|
3782
|
+
message: "invariant-field-check-unbound",
|
|
3783
|
+
severity: "advisory",
|
|
3784
|
+
// Every Screen, each judged again only when its own Controls move (ADR 0192).
|
|
3785
|
+
deps: ["screenControlMaps", "features", "functions", "screens"],
|
|
3786
|
+
validate: ({ screenControlMaps, features, functions, screens }) => unboundChecks(screens, screenControlMaps, { features, functions })
|
|
3787
|
+
});
|
|
3788
|
+
var unboundChecks = perScreen(
|
|
3789
|
+
(controlMap, screen, {
|
|
3790
|
+
features,
|
|
3791
|
+
functions
|
|
3792
|
+
}) => {
|
|
3793
|
+
const feature = (0, import_codegen45.isFeatureScreen)(screen) ? features[screen.featureId] : void 0;
|
|
3794
|
+
const properties = feature?.properties ?? {};
|
|
3795
|
+
const sources = (0, import_codegen45.limitSources)({
|
|
3796
|
+
inputs: screen.inputs,
|
|
3797
|
+
constants: screen.constants,
|
|
3798
|
+
variables: screen.variables,
|
|
3799
|
+
screenComputeds: screen.computeds,
|
|
3800
|
+
properties,
|
|
3801
|
+
computeds: feature?.computeds,
|
|
3802
|
+
functions: { ...functions, ...feature?.functions ?? {} }
|
|
3803
|
+
});
|
|
3804
|
+
return Object.entries(controlMap).flatMap(([controlId, control]) => {
|
|
3805
|
+
if (control.type !== import_codegen45.ControlType.FIELD) return [];
|
|
3806
|
+
const checks = (0, import_codegen45.fieldChecks)(control);
|
|
3807
|
+
if (!checks.length) return [];
|
|
3808
|
+
const formId = (0, import_codegen45.owningFormId)(controlId, controlMap);
|
|
3809
|
+
const broken = checks.some((check) => {
|
|
3810
|
+
if ((0, import_codegen45.checkKind)(check) !== "function") {
|
|
3811
|
+
return !(0, import_codegen45.isCheckComplete)(
|
|
3812
|
+
check,
|
|
3813
|
+
functions,
|
|
3814
|
+
controlMap,
|
|
3815
|
+
properties,
|
|
3816
|
+
sources
|
|
3817
|
+
);
|
|
3818
|
+
}
|
|
3819
|
+
const fn = functions[check.functionId];
|
|
3820
|
+
if (!fn) return true;
|
|
3821
|
+
if (!(0, import_codegen45.isFieldCheckEligible)(fn)) return true;
|
|
3822
|
+
const writtenFor = (0, import_codegen45.fieldCheckFormId)(fn);
|
|
3823
|
+
if (writtenFor && writtenFor !== formId) return true;
|
|
3824
|
+
return !(0, import_codegen45.isCheckComplete)(check, functions, controlMap, properties);
|
|
3825
|
+
});
|
|
3826
|
+
if (!broken) return [];
|
|
3827
|
+
return [
|
|
3828
|
+
{
|
|
3829
|
+
subject: (0, import_codegen45.resolveFieldName)({
|
|
3830
|
+
id: controlId,
|
|
3831
|
+
configs: control.configs
|
|
3832
|
+
}),
|
|
3833
|
+
target: {
|
|
3834
|
+
kind: "control",
|
|
3835
|
+
screenId: screen.id,
|
|
3836
|
+
controlId
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
];
|
|
3840
|
+
});
|
|
3841
|
+
}
|
|
3842
|
+
);
|
|
3843
|
+
|
|
3844
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/function-case-args.ts
|
|
3845
|
+
var import_codegen46 = require("./index.js");
|
|
3846
|
+
var functionCaseArgs = defineInvariant({
|
|
3847
|
+
name: "function-case-args",
|
|
3848
|
+
message: "invariant-function-case-args",
|
|
3849
|
+
severity: "advisory",
|
|
3850
|
+
deps: ["features", "functions", "sharedShapes"],
|
|
3851
|
+
validate: ({ features, functions, sharedShapes }) => {
|
|
3852
|
+
const shared = sharedShapes ?? {};
|
|
3853
|
+
return [
|
|
3854
|
+
...(0, import_codegen46.listFunctions)(functions).map((fn) => ({
|
|
3855
|
+
fn,
|
|
3856
|
+
featureId: void 0,
|
|
3857
|
+
shapes: (0, import_codegen46.shapesInReach)(void 0, shared)
|
|
3858
|
+
})),
|
|
3859
|
+
...Object.values(features).flatMap(
|
|
3860
|
+
(feature) => (0, import_codegen46.listFunctions)(feature.functions).map((fn) => ({
|
|
3861
|
+
fn,
|
|
3862
|
+
featureId: feature.id,
|
|
3863
|
+
shapes: (0, import_codegen46.shapesInReach)(feature, shared)
|
|
3864
|
+
}))
|
|
3865
|
+
)
|
|
3866
|
+
].filter(({ fn, shapes }) => (0, import_codegen46.staleCases)(fn, shapes).length > 0).map(({ fn, featureId, shapes }) => ({
|
|
3867
|
+
subject: `${fn.name}: ${(0, import_codegen46.staleCases)(fn, shapes).map((entry) => entry.name).join(", ")}`,
|
|
3868
|
+
target: {
|
|
3869
|
+
kind: "function",
|
|
3870
|
+
...featureId ? { featureId } : {},
|
|
3871
|
+
functionId: fn.id
|
|
3872
|
+
}
|
|
3873
|
+
}));
|
|
3874
|
+
}
|
|
3875
|
+
});
|
|
3876
|
+
|
|
3877
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/outcome-transform-self-fold.ts
|
|
3878
|
+
var import_codegen47 = require("./index.js");
|
|
3879
|
+
var outcomeTransformSelfFold = defineInvariant({
|
|
3880
|
+
name: "outcome-transform-self-fold",
|
|
3881
|
+
message: "invariant-outcome-transform-self-fold",
|
|
3882
|
+
severity: "advisory",
|
|
3883
|
+
deps: ["features"],
|
|
3884
|
+
validate: ({ features }) => Object.values(features).flatMap(
|
|
3885
|
+
(feature) => (0, import_codegen47.storesOf)(feature).flatMap((store) => {
|
|
3886
|
+
const methods = Object.values(store.methods ?? {});
|
|
3887
|
+
const landings = methods.flatMap(
|
|
3888
|
+
(method) => (method.response ?? []).map((mapping) => ({ method, mapping }))
|
|
3889
|
+
);
|
|
3890
|
+
const readsItself = ({ mapping }) => !!mapping.transform?.args.some(
|
|
3891
|
+
(arg) => arg.source === "state" && arg.path[0] === mapping.propertyId
|
|
3892
|
+
);
|
|
3893
|
+
return landings.filter((landing) => readsItself(landing)).filter(({ mapping }) => store.properties[mapping.propertyId]?.cardinality === "one").filter(
|
|
3894
|
+
({ mapping }) => !landings.some(
|
|
3895
|
+
(other) => other.mapping.propertyId === mapping.propertyId && !readsItself(other)
|
|
3896
|
+
)
|
|
3897
|
+
).map(({ method, mapping }) => ({
|
|
3898
|
+
subject: `${feature.name}.${method.name} \u2192 ${store.properties[mapping.propertyId].name}`,
|
|
3899
|
+
target: {
|
|
3900
|
+
kind: "panel",
|
|
3901
|
+
panel: "store",
|
|
3902
|
+
featureId: feature.id,
|
|
3903
|
+
...store.owner.kind === "sub" ? { subStoreId: store.owner.subStoreId } : {},
|
|
3904
|
+
memberId: method.id
|
|
3905
|
+
}
|
|
3906
|
+
}));
|
|
3907
|
+
})
|
|
3908
|
+
)
|
|
3909
|
+
});
|
|
3910
|
+
|
|
3911
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/filter-group-squeeze-orphan.ts
|
|
3912
|
+
var import_codegen48 = require("./index.js");
|
|
3913
|
+
var orphanIds = (groupId, controlMap) => {
|
|
3914
|
+
const found = [];
|
|
3915
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3916
|
+
const walk = (id) => {
|
|
3917
|
+
if (seen.has(id)) return;
|
|
3918
|
+
seen.add(id);
|
|
3919
|
+
for (const childId of controlMap[id]?.childrens ?? []) {
|
|
3920
|
+
const child = controlMap[childId];
|
|
3921
|
+
if (!child) continue;
|
|
3922
|
+
if (child.type === import_codegen48.ControlType.SECTION_FILTER) continue;
|
|
3923
|
+
if (child.type === import_codegen48.ControlType.COL) {
|
|
3924
|
+
walk(childId);
|
|
3925
|
+
continue;
|
|
3926
|
+
}
|
|
3927
|
+
found.push(childId);
|
|
3928
|
+
}
|
|
3929
|
+
};
|
|
3930
|
+
walk(groupId);
|
|
3931
|
+
return found;
|
|
3932
|
+
};
|
|
3933
|
+
var filterGroupSqueezeOrphan = defineInvariant({
|
|
3934
|
+
name: "filter-group-squeeze-orphan",
|
|
3935
|
+
message: "invariant-filter-group-squeeze-orphan",
|
|
3936
|
+
severity: "advisory",
|
|
3937
|
+
// Every Screen, each judged again only when its own Controls move (ADR 0192).
|
|
3938
|
+
deps: ["screenControlMaps", "screens"],
|
|
3939
|
+
validate: ({ screenControlMaps, screens }) => squeezedOrphans(screens, screenControlMaps, {})
|
|
3940
|
+
});
|
|
3941
|
+
var squeezedOrphans = perScreen(
|
|
3942
|
+
(controlMap, screen) => Object.entries(controlMap).flatMap(([groupId, control]) => {
|
|
3943
|
+
if (control.type !== import_codegen48.ControlType.SECTION_FILTER_GROUP) return [];
|
|
3944
|
+
const parentId = control.parentId;
|
|
3945
|
+
const squeezed = !!control.configs?.["squeeze"] || !!parentId && controlMap[parentId]?.type === import_codegen48.ControlType.SECTION_HEADER;
|
|
3946
|
+
if (!squeezed) return [];
|
|
3947
|
+
return orphanIds(groupId, controlMap).map((orphanId) => ({
|
|
3948
|
+
subject: import_codegen48.CONTROL_LABEL[controlMap[orphanId].type],
|
|
3949
|
+
target: {
|
|
3950
|
+
kind: "control",
|
|
3951
|
+
screenId: screen.id,
|
|
3952
|
+
controlId: orphanId
|
|
3953
|
+
}
|
|
3954
|
+
}));
|
|
3955
|
+
})
|
|
3956
|
+
);
|
|
3957
|
+
|
|
3958
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/context-group-primary-unique.ts
|
|
3959
|
+
var import_codegen49 = require("./index.js");
|
|
3960
|
+
var contextGroupPrimaryUnique = defineInvariant({
|
|
3961
|
+
name: "context-group-primary-unique",
|
|
3962
|
+
message: "invariant-context-group-primary-unique",
|
|
3963
|
+
severity: "advisory",
|
|
3964
|
+
// Every Screen, each judged again only when its own Controls move (ADR 0192).
|
|
3965
|
+
deps: ["screenControlMaps", "screens"],
|
|
3966
|
+
validate: ({ screenControlMaps, screens }) => duplicatePrimaries(screens, screenControlMaps, {})
|
|
3967
|
+
});
|
|
3968
|
+
var duplicatePrimaries = perScreen(
|
|
3969
|
+
(controlMap, screen) => Object.entries(controlMap).flatMap(([groupId, control]) => {
|
|
3970
|
+
if (control.type !== import_codegen49.ControlType.SECTION_BUTTON_GROUP) return [];
|
|
3971
|
+
if (control.configs?.["variant"] !== "context") return [];
|
|
3972
|
+
const primaries = (control.childrens ?? []).filter((childId) => {
|
|
3973
|
+
const child = controlMap[childId];
|
|
3974
|
+
return child?.type === import_codegen49.ControlType.BUTTON && child.configs?.["variant"] === "primary";
|
|
3975
|
+
});
|
|
3976
|
+
return primaries.slice(1).map((buttonId) => ({
|
|
3977
|
+
subject: import_codegen49.CONTROL_LABEL[import_codegen49.ControlType.BUTTON],
|
|
3978
|
+
target: {
|
|
3979
|
+
kind: "control",
|
|
3980
|
+
screenId: screen.id,
|
|
3981
|
+
controlId: buttonId
|
|
3982
|
+
}
|
|
3983
|
+
}));
|
|
3984
|
+
})
|
|
3985
|
+
);
|
|
3986
|
+
|
|
3987
|
+
// apps/m-one-ui/src/app/pages/design/lib/hand-binding-helper.ts
|
|
3988
|
+
var import_codegen50 = require("./index.js");
|
|
3989
|
+
var handControls = (controlMap) => Object.values(controlMap).filter(
|
|
3990
|
+
(control) => control.type === import_codegen50.ControlType.SCREEN && !!control.handRef
|
|
3991
|
+
);
|
|
3992
|
+
var unmountableReason = (handRef, hand) => {
|
|
3993
|
+
const contract = hand.contracts[handRef];
|
|
3994
|
+
if (!contract) {
|
|
3995
|
+
const skipped = hand.skips.find(
|
|
3996
|
+
(skip) => `${skip.slice}/${skip.className}` === handRef
|
|
3997
|
+
);
|
|
3998
|
+
return skipped ? skipped.reason : "gone";
|
|
3999
|
+
}
|
|
4000
|
+
const blockers = (0, import_codegen50.mountBlockers)(contract);
|
|
4001
|
+
return blockers.length ? `required: ${blockers.join(", ")}` : void 0;
|
|
4002
|
+
};
|
|
4003
|
+
var memberOf = (screen, binding) => {
|
|
4004
|
+
if (binding.kind === "input") {
|
|
4005
|
+
const found = screen.inputs?.[binding.inputId];
|
|
4006
|
+
if (!found)
|
|
4007
|
+
return { type: void 0, cardinality: void 0, present: false };
|
|
4008
|
+
return {
|
|
4009
|
+
type: found.dataType.type,
|
|
4010
|
+
cardinality: found.cardinality,
|
|
4011
|
+
present: true
|
|
4012
|
+
};
|
|
4013
|
+
}
|
|
4014
|
+
if (binding.kind === "variable") {
|
|
4015
|
+
const found = screen.variables?.[binding.variableId];
|
|
4016
|
+
if (!found)
|
|
4017
|
+
return { type: void 0, cardinality: void 0, present: false };
|
|
4018
|
+
return {
|
|
4019
|
+
type: found.dataType,
|
|
4020
|
+
cardinality: found.cardinality,
|
|
4021
|
+
present: true
|
|
4022
|
+
};
|
|
4023
|
+
}
|
|
4024
|
+
if (binding.kind === "constant") {
|
|
4025
|
+
const found = screen.constants?.[binding.constantId];
|
|
4026
|
+
if (!found)
|
|
4027
|
+
return { type: void 0, cardinality: void 0, present: false };
|
|
4028
|
+
return { type: found.dataType, cardinality: "one", present: true };
|
|
4029
|
+
}
|
|
4030
|
+
return void 0;
|
|
4031
|
+
};
|
|
4032
|
+
var brokenHandBindings = (control, contract, screen, controlMap, hand) => {
|
|
4033
|
+
const problems = [];
|
|
4034
|
+
const inputs = new Map(contract.inputs.map((one) => [one.name, one]));
|
|
4035
|
+
const outputs = new Map(contract.outputs.map((one) => [one.name, one]));
|
|
4036
|
+
Object.entries(control.screenInputs ?? {}).forEach(([name, binding]) => {
|
|
4037
|
+
const declared = inputs.get(name);
|
|
4038
|
+
if (!declared) {
|
|
4039
|
+
problems.push(name);
|
|
4040
|
+
return;
|
|
4041
|
+
}
|
|
4042
|
+
if (binding.kind === "static") return;
|
|
4043
|
+
if (binding.kind === "output") {
|
|
4044
|
+
const producer = controlMap[binding.controlId];
|
|
4045
|
+
const from = producer?.handRef ? hand.contracts[producer.handRef]?.outputs.find(
|
|
4046
|
+
(one) => one.name === binding.outputId
|
|
4047
|
+
)?.payload : void 0;
|
|
4048
|
+
if (producer?.handRef && !from) problems.push(name);
|
|
4049
|
+
else if (from && (from.type !== declared.type || from.cardinality !== declared.cardinality)) {
|
|
4050
|
+
problems.push(name);
|
|
4051
|
+
}
|
|
4052
|
+
return;
|
|
4053
|
+
}
|
|
4054
|
+
const member = memberOf(screen, binding);
|
|
4055
|
+
if (!member) return;
|
|
4056
|
+
if (!member.present || member.type !== declared.type || member.cardinality !== declared.cardinality) {
|
|
4057
|
+
problems.push(name);
|
|
4058
|
+
}
|
|
4059
|
+
});
|
|
4060
|
+
wiredOutputKeys(control).forEach((name) => {
|
|
4061
|
+
if (!outputs.has(name)) problems.push(name);
|
|
4062
|
+
});
|
|
4063
|
+
return [...new Set(problems)].sort();
|
|
4064
|
+
};
|
|
4065
|
+
var unboundRequiredInputs = (control, contract) => {
|
|
4066
|
+
const bound = control.screenInputs ?? {};
|
|
4067
|
+
return contract.inputs.filter((declared) => declared.required && !bound[declared.name]).map((declared) => declared.name).sort();
|
|
4068
|
+
};
|
|
4069
|
+
var mountedContract = (control, hand) => {
|
|
4070
|
+
const contract = control.handRef ? hand.contracts[control.handRef] : void 0;
|
|
4071
|
+
return contract && (0, import_codegen50.isMountable)(contract) ? contract : void 0;
|
|
4072
|
+
};
|
|
4073
|
+
|
|
4074
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/hand-binding-resolves.ts
|
|
4075
|
+
var handBindingResolves = defineInvariant({
|
|
4076
|
+
name: "hand-binding-resolves",
|
|
4077
|
+
message: "invariant-hand-binding-unresolved",
|
|
4078
|
+
severity: "blocking",
|
|
4079
|
+
deps: ["screens", "screenControlMaps", "hand"],
|
|
4080
|
+
validate: ({ screens, screenControlMaps, hand }) => screens.flatMap((screen) => {
|
|
4081
|
+
const controlMap = screenControlMaps[screen.id] ?? {};
|
|
4082
|
+
return handControls(controlMap).flatMap((control) => {
|
|
4083
|
+
const contract = mountedContract(control, hand);
|
|
4084
|
+
if (!contract) return [];
|
|
4085
|
+
const broken = brokenHandBindings(
|
|
4086
|
+
control,
|
|
4087
|
+
contract,
|
|
4088
|
+
screen,
|
|
4089
|
+
controlMap,
|
|
4090
|
+
hand
|
|
4091
|
+
);
|
|
4092
|
+
if (!broken.length) return [];
|
|
4093
|
+
return [
|
|
4094
|
+
{
|
|
4095
|
+
subject: `${screen.name} \u2192 ${contract.ref}: ${broken.join(", ")}`,
|
|
4096
|
+
target: {
|
|
4097
|
+
kind: "control",
|
|
4098
|
+
screenId: screen.id,
|
|
4099
|
+
controlId: control.id
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
];
|
|
4103
|
+
});
|
|
4104
|
+
})
|
|
4105
|
+
});
|
|
4106
|
+
|
|
4107
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/hand-required-input-bound.ts
|
|
4108
|
+
var handRequiredInputBound = defineInvariant({
|
|
4109
|
+
name: "hand-required-input-bound",
|
|
4110
|
+
message: "invariant-hand-required-input-unbound",
|
|
4111
|
+
severity: "blocking",
|
|
4112
|
+
deps: ["screens", "screenControlMaps", "hand"],
|
|
4113
|
+
validate: ({ screens, screenControlMaps, hand }) => screens.flatMap((screen) => {
|
|
4114
|
+
const controlMap = screenControlMaps[screen.id] ?? {};
|
|
4115
|
+
return handControls(controlMap).flatMap((control) => {
|
|
4116
|
+
const contract = mountedContract(control, hand);
|
|
4117
|
+
if (!contract) return [];
|
|
4118
|
+
const missing = unboundRequiredInputs(control, contract);
|
|
4119
|
+
if (!missing.length) return [];
|
|
4120
|
+
return [
|
|
4121
|
+
{
|
|
4122
|
+
subject: `${screen.name} \u2192 ${contract.ref}: ${missing.join(", ")}`,
|
|
4123
|
+
target: {
|
|
4124
|
+
kind: "control",
|
|
4125
|
+
screenId: screen.id,
|
|
4126
|
+
controlId: control.id
|
|
4127
|
+
}
|
|
4128
|
+
}
|
|
4129
|
+
];
|
|
4130
|
+
});
|
|
4131
|
+
})
|
|
4132
|
+
});
|
|
4133
|
+
|
|
4134
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/hand-screen-resolves.ts
|
|
4135
|
+
var handScreenResolves = defineInvariant({
|
|
4136
|
+
name: "hand-screen-resolves",
|
|
4137
|
+
message: "invariant-hand-screen-unresolved",
|
|
4138
|
+
severity: "blocking",
|
|
4139
|
+
deps: ["screens", "screenControlMaps", "hand"],
|
|
4140
|
+
validate: ({ screens, screenControlMaps, hand }) => screens.flatMap((screen) => {
|
|
4141
|
+
const controlMap = screenControlMaps[screen.id] ?? {};
|
|
4142
|
+
return handControls(controlMap).flatMap((control) => {
|
|
4143
|
+
const reason = unmountableReason(control.handRef, hand);
|
|
4144
|
+
if (!reason) return [];
|
|
4145
|
+
return [
|
|
4146
|
+
{
|
|
4147
|
+
subject: `${screen.name} \u2192 ${control.handRef} (${reason})`,
|
|
4148
|
+
target: {
|
|
4149
|
+
kind: "control",
|
|
4150
|
+
screenId: screen.id,
|
|
4151
|
+
controlId: control.id
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
];
|
|
4155
|
+
});
|
|
4156
|
+
})
|
|
4157
|
+
});
|
|
4158
|
+
|
|
4159
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/reserved-variant-name-free.ts
|
|
4160
|
+
var import_codegen51 = require("./index.js");
|
|
4161
|
+
var reservedVariantNameFree = defineInvariant({
|
|
4162
|
+
name: "reserved-variant-name-free",
|
|
4163
|
+
message: "invariant-reserved-variant-name",
|
|
4164
|
+
severity: "blocking",
|
|
4165
|
+
deps: ["features", "screens"],
|
|
4166
|
+
validate: ({ features, screens }) => {
|
|
4167
|
+
const featureScreen = (featureId) => screens.find((screen) => screen.featureId === featureId)?.id ?? "";
|
|
4168
|
+
const fromFeatures = Object.values(features).flatMap((feature) => {
|
|
4169
|
+
const held = [
|
|
4170
|
+
...Object.values(feature.properties).map((property) => property.name),
|
|
4171
|
+
...Object.values(feature.variants).map((variant) => variant.name)
|
|
4172
|
+
].filter(import_codegen51.isReservedVariantName);
|
|
4173
|
+
return held.length ? [
|
|
4174
|
+
{
|
|
4175
|
+
subject: `${feature.name}.${held[0]}`,
|
|
4176
|
+
target: {
|
|
4177
|
+
kind: "screen",
|
|
4178
|
+
screenId: featureScreen(feature.id)
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
] : [];
|
|
4182
|
+
});
|
|
4183
|
+
const fromScreens = screens.flatMap((screen) => {
|
|
4184
|
+
const held = [
|
|
4185
|
+
...Object.values(screen.inputs ?? {}),
|
|
4186
|
+
...Object.values(screen.outputs ?? {}),
|
|
4187
|
+
...Object.values(screen.constants ?? {}),
|
|
4188
|
+
...Object.values(screen.computeds ?? {})
|
|
4189
|
+
].map((member) => member.name).filter(import_codegen51.isReservedVariantName);
|
|
4190
|
+
return held.length ? [
|
|
4191
|
+
{
|
|
4192
|
+
subject: `${screen.name}.${held[0]}`,
|
|
4193
|
+
target: { kind: "screen", screenId: screen.id }
|
|
4194
|
+
}
|
|
4195
|
+
] : [];
|
|
4196
|
+
});
|
|
4197
|
+
return [...fromFeatures, ...fromScreens];
|
|
4198
|
+
}
|
|
4199
|
+
});
|
|
4200
|
+
|
|
4201
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/feature-name-free.ts
|
|
4202
|
+
var import_codegen52 = require("./index.js");
|
|
4203
|
+
var featureNameFree = defineInvariant({
|
|
4204
|
+
name: "feature-name-free",
|
|
4205
|
+
message: "invariant-feature-name-reserved",
|
|
4206
|
+
severity: "advisory",
|
|
4207
|
+
deps: ["features", "screens"],
|
|
4208
|
+
validate: ({ features, screens }) => Object.values(features).filter((feature) => (0, import_codegen52.isReservedFeatureName)(feature.name)).map((feature) => ({
|
|
4209
|
+
subject: feature.name,
|
|
4210
|
+
target: {
|
|
4211
|
+
kind: "screen",
|
|
4212
|
+
screenId: screens.find((screen) => screen.featureId === feature.id)?.id ?? ""
|
|
4213
|
+
}
|
|
4214
|
+
}))
|
|
4215
|
+
});
|
|
4216
|
+
|
|
4217
|
+
// apps/m-one-ui/src/app/pages/design/lib/compare-register.ts
|
|
4218
|
+
var import_codegen54 = require("./index.js");
|
|
4219
|
+
|
|
4220
|
+
// apps/m-one-ui/src/app/pages/design/lib/shape-register.ts
|
|
4221
|
+
var import_codegen53 = require("./index.js");
|
|
4222
|
+
|
|
4223
|
+
// apps/m-one-ui/src/app/pages/design/lib/compare-register.ts
|
|
4224
|
+
var import_codegen55 = require("./index.js");
|
|
4225
|
+
var everyShape = (features, sharedShapes = {}) => [
|
|
4226
|
+
...(0, import_codegen54.listShapes)(sharedShapes).map((shape) => ({ shape })),
|
|
4227
|
+
...(0, import_codegen54.listFeatures)(features).flatMap(
|
|
4228
|
+
(feature) => (0, import_codegen54.listShapes)(feature.shapes).filter((shape) => !(0, import_codegen54.isSharedShapeId)(shape.id)).map((shape) => ({ shape, featureId: feature.id }))
|
|
4229
|
+
)
|
|
4230
|
+
];
|
|
4231
|
+
var distinctPair = (kind, a, b) => ({ kind, ids: a < b ? [a, b] : [b, a] });
|
|
4232
|
+
var isDistinct = (distinct, kind, a, b) => {
|
|
4233
|
+
const [first, second] = distinctPair(kind, a, b).ids;
|
|
4234
|
+
return distinct.some(
|
|
4235
|
+
(pair) => pair.kind === kind && pair.ids[0] === first && pair.ids[1] === second
|
|
4236
|
+
);
|
|
4237
|
+
};
|
|
4238
|
+
var liveDistinct = (distinct, features, appFunctions, sharedShapes = {}) => {
|
|
4239
|
+
const shapes = new Set(
|
|
4240
|
+
everyShape(features, sharedShapes).map(({ shape }) => shape.id)
|
|
4241
|
+
);
|
|
4242
|
+
const functions = new Set(
|
|
4243
|
+
everyFunction(appFunctions, features).map(({ fn }) => fn.id)
|
|
4244
|
+
);
|
|
4245
|
+
return distinct.filter((pair) => {
|
|
4246
|
+
const live = pair.kind === "shapes" ? shapes : functions;
|
|
4247
|
+
return live.has(pair.ids[0]) && live.has(pair.ids[1]);
|
|
4248
|
+
});
|
|
4249
|
+
};
|
|
4250
|
+
var shapeStructureKey = (shape) => JSON.stringify(
|
|
4251
|
+
canonical(
|
|
4252
|
+
[...shape.keys].sort((a, b) => a.name.localeCompare(b.name)).map((key) => [key.name, key.dataType, key.cardinality])
|
|
4253
|
+
)
|
|
4254
|
+
);
|
|
4255
|
+
var shapeMatchIndex = (all, distinct = []) => {
|
|
4256
|
+
const byStructure = /* @__PURE__ */ new Map();
|
|
4257
|
+
for (const entry of all) {
|
|
4258
|
+
if (!entry.shape.keys.length) continue;
|
|
4259
|
+
const key = shapeStructureKey(entry.shape);
|
|
4260
|
+
byStructure.set(key, [...byStructure.get(key) ?? [], entry]);
|
|
4261
|
+
}
|
|
4262
|
+
const index = /* @__PURE__ */ new Map();
|
|
4263
|
+
for (const group of byStructure.values()) {
|
|
4264
|
+
for (const entry of group) {
|
|
4265
|
+
const matches = group.filter(
|
|
4266
|
+
(other) => other.shape.id !== entry.shape.id && !isDistinct(distinct, "shapes", other.shape.id, entry.shape.id)
|
|
4267
|
+
);
|
|
4268
|
+
if (matches.length) index.set(entry.shape.id, matches);
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
return index;
|
|
4272
|
+
};
|
|
4273
|
+
|
|
4274
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/shape-match.ts
|
|
4275
|
+
var shapeMatch = defineInvariant({
|
|
4276
|
+
name: "shape-match",
|
|
4277
|
+
message: "invariant-shape-match",
|
|
4278
|
+
severity: "advisory",
|
|
4279
|
+
deps: ["features", "functions", "sharedShapes", "distinct"],
|
|
4280
|
+
validate: ({ features, functions, sharedShapes, distinct }) => {
|
|
4281
|
+
const shapes = everyShape(features, sharedShapes);
|
|
4282
|
+
const index = shapeMatchIndex(
|
|
4283
|
+
shapes,
|
|
4284
|
+
liveDistinct(distinct, features, functions, sharedShapes)
|
|
4285
|
+
);
|
|
4286
|
+
return shapes.filter(({ shape }) => index.has(shape.id)).map(({ shape, featureId }) => ({
|
|
4287
|
+
subject: `${shape.name} \u2261 ${(index.get(shape.id) ?? []).map((match) => match.shape.name).join(", ")}`,
|
|
4288
|
+
target: {
|
|
4289
|
+
kind: "compare",
|
|
4290
|
+
tab: "shapes",
|
|
4291
|
+
item: featureId ? { featureId, id: shape.id } : { id: shape.id }
|
|
4292
|
+
}
|
|
4293
|
+
}));
|
|
4294
|
+
}
|
|
4295
|
+
});
|
|
4296
|
+
|
|
4297
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/theme-selection-resolves.ts
|
|
4298
|
+
var themeSelectionResolves = defineInvariant({
|
|
4299
|
+
name: "theme-selection-resolves",
|
|
4300
|
+
message: "invariant-theme-selection-missing",
|
|
4301
|
+
severity: "advisory",
|
|
4302
|
+
deps: ["wcConfig", "themes", "themeCatalog"],
|
|
4303
|
+
validate: ({ wcConfig, themes, themeCatalog }) => {
|
|
4304
|
+
const selected = wcConfig.theme?.trim();
|
|
4305
|
+
if (!selected) return [];
|
|
4306
|
+
if (themes[selected] || themeCatalog.includes(selected)) return [];
|
|
4307
|
+
return [
|
|
4308
|
+
{ subject: selected, target: { kind: "panel", panel: "config" } }
|
|
4309
|
+
];
|
|
4310
|
+
}
|
|
4311
|
+
});
|
|
4312
|
+
|
|
4313
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/search-feed-resolves.ts
|
|
4314
|
+
var import_codegen56 = require("./index.js");
|
|
4315
|
+
var searchFeedResolves = defineInvariant({
|
|
4316
|
+
name: "search-feed-resolves",
|
|
4317
|
+
message: "invariant-search-feed-unresolved",
|
|
4318
|
+
severity: "advisory",
|
|
4319
|
+
deps: ["features", "functions"],
|
|
4320
|
+
validate: ({ features, functions }) => Object.values(features).flatMap(
|
|
4321
|
+
(feature) => (0, import_codegen56.storesOf)(feature).flatMap((store) => {
|
|
4322
|
+
const feed = store.searchFeed;
|
|
4323
|
+
if (!feed) return [];
|
|
4324
|
+
const property = store.properties[feed.propertyId];
|
|
4325
|
+
const rows = property?.cardinality === "many" ? property.dataType : void 0;
|
|
4326
|
+
if (feed.functionId) {
|
|
4327
|
+
const fn = feature.functions?.[feed.functionId] ?? functions[feed.functionId];
|
|
4328
|
+
if (fn && (0, import_codegen56.isSearchFeedFunction)(fn, property, feature.shapes) && (0, import_codegen56.searchFeedArgsComplete)(fn, feed.args)) {
|
|
4329
|
+
return [];
|
|
4330
|
+
}
|
|
4331
|
+
} else if (rows && (0, import_codegen56.resolveSearchFeedMember)(feed.title, rows, feature.shapes)) {
|
|
4332
|
+
return [];
|
|
4333
|
+
}
|
|
4334
|
+
return [
|
|
4335
|
+
{
|
|
4336
|
+
subject: property ? `${feature.name} \u2192 ${property.name}` : feature.name,
|
|
4337
|
+
target: {
|
|
4338
|
+
kind: "panel",
|
|
4339
|
+
panel: "store",
|
|
4340
|
+
featureId: feature.id,
|
|
4341
|
+
...store.owner.kind === "sub" ? { subStoreId: store.owner.subStoreId } : {}
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
];
|
|
4345
|
+
})
|
|
4346
|
+
)
|
|
4347
|
+
});
|
|
4348
|
+
|
|
4349
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/search-answer-resolves.ts
|
|
4350
|
+
var import_codegen57 = require("./index.js");
|
|
4351
|
+
var searchAnswerResolves = defineInvariant({
|
|
4352
|
+
name: "search-answer-resolves",
|
|
4353
|
+
message: "invariant-search-answer-unresolved",
|
|
4354
|
+
severity: "advisory",
|
|
4355
|
+
deps: ["navMap", "screens"],
|
|
4356
|
+
validate: ({ navMap, screens }) => {
|
|
4357
|
+
const screenId = (0, import_codegen57.searchAnswerScreenId)(navMap);
|
|
4358
|
+
if (!screenId) return [];
|
|
4359
|
+
const screen = screens.find((s) => s.id === screenId);
|
|
4360
|
+
if (screen && (screen.kind === "app_widget" || screen.kind === "feature")) {
|
|
4361
|
+
return [];
|
|
4362
|
+
}
|
|
4363
|
+
return [
|
|
4364
|
+
{
|
|
4365
|
+
subject: screen?.name ?? screenId,
|
|
4366
|
+
target: { kind: "nav", navId: import_codegen57.SEARCH_NAV_ID }
|
|
4367
|
+
}
|
|
4368
|
+
];
|
|
4369
|
+
}
|
|
4370
|
+
});
|
|
4371
|
+
|
|
4372
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/state-path-resolves.ts
|
|
4373
|
+
var import_codegen58 = require("./index.js");
|
|
4374
|
+
var reachOf = (feature, shared) => ({
|
|
4375
|
+
properties: Object.assign(
|
|
4376
|
+
{},
|
|
4377
|
+
...(0, import_codegen58.storesOf)(feature).map((store) => store.properties)
|
|
4378
|
+
),
|
|
4379
|
+
shapes: (0, import_codegen58.shapesInReach)(feature, shared)
|
|
4380
|
+
});
|
|
4381
|
+
function declaredIds(value, into = /* @__PURE__ */ new Set()) {
|
|
4382
|
+
if (Array.isArray(value)) value.forEach((item) => declaredIds(item, into));
|
|
4383
|
+
else if (value && typeof value === "object") {
|
|
4384
|
+
const id = value.id;
|
|
4385
|
+
if (typeof id === "string") into.add(id);
|
|
4386
|
+
Object.values(value).forEach((item) => declaredIds(item, into));
|
|
4387
|
+
}
|
|
4388
|
+
return into;
|
|
4389
|
+
}
|
|
4390
|
+
var STATE_ROOT_KINDS = /* @__PURE__ */ new Set(["property", "computed"]);
|
|
4391
|
+
var STATE_SOURCES = /* @__PURE__ */ new Set(["state", "path", "store"]);
|
|
4392
|
+
function holdsDeadPath(value, reach, roots, state) {
|
|
4393
|
+
if (Array.isArray(value)) {
|
|
4394
|
+
if (value.length > 1 && value.every((id) => typeof id === "string") && value[0] in reach.properties && !value.slice(1).some((id) => id in reach.properties)) {
|
|
4395
|
+
return !(0, import_codegen58.isPathResolved)(value, reach.properties, reach.shapes);
|
|
4396
|
+
}
|
|
4397
|
+
return value.some((item) => holdsDeadPath(item, reach, roots, state));
|
|
4398
|
+
}
|
|
4399
|
+
if (value && typeof value === "object") {
|
|
4400
|
+
const record = value;
|
|
4401
|
+
const path = record.path;
|
|
4402
|
+
if (roots && record.root === void 0 && (record.source === void 0 || typeof record.source === "string" && STATE_SOURCES.has(record.source)) && Array.isArray(path) && path.length > 0 && path.every((id) => typeof id === "string") && !roots.has(path[0])) {
|
|
4403
|
+
return true;
|
|
4404
|
+
}
|
|
4405
|
+
const root = record.root;
|
|
4406
|
+
if (state && root && typeof root.kind === "string" && STATE_ROOT_KINDS.has(root.kind) && typeof root.id === "string" && !state.has(root.id)) {
|
|
4407
|
+
return true;
|
|
4408
|
+
}
|
|
4409
|
+
return Object.values(value).some((item) => holdsDeadPath(item, reach, roots, state));
|
|
4410
|
+
}
|
|
4411
|
+
return false;
|
|
4412
|
+
}
|
|
4413
|
+
var named = (members) => Object.values(members ?? {}).map((member) => ({
|
|
4414
|
+
id: member.id,
|
|
4415
|
+
name: member.name,
|
|
4416
|
+
value: member
|
|
4417
|
+
}));
|
|
4418
|
+
var statePathResolves = defineInvariant({
|
|
4419
|
+
name: "state-path-resolves",
|
|
4420
|
+
message: "invariant-state-path-unresolved",
|
|
4421
|
+
severity: "blocking",
|
|
4422
|
+
deps: ["features", "screens", "navMap", "sharedShapes"],
|
|
4423
|
+
validate: ({ features, screens, navMap, sharedShapes }) => {
|
|
4424
|
+
const found = [];
|
|
4425
|
+
const reaches = /* @__PURE__ */ new Map();
|
|
4426
|
+
const state = new Set(
|
|
4427
|
+
Object.values(features).flatMap(
|
|
4428
|
+
(feature) => (0, import_codegen58.storesOf)(feature).flatMap((store) => [
|
|
4429
|
+
...Object.keys(store.properties ?? {}),
|
|
4430
|
+
...Object.keys(store.computeds ?? {})
|
|
4431
|
+
])
|
|
4432
|
+
)
|
|
4433
|
+
);
|
|
4434
|
+
const rootsFor = (holder, extra = []) => /* @__PURE__ */ new Set([...state, ...declaredIds(holder), ...extra]);
|
|
4435
|
+
for (const feature of Object.values(features)) {
|
|
4436
|
+
const reach = reachOf(feature, sharedShapes);
|
|
4437
|
+
reaches.set(feature.id, reach);
|
|
4438
|
+
const at = { kind: "panel", panel: "store", featureId: feature.id };
|
|
4439
|
+
for (const variant of named(feature.variants)) {
|
|
4440
|
+
if (holdsDeadPath(variant.value, reach, rootsFor(variant.value), state)) {
|
|
4441
|
+
found.push({
|
|
4442
|
+
subject: `${feature.name} \u2192 variant ${variant.name}`,
|
|
4443
|
+
target: { ...at, memberId: variant.id }
|
|
4444
|
+
});
|
|
4445
|
+
}
|
|
4446
|
+
}
|
|
4447
|
+
for (const store of (0, import_codegen58.storesOf)(feature)) {
|
|
4448
|
+
const subStoreId = store.subStore?.id;
|
|
4449
|
+
const owner = subStoreId ? { ...at, subStoreId } : at;
|
|
4450
|
+
const prefix = store.subStore ? `${feature.name} \u2192 ${store.subStore.name}` : feature.name;
|
|
4451
|
+
for (const [word, members] of [
|
|
4452
|
+
["computed", store.computeds],
|
|
4453
|
+
["method", store.methods],
|
|
4454
|
+
["timer", store.timers]
|
|
4455
|
+
]) {
|
|
4456
|
+
for (const member of named(members)) {
|
|
4457
|
+
if (holdsDeadPath(member.value, reach, rootsFor(member.value), state)) {
|
|
4458
|
+
found.push({
|
|
4459
|
+
subject: `${prefix} \u2192 ${word} ${member.name}`,
|
|
4460
|
+
target: { ...owner, memberId: member.id }
|
|
4461
|
+
});
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
for (const screen of screens) {
|
|
4468
|
+
const reach = (0, import_codegen58.isFeatureScreen)(screen) ? reaches.get(screen.featureId) : void 0;
|
|
4469
|
+
if (!reach) continue;
|
|
4470
|
+
const at = { kind: "screen", screenId: screen.id, panel: "screen" };
|
|
4471
|
+
const own = [
|
|
4472
|
+
...Object.keys(screen.inputs ?? {}),
|
|
4473
|
+
...Object.keys(screen.computeds ?? {}),
|
|
4474
|
+
...Object.keys(screen.constants ?? {}),
|
|
4475
|
+
...Object.keys(screen.variables ?? {}),
|
|
4476
|
+
...Object.keys(screen.formModels ?? {}),
|
|
4477
|
+
...Object.values(screen.formModels ?? {}).map((model) => model.id)
|
|
4478
|
+
];
|
|
4479
|
+
for (const variant of named(screen.variants)) {
|
|
4480
|
+
if (holdsDeadPath(variant.value, reach, rootsFor(variant.value, own), state)) {
|
|
4481
|
+
found.push({
|
|
4482
|
+
subject: `${screen.name} \u2192 variant ${variant.name}`,
|
|
4483
|
+
target: { ...at, memberId: variant.id }
|
|
4484
|
+
});
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
for (const computed of named(screen.computeds)) {
|
|
4488
|
+
if (holdsDeadPath(computed.value, reach, rootsFor(computed.value, own), state)) {
|
|
4489
|
+
found.push({
|
|
4490
|
+
subject: `${screen.name} \u2192 computed ${computed.name}`,
|
|
4491
|
+
target: { ...at, computedId: computed.id }
|
|
4492
|
+
});
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
const everywhere = {
|
|
4497
|
+
properties: Object.assign({}, ...[...reaches.values()].map((r) => r.properties)),
|
|
4498
|
+
shapes: Object.assign({}, ...[...reaches.values()].map((r) => r.shapes))
|
|
4499
|
+
};
|
|
4500
|
+
for (const nav of Object.values(navMap)) {
|
|
4501
|
+
if (holdsDeadPath(nav, everywhere, rootsFor(nav), state)) {
|
|
4502
|
+
found.push({
|
|
4503
|
+
subject: `nav ${nav.label ?? nav.navId}`,
|
|
4504
|
+
target: { kind: "nav", navId: nav.navId }
|
|
4505
|
+
});
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
return found;
|
|
4509
|
+
}
|
|
4510
|
+
});
|
|
4511
|
+
|
|
4512
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/rule-operand-fits.ts
|
|
4513
|
+
var import_codegen59 = require("./index.js");
|
|
4514
|
+
var unfit = (check, properties, shapes) => {
|
|
4515
|
+
const error = (0, import_codegen59.checkError)(check, properties, shapes);
|
|
4516
|
+
if (error === "rule-path-missing") return false;
|
|
4517
|
+
if (error === "rule-operator-invalid" || error === "rule-path-not-leaf" || error === "rule-operand-missing" && check.operand.kind === "path") {
|
|
4518
|
+
return true;
|
|
4519
|
+
}
|
|
4520
|
+
if ((0, import_codegen59.isUnaryOperator)(check.operator) || check.operand.kind !== "literal") {
|
|
4521
|
+
return false;
|
|
4522
|
+
}
|
|
4523
|
+
const segments = (0, import_codegen59.resolvePath)(check.path, properties, shapes);
|
|
4524
|
+
if (!check.count && (0, import_codegen59.pathLeafEnumId)(segments)) return false;
|
|
4525
|
+
const type = (0, import_codegen59.operandType)((0, import_codegen59.pathLeafType)(segments), !!check.count);
|
|
4526
|
+
if (!type) return false;
|
|
4527
|
+
return (0, import_codegen59.validateLiteral)(String(check.operand.value), { type }, "one") === "value-type-mismatch";
|
|
4528
|
+
};
|
|
4529
|
+
var ruleOperandFits = defineInvariant({
|
|
4530
|
+
name: "rule-operand-fits",
|
|
4531
|
+
message: "invariant-rule-operand-unfit",
|
|
4532
|
+
severity: "blocking",
|
|
4533
|
+
deps: ["features", "sharedShapes"],
|
|
4534
|
+
validate: ({ features, sharedShapes }) => {
|
|
4535
|
+
const found = [];
|
|
4536
|
+
for (const feature of Object.values(features)) {
|
|
4537
|
+
const properties = Object.assign(
|
|
4538
|
+
{},
|
|
4539
|
+
...(0, import_codegen59.storesOf)(feature).map((store) => store.properties)
|
|
4540
|
+
);
|
|
4541
|
+
const shapes = (0, import_codegen59.shapesInReach)(feature, sharedShapes);
|
|
4542
|
+
for (const variant of Object.values(feature.variants ?? {})) {
|
|
4543
|
+
if ((0, import_codegen59.ruleChecks)(variant.rule).some(
|
|
4544
|
+
(check) => unfit(check, properties, shapes)
|
|
4545
|
+
)) {
|
|
4546
|
+
found.push({
|
|
4547
|
+
subject: `${feature.name} \u2192 variant ${variant.name}`,
|
|
4548
|
+
target: {
|
|
4549
|
+
kind: "panel",
|
|
4550
|
+
panel: "store",
|
|
4551
|
+
featureId: feature.id,
|
|
4552
|
+
memberId: variant.id
|
|
4553
|
+
}
|
|
4554
|
+
});
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
}
|
|
4558
|
+
return found;
|
|
4559
|
+
}
|
|
4560
|
+
});
|
|
4561
|
+
|
|
4562
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/timer-complete.ts
|
|
4563
|
+
var import_codegen60 = require("./index.js");
|
|
4564
|
+
var timerComplete = defineInvariant({
|
|
4565
|
+
name: "timer-complete",
|
|
4566
|
+
message: "invariant-timer-incomplete",
|
|
4567
|
+
severity: "blocking",
|
|
4568
|
+
deps: ["features", "screens"],
|
|
4569
|
+
validate: ({ features, screens }) => {
|
|
4570
|
+
const featureScreen = (featureId) => screens.find((screen) => screen.featureId === featureId)?.id ?? "";
|
|
4571
|
+
return Object.values(features).flatMap(
|
|
4572
|
+
(feature) => Object.values(feature.timers ?? {}).filter((timer) => (0, import_codegen60.timerError)(timer)).map((timer) => ({
|
|
4573
|
+
subject: `${feature.name}.${timer.name}`,
|
|
4574
|
+
target: {
|
|
4575
|
+
kind: "screen",
|
|
4576
|
+
screenId: featureScreen(feature.id)
|
|
4577
|
+
}
|
|
4578
|
+
}))
|
|
4579
|
+
);
|
|
4580
|
+
}
|
|
4581
|
+
});
|
|
4582
|
+
|
|
4583
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariants/variant-gate-satisfiable.ts
|
|
4584
|
+
var import_codegen61 = require("./index.js");
|
|
4585
|
+
var ATOM_CAP2 = 12;
|
|
4586
|
+
var foldText2 = (entries, names) => entries.map((entry, index) => {
|
|
4587
|
+
const name = names.get(entry.id) ?? entry.id;
|
|
4588
|
+
const term = (0, import_codegen61.variantJoinIsNot)(entry.join) ? `!${name}` : name;
|
|
4589
|
+
if (index === 0) return term;
|
|
4590
|
+
return `${(0, import_codegen61.variantJoinIsAnd)(entry.join) ? "&&" : "||"} ${term}`;
|
|
4591
|
+
}).join(" ");
|
|
4592
|
+
var variantNames2 = (features, screens, currentScreenId) => {
|
|
4593
|
+
const screen = screens.find((one) => one.id === currentScreenId);
|
|
4594
|
+
const feature = screen?.featureId ? features[screen.featureId] : void 0;
|
|
4595
|
+
const names = /* @__PURE__ */ new Map([
|
|
4596
|
+
[import_codegen61.ELSE_VARIANT_ID, import_codegen61.ELSE_VARIANT_NAME],
|
|
4597
|
+
[import_codegen61.BUSY_VARIANT_ID, import_codegen61.BUSY_VARIANT_NAME]
|
|
4598
|
+
]);
|
|
4599
|
+
Object.values(feature?.variants ?? {}).forEach(
|
|
4600
|
+
(variant) => names.set(variant.id, variant.name)
|
|
4601
|
+
);
|
|
4602
|
+
return names;
|
|
4603
|
+
};
|
|
4604
|
+
var satisfiable = (gates) => {
|
|
4605
|
+
const atoms = [
|
|
4606
|
+
...new Set(
|
|
4607
|
+
gates.flat().map((entry) => entry.id).filter((id) => !(0, import_codegen61.isReservedVariantId)(id))
|
|
4608
|
+
)
|
|
4609
|
+
];
|
|
4610
|
+
if (atoms.length > ATOM_CAP2) return true;
|
|
4611
|
+
const rows = 1 << atoms.length;
|
|
4612
|
+
for (let row = 0; row < rows; row++) {
|
|
4613
|
+
const on = atoms.filter((_, index) => row & 1 << index);
|
|
4614
|
+
const base = on.length ? on : [...on, import_codegen61.ELSE_VARIANT_ID];
|
|
4615
|
+
for (const withBusy of [base, [...base, import_codegen61.BUSY_VARIANT_ID]]) {
|
|
4616
|
+
if (gates.every((gate) => (0, import_codegen61.evaluateVariantGate)(gate, withBusy))) {
|
|
4617
|
+
return true;
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
}
|
|
4621
|
+
return false;
|
|
4622
|
+
};
|
|
4623
|
+
var variantGateSatisfiable = defineInvariant({
|
|
4624
|
+
name: "variant-gate-satisfiable",
|
|
4625
|
+
message: "invariant-variant-gate-unsatisfiable",
|
|
4626
|
+
severity: "advisory",
|
|
4627
|
+
// Every Screen, each judged again only when its own Controls move (ADR 0192).
|
|
4628
|
+
deps: ["screenControlMaps", "features", "screens"],
|
|
4629
|
+
validate: ({ screenControlMaps, features, screens }) => unsatisfiableGates(screens, screenControlMaps, { features, screens })
|
|
4630
|
+
});
|
|
4631
|
+
var unsatisfiableGates = perScreen(
|
|
4632
|
+
(controlMap, screen, { features, screens }) => {
|
|
4633
|
+
const names = variantNames2(features, screens, screen.id);
|
|
4634
|
+
return Object.entries(controlMap).flatMap(([controlId, control]) => {
|
|
4635
|
+
const own = (0, import_codegen61.controlVariants)(control);
|
|
4636
|
+
if (!own.length) return [];
|
|
4637
|
+
const above = (0, import_codegen61.enclosingGates)(controlId, controlMap);
|
|
4638
|
+
if (above === null) return [];
|
|
4639
|
+
const gates = [own, ...above];
|
|
4640
|
+
if (satisfiable(gates)) return [];
|
|
4641
|
+
return [
|
|
4642
|
+
{
|
|
4643
|
+
// Its own guard, then what encloses it, innermost first — the two
|
|
4644
|
+
// halves that cannot hold together.
|
|
4645
|
+
subject: `${foldText2(own, names)} \u2014 ${gates.slice(1).map((gate) => foldText2(gate, names)).join(" & ")}`,
|
|
4646
|
+
target: {
|
|
4647
|
+
kind: "control",
|
|
4648
|
+
screenId: screen.id,
|
|
4649
|
+
controlId
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
];
|
|
4653
|
+
});
|
|
4654
|
+
}
|
|
4655
|
+
);
|
|
4656
|
+
|
|
4657
|
+
// apps/m-one-ui/src/app/pages/design/lib/emit-gap-helper.ts
|
|
4658
|
+
var import_codegen63 = require("./index.js");
|
|
4659
|
+
|
|
4660
|
+
// apps/m-one-ui/src/app/pages/design/lib/store-method-check.ts
|
|
4661
|
+
var import_codegen62 = require("./index.js");
|
|
4662
|
+
|
|
4663
|
+
// apps/m-one-ui/src/app/pages/design/lib/invariant-catalog.ts
|
|
4664
|
+
var INVARIANTS = [
|
|
4665
|
+
appScaffoldComplete,
|
|
4666
|
+
backendUrlDeclared,
|
|
4667
|
+
bindingResolves,
|
|
4668
|
+
branchArmReachable,
|
|
4669
|
+
computedArgsBound,
|
|
4670
|
+
computedArgsTyped,
|
|
4671
|
+
oneFunctionArgMismatch,
|
|
4672
|
+
oneFunctionRequiredParam,
|
|
4673
|
+
confirmUnattendedCall,
|
|
4674
|
+
outcomeUnattendedCall,
|
|
4675
|
+
outcomeCallNested,
|
|
4676
|
+
reactionWritesOwnWatch,
|
|
4677
|
+
closeOverlayOffOverlay,
|
|
4678
|
+
outcomeNavComplete,
|
|
4679
|
+
dynamicNavInputDeclared,
|
|
4680
|
+
navTailInputDeclared,
|
|
4681
|
+
navTailChildless,
|
|
4682
|
+
navVariantOnChain,
|
|
4683
|
+
computedNavOnChain,
|
|
4684
|
+
computedOneFunctionKnown,
|
|
4685
|
+
remoteTailSingle,
|
|
4686
|
+
remoteTailRouted,
|
|
4687
|
+
remoteNameUnique,
|
|
4688
|
+
remoteMountPatternValid,
|
|
4689
|
+
remoteMountMatchesRoute,
|
|
4690
|
+
fieldCheckBound,
|
|
4691
|
+
filterGroupSqueezeOrphan,
|
|
4692
|
+
contextGroupPrimaryUnique,
|
|
4693
|
+
functionCaseArgs,
|
|
4694
|
+
outcomeTransformSelfFold,
|
|
4695
|
+
handBindingResolves,
|
|
4696
|
+
handRequiredInputBound,
|
|
4697
|
+
handScreenResolves,
|
|
4698
|
+
landingPageBound,
|
|
4699
|
+
navVisibilityResolvable,
|
|
4700
|
+
methodVariantNoLanding,
|
|
4701
|
+
methodVariantUnused,
|
|
4702
|
+
overlayBodyBound,
|
|
4703
|
+
pageInputRoutable,
|
|
4704
|
+
reservedVariantNameFree,
|
|
4705
|
+
featureNameFree,
|
|
4706
|
+
screenControlReachable,
|
|
4707
|
+
screenInputBound,
|
|
4708
|
+
searchFeedResolves,
|
|
4709
|
+
searchAnswerResolves,
|
|
4710
|
+
shapeMatch,
|
|
4711
|
+
statePathResolves,
|
|
4712
|
+
ruleOperandFits,
|
|
4713
|
+
themeSelectionResolves,
|
|
4714
|
+
timerComplete,
|
|
4715
|
+
variantGateSatisfiable,
|
|
4716
|
+
// Gesture rules, judged on the design as it stands so an edit made outside
|
|
4717
|
+
// the editor meets them too (0128_11).
|
|
4718
|
+
routerOutletPlaced,
|
|
4719
|
+
controlIdUnique,
|
|
4720
|
+
fieldKeyTypeAgrees,
|
|
4721
|
+
submitTargetResolves,
|
|
4722
|
+
formResetResolves,
|
|
4723
|
+
ruleFieldResolves,
|
|
4724
|
+
embedShapeWithinFeature,
|
|
4725
|
+
storeNameReserved,
|
|
4726
|
+
storeMemberNameUnique,
|
|
4727
|
+
functionNameUnshadowed,
|
|
4728
|
+
functionTierFiled,
|
|
4729
|
+
functionRefExclusive,
|
|
4730
|
+
bindingResolvesOutputs
|
|
4731
|
+
];
|
|
4732
|
+
var runInvariants = (scope) => INVARIANTS.flatMap((invariant) => invariant.run(scope));
|
|
4733
|
+
var invariantScopeOf = (source, themeCatalog) => ({
|
|
4734
|
+
appTarget: source.appTarget,
|
|
4735
|
+
wcConfig: source.wcConfig,
|
|
4736
|
+
features: (0, import_codegen64.featuresAsRead)(
|
|
4737
|
+
source.features,
|
|
4738
|
+
source.sharedShapes,
|
|
4739
|
+
source.screens.map(({ meta, state }) => ({
|
|
4740
|
+
...(0, import_codegen64.isFeatureScreen)(meta) ? { featureId: meta.featureId } : {},
|
|
4741
|
+
controlMap: state.controlMap
|
|
4742
|
+
}))
|
|
4743
|
+
),
|
|
4744
|
+
screens: source.screens.map(({ meta }) => meta),
|
|
4745
|
+
navMap: source.navMap,
|
|
4746
|
+
controlMap: {},
|
|
4747
|
+
screenControlMaps: Object.fromEntries(
|
|
4748
|
+
source.screens.map(({ meta, state }) => [meta.id, state.controlMap])
|
|
4749
|
+
),
|
|
4750
|
+
functions: source.functions,
|
|
4751
|
+
distinct: source.distinct,
|
|
4752
|
+
sharedShapes: source.sharedShapes,
|
|
4753
|
+
enums: source.enums,
|
|
4754
|
+
themes: source.themes,
|
|
4755
|
+
themeCatalog: [...themeCatalog],
|
|
4756
|
+
hand: source.hand,
|
|
4757
|
+
currentScreenId: void 0
|
|
4758
|
+
});
|
|
4759
|
+
|
|
4760
|
+
// apps/m-one-ui/src/app/pages/design/lib/gestures/finding-gestures.ts
|
|
4761
|
+
var refuse5 = (reason, detail) => ({
|
|
4762
|
+
ok: false,
|
|
4763
|
+
notes: [],
|
|
4764
|
+
refusal: { reason, ...detail ? { detail } : {} }
|
|
4765
|
+
});
|
|
4766
|
+
function screenMemberNameTakenOn(screen, name, exceptId) {
|
|
4767
|
+
if ((0, import_codegen65.isReservedVariantName)(name)) return true;
|
|
4768
|
+
return [
|
|
4769
|
+
...Object.values(screen.inputs ?? {}),
|
|
4770
|
+
...Object.values(screen.outputs ?? {}),
|
|
4771
|
+
...Object.values(screen.constants ?? {}),
|
|
4772
|
+
...Object.values(screen.variables ?? {}),
|
|
4773
|
+
...Object.values(screen.formModels ?? {}),
|
|
4774
|
+
...Object.values(screen.computeds ?? {}),
|
|
4775
|
+
...Object.values(screen.methods ?? {})
|
|
4776
|
+
].some((member) => member.id !== exceptId && member.name === name);
|
|
4777
|
+
}
|
|
4778
|
+
function routeInputsDeclared(screen, names, mint = import_codegen65.genId) {
|
|
4779
|
+
const taken = new Set(Object.values(screen.inputs ?? {}).map((input) => input.name));
|
|
4780
|
+
const minted = names.filter((name) => !taken.has(name));
|
|
4781
|
+
const inputs = { ...screen.inputs ?? {} };
|
|
4782
|
+
minted.forEach((name) => {
|
|
4783
|
+
const id = mint();
|
|
4784
|
+
inputs[id] = { id, name, dataType: { type: "string" }, cardinality: "one", required: true };
|
|
4785
|
+
});
|
|
4786
|
+
return { inputs, minted };
|
|
4787
|
+
}
|
|
4788
|
+
var EDITOR_ONLY = /* @__PURE__ */ new Set(["cast", "prune", "remove"]);
|
|
4789
|
+
var findingFix = {
|
|
4790
|
+
name: "finding-fix",
|
|
4791
|
+
summary: "Apply one of a Finding's apply-Fixes \u2014 the Repair Register's Fix button, by the Finding's key",
|
|
4792
|
+
args: {
|
|
4793
|
+
key: {
|
|
4794
|
+
type: "string",
|
|
4795
|
+
required: true,
|
|
4796
|
+
doc: "The Finding key, as `mag-cli findings` gives it"
|
|
4797
|
+
},
|
|
4798
|
+
fix: {
|
|
4799
|
+
type: "string",
|
|
4800
|
+
required: true,
|
|
4801
|
+
doc: "The apply-Fix id the Finding offers: computed-fix, route-input-fix (cast, prune, remove: in the editor only)"
|
|
4802
|
+
}
|
|
4803
|
+
},
|
|
4804
|
+
run: (ctx, { key, fix }) => {
|
|
4805
|
+
if (EDITOR_ONLY.has(fix))
|
|
4806
|
+
return refuse5("fix-editor-only", { fix, where: "m-one-ui \u2192 Repair" });
|
|
4807
|
+
const violation = runInvariants(invariantScopeOf(ctx.source, [])).find(
|
|
4808
|
+
(one) => violationFindingKey(one) === key
|
|
4809
|
+
);
|
|
4810
|
+
if (!violation) return refuse5("finding-unknown", { key });
|
|
4811
|
+
const finding = { source: "violation", violation };
|
|
4812
|
+
if (!applyFixesOf(finding).some((offered) => offered.id === fix))
|
|
4813
|
+
return refuse5("fix-not-offered", {
|
|
4814
|
+
key,
|
|
4815
|
+
fix,
|
|
4816
|
+
offered: applyFixesOf(finding).map((offered) => offered.id)
|
|
4817
|
+
});
|
|
4818
|
+
if (fix === "computed-fix" && violation.computedFix) {
|
|
4819
|
+
const { featureId, functionId, params } = violation.computedFix;
|
|
4820
|
+
const fn = (featureId ? ctx.source.features[featureId]?.functions?.[functionId] : void 0) ?? ctx.source.functions[functionId];
|
|
4821
|
+
if (!fn) return refuse5("function-unknown", { functionId });
|
|
4822
|
+
const saved = functionSave.run(ctx, { fn: { ...fn, params }, featureId: featureId ?? null });
|
|
4823
|
+
return saved.ok ? { ...saved, notes: [`${fn.name}: parameters retyped`, ...saved.notes] } : saved;
|
|
4824
|
+
}
|
|
4825
|
+
if (fix === "route-input-fix" && violation.routeInputFix) {
|
|
4826
|
+
const { screenId, name } = violation.routeInputFix;
|
|
4827
|
+
const slot = ctx.screenOf(screenId);
|
|
4828
|
+
if (!slot) return refuse5("screen-unknown", { screenId });
|
|
4829
|
+
if (screenMemberNameTakenOn(slot.meta, name))
|
|
4830
|
+
return refuse5("screen-member-name-taken", { screenId, name });
|
|
4831
|
+
const { inputs, minted } = routeInputsDeclared(slot.meta, [name]);
|
|
4832
|
+
if (!minted.length) return refuse5("fix-nothing-to-do", { key });
|
|
4833
|
+
return {
|
|
4834
|
+
ok: true,
|
|
4835
|
+
notes: [`${slot.meta.name}: ScreenInput ${name} declared`],
|
|
4836
|
+
patch: { screens: { [screenId]: { ...slot, meta: { ...slot.meta, inputs } } } }
|
|
4837
|
+
};
|
|
4838
|
+
}
|
|
4839
|
+
return refuse5("fix-not-offered", { key, fix });
|
|
4840
|
+
}
|
|
4841
|
+
};
|
|
4842
|
+
|
|
4843
|
+
// apps/m-one-ui/src/app/pages/design/lib/function-check.ts
|
|
4844
|
+
var import_codegen66 = require("./index.js");
|
|
4845
|
+
|
|
4846
|
+
// apps/m-one-ui/src/app/pages/design/lib/pure-lib.ts
|
|
4847
|
+
var PURE_LIB_FILE = "pure.lib.d.ts";
|
|
4848
|
+
var PURE_LIB = `
|
|
4849
|
+
interface Boolean { valueOf(): boolean; }
|
|
4850
|
+
interface Function { readonly length: number; readonly name: string; }
|
|
4851
|
+
interface IArguments {}
|
|
4852
|
+
interface RegExp {
|
|
4853
|
+
test(string: string): boolean;
|
|
4854
|
+
exec(string: string): RegExpExecArray | null;
|
|
4855
|
+
readonly source: string;
|
|
4856
|
+
readonly flags: string;
|
|
4857
|
+
}
|
|
4858
|
+
interface RegExpExecArray extends Array<string> { index: number; input: string; }
|
|
4859
|
+
interface RegExpMatchArray extends Array<string> { index?: number; input?: string; }
|
|
4860
|
+
interface Object {
|
|
4861
|
+
toString(): string;
|
|
4862
|
+
valueOf(): Object;
|
|
4863
|
+
hasOwnProperty(v: string): boolean;
|
|
4864
|
+
}
|
|
4865
|
+
interface ObjectConstructor {
|
|
4866
|
+
keys(o: object): string[];
|
|
4867
|
+
values<T>(o: { [s: string]: T } | ArrayLike<T>): T[];
|
|
4868
|
+
entries<T>(o: { [s: string]: T } | ArrayLike<T>): [string, T][];
|
|
4869
|
+
fromEntries<T>(entries: Iterable<readonly [PropertyKey, T]>): { [k: string]: T };
|
|
4870
|
+
assign<T, U>(target: T, source: U): T & U;
|
|
4871
|
+
freeze<T>(o: T): Readonly<T>;
|
|
4872
|
+
}
|
|
4873
|
+
declare var Object: ObjectConstructor;
|
|
4874
|
+
|
|
4875
|
+
interface String {
|
|
4876
|
+
readonly length: number;
|
|
4877
|
+
charAt(pos: number): string;
|
|
4878
|
+
charCodeAt(index: number): number;
|
|
4879
|
+
codePointAt(pos: number): number | undefined;
|
|
4880
|
+
concat(...strings: string[]): string;
|
|
4881
|
+
endsWith(searchString: string, endPosition?: number): boolean;
|
|
4882
|
+
includes(searchString: string, position?: number): boolean;
|
|
4883
|
+
indexOf(searchString: string, position?: number): number;
|
|
4884
|
+
lastIndexOf(searchString: string, position?: number): number;
|
|
4885
|
+
localeCompare(that: string): number;
|
|
4886
|
+
match(regexp: string | RegExp): RegExpMatchArray | null;
|
|
4887
|
+
normalize(form?: string): string;
|
|
4888
|
+
padEnd(maxLength: number, fillString?: string): string;
|
|
4889
|
+
padStart(maxLength: number, fillString?: string): string;
|
|
4890
|
+
repeat(count: number): string;
|
|
4891
|
+
replace(searchValue: string | RegExp, replaceValue: string): string;
|
|
4892
|
+
replaceAll(searchValue: string | RegExp, replaceValue: string): string;
|
|
4893
|
+
search(regexp: string | RegExp): number;
|
|
4894
|
+
slice(start?: number, end?: number): string;
|
|
4895
|
+
split(separator: string | RegExp, limit?: number): string[];
|
|
4896
|
+
startsWith(searchString: string, position?: number): boolean;
|
|
4897
|
+
substring(start: number, end?: number): string;
|
|
4898
|
+
toLowerCase(): string;
|
|
4899
|
+
toUpperCase(): string;
|
|
4900
|
+
toLocaleLowerCase(locales?: string | string[]): string;
|
|
4901
|
+
toLocaleUpperCase(locales?: string | string[]): string;
|
|
4902
|
+
trim(): string;
|
|
4903
|
+
trimStart(): string;
|
|
4904
|
+
trimEnd(): string;
|
|
4905
|
+
toString(): string;
|
|
4906
|
+
valueOf(): string;
|
|
4907
|
+
readonly [index: number]: string;
|
|
4908
|
+
}
|
|
4909
|
+
interface StringConstructor {
|
|
4910
|
+
(value?: unknown): string;
|
|
4911
|
+
fromCharCode(...codes: number[]): string;
|
|
4912
|
+
raw(template: { raw: readonly string[] | ArrayLike<string> }, ...substitutions: unknown[]): string;
|
|
4913
|
+
}
|
|
4914
|
+
declare var String: StringConstructor;
|
|
4915
|
+
|
|
4916
|
+
interface Number {
|
|
4917
|
+
toExponential(fractionDigits?: number): string;
|
|
4918
|
+
toFixed(digits?: number): string;
|
|
4919
|
+
toPrecision(precision?: number): string;
|
|
4920
|
+
toString(radix?: number): string;
|
|
4921
|
+
toLocaleString(locales?: string | string[], options?: object): string;
|
|
4922
|
+
valueOf(): number;
|
|
4923
|
+
}
|
|
4924
|
+
interface NumberConstructor {
|
|
4925
|
+
(value?: unknown): number;
|
|
4926
|
+
readonly MAX_SAFE_INTEGER: number;
|
|
4927
|
+
readonly MIN_SAFE_INTEGER: number;
|
|
4928
|
+
readonly MAX_VALUE: number;
|
|
4929
|
+
readonly MIN_VALUE: number;
|
|
4930
|
+
readonly EPSILON: number;
|
|
4931
|
+
readonly POSITIVE_INFINITY: number;
|
|
4932
|
+
readonly NEGATIVE_INFINITY: number;
|
|
4933
|
+
readonly NaN: number;
|
|
4934
|
+
isFinite(number: unknown): boolean;
|
|
4935
|
+
isInteger(number: unknown): boolean;
|
|
4936
|
+
isNaN(number: unknown): boolean;
|
|
4937
|
+
isSafeInteger(number: unknown): boolean;
|
|
4938
|
+
parseFloat(string: string): number;
|
|
4939
|
+
parseInt(string: string, radix?: number): number;
|
|
4940
|
+
}
|
|
4941
|
+
declare var Number: NumberConstructor;
|
|
4942
|
+
|
|
4943
|
+
interface BooleanConstructor { (value?: unknown): boolean; }
|
|
4944
|
+
declare var Boolean: BooleanConstructor;
|
|
4945
|
+
|
|
4946
|
+
interface Math {
|
|
4947
|
+
readonly E: number;
|
|
4948
|
+
readonly LN10: number;
|
|
4949
|
+
readonly LN2: number;
|
|
4950
|
+
readonly PI: number;
|
|
4951
|
+
readonly SQRT2: number;
|
|
4952
|
+
abs(x: number): number;
|
|
4953
|
+
ceil(x: number): number;
|
|
4954
|
+
floor(x: number): number;
|
|
4955
|
+
round(x: number): number;
|
|
4956
|
+
trunc(x: number): number;
|
|
4957
|
+
sign(x: number): number;
|
|
4958
|
+
max(...values: number[]): number;
|
|
4959
|
+
min(...values: number[]): number;
|
|
4960
|
+
pow(x: number, y: number): number;
|
|
4961
|
+
sqrt(x: number): number;
|
|
4962
|
+
cbrt(x: number): number;
|
|
4963
|
+
log(x: number): number;
|
|
4964
|
+
log2(x: number): number;
|
|
4965
|
+
log10(x: number): number;
|
|
4966
|
+
exp(x: number): number;
|
|
4967
|
+
hypot(...values: number[]): number;
|
|
4968
|
+
}
|
|
4969
|
+
/**
|
|
4970
|
+
* No \`random\`. A pure function returning a different value on each call is not
|
|
4971
|
+
* one, and a \`Math.random()\` inside a \`computed()\` would not recompute anyway
|
|
4972
|
+
* \u2014 signals track dependencies and entropy is not one.
|
|
4973
|
+
*/
|
|
4974
|
+
declare var Math: Math;
|
|
4975
|
+
|
|
4976
|
+
/**
|
|
4977
|
+
* Reading the clock is admitted (ADR 0199): \`today()\` is impure by nature and
|
|
4978
|
+
* that is accepted. Only reads and formatting are declared \u2014 no setters.
|
|
4979
|
+
*/
|
|
4980
|
+
interface Date {
|
|
4981
|
+
getTime(): number;
|
|
4982
|
+
getFullYear(): number;
|
|
4983
|
+
getMonth(): number;
|
|
4984
|
+
getDate(): number;
|
|
4985
|
+
getDay(): number;
|
|
4986
|
+
getHours(): number;
|
|
4987
|
+
getMinutes(): number;
|
|
4988
|
+
getSeconds(): number;
|
|
4989
|
+
getMilliseconds(): number;
|
|
4990
|
+
getUTCFullYear(): number;
|
|
4991
|
+
getUTCMonth(): number;
|
|
4992
|
+
getUTCDate(): number;
|
|
4993
|
+
getUTCDay(): number;
|
|
4994
|
+
getUTCHours(): number;
|
|
4995
|
+
getUTCMinutes(): number;
|
|
4996
|
+
getUTCSeconds(): number;
|
|
4997
|
+
getTimezoneOffset(): number;
|
|
4998
|
+
toISOString(): string;
|
|
4999
|
+
toJSON(): string;
|
|
5000
|
+
toDateString(): string;
|
|
5001
|
+
toTimeString(): string;
|
|
5002
|
+
toLocaleDateString(locales?: string | string[]): string;
|
|
5003
|
+
toLocaleTimeString(locales?: string | string[]): string;
|
|
5004
|
+
toLocaleString(locales?: string | string[]): string;
|
|
5005
|
+
valueOf(): number;
|
|
5006
|
+
}
|
|
5007
|
+
interface DateConstructor {
|
|
5008
|
+
new (value?: number | string | Date): Date;
|
|
5009
|
+
new (year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date;
|
|
5010
|
+
now(): number;
|
|
5011
|
+
parse(s: string): number;
|
|
5012
|
+
UTC(year: number, monthIndex?: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
|
|
5013
|
+
}
|
|
5014
|
+
declare var Date: DateConstructor;
|
|
5015
|
+
|
|
5016
|
+
interface JSON {
|
|
5017
|
+
parse(text: string): unknown;
|
|
5018
|
+
stringify(value: unknown): string;
|
|
5019
|
+
}
|
|
5020
|
+
declare var JSON: JSON;
|
|
5021
|
+
|
|
5022
|
+
interface ArrayLike<T> { readonly length: number; readonly [n: number]: T; }
|
|
5023
|
+
interface ConcatArray<T> { readonly length: number; readonly [n: number]: T; join(separator?: string): string; slice(start?: number, end?: number): T[]; }
|
|
5024
|
+
interface Array<T> {
|
|
5025
|
+
length: number;
|
|
5026
|
+
[n: number]: T;
|
|
5027
|
+
concat(...items: ConcatArray<T>[]): T[];
|
|
5028
|
+
every(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
|
|
5029
|
+
filter(predicate: (value: T, index: number, array: T[]) => unknown): T[];
|
|
5030
|
+
find(predicate: (value: T, index: number, obj: T[]) => unknown): T | undefined;
|
|
5031
|
+
findIndex(predicate: (value: T, index: number, obj: T[]) => unknown): number;
|
|
5032
|
+
flat<D extends number = 1>(depth?: D): unknown[];
|
|
5033
|
+
flatMap<U>(callback: (value: T, index: number, array: T[]) => U | U[]): U[];
|
|
5034
|
+
forEach(callbackfn: (value: T, index: number, array: T[]) => void): void;
|
|
5035
|
+
includes(searchElement: T, fromIndex?: number): boolean;
|
|
5036
|
+
indexOf(searchElement: T, fromIndex?: number): number;
|
|
5037
|
+
join(separator?: string): string;
|
|
5038
|
+
lastIndexOf(searchElement: T, fromIndex?: number): number;
|
|
5039
|
+
map<U>(callbackfn: (value: T, index: number, array: T[]) => U): U[];
|
|
5040
|
+
reduce(callbackfn: (prev: T, cur: T, index: number, array: T[]) => T): T;
|
|
5041
|
+
reduce<U>(callbackfn: (prev: U, cur: T, index: number, array: T[]) => U, initialValue: U): U;
|
|
5042
|
+
reduceRight<U>(callbackfn: (prev: U, cur: T, index: number, array: T[]) => U, initialValue: U): U;
|
|
5043
|
+
reverse(): T[];
|
|
5044
|
+
slice(start?: number, end?: number): T[];
|
|
5045
|
+
some(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
|
|
5046
|
+
sort(compareFn?: (a: T, b: T) => number): this;
|
|
5047
|
+
at(index: number): T | undefined;
|
|
5048
|
+
}
|
|
5049
|
+
interface ReadonlyArray<T> {
|
|
5050
|
+
readonly length: number;
|
|
5051
|
+
readonly [n: number]: T;
|
|
5052
|
+
every(predicate: (value: T, index: number, array: readonly T[]) => unknown): boolean;
|
|
5053
|
+
filter(predicate: (value: T, index: number, array: readonly T[]) => unknown): T[];
|
|
5054
|
+
find(predicate: (value: T, index: number, obj: readonly T[]) => unknown): T | undefined;
|
|
5055
|
+
includes(searchElement: T, fromIndex?: number): boolean;
|
|
5056
|
+
indexOf(searchElement: T, fromIndex?: number): number;
|
|
5057
|
+
join(separator?: string): string;
|
|
5058
|
+
map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U): U[];
|
|
5059
|
+
reduce<U>(callbackfn: (prev: U, cur: T, index: number, array: readonly T[]) => U, initialValue: U): U;
|
|
1987
5060
|
slice(start?: number, end?: number): T[];
|
|
1988
5061
|
some(predicate: (value: T, index: number, array: readonly T[]) => unknown): boolean;
|
|
1989
5062
|
}
|
|
@@ -2127,17 +5200,17 @@ function closedShapeIds(shapes, rootIds) {
|
|
|
2127
5200
|
const shape = shapes[id];
|
|
2128
5201
|
if (!shape || seen.has(id)) return;
|
|
2129
5202
|
seen.add(id);
|
|
2130
|
-
(0,
|
|
5203
|
+
(0, import_codegen66.referencedShapeIds)(shape).forEach(walk);
|
|
2131
5204
|
};
|
|
2132
5205
|
rootIds.forEach(walk);
|
|
2133
5206
|
return Array.from(seen);
|
|
2134
5207
|
}
|
|
2135
5208
|
function ambientTypes(shapes, fn, enums) {
|
|
2136
|
-
const shapeSource = closedShapeIds(shapes, (0,
|
|
2137
|
-
const formSource = (0,
|
|
2138
|
-
const optionSource = (0,
|
|
2139
|
-
const enumSource = (0,
|
|
2140
|
-
(entry) => `enum ${entry.name} { ${entry.values.map((value, i) => `${(0,
|
|
5209
|
+
const shapeSource = closedShapeIds(shapes, (0, import_codegen66.signatureShapeIds)(fn)).map((id) => shapes[id]).filter((shape) => !!shape).map((shape) => (0, import_codegen66.generateShapeInterface)(shapes, shape, { imports: false })).join("\n");
|
|
5210
|
+
const formSource = (0, import_codegen66.signatureFormIds)(fn).map((id) => shapes[id]).filter((shape) => !!shape).map((shape) => (0, import_codegen66.generateFormInterface)(shape)).join("\n");
|
|
5211
|
+
const optionSource = (0, import_codegen66.signatureNamesOptionRow)(fn) ? `interface ${import_codegen66.OPTION_ROW_TYPE_NAME} { value: string; label: string; }` : "";
|
|
5212
|
+
const enumSource = (0, import_codegen66.signatureEnums)(fn, enums).map(
|
|
5213
|
+
(entry) => `enum ${entry.name} { ${entry.values.map((value, i) => `${(0, import_codegen66.enumMemberName)(entry, i)} = '${value}'`).join(", ")} }`
|
|
2141
5214
|
).join("\n");
|
|
2142
5215
|
const source = [enumSource, shapeSource, formSource, optionSource].filter(Boolean).join("\n");
|
|
2143
5216
|
return source && !source.endsWith("\n") ? `${source}
|
|
@@ -2164,7 +5237,7 @@ function checkFunctionBody(ts, shapes, fn, allowlist = {}, enums) {
|
|
|
2164
5237
|
}
|
|
2165
5238
|
}
|
|
2166
5239
|
const source = wrap(shapes, fn, enums);
|
|
2167
|
-
const
|
|
5240
|
+
const named2 = fn.name.trim() ? fn : { ...fn, name: "name" };
|
|
2168
5241
|
const shapeSource = ambientTypes(shapes, fn, enums);
|
|
2169
5242
|
const stubSource = (fn.imports ?? []).filter((entry) => allowlist[entry.package]).flatMap(
|
|
2170
5243
|
(entry) => entry.names.map((name) => `declare const ${name}: any;`)
|
|
@@ -2212,7 +5285,7 @@ function checkFunctionBody(ts, shapes, fn, allowlist = {}, enums) {
|
|
|
2212
5285
|
});
|
|
2213
5286
|
});
|
|
2214
5287
|
if (file) {
|
|
2215
|
-
const bodyStart = stubBlock.length + shapeSource.length + (0,
|
|
5288
|
+
const bodyStart = stubBlock.length + shapeSource.length + (0, import_codegen66.signatureText)(shapes, named2, enums).length + 1;
|
|
2216
5289
|
problems.push(
|
|
2217
5290
|
...purity(ts, file, prependLines, bodyStart, bodyLineOffset)
|
|
2218
5291
|
);
|
|
@@ -2220,8 +5293,8 @@ function checkFunctionBody(ts, shapes, fn, allowlist = {}, enums) {
|
|
|
2220
5293
|
return problems;
|
|
2221
5294
|
}
|
|
2222
5295
|
function wrap(shapes, fn, enums) {
|
|
2223
|
-
const
|
|
2224
|
-
return `${(0,
|
|
5296
|
+
const named2 = fn.name.trim() ? fn : { ...fn, name: "name" };
|
|
5297
|
+
return `${(0, import_codegen66.signatureText)(shapes, named2, enums)}
|
|
2225
5298
|
${fn.body}
|
|
2226
5299
|
};
|
|
2227
5300
|
`;
|
|
@@ -2243,7 +5316,7 @@ function compilerHost(ts, files) {
|
|
|
2243
5316
|
function purity(ts, file, prependLines, bodyStart, bodyLineOffset) {
|
|
2244
5317
|
const found = [];
|
|
2245
5318
|
const banned = new Set(
|
|
2246
|
-
|
|
5319
|
+
import_codegen66.IMPURE_TOKENS.filter((token) => /^[a-zA-Z]+$/.test(token))
|
|
2247
5320
|
);
|
|
2248
5321
|
const report = (node, name) => {
|
|
2249
5322
|
const at = file.getLineAndCharacterOfPosition(node.getStart(file));
|
|
@@ -2279,26 +5352,26 @@ var functionBodyCheckFor = (ts) => (source, fn, featureId) => {
|
|
|
2279
5352
|
var functionScopeOf = (source, featureId) => {
|
|
2280
5353
|
const shapes = { ...source.sharedShapes };
|
|
2281
5354
|
Object.values(source.features).forEach((feature) => Object.assign(shapes, feature.shapes));
|
|
2282
|
-
source.screens.forEach(({ state }) => Object.assign(shapes, (0,
|
|
5355
|
+
source.screens.forEach(({ state }) => Object.assign(shapes, (0, import_codegen66.formShapeMap)(state.controlMap)));
|
|
2283
5356
|
const enums = featureId ? (() => {
|
|
2284
|
-
const found = (0,
|
|
2285
|
-
source.screens.filter(({ meta }) => (0,
|
|
2286
|
-
tree: (0,
|
|
5357
|
+
const found = (0, import_codegen66.controlEnums)(
|
|
5358
|
+
source.screens.filter(({ meta }) => (0, import_codegen66.isFeatureScreen)(meta) && meta.featureId === featureId).map(({ state }) => ({
|
|
5359
|
+
tree: (0, import_codegen66.buildTree)(state.controlMap, state.rootControlIds),
|
|
2287
5360
|
controlMap: state.controlMap
|
|
2288
5361
|
}))
|
|
2289
5362
|
);
|
|
2290
|
-
return found.some((entry) => entry.library) ? found : [...found,
|
|
2291
|
-
})() : [
|
|
5363
|
+
return found.some((entry) => entry.library) ? found : [...found, import_codegen66.SORT_DIRECTION_ENUM];
|
|
5364
|
+
})() : [import_codegen66.SORT_DIRECTION_ENUM];
|
|
2292
5365
|
return { shapes, allowlist: source.npmAllowlist ?? {}, enums };
|
|
2293
5366
|
};
|
|
2294
5367
|
|
|
2295
5368
|
// apps/m-one-ui/src/app/pages/design/lib/function-case-runner.ts
|
|
2296
|
-
var
|
|
5369
|
+
var import_codegen67 = require("./index.js");
|
|
2297
5370
|
function transpileFunction(ts, shapes, fn, cases, enums) {
|
|
2298
|
-
const
|
|
2299
|
-
const shapeSource = ambientTypes(shapes,
|
|
5371
|
+
const named2 = fn.name.trim() ? fn : { ...fn, name: "name" };
|
|
5372
|
+
const shapeSource = ambientTypes(shapes, named2, enums);
|
|
2300
5373
|
const caseSource = cases.map((entry) => `[[${entry.args.join(", ")}], ${entry.expected}]`).join(",\n");
|
|
2301
|
-
const source = `${shapeSource}${(0,
|
|
5374
|
+
const source = `${shapeSource}${(0, import_codegen67.signatureText)(shapes, named2, enums)}
|
|
2302
5375
|
${fn.body}
|
|
2303
5376
|
};
|
|
2304
5377
|
`.replace(
|
|
@@ -2335,7 +5408,7 @@ ${caseSource}
|
|
|
2335
5408
|
try {
|
|
2336
5409
|
const [impl, values] = new Function(
|
|
2337
5410
|
`${outputText}
|
|
2338
|
-
return [${
|
|
5411
|
+
return [${named2.name}, __cases];`
|
|
2339
5412
|
)();
|
|
2340
5413
|
return { impl, values };
|
|
2341
5414
|
} catch (error) {
|
|
@@ -2350,21 +5423,21 @@ var functionCaseRunFor = (ts) => (source, fn, featureId) => {
|
|
|
2350
5423
|
const cases = fn.cases ?? [];
|
|
2351
5424
|
if (!cases.length) return [];
|
|
2352
5425
|
const scope = functionScopeOf(source, featureId);
|
|
2353
|
-
const runnable = cases.filter((entry) => (0,
|
|
5426
|
+
const runnable = cases.filter((entry) => (0, import_codegen67.caseFits)(fn, entry, scope.shapes));
|
|
2354
5427
|
const compiled = transpileFunction(ts, scope.shapes, fn, runnable, scope.enums);
|
|
2355
5428
|
const impl = compiled.impl;
|
|
2356
5429
|
if (!impl)
|
|
2357
5430
|
return cases.map(() => ({ ok: false, passed: false, error: compiled.error ?? "" }));
|
|
2358
5431
|
let next = 0;
|
|
2359
5432
|
return cases.map((entry) => {
|
|
2360
|
-
if (!(0,
|
|
5433
|
+
if (!(0, import_codegen67.caseFits)(fn, entry, scope.shapes))
|
|
2361
5434
|
return { ok: false, passed: false, error: "The case no longer fits the signature." };
|
|
2362
5435
|
const [args, expected] = compiled.values[next++];
|
|
2363
5436
|
try {
|
|
2364
5437
|
const actual = impl(...args);
|
|
2365
5438
|
if (actual instanceof Promise)
|
|
2366
5439
|
return { ok: false, passed: false, error: "The body answered a Promise." };
|
|
2367
|
-
return { ok: true, passed: (0,
|
|
5440
|
+
return { ok: true, passed: (0, import_codegen67.caseEquals)(actual, expected), actual };
|
|
2368
5441
|
} catch (error) {
|
|
2369
5442
|
return { ok: false, passed: false, error: errorText(error) };
|
|
2370
5443
|
}
|
|
@@ -2383,7 +5456,8 @@ var GESTURES = [
|
|
|
2383
5456
|
controlBind,
|
|
2384
5457
|
functionSave,
|
|
2385
5458
|
functionDelete,
|
|
2386
|
-
functionReplace
|
|
5459
|
+
functionReplace,
|
|
5460
|
+
findingFix
|
|
2387
5461
|
];
|
|
2388
5462
|
var gestureByName = (name) => GESTURES.find((gesture) => gesture.name === name);
|
|
2389
5463
|
var applyGesture = (source, patch) => {
|