@objectstack/lint 16.1.0 → 17.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3627 -0
- package/dist/index.cjs +3889 -287
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +902 -35
- package/dist/index.d.ts +902 -35
- package/dist/index.js +3820 -281
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
// src/validate-widget-bindings.ts
|
|
2
2
|
import { isIncoherentAggregate } from "@objectstack/spec/data";
|
|
3
|
+
import { ChartTypeSchema } from "@objectstack/spec/ui";
|
|
4
|
+
|
|
5
|
+
// src/system-fields.ts
|
|
6
|
+
import { FIELD_GROUP_SYSTEM_FIELDS } from "@objectstack/spec/data";
|
|
7
|
+
import { SystemFieldName } from "@objectstack/spec/system";
|
|
8
|
+
var SYSTEM_FIELDS = /* @__PURE__ */ new Set([
|
|
9
|
+
...FIELD_GROUP_SYSTEM_FIELDS,
|
|
10
|
+
...Object.values(SystemFieldName)
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
// src/validate-widget-bindings.ts
|
|
3
14
|
var WIDGET_DATASET_UNKNOWN = "widget-dataset-unknown";
|
|
4
15
|
var WIDGET_DIMENSION_UNKNOWN = "widget-dimension-unknown";
|
|
5
16
|
var WIDGET_MEASURE_UNKNOWN = "widget-measure-unknown";
|
|
@@ -30,20 +41,18 @@ function asArray(v) {
|
|
|
30
41
|
function asStrings(v) {
|
|
31
42
|
return Array.isArray(v) ? v.filter((s) => typeof s === "string") : [];
|
|
32
43
|
}
|
|
33
|
-
var
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"funnel",
|
|
42
|
-
"scatter",
|
|
43
|
-
"treemap",
|
|
44
|
-
"sankey",
|
|
45
|
-
"radar"
|
|
44
|
+
var MEASURE_EXEMPT_CHART_TYPES = /* @__PURE__ */ new Set([
|
|
45
|
+
"gauge",
|
|
46
|
+
"solid-gauge",
|
|
47
|
+
"metric",
|
|
48
|
+
"kpi",
|
|
49
|
+
"bullet",
|
|
50
|
+
"table",
|
|
51
|
+
"pivot"
|
|
46
52
|
]);
|
|
53
|
+
var CHART_TYPES = new Set(
|
|
54
|
+
ChartTypeSchema.options.filter((t) => !MEASURE_EXEMPT_CHART_TYPES.has(t))
|
|
55
|
+
);
|
|
47
56
|
function levenshtein(a, b) {
|
|
48
57
|
const m = a.length, n = b.length;
|
|
49
58
|
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
@@ -89,18 +98,6 @@ function list(names) {
|
|
|
89
98
|
}
|
|
90
99
|
var DATE_RANGE_FILTER_NAME = "dateRange";
|
|
91
100
|
var DATE_RANGE_DEFAULT_FIELD = "created_at";
|
|
92
|
-
var SYSTEM_FIELDS = /* @__PURE__ */ new Set([
|
|
93
|
-
"id",
|
|
94
|
-
"created_at",
|
|
95
|
-
"created_by",
|
|
96
|
-
"updated_at",
|
|
97
|
-
"updated_by",
|
|
98
|
-
"owner_id",
|
|
99
|
-
"organization_id",
|
|
100
|
-
"tenant_id",
|
|
101
|
-
"user_id",
|
|
102
|
-
"deleted_at"
|
|
103
|
-
]);
|
|
104
101
|
function dashboardFilterDefs(dash) {
|
|
105
102
|
const byName = /* @__PURE__ */ new Map();
|
|
106
103
|
const dateRange = dash.dateRange;
|
|
@@ -216,6 +213,15 @@ function validateWidgetBindings(stack) {
|
|
|
216
213
|
hint: `Declared datasets: ${list(datasets.keys())}.${suggest(dsName, datasets.keys())} Define the dataset with defineDataset() or fix the reference (ADR-0021).`
|
|
217
214
|
});
|
|
218
215
|
}
|
|
216
|
+
if (!dsName) {
|
|
217
|
+
push({
|
|
218
|
+
severity: "error",
|
|
219
|
+
rule: WIDGET_DATASET_UNKNOWN,
|
|
220
|
+
message: `binds no \`dataset\` \u2014 the ADR-0021 widget shape requires one, so this widget resolves no data and renders empty.`,
|
|
221
|
+
hint: `Set \`dataset: '<name>'\` (plus \`values\`, and \`dimensions\` where the chart family needs them). Declared datasets: ${list(datasets.keys())}.`
|
|
222
|
+
});
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
219
225
|
if (!dataset) continue;
|
|
220
226
|
if (dashFilterDefs.length > 0) {
|
|
221
227
|
const datasetObject = typeof dataset.object === "string" ? dataset.object : void 0;
|
|
@@ -277,13 +283,13 @@ function validateWidgetBindings(stack) {
|
|
|
277
283
|
hint: `Point xAxis.field at a dataset dimension name.${suggest(xAxis.field, dimensionNames)}`
|
|
278
284
|
});
|
|
279
285
|
}
|
|
280
|
-
const measureField = (
|
|
286
|
+
const measureField = (label2, field) => {
|
|
281
287
|
if (values.includes(field)) return;
|
|
282
288
|
const declaredButUnselected = measures.has(field);
|
|
283
289
|
push({
|
|
284
290
|
severity: "error",
|
|
285
291
|
rule: CHART_FIELD_UNKNOWN,
|
|
286
|
-
message: declaredButUnselected ? `chartConfig.${
|
|
292
|
+
message: declaredButUnselected ? `chartConfig.${label2} "${field}" is a measure of dataset "${dsName}" but is not selected in the widget's values (${list(values)}), so the query result will not contain it.` : `chartConfig.${label2} "${field}" does not resolve to a measure of dataset "${dsName}" (declared measures: ${list(measures.keys())}).`,
|
|
287
293
|
hint: declaredButUnselected ? `Add "${field}" to the widget's values, or bind the chart to a selected measure.` : `Post-cutover data is keyed by the dataset's measure NAME, not the base column.${suggest(field, selectedValues.size > 0 ? selectedValues : measures.keys())}`
|
|
288
294
|
});
|
|
289
295
|
};
|
|
@@ -325,6 +331,7 @@ function validateWidgetBindings(stack) {
|
|
|
325
331
|
|
|
326
332
|
// src/validate-expressions.ts
|
|
327
333
|
import { validateExpression } from "@objectstack/formula";
|
|
334
|
+
import { collectFlowGraphs, resolveFlowNodeExpressions } from "@objectstack/spec/automation";
|
|
328
335
|
function asArray2(v) {
|
|
329
336
|
if (Array.isArray(v)) return v;
|
|
330
337
|
if (v && typeof v === "object") {
|
|
@@ -385,37 +392,53 @@ function validateStackExpressions(stack) {
|
|
|
385
392
|
for (const e of res.errors) issues.push({ where, message: e.message, source: e.source, severity: "error" });
|
|
386
393
|
for (const w of res.warnings) issues.push({ where, message: w.message, source: w.source, severity: "warning" });
|
|
387
394
|
};
|
|
395
|
+
const checkDeclaredPredicate = (where, raw) => {
|
|
396
|
+
if (raw == null) return;
|
|
397
|
+
const res = validateExpression("predicate", raw);
|
|
398
|
+
for (const e of res.errors) issues.push({ where, message: e.message, source: e.source, severity: "error" });
|
|
399
|
+
for (const w of res.warnings) issues.push({ where, message: w.message, source: w.source, severity: "warning" });
|
|
400
|
+
};
|
|
388
401
|
for (const flow of asArray2(stack.flows)) {
|
|
389
402
|
const flowName = typeof flow.name === "string" ? flow.name : "(unnamed flow)";
|
|
390
403
|
const nodes = Array.isArray(flow.nodes) ? flow.nodes : [];
|
|
391
|
-
const edges = Array.isArray(flow.edges) ? flow.edges : [];
|
|
392
404
|
const startNode = nodes.find((n) => n.type === "start");
|
|
393
405
|
const startCfg = startNode?.config ?? {};
|
|
394
406
|
const objectName = typeof startCfg.objectName === "string" ? startCfg.objectName : void 0;
|
|
395
|
-
for (const
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
const
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
407
|
+
for (const graph of collectFlowGraphs(flow)) {
|
|
408
|
+
const at = graph.scope ? `flow '${flowName}' \xB7 ${graph.scope}` : `flow '${flowName}'`;
|
|
409
|
+
for (const node of graph.nodes) {
|
|
410
|
+
const cfg = node.config ?? {};
|
|
411
|
+
check(`${at} \xB7 node '${node.id}' (${node.type}) condition`, cfg.condition, objectName);
|
|
412
|
+
const nodeType = typeof node.type === "string" ? node.type : "";
|
|
413
|
+
for (const found of resolveFlowNodeExpressions(nodeType, cfg)) {
|
|
414
|
+
if (found.entry.role !== "predicate") continue;
|
|
415
|
+
checkDeclaredPredicate(
|
|
416
|
+
`${at} \xB7 node '${node.id}' (${nodeType}) ${found.entry.label} at config.${found.path}`,
|
|
417
|
+
found.value
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
if (node.type === "script") {
|
|
421
|
+
const fn = (typeof cfg.function === "string" ? cfg.function.trim() : "") || (typeof cfg.functionName === "string" ? cfg.functionName.trim() : "");
|
|
422
|
+
const action = typeof cfg.actionType === "string" ? cfg.actionType.trim() : "";
|
|
423
|
+
const inline = typeof cfg.script === "string" ? cfg.script.trim() : "";
|
|
424
|
+
if (!fn && !action && !inline) {
|
|
425
|
+
issues.push({
|
|
426
|
+
where: `${at} \xB7 node '${node.id}' (script) callable`,
|
|
427
|
+
message: `script node declares neither \`actionType\` nor \`function\` \u2014 it would do nothing at runtime. Name a built-in action (e.g. \`actionType: 'email'\`) or a registered function (\`function: 'my_fn'\`, registered via \`defineStack({ functions })\`).`,
|
|
428
|
+
source: JSON.stringify({ id: node.id, type: node.type, config: cfg })
|
|
429
|
+
});
|
|
430
|
+
} else if (action === "invoke_function" && !fn) {
|
|
431
|
+
issues.push({
|
|
432
|
+
where: `${at} \xB7 node '${node.id}' (script) callable`,
|
|
433
|
+
message: `script node uses \`actionType: 'invoke_function'\` but no \`function\` (or \`functionName\`) \u2014 it names no callable. Set \`function: 'my_fn'\` and register it via \`defineStack({ functions })\`.`,
|
|
434
|
+
source: JSON.stringify({ id: node.id, type: node.type, config: cfg })
|
|
435
|
+
});
|
|
436
|
+
}
|
|
414
437
|
}
|
|
415
438
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
439
|
+
for (const edge of graph.edges) {
|
|
440
|
+
check(`${at} \xB7 edge '${edge.id}' (${edge.source}\u2192${edge.target}) condition`, edge.condition, objectName);
|
|
441
|
+
}
|
|
419
442
|
}
|
|
420
443
|
}
|
|
421
444
|
for (const obj of objects) {
|
|
@@ -474,8 +497,33 @@ function validateStackExpressions(stack) {
|
|
|
474
497
|
check(where, rule.condition ?? rule.criteria ?? rule.predicate, ruleObj, "record");
|
|
475
498
|
}
|
|
476
499
|
for (const hook of asArray2(stack.hooks)) {
|
|
477
|
-
const
|
|
478
|
-
|
|
500
|
+
const hookName = hook.name ?? "?";
|
|
501
|
+
if (typeof hook.object === "string") {
|
|
502
|
+
check(`hook '${hookName}' (${hook.object}) condition`, hook.condition, hook.object, "record");
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
const targets = Array.isArray(hook.object) ? hook.object.filter((o) => typeof o === "string" && o !== "*") : [];
|
|
506
|
+
if (targets.length === 0) {
|
|
507
|
+
check(`hook '${hookName}' condition`, hook.condition, void 0, "record");
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
const before = issues.length;
|
|
511
|
+
const seen = /* @__PURE__ */ new Set();
|
|
512
|
+
const kept = [];
|
|
513
|
+
for (const target of targets) {
|
|
514
|
+
const mark = issues.length;
|
|
515
|
+
check(`hook '${hookName}' (${target}) condition`, hook.condition, target, "record");
|
|
516
|
+
for (let i = mark; i < issues.length; i++) {
|
|
517
|
+
const issue = issues[i];
|
|
518
|
+
const key = `${issue.message}\0${issue.source ?? ""}`;
|
|
519
|
+
if (!seen.has(key)) {
|
|
520
|
+
seen.add(key);
|
|
521
|
+
kept.push(issue);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
issues.length = before;
|
|
526
|
+
issues.push(...kept);
|
|
479
527
|
}
|
|
480
528
|
return issues;
|
|
481
529
|
}
|
|
@@ -534,14 +582,14 @@ function scanListViews(listViews, wherePrefix, pathPrefix, out) {
|
|
|
534
582
|
function validateListViewMode(stack) {
|
|
535
583
|
const out = [];
|
|
536
584
|
asArray3(stack.objects).forEach((obj, i) => {
|
|
537
|
-
const
|
|
538
|
-
scanListViews(obj.listViews,
|
|
585
|
+
const label2 = typeof obj.name === "string" ? `object "${obj.name}"` : `objects[${i}]`;
|
|
586
|
+
scanListViews(obj.listViews, label2, `objects[${i}]`, out);
|
|
539
587
|
});
|
|
540
588
|
asArray3(stack.views).forEach((view, i) => {
|
|
541
589
|
const named = typeof view.objectName === "string" ? view.objectName : typeof view.name === "string" ? view.name : void 0;
|
|
542
|
-
const
|
|
543
|
-
scanView(view.list, `${
|
|
544
|
-
scanListViews(view.listViews,
|
|
590
|
+
const label2 = named ? `view "${named}"` : `views[${i}]`;
|
|
591
|
+
scanView(view.list, `${label2} \u203A list`, `views[${i}].list`, out);
|
|
592
|
+
scanListViews(view.listViews, label2, `views[${i}]`, out);
|
|
545
593
|
});
|
|
546
594
|
return out;
|
|
547
595
|
}
|
|
@@ -549,6 +597,8 @@ function validateListViewMode(stack) {
|
|
|
549
597
|
// src/validate-flow-trigger-readiness.ts
|
|
550
598
|
var FLOW_TRIGGER_UNKNOWN_OBJECT = "flow-trigger-unknown-object";
|
|
551
599
|
var FLOW_DRAFT_STATUS_AMBIGUOUS = "flow-draft-status-ambiguous";
|
|
600
|
+
var FLOW_TRIGGER_UNKNOWN_EVENT = "flow-trigger-unknown-event";
|
|
601
|
+
var VALID_RECORD_TRIGGER = /^record-(?:before|after)-(?:create|insert|update|delete|write)$/;
|
|
552
602
|
function asArray4(v) {
|
|
553
603
|
if (Array.isArray(v)) return v;
|
|
554
604
|
if (v && typeof v === "object") {
|
|
@@ -576,10 +626,11 @@ function validateFlowTriggerReadiness(stack) {
|
|
|
576
626
|
const start = startNodeOf(flow);
|
|
577
627
|
const config = start?.node.config ?? {};
|
|
578
628
|
const triggerType = typeof config.triggerType === "string" ? config.triggerType : void 0;
|
|
579
|
-
const
|
|
629
|
+
const isRecordTriggered2 = !!triggerType && triggerType.startsWith("record-");
|
|
630
|
+
const isArrayRecordTriggered = Array.isArray(config.triggerType) && config.triggerType.some((t) => typeof t === "string" && t.startsWith("record-"));
|
|
580
631
|
const isTimeRelative = config.timeRelative != null && typeof config.timeRelative === "object";
|
|
581
|
-
const isAutoTriggered =
|
|
582
|
-
if (
|
|
632
|
+
const isAutoTriggered = isRecordTriggered2 || triggerType === "api" || config.schedule != null || isTimeRelative || flow.type === "schedule" || flow.type === "api";
|
|
633
|
+
if (isRecordTriggered2 && start) {
|
|
583
634
|
const objectName = typeof config.objectName === "string" ? config.objectName : void 0;
|
|
584
635
|
if (objectName && !objectNames.has(objectName) && !objectName.startsWith("sys_")) {
|
|
585
636
|
findings.push({
|
|
@@ -606,6 +657,26 @@ function validateFlowTriggerReadiness(stack) {
|
|
|
606
657
|
});
|
|
607
658
|
}
|
|
608
659
|
}
|
|
660
|
+
if (start && isRecordTriggered2 && !VALID_RECORD_TRIGGER.test((triggerType ?? "").trim())) {
|
|
661
|
+
findings.push({
|
|
662
|
+
severity: "warning",
|
|
663
|
+
rule: FLOW_TRIGGER_UNKNOWN_EVENT,
|
|
664
|
+
where: `flow "${flowName}" \u203A start node`,
|
|
665
|
+
path: `flows[${flowIndex}].nodes[${start.index}].config.triggerType`,
|
|
666
|
+
message: `triggerType '${triggerType}' is not a recognized record trigger \u2014 the flow binds to the record-change trigger but never fires (the runtime stays silent about it).`,
|
|
667
|
+
hint: `Use record-{before,after}-{create,update,delete,write}. 'write' fires on create OR update in one flow (#3427); create/insert are synonyms. There is no "any change" token \u2014 pick the specific event(s).`
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
if (start && isArrayRecordTriggered) {
|
|
671
|
+
findings.push({
|
|
672
|
+
severity: "warning",
|
|
673
|
+
rule: FLOW_TRIGGER_UNKNOWN_EVENT,
|
|
674
|
+
where: `flow "${flowName}" \u203A start node`,
|
|
675
|
+
path: `flows[${flowIndex}].nodes[${start.index}].config.triggerType`,
|
|
676
|
+
message: `triggerType is an array (${JSON.stringify(config.triggerType)}), which is not supported \u2014 a start node takes a single trigger event, so the flow binds to nothing and never fires (the runtime stays silent about it).`,
|
|
677
|
+
hint: `Use one triggerType string. For "created or updated" use record-after-write (one flow, both events, #3427). For any other combination, author one flow per event \u2014 multi-event arrays are deferred (#3457).`
|
|
678
|
+
});
|
|
679
|
+
}
|
|
609
680
|
if (isAutoTriggered && (flow.status == null || flow.status === "draft")) {
|
|
610
681
|
findings.push({
|
|
611
682
|
severity: "warning",
|
|
@@ -620,6 +691,375 @@ function validateFlowTriggerReadiness(stack) {
|
|
|
620
691
|
return findings;
|
|
621
692
|
}
|
|
622
693
|
|
|
694
|
+
// src/flow-walk.ts
|
|
695
|
+
import { FLOW_REGION_SLOTS_BY_TYPE, FLOW_REGION_CONFIG_KEYS } from "@objectstack/spec/automation";
|
|
696
|
+
function isRec(v) {
|
|
697
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
698
|
+
}
|
|
699
|
+
function strName(v) {
|
|
700
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
701
|
+
}
|
|
702
|
+
var REGION_SLOTS = new Map(
|
|
703
|
+
[...FLOW_REGION_SLOTS_BY_TYPE].map(([type, slots]) => [type, slots.map((s) => s.key)])
|
|
704
|
+
);
|
|
705
|
+
var REGION_CONFIG_KEYS = FLOW_REGION_CONFIG_KEYS;
|
|
706
|
+
var MAX_REGION_DEPTH = 16;
|
|
707
|
+
function flowNodeLabel(node, index) {
|
|
708
|
+
return strName(node.label) ?? strName(node.id) ?? `#${index}`;
|
|
709
|
+
}
|
|
710
|
+
function stripRegions(config) {
|
|
711
|
+
if (!isRec(config)) return void 0;
|
|
712
|
+
let out;
|
|
713
|
+
for (const key of Object.keys(config)) {
|
|
714
|
+
if (!REGION_CONFIG_KEYS.has(key)) continue;
|
|
715
|
+
out ?? (out = { ...config });
|
|
716
|
+
delete out[key];
|
|
717
|
+
}
|
|
718
|
+
return out ?? config;
|
|
719
|
+
}
|
|
720
|
+
function walkFlowNodes(flow, flowPath) {
|
|
721
|
+
const out = [];
|
|
722
|
+
if (!isRec(flow)) return out;
|
|
723
|
+
const visitList = (nodes, basePath, trail, depth) => {
|
|
724
|
+
if (!Array.isArray(nodes) || depth > MAX_REGION_DEPTH) return;
|
|
725
|
+
nodes.forEach((raw, index) => {
|
|
726
|
+
if (!isRec(raw)) return;
|
|
727
|
+
const path = `${basePath}[${index}]`;
|
|
728
|
+
out.push({
|
|
729
|
+
node: raw,
|
|
730
|
+
path,
|
|
731
|
+
localConfig: stripRegions(raw.config),
|
|
732
|
+
regionTrail: trail,
|
|
733
|
+
depth
|
|
734
|
+
});
|
|
735
|
+
const type = strName(raw.type);
|
|
736
|
+
const slots = type ? REGION_SLOTS.get(type) : void 0;
|
|
737
|
+
if (!slots || !isRec(raw.config)) return;
|
|
738
|
+
const config = raw.config;
|
|
739
|
+
const here = `${type} "${flowNodeLabel(raw, index)}"`;
|
|
740
|
+
for (const slot of slots) {
|
|
741
|
+
const value = config[slot];
|
|
742
|
+
if (slot === "branches") {
|
|
743
|
+
if (!Array.isArray(value)) continue;
|
|
744
|
+
value.forEach((branch, b) => {
|
|
745
|
+
if (!isRec(branch)) return;
|
|
746
|
+
const branchName = strName(branch.name) ?? `#${b}`;
|
|
747
|
+
visitList(
|
|
748
|
+
branch.nodes,
|
|
749
|
+
`${path}.config.branches[${b}].nodes`,
|
|
750
|
+
joinTrail(trail, `${here} \u203A branch ${branchName}`),
|
|
751
|
+
depth + 1
|
|
752
|
+
);
|
|
753
|
+
});
|
|
754
|
+
continue;
|
|
755
|
+
}
|
|
756
|
+
if (!isRec(value)) continue;
|
|
757
|
+
visitList(
|
|
758
|
+
value.nodes,
|
|
759
|
+
`${path}.config.${slot}.nodes`,
|
|
760
|
+
joinTrail(trail, `${here} \u203A ${slot}`),
|
|
761
|
+
depth + 1
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
};
|
|
766
|
+
visitList(flow.nodes, `${flowPath}.nodes`, "", 0);
|
|
767
|
+
return out;
|
|
768
|
+
}
|
|
769
|
+
function joinTrail(trail, segment) {
|
|
770
|
+
return trail ? `${trail} \u203A ${segment}` : segment;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// src/validate-flow-template-paths.ts
|
|
774
|
+
var FLOW_TEMPLATE_UNKNOWN_FIELD = "flow-template-unknown-field";
|
|
775
|
+
var FLOW_TEMPLATE_LOOKUP_TRAVERSAL = "flow-template-lookup-traversal";
|
|
776
|
+
function asArray5(v) {
|
|
777
|
+
if (Array.isArray(v)) return v;
|
|
778
|
+
if (v && typeof v === "object") {
|
|
779
|
+
return Object.entries(v).map(([name, def]) => ({
|
|
780
|
+
name,
|
|
781
|
+
...def
|
|
782
|
+
}));
|
|
783
|
+
}
|
|
784
|
+
return [];
|
|
785
|
+
}
|
|
786
|
+
var IMPLICIT_HEADS = /* @__PURE__ */ new Set([
|
|
787
|
+
...SYSTEM_FIELDS,
|
|
788
|
+
"name",
|
|
789
|
+
"owner",
|
|
790
|
+
"record_type"
|
|
791
|
+
]);
|
|
792
|
+
var RELATION_TYPES = /* @__PURE__ */ new Set([
|
|
793
|
+
"lookup",
|
|
794
|
+
"master_detail",
|
|
795
|
+
"user",
|
|
796
|
+
"tree"
|
|
797
|
+
]);
|
|
798
|
+
var FILTER_GUARDED_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
799
|
+
"get_record",
|
|
800
|
+
"update_record",
|
|
801
|
+
"delete_record"
|
|
802
|
+
]);
|
|
803
|
+
function fieldTypesOf(obj) {
|
|
804
|
+
const types = /* @__PURE__ */ new Map();
|
|
805
|
+
for (const f of asArray5(obj.fields)) {
|
|
806
|
+
if (typeof f.name === "string") {
|
|
807
|
+
types.set(f.name, typeof f.type === "string" ? f.type : "");
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return types;
|
|
811
|
+
}
|
|
812
|
+
function recordRefsIn(text) {
|
|
813
|
+
const refs = [];
|
|
814
|
+
const tokenRe = /\{([^{}]+)\}/g;
|
|
815
|
+
let m;
|
|
816
|
+
while ((m = tokenRe.exec(text)) !== null) {
|
|
817
|
+
const body = m[1].trim();
|
|
818
|
+
if (!/^[A-Za-z_$][\w$]*(?:\.(?:[A-Za-z_$][\w$]*|\d+))*$/.test(body)) continue;
|
|
819
|
+
const segments = body.split(".");
|
|
820
|
+
if (segments[0] !== "record") continue;
|
|
821
|
+
const rest = segments.slice(1);
|
|
822
|
+
if (rest.length > 0) refs.push(rest);
|
|
823
|
+
}
|
|
824
|
+
return refs;
|
|
825
|
+
}
|
|
826
|
+
function stringLeaves(value, out) {
|
|
827
|
+
if (typeof value === "string") {
|
|
828
|
+
if (value.includes("{")) out.push(value);
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
if (Array.isArray(value)) {
|
|
832
|
+
for (const v of value) stringLeaves(v, out);
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
if (value && typeof value === "object") {
|
|
836
|
+
for (const v of Object.values(value)) stringLeaves(v, out);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
var NODE_CONFIG_KEYS = [
|
|
840
|
+
"config",
|
|
841
|
+
"notify",
|
|
842
|
+
"update_record",
|
|
843
|
+
"create_record",
|
|
844
|
+
"http",
|
|
845
|
+
"script",
|
|
846
|
+
"screen",
|
|
847
|
+
"wait",
|
|
848
|
+
"approval",
|
|
849
|
+
"connector_action",
|
|
850
|
+
"subflow",
|
|
851
|
+
"decision",
|
|
852
|
+
"start"
|
|
853
|
+
];
|
|
854
|
+
function collectNodeLeaves(node, guarded) {
|
|
855
|
+
const filterLeaves = [];
|
|
856
|
+
const otherLeaves = [];
|
|
857
|
+
for (const key of NODE_CONFIG_KEYS) {
|
|
858
|
+
if (!(key in node)) continue;
|
|
859
|
+
const block = node[key];
|
|
860
|
+
const splitFilter = guarded && !!block && typeof block === "object" && !Array.isArray(block);
|
|
861
|
+
if (splitFilter) {
|
|
862
|
+
const { filter, ...rest } = block;
|
|
863
|
+
const inFilter = [];
|
|
864
|
+
stringLeaves(filter, inFilter);
|
|
865
|
+
for (const text of inFilter) filterLeaves.push({ text, inFilter: true });
|
|
866
|
+
const outside = [];
|
|
867
|
+
stringLeaves(rest, outside);
|
|
868
|
+
for (const text of outside) otherLeaves.push({ text, inFilter: false });
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
const plain = [];
|
|
872
|
+
stringLeaves(block, plain);
|
|
873
|
+
for (const text of plain) otherLeaves.push({ text, inFilter: false });
|
|
874
|
+
}
|
|
875
|
+
return [...filterLeaves, ...otherLeaves];
|
|
876
|
+
}
|
|
877
|
+
function isRecordTriggered(flow, startConfig) {
|
|
878
|
+
if (flow.type === "record_change") return true;
|
|
879
|
+
const triggerType = typeof startConfig.triggerType === "string" ? startConfig.triggerType : void 0;
|
|
880
|
+
return !!triggerType && triggerType.startsWith("record-");
|
|
881
|
+
}
|
|
882
|
+
function boundObjectOf(flow) {
|
|
883
|
+
const nodes = Array.isArray(flow.nodes) ? flow.nodes : [];
|
|
884
|
+
const start = nodes.find((n) => n?.type === "start");
|
|
885
|
+
if (!start) return void 0;
|
|
886
|
+
const config = start.config ?? {};
|
|
887
|
+
const typed = start.start ?? {};
|
|
888
|
+
const fromConfig = typeof config.objectName === "string" ? config.objectName : void 0;
|
|
889
|
+
const fromTyped = typeof typed.objectName === "string" ? typed.objectName : void 0;
|
|
890
|
+
return fromConfig ?? fromTyped;
|
|
891
|
+
}
|
|
892
|
+
function declaredExpandOf(flow) {
|
|
893
|
+
const nodes = Array.isArray(flow.nodes) ? flow.nodes : [];
|
|
894
|
+
const start = nodes.find((n) => n?.type === "start");
|
|
895
|
+
const raw = (start?.config ?? {}).expand;
|
|
896
|
+
if (typeof raw === "string") return new Set(raw ? [raw] : []);
|
|
897
|
+
if (Array.isArray(raw)) return new Set(raw.filter((r) => typeof r === "string" && r.length > 0));
|
|
898
|
+
return /* @__PURE__ */ new Set();
|
|
899
|
+
}
|
|
900
|
+
function validateFlowTemplatePaths(stack) {
|
|
901
|
+
const findings = [];
|
|
902
|
+
const flows = asArray5(stack.flows);
|
|
903
|
+
if (flows.length === 0) return findings;
|
|
904
|
+
const objectsByName = /* @__PURE__ */ new Map();
|
|
905
|
+
for (const obj of asArray5(stack.objects)) {
|
|
906
|
+
if (typeof obj.name === "string") objectsByName.set(obj.name, obj);
|
|
907
|
+
}
|
|
908
|
+
flows.forEach((flow, flowIndex) => {
|
|
909
|
+
const flowName = typeof flow.name === "string" ? flow.name : `#${flowIndex}`;
|
|
910
|
+
const nodes = Array.isArray(flow.nodes) ? flow.nodes : [];
|
|
911
|
+
const start = nodes.find((n) => n?.type === "start")?.config ?? {};
|
|
912
|
+
if (!isRecordTriggered(flow, start)) return;
|
|
913
|
+
const objectName = boundObjectOf(flow);
|
|
914
|
+
if (!objectName) return;
|
|
915
|
+
const obj = objectsByName.get(objectName);
|
|
916
|
+
if (!obj) return;
|
|
917
|
+
const fieldTypes = fieldTypesOf(obj);
|
|
918
|
+
const expandSet = declaredExpandOf(flow);
|
|
919
|
+
walkFlowNodes(flow, `flows[${flowIndex}]`).forEach(({ node, path: nodePath, regionTrail, localConfig }, walkIndex) => {
|
|
920
|
+
const nodeLabel = typeof node.type === "string" ? node.type : typeof node.id === "string" ? node.id : `#${walkIndex}`;
|
|
921
|
+
const where = regionTrail ? `flow "${flowName}" ${regionTrail} node "${nodeLabel}"` : `flow "${flowName}" node "${nodeLabel}"`;
|
|
922
|
+
const nodeType = typeof node.type === "string" ? node.type : "";
|
|
923
|
+
const guarded = FILTER_GUARDED_NODE_TYPES.has(nodeType);
|
|
924
|
+
const scanNode = localConfig !== void 0 && localConfig !== node.config ? { ...node, config: localConfig } : node;
|
|
925
|
+
const leaves = collectNodeLeaves(scanNode, guarded);
|
|
926
|
+
if (leaves.length === 0) return;
|
|
927
|
+
const seenUnknown = /* @__PURE__ */ new Set();
|
|
928
|
+
const seenTraversal = /* @__PURE__ */ new Set();
|
|
929
|
+
for (const leaf of leaves) {
|
|
930
|
+
const inFilter = leaf.inFilter;
|
|
931
|
+
for (const rest of recordRefsIn(leaf.text)) {
|
|
932
|
+
const head = rest[0];
|
|
933
|
+
const hasSubPath = rest.length > 1;
|
|
934
|
+
const nextIsIdentifier = hasSubPath && !/^\d+$/.test(rest[1]);
|
|
935
|
+
const isKnown = fieldTypes.has(head) || IMPLICIT_HEADS.has(head);
|
|
936
|
+
if (!isKnown) {
|
|
937
|
+
if (seenUnknown.has(head)) continue;
|
|
938
|
+
seenUnknown.add(head);
|
|
939
|
+
findings.push({
|
|
940
|
+
severity: inFilter ? "error" : "warning",
|
|
941
|
+
rule: FLOW_TEMPLATE_UNKNOWN_FIELD,
|
|
942
|
+
where,
|
|
943
|
+
path: nodePath,
|
|
944
|
+
message: inFilter ? `${nodeType} filter references '{record.${rest.join(".")}}', but '${head}' is not a field on object '${objectName}' \u2014 the token resolves to nothing, which DROPS the condition from the query instead of narrowing it. The node refuses to run at execution time (#3810).` : `template references '{record.${rest.join(".")}}', but '${head}' is not a field on object '${objectName}' \u2014 it resolves to an empty string at runtime (silently).`,
|
|
945
|
+
hint: inFilter ? `Check the field name against the object's field definitions (e.g. '{record.full_name}', not '{record.full_naem}'); system columns like id/created_at/owner are also addressable. This gates the build rather than warning: an absent condition WIDENS the query, so the runtime has already decided to refuse this node.` : `Check the field name against the object's field definitions (e.g. '{record.full_name}', not '{record.full_naem}'). System columns like id/created_at/owner are also addressable.`
|
|
946
|
+
});
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
if (nextIsIdentifier) {
|
|
950
|
+
const headType = fieldTypes.get(head) ?? "";
|
|
951
|
+
if (RELATION_TYPES.has(headType) && !expandSet.has(head)) {
|
|
952
|
+
const key = rest.join(".");
|
|
953
|
+
if (seenTraversal.has(key)) continue;
|
|
954
|
+
seenTraversal.add(key);
|
|
955
|
+
findings.push({
|
|
956
|
+
severity: inFilter ? "error" : "warning",
|
|
957
|
+
rule: FLOW_TEMPLATE_LOOKUP_TRAVERSAL,
|
|
958
|
+
where,
|
|
959
|
+
path: nodePath,
|
|
960
|
+
message: inFilter ? `${nodeType} filter references '{record.${key}}', a cross-object hop through the ${headType} field '${head}' \u2014 the flow record carries '${head}' as a scalar id, not an expanded object, so the token resolves to nothing and the condition is DROPPED from the query instead of narrowing it. The node refuses to run at execution time (#3810).` : `template references '{record.${key}}', a cross-object hop through the ${headType} field '${head}' \u2014 the flow record carries '${head}' as a scalar id, not an expanded object, so this resolves to an empty string at runtime (silently).`,
|
|
961
|
+
hint: inFilter ? `Opt in to resolve it: add '${head}' to the start node's config.expand (#3475) and the engine re-reads it as the run's identity. Otherwise filter on the foreign-key id directly ('{record.${head}}'), or project the value via a formula field on '${objectName}'. This gates the build rather than warning: an absent condition WIDENS the query.` : `Opt in to resolve it: add '${head}' to the start node's config.expand (#3475) and the engine re-reads it as the run's identity. Otherwise reference the foreign-key id directly ('{record.${head}}'), or project the value via a formula field on '${objectName}'.`
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
});
|
|
969
|
+
return findings;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// src/validate-readonly-flow-writes.ts
|
|
973
|
+
var FLOW_UPDATE_READONLY_FIELD = "flow-update-readonly-field";
|
|
974
|
+
var FLOW_UPDATE_READONLY_WHEN_FIELD = "flow-update-readonly-when-field";
|
|
975
|
+
function asArray6(v) {
|
|
976
|
+
if (Array.isArray(v)) return v;
|
|
977
|
+
if (v && typeof v === "object") {
|
|
978
|
+
return Object.entries(v).map(([name, def]) => ({
|
|
979
|
+
name,
|
|
980
|
+
...def
|
|
981
|
+
}));
|
|
982
|
+
}
|
|
983
|
+
return [];
|
|
984
|
+
}
|
|
985
|
+
function buildReadonlyIndex(objects) {
|
|
986
|
+
const idx = /* @__PURE__ */ new Map();
|
|
987
|
+
for (const obj of objects) {
|
|
988
|
+
const name = typeof obj.name === "string" ? obj.name : void 0;
|
|
989
|
+
if (!name) continue;
|
|
990
|
+
const fieldMap = /* @__PURE__ */ new Map();
|
|
991
|
+
const collect = (fieldName, def) => {
|
|
992
|
+
const rw = def?.readonlyWhen;
|
|
993
|
+
const readonlyWhen = rw != null && !(typeof rw === "string" && rw.trim() === "");
|
|
994
|
+
fieldMap.set(fieldName, { readonly: def?.readonly === true, readonlyWhen });
|
|
995
|
+
};
|
|
996
|
+
const fields = obj.fields;
|
|
997
|
+
if (Array.isArray(fields)) {
|
|
998
|
+
for (const f of fields) {
|
|
999
|
+
const fn = f?.name;
|
|
1000
|
+
if (typeof fn === "string") collect(fn, f);
|
|
1001
|
+
}
|
|
1002
|
+
} else if (fields && typeof fields === "object") {
|
|
1003
|
+
for (const [fn, def] of Object.entries(fields)) collect(fn, def);
|
|
1004
|
+
}
|
|
1005
|
+
idx.set(name, fieldMap);
|
|
1006
|
+
}
|
|
1007
|
+
return idx;
|
|
1008
|
+
}
|
|
1009
|
+
function readLiteralObjectName(config) {
|
|
1010
|
+
const raw = config.objectName ?? config.object;
|
|
1011
|
+
if (typeof raw !== "string" || raw.includes("{")) return void 0;
|
|
1012
|
+
return raw || void 0;
|
|
1013
|
+
}
|
|
1014
|
+
function validateReadonlyFlowWrites(stack) {
|
|
1015
|
+
const findings = [];
|
|
1016
|
+
const flows = asArray6(stack.flows);
|
|
1017
|
+
if (flows.length === 0) return findings;
|
|
1018
|
+
const roIndex = buildReadonlyIndex(asArray6(stack.objects));
|
|
1019
|
+
flows.forEach((flow, flowIndex) => {
|
|
1020
|
+
if (flow.runAs === "system") return;
|
|
1021
|
+
const runAs = flow.runAs === "user" || flow.runAs === "system" ? flow.runAs : "user";
|
|
1022
|
+
const flowName = typeof flow.name === "string" ? flow.name : `#${flowIndex}`;
|
|
1023
|
+
const walked = walkFlowNodes(flow, `flows[${flowIndex}]`);
|
|
1024
|
+
walked.forEach(({ node, path: nodePath, regionTrail }, walkIndex) => {
|
|
1025
|
+
if (node?.type !== "update_record") return;
|
|
1026
|
+
const config = node.config ?? {};
|
|
1027
|
+
const objectName = readLiteralObjectName(config);
|
|
1028
|
+
if (!objectName) return;
|
|
1029
|
+
const fieldMap = roIndex.get(objectName);
|
|
1030
|
+
if (!fieldMap) return;
|
|
1031
|
+
const fields = config.fields;
|
|
1032
|
+
if (!fields || typeof fields !== "object" || Array.isArray(fields)) return;
|
|
1033
|
+
const nodeName = flowNodeLabel(node, walkIndex);
|
|
1034
|
+
const where = regionTrail ? `flow "${flowName}" \u203A ${regionTrail} \u203A node "${nodeName}"` : `flow "${flowName}" \u203A node "${nodeName}"`;
|
|
1035
|
+
for (const fieldName of Object.keys(fields)) {
|
|
1036
|
+
const meta = fieldMap.get(fieldName);
|
|
1037
|
+
if (!meta) continue;
|
|
1038
|
+
if (meta.readonly) {
|
|
1039
|
+
findings.push({
|
|
1040
|
+
severity: "error",
|
|
1041
|
+
rule: FLOW_UPDATE_READONLY_FIELD,
|
|
1042
|
+
where,
|
|
1043
|
+
path: `${nodePath}.config.fields.${fieldName}`,
|
|
1044
|
+
message: `writes field '${fieldName}', which object '${objectName}' declares readonly:true. Under runAs:'${runAs}' the engine silently strips readonly fields from the UPDATE payload (#2948), so this write never lands \u2014 while the step still reports success.`,
|
|
1045
|
+
hint: `If automation is meant to maintain this field, declare the flow runAs:'system' (the intended channel \u2014 readonly governs the end-user/API surface, not trusted system writers). Otherwise remove '${fieldName}' from this update_record node.`
|
|
1046
|
+
});
|
|
1047
|
+
} else if (meta.readonlyWhen) {
|
|
1048
|
+
findings.push({
|
|
1049
|
+
severity: "warning",
|
|
1050
|
+
rule: FLOW_UPDATE_READONLY_WHEN_FIELD,
|
|
1051
|
+
where,
|
|
1052
|
+
path: `${nodePath}.config.fields.${fieldName}`,
|
|
1053
|
+
message: `writes field '${fieldName}', which object '${objectName}' declares readonlyWhen. On records where that predicate is TRUE, a runAs:'${runAs}' UPDATE strips the field (#3042), so this write may silently not land depending on the record's state.`,
|
|
1054
|
+
hint: `If automation must maintain this field regardless of record state, run the flow runAs:'system'. Otherwise confirm this node only targets records whose readonlyWhen predicate is FALSE.`
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
return findings;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
623
1063
|
// src/validate-view-containers.ts
|
|
624
1064
|
var VIEW_CONTAINER_SHAPE = "view-container-shape";
|
|
625
1065
|
var CONTAINER_SLOT_KEYS = ["list", "form", "listViews", "formViews"];
|
|
@@ -642,13 +1082,13 @@ function validateViewContainers(stack) {
|
|
|
642
1082
|
const rec = value;
|
|
643
1083
|
if (rec.viewKind != null) continue;
|
|
644
1084
|
if (containerViewCount(rec) > 0) continue;
|
|
645
|
-
const
|
|
1085
|
+
const label2 = typeof rec.name === "string" ? ` ("${rec.name}")` : "";
|
|
646
1086
|
const hasContainerSlot = CONTAINER_SLOT_KEYS.some((k) => k in rec);
|
|
647
1087
|
const looksFlat = !hasContainerSlot && ["type", "columns", "data", "filter", "sort"].some((k) => k in rec);
|
|
648
1088
|
out.push({
|
|
649
1089
|
severity: "error",
|
|
650
1090
|
rule: VIEW_CONTAINER_SHAPE,
|
|
651
|
-
where: `views${key}${
|
|
1091
|
+
where: `views${key}${label2}`,
|
|
652
1092
|
path: `views${key}`,
|
|
653
1093
|
message: looksFlat ? "Flat list-view object is not a view container: `ViewSchema` strips its keys, so it parses to an EMPTY container \u2014 zero views register and the Console renders no view for it." : "View container defines no views \u2014 all of `list` / `form` / `listViews` / `formViews` are absent or empty, so nothing registers.",
|
|
654
1094
|
hint: "Wrap every view in a defineView container: defineView({ list: { type, data, columns, ... }, listViews: { ... }, formViews: { ... } }). See examples/app-showcase/src/ui/views/task.view.ts."
|
|
@@ -860,7 +1300,7 @@ function looksLikeTailwind(className) {
|
|
|
860
1300
|
return false;
|
|
861
1301
|
});
|
|
862
1302
|
}
|
|
863
|
-
function
|
|
1303
|
+
function asArray7(v) {
|
|
864
1304
|
if (Array.isArray(v)) return v;
|
|
865
1305
|
if (v && typeof v === "object") {
|
|
866
1306
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
@@ -953,13 +1393,13 @@ function checkNode(node, pageName, path, findings) {
|
|
|
953
1393
|
}
|
|
954
1394
|
function validateResponsiveStyles(stack) {
|
|
955
1395
|
const findings = [];
|
|
956
|
-
const pages =
|
|
1396
|
+
const pages = asArray7(stack.pages);
|
|
957
1397
|
for (let p = 0; p < pages.length; p++) {
|
|
958
1398
|
const page = pages[p];
|
|
959
1399
|
const pageName = typeof page.name === "string" ? page.name : `pages[${p}]`;
|
|
960
|
-
const regions =
|
|
1400
|
+
const regions = asArray7(page.regions);
|
|
961
1401
|
for (let r = 0; r < regions.length; r++) {
|
|
962
|
-
const components =
|
|
1402
|
+
const components = asArray7(regions[r].components);
|
|
963
1403
|
for (let c = 0; c < components.length; c++) {
|
|
964
1404
|
checkNode(components[c], pageName, `pages[${p}].regions[${r}].components[${c}]`, findings);
|
|
965
1405
|
}
|
|
@@ -970,10 +1410,10 @@ function validateResponsiveStyles(stack) {
|
|
|
970
1410
|
|
|
971
1411
|
// src/validate-jsx-pages.ts
|
|
972
1412
|
import { parseJsx, compile } from "@objectstack/sdui-parser";
|
|
973
|
-
var
|
|
1413
|
+
var asArray8 = (v) => Array.isArray(v) ? v : [];
|
|
974
1414
|
function validateJsxPages(stack, opts = {}) {
|
|
975
1415
|
const findings = [];
|
|
976
|
-
const pages =
|
|
1416
|
+
const pages = asArray8(stack.pages);
|
|
977
1417
|
for (let p = 0; p < pages.length; p++) {
|
|
978
1418
|
const page = pages[p];
|
|
979
1419
|
if (!page || page.kind !== "html" && page.kind !== "jsx") continue;
|
|
@@ -1020,10 +1460,10 @@ function loadSucraseTransform() {
|
|
|
1020
1460
|
}
|
|
1021
1461
|
return cachedTransform;
|
|
1022
1462
|
}
|
|
1023
|
-
var
|
|
1463
|
+
var asArray9 = (v) => Array.isArray(v) ? v : [];
|
|
1024
1464
|
function validateReactPages(stack) {
|
|
1025
1465
|
const findings = [];
|
|
1026
|
-
const pages =
|
|
1466
|
+
const pages = asArray9(stack.pages);
|
|
1027
1467
|
for (let p = 0; p < pages.length; p++) {
|
|
1028
1468
|
const page = pages[p];
|
|
1029
1469
|
if (!page || page.kind !== "react") continue;
|
|
@@ -1060,87 +1500,783 @@ function validateReactPages(stack) {
|
|
|
1060
1500
|
|
|
1061
1501
|
// src/validate-react-page-props.ts
|
|
1062
1502
|
import { createRequire as createRequire2 } from "module";
|
|
1063
|
-
import { REACT_BLOCKS } from "@objectstack/spec/ui";
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
`@objectstack/lint: validating a kind:'react' page requires the "typescript" package, which could not be loaded (${err instanceof Error ? err.message : String(err)}). It is a declared dependency of @objectstack/lint \u2014 if this deployment prunes packages, keep "typescript" in the image; it is only loaded when a react-source page is validated.`
|
|
1073
|
-
);
|
|
1503
|
+
import { REACT_BLOCKS, chartAggregateResultKeys } from "@objectstack/spec/ui";
|
|
1504
|
+
import { VALID_AST_OPERATORS } from "@objectstack/spec/data";
|
|
1505
|
+
|
|
1506
|
+
// src/validate-searchable-fields.ts
|
|
1507
|
+
var SEARCHABLE_FIELD_UNKNOWN = "searchable-field-unknown";
|
|
1508
|
+
function asArray10(v) {
|
|
1509
|
+
if (Array.isArray(v)) return v;
|
|
1510
|
+
if (v && typeof v === "object") {
|
|
1511
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
1074
1512
|
}
|
|
1075
|
-
return
|
|
1513
|
+
return [];
|
|
1076
1514
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
);
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1515
|
+
function isRec2(v) {
|
|
1516
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
1517
|
+
}
|
|
1518
|
+
function strName2(v) {
|
|
1519
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
1520
|
+
}
|
|
1521
|
+
function declaredFieldNames(obj) {
|
|
1522
|
+
const fields = obj.fields;
|
|
1523
|
+
if (!fields || typeof fields !== "object") return null;
|
|
1524
|
+
const names = /* @__PURE__ */ new Set();
|
|
1525
|
+
for (const f of asArray10(fields)) {
|
|
1526
|
+
const n = strName2(f.name);
|
|
1527
|
+
if (n) names.add(n);
|
|
1528
|
+
}
|
|
1529
|
+
return names.size > 0 ? names : null;
|
|
1530
|
+
}
|
|
1531
|
+
function suggest2(target, known) {
|
|
1532
|
+
let best;
|
|
1533
|
+
let bestScore = Infinity;
|
|
1534
|
+
for (const candidate of known) {
|
|
1535
|
+
const d = distance(target, candidate);
|
|
1536
|
+
if (d < bestScore) {
|
|
1537
|
+
bestScore = d;
|
|
1538
|
+
best = candidate;
|
|
1097
1539
|
}
|
|
1098
1540
|
}
|
|
1099
|
-
|
|
1541
|
+
const limit = Math.max(2, Math.floor(target.length / 3));
|
|
1542
|
+
return best && bestScore <= limit ? ` Did you mean "${best}"?` : "";
|
|
1100
1543
|
}
|
|
1101
|
-
function
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1544
|
+
function distance(a, b) {
|
|
1545
|
+
const m = a.length;
|
|
1546
|
+
const n = b.length;
|
|
1547
|
+
if (m === 0) return n;
|
|
1548
|
+
if (n === 0) return m;
|
|
1549
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
1550
|
+
for (let i = 1; i <= m; i++) {
|
|
1551
|
+
const curr = [i, ...new Array(n).fill(0)];
|
|
1552
|
+
for (let j = 1; j <= n; j++) {
|
|
1553
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
1554
|
+
curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
1110
1555
|
}
|
|
1556
|
+
prev = curr;
|
|
1111
1557
|
}
|
|
1112
|
-
return
|
|
1558
|
+
return prev[n];
|
|
1113
1559
|
}
|
|
1114
|
-
function
|
|
1560
|
+
function indexObjectSearchTargets(stack) {
|
|
1561
|
+
const fieldsByObject = /* @__PURE__ */ new Map();
|
|
1562
|
+
if (!isRec2(stack)) return fieldsByObject;
|
|
1563
|
+
for (const obj of asArray10(stack.objects)) {
|
|
1564
|
+
const name = strName2(obj.name);
|
|
1565
|
+
if (name) fieldsByObject.set(name, declaredFieldNames(obj));
|
|
1566
|
+
}
|
|
1567
|
+
return fieldsByObject;
|
|
1568
|
+
}
|
|
1569
|
+
function checkSearchableFieldList(declared, objectName, fieldsByObject, where, path, subject) {
|
|
1115
1570
|
const findings = [];
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1571
|
+
if (!Array.isArray(declared) || declared.length === 0) return findings;
|
|
1572
|
+
if (!objectName) return findings;
|
|
1573
|
+
if (!fieldsByObject.has(objectName)) return findings;
|
|
1574
|
+
const known = fieldsByObject.get(objectName);
|
|
1575
|
+
if (!known) return findings;
|
|
1576
|
+
for (let i = 0; i < declared.length; i++) {
|
|
1577
|
+
const entry = declared[i];
|
|
1578
|
+
const name = strName2(entry);
|
|
1579
|
+
if (!name) continue;
|
|
1580
|
+
if (known.has(name) || SYSTEM_FIELDS.has(name)) continue;
|
|
1581
|
+
const dotted = name.includes(".");
|
|
1582
|
+
findings.push({
|
|
1583
|
+
severity: "error",
|
|
1584
|
+
rule: SEARCHABLE_FIELD_UNKNOWN,
|
|
1585
|
+
where,
|
|
1586
|
+
path: `${path}[${i}]`,
|
|
1587
|
+
message: `${subject} entry "${name}" is not a field on object "${objectName}". The declaration is stale: searching it can never match, and the engine silently drops it \u2014 leaving a narrower search than declared, or the auto-default set once every entry is dropped.` + (dotted ? "" : suggest2(name, known)),
|
|
1588
|
+
hint: (dotted ? `'search' scans this object's own columns, so a related record's column cannot be a search target \u2014 expand the relation and search the related object, or copy the value onto a formula field here. ` : `Fix the name, or add "${name}" to ${objectName}.fields. `) + `Clients echo this declaration verbatim as the '$searchFields' override, so a stale entry becomes a 400 INVALID_FIELD on list search (#4254), not just a quietly narrowed one.` + (known.size > 0 ? ` Object fields: ${[...known].sort().join(", ")}.` : "")
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
return findings;
|
|
1592
|
+
}
|
|
1593
|
+
function validateSearchableFields(stack) {
|
|
1594
|
+
const findings = [];
|
|
1595
|
+
if (!isRec2(stack)) return findings;
|
|
1596
|
+
const objects = asArray10(stack.objects);
|
|
1597
|
+
const fieldsByObject = indexObjectSearchTargets(stack);
|
|
1598
|
+
const check = (declared, objectName, where, path, subject) => {
|
|
1599
|
+
findings.push(
|
|
1600
|
+
...checkSearchableFieldList(declared, objectName, fieldsByObject, where, path, subject)
|
|
1601
|
+
);
|
|
1602
|
+
};
|
|
1603
|
+
for (let oi = 0; oi < objects.length; oi++) {
|
|
1604
|
+
const obj = objects[oi];
|
|
1605
|
+
if (!isRec2(obj)) continue;
|
|
1606
|
+
const objName = strName2(obj.name);
|
|
1607
|
+
const label2 = objName ? `object "${objName}"` : `objects[${oi}]`;
|
|
1608
|
+
check(
|
|
1609
|
+
obj.searchableFields,
|
|
1610
|
+
objName,
|
|
1611
|
+
label2,
|
|
1612
|
+
`objects[${oi}].searchableFields`,
|
|
1613
|
+
"searchableFields"
|
|
1614
|
+
);
|
|
1615
|
+
if (isRec2(obj.listViews)) {
|
|
1616
|
+
for (const [key, lv] of Object.entries(obj.listViews)) {
|
|
1617
|
+
if (!isRec2(lv)) continue;
|
|
1618
|
+
check(
|
|
1619
|
+
lv.searchableFields,
|
|
1620
|
+
// A built-in list view belongs to its object; an inline `data.object`
|
|
1621
|
+
// may still retarget it (ADR-0047 allows the explicit binding).
|
|
1622
|
+
listViewObject(lv) ?? objName,
|
|
1623
|
+
`${label2} \u203A listViews.${key}`,
|
|
1624
|
+
`objects[${oi}].listViews.${key}.searchableFields`,
|
|
1625
|
+
"list-view searchableFields"
|
|
1626
|
+
);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
const views = asArray10(stack.views);
|
|
1631
|
+
for (let vi = 0; vi < views.length; vi++) {
|
|
1632
|
+
const view = views[vi];
|
|
1633
|
+
if (!isRec2(view)) continue;
|
|
1634
|
+
const viewLabel = strName2(view.name) ?? strName2(view.objectName) ?? `#${vi}`;
|
|
1635
|
+
const viewObject = strName2(view.objectName) ?? strName2(view.object);
|
|
1636
|
+
if (isRec2(view.list)) {
|
|
1637
|
+
check(
|
|
1638
|
+
view.list.searchableFields,
|
|
1639
|
+
listViewObject(view.list) ?? viewObject,
|
|
1640
|
+
`view "${viewLabel}" \u203A list`,
|
|
1641
|
+
`views[${vi}].list.searchableFields`,
|
|
1642
|
+
"list-view searchableFields"
|
|
1643
|
+
);
|
|
1644
|
+
}
|
|
1645
|
+
if (isRec2(view.listViews)) {
|
|
1646
|
+
for (const [key, lv] of Object.entries(view.listViews)) {
|
|
1647
|
+
if (!isRec2(lv)) continue;
|
|
1648
|
+
check(
|
|
1649
|
+
lv.searchableFields,
|
|
1650
|
+
listViewObject(lv) ?? viewObject,
|
|
1651
|
+
`view "${viewLabel}" \u203A listViews.${key}`,
|
|
1652
|
+
`views[${vi}].listViews.${key}.searchableFields`,
|
|
1653
|
+
"list-view searchableFields"
|
|
1654
|
+
);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
return findings;
|
|
1659
|
+
}
|
|
1660
|
+
function listViewObject(listView) {
|
|
1661
|
+
const data = listView.data;
|
|
1662
|
+
return isRec2(data) ? strName2(data.object) : void 0;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
// src/page-walk.ts
|
|
1666
|
+
function isRec3(v) {
|
|
1667
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
1668
|
+
}
|
|
1669
|
+
function strName3(v) {
|
|
1670
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
1671
|
+
}
|
|
1672
|
+
var SOURCE_AUTHORED_KINDS = /* @__PURE__ */ new Set(["html", "react", "jsx"]);
|
|
1673
|
+
function isSourceAuthoredPage(page) {
|
|
1674
|
+
const kind = strName3(page.kind);
|
|
1675
|
+
return kind !== void 0 && SOURCE_AUTHORED_KINDS.has(kind);
|
|
1676
|
+
}
|
|
1677
|
+
function walkPageComponents(page, pagePath) {
|
|
1678
|
+
const out = [];
|
|
1679
|
+
if (!isRec3(page) || isSourceAuthoredPage(page)) return out;
|
|
1680
|
+
const pageObject = strName3(page.object);
|
|
1681
|
+
const visit = (node, path, inheritedObject) => {
|
|
1682
|
+
if (!isRec3(node)) return;
|
|
1683
|
+
const props = isRec3(node.properties) ? node.properties : void 0;
|
|
1684
|
+
const dataSource = isRec3(node.dataSource) ? node.dataSource : void 0;
|
|
1685
|
+
const objectName = strName3(dataSource?.object) ?? strName3(props?.object) ?? inheritedObject;
|
|
1686
|
+
out.push({ component: node, path, objectName });
|
|
1687
|
+
if (!props) return;
|
|
1688
|
+
if (Array.isArray(props.items)) {
|
|
1689
|
+
for (let i = 0; i < props.items.length; i++) {
|
|
1690
|
+
const item = props.items[i];
|
|
1691
|
+
if (!isRec3(item) || !Array.isArray(item.children)) continue;
|
|
1692
|
+
for (let c = 0; c < item.children.length; c++) {
|
|
1693
|
+
visit(item.children[c], `${path}.properties.items[${i}].children[${c}]`, objectName);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
if (Array.isArray(props.children)) {
|
|
1698
|
+
for (let i = 0; i < props.children.length; i++) {
|
|
1699
|
+
visit(props.children[i], `${path}.properties.children[${i}]`, objectName);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
for (const key of ["body", "footer"]) {
|
|
1703
|
+
const slotList = props[key];
|
|
1704
|
+
if (!Array.isArray(slotList)) continue;
|
|
1705
|
+
for (let i = 0; i < slotList.length; i++) {
|
|
1706
|
+
visit(slotList[i], `${path}.properties.${key}[${i}]`, objectName);
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
const regions = Array.isArray(page.regions) ? page.regions : [];
|
|
1711
|
+
for (let r = 0; r < regions.length; r++) {
|
|
1712
|
+
const region = regions[r];
|
|
1713
|
+
if (!isRec3(region) || !Array.isArray(region.components)) continue;
|
|
1714
|
+
for (let c = 0; c < region.components.length; c++) {
|
|
1715
|
+
visit(region.components[c], `${pagePath}.regions[${r}].components[${c}]`, pageObject);
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
const slots = isRec3(page.slots) ? page.slots : void 0;
|
|
1719
|
+
if (slots) {
|
|
1720
|
+
for (const [slot, value] of Object.entries(slots)) {
|
|
1721
|
+
const list3 = Array.isArray(value) ? value : [value];
|
|
1722
|
+
const indexed = Array.isArray(value);
|
|
1723
|
+
for (let i = 0; i < list3.length; i++) {
|
|
1724
|
+
visit(list3[i], `${pagePath}.slots.${slot}${indexed ? `[${i}]` : ""}`, pageObject);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
return out;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
// src/validate-page-field-bindings.ts
|
|
1732
|
+
var PAGE_FIELD_UNKNOWN = "page-field-unknown";
|
|
1733
|
+
function asArray11(v) {
|
|
1734
|
+
if (Array.isArray(v)) return v;
|
|
1735
|
+
if (v && typeof v === "object") {
|
|
1736
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
1737
|
+
}
|
|
1738
|
+
return [];
|
|
1739
|
+
}
|
|
1740
|
+
function strName4(v) {
|
|
1741
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
1742
|
+
}
|
|
1743
|
+
function isRec4(v) {
|
|
1744
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
1745
|
+
}
|
|
1746
|
+
function fieldRefsFrom(value, basePath) {
|
|
1747
|
+
const out = [];
|
|
1748
|
+
const one = (v, path) => {
|
|
1749
|
+
const bare = strName4(v);
|
|
1750
|
+
if (bare) {
|
|
1751
|
+
out.push({ name: bare, path });
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
if (!isRec4(v)) return;
|
|
1755
|
+
const named = strName4(v.field) ?? strName4(v.name);
|
|
1756
|
+
if (named) out.push({ name: named, path: `${path}.${strName4(v.field) ? "field" : "name"}` });
|
|
1757
|
+
};
|
|
1758
|
+
if (Array.isArray(value)) {
|
|
1759
|
+
for (let i = 0; i < value.length; i++) one(value[i], `${basePath}[${i}]`);
|
|
1760
|
+
} else {
|
|
1761
|
+
one(value, basePath);
|
|
1762
|
+
}
|
|
1763
|
+
return out;
|
|
1764
|
+
}
|
|
1765
|
+
function sortFieldRefs(value, basePath) {
|
|
1766
|
+
if (typeof value === "string") {
|
|
1767
|
+
const head = value.trim().split(/\s+/)[0];
|
|
1768
|
+
return head ? [{ name: head, path: basePath }] : [];
|
|
1769
|
+
}
|
|
1770
|
+
return fieldRefsFrom(value, basePath);
|
|
1771
|
+
}
|
|
1772
|
+
var COMPONENT_FIELD_SPECS = {
|
|
1773
|
+
"record:highlights": { props: ["fields"] },
|
|
1774
|
+
// `sections`/`hideFields` are not in RecordDetailsProps, but every real page
|
|
1775
|
+
// authors them (they survive because `properties` is unvalidated).
|
|
1776
|
+
"record:details": { props: ["fields", "hideFields"], nestedSections: ["sections"] },
|
|
1777
|
+
"record:path": { props: ["statusField"] },
|
|
1778
|
+
"element:number": { props: ["field"] },
|
|
1779
|
+
"element:filter": { props: ["fields"] },
|
|
1780
|
+
"element:form": { props: ["fields"] },
|
|
1781
|
+
// The schema says `displayField`; real pages author `labelField`. Accept both.
|
|
1782
|
+
"element:record_picker": { props: ["displayField", "labelField", "searchFields"] }
|
|
1783
|
+
};
|
|
1784
|
+
var RELATED_LIST_TYPE = "record:related_list";
|
|
1785
|
+
function componentFieldRefs(type, props, basePath, sep = ".") {
|
|
1786
|
+
const spec = COMPONENT_FIELD_SPECS[type];
|
|
1787
|
+
if (!spec) return null;
|
|
1788
|
+
const refs = [];
|
|
1789
|
+
for (const key of spec.props ?? []) {
|
|
1790
|
+
refs.push(...fieldRefsFrom(props[key], `${basePath}${sep}${key}`));
|
|
1791
|
+
}
|
|
1792
|
+
for (const key of spec.nestedSections ?? []) {
|
|
1793
|
+
const sections = Array.isArray(props[key]) ? props[key] : [];
|
|
1794
|
+
for (let si = 0; si < sections.length; si++) {
|
|
1795
|
+
const section = sections[si];
|
|
1796
|
+
if (!isRec4(section)) continue;
|
|
1797
|
+
refs.push(...fieldRefsFrom(section.fields, `${basePath}${sep}${key}[${si}].fields`));
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
return refs;
|
|
1801
|
+
}
|
|
1802
|
+
function relatedListFieldRefs(props, basePath, sep = ".") {
|
|
1803
|
+
const add = isRec4(props.add) ? props.add : void 0;
|
|
1804
|
+
const picker = add && isRec4(add.picker) ? add.picker : void 0;
|
|
1805
|
+
const at = (key) => `${basePath}${sep}${key}`;
|
|
1806
|
+
return {
|
|
1807
|
+
relatedObject: strName4(props.objectName),
|
|
1808
|
+
related: [
|
|
1809
|
+
...fieldRefsFrom(props.columns, at("columns")),
|
|
1810
|
+
...sortFieldRefs(props.sort, at("sort")),
|
|
1811
|
+
...fieldRefsFrom(props.filter, at("filter")),
|
|
1812
|
+
...fieldRefsFrom(props.relationshipField, at("relationshipField")),
|
|
1813
|
+
...add ? fieldRefsFrom(add.linkField, at("add.linkField")) : []
|
|
1814
|
+
],
|
|
1815
|
+
parent: fieldRefsFrom(props.relationshipValueField, at("relationshipValueField")),
|
|
1816
|
+
pickerObject: picker ? strName4(picker.object) : void 0,
|
|
1817
|
+
picker: picker ? [
|
|
1818
|
+
...fieldRefsFrom(picker.valueField, at("add.picker.valueField")),
|
|
1819
|
+
...fieldRefsFrom(picker.labelField, at("add.picker.labelField"))
|
|
1820
|
+
] : []
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
function indexObjectFields(stack) {
|
|
1824
|
+
const objectFields = /* @__PURE__ */ new Map();
|
|
1825
|
+
if (!isRec4(stack)) return objectFields;
|
|
1826
|
+
for (const obj of asArray11(stack.objects)) {
|
|
1827
|
+
const name = strName4(obj.name);
|
|
1828
|
+
if (!name) continue;
|
|
1829
|
+
const names = /* @__PURE__ */ new Set();
|
|
1830
|
+
for (const f of asArray11(obj.fields)) {
|
|
1831
|
+
const fn = strName4(f.name);
|
|
1832
|
+
if (fn) names.add(fn);
|
|
1833
|
+
}
|
|
1834
|
+
objectFields.set(name, names);
|
|
1835
|
+
}
|
|
1836
|
+
return objectFields;
|
|
1837
|
+
}
|
|
1838
|
+
function checkFieldRefs(refs, objectName, objectFields, where, consequence = "skipped") {
|
|
1839
|
+
const findings = [];
|
|
1840
|
+
if (!objectName) return findings;
|
|
1841
|
+
const known = objectFields.get(objectName);
|
|
1842
|
+
if (!known) return findings;
|
|
1843
|
+
for (const ref of refs) {
|
|
1844
|
+
if (ref.name.includes(".")) continue;
|
|
1845
|
+
if (known.has(ref.name) || SYSTEM_FIELDS.has(ref.name)) continue;
|
|
1846
|
+
findings.push({
|
|
1847
|
+
severity: consequence === "queried" ? "error" : "warning",
|
|
1848
|
+
rule: PAGE_FIELD_UNKNOWN,
|
|
1849
|
+
where,
|
|
1850
|
+
path: ref.path,
|
|
1851
|
+
message: `field "${ref.name}" is not a field on object "${objectName}" \u2014 ` + (consequence === "queried" ? 'it is used in a QUERY, so the predicate can never match: the surface renders an empty result that looks exactly like "there is no data".' : "the component silently skips it, so it never renders."),
|
|
1852
|
+
hint: `Fix the field name, or add "${ref.name}" to ${objectName}. References must match the object's field names exactly.` + (known.size > 0 ? ` Object fields: ${[...known].sort().join(", ")}.` : "")
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
return findings;
|
|
1856
|
+
}
|
|
1857
|
+
function validatePageFieldBindings(stack) {
|
|
1858
|
+
const findings = [];
|
|
1859
|
+
if (!stack || typeof stack !== "object") return findings;
|
|
1860
|
+
const objectFields = indexObjectFields(stack);
|
|
1861
|
+
const pages = asArray11(stack.pages);
|
|
1862
|
+
for (let pi = 0; pi < pages.length; pi++) {
|
|
1863
|
+
const page = pages[pi];
|
|
1864
|
+
if (!page || typeof page !== "object") continue;
|
|
1865
|
+
const pageName = strName4(page.name) ?? `#${pi}`;
|
|
1866
|
+
const checkRefs = (refs, objectName, where) => {
|
|
1867
|
+
findings.push(...checkFieldRefs(refs, objectName, objectFields, where));
|
|
1868
|
+
};
|
|
1869
|
+
for (const { component, path, objectName } of walkPageComponents(page, `pages[${pi}]`)) {
|
|
1870
|
+
const type = strName4(component.type);
|
|
1871
|
+
const props = isRec4(component.properties) ? component.properties : void 0;
|
|
1872
|
+
if (!type || !props) continue;
|
|
1873
|
+
const where = `page "${pageName}" \xB7 ${type}`;
|
|
1874
|
+
const base = `${path}.properties`;
|
|
1875
|
+
if (type === RELATED_LIST_TYPE) {
|
|
1876
|
+
const split = relatedListFieldRefs(props, base);
|
|
1877
|
+
checkRefs(split.related, split.relatedObject, where);
|
|
1878
|
+
checkRefs(split.parent, objectName, where);
|
|
1879
|
+
checkRefs(split.picker, split.pickerObject, where);
|
|
1880
|
+
continue;
|
|
1881
|
+
}
|
|
1882
|
+
const refs = componentFieldRefs(type, props, base);
|
|
1883
|
+
if (!refs) continue;
|
|
1884
|
+
checkRefs(refs, objectName, where);
|
|
1885
|
+
}
|
|
1886
|
+
const cfg = isRec4(page.interfaceConfig) ? page.interfaceConfig : void 0;
|
|
1887
|
+
if (cfg) {
|
|
1888
|
+
const cfgObject = strName4(cfg.source) ?? strName4(page.object);
|
|
1889
|
+
const base = `pages[${pi}].interfaceConfig`;
|
|
1890
|
+
const refs = [
|
|
1891
|
+
...fieldRefsFrom(cfg.columns, `${base}.columns`),
|
|
1892
|
+
...sortFieldRefs(cfg.sort, `${base}.sort`),
|
|
1893
|
+
...fieldRefsFrom(cfg.filterBy, `${base}.filterBy`)
|
|
1894
|
+
];
|
|
1895
|
+
const userFilters = isRec4(cfg.userFilters) ? cfg.userFilters : void 0;
|
|
1896
|
+
if (userFilters) {
|
|
1897
|
+
refs.push(...fieldRefsFrom(userFilters.fields, `${base}.userFilters.fields`));
|
|
1898
|
+
}
|
|
1899
|
+
checkRefs(refs, cfgObject, `page "${pageName}" \xB7 interfaceConfig`);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
return findings;
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
// src/validate-react-page-props.ts
|
|
1906
|
+
var cachedTs = null;
|
|
1907
|
+
function loadTypeScript() {
|
|
1908
|
+
if (cachedTs) return cachedTs;
|
|
1909
|
+
const anchor = typeof import.meta !== "undefined" && import.meta.url ? import.meta.url : typeof __filename !== "undefined" ? __filename : process.cwd() + "/";
|
|
1910
|
+
try {
|
|
1911
|
+
cachedTs = createRequire2(anchor)("typescript");
|
|
1912
|
+
} catch (err) {
|
|
1913
|
+
throw new Error(
|
|
1914
|
+
`@objectstack/lint: validating a kind:'react' page requires the "typescript" package, which could not be loaded (${err instanceof Error ? err.message : String(err)}). It is a declared dependency of @objectstack/lint \u2014 if this deployment prunes packages, keep "typescript" in the image; it is only loaded when a react-source page is validated.`
|
|
1915
|
+
);
|
|
1916
|
+
}
|
|
1917
|
+
return cachedTs;
|
|
1918
|
+
}
|
|
1919
|
+
var asArray12 = (v) => Array.isArray(v) ? v : [];
|
|
1920
|
+
var BLOCKS = new Map(
|
|
1921
|
+
REACT_BLOCKS.map((b) => [
|
|
1922
|
+
b.tag,
|
|
1923
|
+
{
|
|
1924
|
+
requiredBindings: b.interactions.filter((i) => i.required).map((i) => i.name),
|
|
1925
|
+
knownProps: new Set(b.interactions.map((i) => i.name))
|
|
1926
|
+
}
|
|
1927
|
+
])
|
|
1928
|
+
);
|
|
1929
|
+
function editDistance(a, b, cap = 2) {
|
|
1930
|
+
if (Math.abs(a.length - b.length) > cap) return cap + 1;
|
|
1931
|
+
const dp = Array.from({ length: a.length + 1 }, (_, i) => i);
|
|
1932
|
+
for (let j = 1; j <= b.length; j++) {
|
|
1933
|
+
let prev = dp[0];
|
|
1934
|
+
dp[0] = j;
|
|
1935
|
+
for (let i = 1; i <= a.length; i++) {
|
|
1936
|
+
const tmp = dp[i];
|
|
1937
|
+
dp[i] = Math.min(dp[i] + 1, dp[i - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
1938
|
+
prev = tmp;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
return dp[a.length];
|
|
1942
|
+
}
|
|
1943
|
+
function nearestKnown(prop, known) {
|
|
1944
|
+
if (known.has(prop)) return null;
|
|
1945
|
+
let best = null;
|
|
1946
|
+
let bestD = 3;
|
|
1947
|
+
for (const k of known) {
|
|
1948
|
+
const d = editDistance(prop, k);
|
|
1949
|
+
if (d < bestD) {
|
|
1950
|
+
bestD = d;
|
|
1951
|
+
best = k;
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
return bestD <= 2 ? best : null;
|
|
1955
|
+
}
|
|
1956
|
+
var NOT_STATIC = /* @__PURE__ */ Symbol("not-static");
|
|
1957
|
+
function staticValue(tsc, sf, node) {
|
|
1958
|
+
if (!node) return NOT_STATIC;
|
|
1959
|
+
if (tsc.isParenthesizedExpression(node)) return staticValue(tsc, sf, node.expression);
|
|
1960
|
+
if (tsc.isStringLiteral(node) || tsc.isNoSubstitutionTemplateLiteral(node)) return node.text;
|
|
1961
|
+
if (tsc.isNumericLiteral(node)) return Number(node.text);
|
|
1962
|
+
if (node.kind === tsc.SyntaxKind.TrueKeyword) return true;
|
|
1963
|
+
if (node.kind === tsc.SyntaxKind.FalseKeyword) return false;
|
|
1964
|
+
if (node.kind === tsc.SyntaxKind.NullKeyword) return null;
|
|
1965
|
+
if (tsc.isArrayLiteralExpression(node)) {
|
|
1966
|
+
const out = [];
|
|
1967
|
+
for (const el of node.elements) {
|
|
1968
|
+
const v = staticValue(tsc, sf, el);
|
|
1969
|
+
if (v === NOT_STATIC) return NOT_STATIC;
|
|
1970
|
+
out.push(v);
|
|
1971
|
+
}
|
|
1972
|
+
return out;
|
|
1973
|
+
}
|
|
1974
|
+
if (tsc.isObjectLiteralExpression(node)) {
|
|
1975
|
+
const out = {};
|
|
1976
|
+
for (const p of node.properties) {
|
|
1977
|
+
if (!tsc.isPropertyAssignment(p)) return NOT_STATIC;
|
|
1978
|
+
const key = tsc.isIdentifier(p.name) || tsc.isStringLiteral(p.name) ? p.name.text : null;
|
|
1979
|
+
if (key === null) return NOT_STATIC;
|
|
1980
|
+
const v = staticValue(tsc, sf, p.initializer);
|
|
1981
|
+
if (v === NOT_STATIC) return NOT_STATIC;
|
|
1982
|
+
out[key] = v;
|
|
1983
|
+
}
|
|
1984
|
+
return out;
|
|
1985
|
+
}
|
|
1986
|
+
return NOT_STATIC;
|
|
1987
|
+
}
|
|
1988
|
+
function attrValue(tsc, sf, attr) {
|
|
1989
|
+
const init = attr.initializer;
|
|
1990
|
+
if (!init) return true;
|
|
1991
|
+
if (tsc.isStringLiteral(init)) return init.text;
|
|
1992
|
+
if (tsc.isJsxExpression(init)) return staticValue(tsc, sf, init.expression);
|
|
1993
|
+
return NOT_STATIC;
|
|
1994
|
+
}
|
|
1995
|
+
function filterAttrValue(tsc, sf, attr) {
|
|
1996
|
+
const init = attr.initializer;
|
|
1997
|
+
if (!init || !tsc.isJsxExpression(init)) return NOT_STATIC;
|
|
1998
|
+
const perPosition = (node) => {
|
|
1999
|
+
if (!node) return NOT_STATIC;
|
|
2000
|
+
if (tsc.isParenthesizedExpression(node)) return perPosition(node.expression);
|
|
2001
|
+
if (tsc.isArrayLiteralExpression(node)) return node.elements.map((el) => perPosition(el));
|
|
2002
|
+
return staticValue(tsc, sf, node);
|
|
2003
|
+
};
|
|
2004
|
+
return perPosition(init.expression);
|
|
2005
|
+
}
|
|
2006
|
+
var REACT_CHART_FIELD_UNKNOWN = "react-chart-field-unknown";
|
|
2007
|
+
var REACT_CHART_AGGREGATE_INVALID = "react-chart-aggregate-invalid";
|
|
2008
|
+
var REACT_CHART_AXIS_UNKNOWN = "react-chart-axis-unknown";
|
|
2009
|
+
var CHART_FUNCTIONS = ["count", "sum", "avg", "min", "max"];
|
|
2010
|
+
var isRec5 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
2011
|
+
var strOf = (v) => typeof v === "string" && v.length > 0 ? v : void 0;
|
|
2012
|
+
function checkObjectChart(attrs, objectFields, findings) {
|
|
2013
|
+
const { values, where, path } = attrs;
|
|
2014
|
+
const push = (severity, rule, message, hint) => findings.push({ severity, rule, where, path, message, hint });
|
|
2015
|
+
if (values.has("data")) return;
|
|
2016
|
+
const aggregate = values.get("aggregate");
|
|
2017
|
+
if (aggregate === void 0 || aggregate === NOT_STATIC) return;
|
|
2018
|
+
if (!isRec5(aggregate)) return;
|
|
2019
|
+
const fn = strOf(aggregate.function);
|
|
2020
|
+
const field = strOf(aggregate.field);
|
|
2021
|
+
const groupBy = aggregate.groupBy;
|
|
2022
|
+
const groupByField = strOf(groupBy) ?? (isRec5(groupBy) ? strOf(groupBy.field) : void 0);
|
|
2023
|
+
if (fn && !CHART_FUNCTIONS.includes(fn)) {
|
|
2024
|
+
push(
|
|
2025
|
+
"error",
|
|
2026
|
+
REACT_CHART_AGGREGATE_INVALID,
|
|
2027
|
+
`aggregate.function "${fn}" is not an aggregation this chart can run.`,
|
|
2028
|
+
`Use one of: ${CHART_FUNCTIONS.join(", ")}.`
|
|
2029
|
+
);
|
|
2030
|
+
} else if (fn && fn !== "count" && !field) {
|
|
2031
|
+
push(
|
|
2032
|
+
"error",
|
|
2033
|
+
REACT_CHART_AGGREGATE_INVALID,
|
|
2034
|
+
`aggregate.function "${fn}" has no "field" to aggregate.`,
|
|
2035
|
+
'Add aggregate.field, or use function "count" (the only one that may omit it).'
|
|
2036
|
+
);
|
|
2037
|
+
}
|
|
2038
|
+
const objectName = strOf(values.get("objectName"));
|
|
2039
|
+
const known = objectName ? objectFields.get(objectName) : void 0;
|
|
2040
|
+
if (objectName && known) {
|
|
2041
|
+
const fieldRef = (name, prop) => {
|
|
2042
|
+
if (!name) return;
|
|
2043
|
+
if (name.includes(".")) return;
|
|
2044
|
+
if (known.has(name) || SYSTEM_FIELDS.has(name)) return;
|
|
2045
|
+
push(
|
|
2046
|
+
"error",
|
|
2047
|
+
REACT_CHART_FIELD_UNKNOWN,
|
|
2048
|
+
`aggregate.${prop} "${name}" is not a field on object "${objectName}" \u2014 the aggregate query has nothing to ${prop === "groupBy" ? "group by" : "aggregate"}, so the chart comes back empty.`,
|
|
2049
|
+
`Fix the field name, or add "${name}" to ${objectName}.` + (known.size > 0 ? ` Object fields: ${[...known].sort().join(", ")}.` : "")
|
|
2050
|
+
);
|
|
2051
|
+
};
|
|
2052
|
+
fieldRef(field, "field");
|
|
2053
|
+
fieldRef(groupByField, "groupBy");
|
|
2054
|
+
}
|
|
2055
|
+
const keys = chartAggregateResultKeys({ field, function: fn, groupBy });
|
|
2056
|
+
const columns = [keys.category, keys.value].filter((k) => !!k);
|
|
2057
|
+
if (columns.length === 0) return;
|
|
2058
|
+
const axisRef = (name, prop) => {
|
|
2059
|
+
if (!name) return;
|
|
2060
|
+
if (columns.includes(name)) return;
|
|
2061
|
+
if (keys.comparison && name === keys.comparison) return;
|
|
2062
|
+
push(
|
|
2063
|
+
"error",
|
|
2064
|
+
REACT_CHART_AXIS_UNKNOWN,
|
|
2065
|
+
`"${name}" is not a column this aggregate returns, so the axis plots nothing. Object-bound aggregate rows are keyed by the RAW FIELD NAMES (unlike a dataset, whose rows are keyed by measure name).`,
|
|
2066
|
+
`Result columns: ${columns.join(", ")}` + (keys.comparison ? ` (plus "${keys.comparison}" with a comparison overlay)` : "") + `. Bind ${prop} to one of them.`
|
|
2067
|
+
);
|
|
2068
|
+
};
|
|
2069
|
+
const xAxisRaw = values.get("xAxis");
|
|
2070
|
+
const categoryAxis = strOf(values.get("xAxisKey")) ?? strOf(xAxisRaw) ?? (isRec5(xAxisRaw) ? strOf(xAxisRaw.field) : void 0);
|
|
2071
|
+
const categoryProp = values.has("xAxisKey") ? "xAxisKey" : "xAxis.field";
|
|
2072
|
+
axisRef(categoryAxis, categoryProp);
|
|
2073
|
+
const yAxisRaw = values.get("yAxis");
|
|
2074
|
+
const yAxisList = Array.isArray(yAxisRaw) ? yAxisRaw : yAxisRaw !== void 0 ? [yAxisRaw] : [];
|
|
2075
|
+
for (const a of yAxisList) {
|
|
2076
|
+
axisRef(strOf(a) ?? (isRec5(a) ? strOf(a.field) : void 0), "yAxis[].field");
|
|
2077
|
+
}
|
|
2078
|
+
const series = values.get("series");
|
|
2079
|
+
if (Array.isArray(series)) {
|
|
2080
|
+
for (const s of series) {
|
|
2081
|
+
if (!isRec5(s)) continue;
|
|
2082
|
+
const dataKey = strOf(s.dataKey);
|
|
2083
|
+
axisRef(dataKey ?? strOf(s.name), dataKey ? "series[].dataKey" : "series[].name");
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
if (categoryAxis && keys.category && categoryAxis !== keys.category && categoryAxis === keys.value) {
|
|
2087
|
+
push(
|
|
2088
|
+
"error",
|
|
2089
|
+
REACT_CHART_AXIS_UNKNOWN,
|
|
2090
|
+
`${categoryProp} "${categoryAxis}" is the aggregate's VALUE column, not its category column.`,
|
|
2091
|
+
`The category axis is keyed by groupBy \u2014 bind it to "${keys.category}".`
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
var REACT_FIELD_SPECS = {
|
|
2096
|
+
ListView: {
|
|
2097
|
+
// `fields` is the React overlay's "limit/order the columns"; `columns` the
|
|
2098
|
+
// spec ListView prop. Both name columns on the bound object, and a page may
|
|
2099
|
+
// write either. `hiddenFields`/`fieldOrder`/`filterableFields` are schema
|
|
2100
|
+
// props outside the curated contract — unadvertised but honored by the
|
|
2101
|
+
// renderer, so a stale name there is drift just the same.
|
|
2102
|
+
fields: ["fields", "columns", "hiddenFields", "fieldOrder", "filterableFields"],
|
|
2103
|
+
sorts: ["sort"],
|
|
2104
|
+
nestedFields: ["userFilters", "grouping"],
|
|
2105
|
+
filterArrays: ["filters"]
|
|
2106
|
+
},
|
|
2107
|
+
ObjectForm: {
|
|
2108
|
+
fields: ["fields"],
|
|
2109
|
+
keyedByField: ["initialValues"],
|
|
2110
|
+
// `groups` is FormViewSchema's legacy alias for `sections`.
|
|
2111
|
+
sections: ["sections", "groups"]
|
|
2112
|
+
},
|
|
2113
|
+
ObjectChart: {
|
|
2114
|
+
// The axes are result columns (checkObjectChart owns them); `filter` is an
|
|
2115
|
+
// ordinary ObjectQL predicate over the bound object, like ListView's.
|
|
2116
|
+
filterArrays: ["filter"]
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
var PATH_SEP = " \u203A ";
|
|
2120
|
+
var SCHEMA_TYPE_BY_TAG = new Map(
|
|
2121
|
+
REACT_BLOCKS.map((b) => [b.tag, b.schemaType])
|
|
2122
|
+
);
|
|
2123
|
+
var FILTER_PROPS = new Set(
|
|
2124
|
+
Object.values(REACT_FIELD_SPECS).flatMap((s) => s.filterArrays ?? [])
|
|
2125
|
+
);
|
|
2126
|
+
function readableProps(values) {
|
|
2127
|
+
const out = {};
|
|
2128
|
+
for (const [k, v] of values) if (v !== NOT_STATIC) out[k] = v;
|
|
2129
|
+
return out;
|
|
2130
|
+
}
|
|
2131
|
+
function subformFieldRefs(value, basePath) {
|
|
2132
|
+
const child = [];
|
|
2133
|
+
const parent = [];
|
|
2134
|
+
if (!Array.isArray(value)) return { child, parent };
|
|
2135
|
+
for (let i = 0; i < value.length; i++) {
|
|
2136
|
+
const sub = value[i];
|
|
2137
|
+
if (!isRec5(sub)) continue;
|
|
2138
|
+
const at = (key) => `${basePath}[${i}].${key}`;
|
|
2139
|
+
child.push({
|
|
2140
|
+
objectName: strOf(sub.childObject),
|
|
2141
|
+
refs: [
|
|
2142
|
+
...fieldRefsFrom(sub.columns, at("columns")),
|
|
2143
|
+
...fieldRefsFrom(sub.relationshipField, at("relationshipField")),
|
|
2144
|
+
...fieldRefsFrom(sub.amountField, at("amountField"))
|
|
2145
|
+
]
|
|
2146
|
+
});
|
|
2147
|
+
parent.push(...fieldRefsFrom(sub.totalField, at("totalField")));
|
|
2148
|
+
}
|
|
2149
|
+
return { child, parent };
|
|
2150
|
+
}
|
|
2151
|
+
function filterFieldRefs(node, basePath, out) {
|
|
2152
|
+
if (!Array.isArray(node) || node.length === 0) return;
|
|
2153
|
+
const head = node[0];
|
|
2154
|
+
if (typeof head === "string" && (head.toLowerCase() === "and" || head.toLowerCase() === "or")) {
|
|
2155
|
+
for (let i = 1; i < node.length; i++) filterFieldRefs(node[i], `${basePath}[${i}]`, out);
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
if (Array.isArray(head)) {
|
|
2159
|
+
for (let i = 0; i < node.length; i++) filterFieldRefs(node[i], `${basePath}[${i}]`, out);
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2162
|
+
if (typeof head === "string" && head.length > 0 && node.length >= 2 && typeof node[1] === "string" && VALID_AST_OPERATORS.has(node[1].toLowerCase())) {
|
|
2163
|
+
out.push({ name: head, path: `${basePath}[0]` });
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
function reactFieldRefs(spec, values, basePath) {
|
|
2167
|
+
const own = [];
|
|
2168
|
+
const queried = [];
|
|
2169
|
+
const readable = (key) => {
|
|
2170
|
+
const v = values.get(key);
|
|
2171
|
+
return v === NOT_STATIC ? void 0 : v;
|
|
2172
|
+
};
|
|
2173
|
+
const at = (key) => `${basePath}${PATH_SEP}${key}`;
|
|
2174
|
+
for (const key of spec.fields ?? []) {
|
|
2175
|
+
own.push(...fieldRefsFrom(readable(key), at(key)));
|
|
2176
|
+
}
|
|
2177
|
+
for (const key of spec.sorts ?? []) {
|
|
2178
|
+
own.push(...sortFieldRefs(readable(key), at(key)));
|
|
2179
|
+
}
|
|
2180
|
+
for (const key of spec.nestedFields ?? []) {
|
|
2181
|
+
const v = readable(key);
|
|
2182
|
+
if (isRec5(v)) own.push(...fieldRefsFrom(v.fields, at(`${key}.fields`)));
|
|
2183
|
+
}
|
|
2184
|
+
for (const key of spec.sections ?? []) {
|
|
2185
|
+
const v = readable(key);
|
|
2186
|
+
if (!Array.isArray(v)) continue;
|
|
2187
|
+
for (let i = 0; i < v.length; i++) {
|
|
2188
|
+
const section = v[i];
|
|
2189
|
+
if (!isRec5(section)) continue;
|
|
2190
|
+
own.push(...fieldRefsFrom(section.fields, at(`${key}[${i}].fields`)));
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
for (const key of spec.keyedByField ?? []) {
|
|
2194
|
+
const v = readable(key);
|
|
2195
|
+
if (!isRec5(v)) continue;
|
|
2196
|
+
for (const k of Object.keys(v)) own.push({ name: k, path: at(`${key}.${k}`) });
|
|
2197
|
+
}
|
|
2198
|
+
for (const key of spec.filterArrays ?? []) {
|
|
2199
|
+
filterFieldRefs(values.get(key), at(key), queried);
|
|
2200
|
+
}
|
|
2201
|
+
return { own, queried };
|
|
2202
|
+
}
|
|
2203
|
+
function checkBlockFieldProps(tag, values, objectFields, where, path) {
|
|
2204
|
+
const objectName = strOf(values.get("objectName"));
|
|
2205
|
+
const out = [];
|
|
2206
|
+
const spec = REACT_FIELD_SPECS[tag];
|
|
2207
|
+
if (spec) {
|
|
2208
|
+
const { own, queried } = reactFieldRefs(spec, values, path);
|
|
2209
|
+
out.push(...checkFieldRefs(own, objectName, objectFields, where));
|
|
2210
|
+
out.push(...checkFieldRefs(queried, objectName, objectFields, where, "queried"));
|
|
2211
|
+
}
|
|
2212
|
+
if (tag === "ObjectForm") {
|
|
2213
|
+
const raw = values.get("subforms");
|
|
2214
|
+
const subs = subformFieldRefs(raw === NOT_STATIC ? void 0 : raw, `${path}${PATH_SEP}subforms`);
|
|
2215
|
+
for (const sub of subs.child) {
|
|
2216
|
+
out.push(...checkFieldRefs(sub.refs, sub.objectName, objectFields, where));
|
|
2217
|
+
}
|
|
2218
|
+
out.push(...checkFieldRefs(subs.parent, objectName, objectFields, where));
|
|
2219
|
+
}
|
|
2220
|
+
const schemaType = tag === "Block" ? strOf(values.get("type")) : SCHEMA_TYPE_BY_TAG.get(tag);
|
|
2221
|
+
if (schemaType) {
|
|
2222
|
+
const props = readableProps(values);
|
|
2223
|
+
if (schemaType === RELATED_LIST_TYPE) {
|
|
2224
|
+
const split = relatedListFieldRefs(props, path, PATH_SEP);
|
|
2225
|
+
out.push(...checkFieldRefs(split.related, split.relatedObject, objectFields, where));
|
|
2226
|
+
out.push(...checkFieldRefs(split.picker, split.pickerObject, objectFields, where));
|
|
2227
|
+
} else if (COMPONENT_FIELD_SPECS[schemaType]) {
|
|
2228
|
+
out.push(
|
|
2229
|
+
...checkFieldRefs(
|
|
2230
|
+
componentFieldRefs(schemaType, props, path, PATH_SEP) ?? [],
|
|
2231
|
+
objectName,
|
|
2232
|
+
objectFields,
|
|
2233
|
+
where
|
|
2234
|
+
)
|
|
2235
|
+
);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
return out;
|
|
2239
|
+
}
|
|
2240
|
+
function validateReactPageProps(stack) {
|
|
2241
|
+
const findings = [];
|
|
2242
|
+
const objectFields = indexObjectFields(stack);
|
|
2243
|
+
const searchTargets = indexObjectSearchTargets(stack);
|
|
2244
|
+
const pages = asArray12(stack.pages);
|
|
2245
|
+
for (let p = 0; p < pages.length; p++) {
|
|
2246
|
+
const page = pages[p];
|
|
2247
|
+
if (!page || page.kind !== "react") continue;
|
|
2248
|
+
const source = page.source;
|
|
2249
|
+
if (typeof source !== "string" || source.trim() === "") continue;
|
|
2250
|
+
const name = String(page.name ?? `#${p}`);
|
|
2251
|
+
const tsc = loadTypeScript();
|
|
2252
|
+
let sf;
|
|
2253
|
+
try {
|
|
2254
|
+
sf = tsc.createSourceFile("page.tsx", source, tsc.ScriptTarget.Latest, true, tsc.ScriptKind.TSX);
|
|
2255
|
+
} catch {
|
|
2256
|
+
continue;
|
|
2257
|
+
}
|
|
2258
|
+
const visit = (node) => {
|
|
2259
|
+
if (tsc.isJsxOpeningElement(node) || tsc.isJsxSelfClosingElement(node)) {
|
|
2260
|
+
const tag = node.tagName.getText(sf);
|
|
2261
|
+
const block = BLOCKS.get(tag);
|
|
2262
|
+
if (block) {
|
|
2263
|
+
let hasSpread = false;
|
|
2264
|
+
const used = /* @__PURE__ */ new Set();
|
|
2265
|
+
const values = /* @__PURE__ */ new Map();
|
|
2266
|
+
for (const a of node.attributes.properties) {
|
|
2267
|
+
if (tsc.isJsxSpreadAttribute(a)) {
|
|
2268
|
+
hasSpread = true;
|
|
2269
|
+
continue;
|
|
2270
|
+
}
|
|
2271
|
+
if (tsc.isJsxAttribute(a)) {
|
|
2272
|
+
const propName = a.name.getText(sf);
|
|
2273
|
+
used.add(propName);
|
|
2274
|
+
values.set(
|
|
2275
|
+
propName,
|
|
2276
|
+
FILTER_PROPS.has(propName) ? filterAttrValue(tsc, sf, a) : attrValue(tsc, sf, a)
|
|
2277
|
+
);
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
1144
2280
|
const where = `page "${name}" \u203A <${tag}>`;
|
|
1145
2281
|
const path = `pages[${p}].source`;
|
|
1146
2282
|
if (!hasSpread) {
|
|
@@ -1170,6 +2306,26 @@ function validateReactPageProps(stack) {
|
|
|
1170
2306
|
});
|
|
1171
2307
|
}
|
|
1172
2308
|
}
|
|
2309
|
+
if (tag === "ObjectChart" && !hasSpread) {
|
|
2310
|
+
checkObjectChart({ values, where, path }, objectFields, findings);
|
|
2311
|
+
}
|
|
2312
|
+
if (tag === "ListView" && !hasSpread) {
|
|
2313
|
+
findings.push(
|
|
2314
|
+
...checkSearchableFieldList(
|
|
2315
|
+
values.get("searchableFields"),
|
|
2316
|
+
strOf(values.get("objectName")),
|
|
2317
|
+
searchTargets,
|
|
2318
|
+
where,
|
|
2319
|
+
`${path} \u203A searchableFields`,
|
|
2320
|
+
"searchableFields"
|
|
2321
|
+
)
|
|
2322
|
+
);
|
|
2323
|
+
}
|
|
2324
|
+
if (!hasSpread) {
|
|
2325
|
+
findings.push(
|
|
2326
|
+
...checkBlockFieldProps(tag, values, objectFields, where, path)
|
|
2327
|
+
);
|
|
2328
|
+
}
|
|
1173
2329
|
}
|
|
1174
2330
|
}
|
|
1175
2331
|
tsc.forEachChild(node, visit);
|
|
@@ -1181,11 +2337,11 @@ function validateReactPageProps(stack) {
|
|
|
1181
2337
|
|
|
1182
2338
|
// src/validate-page-source-styling.ts
|
|
1183
2339
|
var PAGE_SOURCE_CLASSNAME = "page-source-className-tailwind";
|
|
1184
|
-
var
|
|
2340
|
+
var asArray13 = (v) => Array.isArray(v) ? v : [];
|
|
1185
2341
|
var CLASSNAME_ATTR = /\bclassName\s*=\s*["'{]/g;
|
|
1186
2342
|
function validatePageSourceStyling(stack) {
|
|
1187
2343
|
const findings = [];
|
|
1188
|
-
const pages =
|
|
2344
|
+
const pages = asArray13(stack.pages);
|
|
1189
2345
|
for (let p = 0; p < pages.length; p++) {
|
|
1190
2346
|
const page = pages[p];
|
|
1191
2347
|
if (!page) continue;
|
|
@@ -1214,7 +2370,7 @@ function validatePageSourceStyling(stack) {
|
|
|
1214
2370
|
import { objectTitleCompleteness } from "@objectstack/spec/data";
|
|
1215
2371
|
var TITLE_FORMAT_RETIRED = "title-format-retired";
|
|
1216
2372
|
var TITLE_UNRESOLVABLE = "title-unresolvable";
|
|
1217
|
-
function
|
|
2373
|
+
function asArray14(v) {
|
|
1218
2374
|
if (Array.isArray(v)) return v;
|
|
1219
2375
|
if (v && typeof v === "object") {
|
|
1220
2376
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
@@ -1223,7 +2379,7 @@ function asArray10(v) {
|
|
|
1223
2379
|
}
|
|
1224
2380
|
function validateRecordTitle(stack) {
|
|
1225
2381
|
const findings = [];
|
|
1226
|
-
const objects =
|
|
2382
|
+
const objects = asArray14(stack.objects);
|
|
1227
2383
|
for (let i = 0; i < objects.length; i++) {
|
|
1228
2384
|
const obj = objects[i];
|
|
1229
2385
|
const objName = typeof obj.name === "string" ? obj.name : `(object ${i})`;
|
|
@@ -1259,7 +2415,7 @@ var FIELD_GROUP_UNDECLARED = "field-group-undeclared";
|
|
|
1259
2415
|
var FIELD_GROUP_EMPTY = "field-group-empty";
|
|
1260
2416
|
var FIELD_GROUP_SHADOWED = "field-group-shadowed";
|
|
1261
2417
|
var SEMANTIC_ROLE_FIELD_UNKNOWN = "semantic-role-field-unknown";
|
|
1262
|
-
function
|
|
2418
|
+
function asArray15(v) {
|
|
1263
2419
|
if (Array.isArray(v)) return v;
|
|
1264
2420
|
if (v && typeof v === "object") {
|
|
1265
2421
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
@@ -1268,7 +2424,7 @@ function asArray11(v) {
|
|
|
1268
2424
|
}
|
|
1269
2425
|
function validateSemanticRoles(stack) {
|
|
1270
2426
|
const findings = [];
|
|
1271
|
-
const objects =
|
|
2427
|
+
const objects = asArray15(stack.objects);
|
|
1272
2428
|
for (let i = 0; i < objects.length; i++) {
|
|
1273
2429
|
const obj = objects[i];
|
|
1274
2430
|
if (!obj || typeof obj !== "object") continue;
|
|
@@ -1363,7 +2519,7 @@ function validateSemanticRoles(stack) {
|
|
|
1363
2519
|
// src/validate-form-layout.ts
|
|
1364
2520
|
var FORM_FIELD_UNKNOWN = "form-field-unknown";
|
|
1365
2521
|
var FORM_COLSPAN_ABSOLUTE = "absolute-colspan-discouraged";
|
|
1366
|
-
function
|
|
2522
|
+
function asArray16(v) {
|
|
1367
2523
|
if (Array.isArray(v)) return v;
|
|
1368
2524
|
if (v && typeof v === "object") {
|
|
1369
2525
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
@@ -1388,13 +2544,13 @@ function boundObject(view) {
|
|
|
1388
2544
|
function validateFormLayout(stack) {
|
|
1389
2545
|
const findings = [];
|
|
1390
2546
|
const objectFields = /* @__PURE__ */ new Map();
|
|
1391
|
-
for (const obj of
|
|
2547
|
+
for (const obj of asArray16(stack.objects)) {
|
|
1392
2548
|
const name = typeof obj.name === "string" ? obj.name : void 0;
|
|
1393
2549
|
if (!name) continue;
|
|
1394
2550
|
const fields = obj.fields && typeof obj.fields === "object" && !Array.isArray(obj.fields) ? Object.keys(obj.fields) : [];
|
|
1395
2551
|
objectFields.set(name, new Set(fields));
|
|
1396
2552
|
}
|
|
1397
|
-
const views =
|
|
2553
|
+
const views = asArray16(stack.views);
|
|
1398
2554
|
for (let i = 0; i < views.length; i++) {
|
|
1399
2555
|
const view = views[i];
|
|
1400
2556
|
if (!view || typeof view !== "object") continue;
|
|
@@ -1444,7 +2600,7 @@ var VISIBILITY_ALIAS_DEPRECATED = "visibility-alias-deprecated";
|
|
|
1444
2600
|
var VISIBILITY_ROOT_MISLAYERED = "visibility-root-mislayered";
|
|
1445
2601
|
var CANONICAL = "visibleWhen";
|
|
1446
2602
|
var ALIASES = ["visibleOn", "visibility"];
|
|
1447
|
-
function
|
|
2603
|
+
function asArray17(v) {
|
|
1448
2604
|
if (Array.isArray(v)) return v;
|
|
1449
2605
|
if (v && typeof v === "object") {
|
|
1450
2606
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
@@ -1506,7 +2662,7 @@ function isFieldObject(entry) {
|
|
|
1506
2662
|
function validateVisibilityPredicates(stack, opts = {}) {
|
|
1507
2663
|
const layer = opts.layer ?? "runtime";
|
|
1508
2664
|
const findings = [];
|
|
1509
|
-
const views =
|
|
2665
|
+
const views = asArray17(stack.views);
|
|
1510
2666
|
for (let i = 0; i < views.length; i++) {
|
|
1511
2667
|
const view = views[i];
|
|
1512
2668
|
if (!view || typeof view !== "object") continue;
|
|
@@ -1529,7 +2685,7 @@ function validateVisibilityPredicates(stack, opts = {}) {
|
|
|
1529
2685
|
}
|
|
1530
2686
|
}
|
|
1531
2687
|
}
|
|
1532
|
-
const pages =
|
|
2688
|
+
const pages = asArray17(stack.pages);
|
|
1533
2689
|
for (let i = 0; i < pages.length; i++) {
|
|
1534
2690
|
const page = pages[i];
|
|
1535
2691
|
if (!page || typeof page !== "object") continue;
|
|
@@ -1553,7 +2709,7 @@ function validateVisibilityPredicates(stack, opts = {}) {
|
|
|
1553
2709
|
// src/validate-capability-references.ts
|
|
1554
2710
|
import { PLATFORM_CAPABILITY_NAMES } from "@objectstack/spec/security";
|
|
1555
2711
|
var CAPABILITY_REFERENCE_UNKNOWN = "capability-reference-unknown";
|
|
1556
|
-
function
|
|
2712
|
+
function asArray18(v) {
|
|
1557
2713
|
if (Array.isArray(v)) return v;
|
|
1558
2714
|
if (v && typeof v === "object") {
|
|
1559
2715
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
@@ -1578,13 +2734,13 @@ function validateCapabilityReferences(stack) {
|
|
|
1578
2734
|
const findings = [];
|
|
1579
2735
|
if (!stack || typeof stack !== "object") return findings;
|
|
1580
2736
|
const known = new Set(PLATFORM_CAPABILITY_NAMES);
|
|
1581
|
-
for (const cap of
|
|
2737
|
+
for (const cap of asArray18(stack.capabilities)) {
|
|
1582
2738
|
if (typeof cap.name === "string" && cap.name.length > 0) known.add(cap.name);
|
|
1583
2739
|
}
|
|
1584
|
-
for (const ps of
|
|
2740
|
+
for (const ps of asArray18(stack.permissions)) {
|
|
1585
2741
|
for (const cap of asCapArray(ps.systemPermissions)) known.add(cap);
|
|
1586
2742
|
}
|
|
1587
|
-
for (const seed of
|
|
2743
|
+
for (const seed of asArray18(stack.data)) {
|
|
1588
2744
|
if (seed.object !== "sys_capability") continue;
|
|
1589
2745
|
for (const rec of Array.isArray(seed.records) ? seed.records : []) {
|
|
1590
2746
|
const name = rec?.name;
|
|
@@ -1603,7 +2759,7 @@ function validateCapabilityReferences(stack) {
|
|
|
1603
2759
|
hint
|
|
1604
2760
|
});
|
|
1605
2761
|
};
|
|
1606
|
-
const objects =
|
|
2762
|
+
const objects = asArray18(stack.objects);
|
|
1607
2763
|
for (let i = 0; i < objects.length; i++) {
|
|
1608
2764
|
const obj = objects[i];
|
|
1609
2765
|
if (!obj || typeof obj !== "object") continue;
|
|
@@ -1612,27 +2768,27 @@ function validateCapabilityReferences(stack) {
|
|
|
1612
2768
|
for (const { cap, key } of flattenObjectRequired(obj.requiredPermissions)) {
|
|
1613
2769
|
flag(cap, `object "${objName}"`, `${objPath}.requiredPermissions${key ? `.${key}` : ""}`);
|
|
1614
2770
|
}
|
|
1615
|
-
const fields =
|
|
2771
|
+
const fields = asArray18(obj.fields);
|
|
1616
2772
|
for (const f of fields) {
|
|
1617
2773
|
const fname = typeof f.name === "string" ? f.name : "(field)";
|
|
1618
2774
|
for (const cap of asCapArray(f.requiredPermissions)) {
|
|
1619
2775
|
flag(cap, `field "${objName}.${fname}"`, `${objPath}.fields.${fname}.requiredPermissions`);
|
|
1620
2776
|
}
|
|
1621
2777
|
}
|
|
1622
|
-
for (const [ai, action] of
|
|
2778
|
+
for (const [ai, action] of asArray18(obj.actions).entries()) {
|
|
1623
2779
|
const aName = typeof action.name === "string" ? action.name : `(action ${ai})`;
|
|
1624
2780
|
for (const cap of asCapArray(action.requiredPermissions)) {
|
|
1625
2781
|
flag(cap, `action "${objName}.${aName}"`, `${objPath}.actions[${ai}].requiredPermissions`);
|
|
1626
2782
|
}
|
|
1627
2783
|
}
|
|
1628
2784
|
}
|
|
1629
|
-
for (const [i, action] of
|
|
2785
|
+
for (const [i, action] of asArray18(stack.actions).entries()) {
|
|
1630
2786
|
const aName = typeof action.name === "string" ? action.name : `(action ${i})`;
|
|
1631
2787
|
for (const cap of asCapArray(action.requiredPermissions)) {
|
|
1632
2788
|
flag(cap, `action "${aName}"`, `actions[${i}].requiredPermissions`);
|
|
1633
2789
|
}
|
|
1634
2790
|
}
|
|
1635
|
-
const apps =
|
|
2791
|
+
const apps = asArray18(stack.apps);
|
|
1636
2792
|
for (let i = 0; i < apps.length; i++) {
|
|
1637
2793
|
const app = apps[i];
|
|
1638
2794
|
if (!app || typeof app !== "object") continue;
|
|
@@ -1663,18 +2819,33 @@ import {
|
|
|
1663
2819
|
ApproverType,
|
|
1664
2820
|
APPROVAL_NODE_TYPE,
|
|
1665
2821
|
DEPRECATED_APPROVER_TYPES,
|
|
1666
|
-
|
|
2822
|
+
APPROVER_VALUE_BINDINGS,
|
|
2823
|
+
approverTypeIsOrgScoped,
|
|
2824
|
+
canonicalApproverType,
|
|
2825
|
+
normalizeDecisionOutputs
|
|
1667
2826
|
} from "@objectstack/spec/automation";
|
|
2827
|
+
import { BUILTIN_MEMBERSHIP_ROLES } from "@objectstack/spec";
|
|
2828
|
+
import { collectCelRootIdentifiers } from "@objectstack/formula";
|
|
1668
2829
|
var APPROVAL_APPROVER_NOT_MEMBERSHIP_TIER = "approval-approver-not-membership-tier";
|
|
1669
2830
|
var APPROVAL_APPROVER_TYPE_DEPRECATED = "approval-approver-type-deprecated";
|
|
1670
2831
|
var APPROVAL_APPROVER_TYPE_UNKNOWN = "approval-approver-type-unknown";
|
|
2832
|
+
var APPROVAL_APPROVER_TYPE_UNSUPPORTED = "approval-approver-type-unsupported";
|
|
1671
2833
|
var APPROVAL_ESCALATION_REASSIGN_NO_TARGET = "approval-escalation-reassign-no-target";
|
|
1672
|
-
var
|
|
2834
|
+
var APPROVAL_APPROVERS_MAY_RESOLVE_EMPTY = "approval-approvers-may-resolve-empty";
|
|
2835
|
+
var APPROVAL_EXPRESSION_INVALID = "approval-expression-invalid";
|
|
2836
|
+
var APPROVAL_EXPRESSION_NO_EMPTY_POLICY = "approval-expression-no-empty-policy";
|
|
2837
|
+
var APPROVAL_DECISION_OUTPUTS_RESERVED = "approval-decision-outputs-reserved";
|
|
2838
|
+
var APPROVAL_APPROVER_CROSS_ORG_UNSUPPORTED = "approval-approver-cross-org-unsupported";
|
|
2839
|
+
var EXPRESSION_ROOTS = /* @__PURE__ */ new Set(["current", "trigger", "vars"]);
|
|
2840
|
+
var RESERVED_OUTPUT_KEYS = /* @__PURE__ */ new Set(["decision", "requestId"]);
|
|
2841
|
+
var GROUP_ROUTED_TYPES = /* @__PURE__ */ new Set(["position", "team", "department"]);
|
|
2842
|
+
var MEMBERSHIP_TIERS = new Set(BUILTIN_MEMBERSHIP_ROLES);
|
|
2843
|
+
var MEMBERSHIP_TIER_LIST = BUILTIN_MEMBERSHIP_ROLES.join("/");
|
|
1673
2844
|
var TYPE_FIX = {
|
|
1674
2845
|
business_unit: "department",
|
|
1675
2846
|
bu: "department"
|
|
1676
2847
|
};
|
|
1677
|
-
function
|
|
2848
|
+
function asArray19(v) {
|
|
1678
2849
|
if (Array.isArray(v)) return v;
|
|
1679
2850
|
if (v && typeof v === "object") {
|
|
1680
2851
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
@@ -1684,15 +2855,15 @@ function asArray15(v) {
|
|
|
1684
2855
|
function validateApprovalApprovers(stack) {
|
|
1685
2856
|
const findings = [];
|
|
1686
2857
|
if (!stack || typeof stack !== "object") return findings;
|
|
1687
|
-
const flows =
|
|
2858
|
+
const flows = asArray19(stack.flows);
|
|
1688
2859
|
const validTypes = new Set(ApproverType.options);
|
|
1689
2860
|
for (let fi = 0; fi < flows.length; fi++) {
|
|
1690
2861
|
const flow = flows[fi];
|
|
1691
2862
|
if (!flow || typeof flow !== "object") continue;
|
|
1692
2863
|
const flowName = typeof flow.name === "string" ? flow.name : `(flow ${fi})`;
|
|
1693
|
-
const
|
|
1694
|
-
for (let ni = 0; ni <
|
|
1695
|
-
const node =
|
|
2864
|
+
const walked = walkFlowNodes(flow, `flows[${fi}]`);
|
|
2865
|
+
for (let ni = 0; ni < walked.length; ni++) {
|
|
2866
|
+
const { node, path: nodePath } = walked[ni];
|
|
1696
2867
|
if (!node || node.type !== APPROVAL_NODE_TYPE) continue;
|
|
1697
2868
|
const nodeId = typeof node.id === "string" ? node.id : `(node ${ni})`;
|
|
1698
2869
|
const cfg = node.config ?? {};
|
|
@@ -1703,7 +2874,7 @@ function validateApprovalApprovers(stack) {
|
|
|
1703
2874
|
if (!a || typeof a !== "object") continue;
|
|
1704
2875
|
const type = typeof a.type === "string" ? a.type : "";
|
|
1705
2876
|
const value = typeof a.value === "string" ? a.value : "";
|
|
1706
|
-
const path =
|
|
2877
|
+
const path = `${nodePath}.config.approvers[${ai}]`;
|
|
1707
2878
|
if (type && !validTypes.has(type)) {
|
|
1708
2879
|
const fix = TYPE_FIX[type];
|
|
1709
2880
|
findings.push({
|
|
@@ -1717,14 +2888,61 @@ function validateApprovalApprovers(stack) {
|
|
|
1717
2888
|
continue;
|
|
1718
2889
|
}
|
|
1719
2890
|
const canonical = canonicalApproverType(type);
|
|
2891
|
+
if (canonical === "expression") {
|
|
2892
|
+
const source = value.trim();
|
|
2893
|
+
if (!source) {
|
|
2894
|
+
findings.push({
|
|
2895
|
+
severity: "error",
|
|
2896
|
+
rule: APPROVAL_EXPRESSION_INVALID,
|
|
2897
|
+
where,
|
|
2898
|
+
path: `${path}.value`,
|
|
2899
|
+
message: `expression approver has an empty expression \u2014 the node fails at entry.`,
|
|
2900
|
+
hint: `Write a CEL expression over current.* (the record's live state at node entry), trigger.* (the submit-time snapshot) or vars.* (flow variables), e.g. current.approvers_dynamic or vars.approval_lead.picked_departments.`
|
|
2901
|
+
});
|
|
2902
|
+
} else {
|
|
2903
|
+
const parsed = collectCelRootIdentifiers(source);
|
|
2904
|
+
if (!parsed.ok) {
|
|
2905
|
+
findings.push({
|
|
2906
|
+
severity: "error",
|
|
2907
|
+
rule: APPROVAL_EXPRESSION_INVALID,
|
|
2908
|
+
where,
|
|
2909
|
+
path: `${path}.value`,
|
|
2910
|
+
message: `expression approver does not parse as CEL: ${parsed.error}.`,
|
|
2911
|
+
hint: `Approver expressions are bare CEL (no {\u2026} template braces), e.g. current.approvers_dynamic or vars.get_reviewers.record.owner_id.`
|
|
2912
|
+
});
|
|
2913
|
+
} else {
|
|
2914
|
+
const illegal = parsed.roots.filter((r) => !EXPRESSION_ROOTS.has(r));
|
|
2915
|
+
if (illegal.length) {
|
|
2916
|
+
const wantsRecord = illegal.includes("record") || illegal.includes("previous");
|
|
2917
|
+
findings.push({
|
|
2918
|
+
severity: "error",
|
|
2919
|
+
rule: APPROVAL_EXPRESSION_INVALID,
|
|
2920
|
+
where,
|
|
2921
|
+
path: `${path}.value`,
|
|
2922
|
+
message: `expression approver references \`${illegal.join("`, `")}\` \u2014 only current.*, trigger.* and vars.* are available, and the node fails at entry on any other root.`,
|
|
2923
|
+
hint: wantsRecord ? `\`record\`/\`previous\` are not bound here (on this platform \`record\` always means "the record at event time", which is ambiguous at an approval node). Write current.<field> for the live value at node entry, trigger.<field> for the submit-time snapshot (vars.previous carries the pre-update row).` : `Did you mean current.<field> (live record), trigger.<field> (submit snapshot), or vars.<name> (flow variable)?`
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
} else if (a.resolveAs != null) {
|
|
2929
|
+
findings.push({
|
|
2930
|
+
severity: "info",
|
|
2931
|
+
rule: APPROVAL_EXPRESSION_INVALID,
|
|
2932
|
+
where,
|
|
2933
|
+
path: `${path}.resolveAs`,
|
|
2934
|
+
message: `resolveAs has no effect on a '${type}' approver \u2014 it only applies to type 'expression'.`,
|
|
2935
|
+
hint: `Remove it, or switch this approver to { type: 'expression', value: '<CEL>', resolveAs: '${String(a.resolveAs)}' }.`
|
|
2936
|
+
});
|
|
2937
|
+
}
|
|
1720
2938
|
if (canonical === "org_membership_level" && value && !MEMBERSHIP_TIERS.has(value.toLowerCase())) {
|
|
1721
2939
|
findings.push({
|
|
1722
2940
|
severity: "warning",
|
|
1723
2941
|
rule: APPROVAL_APPROVER_NOT_MEMBERSHIP_TIER,
|
|
1724
2942
|
where,
|
|
1725
2943
|
path: `${path}.value`,
|
|
1726
|
-
message: `approver { type: '${type}', value: '${value}' } resolves against the better-auth org-membership tier (sys_member.role:
|
|
1727
|
-
hint: `If '${value}' is an org position, author { type: 'position', value: '${value}' } (resolved via sys_user_position, ADR-0090 D3). Keep type 'org_membership_level' only for membership tiers (
|
|
2944
|
+
message: `approver { type: '${type}', value: '${value}' } resolves against the better-auth org-membership tier (sys_member.role: ${MEMBERSHIP_TIER_LIST}) \u2014 '${value}' is not a membership tier, so this approver matches nobody and the request stalls.`,
|
|
2945
|
+
hint: `If '${value}' is an org position, author { type: 'position', value: '${value}' } (resolved via sys_user_position, ADR-0090 D3). Keep type 'org_membership_level' only for membership tiers (${MEMBERSHIP_TIER_LIST}) \u2014 the vocabulary is closed (ADR-0108), so a business role is always a position.`
|
|
1728
2946
|
});
|
|
1729
2947
|
} else if (type in DEPRECATED_APPROVER_TYPES) {
|
|
1730
2948
|
const fix = canonicalApproverType(type);
|
|
@@ -1736,7 +2954,66 @@ function validateApprovalApprovers(stack) {
|
|
|
1736
2954
|
message: `approver type '${type}' is the deprecated spelling of '${fix}' (ADR-0090 D3) and is removed in the next major.`,
|
|
1737
2955
|
hint: `Author { type: '${fix}', value: '${value}' }. It resolves identically today.`
|
|
1738
2956
|
});
|
|
2957
|
+
} else if (APPROVER_VALUE_BINDINGS[canonical]?.source === "unsupported") {
|
|
2958
|
+
findings.push({
|
|
2959
|
+
severity: "warning",
|
|
2960
|
+
rule: APPROVAL_APPROVER_TYPE_UNSUPPORTED,
|
|
2961
|
+
where,
|
|
2962
|
+
path: `${path}.type`,
|
|
2963
|
+
message: `approver type '${type}' is declared but not implemented by the runtime (#3508) \u2014 the slot resolves to nobody and the request stalls.`,
|
|
2964
|
+
hint: `Route to people the engine can expand: { type: 'team' | 'department' | 'position', ... }. Queue approvers need a real ownership-queue implementation before they take effect.`
|
|
2965
|
+
});
|
|
1739
2966
|
}
|
|
2967
|
+
const declaredOrg = a.organization;
|
|
2968
|
+
if (typeof declaredOrg === "string" && declaredOrg.trim() !== "" && ApproverType.options.includes(canonical) && !approverTypeIsOrgScoped(canonical)) {
|
|
2969
|
+
findings.push({
|
|
2970
|
+
severity: "error",
|
|
2971
|
+
rule: APPROVAL_APPROVER_CROSS_ORG_UNSUPPORTED,
|
|
2972
|
+
where,
|
|
2973
|
+
path: `${path}.organization`,
|
|
2974
|
+
message: `approver type '${type}' does not resolve through an organization directory, so 'organization: ${declaredOrg}' has no effect (ADR-0105 D9) \u2014 the runtime refuses it.`,
|
|
2975
|
+
hint: `Drop 'organization' here. Cross-organization targeting applies to 'position', 'org_membership_level', 'department' and 'expression' approvers.`
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
const routable = approvers.filter(
|
|
2980
|
+
(a) => a && typeof a === "object" && typeof a.type === "string"
|
|
2981
|
+
);
|
|
2982
|
+
if (routable.length > 0 && routable.every((a) => GROUP_ROUTED_TYPES.has(canonicalApproverType(String(a.type))))) {
|
|
2983
|
+
const locks = cfg.lockRecord !== false;
|
|
2984
|
+
findings.push({
|
|
2985
|
+
severity: "info",
|
|
2986
|
+
rule: APPROVAL_APPROVERS_MAY_RESOLVE_EMPTY,
|
|
2987
|
+
where,
|
|
2988
|
+
path: `${nodePath}.config.approvers`,
|
|
2989
|
+
message: `every approver on this node routes to a group (position/team/department) whose members are runtime data \u2014 if none is staffed, the request resolves to an empty slate and waits forever` + (locks ? `, and (lockRecord) the record stays locked with no in-product recovery.` : `.`),
|
|
2990
|
+
hint: `Make sure at least one target is always staffed, or add a guaranteed-staffed fallback approver, e.g. { type: 'org_membership_level', value: 'owner' }. A request that still lands empty is recoverable only by a platform/tenant admin override (#3424).`
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
const hasExpression = approvers.some(
|
|
2994
|
+
(a) => a && typeof a === "object" && canonicalApproverType(String(a.type ?? "")) === "expression"
|
|
2995
|
+
);
|
|
2996
|
+
if (hasExpression && cfg.onEmptyApprovers == null) {
|
|
2997
|
+
findings.push({
|
|
2998
|
+
severity: "info",
|
|
2999
|
+
rule: APPROVAL_EXPRESSION_NO_EMPTY_POLICY,
|
|
3000
|
+
where,
|
|
3001
|
+
path: `${nodePath}.config`,
|
|
3002
|
+
message: `this node resolves approvers from an expression but declares no onEmptyApprovers \u2014 an empty result falls back to the default ('admin_rescue': request opens, only a privileged admin can act).`,
|
|
3003
|
+
hint: `Declare the empty-slate policy explicitly: onEmptyApprovers: 'admin_rescue' (hold for admin takeover), 'fail' (fail the node \u2014 config bug), or 'auto_approve' (wave through, output.autoApproved = true).`
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
3006
|
+
const declaredOutputs = normalizeDecisionOutputs(cfg.decisionOutputs).map((d) => d.key);
|
|
3007
|
+
const reserved = declaredOutputs.filter((k) => RESERVED_OUTPUT_KEYS.has(k));
|
|
3008
|
+
if (reserved.length) {
|
|
3009
|
+
findings.push({
|
|
3010
|
+
severity: "error",
|
|
3011
|
+
rule: APPROVAL_DECISION_OUTPUTS_RESERVED,
|
|
3012
|
+
where,
|
|
3013
|
+
path: `${nodePath}.config.decisionOutputs`,
|
|
3014
|
+
message: `decisionOutputs declares reserved key(s) \`${reserved.join("`, `")}\` \u2014 the resume envelope owns them, so every decide carrying them is rejected.`,
|
|
3015
|
+
hint: `Rename the output key(s); any name other than 'decision'/'requestId' works.`
|
|
3016
|
+
});
|
|
1740
3017
|
}
|
|
1741
3018
|
const escalation = cfg.escalation ?? null;
|
|
1742
3019
|
if (escalation && typeof escalation === "object" && escalation.action === "reassign") {
|
|
@@ -1746,7 +3023,7 @@ function validateApprovalApprovers(stack) {
|
|
|
1746
3023
|
severity: "warning",
|
|
1747
3024
|
rule: APPROVAL_ESCALATION_REASSIGN_NO_TARGET,
|
|
1748
3025
|
where,
|
|
1749
|
-
path:
|
|
3026
|
+
path: `${nodePath}.config.escalation.escalateTo`,
|
|
1750
3027
|
message: `escalation.action is 'reassign' but escalateTo is empty \u2014 at runtime the escalation degrades to a notify and the request stays with the original approvers.`,
|
|
1751
3028
|
hint: `Set escalateTo to a position machine name (expanded via sys_user_position, ADR-0090 D3) or a specific user id, or change action to 'notify'.`
|
|
1752
3029
|
});
|
|
@@ -1757,6 +3034,96 @@ function validateApprovalApprovers(stack) {
|
|
|
1757
3034
|
return findings;
|
|
1758
3035
|
}
|
|
1759
3036
|
|
|
3037
|
+
// src/validate-seed-replay-safety.ts
|
|
3038
|
+
var SEED_INSERT_MODE_DUPLICATES_ON_REPLAY = "seed-insert-mode-duplicates-on-replay";
|
|
3039
|
+
function validateSeedReplaySafety(stack) {
|
|
3040
|
+
const out = [];
|
|
3041
|
+
const seeds = Array.isArray(stack.data) ? stack.data : [];
|
|
3042
|
+
seeds.forEach((seed, i) => {
|
|
3043
|
+
if (!seed || typeof seed !== "object") return;
|
|
3044
|
+
if (seed.mode !== "insert") return;
|
|
3045
|
+
const object = typeof seed.object === "string" ? seed.object : void 0;
|
|
3046
|
+
const where = object ? `seed "${object}"` : `data[${i}]`;
|
|
3047
|
+
out.push({
|
|
3048
|
+
severity: "warning",
|
|
3049
|
+
rule: SEED_INSERT_MODE_DUPLICATES_ON_REPLAY,
|
|
3050
|
+
where,
|
|
3051
|
+
path: `data[${i}].mode`,
|
|
3052
|
+
message: "`mode: 'insert'` re-inserts every record on each replay boot (dev-server restart, package re-publish) with no existing-row check, so the dataset duplicates the table on every restart \u2014 seeds are replayed, not applied once.",
|
|
3053
|
+
hint: "Use `mode: 'ignore'` (skip rows that already exist) or `'upsert'` (create-or-update), and declare an `externalId` to match on: a single natural-key field (e.g. `externalId: 'code'`), or a COMPOSITE list of fields for a join / junction table with no single natural key (e.g. `externalId: ['team', 'project']`)."
|
|
3054
|
+
});
|
|
3055
|
+
});
|
|
3056
|
+
return out;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
// src/validate-seed-state-machine.ts
|
|
3060
|
+
var SEED_VALUE_OUTSIDE_STATE_MACHINE = "seed-value-outside-state-machine";
|
|
3061
|
+
function fsmRulesByObject(objects) {
|
|
3062
|
+
const map = /* @__PURE__ */ new Map();
|
|
3063
|
+
for (const obj of objects) {
|
|
3064
|
+
if (!obj || typeof obj !== "object") continue;
|
|
3065
|
+
const name = typeof obj.name === "string" ? obj.name : void 0;
|
|
3066
|
+
if (!name) continue;
|
|
3067
|
+
const validations = Array.isArray(obj.validations) ? obj.validations : [];
|
|
3068
|
+
const rules = [];
|
|
3069
|
+
for (const v of validations) {
|
|
3070
|
+
if (!v || typeof v !== "object" || v.type !== "state_machine") continue;
|
|
3071
|
+
const field = typeof v.field === "string" ? v.field : void 0;
|
|
3072
|
+
if (!field) continue;
|
|
3073
|
+
const transitions = v.transitions && typeof v.transitions === "object" ? v.transitions : {};
|
|
3074
|
+
const states = /* @__PURE__ */ new Set();
|
|
3075
|
+
for (const s of Array.isArray(v.initialStates) ? v.initialStates : []) states.add(String(s));
|
|
3076
|
+
for (const from of Object.keys(transitions)) {
|
|
3077
|
+
states.add(String(from));
|
|
3078
|
+
const targets = transitions[from];
|
|
3079
|
+
for (const to of Array.isArray(targets) ? targets : []) states.add(String(to));
|
|
3080
|
+
}
|
|
3081
|
+
if (states.size > 0) rules.push({ field, states });
|
|
3082
|
+
}
|
|
3083
|
+
if (rules.length > 0) map.set(name, rules);
|
|
3084
|
+
}
|
|
3085
|
+
return map;
|
|
3086
|
+
}
|
|
3087
|
+
function recordLabel(record, externalId, index) {
|
|
3088
|
+
const keys = Array.isArray(externalId) ? externalId.map(String) : typeof externalId === "string" ? [externalId] : ["name"];
|
|
3089
|
+
const parts = keys.map((k) => record[k]).filter((v) => v != null && v !== "");
|
|
3090
|
+
return parts.length > 0 ? parts.map(String).join(" \xB7 ") : `#${index}`;
|
|
3091
|
+
}
|
|
3092
|
+
function validateSeedStateMachine(stack) {
|
|
3093
|
+
const out = [];
|
|
3094
|
+
const objects = Array.isArray(stack.objects) ? stack.objects : [];
|
|
3095
|
+
const seeds = Array.isArray(stack.data) ? stack.data : [];
|
|
3096
|
+
if (objects.length === 0 || seeds.length === 0) return out;
|
|
3097
|
+
const rulesByObject = fsmRulesByObject(objects);
|
|
3098
|
+
if (rulesByObject.size === 0) return out;
|
|
3099
|
+
seeds.forEach((seed, i) => {
|
|
3100
|
+
if (!seed || typeof seed !== "object") return;
|
|
3101
|
+
const objectName = typeof seed.object === "string" ? seed.object : void 0;
|
|
3102
|
+
if (!objectName) return;
|
|
3103
|
+
const rules = rulesByObject.get(objectName);
|
|
3104
|
+
if (!rules) return;
|
|
3105
|
+
const records = Array.isArray(seed.records) ? seed.records : [];
|
|
3106
|
+
records.forEach((record, j) => {
|
|
3107
|
+
if (!record || typeof record !== "object") return;
|
|
3108
|
+
for (const rule of rules) {
|
|
3109
|
+
const value = record[rule.field];
|
|
3110
|
+
if (value == null || value === "") continue;
|
|
3111
|
+
if (typeof value !== "string") continue;
|
|
3112
|
+
if (rule.states.has(value)) continue;
|
|
3113
|
+
out.push({
|
|
3114
|
+
severity: "warning",
|
|
3115
|
+
rule: SEED_VALUE_OUTSIDE_STATE_MACHINE,
|
|
3116
|
+
where: `seed "${objectName}" (${recordLabel(record, seed.externalId, j)})`,
|
|
3117
|
+
path: `data[${i}].records[${j}].${rule.field}`,
|
|
3118
|
+
message: `seeds '${rule.field}=${value}', which the '${objectName}' state machine does not declare (known states: ${[...rule.states].sort().join(", ")}). Seed writes are exempt from the state_machine rule (#3433), so this is NOT rejected at write time \u2014 a typo lands silently.`,
|
|
3119
|
+
hint: `If '${value}' is a real state, add it to the state machine (as an initial state or a transition endpoint). If it is a typo, correct it to a declared state. The exemption lets a seed be born mid-lifecycle; it is not a licence to write an unknown state.`
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
});
|
|
3123
|
+
});
|
|
3124
|
+
return out;
|
|
3125
|
+
}
|
|
3126
|
+
|
|
1760
3127
|
// src/validate-security-posture.ts
|
|
1761
3128
|
import { describeAnchorForbiddenBits } from "@objectstack/spec/security";
|
|
1762
3129
|
var SECURITY_OWD_UNSET = "security-owd-unset";
|
|
@@ -1783,7 +3150,7 @@ var OWD_WIDTH = {
|
|
|
1783
3150
|
public_read: 1,
|
|
1784
3151
|
public_read_write: 2
|
|
1785
3152
|
};
|
|
1786
|
-
function
|
|
3153
|
+
function asArray20(v) {
|
|
1787
3154
|
if (Array.isArray(v)) return v;
|
|
1788
3155
|
if (v && typeof v === "object") {
|
|
1789
3156
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
@@ -1800,16 +3167,16 @@ function identifierHasRoleToken(name) {
|
|
|
1800
3167
|
if (typeof name !== "string") return false;
|
|
1801
3168
|
return name.toLowerCase().split(/[^a-z0-9]+/).some((tok) => tok === "role" || tok === "roles");
|
|
1802
3169
|
}
|
|
1803
|
-
function labelHasRoleWord(
|
|
1804
|
-
if (typeof
|
|
1805
|
-
return /\brole(s)?\b/i.test(
|
|
3170
|
+
function labelHasRoleWord(label2) {
|
|
3171
|
+
if (typeof label2 !== "string") return false;
|
|
3172
|
+
return /\brole(s)?\b/i.test(label2);
|
|
1806
3173
|
}
|
|
1807
3174
|
function refOf(def) {
|
|
1808
3175
|
const r = def.reference ?? def.reference_to;
|
|
1809
3176
|
return typeof r === "string" && r ? r : void 0;
|
|
1810
3177
|
}
|
|
1811
3178
|
function firstMasterDetailField(obj) {
|
|
1812
|
-
for (const f of
|
|
3179
|
+
for (const f of asArray20(obj.fields)) {
|
|
1813
3180
|
if (f.type === "master_detail") {
|
|
1814
3181
|
return { name: String(f.name ?? "?"), parent: refOf(f) };
|
|
1815
3182
|
}
|
|
@@ -1822,8 +3189,8 @@ function grantsObjectAccess(p) {
|
|
|
1822
3189
|
function validateSecurityPosture(stack, opts) {
|
|
1823
3190
|
const findings = [];
|
|
1824
3191
|
if (!stack || typeof stack !== "object") return findings;
|
|
1825
|
-
const objects =
|
|
1826
|
-
const permissionSets =
|
|
3192
|
+
const objects = asArray20(stack.objects);
|
|
3193
|
+
const permissionSets = asArray20(stack.permissions);
|
|
1827
3194
|
for (let i = 0; i < objects.length; i++) {
|
|
1828
3195
|
const obj = objects[i];
|
|
1829
3196
|
if (!obj || typeof obj !== "object") continue;
|
|
@@ -1926,7 +3293,7 @@ function validateSecurityPosture(stack, opts) {
|
|
|
1926
3293
|
}
|
|
1927
3294
|
}
|
|
1928
3295
|
}
|
|
1929
|
-
const flagRole = (kind, name,
|
|
3296
|
+
const flagRole = (kind, name, label2, where, path) => {
|
|
1930
3297
|
if (identifierHasRoleToken(name)) {
|
|
1931
3298
|
findings.push({
|
|
1932
3299
|
severity: "error",
|
|
@@ -1936,13 +3303,13 @@ function validateSecurityPosture(stack, opts) {
|
|
|
1936
3303
|
message: `${kind} name "${String(name)}" uses the reserved word "role" \u2014 the platform vocabulary is permission_set (capability), position (distribution), business_unit (hierarchy) (ADR-0090 D3).`,
|
|
1937
3304
|
hint: `Rename using 'position' for distribution groups or a domain word (e.g. 'function', 'duty').`
|
|
1938
3305
|
});
|
|
1939
|
-
} else if (labelHasRoleWord(
|
|
3306
|
+
} else if (labelHasRoleWord(label2)) {
|
|
1940
3307
|
findings.push({
|
|
1941
3308
|
severity: "error",
|
|
1942
3309
|
rule: SECURITY_ROLE_WORD,
|
|
1943
3310
|
where,
|
|
1944
3311
|
path: `${path.replace(/\.name$/, "")}.label`,
|
|
1945
|
-
message: `${kind} label "${String(
|
|
3312
|
+
message: `${kind} label "${String(label2)}" uses the reserved word "role" (ADR-0090 D3).`,
|
|
1946
3313
|
hint: `Relabel with 'Position' (distribution) or a domain word \u2014 admins must meet ONE vocabulary.`
|
|
1947
3314
|
});
|
|
1948
3315
|
}
|
|
@@ -1952,10 +3319,10 @@ function validateSecurityPosture(stack, opts) {
|
|
|
1952
3319
|
if (!obj || typeof obj !== "object" || isSystemObject(obj)) continue;
|
|
1953
3320
|
const objName = typeof obj.name === "string" ? obj.name : `(object ${i})`;
|
|
1954
3321
|
flagRole("object", obj.name, obj.label, `object "${objName}"`, `objects[${i}].name`);
|
|
1955
|
-
for (const f of
|
|
3322
|
+
for (const f of asArray20(obj.fields)) {
|
|
1956
3323
|
flagRole("field", f.name, f.label, `field "${objName}.${String(f.name ?? "?")}"`, `objects[${i}].fields.${String(f.name ?? "?")}.name`);
|
|
1957
3324
|
}
|
|
1958
|
-
for (const [ai, action] of
|
|
3325
|
+
for (const [ai, action] of asArray20(obj.actions).entries()) {
|
|
1959
3326
|
flagRole("action", action.name, action.label, `action "${objName}.${String(action.name ?? "?")}"`, `objects[${i}].actions[${ai}].name`);
|
|
1960
3327
|
}
|
|
1961
3328
|
}
|
|
@@ -1964,19 +3331,19 @@ function validateSecurityPosture(stack, opts) {
|
|
|
1964
3331
|
if (!ps || typeof ps !== "object") continue;
|
|
1965
3332
|
flagRole("permission set", ps.name, ps.label, `permission set "${String(ps.name ?? i)}"`, `permissions[${i}].name`);
|
|
1966
3333
|
}
|
|
1967
|
-
for (const [i, pos] of
|
|
3334
|
+
for (const [i, pos] of asArray20(stack.positions).entries()) {
|
|
1968
3335
|
flagRole("position", pos.name, pos.label, `position "${String(pos.name ?? i)}"`, `positions[${i}].name`);
|
|
1969
3336
|
}
|
|
1970
|
-
for (const [i, app] of
|
|
3337
|
+
for (const [i, app] of asArray20(stack.apps).entries()) {
|
|
1971
3338
|
flagRole("app", app.name, app.label, `app "${String(app.name ?? i)}"`, `apps[${i}].name`);
|
|
1972
3339
|
}
|
|
1973
|
-
for (const [i, book] of
|
|
3340
|
+
for (const [i, book] of asArray20(stack.books).entries()) {
|
|
1974
3341
|
flagRole("book", book.name, book.label, `book "${String(book.name ?? i)}"`, `books[${i}].name`);
|
|
1975
3342
|
}
|
|
1976
3343
|
const stackSetNames = new Set(
|
|
1977
3344
|
permissionSets.map((ps) => typeof ps.name === "string" ? ps.name : void 0).filter((n) => !!n)
|
|
1978
3345
|
);
|
|
1979
|
-
for (const [i, book] of
|
|
3346
|
+
for (const [i, book] of asArray20(stack.books).entries()) {
|
|
1980
3347
|
const audience = book.audience;
|
|
1981
3348
|
if (!audience || typeof audience !== "object") continue;
|
|
1982
3349
|
const setName = audience.permissionSet;
|
|
@@ -2054,7 +3421,7 @@ function validateSecurityPosture(stack, opts) {
|
|
|
2054
3421
|
}
|
|
2055
3422
|
const GRANT_SEED_OBJECTS = /* @__PURE__ */ new Set(["sys_user_position", "sys_user_permission_set"]);
|
|
2056
3423
|
const nowMs = opts?.nowMs ?? Date.now();
|
|
2057
|
-
for (const [i, seed] of
|
|
3424
|
+
for (const [i, seed] of asArray20(stack.data).entries()) {
|
|
2058
3425
|
const seedObject = typeof seed.object === "string" ? seed.object : "";
|
|
2059
3426
|
if (!GRANT_SEED_OBJECTS.has(seedObject)) continue;
|
|
2060
3427
|
const records = Array.isArray(seed.records) ? seed.records : [];
|
|
@@ -2094,17 +3461,110 @@ function validateSecurityPosture(stack, opts) {
|
|
|
2094
3461
|
return findings;
|
|
2095
3462
|
}
|
|
2096
3463
|
|
|
3464
|
+
// src/validate-org-axis-red-lines.ts
|
|
3465
|
+
var ORG_AXIS_PERMISSION_INHERITANCE = "org-axis-permission-inheritance";
|
|
3466
|
+
var ORG_AXIS_CROSS_ORG_BU_GRANT = "org-axis-cross-org-bu-grant";
|
|
3467
|
+
var ORG_PARENT_FIELD = "parent_organization_id";
|
|
3468
|
+
function asArray21(v) {
|
|
3469
|
+
if (Array.isArray(v)) return v;
|
|
3470
|
+
if (v && typeof v === "object") {
|
|
3471
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
3472
|
+
}
|
|
3473
|
+
return [];
|
|
3474
|
+
}
|
|
3475
|
+
function str(v) {
|
|
3476
|
+
return typeof v === "string" ? v : "";
|
|
3477
|
+
}
|
|
3478
|
+
function isTenancyDisabled(object) {
|
|
3479
|
+
const tenancy = object.tenancy;
|
|
3480
|
+
if (tenancy && typeof tenancy === "object" && tenancy.enabled === false) return true;
|
|
3481
|
+
const systemFields = object.systemFields;
|
|
3482
|
+
if (systemFields && typeof systemFields === "object" && systemFields.tenant === false) return true;
|
|
3483
|
+
return false;
|
|
3484
|
+
}
|
|
3485
|
+
var INHERITANCE_HINT = `Remove the ${ORG_PARENT_FIELD} reference. Cross-organization visibility comes from MEMBERSHIP: under the \`group\` tenancy posture the engine's Layer 0 wall is \`organization_id IN accessible_org_ids\`, so a user who should see several organizations is made a member of them (ADR-0105 D2). A Layer-1 policy cannot widen Layer 0 anyway, so this rule would not grant the access it appears to. For a hierarchy INSIDE one organization, use the business-unit tree (\`unit_and_subordinates\` sharing, or a depth scope anchored on \`sys_user_position\`).`;
|
|
3486
|
+
function validateOrgAxisRedLines(stack) {
|
|
3487
|
+
const findings = [];
|
|
3488
|
+
const cfg = stack ?? {};
|
|
3489
|
+
const permissionSets = asArray21(cfg.permissions ?? cfg.permissionSets);
|
|
3490
|
+
permissionSets.forEach((ps, psIndex) => {
|
|
3491
|
+
asArray21(ps.rowLevelSecurity).forEach((policy, pIndex) => {
|
|
3492
|
+
for (const clause of ["using", "check"]) {
|
|
3493
|
+
if (!str(policy[clause]).includes(ORG_PARENT_FIELD)) continue;
|
|
3494
|
+
findings.push({
|
|
3495
|
+
severity: "error",
|
|
3496
|
+
rule: ORG_AXIS_PERMISSION_INHERITANCE,
|
|
3497
|
+
where: `permission set "${str(ps.name) || psIndex}" policy "${str(policy.name) || pIndex}"`,
|
|
3498
|
+
path: `permissions[${psIndex}].rowLevelSecurity[${pIndex}].${clause}`,
|
|
3499
|
+
message: `RLS ${clause} reads \`${ORG_PARENT_FIELD}\`, which builds a permission hierarchy along the organization axis. ADR-0105 D6 forbids it: the org tree is a REPORTING dimension only.`,
|
|
3500
|
+
hint: INHERITANCE_HINT
|
|
3501
|
+
});
|
|
3502
|
+
}
|
|
3503
|
+
});
|
|
3504
|
+
});
|
|
3505
|
+
const objects = asArray21(cfg.objects);
|
|
3506
|
+
objects.forEach((object, oIndex) => {
|
|
3507
|
+
const objectName = str(object.name) || String(oIndex);
|
|
3508
|
+
asArray21(object.rowLevelSecurity ?? object.rls).forEach((policy, pIndex) => {
|
|
3509
|
+
for (const clause of ["using", "check"]) {
|
|
3510
|
+
if (!str(policy[clause]).includes(ORG_PARENT_FIELD)) continue;
|
|
3511
|
+
findings.push({
|
|
3512
|
+
severity: "error",
|
|
3513
|
+
rule: ORG_AXIS_PERMISSION_INHERITANCE,
|
|
3514
|
+
where: `object "${objectName}" policy "${str(policy.name) || pIndex}"`,
|
|
3515
|
+
path: `objects[${oIndex}].rowLevelSecurity[${pIndex}].${clause}`,
|
|
3516
|
+
message: `RLS ${clause} reads \`${ORG_PARENT_FIELD}\`, which builds a permission hierarchy along the organization axis. ADR-0105 D6 forbids it: the org tree is a REPORTING dimension only.`,
|
|
3517
|
+
hint: INHERITANCE_HINT
|
|
3518
|
+
});
|
|
3519
|
+
}
|
|
3520
|
+
});
|
|
3521
|
+
});
|
|
3522
|
+
asArray21(cfg.sharingRules ?? cfg.sharing).forEach((rule, rIndex) => {
|
|
3523
|
+
const criteria = JSON.stringify(rule.criteria ?? rule.filter ?? "");
|
|
3524
|
+
const sharedTo = JSON.stringify(rule.sharedTo ?? rule.recipient ?? "");
|
|
3525
|
+
if (criteria.includes(ORG_PARENT_FIELD) || sharedTo.includes(ORG_PARENT_FIELD)) {
|
|
3526
|
+
findings.push({
|
|
3527
|
+
severity: "error",
|
|
3528
|
+
rule: ORG_AXIS_PERMISSION_INHERITANCE,
|
|
3529
|
+
where: `sharing rule "${str(rule.name) || rIndex}"`,
|
|
3530
|
+
path: `sharingRules[${rIndex}]`,
|
|
3531
|
+
message: `Sharing rule reads \`${ORG_PARENT_FIELD}\`, granting access by walking the organization tree. ADR-0105 D6 forbids permission inheritance along the org axis.`,
|
|
3532
|
+
hint: INHERITANCE_HINT
|
|
3533
|
+
});
|
|
3534
|
+
}
|
|
3535
|
+
});
|
|
3536
|
+
const tenancyDisabledObjects = new Set(
|
|
3537
|
+
objects.filter((o) => isTenancyDisabled(o)).map((o) => str(o.name)).filter(Boolean)
|
|
3538
|
+
);
|
|
3539
|
+
asArray21(cfg.sharingRules ?? cfg.sharing).forEach((rule, rIndex) => {
|
|
3540
|
+
const target = str(rule.object ?? rule.objectName);
|
|
3541
|
+
if (!target || !tenancyDisabledObjects.has(target)) return;
|
|
3542
|
+
const sharedTo = rule.sharedTo ?? rule.recipient;
|
|
3543
|
+
const recipientType = str(sharedTo?.type);
|
|
3544
|
+
if (recipientType !== "business_unit") return;
|
|
3545
|
+
findings.push({
|
|
3546
|
+
severity: "error",
|
|
3547
|
+
rule: ORG_AXIS_CROSS_ORG_BU_GRANT,
|
|
3548
|
+
where: `sharing rule "${str(rule.name) || rIndex}" on object "${target}"`,
|
|
3549
|
+
path: `sharingRules[${rIndex}].sharedTo`,
|
|
3550
|
+
message: `A business-unit sharing rule targets "${target}", which opted out of tenancy (\`tenancy.enabled: false\`). Platform-global objects carry no organization column, so this grant spans EVERY organization \u2014 a cross-organization business-unit grant, which ADR-0105 D6 forbids (BU trees are org-internal).`,
|
|
3551
|
+
hint: `Either scope the object to organizations (drop \`tenancy.enabled: false\` so Layer 0 walls it), or share it to a position / permission-set audience instead of a business unit. A platform-global catalog that everyone should read wants an OWD of \`public_read\`, not a BU grant.`
|
|
3552
|
+
});
|
|
3553
|
+
});
|
|
3554
|
+
return findings;
|
|
3555
|
+
}
|
|
3556
|
+
|
|
2097
3557
|
// src/validate-dashboard-action-refs.ts
|
|
2098
3558
|
var DASHBOARD_ACTION_TARGET_UNDEFINED = "dashboard-action-target-undefined";
|
|
2099
3559
|
var DASHBOARD_ACTION_ROUTE_UNRESOLVED = "dashboard-action-route-unresolved";
|
|
2100
|
-
function
|
|
3560
|
+
function asArray22(v) {
|
|
2101
3561
|
if (Array.isArray(v)) return v;
|
|
2102
3562
|
if (v && typeof v === "object") {
|
|
2103
3563
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
2104
3564
|
}
|
|
2105
3565
|
return [];
|
|
2106
3566
|
}
|
|
2107
|
-
function
|
|
3567
|
+
function strName5(v) {
|
|
2108
3568
|
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
2109
3569
|
}
|
|
2110
3570
|
var MODAL_VERB_RE = /^(?:create|new|add|edit|update)_(.+)$/;
|
|
@@ -2121,7 +3581,7 @@ var URL_COLLECTION_TO_STACK_KEY = {
|
|
|
2121
3581
|
views: "views"
|
|
2122
3582
|
};
|
|
2123
3583
|
function viewContainerName(item) {
|
|
2124
|
-
return
|
|
3584
|
+
return strName5(item.name) ?? strName5(item.id) ?? strName5(item.object) ?? strName5(item.list?.data && item.list.data.object) ?? strName5(item.form?.data && item.form.data.object);
|
|
2125
3585
|
}
|
|
2126
3586
|
function collectKnownTargets(stack) {
|
|
2127
3587
|
const actions = /* @__PURE__ */ new Set();
|
|
@@ -2131,22 +3591,22 @@ function collectKnownTargets(stack) {
|
|
|
2131
3591
|
const pages = /* @__PURE__ */ new Set();
|
|
2132
3592
|
const views = /* @__PURE__ */ new Set();
|
|
2133
3593
|
const collectNames = (v, into, name) => {
|
|
2134
|
-
for (const item of
|
|
3594
|
+
for (const item of asArray22(v)) {
|
|
2135
3595
|
if (!item || typeof item !== "object") continue;
|
|
2136
3596
|
const n = name(item);
|
|
2137
3597
|
if (n) into.add(n);
|
|
2138
3598
|
}
|
|
2139
3599
|
};
|
|
2140
|
-
collectNames(stack.actions, actions, (a) =>
|
|
2141
|
-
for (const obj of
|
|
3600
|
+
collectNames(stack.actions, actions, (a) => strName5(a.name));
|
|
3601
|
+
for (const obj of asArray22(stack.objects)) {
|
|
2142
3602
|
if (!obj || typeof obj !== "object") continue;
|
|
2143
|
-
const n =
|
|
3603
|
+
const n = strName5(obj.name);
|
|
2144
3604
|
if (n) objects.add(n);
|
|
2145
|
-
collectNames(obj.actions, actions, (a) =>
|
|
3605
|
+
collectNames(obj.actions, actions, (a) => strName5(a.name));
|
|
2146
3606
|
}
|
|
2147
|
-
collectNames(stack.reports, reports, (r) =>
|
|
2148
|
-
collectNames(stack.dashboards, dashboards, (d) =>
|
|
2149
|
-
collectNames(stack.pages, pages, (p) =>
|
|
3607
|
+
collectNames(stack.reports, reports, (r) => strName5(r.name));
|
|
3608
|
+
collectNames(stack.dashboards, dashboards, (d) => strName5(d.name));
|
|
3609
|
+
collectNames(stack.pages, pages, (p) => strName5(p.name));
|
|
2150
3610
|
collectNames(stack.views, views, viewContainerName);
|
|
2151
3611
|
for (const o of objects) views.add(o);
|
|
2152
3612
|
return { actions, objects, reports, dashboards, pages, views };
|
|
@@ -2178,14 +3638,14 @@ function resolveUrlRoute(target, known) {
|
|
|
2178
3638
|
function validateDashboardActionRefs(stack) {
|
|
2179
3639
|
const findings = [];
|
|
2180
3640
|
if (!stack || typeof stack !== "object") return findings;
|
|
2181
|
-
const dashboards =
|
|
3641
|
+
const dashboards = asArray22(stack.dashboards);
|
|
2182
3642
|
if (dashboards.length === 0) return findings;
|
|
2183
3643
|
const known = collectKnownTargets(stack);
|
|
2184
3644
|
const checkOne = (action, where, path) => {
|
|
2185
|
-
const target =
|
|
3645
|
+
const target = strName5(action.actionUrl);
|
|
2186
3646
|
if (!target) return;
|
|
2187
3647
|
if (target.includes("${")) return;
|
|
2188
|
-
const actionType =
|
|
3648
|
+
const actionType = strName5(action.actionType) ?? "url";
|
|
2189
3649
|
if (actionType === "script" || actionType === "modal") {
|
|
2190
3650
|
if (resolveActionTarget(actionType, target, known)) return;
|
|
2191
3651
|
const kindWord = actionType === "script" ? "script" : "modal";
|
|
@@ -2216,25 +3676,25 @@ function validateDashboardActionRefs(stack) {
|
|
|
2216
3676
|
for (let di = 0; di < dashboards.length; di++) {
|
|
2217
3677
|
const dash = dashboards[di];
|
|
2218
3678
|
if (!dash || typeof dash !== "object") continue;
|
|
2219
|
-
const dashName =
|
|
3679
|
+
const dashName = strName5(dash.name) ?? `(dashboard ${di})`;
|
|
2220
3680
|
const dashPath = `dashboards[${di}]`;
|
|
2221
|
-
const headerActions =
|
|
3681
|
+
const headerActions = asArray22(dash.header?.actions);
|
|
2222
3682
|
for (let ai = 0; ai < headerActions.length; ai++) {
|
|
2223
3683
|
const action = headerActions[ai];
|
|
2224
3684
|
if (!action || typeof action !== "object") continue;
|
|
2225
|
-
const
|
|
3685
|
+
const label2 = strName5(action.label) ?? strName5(action.actionUrl) ?? `#${ai}`;
|
|
2226
3686
|
checkOne(
|
|
2227
3687
|
action,
|
|
2228
|
-
`dashboard "${dashName}" \xB7 header action "${
|
|
3688
|
+
`dashboard "${dashName}" \xB7 header action "${label2}"`,
|
|
2229
3689
|
`${dashPath}.header.actions[${ai}].actionUrl`
|
|
2230
3690
|
);
|
|
2231
3691
|
}
|
|
2232
|
-
const widgets =
|
|
3692
|
+
const widgets = asArray22(dash.widgets);
|
|
2233
3693
|
for (let wi = 0; wi < widgets.length; wi++) {
|
|
2234
3694
|
const widget = widgets[wi];
|
|
2235
3695
|
if (!widget || typeof widget !== "object") continue;
|
|
2236
|
-
if (!
|
|
2237
|
-
const widgetId =
|
|
3696
|
+
if (!strName5(widget.actionUrl)) continue;
|
|
3697
|
+
const widgetId = strName5(widget.id) ?? `#${wi}`;
|
|
2238
3698
|
checkOne(
|
|
2239
3699
|
{ actionType: widget.actionType, actionUrl: widget.actionUrl },
|
|
2240
3700
|
`dashboard "${dashName}" \xB7 widget "${widgetId}" action`,
|
|
@@ -2245,114 +3705,2167 @@ function validateDashboardActionRefs(stack) {
|
|
|
2245
3705
|
return findings;
|
|
2246
3706
|
}
|
|
2247
3707
|
|
|
2248
|
-
// src/
|
|
2249
|
-
|
|
3708
|
+
// src/validate-filter-tokens.ts
|
|
3709
|
+
import { classifyFilterToken, CONTEXT_TOKENS } from "@objectstack/spec/data";
|
|
3710
|
+
var FILTER_TOKEN_UNKNOWN = "filter-token-unknown";
|
|
3711
|
+
var FILTER_KEYS = /* @__PURE__ */ new Set(["filter", "filters", "runtimeFilter"]);
|
|
3712
|
+
function asArray23(v) {
|
|
2250
3713
|
if (Array.isArray(v)) return v;
|
|
2251
3714
|
if (v && typeof v === "object") {
|
|
2252
3715
|
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
2253
3716
|
}
|
|
2254
3717
|
return [];
|
|
2255
3718
|
}
|
|
2256
|
-
function
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
const
|
|
2264
|
-
if (
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
object: objName,
|
|
2275
|
-
create: p.allowCreate === true,
|
|
2276
|
-
read: p.allowRead === true || p.viewAllRecords === true || p.modifyAllRecords === true,
|
|
2277
|
-
edit: p.allowEdit === true || p.modifyAllRecords === true,
|
|
2278
|
-
delete: p.allowDelete === true || p.modifyAllRecords === true,
|
|
2279
|
-
viewAllRecords: p.viewAllRecords === true,
|
|
2280
|
-
modifyAllRecords: p.modifyAllRecords === true
|
|
2281
|
-
};
|
|
2282
|
-
if (typeof p.readScope === "string") entry.readScope = p.readScope;
|
|
2283
|
-
if (typeof p.writeScope === "string") entry.writeScope = p.writeScope;
|
|
2284
|
-
const owd = owdByObject.get(objName);
|
|
2285
|
-
if (owd) entry.sharingModel = owd;
|
|
2286
|
-
entries.push(entry);
|
|
3719
|
+
function label(v, fallback) {
|
|
3720
|
+
return typeof v === "string" && v.length > 0 ? v : fallback;
|
|
3721
|
+
}
|
|
3722
|
+
var KNOWN_LIST = CONTEXT_TOKENS.join("}, {");
|
|
3723
|
+
function walkFilterValues(node, path, where, out, seen) {
|
|
3724
|
+
if (node === null || node === void 0) return;
|
|
3725
|
+
if (typeof node === "string") {
|
|
3726
|
+
const cls = classifyFilterToken(node);
|
|
3727
|
+
if (cls?.kind === "unknown") {
|
|
3728
|
+
const suggestion = cls.suggestion;
|
|
3729
|
+
out.push({
|
|
3730
|
+
severity: "error",
|
|
3731
|
+
rule: FILTER_TOKEN_UNKNOWN,
|
|
3732
|
+
where,
|
|
3733
|
+
path,
|
|
3734
|
+
message: `Filter value "${node}" is not a resolvable placeholder. It is sent to the data engine as a literal string, matches no record, and the surface renders empty.`,
|
|
3735
|
+
hint: suggestion ? `Did you mean "{${suggestion}}"? Context tokens are {${KNOWN_LIST}}; time-based values use date macros such as {today} or {30_days_ago}.` : `Resolvable placeholders are the context tokens {${KNOWN_LIST}} and the date macros (e.g. {today}, {week_start}, {30_days_ago}). To filter on a literal value that happens to look like a placeholder, this is not supported \u2014 rename the value.`
|
|
3736
|
+
});
|
|
2287
3737
|
}
|
|
3738
|
+
return;
|
|
3739
|
+
}
|
|
3740
|
+
if (typeof node !== "object") return;
|
|
3741
|
+
if (seen.has(node)) return;
|
|
3742
|
+
seen.add(node);
|
|
3743
|
+
if (Array.isArray(node)) {
|
|
3744
|
+
node.forEach((v, i) => walkFilterValues(v, `${path}[${i}]`, where, out, seen));
|
|
3745
|
+
return;
|
|
3746
|
+
}
|
|
3747
|
+
for (const [k, v] of Object.entries(node)) {
|
|
3748
|
+
walkFilterValues(v, `${path}.${k}`, where, out, seen);
|
|
2288
3749
|
}
|
|
2289
|
-
entries.sort(
|
|
2290
|
-
(a, b) => a.permissionSet === b.permissionSet ? a.object.localeCompare(b.object) : a.permissionSet.localeCompare(b.permissionSet)
|
|
2291
|
-
);
|
|
2292
|
-
return { version: 1, entries };
|
|
2293
3750
|
}
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
];
|
|
2302
|
-
function diffAccessMatrix(before, after) {
|
|
2303
|
-
const lines = [];
|
|
2304
|
-
const key = (e) => `${e.permissionSet}\0${e.object}`;
|
|
2305
|
-
const beforeMap = new Map((before?.entries ?? []).map((e) => [key(e), e]));
|
|
2306
|
-
const afterMap = new Map((after?.entries ?? []).map((e) => [key(e), e]));
|
|
2307
|
-
for (const [k, b] of beforeMap) {
|
|
2308
|
-
if (!afterMap.has(k)) {
|
|
2309
|
-
lines.push(`'${b.permissionSet}' loses ALL access to '${b.object}' (entry removed)`);
|
|
2310
|
-
}
|
|
3751
|
+
function scanForFilters(node, path, where, out, seen) {
|
|
3752
|
+
if (!node || typeof node !== "object") return;
|
|
3753
|
+
if (seen.has(node)) return;
|
|
3754
|
+
seen.add(node);
|
|
3755
|
+
if (Array.isArray(node)) {
|
|
3756
|
+
node.forEach((v, i) => scanForFilters(v, `${path}[${i}]`, where, out, seen));
|
|
3757
|
+
return;
|
|
2311
3758
|
}
|
|
2312
|
-
for (const [k,
|
|
2313
|
-
const
|
|
2314
|
-
if (
|
|
2315
|
-
|
|
2316
|
-
lines.push(`'${a.permissionSet}' gains access to '${a.object}' (${grants.join(", ") || "no bits set"})`);
|
|
3759
|
+
for (const [k, v] of Object.entries(node)) {
|
|
3760
|
+
const childPath = `${path}.${k}`;
|
|
3761
|
+
if (FILTER_KEYS.has(k)) {
|
|
3762
|
+
walkFilterValues(v, childPath, where, out, /* @__PURE__ */ new Set());
|
|
2317
3763
|
continue;
|
|
2318
3764
|
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
3765
|
+
scanForFilters(v, childPath, where, out, seen);
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
function validateFilterTokens(stack) {
|
|
3769
|
+
if (!stack || typeof stack !== "object") return [];
|
|
3770
|
+
const out = [];
|
|
3771
|
+
const surfaces = [
|
|
3772
|
+
["dashboards", "dashboard"],
|
|
3773
|
+
["objects", "object"],
|
|
3774
|
+
["views", "view"],
|
|
3775
|
+
["reports", "report"],
|
|
3776
|
+
["datasets", "dataset"],
|
|
3777
|
+
["pages", "page"],
|
|
3778
|
+
["apps", "app"]
|
|
3779
|
+
];
|
|
3780
|
+
for (const [key, kind] of surfaces) {
|
|
3781
|
+
const items = asArray23(stack[key]);
|
|
3782
|
+
items.forEach((item, i) => {
|
|
3783
|
+
const name = label(item.name ?? item.id, `#${i}`);
|
|
3784
|
+
if (kind === "dashboard") {
|
|
3785
|
+
const widgets = Array.isArray(item.widgets) ? item.widgets : [];
|
|
3786
|
+
widgets.forEach((w, wi) => {
|
|
3787
|
+
const wName = label(w.id ?? w.title, `#${wi}`);
|
|
3788
|
+
scanForFilters(
|
|
3789
|
+
w,
|
|
3790
|
+
`${key}[${i}].widgets[${wi}]`,
|
|
3791
|
+
`dashboard "${name}" \xB7 widget "${wName}"`,
|
|
3792
|
+
out,
|
|
3793
|
+
/* @__PURE__ */ new Set()
|
|
3794
|
+
);
|
|
3795
|
+
});
|
|
3796
|
+
const { widgets: _skip, ...rest } = item;
|
|
3797
|
+
scanForFilters(rest, `${key}[${i}]`, `dashboard "${name}"`, out, /* @__PURE__ */ new Set());
|
|
3798
|
+
return;
|
|
2322
3799
|
}
|
|
3800
|
+
scanForFilters(item, `${key}[${i}]`, `${kind} "${name}"`, out, /* @__PURE__ */ new Set());
|
|
3801
|
+
});
|
|
3802
|
+
}
|
|
3803
|
+
return out;
|
|
3804
|
+
}
|
|
3805
|
+
|
|
3806
|
+
// src/validate-object-references.ts
|
|
3807
|
+
import {
|
|
3808
|
+
hasPlatformObjectPrefix,
|
|
3809
|
+
isPlatformProvidedObjectName,
|
|
3810
|
+
PLATFORM_PROVIDED_OBJECT_NAMES
|
|
3811
|
+
} from "@objectstack/spec/system";
|
|
3812
|
+
var PLATFORM_NAMES = [...PLATFORM_PROVIDED_OBJECT_NAMES];
|
|
3813
|
+
var OBJECT_REFERENCE_UNKNOWN = "object-reference-unknown";
|
|
3814
|
+
var OBJECT_REFERENCE_UNREGISTERED_PLATFORM = "object-reference-unregistered-platform";
|
|
3815
|
+
function asArray24(v) {
|
|
3816
|
+
if (Array.isArray(v)) return v;
|
|
3817
|
+
if (v && typeof v === "object") {
|
|
3818
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
3819
|
+
}
|
|
3820
|
+
return [];
|
|
3821
|
+
}
|
|
3822
|
+
function strName6(v) {
|
|
3823
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
3824
|
+
}
|
|
3825
|
+
function isInterpolated(target) {
|
|
3826
|
+
if (target.includes("${")) return true;
|
|
3827
|
+
const open = target.indexOf("{");
|
|
3828
|
+
return open !== -1 && target.indexOf("}", open + 2) !== -1;
|
|
3829
|
+
}
|
|
3830
|
+
function suggest3(target, known) {
|
|
3831
|
+
let best;
|
|
3832
|
+
let bestScore = Infinity;
|
|
3833
|
+
for (const candidate of known) {
|
|
3834
|
+
const d = distance2(target, candidate);
|
|
3835
|
+
if (d < bestScore) {
|
|
3836
|
+
bestScore = d;
|
|
3837
|
+
best = candidate;
|
|
2323
3838
|
}
|
|
2324
|
-
|
|
2325
|
-
|
|
3839
|
+
}
|
|
3840
|
+
const limit = Math.max(2, Math.floor(target.length / 3));
|
|
3841
|
+
return best && bestScore <= limit ? ` Did you mean "${best}"?` : "";
|
|
3842
|
+
}
|
|
3843
|
+
function distance2(a, b) {
|
|
3844
|
+
const m = a.length;
|
|
3845
|
+
const n = b.length;
|
|
3846
|
+
if (m === 0) return n;
|
|
3847
|
+
if (n === 0) return m;
|
|
3848
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
3849
|
+
for (let i = 1; i <= m; i++) {
|
|
3850
|
+
const curr = [i, ...new Array(n).fill(0)];
|
|
3851
|
+
for (let j = 1; j <= n; j++) {
|
|
3852
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
3853
|
+
curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
2326
3854
|
}
|
|
2327
|
-
|
|
2328
|
-
|
|
3855
|
+
prev = curr;
|
|
3856
|
+
}
|
|
3857
|
+
return prev[n];
|
|
3858
|
+
}
|
|
3859
|
+
function validateObjectReferences(stack) {
|
|
3860
|
+
const findings = [];
|
|
3861
|
+
if (!stack || typeof stack !== "object") return findings;
|
|
3862
|
+
const objects = asArray24(stack.objects);
|
|
3863
|
+
const ownObjects = /* @__PURE__ */ new Set();
|
|
3864
|
+
for (const obj of objects) {
|
|
3865
|
+
const n = strName6(obj.name);
|
|
3866
|
+
if (n) ownObjects.add(n);
|
|
3867
|
+
}
|
|
3868
|
+
const check = (target, where, path, subject, fix) => {
|
|
3869
|
+
const name = strName6(target);
|
|
3870
|
+
if (!name) return;
|
|
3871
|
+
if (isInterpolated(name)) return;
|
|
3872
|
+
if (ownObjects.has(name)) return;
|
|
3873
|
+
if (isPlatformProvidedObjectName(name)) return;
|
|
3874
|
+
if (hasPlatformObjectPrefix(name)) {
|
|
3875
|
+
findings.push({
|
|
3876
|
+
severity: "warning",
|
|
3877
|
+
rule: OBJECT_REFERENCE_UNREGISTERED_PLATFORM,
|
|
3878
|
+
where,
|
|
3879
|
+
path,
|
|
3880
|
+
message: `${subject} "${name}" carries a platform namespace prefix, but no platform package, official plugin, or cloud runtime object registers that name \u2014 and this stack does not define it either. If nothing provides it at runtime the reference resolves to nothing and fails silently.` + suggest3(name, PLATFORM_NAMES),
|
|
3881
|
+
hint: `Check the spelling against the object the providing package actually registers (e.g. "sys_approval_request", not "sys_approval_process" \u2014 the process object was removed when approval became a flow node, ADR-0019). If a third-party package genuinely provides it, this warning is expected. ${fix}`
|
|
3882
|
+
});
|
|
3883
|
+
return;
|
|
2329
3884
|
}
|
|
2330
|
-
|
|
2331
|
-
|
|
3885
|
+
findings.push({
|
|
3886
|
+
severity: "error",
|
|
3887
|
+
rule: OBJECT_REFERENCE_UNKNOWN,
|
|
3888
|
+
where,
|
|
3889
|
+
path,
|
|
3890
|
+
message: `${subject} "${name}" resolves to no object defined in this stack. The reference is inert at runtime \u2014 nothing reports the miss.` + suggest3(name, ownObjects),
|
|
3891
|
+
hint: `Point it at one of this stack's objects, or at a platform object by its full name (the platform user object is "sys_user", not "user"). ${fix}` + (ownObjects.size > 0 ? ` Defined objects: ${[...ownObjects].sort().join(", ")}.` : "")
|
|
3892
|
+
});
|
|
3893
|
+
};
|
|
3894
|
+
const checkActionParams2 = (action, actionPath, actionLabel) => {
|
|
3895
|
+
const params = asArray24(action.params);
|
|
3896
|
+
for (let pi = 0; pi < params.length; pi++) {
|
|
3897
|
+
const param = params[pi];
|
|
3898
|
+
if (!param || typeof param !== "object") continue;
|
|
3899
|
+
const paramLabel = strName6(param.name) ?? strName6(param.field) ?? `#${pi}`;
|
|
3900
|
+
const where = `${actionLabel} \xB7 param "${paramLabel}"`;
|
|
3901
|
+
check(
|
|
3902
|
+
strName6(param.reference),
|
|
3903
|
+
where,
|
|
3904
|
+
`${actionPath}.params[${pi}].reference`,
|
|
3905
|
+
"record-picker target",
|
|
3906
|
+
"Without a resolvable target the picker degrades to a raw record-id text input."
|
|
3907
|
+
);
|
|
3908
|
+
check(
|
|
3909
|
+
strName6(param.objectOverride),
|
|
3910
|
+
where,
|
|
3911
|
+
`${actionPath}.params[${pi}].objectOverride`,
|
|
3912
|
+
"field-backed param object",
|
|
3913
|
+
"The param inherits type/options from a field on this object, so an unknown object leaves it untyped."
|
|
3914
|
+
);
|
|
2332
3915
|
}
|
|
3916
|
+
};
|
|
3917
|
+
const globalActions = asArray24(stack.actions);
|
|
3918
|
+
for (let ai = 0; ai < globalActions.length; ai++) {
|
|
3919
|
+
const action = globalActions[ai];
|
|
3920
|
+
if (!action || typeof action !== "object") continue;
|
|
3921
|
+
checkActionParams2(action, `actions[${ai}]`, `action "${strName6(action.name) ?? `#${ai}`}"`);
|
|
2333
3922
|
}
|
|
2334
|
-
|
|
3923
|
+
for (let oi = 0; oi < objects.length; oi++) {
|
|
3924
|
+
const obj = objects[oi];
|
|
3925
|
+
if (!obj || typeof obj !== "object") continue;
|
|
3926
|
+
const objName = strName6(obj.name) ?? `#${oi}`;
|
|
3927
|
+
const objActions = asArray24(obj.actions);
|
|
3928
|
+
for (let ai = 0; ai < objActions.length; ai++) {
|
|
3929
|
+
const action = objActions[ai];
|
|
3930
|
+
if (!action || typeof action !== "object") continue;
|
|
3931
|
+
checkActionParams2(
|
|
3932
|
+
action,
|
|
3933
|
+
`objects[${oi}].actions[${ai}]`,
|
|
3934
|
+
`object "${objName}" \xB7 action "${strName6(action.name) ?? `#${ai}`}"`
|
|
3935
|
+
);
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
const dashboards = asArray24(stack.dashboards);
|
|
3939
|
+
for (let di = 0; di < dashboards.length; di++) {
|
|
3940
|
+
const dash = dashboards[di];
|
|
3941
|
+
if (!dash || typeof dash !== "object") continue;
|
|
3942
|
+
const dashName = strName6(dash.name) ?? `#${di}`;
|
|
3943
|
+
const filters = asArray24(dash.globalFilters);
|
|
3944
|
+
for (let fi = 0; fi < filters.length; fi++) {
|
|
3945
|
+
const filter = filters[fi];
|
|
3946
|
+
if (!filter || typeof filter !== "object") continue;
|
|
3947
|
+
const optionsFrom = filter.optionsFrom;
|
|
3948
|
+
if (!optionsFrom || typeof optionsFrom !== "object") continue;
|
|
3949
|
+
check(
|
|
3950
|
+
strName6(optionsFrom.object),
|
|
3951
|
+
`dashboard "${dashName}" \xB7 filter "${strName6(filter.name) ?? `#${fi}`}"`,
|
|
3952
|
+
`dashboards[${di}].globalFilters[${fi}].optionsFrom.object`,
|
|
3953
|
+
"filter options source",
|
|
3954
|
+
"The dropdown fetches its options from this object; an unknown one renders an always-empty filter."
|
|
3955
|
+
);
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
const apps = asArray24(stack.apps);
|
|
3959
|
+
for (let ai = 0; ai < apps.length; ai++) {
|
|
3960
|
+
const app = apps[ai];
|
|
3961
|
+
if (!app || typeof app !== "object") continue;
|
|
3962
|
+
const appName = strName6(app.name) ?? `#${ai}`;
|
|
3963
|
+
const walkNav = (items, basePath) => {
|
|
3964
|
+
const navItems = asArray24(items);
|
|
3965
|
+
for (let ni = 0; ni < navItems.length; ni++) {
|
|
3966
|
+
const nav = navItems[ni];
|
|
3967
|
+
if (!nav || typeof nav !== "object") continue;
|
|
3968
|
+
const navId = strName6(nav.id) ?? `#${ni}`;
|
|
3969
|
+
const where = `app "${appName}" \xB7 nav "${navId}"`;
|
|
3970
|
+
const navPath = `${basePath}[${ni}]`;
|
|
3971
|
+
check(
|
|
3972
|
+
strName6(nav.requiresObject),
|
|
3973
|
+
where,
|
|
3974
|
+
`${navPath}.requiresObject`,
|
|
3975
|
+
"capability gate object",
|
|
3976
|
+
"The entry is hidden unless this object is registered, so a typo hides it permanently \u2014 and it suppresses the nav cross-reference check that would have caught the target."
|
|
3977
|
+
);
|
|
3978
|
+
if (nav.requiresObject && strName6(nav.objectName)) {
|
|
3979
|
+
check(
|
|
3980
|
+
strName6(nav.objectName),
|
|
3981
|
+
where,
|
|
3982
|
+
`${navPath}.objectName`,
|
|
3983
|
+
"navigation target",
|
|
3984
|
+
"Declaring `requiresObject` exempts this target from the build-time check, so it is only verified here."
|
|
3985
|
+
);
|
|
3986
|
+
}
|
|
3987
|
+
if (Array.isArray(nav.children)) walkNav(nav.children, `${navPath}.children`);
|
|
3988
|
+
}
|
|
3989
|
+
};
|
|
3990
|
+
walkNav(app.navigation, `apps[${ai}].navigation`);
|
|
3991
|
+
const areas = asArray24(app.areas);
|
|
3992
|
+
for (let ri = 0; ri < areas.length; ri++) {
|
|
3993
|
+
walkNav(areas[ri]?.navigation, `apps[${ai}].areas[${ri}].navigation`);
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
return findings;
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
// src/validate-action-name-refs.ts
|
|
4000
|
+
var ACTION_NAME_UNDEFINED = "action-name-undefined";
|
|
4001
|
+
function asArray25(v) {
|
|
4002
|
+
if (Array.isArray(v)) return v;
|
|
4003
|
+
if (v && typeof v === "object") {
|
|
4004
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
4005
|
+
}
|
|
4006
|
+
return [];
|
|
4007
|
+
}
|
|
4008
|
+
function strName7(v) {
|
|
4009
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
4010
|
+
}
|
|
4011
|
+
function strList(v) {
|
|
4012
|
+
return Array.isArray(v) ? v.filter((x) => typeof x === "string" && x.length > 0) : [];
|
|
4013
|
+
}
|
|
4014
|
+
function distance3(a, b) {
|
|
4015
|
+
const m = a.length;
|
|
4016
|
+
const n = b.length;
|
|
4017
|
+
if (m === 0) return n;
|
|
4018
|
+
if (n === 0) return m;
|
|
4019
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
4020
|
+
for (let i = 1; i <= m; i++) {
|
|
4021
|
+
const curr = [i, ...new Array(n).fill(0)];
|
|
4022
|
+
for (let j = 1; j <= n; j++) {
|
|
4023
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
4024
|
+
curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
4025
|
+
}
|
|
4026
|
+
prev = curr;
|
|
4027
|
+
}
|
|
4028
|
+
return prev[n];
|
|
4029
|
+
}
|
|
4030
|
+
function suggest4(target, known) {
|
|
4031
|
+
let best;
|
|
4032
|
+
let bestScore = Infinity;
|
|
4033
|
+
for (const candidate of known) {
|
|
4034
|
+
const d = distance3(target, candidate);
|
|
4035
|
+
if (d < bestScore) {
|
|
4036
|
+
bestScore = d;
|
|
4037
|
+
best = candidate;
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
const limit = Math.max(2, Math.floor(target.length / 3));
|
|
4041
|
+
return best && bestScore <= limit ? ` Did you mean "${best}"?` : "";
|
|
4042
|
+
}
|
|
4043
|
+
function collectActionNames(stack) {
|
|
4044
|
+
const names = /* @__PURE__ */ new Set();
|
|
4045
|
+
for (const action of asArray25(stack.actions)) {
|
|
4046
|
+
const n = strName7(action?.name);
|
|
4047
|
+
if (n) names.add(n);
|
|
4048
|
+
}
|
|
4049
|
+
for (const obj of asArray25(stack.objects)) {
|
|
4050
|
+
if (!obj || typeof obj !== "object") continue;
|
|
4051
|
+
for (const action of asArray25(obj.actions)) {
|
|
4052
|
+
const n = strName7(action?.name);
|
|
4053
|
+
if (n) names.add(n);
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
return names;
|
|
4057
|
+
}
|
|
4058
|
+
function validateActionNameRefs(stack) {
|
|
4059
|
+
const findings = [];
|
|
4060
|
+
if (!stack || typeof stack !== "object") return findings;
|
|
4061
|
+
const known = collectActionNames(stack);
|
|
4062
|
+
const check = (name, where, path, surface) => {
|
|
4063
|
+
if (known.has(name)) return;
|
|
4064
|
+
findings.push({
|
|
4065
|
+
severity: "error",
|
|
4066
|
+
rule: ACTION_NAME_UNDEFINED,
|
|
4067
|
+
where,
|
|
4068
|
+
path,
|
|
4069
|
+
message: `${surface} names action "${name}", which is defined by no action in this stack (neither \`stack.actions\` nor any object's \`actions\`). The button renders and does nothing when clicked \u2014 a dead affordance the runtime cannot dispatch.` + suggest4(name, known),
|
|
4070
|
+
hint: `Define an action named "${name}" (in \`stack.actions\` or the object's \`actions\`) with the location this surface needs, remove the reference, or ignore this if the action is contributed by another installed package.` + (known.size > 0 ? ` Defined actions: ${[...known].sort().join(", ")}.` : "")
|
|
4071
|
+
});
|
|
4072
|
+
};
|
|
4073
|
+
const views = asArray25(stack.views);
|
|
4074
|
+
for (let vi = 0; vi < views.length; vi++) {
|
|
4075
|
+
const view = views[vi];
|
|
4076
|
+
if (!view || typeof view !== "object") continue;
|
|
4077
|
+
const viewName = strName7(view.name) ?? strName7(view.object) ?? `#${vi}`;
|
|
4078
|
+
const checkListContainer = (container, label2, path) => {
|
|
4079
|
+
if (!container || typeof container !== "object") return;
|
|
4080
|
+
const list3 = container;
|
|
4081
|
+
for (const key of ["rowActions", "bulkActions"]) {
|
|
4082
|
+
const names = strList(list3[key]);
|
|
4083
|
+
for (let ai = 0; ai < names.length; ai++) {
|
|
4084
|
+
check(
|
|
4085
|
+
names[ai],
|
|
4086
|
+
`view "${viewName}" \xB7 ${label2} \xB7 ${key}`,
|
|
4087
|
+
`${path}.${key}[${ai}]`,
|
|
4088
|
+
key === "bulkActions" ? "Bulk-action menu" : "Row-action menu"
|
|
4089
|
+
);
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
};
|
|
4093
|
+
checkListContainer(view.list, "list", `views[${vi}].list`);
|
|
4094
|
+
const listViews = view.listViews;
|
|
4095
|
+
if (listViews && typeof listViews === "object" && !Array.isArray(listViews)) {
|
|
4096
|
+
for (const [key, lv] of Object.entries(listViews)) {
|
|
4097
|
+
checkListContainer(lv, `listViews.${key}`, `views[${vi}].listViews.${key}`);
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
const pages = asArray25(stack.pages);
|
|
4102
|
+
for (let pi = 0; pi < pages.length; pi++) {
|
|
4103
|
+
const page = pages[pi];
|
|
4104
|
+
if (!page || typeof page !== "object") continue;
|
|
4105
|
+
const pageName = strName7(page.name) ?? `#${pi}`;
|
|
4106
|
+
for (const { component, path } of walkPageComponents(page, `pages[${pi}]`)) {
|
|
4107
|
+
const props = component.properties;
|
|
4108
|
+
if (!props || typeof props !== "object") continue;
|
|
4109
|
+
const names = strList(props.actionNames);
|
|
4110
|
+
for (let ai = 0; ai < names.length; ai++) {
|
|
4111
|
+
check(
|
|
4112
|
+
names[ai],
|
|
4113
|
+
`page "${pageName}" \xB7 component "${strName7(component.type) ?? "?"}"`,
|
|
4114
|
+
`${path}.properties.actionNames[${ai}]`,
|
|
4115
|
+
"Quick-actions bar"
|
|
4116
|
+
);
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
}
|
|
4120
|
+
const apps = asArray25(stack.apps);
|
|
4121
|
+
for (let ai = 0; ai < apps.length; ai++) {
|
|
4122
|
+
const app = apps[ai];
|
|
4123
|
+
if (!app || typeof app !== "object") continue;
|
|
4124
|
+
const appName = strName7(app.name) ?? `#${ai}`;
|
|
4125
|
+
const walkNav = (items, basePath) => {
|
|
4126
|
+
const navItems = asArray25(items);
|
|
4127
|
+
for (let ni = 0; ni < navItems.length; ni++) {
|
|
4128
|
+
const nav = navItems[ni];
|
|
4129
|
+
if (!nav || typeof nav !== "object") continue;
|
|
4130
|
+
const navPath = `${basePath}[${ni}]`;
|
|
4131
|
+
const actionDef = nav.actionDef;
|
|
4132
|
+
const actionName = strName7(actionDef?.actionName);
|
|
4133
|
+
if (nav.type === "action" && actionName) {
|
|
4134
|
+
check(
|
|
4135
|
+
actionName,
|
|
4136
|
+
`app "${appName}" \xB7 nav "${strName7(nav.id) ?? `#${ni}`}"`,
|
|
4137
|
+
`${navPath}.actionDef.actionName`,
|
|
4138
|
+
"Navigation action item"
|
|
4139
|
+
);
|
|
4140
|
+
}
|
|
4141
|
+
if (Array.isArray(nav.children)) walkNav(nav.children, `${navPath}.children`);
|
|
4142
|
+
}
|
|
4143
|
+
};
|
|
4144
|
+
walkNav(app.navigation, `apps[${ai}].navigation`);
|
|
4145
|
+
const areas = asArray25(app.areas);
|
|
4146
|
+
for (let ri = 0; ri < areas.length; ri++) {
|
|
4147
|
+
walkNav(areas[ri]?.navigation, `apps[${ai}].areas[${ri}].navigation`);
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
return findings;
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4153
|
+
// src/validate-chart-bindings.ts
|
|
4154
|
+
var CHART_DIMENSION_UNKNOWN = "chart-dimension-unknown";
|
|
4155
|
+
var CHART_MEASURE_UNKNOWN = "chart-measure-unknown";
|
|
4156
|
+
var CHART_DATASET_UNKNOWN = "chart-dataset-unknown";
|
|
4157
|
+
var CHART_AXIS_NOT_SELECTED = "chart-axis-not-selected";
|
|
4158
|
+
function asArray26(v) {
|
|
4159
|
+
if (Array.isArray(v)) return v;
|
|
4160
|
+
if (v && typeof v === "object") {
|
|
4161
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
4162
|
+
}
|
|
4163
|
+
return [];
|
|
4164
|
+
}
|
|
4165
|
+
function strName8(v) {
|
|
4166
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
4167
|
+
}
|
|
4168
|
+
function strList2(v) {
|
|
4169
|
+
return Array.isArray(v) ? v.filter((x) => typeof x === "string" && x.length > 0) : [];
|
|
4170
|
+
}
|
|
4171
|
+
function isRec6(v) {
|
|
4172
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
4173
|
+
}
|
|
4174
|
+
function distance4(a, b) {
|
|
4175
|
+
const m = a.length;
|
|
4176
|
+
const n = b.length;
|
|
4177
|
+
if (m === 0) return n;
|
|
4178
|
+
if (n === 0) return m;
|
|
4179
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
4180
|
+
for (let i = 1; i <= m; i++) {
|
|
4181
|
+
const curr = [i, ...new Array(n).fill(0)];
|
|
4182
|
+
for (let j = 1; j <= n; j++) {
|
|
4183
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
4184
|
+
curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
4185
|
+
}
|
|
4186
|
+
prev = curr;
|
|
4187
|
+
}
|
|
4188
|
+
return prev[n];
|
|
4189
|
+
}
|
|
4190
|
+
function suggest5(target, known) {
|
|
4191
|
+
let best;
|
|
4192
|
+
let bestScore = Infinity;
|
|
4193
|
+
for (const c of known) {
|
|
4194
|
+
const d = distance4(target, c);
|
|
4195
|
+
if (d < bestScore) {
|
|
4196
|
+
bestScore = d;
|
|
4197
|
+
best = c;
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
const limit = Math.max(2, Math.floor(target.length / 3));
|
|
4201
|
+
return best && bestScore <= limit ? ` Did you mean "${best}"?` : "";
|
|
4202
|
+
}
|
|
4203
|
+
function list2(names) {
|
|
4204
|
+
const all = [...names].sort();
|
|
4205
|
+
return all.length ? all.join(", ") : "(none)";
|
|
4206
|
+
}
|
|
4207
|
+
function indexDatasets(stack) {
|
|
4208
|
+
const out = /* @__PURE__ */ new Map();
|
|
4209
|
+
for (const ds of asArray26(stack.datasets)) {
|
|
4210
|
+
const name = strName8(ds.name);
|
|
4211
|
+
if (!name) continue;
|
|
4212
|
+
const dimensions = /* @__PURE__ */ new Set();
|
|
4213
|
+
for (const d of asArray26(ds.dimensions)) {
|
|
4214
|
+
const n = strName8(d.name);
|
|
4215
|
+
if (n) dimensions.add(n);
|
|
4216
|
+
}
|
|
4217
|
+
const measures = /* @__PURE__ */ new Set();
|
|
4218
|
+
for (const m of asArray26(ds.measures)) {
|
|
4219
|
+
const n = strName8(m.name);
|
|
4220
|
+
if (n) measures.add(n);
|
|
4221
|
+
}
|
|
4222
|
+
out.set(name, { dimensions, measures });
|
|
4223
|
+
}
|
|
4224
|
+
return out;
|
|
4225
|
+
}
|
|
4226
|
+
function validateChartBindings(stack) {
|
|
4227
|
+
const findings = [];
|
|
4228
|
+
if (!stack || typeof stack !== "object") return findings;
|
|
4229
|
+
const datasets = indexDatasets(stack);
|
|
4230
|
+
if (datasets.size === 0 && !stack.reports && !stack.views && !stack.pages) return findings;
|
|
4231
|
+
const check = (binding) => {
|
|
4232
|
+
const dsName = binding.dataset;
|
|
4233
|
+
if (!dsName) return;
|
|
4234
|
+
const ds = datasets.get(dsName);
|
|
4235
|
+
if (!ds) {
|
|
4236
|
+
findings.push({
|
|
4237
|
+
severity: "error",
|
|
4238
|
+
rule: CHART_DATASET_UNKNOWN,
|
|
4239
|
+
where: binding.where,
|
|
4240
|
+
path: `${binding.path}.dataset`,
|
|
4241
|
+
message: `binds dataset "${dsName}", which resolves to no declared dataset \u2014 the chart has no data to render.`,
|
|
4242
|
+
hint: `Declared datasets: ${list2(datasets.keys())}.${suggest5(dsName, datasets.keys())} Define it with defineDataset() or fix the reference (ADR-0021).`
|
|
4243
|
+
});
|
|
4244
|
+
return;
|
|
4245
|
+
}
|
|
4246
|
+
const dimensionRef = (name, path) => {
|
|
4247
|
+
if (ds.dimensions.has(name)) return;
|
|
4248
|
+
findings.push({
|
|
4249
|
+
severity: "error",
|
|
4250
|
+
rule: CHART_DIMENSION_UNKNOWN,
|
|
4251
|
+
where: binding.where,
|
|
4252
|
+
path,
|
|
4253
|
+
message: `"${name}" is not a dimension declared by dataset "${dsName}". Post-ADR-0021 result rows are keyed by DIMENSION NAME, not the base field, so this axis renders with no categories.`,
|
|
4254
|
+
hint: `Dataset dimensions: ${list2(ds.dimensions)}.${suggest5(name, ds.dimensions)} Declare the dimension on the dataset, or bind an existing one.`
|
|
4255
|
+
});
|
|
4256
|
+
};
|
|
4257
|
+
const measureRef = (name, path, selected2) => {
|
|
4258
|
+
if (!ds.measures.has(name)) {
|
|
4259
|
+
findings.push({
|
|
4260
|
+
severity: "error",
|
|
4261
|
+
rule: CHART_MEASURE_UNKNOWN,
|
|
4262
|
+
where: binding.where,
|
|
4263
|
+
path,
|
|
4264
|
+
message: `"${name}" is not a measure declared by dataset "${dsName}". Post-ADR-0021 result rows are keyed by MEASURE NAME (e.g. "sum_amount"), not the base field (e.g. "amount"), so this series comes back empty.`,
|
|
4265
|
+
hint: `Dataset measures: ${list2(ds.measures)}.${suggest5(name, ds.measures)} Declare the measure on the dataset, or bind an existing one.`
|
|
4266
|
+
});
|
|
4267
|
+
return;
|
|
4268
|
+
}
|
|
4269
|
+
if (selected2 && selected2.size > 0 && !selected2.has(name)) {
|
|
4270
|
+
findings.push({
|
|
4271
|
+
severity: "warning",
|
|
4272
|
+
rule: CHART_AXIS_NOT_SELECTED,
|
|
4273
|
+
where: binding.where,
|
|
4274
|
+
path,
|
|
4275
|
+
message: `"${name}" is a declared measure of "${dsName}" but is not in this chart's selected values (${list2(selected2)}) \u2014 the query does not return it, so the series plots nothing.`,
|
|
4276
|
+
hint: `Add "${name}" to \`values\`, or point the axis at a selected measure.`
|
|
4277
|
+
});
|
|
4278
|
+
}
|
|
4279
|
+
};
|
|
4280
|
+
const dimSel = binding.dimensions;
|
|
4281
|
+
if (dimSel) {
|
|
4282
|
+
for (let i = 0; i < dimSel.names.length; i++) {
|
|
4283
|
+
dimensionRef(dimSel.names[i], `${dimSel.path}[${i}]`);
|
|
4284
|
+
}
|
|
4285
|
+
}
|
|
4286
|
+
const valSel = binding.values;
|
|
4287
|
+
const selected = new Set(valSel?.names ?? []);
|
|
4288
|
+
if (valSel) {
|
|
4289
|
+
for (let i = 0; i < valSel.names.length; i++) {
|
|
4290
|
+
measureRef(valSel.names[i], `${valSel.path}[${i}]`);
|
|
4291
|
+
}
|
|
4292
|
+
}
|
|
4293
|
+
if (binding.xAxis) dimensionRef(binding.xAxis.name, binding.xAxis.path);
|
|
4294
|
+
if (binding.yAxis) measureRef(binding.yAxis.name, binding.yAxis.path, selected);
|
|
4295
|
+
for (const s of binding.series ?? []) measureRef(s.name, s.path, selected);
|
|
4296
|
+
};
|
|
4297
|
+
const reports = asArray26(stack.reports);
|
|
4298
|
+
for (let ri = 0; ri < reports.length; ri++) {
|
|
4299
|
+
const report = reports[ri];
|
|
4300
|
+
if (!isRec6(report)) continue;
|
|
4301
|
+
const reportName = strName8(report.name) ?? `#${ri}`;
|
|
4302
|
+
const checkReportChart = (chart, dataset, values, where, path) => {
|
|
4303
|
+
if (!isRec6(chart)) return;
|
|
4304
|
+
check({
|
|
4305
|
+
dataset,
|
|
4306
|
+
// `values` is the report's measure SELECTION, not a chart ref; feeding
|
|
4307
|
+
// it in lets the yAxis "declared but not selected" check work without
|
|
4308
|
+
// reporting the selection itself twice.
|
|
4309
|
+
values: { names: values, path: `${path}.values` },
|
|
4310
|
+
xAxis: strName8(chart.xAxis) ? { name: strName8(chart.xAxis), path: `${path}.chart.xAxis` } : void 0,
|
|
4311
|
+
yAxis: strName8(chart.yAxis) ? { name: strName8(chart.yAxis), path: `${path}.chart.yAxis` } : void 0,
|
|
4312
|
+
series: asArray26(chart.series).map((s, si) => ({ name: strName8(s.name), path: `${path}.chart.series[${si}].name` })).filter((s) => !!s.name),
|
|
4313
|
+
where,
|
|
4314
|
+
path: `${path}.chart`
|
|
4315
|
+
});
|
|
4316
|
+
};
|
|
4317
|
+
checkReportChart(
|
|
4318
|
+
report.chart,
|
|
4319
|
+
strName8(report.dataset),
|
|
4320
|
+
strList2(report.values),
|
|
4321
|
+
`report "${reportName}" \xB7 chart`,
|
|
4322
|
+
`reports[${ri}]`
|
|
4323
|
+
);
|
|
4324
|
+
const blocks = Array.isArray(report.blocks) ? report.blocks : [];
|
|
4325
|
+
for (let bi = 0; bi < blocks.length; bi++) {
|
|
4326
|
+
const block = blocks[bi];
|
|
4327
|
+
if (!isRec6(block)) continue;
|
|
4328
|
+
checkReportChart(
|
|
4329
|
+
block.chart,
|
|
4330
|
+
strName8(block.dataset),
|
|
4331
|
+
strList2(block.values),
|
|
4332
|
+
`report "${reportName}" \xB7 block "${strName8(block.name) ?? `#${bi}`}" chart`,
|
|
4333
|
+
`reports[${ri}].blocks[${bi}]`
|
|
4334
|
+
);
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
const checkListChart = (container, where, path) => {
|
|
4338
|
+
if (!isRec6(container)) return;
|
|
4339
|
+
const chart = container.chart;
|
|
4340
|
+
if (!isRec6(chart)) return;
|
|
4341
|
+
check({
|
|
4342
|
+
dataset: strName8(chart.dataset),
|
|
4343
|
+
dimensions: { names: strList2(chart.dimensions), path: `${path}.chart.dimensions` },
|
|
4344
|
+
values: { names: strList2(chart.values), path: `${path}.chart.values` },
|
|
4345
|
+
where,
|
|
4346
|
+
path: `${path}.chart`
|
|
4347
|
+
});
|
|
4348
|
+
};
|
|
4349
|
+
const views = asArray26(stack.views);
|
|
4350
|
+
for (let vi = 0; vi < views.length; vi++) {
|
|
4351
|
+
const view = views[vi];
|
|
4352
|
+
if (!isRec6(view)) continue;
|
|
4353
|
+
const viewName = strName8(view.name) ?? strName8(view.objectName) ?? `#${vi}`;
|
|
4354
|
+
checkListChart(view.list, `view "${viewName}" \xB7 list chart`, `views[${vi}].list`);
|
|
4355
|
+
if (isRec6(view.listViews)) {
|
|
4356
|
+
for (const [key, lv] of Object.entries(view.listViews)) {
|
|
4357
|
+
checkListChart(lv, `view "${viewName}" \xB7 listViews.${key} chart`, `views[${vi}].listViews.${key}`);
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
const objects = asArray26(stack.objects);
|
|
4362
|
+
for (let oi = 0; oi < objects.length; oi++) {
|
|
4363
|
+
const obj = objects[oi];
|
|
4364
|
+
if (!isRec6(obj) || !isRec6(obj.listViews)) continue;
|
|
4365
|
+
const objName = strName8(obj.name) ?? `#${oi}`;
|
|
4366
|
+
for (const [key, lv] of Object.entries(obj.listViews)) {
|
|
4367
|
+
checkListChart(
|
|
4368
|
+
lv,
|
|
4369
|
+
`object "${objName}" \xB7 listViews.${key} chart`,
|
|
4370
|
+
`objects[${oi}].listViews.${key}`
|
|
4371
|
+
);
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
const pages = asArray26(stack.pages);
|
|
4375
|
+
for (let pi = 0; pi < pages.length; pi++) {
|
|
4376
|
+
const page = pages[pi];
|
|
4377
|
+
if (!isRec6(page)) continue;
|
|
4378
|
+
const pageName = strName8(page.name) ?? `#${pi}`;
|
|
4379
|
+
for (const { component, path } of walkPageComponents(page, `pages[${pi}]`)) {
|
|
4380
|
+
const props = isRec6(component.properties) ? component.properties : void 0;
|
|
4381
|
+
if (!props || !strName8(props.dataset)) continue;
|
|
4382
|
+
const axisRefs = asArray26(props.yAxis).map((a, ai) => ({ name: strName8(a.field), path: `${path}.properties.yAxis[${ai}].field` })).filter((a) => !!a.name);
|
|
4383
|
+
const seriesRefs = asArray26(props.series).map((s, si) => ({ name: strName8(s.name), path: `${path}.properties.series[${si}].name` })).filter((s) => !!s.name);
|
|
4384
|
+
check({
|
|
4385
|
+
dataset: strName8(props.dataset),
|
|
4386
|
+
dimensions: { names: strList2(props.dimensions), path: `${path}.properties.dimensions` },
|
|
4387
|
+
values: { names: strList2(props.values), path: `${path}.properties.values` },
|
|
4388
|
+
series: [...axisRefs, ...seriesRefs],
|
|
4389
|
+
where: `page "${pageName}" \xB7 ${strName8(component.type) ?? "chart"}`,
|
|
4390
|
+
path: `${path}.properties`
|
|
4391
|
+
});
|
|
4392
|
+
}
|
|
4393
|
+
}
|
|
4394
|
+
return findings;
|
|
4395
|
+
}
|
|
4396
|
+
|
|
4397
|
+
// src/validate-nav-access.ts
|
|
4398
|
+
import { isPlatformProvidedObjectName as isPlatformProvidedObjectName2 } from "@objectstack/spec/system";
|
|
4399
|
+
|
|
4400
|
+
// src/build-access-matrix.ts
|
|
4401
|
+
function asArray27(v) {
|
|
4402
|
+
if (Array.isArray(v)) return v;
|
|
4403
|
+
if (v && typeof v === "object") {
|
|
4404
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
4405
|
+
}
|
|
4406
|
+
return [];
|
|
4407
|
+
}
|
|
4408
|
+
function buildAccessMatrix(stack) {
|
|
4409
|
+
const entries = [];
|
|
4410
|
+
if (!stack || typeof stack !== "object") return { version: 1, entries };
|
|
4411
|
+
const owdByObject = /* @__PURE__ */ new Map();
|
|
4412
|
+
for (const obj of asArray27(stack.objects)) {
|
|
4413
|
+
const name = typeof obj.name === "string" ? obj.name : "";
|
|
4414
|
+
if (!name) continue;
|
|
4415
|
+
const owd = obj.sharingModel ?? obj.security?.sharingModel;
|
|
4416
|
+
if (typeof owd === "string") owdByObject.set(name, owd);
|
|
4417
|
+
}
|
|
4418
|
+
for (const ps of asArray27(stack.permissions)) {
|
|
4419
|
+
const psName = typeof ps.name === "string" ? ps.name : "";
|
|
4420
|
+
if (!psName) continue;
|
|
4421
|
+
const objects = ps.objects && typeof ps.objects === "object" ? ps.objects : {};
|
|
4422
|
+
for (const [objName, rawPerm] of Object.entries(objects)) {
|
|
4423
|
+
const p = rawPerm ?? {};
|
|
4424
|
+
const entry = {
|
|
4425
|
+
permissionSet: psName,
|
|
4426
|
+
object: objName,
|
|
4427
|
+
create: p.allowCreate === true,
|
|
4428
|
+
read: p.allowRead === true || p.viewAllRecords === true || p.modifyAllRecords === true,
|
|
4429
|
+
edit: p.allowEdit === true || p.modifyAllRecords === true,
|
|
4430
|
+
delete: p.allowDelete === true || p.modifyAllRecords === true,
|
|
4431
|
+
viewAllRecords: p.viewAllRecords === true,
|
|
4432
|
+
modifyAllRecords: p.modifyAllRecords === true
|
|
4433
|
+
};
|
|
4434
|
+
if (typeof p.readScope === "string") entry.readScope = p.readScope;
|
|
4435
|
+
if (typeof p.writeScope === "string") entry.writeScope = p.writeScope;
|
|
4436
|
+
const owd = owdByObject.get(objName);
|
|
4437
|
+
if (owd) entry.sharingModel = owd;
|
|
4438
|
+
entries.push(entry);
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
entries.sort(
|
|
4442
|
+
(a, b) => a.permissionSet === b.permissionSet ? a.object.localeCompare(b.object) : a.permissionSet.localeCompare(b.permissionSet)
|
|
4443
|
+
);
|
|
4444
|
+
return { version: 1, entries };
|
|
4445
|
+
}
|
|
4446
|
+
var BIT_LABELS = [
|
|
4447
|
+
["create", "create"],
|
|
4448
|
+
["read", "read"],
|
|
4449
|
+
["edit", "edit"],
|
|
4450
|
+
["delete", "delete"],
|
|
4451
|
+
["viewAllRecords", "View All Data"],
|
|
4452
|
+
["modifyAllRecords", "Modify All Data"]
|
|
4453
|
+
];
|
|
4454
|
+
function diffAccessMatrix(before, after) {
|
|
4455
|
+
const lines = [];
|
|
4456
|
+
const key = (e) => `${e.permissionSet}\0${e.object}`;
|
|
4457
|
+
const beforeMap = new Map((before?.entries ?? []).map((e) => [key(e), e]));
|
|
4458
|
+
const afterMap = new Map((after?.entries ?? []).map((e) => [key(e), e]));
|
|
4459
|
+
for (const [k, b] of beforeMap) {
|
|
4460
|
+
if (!afterMap.has(k)) {
|
|
4461
|
+
lines.push(`'${b.permissionSet}' loses ALL access to '${b.object}' (entry removed)`);
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
for (const [k, a] of afterMap) {
|
|
4465
|
+
const b = beforeMap.get(k);
|
|
4466
|
+
if (!b) {
|
|
4467
|
+
const grants = BIT_LABELS.filter(([bit]) => a[bit] === true).map(([, label2]) => label2);
|
|
4468
|
+
lines.push(`'${a.permissionSet}' gains access to '${a.object}' (${grants.join(", ") || "no bits set"})`);
|
|
4469
|
+
continue;
|
|
4470
|
+
}
|
|
4471
|
+
for (const [bit, label2] of BIT_LABELS) {
|
|
4472
|
+
if (b[bit] !== a[bit]) {
|
|
4473
|
+
lines.push(`'${a.permissionSet}' ${a[bit] ? "gains" : "loses"} ${label2} on '${a.object}'`);
|
|
4474
|
+
}
|
|
4475
|
+
}
|
|
4476
|
+
if ((b.readScope ?? "own") !== (a.readScope ?? "own")) {
|
|
4477
|
+
lines.push(`'${a.permissionSet}' read depth on '${a.object}': ${b.readScope ?? "own"} \u2192 ${a.readScope ?? "own"}`);
|
|
4478
|
+
}
|
|
4479
|
+
if ((b.writeScope ?? "own") !== (a.writeScope ?? "own")) {
|
|
4480
|
+
lines.push(`'${a.permissionSet}' write depth on '${a.object}': ${b.writeScope ?? "own"} \u2192 ${a.writeScope ?? "own"}`);
|
|
4481
|
+
}
|
|
4482
|
+
if ((b.sharingModel ?? "") !== (a.sharingModel ?? "")) {
|
|
4483
|
+
lines.push(`'${a.object}' record baseline (OWD): ${b.sharingModel ?? "(unset)"} \u2192 ${a.sharingModel ?? "(unset)"} (affects every principal)`);
|
|
4484
|
+
}
|
|
4485
|
+
}
|
|
4486
|
+
return lines;
|
|
4487
|
+
}
|
|
4488
|
+
|
|
4489
|
+
// src/validate-nav-access.ts
|
|
4490
|
+
var NAV_OBJECT_UNGRANTED = "nav-object-ungranted";
|
|
4491
|
+
function asArray28(v) {
|
|
4492
|
+
if (Array.isArray(v)) return v;
|
|
4493
|
+
if (v && typeof v === "object") {
|
|
4494
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
4495
|
+
}
|
|
4496
|
+
return [];
|
|
4497
|
+
}
|
|
4498
|
+
function strName9(v) {
|
|
4499
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
4500
|
+
}
|
|
4501
|
+
function collectNavExposures(stack) {
|
|
4502
|
+
const out = [];
|
|
4503
|
+
const apps = asArray28(stack.apps);
|
|
4504
|
+
for (let ai = 0; ai < apps.length; ai++) {
|
|
4505
|
+
const app = apps[ai];
|
|
4506
|
+
if (!app || typeof app !== "object") continue;
|
|
4507
|
+
const appName = strName9(app.name) ?? `#${ai}`;
|
|
4508
|
+
const walk = (items, basePath) => {
|
|
4509
|
+
const navItems = asArray28(items);
|
|
4510
|
+
for (let ni = 0; ni < navItems.length; ni++) {
|
|
4511
|
+
const nav = navItems[ni];
|
|
4512
|
+
if (!nav || typeof nav !== "object") continue;
|
|
4513
|
+
const navPath = `${basePath}[${ni}]`;
|
|
4514
|
+
const objectName = strName9(nav.objectName);
|
|
4515
|
+
if (nav.type === "object" && objectName) {
|
|
4516
|
+
out.push({
|
|
4517
|
+
objectName,
|
|
4518
|
+
where: `app "${appName}" \xB7 nav "${strName9(nav.id) ?? `#${ni}`}"`,
|
|
4519
|
+
path: `${navPath}.objectName`
|
|
4520
|
+
});
|
|
4521
|
+
}
|
|
4522
|
+
if (Array.isArray(nav.children)) walk(nav.children, `${navPath}.children`);
|
|
4523
|
+
}
|
|
4524
|
+
};
|
|
4525
|
+
walk(app.navigation, `apps[${ai}].navigation`);
|
|
4526
|
+
const areas = asArray28(app.areas);
|
|
4527
|
+
for (let ri = 0; ri < areas.length; ri++) {
|
|
4528
|
+
walk(areas[ri]?.navigation, `apps[${ai}].areas[${ri}].navigation`);
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
return out;
|
|
4532
|
+
}
|
|
4533
|
+
function validateNavAccess(stack) {
|
|
4534
|
+
const findings = [];
|
|
4535
|
+
if (!stack || typeof stack !== "object") return findings;
|
|
4536
|
+
const permissionSets = asArray28(stack.permissions);
|
|
4537
|
+
if (permissionSets.length === 0) return findings;
|
|
4538
|
+
const exposures = collectNavExposures(stack);
|
|
4539
|
+
if (exposures.length === 0) return findings;
|
|
4540
|
+
const ownObjects = /* @__PURE__ */ new Set();
|
|
4541
|
+
for (const obj of asArray28(stack.objects)) {
|
|
4542
|
+
const n = strName9(obj.name);
|
|
4543
|
+
if (n) ownObjects.add(n);
|
|
4544
|
+
}
|
|
4545
|
+
const readable = /* @__PURE__ */ new Set();
|
|
4546
|
+
for (const entry of buildAccessMatrix(stack).entries) {
|
|
4547
|
+
if (entry.read) readable.add(entry.object);
|
|
4548
|
+
}
|
|
4549
|
+
if (readable.has("*")) return findings;
|
|
4550
|
+
const reported = /* @__PURE__ */ new Set();
|
|
4551
|
+
for (const exposure of exposures) {
|
|
4552
|
+
const { objectName } = exposure;
|
|
4553
|
+
if (reported.has(objectName)) continue;
|
|
4554
|
+
if (isPlatformProvidedObjectName2(objectName)) continue;
|
|
4555
|
+
if (!ownObjects.has(objectName)) continue;
|
|
4556
|
+
if (readable.has(objectName)) continue;
|
|
4557
|
+
reported.add(objectName);
|
|
4558
|
+
findings.push({
|
|
4559
|
+
severity: "warning",
|
|
4560
|
+
rule: NAV_OBJECT_UNGRANTED,
|
|
4561
|
+
where: exposure.where,
|
|
4562
|
+
path: exposure.path,
|
|
4563
|
+
message: `navigation exposes object "${objectName}", but no permission set this stack declares grants read on it \u2014 the entry renders, and opening it fails permission-denied for every principal except one holding the platform's built-in wildcard admin set. It works when you browse as an administrator and breaks for the users the app ships permission sets for.`,
|
|
4564
|
+
hint: `Add "${objectName}" to a permission set's \`objects\` with \`allowRead: true\` (or \`viewAllRecords\`), gate the entry with \`requiredPermissions\`/\`visible\` if it is meant for admins only, or drop it. Ignore this if a permission set from another installed package grants it.`
|
|
4565
|
+
});
|
|
4566
|
+
}
|
|
4567
|
+
return findings;
|
|
4568
|
+
}
|
|
4569
|
+
|
|
4570
|
+
// src/validate-translation-references.ts
|
|
4571
|
+
import { hasPlatformObjectPrefix as hasPlatformObjectPrefix2, isPlatformProvidedObjectName as isPlatformProvidedObjectName3 } from "@objectstack/spec/system";
|
|
4572
|
+
var TRANSLATION_TARGET_UNKNOWN = "translation-target-unknown";
|
|
4573
|
+
var TRANSLATION_OPTION_KEY_UNKNOWN = "translation-option-key-unknown";
|
|
4574
|
+
function isRec7(v) {
|
|
4575
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
4576
|
+
}
|
|
4577
|
+
function asArray29(v) {
|
|
4578
|
+
if (Array.isArray(v)) return v;
|
|
4579
|
+
if (isRec7(v)) return Object.entries(v).map(([name, def]) => ({ name, ...isRec7(def) ? def : {} }));
|
|
4580
|
+
return [];
|
|
4581
|
+
}
|
|
4582
|
+
function strName10(v) {
|
|
4583
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
4584
|
+
}
|
|
4585
|
+
function distance5(a, b) {
|
|
4586
|
+
const m = a.length;
|
|
4587
|
+
const n = b.length;
|
|
4588
|
+
if (m === 0) return n;
|
|
4589
|
+
if (n === 0) return m;
|
|
4590
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
4591
|
+
for (let i = 1; i <= m; i++) {
|
|
4592
|
+
const curr = [i, ...new Array(n).fill(0)];
|
|
4593
|
+
for (let j = 1; j <= n; j++) {
|
|
4594
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
4595
|
+
curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
4596
|
+
}
|
|
4597
|
+
prev = curr;
|
|
4598
|
+
}
|
|
4599
|
+
return prev[n];
|
|
4600
|
+
}
|
|
4601
|
+
function suggest6(target, known) {
|
|
4602
|
+
const names = [...known];
|
|
4603
|
+
const segmentMatch = names.find(
|
|
4604
|
+
(candidate) => candidate.endsWith(`_${target}`) || candidate.startsWith(`${target}_`)
|
|
4605
|
+
);
|
|
4606
|
+
if (segmentMatch) return ` Did you mean "${segmentMatch}"?`;
|
|
4607
|
+
let best;
|
|
4608
|
+
let bestScore = Infinity;
|
|
4609
|
+
for (const candidate of names) {
|
|
4610
|
+
const d = distance5(target, candidate);
|
|
4611
|
+
if (d < bestScore) {
|
|
4612
|
+
bestScore = d;
|
|
4613
|
+
best = candidate;
|
|
4614
|
+
}
|
|
4615
|
+
}
|
|
4616
|
+
const limit = Math.max(2, Math.floor(target.length / 3));
|
|
4617
|
+
return best && bestScore <= limit ? ` Did you mean "${best}"?` : "";
|
|
4618
|
+
}
|
|
4619
|
+
function listNames(names, max = 12) {
|
|
4620
|
+
const all = [...names].sort();
|
|
4621
|
+
if (all.length === 0) return "";
|
|
4622
|
+
const shown = all.slice(0, max).join(", ");
|
|
4623
|
+
return all.length > max ? `${shown}, \u2026 (${all.length} total)` : shown;
|
|
4624
|
+
}
|
|
4625
|
+
var IMPLICIT_FIELDS = /* @__PURE__ */ new Set([
|
|
4626
|
+
...SYSTEM_FIELDS,
|
|
4627
|
+
"_id",
|
|
4628
|
+
"name",
|
|
4629
|
+
"space"
|
|
4630
|
+
]);
|
|
4631
|
+
function emptyFacts() {
|
|
4632
|
+
return { fields: /* @__PURE__ */ new Map(), views: /* @__PURE__ */ new Set(), actions: /* @__PURE__ */ new Map(), sections: /* @__PURE__ */ new Set() };
|
|
4633
|
+
}
|
|
4634
|
+
function collectViewRecord(view, factsFor) {
|
|
4635
|
+
const recordObject = viewObjectName(view);
|
|
4636
|
+
const bindingOf = (container) => viewObjectName(container) ?? recordObject;
|
|
4637
|
+
const addView = (objectName, name) => {
|
|
4638
|
+
if (objectName && name) factsFor(objectName).views.add(name);
|
|
4639
|
+
};
|
|
4640
|
+
const listBinding = isRec7(view.list) ? bindingOf(view.list) : void 0;
|
|
4641
|
+
if (isRec7(view.list)) addView(listBinding, strName10(view.list.name));
|
|
4642
|
+
addView(recordObject ?? listBinding, strName10(view.name));
|
|
4643
|
+
for (const key of ["listViews", "formViews"]) {
|
|
4644
|
+
const container = view[key];
|
|
4645
|
+
if (!isRec7(container)) continue;
|
|
4646
|
+
for (const [subKey, sub] of Object.entries(container)) {
|
|
4647
|
+
if (!isRec7(sub)) continue;
|
|
4648
|
+
const binding = bindingOf(sub) ?? listBinding;
|
|
4649
|
+
addView(binding, subKey);
|
|
4650
|
+
addView(binding, strName10(sub.name));
|
|
4651
|
+
if (binding) {
|
|
4652
|
+
for (const section of asArray29(sub.sections)) {
|
|
4653
|
+
const sectionName = strName10(section.name);
|
|
4654
|
+
if (sectionName) factsFor(binding).sections.add(sectionName);
|
|
4655
|
+
}
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4659
|
+
const sectionBinding = recordObject ?? listBinding;
|
|
4660
|
+
if (sectionBinding) {
|
|
4661
|
+
for (const section of asArray29(view.sections)) {
|
|
4662
|
+
const sectionName = strName10(section.name);
|
|
4663
|
+
if (sectionName) factsFor(sectionBinding).sections.add(sectionName);
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
}
|
|
4667
|
+
function viewObjectName(view) {
|
|
4668
|
+
return strName10(view.objectName) ?? strName10(view.object) ?? (isRec7(view.data) ? strName10(view.data.object) : void 0);
|
|
4669
|
+
}
|
|
4670
|
+
function readOptions(field) {
|
|
4671
|
+
const raw = field.options;
|
|
4672
|
+
const values = /* @__PURE__ */ new Set();
|
|
4673
|
+
const byLabel = /* @__PURE__ */ new Map();
|
|
4674
|
+
if (Array.isArray(raw)) {
|
|
4675
|
+
for (const opt of raw) {
|
|
4676
|
+
if (typeof opt === "string") {
|
|
4677
|
+
values.add(opt);
|
|
4678
|
+
continue;
|
|
4679
|
+
}
|
|
4680
|
+
if (!isRec7(opt)) continue;
|
|
4681
|
+
const value = strName10(opt.value);
|
|
4682
|
+
if (!value) continue;
|
|
4683
|
+
values.add(value);
|
|
4684
|
+
const label2 = strName10(opt.label);
|
|
4685
|
+
if (label2) byLabel.set(label2.toLowerCase(), value);
|
|
4686
|
+
}
|
|
4687
|
+
} else if (isRec7(raw)) {
|
|
4688
|
+
for (const [value, label2] of Object.entries(raw)) {
|
|
4689
|
+
values.add(value);
|
|
4690
|
+
if (typeof label2 === "string" && label2.length > 0) byLabel.set(label2.toLowerCase(), value);
|
|
4691
|
+
}
|
|
4692
|
+
} else {
|
|
4693
|
+
return void 0;
|
|
4694
|
+
}
|
|
4695
|
+
return values.size > 0 ? { values, byLabel } : void 0;
|
|
4696
|
+
}
|
|
4697
|
+
function buildUniverse(stack) {
|
|
4698
|
+
const objects = /* @__PURE__ */ new Map();
|
|
4699
|
+
const factsFor = (name) => {
|
|
4700
|
+
let facts = objects.get(name);
|
|
4701
|
+
if (!facts) {
|
|
4702
|
+
facts = emptyFacts();
|
|
4703
|
+
objects.set(name, facts);
|
|
4704
|
+
}
|
|
4705
|
+
return facts;
|
|
4706
|
+
};
|
|
4707
|
+
for (const obj of asArray29(stack.objects)) {
|
|
4708
|
+
const objectName = strName10(obj.name);
|
|
4709
|
+
if (!objectName) continue;
|
|
4710
|
+
const facts = factsFor(objectName);
|
|
4711
|
+
for (const field of asArray29(obj.fields)) {
|
|
4712
|
+
const fieldName = strName10(field.name);
|
|
4713
|
+
if (fieldName) facts.fields.set(fieldName, field);
|
|
4714
|
+
}
|
|
4715
|
+
for (const action of asArray29(obj.actions)) {
|
|
4716
|
+
const actionName = strName10(action.name);
|
|
4717
|
+
if (actionName) facts.actions.set(actionName, action);
|
|
4718
|
+
}
|
|
4719
|
+
for (const view of asArray29(obj.views)) {
|
|
4720
|
+
collectViewRecord({ ...view, object: strName10(view.object) ?? objectName }, factsFor);
|
|
4721
|
+
}
|
|
4722
|
+
collectViewRecord({ object: objectName, listViews: obj.listViews }, factsFor);
|
|
4723
|
+
for (const group of asArray29(obj.fieldGroups)) {
|
|
4724
|
+
const key = strName10(group.key) ?? strName10(group.name);
|
|
4725
|
+
if (key) facts.sections.add(key);
|
|
4726
|
+
}
|
|
4727
|
+
}
|
|
4728
|
+
for (const view of asArray29(stack.views)) {
|
|
4729
|
+
collectViewRecord(view, factsFor);
|
|
4730
|
+
}
|
|
4731
|
+
const pages = asArray29(stack.pages);
|
|
4732
|
+
for (let pi = 0; pi < pages.length; pi++) {
|
|
4733
|
+
for (const walked of walkPageComponents(pages[pi], `pages[${pi}]`)) {
|
|
4734
|
+
if (!walked.objectName) continue;
|
|
4735
|
+
const props = isRec7(walked.component.properties) ? walked.component.properties : void 0;
|
|
4736
|
+
if (!props) continue;
|
|
4737
|
+
for (const section of asArray29(props.sections)) {
|
|
4738
|
+
const sectionName = strName10(section.name);
|
|
4739
|
+
if (sectionName) factsFor(walked.objectName).sections.add(sectionName);
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4742
|
+
}
|
|
4743
|
+
const globalActions = /* @__PURE__ */ new Map();
|
|
4744
|
+
const actionOwners = /* @__PURE__ */ new Map();
|
|
4745
|
+
for (const action of asArray29(stack.actions)) {
|
|
4746
|
+
const actionName = strName10(action.name);
|
|
4747
|
+
if (!actionName) continue;
|
|
4748
|
+
const owner = strName10(action.objectName) ?? strName10(action.object);
|
|
4749
|
+
if (owner) {
|
|
4750
|
+
factsFor(owner).actions.set(actionName, action);
|
|
4751
|
+
actionOwners.set(actionName, owner);
|
|
4752
|
+
} else {
|
|
4753
|
+
globalActions.set(actionName, action);
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4756
|
+
for (const [objectName, facts] of objects) {
|
|
4757
|
+
for (const actionName of facts.actions.keys()) {
|
|
4758
|
+
if (!actionOwners.has(actionName)) actionOwners.set(actionName, objectName);
|
|
4759
|
+
}
|
|
4760
|
+
}
|
|
4761
|
+
const apps = /* @__PURE__ */ new Map();
|
|
4762
|
+
for (const app of asArray29(stack.apps)) {
|
|
4763
|
+
const appName = strName10(app.name);
|
|
4764
|
+
if (!appName) continue;
|
|
4765
|
+
const navIds = apps.get(appName) ?? /* @__PURE__ */ new Set();
|
|
4766
|
+
const walkNav = (items) => {
|
|
4767
|
+
for (const item of asArray29(items)) {
|
|
4768
|
+
const id = strName10(item.id);
|
|
4769
|
+
if (id) navIds.add(id);
|
|
4770
|
+
if (item.children) walkNav(item.children);
|
|
4771
|
+
}
|
|
4772
|
+
};
|
|
4773
|
+
walkNav(app.navigation);
|
|
4774
|
+
for (const area of asArray29(app.areas)) {
|
|
4775
|
+
const areaId = strName10(area.id);
|
|
4776
|
+
if (areaId) navIds.add(areaId);
|
|
4777
|
+
walkNav(area.navigation);
|
|
4778
|
+
}
|
|
4779
|
+
apps.set(appName, navIds);
|
|
4780
|
+
}
|
|
4781
|
+
const dashboards = /* @__PURE__ */ new Map();
|
|
4782
|
+
for (const dash of asArray29(stack.dashboards)) {
|
|
4783
|
+
const dashName = strName10(dash.name);
|
|
4784
|
+
if (!dashName) continue;
|
|
4785
|
+
const widgets = /* @__PURE__ */ new Set();
|
|
4786
|
+
for (const widget of asArray29(dash.widgets)) {
|
|
4787
|
+
const id = strName10(widget.id) ?? strName10(widget.name);
|
|
4788
|
+
if (id) widgets.add(id);
|
|
4789
|
+
}
|
|
4790
|
+
const actions = /* @__PURE__ */ new Set();
|
|
4791
|
+
const headerActions = [
|
|
4792
|
+
...asArray29(isRec7(dash.header) ? dash.header.actions : void 0),
|
|
4793
|
+
...asArray29(dash.actions)
|
|
4794
|
+
];
|
|
4795
|
+
for (const action of headerActions) {
|
|
4796
|
+
const key = strName10(action.actionUrl) ?? strName10(action.url) ?? strName10(action.name);
|
|
4797
|
+
if (key) actions.add(key);
|
|
4798
|
+
}
|
|
4799
|
+
dashboards.set(dashName, { widgets, actions });
|
|
4800
|
+
}
|
|
4801
|
+
return { objects, apps, dashboards, globalActions, actionOwners };
|
|
4802
|
+
}
|
|
4803
|
+
function localePath(bundleIndex, locale) {
|
|
4804
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(locale) ? `translations[${bundleIndex}].${locale}` : `translations[${bundleIndex}]["${locale}"]`;
|
|
4805
|
+
}
|
|
4806
|
+
function validateTranslationReferences(stack) {
|
|
4807
|
+
const findings = [];
|
|
4808
|
+
if (!isRec7(stack)) return findings;
|
|
4809
|
+
const bundles = Array.isArray(stack.translations) ? stack.translations : [];
|
|
4810
|
+
if (bundles.length === 0) return findings;
|
|
4811
|
+
const universe = buildUniverse(stack);
|
|
4812
|
+
const orphan = (where, path, message, hint) => {
|
|
4813
|
+
findings.push({ severity: "warning", rule: TRANSLATION_TARGET_UNKNOWN, where, path, message, hint });
|
|
4814
|
+
};
|
|
4815
|
+
for (let bi = 0; bi < bundles.length; bi++) {
|
|
4816
|
+
const bundle = bundles[bi];
|
|
4817
|
+
if (!isRec7(bundle)) continue;
|
|
4818
|
+
for (const [locale, rawData] of Object.entries(bundle)) {
|
|
4819
|
+
if (!isRec7(rawData)) continue;
|
|
4820
|
+
const base = localePath(bi, locale);
|
|
4821
|
+
const inLocale = `locale "${locale}"`;
|
|
4822
|
+
for (const [objectName, rawNode] of Object.entries(asRecord(rawData.objects))) {
|
|
4823
|
+
if (!isRec7(rawNode)) continue;
|
|
4824
|
+
const objPath = `${base}.objects.${objectName}`;
|
|
4825
|
+
const facts = universe.objects.get(objectName);
|
|
4826
|
+
if (!facts) {
|
|
4827
|
+
if (isPlatformProvidedObjectName3(objectName)) continue;
|
|
4828
|
+
orphan(
|
|
4829
|
+
`${inLocale} \xB7 object "${objectName}"`,
|
|
4830
|
+
objPath,
|
|
4831
|
+
hasPlatformObjectPrefix2(objectName) ? `Translations are keyed to "${objectName}", which carries a platform namespace prefix but is registered by no platform package, official plugin, or cloud runtime object \u2014 and this stack does not define it either. Nothing resolves these keys.` + suggest6(objectName, universe.objects.keys()) : `Translations are keyed to "${objectName}", which no object in this stack defines. The resolver looks up keys derived from the metadata, so this whole subtree is dead weight \u2014 every label it carries renders untranslated.` + suggest6(objectName, universe.objects.keys()),
|
|
4832
|
+
`Rename the key to the object it was written for, drop it, or ignore this if the object is contributed by another installed package.` + (universe.objects.size > 0 ? ` Defined objects: ${listNames(universe.objects.keys())}.` : "")
|
|
4833
|
+
);
|
|
4834
|
+
continue;
|
|
4835
|
+
}
|
|
4836
|
+
for (const [fieldName, rawField] of Object.entries(asRecord(rawNode.fields))) {
|
|
4837
|
+
const fieldPath = `${objPath}.fields.${fieldName}`;
|
|
4838
|
+
const field = facts.fields.get(fieldName);
|
|
4839
|
+
if (!field) {
|
|
4840
|
+
if (IMPLICIT_FIELDS.has(fieldName)) continue;
|
|
4841
|
+
orphan(
|
|
4842
|
+
`${inLocale} \xB7 object "${objectName}" \xB7 field "${fieldName}"`,
|
|
4843
|
+
fieldPath,
|
|
4844
|
+
`Translations are keyed to field "${fieldName}", which object "${objectName}" does not declare. The label renders untranslated in this locale \u2014 and because every neighbouring field DOES resolve, the hole reads as a styling quirk rather than a missing translation.` + suggest6(fieldName, facts.fields.keys()),
|
|
4845
|
+
`Point the key at a declared field, or drop it if the field was removed or renamed.` + (facts.fields.size > 0 ? ` Declared fields: ${listNames(facts.fields.keys())}.` : "")
|
|
4846
|
+
);
|
|
4847
|
+
continue;
|
|
4848
|
+
}
|
|
4849
|
+
if (!isRec7(rawField)) continue;
|
|
4850
|
+
checkOptionKeys(findings, {
|
|
4851
|
+
optionMap: rawField.options,
|
|
4852
|
+
field,
|
|
4853
|
+
fieldName,
|
|
4854
|
+
objectName,
|
|
4855
|
+
path: `${fieldPath}.options`,
|
|
4856
|
+
where: `${inLocale} \xB7 object "${objectName}" \xB7 field "${fieldName}"`
|
|
4857
|
+
});
|
|
4858
|
+
}
|
|
4859
|
+
for (const viewName of Object.keys(asRecord(rawNode._views))) {
|
|
4860
|
+
if (facts.views.has(viewName)) continue;
|
|
4861
|
+
orphan(
|
|
4862
|
+
`${inLocale} \xB7 object "${objectName}" \xB7 view "${viewName}"`,
|
|
4863
|
+
`${objPath}._views.${viewName}`,
|
|
4864
|
+
`Translations are keyed to view "${viewName}", which no view of object "${objectName}" declares. The view tab keeps its source-locale label.` + suggest6(viewName, facts.views),
|
|
4865
|
+
`Match the key to the view's \`name\` (not its label), or drop it.` + (facts.views.size > 0 ? ` Declared views: ${listNames(facts.views)}.` : "")
|
|
4866
|
+
);
|
|
4867
|
+
}
|
|
4868
|
+
for (const sectionName of Object.keys(asRecord(rawNode._sections))) {
|
|
4869
|
+
if (facts.sections.has(sectionName)) continue;
|
|
4870
|
+
orphan(
|
|
4871
|
+
`${inLocale} \xB7 object "${objectName}" \xB7 section "${sectionName}"`,
|
|
4872
|
+
`${objPath}._sections.${sectionName}`,
|
|
4873
|
+
`Translations are keyed to section "${sectionName}", which nothing on object "${objectName}" declares \u2014 no \`fieldGroups[].key\`, no named form-view section, no named \`record:details\` section. The section heading stays in the source locale.` + suggest6(sectionName, facts.sections),
|
|
4874
|
+
`Sections are translatable only through a STABLE NAME: give the group/section a \`key\`/\`name\` and use it here, or drop the translation.` + (facts.sections.size > 0 ? ` Declared sections: ${listNames(facts.sections)}.` : ` Object "${objectName}" declares no named section at all.`)
|
|
4875
|
+
);
|
|
4876
|
+
}
|
|
4877
|
+
for (const [actionName, rawAction] of Object.entries(asRecord(rawNode._actions))) {
|
|
4878
|
+
const actionPath = `${objPath}._actions.${actionName}`;
|
|
4879
|
+
const action = facts.actions.get(actionName);
|
|
4880
|
+
if (!action) {
|
|
4881
|
+
orphan(
|
|
4882
|
+
`${inLocale} \xB7 object "${objectName}" \xB7 action "${actionName}"`,
|
|
4883
|
+
actionPath,
|
|
4884
|
+
`Translations are keyed to action "${actionName}", which is defined by neither object "${objectName}"'s \`actions\` nor a \`stack.actions\` entry bound to it. The button keeps its source-locale label.` + suggest6(actionName, facts.actions.keys()),
|
|
4885
|
+
`Match the key to a defined action name, move it under the object that owns the action, or drop it.` + (facts.actions.size > 0 ? ` Actions on this object: ${listNames(facts.actions.keys())}.` : "")
|
|
4886
|
+
);
|
|
4887
|
+
continue;
|
|
4888
|
+
}
|
|
4889
|
+
checkActionParams(findings, {
|
|
4890
|
+
rawAction,
|
|
4891
|
+
action,
|
|
4892
|
+
path: actionPath,
|
|
4893
|
+
where: `${inLocale} \xB7 object "${objectName}" \xB7 action "${actionName}"`,
|
|
4894
|
+
subject: `action "${actionName}"`
|
|
4895
|
+
});
|
|
4896
|
+
}
|
|
4897
|
+
}
|
|
4898
|
+
for (const [actionName, rawAction] of Object.entries(asRecord(rawData.globalActions))) {
|
|
4899
|
+
const actionPath = `${base}.globalActions.${actionName}`;
|
|
4900
|
+
const action = universe.globalActions.get(actionName);
|
|
4901
|
+
if (!action) {
|
|
4902
|
+
const owner = universe.actionOwners.get(actionName);
|
|
4903
|
+
orphan(
|
|
4904
|
+
`${inLocale} \xB7 global action "${actionName}"`,
|
|
4905
|
+
actionPath,
|
|
4906
|
+
owner ? `Action "${actionName}" is bound to object "${owner}", so the resolver looks it up under \`objects.${owner}._actions.${actionName}\` \u2014 never under \`globalActions\`, which is only consulted for object-less actions. This key is never read.` : `Translations are keyed to global action "${actionName}", which no object-less action in this stack defines. The button keeps its source-locale label.` + suggest6(actionName, universe.globalActions.keys()),
|
|
4907
|
+
owner ? `Move these keys under \`objects.${owner}._actions.${actionName}\`.` : `Match the key to an object-less action's name, or drop it.` + (universe.globalActions.size > 0 ? ` Object-less actions: ${listNames(universe.globalActions.keys())}.` : "")
|
|
4908
|
+
);
|
|
4909
|
+
continue;
|
|
4910
|
+
}
|
|
4911
|
+
checkActionParams(findings, {
|
|
4912
|
+
rawAction,
|
|
4913
|
+
action,
|
|
4914
|
+
path: actionPath,
|
|
4915
|
+
where: `${inLocale} \xB7 global action "${actionName}"`,
|
|
4916
|
+
subject: `action "${actionName}"`
|
|
4917
|
+
});
|
|
4918
|
+
}
|
|
4919
|
+
for (const [appName, rawApp] of Object.entries(asRecord(rawData.apps))) {
|
|
4920
|
+
const appPath = `${base}.apps.${appName}`;
|
|
4921
|
+
const navIds = universe.apps.get(appName);
|
|
4922
|
+
if (!navIds) {
|
|
4923
|
+
orphan(
|
|
4924
|
+
`${inLocale} \xB7 app "${appName}"`,
|
|
4925
|
+
appPath,
|
|
4926
|
+
`Translations are keyed to app "${appName}", which this stack does not define. The app launcher shows the source-locale label.` + suggest6(appName, universe.apps.keys()),
|
|
4927
|
+
`Match the key to an app's \`name\`, or drop it.` + (universe.apps.size > 0 ? ` Defined apps: ${listNames(universe.apps.keys())}.` : "")
|
|
4928
|
+
);
|
|
4929
|
+
continue;
|
|
4930
|
+
}
|
|
4931
|
+
if (!isRec7(rawApp)) continue;
|
|
4932
|
+
for (const navId of Object.keys(asRecord(rawApp.navigation))) {
|
|
4933
|
+
if (navIds.has(navId)) continue;
|
|
4934
|
+
orphan(
|
|
4935
|
+
`${inLocale} \xB7 app "${appName}" \xB7 navigation "${navId}"`,
|
|
4936
|
+
`${appPath}.navigation.${navId}`,
|
|
4937
|
+
`Translations are keyed to navigation item "${navId}", which app "${appName}" does not declare. The menu entry keeps its source-locale label.` + suggest6(navId, navIds),
|
|
4938
|
+
`Match the key to the navigation item's \`id\`, or drop it.` + (navIds.size > 0 ? ` Declared navigation ids: ${listNames(navIds)}.` : "")
|
|
4939
|
+
);
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
for (const [dashName, rawDash] of Object.entries(asRecord(rawData.dashboards))) {
|
|
4943
|
+
const dashPath = `${base}.dashboards.${dashName}`;
|
|
4944
|
+
const dash = universe.dashboards.get(dashName);
|
|
4945
|
+
if (!dash) {
|
|
4946
|
+
orphan(
|
|
4947
|
+
`${inLocale} \xB7 dashboard "${dashName}"`,
|
|
4948
|
+
dashPath,
|
|
4949
|
+
`Translations are keyed to dashboard "${dashName}", which this stack does not define. The dashboard title stays in the source locale.` + suggest6(dashName, universe.dashboards.keys()),
|
|
4950
|
+
`Match the key to a dashboard's \`name\`, or drop it.` + (universe.dashboards.size > 0 ? ` Defined dashboards: ${listNames(universe.dashboards.keys())}.` : "")
|
|
4951
|
+
);
|
|
4952
|
+
continue;
|
|
4953
|
+
}
|
|
4954
|
+
if (!isRec7(rawDash)) continue;
|
|
4955
|
+
for (const widgetId of Object.keys(asRecord(rawDash.widgets))) {
|
|
4956
|
+
if (dash.widgets.has(widgetId)) continue;
|
|
4957
|
+
orphan(
|
|
4958
|
+
`${inLocale} \xB7 dashboard "${dashName}" \xB7 widget "${widgetId}"`,
|
|
4959
|
+
`${dashPath}.widgets.${widgetId}`,
|
|
4960
|
+
`Translations are keyed to widget "${widgetId}", which dashboard "${dashName}" does not declare. The widget title stays in the source locale.` + suggest6(widgetId, dash.widgets),
|
|
4961
|
+
`Match the key to the widget's \`id\`, or drop it.` + (dash.widgets.size > 0 ? ` Declared widget ids: ${listNames(dash.widgets)}.` : "")
|
|
4962
|
+
);
|
|
4963
|
+
}
|
|
4964
|
+
for (const actionKey of Object.keys(asRecord(rawDash.actions))) {
|
|
4965
|
+
if (dash.actions.has(actionKey)) continue;
|
|
4966
|
+
orphan(
|
|
4967
|
+
`${inLocale} \xB7 dashboard "${dashName}" \xB7 action "${actionKey}"`,
|
|
4968
|
+
`${dashPath}.actions.${actionKey}`,
|
|
4969
|
+
`Translations are keyed to header action "${actionKey}", which dashboard "${dashName}" does not declare. The button keeps its source-locale label.` + suggest6(actionKey, dash.actions),
|
|
4970
|
+
`Header-action translations are keyed by the action's \`actionUrl\`, not its label.` + (dash.actions.size > 0 ? ` Declared header actions: ${listNames(dash.actions)}.` : "")
|
|
4971
|
+
);
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
}
|
|
4975
|
+
}
|
|
4976
|
+
return findings;
|
|
4977
|
+
}
|
|
4978
|
+
function asRecord(v) {
|
|
4979
|
+
return isRec7(v) ? v : {};
|
|
4980
|
+
}
|
|
4981
|
+
function checkOptionKeys(findings, ctx) {
|
|
4982
|
+
const optionKeys = Object.keys(asRecord(ctx.optionMap));
|
|
4983
|
+
if (optionKeys.length === 0) return;
|
|
4984
|
+
const declared = readOptions(ctx.field);
|
|
4985
|
+
if (!declared) {
|
|
4986
|
+
findings.push({
|
|
4987
|
+
severity: "warning",
|
|
4988
|
+
rule: TRANSLATION_OPTION_KEY_UNKNOWN,
|
|
4989
|
+
where: ctx.where,
|
|
4990
|
+
path: ctx.path,
|
|
4991
|
+
message: `Option translations are keyed under field "${ctx.fieldName}" of object "${ctx.objectName}", which declares no \`options\` at all (field type "${strName10(ctx.field.type) ?? "unknown"}"). Nothing reads this map.`,
|
|
4992
|
+
hint: `Declare the options on the field, move the translations to the field that owns them, or drop them.`
|
|
4993
|
+
});
|
|
4994
|
+
return;
|
|
4995
|
+
}
|
|
4996
|
+
for (const key of optionKeys) {
|
|
4997
|
+
if (declared.values.has(key)) continue;
|
|
4998
|
+
const byLabel = declared.byLabel.get(key.toLowerCase());
|
|
4999
|
+
findings.push({
|
|
5000
|
+
severity: "warning",
|
|
5001
|
+
rule: TRANSLATION_OPTION_KEY_UNKNOWN,
|
|
5002
|
+
where: ctx.where,
|
|
5003
|
+
path: `${ctx.path}.${key}`,
|
|
5004
|
+
message: byLabel ? `Option translation is keyed by the DISPLAY LABEL "${key}" instead of the stored value "${byLabel}". The resolver looks the option up by value, so this entry is never found and the option renders with its source-locale label.` : `Option translation is keyed by "${key}", which is not one of the values declared by field "${ctx.objectName}.${ctx.fieldName}". The option renders untranslated.` + suggest6(key, declared.values),
|
|
5005
|
+
hint: byLabel ? `Rename the key to "${byLabel}".` : `Option keys are the stored \`value\`, not the label and not a variant spelling (\`direct_mail\`, not \`direct-mail\`). Declared values: ${listNames(declared.values)}.`
|
|
5006
|
+
});
|
|
5007
|
+
}
|
|
5008
|
+
}
|
|
5009
|
+
function checkActionParams(findings, ctx) {
|
|
5010
|
+
const rawParams = Object.keys(asRecord(isRec7(ctx.rawAction) ? ctx.rawAction.params : void 0));
|
|
5011
|
+
if (rawParams.length === 0) return;
|
|
5012
|
+
const declared = /* @__PURE__ */ new Set();
|
|
5013
|
+
for (const param of asArray29(ctx.action.params)) {
|
|
5014
|
+
const name = strName10(param.name) ?? strName10(param.field);
|
|
5015
|
+
if (name) declared.add(name);
|
|
5016
|
+
}
|
|
5017
|
+
for (const paramName of rawParams) {
|
|
5018
|
+
if (declared.has(paramName)) continue;
|
|
5019
|
+
findings.push({
|
|
5020
|
+
severity: "warning",
|
|
5021
|
+
rule: TRANSLATION_TARGET_UNKNOWN,
|
|
5022
|
+
where: `${ctx.where} \xB7 param "${paramName}"`,
|
|
5023
|
+
path: `${ctx.path}.params.${paramName}`,
|
|
5024
|
+
message: `Translations are keyed to parameter "${paramName}", which ${ctx.subject} does not declare. The parameter's label and help text render untranslated in the action dialog.` + suggest6(paramName, declared),
|
|
5025
|
+
hint: `Match the key to a declared param \`name\`, or drop it.` + (declared.size > 0 ? ` Declared params: ${listNames(declared)}.` : "")
|
|
5026
|
+
});
|
|
5027
|
+
}
|
|
5028
|
+
}
|
|
5029
|
+
|
|
5030
|
+
// src/validate-ai-surface-affinity.ts
|
|
5031
|
+
var AI_SKILL_SURFACE_MISMATCH = "ai-skill-surface-mismatch";
|
|
5032
|
+
function asArray30(v) {
|
|
5033
|
+
if (Array.isArray(v)) return v.filter((x) => !!x && typeof x === "object");
|
|
5034
|
+
if (v && typeof v === "object") {
|
|
5035
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
5036
|
+
}
|
|
5037
|
+
return [];
|
|
5038
|
+
}
|
|
5039
|
+
function strName11(v) {
|
|
5040
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
5041
|
+
}
|
|
5042
|
+
function surfaceOf(v) {
|
|
5043
|
+
return typeof v === "string" && v.length > 0 ? v : "ask";
|
|
5044
|
+
}
|
|
5045
|
+
function validateAiSurfaceAffinity(stack) {
|
|
5046
|
+
const findings = [];
|
|
5047
|
+
if (!stack || typeof stack !== "object") return findings;
|
|
5048
|
+
const skillsByName = /* @__PURE__ */ new Map();
|
|
5049
|
+
for (const skill of asArray30(stack.skills)) {
|
|
5050
|
+
const n = strName11(skill.name);
|
|
5051
|
+
if (n) skillsByName.set(n, skill);
|
|
5052
|
+
}
|
|
5053
|
+
const agents = asArray30(stack.agents);
|
|
5054
|
+
for (let ai = 0; ai < agents.length; ai++) {
|
|
5055
|
+
const agent = agents[ai];
|
|
5056
|
+
const agentName = strName11(agent.name) ?? `#${ai}`;
|
|
5057
|
+
const agentSurface = surfaceOf(agent.surface);
|
|
5058
|
+
const skillRefs = Array.isArray(agent.skills) ? agent.skills : [];
|
|
5059
|
+
for (let si = 0; si < skillRefs.length; si++) {
|
|
5060
|
+
const ref = strName11(skillRefs[si]);
|
|
5061
|
+
if (!ref) continue;
|
|
5062
|
+
const skill = skillsByName.get(ref);
|
|
5063
|
+
if (!skill) continue;
|
|
5064
|
+
const skillSurface = surfaceOf(skill.surface);
|
|
5065
|
+
if (skillSurface === "both" || skillSurface === agentSurface) continue;
|
|
5066
|
+
findings.push({
|
|
5067
|
+
severity: "error",
|
|
5068
|
+
rule: AI_SKILL_SURFACE_MISMATCH,
|
|
5069
|
+
where: `agent "${agentName}" \xB7 skills`,
|
|
5070
|
+
path: `agents[${ai}].skills[${si}]`,
|
|
5071
|
+
message: `Agent "${agentName}" (surface: '${agentSurface}') references skill "${ref}" (surface: '${skillSurface}') \u2014 incompatible affinity (ADR-0064 \xA73). The runtime refuses this binding with a load error, so chatting with this agent fails at request time even though the stack parses and validates cleanly.`,
|
|
5072
|
+
hint: `A skill may only attach to an agent whose surface it matches. Move "${ref}" to a '${skillSurface}'-surface agent, change its \`surface\` to '${agentSurface}', or \u2014 only if it is a genuinely shared, read-only capability \u2014 declare \`surface: 'both'\`.`
|
|
5073
|
+
});
|
|
5074
|
+
}
|
|
5075
|
+
}
|
|
5076
|
+
return findings;
|
|
5077
|
+
}
|
|
5078
|
+
|
|
5079
|
+
// src/validate-ai-tool-references.ts
|
|
5080
|
+
import { PLATFORM_PROVIDED_TOOL_NAMES, PLATFORM_TOOL_FAMILY_PREFIXES } from "@objectstack/spec/system";
|
|
5081
|
+
var AI_SKILL_TOOL_UNRESOLVED = "ai-skill-tool-unresolved";
|
|
5082
|
+
function asArray31(v) {
|
|
5083
|
+
if (Array.isArray(v)) return v.filter((x) => !!x && typeof x === "object");
|
|
5084
|
+
if (v && typeof v === "object") {
|
|
5085
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
5086
|
+
}
|
|
5087
|
+
return [];
|
|
5088
|
+
}
|
|
5089
|
+
function strName12(v) {
|
|
5090
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
5091
|
+
}
|
|
5092
|
+
function distance6(a, b) {
|
|
5093
|
+
const m = a.length;
|
|
5094
|
+
const n = b.length;
|
|
5095
|
+
if (m === 0) return n;
|
|
5096
|
+
if (n === 0) return m;
|
|
5097
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
5098
|
+
for (let i = 1; i <= m; i++) {
|
|
5099
|
+
const curr = [i, ...new Array(n).fill(0)];
|
|
5100
|
+
for (let j = 1; j <= n; j++) {
|
|
5101
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
5102
|
+
curr[j] = Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost);
|
|
5103
|
+
}
|
|
5104
|
+
prev = curr;
|
|
5105
|
+
}
|
|
5106
|
+
return prev[n];
|
|
5107
|
+
}
|
|
5108
|
+
function suggest7(target, known) {
|
|
5109
|
+
for (const prefix of PLATFORM_TOOL_FAMILY_PREFIXES) {
|
|
5110
|
+
if (known.has(`${prefix}${target}`)) return ` Did you mean "${prefix}${target}"?`;
|
|
5111
|
+
}
|
|
5112
|
+
let best;
|
|
5113
|
+
let bestScore = Infinity;
|
|
5114
|
+
for (const candidate of known) {
|
|
5115
|
+
const d = distance6(target, candidate);
|
|
5116
|
+
if (d < bestScore) {
|
|
5117
|
+
bestScore = d;
|
|
5118
|
+
best = candidate;
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
const limit = Math.max(2, Math.floor(target.length / 3));
|
|
5122
|
+
return best && bestScore <= limit ? ` Did you mean "${best}"?` : "";
|
|
5123
|
+
}
|
|
5124
|
+
var HEADLESS_ACTION_TYPES = /* @__PURE__ */ new Set(["script", "api", "flow"]);
|
|
5125
|
+
function materialisesAsTool(action) {
|
|
5126
|
+
const ai = action.ai;
|
|
5127
|
+
if (!ai || typeof ai !== "object") return false;
|
|
5128
|
+
const aiRec = ai;
|
|
5129
|
+
if (aiRec.exposed !== true) return false;
|
|
5130
|
+
if (!strName12(aiRec.description)) return false;
|
|
5131
|
+
const type = strName12(action.type);
|
|
5132
|
+
if (!type || !HEADLESS_ACTION_TYPES.has(type)) return false;
|
|
5133
|
+
if (type === "script") return Boolean(action.target || action.body);
|
|
5134
|
+
return Boolean(action.target);
|
|
5135
|
+
}
|
|
5136
|
+
function collectToolUniverse(stack) {
|
|
5137
|
+
const universe = new Set(PLATFORM_PROVIDED_TOOL_NAMES);
|
|
5138
|
+
for (const tool of asArray31(stack.tools)) {
|
|
5139
|
+
const n = strName12(tool.name);
|
|
5140
|
+
if (n) universe.add(n);
|
|
5141
|
+
}
|
|
5142
|
+
const addActionFamily = (actions) => {
|
|
5143
|
+
for (const action of asArray31(actions)) {
|
|
5144
|
+
const n = strName12(action.name);
|
|
5145
|
+
if (n && materialisesAsTool(action)) universe.add(`action_${n}`);
|
|
5146
|
+
}
|
|
5147
|
+
};
|
|
5148
|
+
addActionFamily(stack.actions);
|
|
5149
|
+
for (const obj of asArray31(stack.objects)) {
|
|
5150
|
+
addActionFamily(obj.actions);
|
|
5151
|
+
}
|
|
5152
|
+
return universe;
|
|
5153
|
+
}
|
|
5154
|
+
function collectUnexposedActionNames(stack) {
|
|
5155
|
+
const names = /* @__PURE__ */ new Set();
|
|
5156
|
+
const scan = (actions) => {
|
|
5157
|
+
for (const action of asArray31(actions)) {
|
|
5158
|
+
const n = strName12(action.name);
|
|
5159
|
+
if (n && !materialisesAsTool(action)) names.add(n);
|
|
5160
|
+
}
|
|
5161
|
+
};
|
|
5162
|
+
scan(stack.actions);
|
|
5163
|
+
for (const obj of asArray31(stack.objects)) scan(obj.actions);
|
|
5164
|
+
return names;
|
|
5165
|
+
}
|
|
5166
|
+
function validateAiToolReferences(stack) {
|
|
5167
|
+
const findings = [];
|
|
5168
|
+
if (!stack || typeof stack !== "object") return findings;
|
|
5169
|
+
const universe = collectToolUniverse(stack);
|
|
5170
|
+
const unexposedActions = collectUnexposedActionNames(stack);
|
|
5171
|
+
const resolves = (ref) => {
|
|
5172
|
+
if (ref.endsWith("*")) {
|
|
5173
|
+
const prefix = ref.slice(0, -1);
|
|
5174
|
+
for (const name of universe) {
|
|
5175
|
+
if (name.startsWith(prefix)) return true;
|
|
5176
|
+
}
|
|
5177
|
+
return false;
|
|
5178
|
+
}
|
|
5179
|
+
return universe.has(ref);
|
|
5180
|
+
};
|
|
5181
|
+
const skills = asArray31(stack.skills);
|
|
5182
|
+
for (let si = 0; si < skills.length; si++) {
|
|
5183
|
+
const skill = skills[si];
|
|
5184
|
+
const skillName = strName12(skill.name) ?? `#${si}`;
|
|
5185
|
+
const refs = Array.isArray(skill.tools) ? skill.tools : [];
|
|
5186
|
+
for (let ti = 0; ti < refs.length; ti++) {
|
|
5187
|
+
const ref = strName12(refs[ti]);
|
|
5188
|
+
if (!ref || resolves(ref)) continue;
|
|
5189
|
+
const isPattern = ref.endsWith("*");
|
|
5190
|
+
const unexposed = !isPattern && ref.startsWith("action_") && unexposedActions.has(ref.slice("action_".length)) ? ref.slice("action_".length) : void 0;
|
|
5191
|
+
findings.push({
|
|
5192
|
+
severity: "warning",
|
|
5193
|
+
rule: AI_SKILL_TOOL_UNRESOLVED,
|
|
5194
|
+
where: `skill "${skillName}" \xB7 tools`,
|
|
5195
|
+
path: `skills[${si}].tools[${ti}]`,
|
|
5196
|
+
message: isPattern ? `Skill "${skillName}" subscribes to tool family "${ref}", which matches nothing this stack can resolve (no declared tool, no platform tool, and no AI-exposed declarative action materialises into it). The subscription contributes zero tools at runtime.` : unexposed ? `Skill "${skillName}" references tool "${ref}", but the action "${unexposed}" does not become an AI tool: the runtime materialises \`action_<name>\` only for an action that opts in with \`ai.exposed: true\` + \`ai.description\` (ADR-0011) AND has a headless path (type \`script\`/\`api\`/\`flow\` with a target or body \u2014 \`url\`/\`modal\`/\`form\` are UI-only). The reference is dropped at runtime, so the skill promises a capability the agent cannot call.` : `Skill "${skillName}" references tool "${ref}", which resolves to nothing this stack can see: not a \`stack.tools\` record, not a platform-registered tool, and not a materialised action tool (\`action_<name>\`). The runtime silently drops the reference, so the skill's instructions claim a capability the agent does not have \u2014 the assistant will improvise or fail when asked to use it.` + suggest7(ref, universe),
|
|
5197
|
+
hint: unexposed ? `Either opt "${unexposed}" in \u2014 set \`ai: { exposed: true, description: '\u2026' }\` (\u226540 chars, LLM-facing) and give it a headless type \u2014 or drop the reference and have the skill's instructions recommend the UI action instead. A \`modal\`/\`form\`/\`url\` action stays human-driven by design; that is a legitimate answer, not a gap.` : `Back "${ref}" with a real executable: declare a declarative action (or flow), opt it in with \`ai.exposed: true\` + \`ai.description\`, and reference its materialised tool (\`action_<name>\` \u2014 the ADR-0109 default path, no tool record needed); or reference a platform tool by its registered name; or remove the reference and the instructions that mention it. Ignore this only if a runtime plugin outside the platform registry provides "${ref}". Family prefixes materialised by the runtime: ${PLATFORM_TOOL_FAMILY_PREFIXES.join(", ")}.`
|
|
5198
|
+
});
|
|
5199
|
+
}
|
|
5200
|
+
}
|
|
5201
|
+
return findings;
|
|
5202
|
+
}
|
|
5203
|
+
|
|
5204
|
+
// src/validate-ai-agent-authoring.ts
|
|
5205
|
+
var AGENT_AUTHORING_WITHDRAWN = "agent-authoring-withdrawn";
|
|
5206
|
+
function asArray32(v) {
|
|
5207
|
+
if (Array.isArray(v)) return v.filter((x) => !!x && typeof x === "object");
|
|
5208
|
+
if (v && typeof v === "object") {
|
|
5209
|
+
return Object.entries(v).map(([name, def]) => ({ name, ...def }));
|
|
5210
|
+
}
|
|
5211
|
+
return [];
|
|
5212
|
+
}
|
|
5213
|
+
function strName13(v) {
|
|
5214
|
+
return typeof v === "string" && v.length > 0 ? v : void 0;
|
|
5215
|
+
}
|
|
5216
|
+
var PLATFORM_AGENT_NAMES = /* @__PURE__ */ new Set(["ask", "build", "data_chat", "metadata_assistant"]);
|
|
5217
|
+
function validateAiAgentAuthoring(stack) {
|
|
5218
|
+
const findings = [];
|
|
5219
|
+
if (!stack || typeof stack !== "object") return findings;
|
|
5220
|
+
const agents = asArray32(stack.agents);
|
|
5221
|
+
for (let ai = 0; ai < agents.length; ai++) {
|
|
5222
|
+
const agent = agents[ai];
|
|
5223
|
+
const name = strName13(agent.name) ?? `#${ai}`;
|
|
5224
|
+
const isPlatformName = PLATFORM_AGENT_NAMES.has(name);
|
|
5225
|
+
const skillCount = Array.isArray(agent.skills) ? agent.skills.length : 0;
|
|
5226
|
+
findings.push({
|
|
5227
|
+
severity: "warning",
|
|
5228
|
+
rule: AGENT_AUTHORING_WITHDRAWN,
|
|
5229
|
+
where: `agent "${name}"`,
|
|
5230
|
+
path: `agents[${ai}]`,
|
|
5231
|
+
message: isPlatformName ? `This stack declares an agent named "${name}", which is a PLATFORM agent id. The runtime serves its own record for that name and ignores this one \u2014 the declaration has no effect and will drift from the platform's definition.` : `This stack declares the agent "${name}", but tenant/app-package agents were withdrawn (ADR-0063 \xA72): the kernel ships exactly two agents (\`ask\`, \`build\`) and the surface the user is in binds one. The runtime filters this record out of the agent catalog and refuses to load it, so it never runs \u2014 it parses, validates, and ships as inert metadata.`,
|
|
5232
|
+
hint: isPlatformName ? `Remove the declaration; the platform owns "${name}". Extend it with skills instead.` : `Delete the agent and express its capability as skills. Everything an agent carried that a skill does not is persona text: move the useful parts of \`instructions\` into the skills' own instructions.` + (skillCount > 0 ? ` The ${skillCount} skill${skillCount === 1 ? "" : "s"} this agent references already carry the capability \u2014 they attach to the platform agent by \`surface\` affinity, so nothing is lost by dropping the persona.` : ``)
|
|
5233
|
+
});
|
|
5234
|
+
}
|
|
5235
|
+
return findings;
|
|
5236
|
+
}
|
|
5237
|
+
|
|
5238
|
+
// src/validate-hook-body-writes.ts
|
|
5239
|
+
import { createRequire as createRequire3 } from "module";
|
|
5240
|
+
import { findClosestMatches, formatSuggestion } from "@objectstack/spec/shared";
|
|
5241
|
+
var cachedTs2 = null;
|
|
5242
|
+
function loadTypeScript2() {
|
|
5243
|
+
if (cachedTs2) return cachedTs2;
|
|
5244
|
+
const anchor = typeof import.meta !== "undefined" && import.meta.url ? import.meta.url : typeof __filename !== "undefined" ? __filename : process.cwd() + "/";
|
|
5245
|
+
try {
|
|
5246
|
+
cachedTs2 = createRequire3(anchor)("typescript");
|
|
5247
|
+
} catch (err) {
|
|
5248
|
+
throw new Error(
|
|
5249
|
+
`@objectstack/lint: checking an L2 (language:'js') hook body requires the "typescript" package, which could not be loaded (${err instanceof Error ? err.message : String(err)}). It is a declared dependency of @objectstack/lint \u2014 if this deployment prunes packages, keep "typescript" in the image; it is only loaded when a hook with a JS body is validated.`
|
|
5250
|
+
);
|
|
5251
|
+
}
|
|
5252
|
+
return cachedTs2;
|
|
5253
|
+
}
|
|
5254
|
+
var HOOK_BODY_WRITE_UNKNOWN_FIELD = "hook-body-write-unknown-field";
|
|
5255
|
+
var HOOK_BODY_WRITE_PATTERNS = [
|
|
5256
|
+
{
|
|
5257
|
+
id: "input-property-assign",
|
|
5258
|
+
syntax: "ctx.input.<field> = \u2026 | ctx.input['<field>'] \u27E8op\u27E9= \u2026",
|
|
5259
|
+
example: {
|
|
5260
|
+
// Compound (`+=`) and logical (`??=`) assignment operators write their
|
|
5261
|
+
// LHS exactly like `=` does — the example pins the whole operator range.
|
|
5262
|
+
source: "ctx.input.total = 0; ctx.input['status'] ??= 'open'; ctx.input.retries += 1;",
|
|
5263
|
+
writes: [{ field: "total" }, { field: "status" }, { field: "retries" }]
|
|
5264
|
+
}
|
|
5265
|
+
},
|
|
5266
|
+
{
|
|
5267
|
+
id: "input-object-assign",
|
|
5268
|
+
syntax: "Object.assign(ctx.input, { <field>: \u2026 })",
|
|
5269
|
+
example: {
|
|
5270
|
+
source: "Object.assign(ctx.input, { total: 5, 'status': 'open', discount });",
|
|
5271
|
+
writes: [{ field: "total" }, { field: "status" }, { field: "discount" }]
|
|
5272
|
+
}
|
|
5273
|
+
},
|
|
5274
|
+
{
|
|
5275
|
+
// ACTION-only shape (the hook sandbox context has no `ctx.record` at all).
|
|
5276
|
+
// Declared here because this ledger is the extractor's shape inventory, not
|
|
5277
|
+
// any one rule's; every consumer declares which shapes it consumes.
|
|
5278
|
+
id: "record-property-assign",
|
|
5279
|
+
syntax: "ctx.record.<field> = \u2026 | ctx.record['<field>'] \u27E8op\u27E9= \u2026",
|
|
5280
|
+
example: {
|
|
5281
|
+
source: "ctx.record.stage = 'won'; ctx.record['amount'] += 1;",
|
|
5282
|
+
writes: [{ field: "stage" }, { field: "amount" }]
|
|
5283
|
+
}
|
|
5284
|
+
},
|
|
5285
|
+
{
|
|
5286
|
+
id: "api-crud-literal",
|
|
5287
|
+
syntax: "ctx.api.object('<object>').insert({\u2026}) | .create({\u2026}) | .update({\u2026}) | .updateById(id, {\u2026})",
|
|
5288
|
+
example: {
|
|
5289
|
+
// Real ObjectRepository signatures: the record payload is argument 0 for
|
|
5290
|
+
// insert/create/update and argument 1 for updateById. (`update(data)` —
|
|
5291
|
+
// NOT `update(id, data)`; the id travels inside the payload/options.)
|
|
5292
|
+
source: "await ctx.api.object('audit_log').insert({ event: 'won' }); await ctx.api.object('crm_deal').updateById(id, { stage: 'won' });",
|
|
5293
|
+
writes: [
|
|
5294
|
+
{ field: "event", object: "audit_log" },
|
|
5295
|
+
{ field: "stage", object: "crm_deal" }
|
|
5296
|
+
]
|
|
5297
|
+
}
|
|
5298
|
+
}
|
|
5299
|
+
];
|
|
5300
|
+
var HOOK_BODY_WRITE_PATTERN_IDS = [
|
|
5301
|
+
"input-property-assign",
|
|
5302
|
+
"input-object-assign",
|
|
5303
|
+
"api-crud-literal"
|
|
5304
|
+
];
|
|
5305
|
+
var HOOK_BODY_WRITE_EXCLUSIONS = [
|
|
5306
|
+
{
|
|
5307
|
+
id: "record-property-assign",
|
|
5308
|
+
reason: "a hook sandbox context has no `ctx.record` at all \u2014 `buildSandboxContext` never sets it (a hook\u2019s record IS `ctx.input`), so the expression throws at run time rather than silently no-op\u2019ing. A loud failure the author sees on the first run is not this advisory rule\u2019s business"
|
|
5309
|
+
}
|
|
5310
|
+
];
|
|
5311
|
+
var HOOK_APPLICABLE_IDS = new Set(HOOK_BODY_WRITE_PATTERN_IDS);
|
|
5312
|
+
var API_WRITE_METHODS = /* @__PURE__ */ new Map([
|
|
5313
|
+
["insert", 0],
|
|
5314
|
+
["create", 0],
|
|
5315
|
+
["update", 0],
|
|
5316
|
+
["updateById", 1]
|
|
5317
|
+
]);
|
|
5318
|
+
var INPUT_ENVELOPE_KEYS = /* @__PURE__ */ new Set(["id", "options", "ast", "data"]);
|
|
5319
|
+
var IMPLICIT_FIELDS2 = /* @__PURE__ */ new Set([
|
|
5320
|
+
...SYSTEM_FIELDS,
|
|
5321
|
+
"_id",
|
|
5322
|
+
"name",
|
|
5323
|
+
"space",
|
|
5324
|
+
"owner",
|
|
5325
|
+
"record_type"
|
|
5326
|
+
]);
|
|
5327
|
+
var isRec8 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
5328
|
+
function asArray33(v) {
|
|
5329
|
+
if (Array.isArray(v)) return v.filter((x) => isRec8(x));
|
|
5330
|
+
if (isRec8(v)) {
|
|
5331
|
+
return Object.entries(v).map(([name, def]) => ({
|
|
5332
|
+
name,
|
|
5333
|
+
...isRec8(def) ? def : {}
|
|
5334
|
+
}));
|
|
5335
|
+
}
|
|
5336
|
+
return [];
|
|
5337
|
+
}
|
|
5338
|
+
function indexObjectFields2(stack) {
|
|
5339
|
+
const out = /* @__PURE__ */ new Map();
|
|
5340
|
+
for (const obj of asArray33(stack.objects)) {
|
|
5341
|
+
const name = typeof obj.name === "string" ? obj.name : void 0;
|
|
5342
|
+
if (!name) continue;
|
|
5343
|
+
const names = /* @__PURE__ */ new Set();
|
|
5344
|
+
for (const f of asArray33(obj.fields)) {
|
|
5345
|
+
if (typeof f.name === "string" && f.name) names.add(f.name);
|
|
5346
|
+
}
|
|
5347
|
+
out.set(name, names);
|
|
5348
|
+
}
|
|
5349
|
+
return out;
|
|
5350
|
+
}
|
|
5351
|
+
function judgeableFieldsOf(index, objectName) {
|
|
5352
|
+
const declared = index.get(objectName);
|
|
5353
|
+
if (!declared || declared.size === 0) return void 0;
|
|
5354
|
+
return declared;
|
|
5355
|
+
}
|
|
5356
|
+
function extractHookBodyWrites(source) {
|
|
5357
|
+
return extractHookBodyWriteSet(source).writes;
|
|
5358
|
+
}
|
|
5359
|
+
function extractHookBodyWriteSet(source) {
|
|
5360
|
+
if (!/\bctx\b/.test(source) && !/\bObject\b/.test(source)) {
|
|
5361
|
+
return { writes: [], ctxRecordEscapes: false };
|
|
5362
|
+
}
|
|
5363
|
+
const tsc = loadTypeScript2();
|
|
5364
|
+
const sf = tsc.createSourceFile(
|
|
5365
|
+
"hook-body.ts",
|
|
5366
|
+
`async function __body(ctx) {
|
|
5367
|
+
${source}
|
|
5368
|
+
}`,
|
|
5369
|
+
tsc.ScriptTarget.Latest,
|
|
5370
|
+
/* setParentNodes */
|
|
5371
|
+
false,
|
|
5372
|
+
tsc.ScriptKind.TS
|
|
5373
|
+
);
|
|
5374
|
+
const writes = [];
|
|
5375
|
+
const recordRefs = [];
|
|
5376
|
+
const consumedRecordRefs = /* @__PURE__ */ new Set();
|
|
5377
|
+
const isCtxDot = (node, prop) => tsc.isPropertyAccessExpression(node) && tsc.isIdentifier(node.expression) && node.expression.text === "ctx" && node.name.text === prop;
|
|
5378
|
+
const fieldOfCtxLhs = (lhs, prop) => {
|
|
5379
|
+
if (tsc.isPropertyAccessExpression(lhs) && tsc.isIdentifier(lhs.name) && isCtxDot(lhs.expression, prop)) {
|
|
5380
|
+
return lhs.name.text;
|
|
5381
|
+
}
|
|
5382
|
+
if (tsc.isElementAccessExpression(lhs) && isCtxDot(lhs.expression, prop)) {
|
|
5383
|
+
const arg = lhs.argumentExpression;
|
|
5384
|
+
if (tsc.isStringLiteral(arg) || tsc.isNoSubstitutionTemplateLiteral(arg)) return arg.text;
|
|
5385
|
+
}
|
|
5386
|
+
return void 0;
|
|
5387
|
+
};
|
|
5388
|
+
const literalObjectKeys = (node) => {
|
|
5389
|
+
if (!tsc.isObjectLiteralExpression(node)) return [];
|
|
5390
|
+
const keys = [];
|
|
5391
|
+
for (const p of node.properties) {
|
|
5392
|
+
if (tsc.isPropertyAssignment(p)) {
|
|
5393
|
+
if (tsc.isIdentifier(p.name) || tsc.isStringLiteral(p.name)) keys.push(p.name.text);
|
|
5394
|
+
} else if (tsc.isShorthandPropertyAssignment(p)) {
|
|
5395
|
+
keys.push(p.name.text);
|
|
5396
|
+
}
|
|
5397
|
+
}
|
|
5398
|
+
return keys;
|
|
5399
|
+
};
|
|
5400
|
+
const visit = (node) => {
|
|
5401
|
+
if (tsc.isBinaryExpression(node) && node.operatorToken.kind >= tsc.SyntaxKind.FirstAssignment && node.operatorToken.kind <= tsc.SyntaxKind.LastAssignment) {
|
|
5402
|
+
const inputField = fieldOfCtxLhs(node.left, "input");
|
|
5403
|
+
if (inputField !== void 0 && !INPUT_ENVELOPE_KEYS.has(inputField)) {
|
|
5404
|
+
writes.push({ patternId: "input-property-assign", field: inputField });
|
|
5405
|
+
}
|
|
5406
|
+
const recordField = fieldOfCtxLhs(node.left, "record");
|
|
5407
|
+
if (recordField !== void 0) {
|
|
5408
|
+
writes.push({ patternId: "record-property-assign", field: recordField });
|
|
5409
|
+
}
|
|
5410
|
+
}
|
|
5411
|
+
if (tsc.isPropertyAccessExpression(node) || tsc.isElementAccessExpression(node)) {
|
|
5412
|
+
if (isCtxDot(node.expression, "record")) consumedRecordRefs.add(node.expression);
|
|
5413
|
+
}
|
|
5414
|
+
if (tsc.isBinaryExpression(node)) {
|
|
5415
|
+
const op = node.operatorToken.kind;
|
|
5416
|
+
if ((op === tsc.SyntaxKind.AmpersandAmpersandToken || op === tsc.SyntaxKind.BarBarToken || op === tsc.SyntaxKind.QuestionQuestionToken) && isCtxDot(node.left, "record")) {
|
|
5417
|
+
consumedRecordRefs.add(node.left);
|
|
5418
|
+
}
|
|
5419
|
+
}
|
|
5420
|
+
if (tsc.isPrefixUnaryExpression(node) && node.operator === tsc.SyntaxKind.ExclamationToken) {
|
|
5421
|
+
if (isCtxDot(node.operand, "record")) consumedRecordRefs.add(node.operand);
|
|
5422
|
+
}
|
|
5423
|
+
if (tsc.isTypeOfExpression(node) && isCtxDot(node.expression, "record")) {
|
|
5424
|
+
consumedRecordRefs.add(node.expression);
|
|
5425
|
+
}
|
|
5426
|
+
if ((tsc.isIfStatement(node) || tsc.isWhileStatement(node) || tsc.isDoStatement(node)) && isCtxDot(node.expression, "record")) {
|
|
5427
|
+
consumedRecordRefs.add(node.expression);
|
|
5428
|
+
}
|
|
5429
|
+
if (tsc.isConditionalExpression(node) && isCtxDot(node.condition, "record")) {
|
|
5430
|
+
consumedRecordRefs.add(node.condition);
|
|
5431
|
+
}
|
|
5432
|
+
if (isCtxDot(node, "record")) recordRefs.push(node);
|
|
5433
|
+
if (tsc.isCallExpression(node)) {
|
|
5434
|
+
const callee = node.expression;
|
|
5435
|
+
if (tsc.isPropertyAccessExpression(callee) && tsc.isIdentifier(callee.expression) && callee.expression.text === "Object" && callee.name.text === "assign" && node.arguments.length >= 2 && isCtxDot(node.arguments[0], "input")) {
|
|
5436
|
+
for (const arg of node.arguments.slice(1)) {
|
|
5437
|
+
for (const field of literalObjectKeys(arg)) {
|
|
5438
|
+
if (!INPUT_ENVELOPE_KEYS.has(field)) {
|
|
5439
|
+
writes.push({ patternId: "input-object-assign", field });
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
}
|
|
5443
|
+
}
|
|
5444
|
+
if (tsc.isPropertyAccessExpression(callee) && tsc.isIdentifier(callee.name)) {
|
|
5445
|
+
const payloadIndex = API_WRITE_METHODS.get(callee.name.text);
|
|
5446
|
+
const recv = callee.expression;
|
|
5447
|
+
if (payloadIndex !== void 0 && tsc.isCallExpression(recv) && tsc.isPropertyAccessExpression(recv.expression) && recv.expression.name.text === "object" && isCtxDot(recv.expression.expression, "api") && recv.arguments.length === 1) {
|
|
5448
|
+
const objArg = recv.arguments[0];
|
|
5449
|
+
const objectName = tsc.isStringLiteral(objArg) || tsc.isNoSubstitutionTemplateLiteral(objArg) ? objArg.text : void 0;
|
|
5450
|
+
const payload = node.arguments[payloadIndex];
|
|
5451
|
+
if (objectName && payload !== void 0) {
|
|
5452
|
+
for (const field of literalObjectKeys(payload)) {
|
|
5453
|
+
writes.push({
|
|
5454
|
+
patternId: "api-crud-literal",
|
|
5455
|
+
object: objectName,
|
|
5456
|
+
method: callee.name.text,
|
|
5457
|
+
field
|
|
5458
|
+
});
|
|
5459
|
+
}
|
|
5460
|
+
}
|
|
5461
|
+
}
|
|
5462
|
+
}
|
|
5463
|
+
}
|
|
5464
|
+
tsc.forEachChild(node, visit);
|
|
5465
|
+
};
|
|
5466
|
+
visit(sf);
|
|
5467
|
+
return {
|
|
5468
|
+
writes,
|
|
5469
|
+
ctxRecordEscapes: recordRefs.some((ref) => !consumedRecordRefs.has(ref))
|
|
5470
|
+
};
|
|
5471
|
+
}
|
|
5472
|
+
function validateHookBodyWrites(stack) {
|
|
5473
|
+
const findings = [];
|
|
5474
|
+
const hooks = asArray33(stack.hooks);
|
|
5475
|
+
if (hooks.length === 0) return findings;
|
|
5476
|
+
let objectFields = null;
|
|
5477
|
+
hooks.forEach((hook, hookIndex) => {
|
|
5478
|
+
const body = hook.body;
|
|
5479
|
+
if (!isRec8(body) || body.language !== "js") return;
|
|
5480
|
+
const source = body.source;
|
|
5481
|
+
if (typeof source !== "string" || source.trim() === "") return;
|
|
5482
|
+
const writes = extractHookBodyWrites(source).filter((w) => HOOK_APPLICABLE_IDS.has(w.patternId));
|
|
5483
|
+
if (writes.length === 0) return;
|
|
5484
|
+
objectFields ?? (objectFields = indexObjectFields2(stack));
|
|
5485
|
+
const hookName = typeof hook.name === "string" && hook.name ? hook.name : `#${hookIndex}`;
|
|
5486
|
+
const targets = (Array.isArray(hook.object) ? hook.object : [hook.object]).filter(
|
|
5487
|
+
(o) => typeof o === "string" && o.trim() !== ""
|
|
5488
|
+
);
|
|
5489
|
+
const targetSets = targets.map((t) => judgeableFieldsOf(objectFields, t));
|
|
5490
|
+
const inputJudgeable = targets.length > 0 && !targets.includes("*") && targetSets.every((s) => s !== void 0);
|
|
5491
|
+
const where = `hook "${hookName}" \u203A body`;
|
|
5492
|
+
const path = `hooks[${hookIndex}].body.source`;
|
|
5493
|
+
const reported = /* @__PURE__ */ new Set();
|
|
5494
|
+
for (const w of writes) {
|
|
5495
|
+
const dedupeKey = `${w.object ?? ""}\0${w.field}`;
|
|
5496
|
+
if (reported.has(dedupeKey)) continue;
|
|
5497
|
+
if (w.object === void 0) {
|
|
5498
|
+
if (!inputJudgeable) continue;
|
|
5499
|
+
if (IMPLICIT_FIELDS2.has(w.field)) continue;
|
|
5500
|
+
if (targetSets.some((s) => s.has(w.field))) continue;
|
|
5501
|
+
reported.add(dedupeKey);
|
|
5502
|
+
const objDesc = targets.length === 1 ? `object '${targets[0]}'` : `none of its target objects (${targets.join(", ")})`;
|
|
5503
|
+
const declares = targets.length === 1 ? "declares no such field" : "declare that field";
|
|
5504
|
+
findings.push({
|
|
5505
|
+
severity: "warning",
|
|
5506
|
+
rule: HOOK_BODY_WRITE_UNKNOWN_FIELD,
|
|
5507
|
+
where,
|
|
5508
|
+
path,
|
|
5509
|
+
message: `body writes '${w.field}' to its input, but ${objDesc} ${declares}. The sandboxed script runs clean and the value is copied back onto the record payload unfiltered \u2014 on a SQL driver the stray column then fails the WHOLE write with a driver-level error far from here; on a schemaless driver (memory, MongoDB) it is persisted as an undeclared key (#4271).`,
|
|
5510
|
+
hint: fixHint(w.field, unionCandidates(targetSets))
|
|
5511
|
+
});
|
|
5512
|
+
} else {
|
|
5513
|
+
const known = judgeableFieldsOf(objectFields, w.object);
|
|
5514
|
+
if (!known) continue;
|
|
5515
|
+
if (IMPLICIT_FIELDS2.has(w.field) || known.has(w.field)) continue;
|
|
5516
|
+
reported.add(dedupeKey);
|
|
5517
|
+
findings.push({
|
|
5518
|
+
severity: "warning",
|
|
5519
|
+
rule: HOOK_BODY_WRITE_UNKNOWN_FIELD,
|
|
5520
|
+
where,
|
|
5521
|
+
path,
|
|
5522
|
+
message: `body calls ctx.api.object('${w.object}').${w.method ?? "update"}(\u2026) writing '${w.field}', but object '${w.object}' declares no such field. The write-path validator skips the unknown key \u2014 on a SQL driver the whole call then fails with a driver-level error far from here; on a schemaless driver (memory, MongoDB) the stray key is persisted (#4271).`,
|
|
5523
|
+
hint: fixHint(w.field, [...known])
|
|
5524
|
+
});
|
|
5525
|
+
}
|
|
5526
|
+
}
|
|
5527
|
+
});
|
|
5528
|
+
return findings;
|
|
5529
|
+
}
|
|
5530
|
+
function unionCandidates(targetSets) {
|
|
5531
|
+
const out = /* @__PURE__ */ new Set();
|
|
5532
|
+
for (const s of targetSets) for (const f of s ?? []) out.add(f);
|
|
5533
|
+
return [...out];
|
|
5534
|
+
}
|
|
5535
|
+
function fixHint(field, declared) {
|
|
5536
|
+
const suggestion = formatSuggestion(findClosestMatches(field, [...declared, ...IMPLICIT_FIELDS2]));
|
|
5537
|
+
return (suggestion ? `${suggestion} ` : "") + `Fix the field name, or declare '${field}' on the object. Only the literal write patterns in HOOK_BODY_WRITE_PATTERNS are checked \u2014 computed keys, spreads and aliased input are not \u2014 and this warning never blocks a build.`;
|
|
5538
|
+
}
|
|
5539
|
+
|
|
5540
|
+
// src/validate-action-body-writes.ts
|
|
5541
|
+
import { findClosestMatches as findClosestMatches2, formatSuggestion as formatSuggestion2 } from "@objectstack/spec/shared";
|
|
5542
|
+
var ACTION_BODY_WRITE_UNKNOWN_FIELD = "action-body-write-unknown-field";
|
|
5543
|
+
var ACTION_RECORD_WRITE_DISCARDED = "action-record-write-discarded";
|
|
5544
|
+
var ACTION_BODY_WRITE_PATTERN_IDS = ["api-crud-literal"];
|
|
5545
|
+
var ACTION_RECORD_WRITE_PATTERN_IDS = ["record-property-assign"];
|
|
5546
|
+
var ACTION_BODY_WRITE_EXCLUSIONS = [
|
|
5547
|
+
{
|
|
5548
|
+
id: "input-property-assign",
|
|
5549
|
+
reason: "an action's ctx.input is its params bag (`input: unwrapProxyToPlain(actionCtx?.params)`), not a record \u2014 `ctx.input.<name>` writes a declared PARAMETER, which object fields cannot judge"
|
|
5550
|
+
},
|
|
5551
|
+
{
|
|
5552
|
+
id: "input-object-assign",
|
|
5553
|
+
reason: "same surface as input-property-assign \u2014 Object.assign(ctx.input, \u2026) targets the params bag"
|
|
5554
|
+
}
|
|
5555
|
+
];
|
|
5556
|
+
var ACTION_BODY_WRITE_PATTERNS = HOOK_BODY_WRITE_PATTERNS.filter((p) => ACTION_BODY_WRITE_PATTERN_IDS.includes(p.id));
|
|
5557
|
+
var ACTION_RECORD_WRITE_PATTERNS = HOOK_BODY_WRITE_PATTERNS.filter((p) => ACTION_RECORD_WRITE_PATTERN_IDS.includes(p.id));
|
|
5558
|
+
var APPLICABLE_IDS = new Set(ACTION_BODY_WRITE_PATTERN_IDS);
|
|
5559
|
+
var RECORD_WRITE_IDS = new Set(ACTION_RECORD_WRITE_PATTERN_IDS);
|
|
5560
|
+
var isRec9 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
5561
|
+
function asArray34(v) {
|
|
5562
|
+
if (Array.isArray(v)) return v.filter((x) => isRec9(x));
|
|
5563
|
+
if (isRec9(v)) {
|
|
5564
|
+
return Object.entries(v).map(([name, def]) => ({
|
|
5565
|
+
name,
|
|
5566
|
+
...isRec9(def) ? def : {}
|
|
5567
|
+
}));
|
|
5568
|
+
}
|
|
5569
|
+
return [];
|
|
5570
|
+
}
|
|
5571
|
+
function actionObjectBinding(action, parentObject) {
|
|
5572
|
+
if (typeof action.object === "string" && action.object) return action.object;
|
|
5573
|
+
if (typeof action.objectName === "string" && action.objectName) return action.objectName;
|
|
5574
|
+
return parentObject;
|
|
5575
|
+
}
|
|
5576
|
+
function collectActionBodies(stack) {
|
|
5577
|
+
const sites = [];
|
|
5578
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5579
|
+
const collect = (actions, pathPrefix, parentObject) => {
|
|
5580
|
+
asArray34(actions).forEach((action, index) => {
|
|
5581
|
+
const body = action.body;
|
|
5582
|
+
if (!isRec9(body) || body.language !== "js") return;
|
|
5583
|
+
const source = body.source;
|
|
5584
|
+
if (typeof source !== "string" || source.trim() === "") return;
|
|
5585
|
+
const name = typeof action.name === "string" && action.name ? action.name : `#${index}`;
|
|
5586
|
+
const key = `${actionObjectBinding(action, parentObject) ?? ""}\0${name}\0${source}`;
|
|
5587
|
+
if (seen.has(key)) return;
|
|
5588
|
+
seen.add(key);
|
|
5589
|
+
sites.push({ name, source, path: `${pathPrefix}[${index}].body.source` });
|
|
5590
|
+
});
|
|
5591
|
+
};
|
|
5592
|
+
collect(stack.actions, "actions");
|
|
5593
|
+
asArray34(stack.objects).forEach((obj, objIndex) => {
|
|
5594
|
+
const parentObject = typeof obj.name === "string" && obj.name ? obj.name : void 0;
|
|
5595
|
+
collect(obj.actions, `objects[${objIndex}].actions`, parentObject);
|
|
5596
|
+
});
|
|
5597
|
+
return sites;
|
|
5598
|
+
}
|
|
5599
|
+
function validateActionBodyWrites(stack) {
|
|
5600
|
+
const findings = [];
|
|
5601
|
+
if (!isRec9(stack)) return findings;
|
|
5602
|
+
const sites = collectActionBodies(stack);
|
|
5603
|
+
if (sites.length === 0) return findings;
|
|
5604
|
+
let objectFields = null;
|
|
5605
|
+
for (const site of sites) {
|
|
5606
|
+
if (!/\bapi\b/.test(site.source) && !/\brecord\b/.test(site.source)) continue;
|
|
5607
|
+
const { writes: allWrites, ctxRecordEscapes } = extractHookBodyWriteSet(site.source);
|
|
5608
|
+
const writes = allWrites.filter((w) => APPLICABLE_IDS.has(w.patternId));
|
|
5609
|
+
const recordWrites = allWrites.filter((w) => RECORD_WRITE_IDS.has(w.patternId));
|
|
5610
|
+
if (writes.length === 0 && recordWrites.length === 0) continue;
|
|
5611
|
+
const where = `action "${site.name}" \u203A body`;
|
|
5612
|
+
if (recordWrites.length > 0 && !ctxRecordEscapes) {
|
|
5613
|
+
const reportedFields = /* @__PURE__ */ new Set();
|
|
5614
|
+
for (const w of recordWrites) {
|
|
5615
|
+
if (reportedFields.has(w.field)) continue;
|
|
5616
|
+
reportedFields.add(w.field);
|
|
5617
|
+
findings.push({
|
|
5618
|
+
severity: "warning",
|
|
5619
|
+
rule: ACTION_RECORD_WRITE_DISCARDED,
|
|
5620
|
+
where,
|
|
5621
|
+
path: site.path,
|
|
5622
|
+
message: `body assigns ctx.record.${w.field}, but an action's ctx.record is a plain snapshot the runtime never writes back \u2014 the action returns success and the assignment is discarded, whether or not '${w.field}' is a declared field (#4345).`,
|
|
5623
|
+
hint: `To persist it, write through the API: ctx.api.object('<object>').updateById(ctx.recordId, { ${w.field}: \u2026 }). Reported only because ctx.record is never passed anywhere in this body \u2014 mutating the snapshot and then handing it to an API write is a live payload and is not flagged. This warning never blocks a build.`
|
|
5624
|
+
});
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
if (writes.length === 0) continue;
|
|
5628
|
+
objectFields ?? (objectFields = indexObjectFields2(stack));
|
|
5629
|
+
const reported = /* @__PURE__ */ new Set();
|
|
5630
|
+
for (const w of writes) {
|
|
5631
|
+
if (w.object === void 0) continue;
|
|
5632
|
+
const dedupeKey = `${w.object}\0${w.field}`;
|
|
5633
|
+
if (reported.has(dedupeKey)) continue;
|
|
5634
|
+
const known = judgeableFieldsOf(objectFields, w.object);
|
|
5635
|
+
if (!known) continue;
|
|
5636
|
+
if (IMPLICIT_FIELDS2.has(w.field) || known.has(w.field)) continue;
|
|
5637
|
+
reported.add(dedupeKey);
|
|
5638
|
+
findings.push({
|
|
5639
|
+
severity: "warning",
|
|
5640
|
+
rule: ACTION_BODY_WRITE_UNKNOWN_FIELD,
|
|
5641
|
+
where,
|
|
5642
|
+
path: site.path,
|
|
5643
|
+
message: `body calls ctx.api.object('${w.object}').${w.method ?? "update"}(\u2026) writing '${w.field}', but object '${w.object}' declares no such field. The write-path validator skips the unknown key \u2014 on a SQL driver the whole action then fails with a driver-level error far from here; on a schemaless driver (memory, MongoDB) the stray key is persisted (#4271).`,
|
|
5644
|
+
hint: fixHint2(w.field, [...known])
|
|
5645
|
+
});
|
|
5646
|
+
}
|
|
5647
|
+
}
|
|
5648
|
+
return findings;
|
|
5649
|
+
}
|
|
5650
|
+
function fixHint2(field, declared) {
|
|
5651
|
+
const suggestion = formatSuggestion2(findClosestMatches2(field, [...declared, ...IMPLICIT_FIELDS2]));
|
|
5652
|
+
return (suggestion ? `${suggestion} ` : "") + `Fix the field name, or declare '${field}' on the object. Only the literal write patterns in ACTION_BODY_WRITE_PATTERNS are checked \u2014 an action's ctx.input is its params bag, so it is not a record-write surface and is never resolved against fields \u2014 and this warning never blocks a build.`;
|
|
5653
|
+
}
|
|
5654
|
+
|
|
5655
|
+
// src/validate-flow-node-writes.ts
|
|
5656
|
+
import { findClosestMatches as findClosestMatches3, formatSuggestion as formatSuggestion3 } from "@objectstack/spec/shared";
|
|
5657
|
+
var FLOW_NODE_WRITE_UNKNOWN_FIELD = "flow-node-write-unknown-field";
|
|
5658
|
+
var FLOW_WRITE_NODE_TYPES = ["update_record", "create_record"];
|
|
5659
|
+
var FLOW_WRITE_NODE_TYPES_DEFERRED = [];
|
|
5660
|
+
var isRec10 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
5661
|
+
function asArray35(v) {
|
|
5662
|
+
if (Array.isArray(v)) return v.filter((x) => isRec10(x));
|
|
5663
|
+
if (isRec10(v)) {
|
|
5664
|
+
return Object.entries(v).map(([name, def]) => ({
|
|
5665
|
+
name,
|
|
5666
|
+
...isRec10(def) ? def : {}
|
|
5667
|
+
}));
|
|
5668
|
+
}
|
|
5669
|
+
return [];
|
|
5670
|
+
}
|
|
5671
|
+
function readLiteralObjectName2(config) {
|
|
5672
|
+
const raw = config.objectName ?? config.object;
|
|
5673
|
+
if (typeof raw !== "string" || raw.includes("{")) return void 0;
|
|
5674
|
+
return raw || void 0;
|
|
5675
|
+
}
|
|
5676
|
+
var COVERED_TYPES = new Set(FLOW_WRITE_NODE_TYPES);
|
|
5677
|
+
function validateFlowNodeWrites(stack) {
|
|
5678
|
+
const findings = [];
|
|
5679
|
+
if (!isRec10(stack)) return findings;
|
|
5680
|
+
const flows = asArray35(stack.flows);
|
|
5681
|
+
if (flows.length === 0) return findings;
|
|
5682
|
+
let objectFields = null;
|
|
5683
|
+
flows.forEach((flow, flowIndex) => {
|
|
5684
|
+
const flowName = typeof flow.name === "string" && flow.name ? flow.name : `#${flowIndex}`;
|
|
5685
|
+
const walked = walkFlowNodes(flow, `flows[${flowIndex}]`);
|
|
5686
|
+
walked.forEach(({ node, path: nodePath, regionTrail }, walkIndex) => {
|
|
5687
|
+
if (typeof node.type !== "string" || !COVERED_TYPES.has(node.type)) return;
|
|
5688
|
+
const config = isRec10(node.config) ? node.config : void 0;
|
|
5689
|
+
if (!config) return;
|
|
5690
|
+
const fields = config.fields;
|
|
5691
|
+
if (!isRec10(fields)) return;
|
|
5692
|
+
const written = Object.keys(fields);
|
|
5693
|
+
if (written.length === 0) return;
|
|
5694
|
+
const objectName = readLiteralObjectName2(config);
|
|
5695
|
+
if (!objectName) return;
|
|
5696
|
+
objectFields ?? (objectFields = indexObjectFields2(stack));
|
|
5697
|
+
const known = judgeableFieldsOf(objectFields, objectName);
|
|
5698
|
+
if (!known) return;
|
|
5699
|
+
const nodeName = flowNodeLabel(node, walkIndex);
|
|
5700
|
+
const nodeWhere = regionTrail ? `${regionTrail} \u203A node "${nodeName}"` : `node "${nodeName}"`;
|
|
5701
|
+
for (const fieldName of written) {
|
|
5702
|
+
if (known.has(fieldName) || IMPLICIT_FIELDS2.has(fieldName)) continue;
|
|
5703
|
+
if (fieldName.includes(".")) continue;
|
|
5704
|
+
findings.push({
|
|
5705
|
+
severity: "error",
|
|
5706
|
+
rule: FLOW_NODE_WRITE_UNKNOWN_FIELD,
|
|
5707
|
+
where: `flow "${flowName}" \u203A ${nodeWhere}`,
|
|
5708
|
+
path: `${nodePath}.config.fields.${fieldName}`,
|
|
5709
|
+
message: `${node.type} writes '${fieldName}', but object '${objectName}' declares no such field. Nothing between the node and storage removes the key: on a SQL datasource the driver rejects the whole statement ('no such column'), so the correctly named fields in this same payload never land either${node.type === "create_record" ? " and the record is never created at all" : ""}; on a schemaless one the stray key is persisted into a column no read surface returns.`,
|
|
5710
|
+
hint: fixHint3(fieldName, [...known])
|
|
5711
|
+
});
|
|
5712
|
+
}
|
|
5713
|
+
});
|
|
5714
|
+
});
|
|
5715
|
+
return findings;
|
|
5716
|
+
}
|
|
5717
|
+
function fixHint3(field, declared) {
|
|
5718
|
+
const suggestion = formatSuggestion3(findClosestMatches3(field, [...declared, ...IMPLICIT_FIELDS2]));
|
|
5719
|
+
return (suggestion ? `${suggestion} ` : "") + `Fix the field name, or declare '${field}' on the object. This gates the build rather than warning: the key is literal and so is the object, so unlike the hook/action body rules there is nothing here that could have been mis-extracted.`;
|
|
5720
|
+
}
|
|
5721
|
+
|
|
5722
|
+
// src/reference-integrity-suite.ts
|
|
5723
|
+
var REFERENCE_INTEGRITY_RULES = [
|
|
5724
|
+
{ name: "validateObjectReferences", run: validateObjectReferences },
|
|
5725
|
+
{ name: "validateSearchableFields", run: validateSearchableFields },
|
|
5726
|
+
{ name: "validateActionNameRefs", run: validateActionNameRefs },
|
|
5727
|
+
{ name: "validatePageFieldBindings", run: validatePageFieldBindings },
|
|
5728
|
+
{ name: "validateChartBindings", run: validateChartBindings },
|
|
5729
|
+
{ name: "validateNavAccess", run: validateNavAccess },
|
|
5730
|
+
{ name: "validateTranslationReferences", run: validateTranslationReferences },
|
|
5731
|
+
{ name: "validateFlowTemplatePaths", run: validateFlowTemplatePaths },
|
|
5732
|
+
{ name: "validateAiSurfaceAffinity", run: validateAiSurfaceAffinity },
|
|
5733
|
+
{ name: "validateAiToolReferences", run: validateAiToolReferences },
|
|
5734
|
+
{ name: "validateAiAgentAuthoring", run: validateAiAgentAuthoring },
|
|
5735
|
+
// Field names WRITTEN by an L2 hook body (`ctx.input.x = …`,
|
|
5736
|
+
// `ctx.api.object('y').update({ x })`), resolved against the target object's
|
|
5737
|
+
// declared fields — the write-side counterpart of validateFlowTemplatePaths'
|
|
5738
|
+
// read-side membership (#4271). Lazy: only a hook that actually carries a
|
|
5739
|
+
// `language:'js'` body loads the TypeScript parser.
|
|
5740
|
+
{ name: "validateHookBodyWrites", run: validateHookBodyWrites },
|
|
5741
|
+
// The same check on the other surface that carries a `HookBodySchema` body:
|
|
5742
|
+
// action bodies, run by the same sandbox. Only the `ctx.api` write family
|
|
5743
|
+
// carries over — an action's `ctx.input` is its params bag, not a record
|
|
5744
|
+
// (see that module's ledger). Lazy on the same terms.
|
|
5745
|
+
//
|
|
5746
|
+
// The first member here to emit more than one rule id (`validateReactPageProps`
|
|
5747
|
+
// below is the other, and carries the most). Besides resolving `ctx.api`
|
|
5748
|
+
// writes against declared fields (`action-body-write-unknown-field`), it
|
|
5749
|
+
// reports a `ctx.record` write that can reach nothing
|
|
5750
|
+
// (`action-record-write-discarded`, #4345) — not a resolution question, so
|
|
5751
|
+
// by the charter above it does not belong in the suite. It rides along
|
|
5752
|
+
// anyway because it falls out of the SAME parse of the SAME source: a
|
|
5753
|
+
// separate member would parse every action body twice to say two things
|
|
5754
|
+
// about one walk, and hand-wiring it into the CLI instead is exactly the
|
|
5755
|
+
// drift this suite exists to end — which `validateReadonlyFlowWrites` was
|
|
5756
|
+
// the standing proof of, until it joined the suite below.
|
|
5757
|
+
{ name: "validateActionBodyWrites", run: validateActionBodyWrites },
|
|
5758
|
+
// The third surface that writes a record field set: a flow `update_record`
|
|
5759
|
+
// node's `config.fields`. Same question as the two rules above, but the map
|
|
5760
|
+
// is structural metadata rather than parsed JS, so a finding is a certainty
|
|
5761
|
+
// and gates (`error`) — see that module for why, and why the docs' long-
|
|
5762
|
+
// standing "prefer a flow node, it's checked" advice was the least true of
|
|
5763
|
+
// the three until it landed.
|
|
5764
|
+
{ name: "validateFlowNodeWrites", run: validateFlowNodeWrites },
|
|
5765
|
+
// The OTHER question about that same `config.fields` map: not "does this
|
|
5766
|
+
// field exist?" but "is it writable?" — a `runAs:'user'` update_record
|
|
5767
|
+
// writing a static-`readonly` field is stripped by the engine and the step
|
|
5768
|
+
// still reports success (#2948/#3425). It walks the identical map the rule
|
|
5769
|
+
// above walks, so the two splitting call sites was never defensible: hand-
|
|
5770
|
+
// wired into `validate` and `compile` only, it left `os lint` PASSING a flow
|
|
5771
|
+
// `os validate` refuses — and this one gates, so the divergence shipped a
|
|
5772
|
+
// build the other command would have stopped. Joining the suite is the whole
|
|
5773
|
+
// fix; the two hand-wired call sites are deleted with it (#4345 follow-up).
|
|
5774
|
+
{ name: "validateReadonlyFlowWrites", run: validateReadonlyFlowWrites },
|
|
5775
|
+
// The `kind:'react'` page surface. Every prop a react block binds BY FIELD
|
|
5776
|
+
// NAME is resolved against the object it names (#4340) — `<ListView columns>`,
|
|
5777
|
+
// `<ObjectForm fields>`, the `record:*` family through the SAME
|
|
5778
|
+
// `COMPONENT_FIELD_SPECS` table `validatePageFieldBindings` walks one surface
|
|
5779
|
+
// over, plus `<ObjectChart>`'s aggregate/axes (#3701/#3729) and
|
|
5780
|
+
// `searchableFields` (#4329). Squarely the charter's question, on the surface
|
|
5781
|
+
// where it had no answer at all.
|
|
5782
|
+
//
|
|
5783
|
+
// It was hand-wired into `os validate` ALONE, so `os lint` and `os compile`
|
|
5784
|
+
// accepted a react page whose every field binding was stale — including the
|
|
5785
|
+
// gating ones (a missing required binding, a filter position naming no field:
|
|
5786
|
+
// the predicate can never match and the list comes back empty). That is
|
|
5787
|
+
// `validateReadonlyFlowWrites`' divergence again, one surface over, and it is
|
|
5788
|
+
// the reason this entry exists rather than a fourth hand-wiring.
|
|
5789
|
+
//
|
|
5790
|
+
// Like `validateActionBodyWrites` above, it emits ids that are not resolution
|
|
5791
|
+
// questions — `react-prop-missing-required` and `react-prop-typo` are shape,
|
|
5792
|
+
// and by the charter belong outside. They ride along for the same reason: they
|
|
5793
|
+
// fall out of the SAME TypeScript parse of the SAME page source, and splitting
|
|
5794
|
+
// them into a second member would parse every react page twice to say two
|
|
5795
|
+
// things about one walk. Lazy on the same terms as the hook/action body rules
|
|
5796
|
+
// — only a page that is actually `kind:'react'` loads the compiler.
|
|
5797
|
+
{ name: "validateReactPageProps", run: validateReactPageProps }
|
|
5798
|
+
];
|
|
5799
|
+
function validateReferenceIntegrity(stack) {
|
|
5800
|
+
const findings = [];
|
|
5801
|
+
for (const rule of REFERENCE_INTEGRITY_RULES) {
|
|
5802
|
+
findings.push(...rule.run(stack));
|
|
5803
|
+
}
|
|
5804
|
+
return findings;
|
|
2335
5805
|
}
|
|
2336
5806
|
export {
|
|
5807
|
+
ACTION_BODY_WRITE_EXCLUSIONS,
|
|
5808
|
+
ACTION_BODY_WRITE_PATTERNS,
|
|
5809
|
+
ACTION_BODY_WRITE_PATTERN_IDS,
|
|
5810
|
+
ACTION_BODY_WRITE_UNKNOWN_FIELD,
|
|
5811
|
+
ACTION_NAME_UNDEFINED,
|
|
5812
|
+
ACTION_RECORD_WRITE_DISCARDED,
|
|
5813
|
+
ACTION_RECORD_WRITE_PATTERNS,
|
|
5814
|
+
ACTION_RECORD_WRITE_PATTERN_IDS,
|
|
5815
|
+
AGENT_AUTHORING_WITHDRAWN,
|
|
5816
|
+
AI_SKILL_SURFACE_MISMATCH,
|
|
5817
|
+
AI_SKILL_TOOL_UNRESOLVED,
|
|
5818
|
+
APPROVAL_APPROVERS_MAY_RESOLVE_EMPTY,
|
|
5819
|
+
APPROVAL_APPROVER_CROSS_ORG_UNSUPPORTED,
|
|
2337
5820
|
APPROVAL_APPROVER_NOT_MEMBERSHIP_TIER,
|
|
2338
5821
|
APPROVAL_APPROVER_TYPE_DEPRECATED,
|
|
2339
5822
|
APPROVAL_APPROVER_TYPE_UNKNOWN,
|
|
5823
|
+
APPROVAL_DECISION_OUTPUTS_RESERVED,
|
|
2340
5824
|
APPROVAL_ESCALATION_REASSIGN_NO_TARGET,
|
|
5825
|
+
APPROVAL_EXPRESSION_INVALID,
|
|
5826
|
+
APPROVAL_EXPRESSION_NO_EMPTY_POLICY,
|
|
2341
5827
|
CAPABILITY_REFERENCE_UNKNOWN,
|
|
5828
|
+
CHART_AXIS_NOT_SELECTED,
|
|
2342
5829
|
CHART_CONFIG_MISSING,
|
|
5830
|
+
CHART_DATASET_UNKNOWN,
|
|
5831
|
+
CHART_DIMENSION_UNKNOWN,
|
|
2343
5832
|
CHART_FIELD_UNKNOWN,
|
|
5833
|
+
CHART_MEASURE_UNKNOWN,
|
|
2344
5834
|
DASHBOARD_ACTION_ROUTE_UNRESOLVED,
|
|
2345
5835
|
DASHBOARD_ACTION_TARGET_UNDEFINED,
|
|
2346
5836
|
DASHBOARD_FILTER_FIELD_UNKNOWN,
|
|
2347
5837
|
FIELD_GROUP_EMPTY,
|
|
2348
5838
|
FIELD_GROUP_UNDECLARED,
|
|
5839
|
+
FILTER_TOKEN_UNKNOWN,
|
|
2349
5840
|
FLOW_DRAFT_STATUS_AMBIGUOUS,
|
|
5841
|
+
FLOW_NODE_WRITE_UNKNOWN_FIELD,
|
|
5842
|
+
FLOW_TEMPLATE_LOOKUP_TRAVERSAL,
|
|
5843
|
+
FLOW_TEMPLATE_UNKNOWN_FIELD,
|
|
2350
5844
|
FLOW_TRIGGER_UNKNOWN_OBJECT,
|
|
5845
|
+
FLOW_UPDATE_READONLY_FIELD,
|
|
5846
|
+
FLOW_UPDATE_READONLY_WHEN_FIELD,
|
|
5847
|
+
FLOW_WRITE_NODE_TYPES,
|
|
5848
|
+
FLOW_WRITE_NODE_TYPES_DEFERRED,
|
|
2351
5849
|
FORM_COLSPAN_ABSOLUTE,
|
|
2352
5850
|
FORM_FIELD_UNKNOWN,
|
|
5851
|
+
HOOK_BODY_WRITE_EXCLUSIONS,
|
|
5852
|
+
HOOK_BODY_WRITE_PATTERNS,
|
|
5853
|
+
HOOK_BODY_WRITE_PATTERN_IDS,
|
|
5854
|
+
HOOK_BODY_WRITE_UNKNOWN_FIELD,
|
|
2353
5855
|
LIST_VIEW_FILTERS_IN_VIEWS_MODE,
|
|
2354
5856
|
MEASURE_AGGREGATE_INCOHERENT,
|
|
5857
|
+
NAV_OBJECT_UNGRANTED,
|
|
5858
|
+
OBJECT_REFERENCE_UNKNOWN,
|
|
5859
|
+
OBJECT_REFERENCE_UNREGISTERED_PLATFORM,
|
|
5860
|
+
ORG_AXIS_CROSS_ORG_BU_GRANT,
|
|
5861
|
+
ORG_AXIS_PERMISSION_INHERITANCE,
|
|
5862
|
+
PAGE_FIELD_UNKNOWN,
|
|
2355
5863
|
PAGE_SOURCE_CLASSNAME,
|
|
5864
|
+
REACT_CHART_AGGREGATE_INVALID,
|
|
5865
|
+
REACT_CHART_AXIS_UNKNOWN,
|
|
5866
|
+
REACT_CHART_FIELD_UNKNOWN,
|
|
5867
|
+
REFERENCE_INTEGRITY_RULES,
|
|
5868
|
+
SEARCHABLE_FIELD_UNKNOWN,
|
|
2356
5869
|
SECURITY_ANCHOR_HIGH_PRIVILEGE,
|
|
2357
5870
|
SECURITY_BOOK_AUDIENCE_UNKNOWN_SET,
|
|
2358
5871
|
SECURITY_DELEGATION_MISSING_REASON,
|
|
@@ -2364,6 +5877,8 @@ export {
|
|
|
2364
5877
|
SECURITY_PRIVATE_NO_READSCOPE,
|
|
2365
5878
|
SECURITY_ROLE_WORD,
|
|
2366
5879
|
SECURITY_WILDCARD_VAMA,
|
|
5880
|
+
SEED_INSERT_MODE_DUPLICATES_ON_REPLAY,
|
|
5881
|
+
SEED_VALUE_OUTSIDE_STATE_MACHINE,
|
|
2367
5882
|
SEMANTIC_ROLE_FIELD_UNKNOWN,
|
|
2368
5883
|
STYLE_CLASSNAME_TAILWIND,
|
|
2369
5884
|
STYLE_NODE_MISSING_ID,
|
|
@@ -2373,6 +5888,8 @@ export {
|
|
|
2373
5888
|
TABLE_COUNT_ONLY,
|
|
2374
5889
|
TITLE_FORMAT_RETIRED,
|
|
2375
5890
|
TITLE_UNRESOLVABLE,
|
|
5891
|
+
TRANSLATION_OPTION_KEY_UNKNOWN,
|
|
5892
|
+
TRANSLATION_TARGET_UNKNOWN,
|
|
2376
5893
|
VIEW_CONTAINER_SHAPE,
|
|
2377
5894
|
VISIBILITY_ALIAS_DEPRECATED,
|
|
2378
5895
|
VISIBILITY_ROOT_MISLAYERED,
|
|
@@ -2381,21 +5898,43 @@ export {
|
|
|
2381
5898
|
WIDGET_MEASURE_UNKNOWN,
|
|
2382
5899
|
buildAccessMatrix,
|
|
2383
5900
|
diffAccessMatrix,
|
|
5901
|
+
extractHookBodyWriteSet,
|
|
5902
|
+
extractHookBodyWrites,
|
|
5903
|
+
validateActionBodyWrites,
|
|
5904
|
+
validateActionNameRefs,
|
|
5905
|
+
validateAiAgentAuthoring,
|
|
5906
|
+
validateAiSurfaceAffinity,
|
|
5907
|
+
validateAiToolReferences,
|
|
2384
5908
|
validateApprovalApprovers,
|
|
2385
5909
|
validateCapabilityReferences,
|
|
5910
|
+
validateChartBindings,
|
|
2386
5911
|
validateDashboardActionRefs,
|
|
5912
|
+
validateFilterTokens,
|
|
5913
|
+
validateFlowNodeWrites,
|
|
5914
|
+
validateFlowTemplatePaths,
|
|
2387
5915
|
validateFlowTriggerReadiness,
|
|
2388
5916
|
validateFormLayout,
|
|
5917
|
+
validateHookBodyWrites,
|
|
2389
5918
|
validateJsxPages,
|
|
2390
5919
|
validateListViewMode,
|
|
5920
|
+
validateNavAccess,
|
|
5921
|
+
validateObjectReferences,
|
|
5922
|
+
validateOrgAxisRedLines,
|
|
5923
|
+
validatePageFieldBindings,
|
|
2391
5924
|
validatePageSourceStyling,
|
|
2392
5925
|
validateReactPageProps,
|
|
2393
5926
|
validateReactPages,
|
|
5927
|
+
validateReadonlyFlowWrites,
|
|
2394
5928
|
validateRecordTitle,
|
|
5929
|
+
validateReferenceIntegrity,
|
|
2395
5930
|
validateResponsiveStyles,
|
|
5931
|
+
validateSearchableFields,
|
|
2396
5932
|
validateSecurityPosture,
|
|
5933
|
+
validateSeedReplaySafety,
|
|
5934
|
+
validateSeedStateMachine,
|
|
2397
5935
|
validateSemanticRoles,
|
|
2398
5936
|
validateStackExpressions,
|
|
5937
|
+
validateTranslationReferences,
|
|
2399
5938
|
validateViewContainers,
|
|
2400
5939
|
validateVisibilityPredicates,
|
|
2401
5940
|
validateWidgetBindings
|