@cosmicdrift/kumiko-framework 0.406.0 → 0.410.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -2
- package/agents/api/framework-db.md +1 -0
- package/agents/api/framework-engine.md +17 -2
- package/agents/api/framework-ui-types.md +15 -0
- package/agents/api/renderer-web.md +156 -2
- package/agents/api/types.md +113 -71
- package/agents/api.md +4 -4
- package/agents/boot-rules.md +744 -0
- package/agents/examples/anonymous-access.md +23 -1
- package/agents/examples/contact.md +173 -0
- package/agents/examples/delivery-notifications.md +34 -1
- package/agents/examples/record-detail-layout.md +13 -2
- package/agents/examples/search.md +65 -3
- package/agents/examples/secrets-demo.md +96 -2
- package/agents/examples/tenant-inactivity.md +138 -0
- package/agents/examples.md +2 -0
- package/agents/features-index.md +4 -0
- package/agents/features.md +25 -1
- package/agents/widgets.md +12 -1
- package/dist/api/export/export-rows.js +1 -0
- package/dist/compliance/index.d.ts +1 -1
- package/dist/db/event-store-executor-read-where.js +15 -5
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/migrate-generator.js +3 -1
- package/dist/db/queries/event-consumer.js +11 -7
- package/dist/db/queries/event-store.d.ts +2 -1
- package/dist/db/queries/event-store.js +25 -6
- package/dist/db/queries/rls-boot-catalog.js +3 -1
- package/dist/db/queries/session-advisory-lock.d.ts +7 -0
- package/dist/db/queries/session-advisory-lock.js +23 -0
- package/dist/db/query.js +7 -10
- package/dist/db/row-level-security-connection.js +4 -2
- package/dist/engine/access.js +5 -1
- package/dist/engine/active-membership.js +1 -0
- package/dist/engine/boot-validator/access-declarations.js +76 -33
- package/dist/engine/boot-validator/action-wiring.js +8 -6
- package/dist/engine/boot-validator/agent-effect-rules.d.ts +12 -0
- package/dist/engine/boot-validator/agent-effect-rules.js +12 -0
- package/dist/engine/boot-validator/agent-effect.d.ts +2 -0
- package/dist/engine/boot-validator/agent-effect.js +20 -0
- package/dist/engine/boot-validator/boot-context.js +5 -1
- package/dist/engine/boot-validator/boot-environment-rules.d.ts +12 -0
- package/dist/engine/boot-validator/boot-environment-rules.js +12 -0
- package/dist/engine/boot-validator/boot-phases-app.js +5 -1
- package/dist/engine/boot-validator/boot-phases.js +3 -1
- package/dist/engine/boot-validator/boot-rules.d.ts +2624 -0
- package/dist/engine/boot-validator/boot-rules.js +58 -0
- package/dist/engine/boot-validator/bundled-lists-table.js +23 -9
- package/dist/engine/boot-validator/config-deps.js +71 -23
- package/dist/engine/boot-validator/config-edit-action-rules.d.ts +17 -0
- package/dist/engine/boot-validator/config-edit-action-rules.js +17 -0
- package/dist/engine/boot-validator/config-key-rules.d.ts +117 -0
- package/dist/engine/boot-validator/config-key-rules.js +117 -0
- package/dist/engine/boot-validator/custom-screen-write-qns.js +6 -2
- package/dist/engine/boot-validator/derived-sql-fields-rules.d.ts +77 -0
- package/dist/engine/boot-validator/derived-sql-fields-rules.js +77 -0
- package/dist/engine/boot-validator/derived-sql-fields.js +53 -17
- package/dist/engine/boot-validator/detail-screens.js +10 -4
- package/dist/engine/boot-validator/entity-declaration-rules.d.ts +92 -0
- package/dist/engine/boot-validator/entity-declaration-rules.js +92 -0
- package/dist/engine/boot-validator/entity-handler-access-rules.d.ts +102 -0
- package/dist/engine/boot-validator/entity-handler-access-rules.js +102 -0
- package/dist/engine/boot-validator/entity-handler.d.ts +0 -7
- package/dist/engine/boot-validator/entity-handler.js +259 -355
- package/dist/engine/boot-validator/entity-image-variants.d.ts +2 -0
- package/dist/engine/boot-validator/entity-image-variants.js +91 -0
- package/dist/engine/boot-validator/entity-list-aggregate-options.js +8 -2
- package/dist/engine/boot-validator/entity-reference-embedded-rules.d.ts +117 -0
- package/dist/engine/boot-validator/entity-reference-embedded-rules.js +117 -0
- package/dist/engine/boot-validator/entity-select-image-rules.d.ts +122 -0
- package/dist/engine/boot-validator/entity-select-image-rules.js +122 -0
- package/dist/engine/boot-validator/entity-select.d.ts +8 -0
- package/dist/engine/boot-validator/entity-select.js +197 -0
- package/dist/engine/boot-validator/entity-structure-rules.d.ts +107 -0
- package/dist/engine/boot-validator/entity-structure-rules.js +107 -0
- package/dist/engine/boot-validator/field-conditions-rules.d.ts +92 -0
- package/dist/engine/boot-validator/field-conditions-rules.js +92 -0
- package/dist/engine/boot-validator/field-conditions.js +67 -22
- package/dist/engine/boot-validator/form-derivations-rules.d.ts +77 -0
- package/dist/engine/boot-validator/form-derivations-rules.js +77 -0
- package/dist/engine/boot-validator/form-derivations.js +52 -18
- package/dist/engine/boot-validator/global-tenancy.js +13 -7
- package/dist/engine/boot-validator/handler-declaration-rules.d.ts +77 -0
- package/dist/engine/boot-validator/handler-declaration-rules.js +77 -0
- package/dist/engine/boot-validator/handler-field-references-rules.d.ts +22 -0
- package/dist/engine/boot-validator/handler-field-references-rules.js +22 -0
- package/dist/engine/boot-validator/handler-field-references.js +14 -6
- package/dist/engine/boot-validator/list-bulk-actions-rules.d.ts +42 -0
- package/dist/engine/boot-validator/list-bulk-actions-rules.js +42 -0
- package/dist/engine/boot-validator/list-bulk-actions.js +29 -11
- package/dist/engine/boot-validator/list-column-layout.js +22 -10
- package/dist/engine/boot-validator/list-query-rules.d.ts +107 -0
- package/dist/engine/boot-validator/list-query-rules.js +107 -0
- package/dist/engine/boot-validator/list-table-aggregate-options.js +43 -15
- package/dist/engine/boot-validator/list-table-aggregate-query.js +7 -3
- package/dist/engine/boot-validator/list-table-aggregate-rules.d.ts +82 -0
- package/dist/engine/boot-validator/list-table-aggregate-rules.js +82 -0
- package/dist/engine/boot-validator/list-table-export-options.js +19 -7
- package/dist/engine/boot-validator/list-table-options.js +33 -13
- package/dist/engine/boot-validator/list-table-reject-unknown-keys.js +6 -2
- package/dist/engine/boot-validator/list-table-rules.d.ts +132 -0
- package/dist/engine/boot-validator/list-table-rules.js +132 -0
- package/dist/engine/boot-validator/nav-rules.d.ts +42 -0
- package/dist/engine/boot-validator/nav-rules.js +42 -0
- package/dist/engine/boot-validator/nav.js +33 -17
- package/dist/engine/boot-validator/ownership-rules.d.ts +27 -0
- package/dist/engine/boot-validator/ownership-rules.js +27 -0
- package/dist/engine/boot-validator/ownership.js +28 -12
- package/dist/engine/boot-validator/parent-ref.js +32 -20
- package/dist/engine/boot-validator/projection-list-screens.js +76 -35
- package/dist/engine/boot-validator/query-output-columns.js +9 -3
- package/dist/engine/boot-validator/query-refs.js +20 -10
- package/dist/engine/boot-validator/query-rules.d.ts +37 -0
- package/dist/engine/boot-validator/query-rules.js +37 -0
- package/dist/engine/boot-validator/read-gate.js +14 -10
- package/dist/engine/boot-validator/record-owned.js +5 -1
- package/dist/engine/boot-validator/related-list-table-rules.js +17 -7
- package/dist/engine/boot-validator/screens-actions-rules.d.ts +185 -0
- package/dist/engine/boot-validator/screens-actions-rules.js +185 -0
- package/dist/engine/boot-validator/screens-actions.js +169 -93
- package/dist/engine/boot-validator/screens-dashboard-chart-rules.d.ts +87 -0
- package/dist/engine/boot-validator/screens-dashboard-chart-rules.js +87 -0
- package/dist/engine/boot-validator/screens-dashboard-rules.d.ts +227 -0
- package/dist/engine/boot-validator/screens-dashboard-rules.js +227 -0
- package/dist/engine/boot-validator/screens-dashboard.js +222 -85
- package/dist/engine/boot-validator/screens-forms-layout-rules.d.ts +122 -0
- package/dist/engine/boot-validator/screens-forms-layout-rules.js +122 -0
- package/dist/engine/boot-validator/screens-forms-rules.d.ts +152 -0
- package/dist/engine/boot-validator/screens-forms-rules.js +152 -0
- package/dist/engine/boot-validator/screens-forms.js +240 -112
- package/dist/engine/boot-validator/screens-kind-config-edit.js +72 -16
- package/dist/engine/boot-validator/screens-kind-entity-edit.js +15 -7
- package/dist/engine/boot-validator/screens-kind-entity-list.js +57 -32
- package/dist/engine/boot-validator/screens-kind-projection-detail-rules.d.ts +92 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail-rules.js +92 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail.js +85 -47
- package/dist/engine/boot-validator/screens-kind-rules.d.ts +137 -0
- package/dist/engine/boot-validator/screens-kind-rules.js +137 -0
- package/dist/engine/boot-validator/screens-kind-secret-mint.js +18 -8
- package/dist/engine/boot-validator/screens-kind-shared.js +40 -22
- package/dist/engine/boot-validator/screens-lists-rules.d.ts +82 -0
- package/dist/engine/boot-validator/screens-lists-rules.js +82 -0
- package/dist/engine/boot-validator/screens-lists.js +90 -45
- package/dist/engine/boot-validator/screens-rules.d.ts +57 -0
- package/dist/engine/boot-validator/screens-rules.js +57 -0
- package/dist/engine/boot-validator/screens.js +17 -12
- package/dist/engine/boot-validator/transaction-phases.js +12 -4
- package/dist/engine/boot-validator/transfer-graph.js +17 -11
- package/dist/engine/boot-validator/url-prefill-fields.js +9 -5
- package/dist/engine/boot-validator/workspaces.js +11 -5
- package/dist/engine/boot-validator/zod-shape.js +6 -2
- package/dist/engine/entity-handlers.d.ts +1 -0
- package/dist/engine/entity-handlers.js +3 -0
- package/dist/engine/entity-list-runtime-options.js +23 -29
- package/dist/engine/extensions/tenant-data.d.ts +3 -0
- package/dist/engine/factories.d.ts +1 -1
- package/dist/engine/factories.js +4 -3
- package/dist/engine/index.d.ts +4 -2
- package/dist/engine/index.js +2 -0
- package/dist/engine/project-app-schema-for-roles.js +29 -14
- package/dist/engine/registry-facade.js +7 -8
- package/dist/engine/registry-validate.js +5 -1
- package/dist/engine/soft-delete-cleanup.d.ts +1 -0
- package/dist/engine/soft-delete-cleanup.js +5 -0
- package/dist/engine/steps/describe-workflow-step-error.js +1 -0
- package/dist/es-ops/operations-schema.d.ts +1 -1
- package/dist/event-store/ensure-dead-letter-table.d.ts +2 -0
- package/dist/event-store/ensure-dead-letter-table.js +10 -0
- package/dist/event-store/rebuild-dead-letter.js +2 -8
- package/dist/event-store/upcaster-dead-letter.js +2 -8
- package/dist/files/copy-pending-file-refs-to-tenant.d.ts +28 -0
- package/dist/files/copy-pending-file-refs-to-tenant.js +87 -0
- package/dist/files/file-routes.d.ts +1 -1
- package/dist/files/file-routes.js +21 -6
- package/dist/files/index.d.ts +2 -0
- package/dist/files/index.js +1 -0
- package/dist/i18n/required-surface-keys.js +1 -0
- package/dist/jobs/job-runner-helpers.js +1 -0
- package/dist/jobs/job-runner.js +7 -12
- package/dist/logging/utils.js +30 -60
- package/dist/observability/metrics-handle.js +10 -21
- package/dist/pipeline/cascade-handler.js +7 -6
- package/dist/pipeline/dispatch-query.js +18 -5
- package/dist/pipeline/dispatch-shared.d.ts +1 -0
- package/dist/pipeline/dispatch-shared.js +3 -1
- package/dist/pipeline/dispatch-write.js +10 -12
- package/dist/pipeline/dispatcher.js +12 -14
- package/dist/pipeline/event-dispatcher-admin.js +9 -8
- package/dist/pipeline/event-dispatcher-delivery.d.ts +19 -1
- package/dist/pipeline/event-dispatcher-delivery.js +121 -29
- package/dist/pipeline/event-dispatcher.d.ts +5 -1
- package/dist/pipeline/event-dispatcher.js +28 -21
- package/dist/pipeline/handler-context-phase-denials.js +2 -0
- package/dist/pipeline/multi-stream-apply-context.js +12 -20
- package/dist/pipeline/system-hooks.d.ts +4 -1
- package/dist/pipeline/system-hooks.js +79 -6
- package/dist/pipeline/system-identity-switch.js +10 -7
- package/dist/search/build-search-snippet.d.ts +9 -0
- package/dist/search/build-search-snippet.js +40 -0
- package/dist/search/index.d.ts +1 -0
- package/dist/search/index.js +1 -0
- package/dist/search/meilisearch-adapter.d.ts +32 -0
- package/dist/search/meilisearch-adapter.js +153 -56
- package/dist/search/meilisearch-chunking.d.ts +21 -0
- package/dist/search/meilisearch-chunking.js +96 -0
- package/dist/search/reindex-entity.d.ts +1 -0
- package/dist/search/reindex-entity.js +97 -52
- package/dist/ui-types/index.d.ts +1 -1
- package/dist/upgrade-cli.js +3 -14
- package/package.json +3 -3
- package/src/changes.json +79 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { isFileSubField } from "../../files/file-field-slots.js";
|
|
2
2
|
import { parseMaxSize } from "../../files/types.js";
|
|
3
3
|
import { isFileField } from "../field-helpers.js";
|
|
4
|
-
import {
|
|
4
|
+
import { bootRuleError } from "./boot-rule.js";
|
|
5
|
+
import { LOCKABLE_FIELD_TYPES } from "./entity-handler.js";
|
|
6
|
+
import { conditionComparisonValues } from "./entity-select.js";
|
|
7
|
+
import { FIELD_CONDITION_RULES } from "./field-conditions-rules.js";
|
|
5
8
|
const STATE_KEYS = ["visibleWhen", "requiredWhen"];
|
|
6
9
|
const SUB_CONDITION_TYPES = new Set([
|
|
7
10
|
"text",
|
|
@@ -19,29 +22,41 @@ function assertNoRequiredConflict(where, def, required) {
|
|
|
19
22
|
if (!required)
|
|
20
23
|
return;
|
|
21
24
|
if (def.requiredWhen !== undefined) {
|
|
22
|
-
throw
|
|
25
|
+
throw bootRuleError(FIELD_CONDITION_RULES.requiredWithRequiredWhen, {
|
|
26
|
+
message: `${where} sets required: true together with requiredWhen — drop required (requiredWhen covers the conditional case).`,
|
|
27
|
+
});
|
|
23
28
|
}
|
|
24
29
|
if (def.visibleWhen !== undefined) {
|
|
25
|
-
throw
|
|
30
|
+
throw bootRuleError(FIELD_CONDITION_RULES.requiredWithVisibleWhen, {
|
|
31
|
+
message: `${where} sets required: true together with visibleWhen — a hidden field cannot be required; use requiredWhen with the same condition.`,
|
|
32
|
+
});
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
function assertComparisonValuesAreOptions(where, key, condition, options) {
|
|
29
36
|
for (const value of conditionComparisonValues(condition)) {
|
|
30
37
|
if (typeof value !== "string" || !options.includes(value)) {
|
|
31
|
-
throw
|
|
38
|
+
throw bootRuleError(FIELD_CONDITION_RULES.comparisonValueNotOption, {
|
|
39
|
+
message: `${where} has ${key} value "${String(value)}" which is not an option of "${condition.field}" (${options.join(", ")}).`,
|
|
40
|
+
});
|
|
32
41
|
}
|
|
33
42
|
}
|
|
34
43
|
}
|
|
35
44
|
function assertTopLevelCondition(where, key, fieldName, condition, entity) {
|
|
36
45
|
const target = entity.fields[condition.field];
|
|
37
46
|
if (condition.field === fieldName) {
|
|
38
|
-
throw
|
|
47
|
+
throw bootRuleError(FIELD_CONDITION_RULES.conditionOnOwnField, {
|
|
48
|
+
message: `${where} has ${key} on its own field. Make the condition depend on a different field.`,
|
|
49
|
+
});
|
|
39
50
|
}
|
|
40
51
|
if (target === undefined) {
|
|
41
|
-
throw
|
|
52
|
+
throw bootRuleError(FIELD_CONDITION_RULES.unknownConditionField, {
|
|
53
|
+
message: `${where} has ${key}.field "${condition.field}" which is not a field of the entity. Use an existing field of the entity.`,
|
|
54
|
+
});
|
|
42
55
|
}
|
|
43
56
|
if (!LOCKABLE_FIELD_TYPES.has(target.type)) {
|
|
44
|
-
throw
|
|
57
|
+
throw bootRuleError(FIELD_CONDITION_RULES.conditionFieldTypeNotComparable, {
|
|
58
|
+
message: `${where} has ${key}.field "${condition.field}" of type "${target.type}", which does not store a plain scalar the condition can compare. Use a text, select, boolean, number or reference field.`,
|
|
59
|
+
});
|
|
45
60
|
}
|
|
46
61
|
if (target.type === "select") {
|
|
47
62
|
assertComparisonValuesAreOptions(where, key, condition, target.options);
|
|
@@ -50,13 +65,19 @@ function assertTopLevelCondition(where, key, fieldName, condition, entity) {
|
|
|
50
65
|
function assertSubFieldCondition(where, key, subName, condition, embedded) {
|
|
51
66
|
const target = embedded.schema[condition.field];
|
|
52
67
|
if (condition.field === subName) {
|
|
53
|
-
throw
|
|
68
|
+
throw bootRuleError(FIELD_CONDITION_RULES.conditionOnOwnField, {
|
|
69
|
+
message: `${where} has ${key} on its own sub-field. Make the condition depend on a sibling.`,
|
|
70
|
+
});
|
|
54
71
|
}
|
|
55
72
|
if (target === undefined) {
|
|
56
|
-
throw
|
|
73
|
+
throw bootRuleError(FIELD_CONDITION_RULES.unknownConditionField, {
|
|
74
|
+
message: `${where} has ${key}.field "${condition.field}" which is not a sub-field of the same row. Use a sibling sub-field.`,
|
|
75
|
+
});
|
|
57
76
|
}
|
|
58
77
|
if (!SUB_CONDITION_TYPES.has(target.type)) {
|
|
59
|
-
throw
|
|
78
|
+
throw bootRuleError(FIELD_CONDITION_RULES.conditionFieldTypeNotComparable, {
|
|
79
|
+
message: `${where} has ${key}.field "${condition.field}" of type "${target.type}", which cannot be compared. Use a text, number, decimal, money, boolean, date, select or reference sub-field.`,
|
|
80
|
+
});
|
|
60
81
|
}
|
|
61
82
|
if (target.type === "select") {
|
|
62
83
|
const stateKey = key === "when" ? "visibleWhen" : key;
|
|
@@ -65,17 +86,23 @@ function assertSubFieldCondition(where, key, subName, condition, embedded) {
|
|
|
65
86
|
}
|
|
66
87
|
function assertFileSubField(where, sub) {
|
|
67
88
|
if (sub.searchable === true) {
|
|
68
|
-
throw
|
|
89
|
+
throw bootRuleError(FIELD_CONDITION_RULES.fileSubFieldSearchable, {
|
|
90
|
+
message: `${where} is a ${sub.type} sub-field and cannot be searchable.`,
|
|
91
|
+
});
|
|
69
92
|
}
|
|
70
93
|
if (sub.maxCount !== undefined && !(Number.isInteger(sub.maxCount) && sub.maxCount > 0)) {
|
|
71
|
-
throw
|
|
94
|
+
throw bootRuleError(FIELD_CONDITION_RULES.fileMaxCountInvalid, {
|
|
95
|
+
message: `${where} has invalid maxCount ${sub.maxCount}. Must be a positive integer.`,
|
|
96
|
+
});
|
|
72
97
|
}
|
|
73
98
|
if (sub.maxSize !== undefined) {
|
|
74
99
|
try {
|
|
75
100
|
parseMaxSize(sub.maxSize);
|
|
76
101
|
}
|
|
77
102
|
catch {
|
|
78
|
-
throw
|
|
103
|
+
throw bootRuleError(FIELD_CONDITION_RULES.fileMaxSizeInvalid, {
|
|
104
|
+
message: `${where} has invalid maxSize "${sub.maxSize}". Use e.g. "10mb", "500kb".`,
|
|
105
|
+
});
|
|
79
106
|
}
|
|
80
107
|
}
|
|
81
108
|
assertAcceptEntries(where, sub.accept);
|
|
@@ -85,11 +112,15 @@ function assertFileSubField(where, sub) {
|
|
|
85
112
|
const BARE_EXTENSION = /^[a-z0-9]+$/;
|
|
86
113
|
function assertAcceptEntries(where, accept) {
|
|
87
114
|
if (accept?.some((ext) => ext.length === 0)) {
|
|
88
|
-
throw
|
|
115
|
+
throw bootRuleError(FIELD_CONDITION_RULES.acceptEntryEmpty, {
|
|
116
|
+
message: `${where} has an empty entry in accept. List file extensions like "pdf".`,
|
|
117
|
+
});
|
|
89
118
|
}
|
|
90
119
|
const offender = accept?.find((entry) => !BARE_EXTENSION.test(entry));
|
|
91
120
|
if (offender !== undefined) {
|
|
92
|
-
throw
|
|
121
|
+
throw bootRuleError(FIELD_CONDITION_RULES.acceptEntryNotBareExtension, {
|
|
122
|
+
message: `${where} has accept entry "${offender}", which can never match an uploaded file. accept takes bare lower-case file extensions without dot, MIME type or wildcard: use "pdf" instead of ".pdf" or "application/pdf".`,
|
|
123
|
+
});
|
|
93
124
|
}
|
|
94
125
|
}
|
|
95
126
|
function assertSelectSubFieldTones(where, sub) {
|
|
@@ -98,7 +129,9 @@ function assertSelectSubFieldTones(where, sub) {
|
|
|
98
129
|
return;
|
|
99
130
|
for (const option of Object.keys(sub.optionTones)) {
|
|
100
131
|
if (!sub.options.includes(option)) {
|
|
101
|
-
throw
|
|
132
|
+
throw bootRuleError(FIELD_CONDITION_RULES.optionToneNotAnOption, {
|
|
133
|
+
message: `${where} has optionTones["${option}"] which is not an option (${sub.options.join(", ")}).`,
|
|
134
|
+
});
|
|
102
135
|
}
|
|
103
136
|
}
|
|
104
137
|
}
|
|
@@ -120,7 +153,9 @@ function assertNumericSources(where, derivedName, embedded, from) {
|
|
|
120
153
|
for (const source of from) {
|
|
121
154
|
const sourceType = embedded.schema[source]?.type;
|
|
122
155
|
if (sourceType === undefined || !NUMERIC_SUB_TYPES.has(sourceType)) {
|
|
123
|
-
throw
|
|
156
|
+
throw bootRuleError(FIELD_CONDITION_RULES.derivedSourceNotNumeric, {
|
|
157
|
+
message: `${where} has a derived cell "${derivedName}" reading "${source}", which is not a number, decimal or money sub-field.`,
|
|
158
|
+
});
|
|
124
159
|
}
|
|
125
160
|
}
|
|
126
161
|
}
|
|
@@ -130,21 +165,29 @@ function assertDerivedCells(where, embedded) {
|
|
|
130
165
|
assertNumericSources(where, name, embedded, cell.from);
|
|
131
166
|
if (cell.op === "inRange") {
|
|
132
167
|
if (cell.from.length !== 3) {
|
|
133
|
-
throw
|
|
168
|
+
throw bootRuleError(FIELD_CONDITION_RULES.inRangeNeedsThreeSources, {
|
|
169
|
+
message: `${where} has a derived cell "${name}" with op "inRange", which needs exactly three sources (value, min, max).`,
|
|
170
|
+
});
|
|
134
171
|
}
|
|
135
172
|
if (target?.type !== "select" ||
|
|
136
173
|
!target.options.includes(cell.inside) ||
|
|
137
174
|
!target.options.includes(cell.outside)) {
|
|
138
|
-
throw
|
|
175
|
+
throw bootRuleError(FIELD_CONDITION_RULES.inRangeTargetNotSelect, {
|
|
176
|
+
message: `${where} has a derived cell "${name}" with op "inRange", whose target must be a select sub-field with the options "${cell.inside}" and "${cell.outside}".`,
|
|
177
|
+
});
|
|
139
178
|
}
|
|
140
179
|
}
|
|
141
180
|
else if (target === undefined || !NUMERIC_SUB_TYPES.has(target.type)) {
|
|
142
|
-
throw
|
|
181
|
+
throw bootRuleError(FIELD_CONDITION_RULES.derivedTargetNotNumeric, {
|
|
182
|
+
message: `${where} has a derived cell "${name}" with op "${cell.op}", whose target must be a number, decimal or money sub-field.`,
|
|
183
|
+
});
|
|
143
184
|
}
|
|
144
185
|
if (cell.when !== undefined) {
|
|
145
186
|
assertSubFieldCondition(`${where}.${name}`, "when", undefined, cell.when, embedded);
|
|
146
187
|
if (cell.when.field in (embedded.derived ?? {})) {
|
|
147
|
-
throw
|
|
188
|
+
throw bootRuleError(FIELD_CONDITION_RULES.derivedWhenReadsDerived, {
|
|
189
|
+
message: `${where} has a derived cell "${name}" whose when reads the derived cell "${cell.when.field}". Read a stored sub-field.`,
|
|
190
|
+
});
|
|
148
191
|
}
|
|
149
192
|
}
|
|
150
193
|
}
|
|
@@ -161,7 +204,9 @@ function assertFileSubFieldsAreNotWired(where, embedded) {
|
|
|
161
204
|
];
|
|
162
205
|
const offender = wired.find((name) => fileSubs.has(name));
|
|
163
206
|
if (offender !== undefined) {
|
|
164
|
-
throw
|
|
207
|
+
throw bootRuleError(FIELD_CONDITION_RULES.fileSubFieldInDerived, {
|
|
208
|
+
message: `${where} uses file sub-field "${offender}" in derived or totals, which only take number, decimal or money sub-fields.`,
|
|
209
|
+
});
|
|
165
210
|
}
|
|
166
211
|
}
|
|
167
212
|
function assertEmbeddedField(where, embedded) {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export declare const FORM_DERIVATION_RULES: {
|
|
2
|
+
readonly sourcesMoneyMixed: {
|
|
3
|
+
readonly id: "form-derive/sources-money-mixed";
|
|
4
|
+
readonly summary: "The sources of a sum or subtract derivation are all money or all number/decimal.";
|
|
5
|
+
readonly fix: "Use sources of one kind.";
|
|
6
|
+
};
|
|
7
|
+
readonly targetKindMismatch: {
|
|
8
|
+
readonly id: "form-derive/target-kind-mismatch";
|
|
9
|
+
readonly summary: "A derivation's target is money exactly when its sources are money.";
|
|
10
|
+
readonly fix: "Change the target field type to match the sources.";
|
|
11
|
+
};
|
|
12
|
+
readonly tooManyMoneySources: {
|
|
13
|
+
readonly id: "form-derive/too-many-money-sources";
|
|
14
|
+
readonly summary: "A derivation other than sum/subtract takes at most one money source.";
|
|
15
|
+
readonly fix: "Use at most one money source (for percent: the base, not the rate).";
|
|
16
|
+
};
|
|
17
|
+
readonly percentNeedsTwoSources: {
|
|
18
|
+
readonly id: "form-derive/percent-needs-two-sources";
|
|
19
|
+
readonly summary: 'A "percent" derivation has exactly two sources (base, rate).';
|
|
20
|
+
readonly fix: "List base and rate in from.";
|
|
21
|
+
};
|
|
22
|
+
readonly unknownSourceField: {
|
|
23
|
+
readonly id: "form-derive/unknown-source-field";
|
|
24
|
+
readonly summary: "Every derivation source is a field of the screen.";
|
|
25
|
+
readonly fix: "Name a field of this screen.";
|
|
26
|
+
};
|
|
27
|
+
readonly sourceNotNumeric: {
|
|
28
|
+
readonly id: "form-derive/source-not-numeric";
|
|
29
|
+
readonly summary: "Every derivation source is a money, number or decimal field.";
|
|
30
|
+
readonly fix: "Use money, number or decimal source fields.";
|
|
31
|
+
};
|
|
32
|
+
readonly unknownListField: {
|
|
33
|
+
readonly id: "form-derive/unknown-list-field";
|
|
34
|
+
readonly summary: "The list of a listSum derivation is a field of the screen.";
|
|
35
|
+
readonly fix: "Name a field of this screen.";
|
|
36
|
+
};
|
|
37
|
+
readonly listNotEmbeddedList: {
|
|
38
|
+
readonly id: "form-derive/list-not-embedded-list";
|
|
39
|
+
readonly summary: "The list of a listSum derivation is an embedded list field.";
|
|
40
|
+
readonly fix: "Use an embedded field with multiple: true.";
|
|
41
|
+
};
|
|
42
|
+
readonly cellNotNumeric: {
|
|
43
|
+
readonly id: "form-derive/cell-not-numeric";
|
|
44
|
+
readonly summary: "The cell of a listSum derivation is a money, number or decimal sub-field.";
|
|
45
|
+
readonly fix: "Name a numeric sub-field of the list.";
|
|
46
|
+
};
|
|
47
|
+
readonly listSumKindMismatch: {
|
|
48
|
+
readonly id: "form-derive/list-sum-kind-mismatch";
|
|
49
|
+
readonly summary: "A listSum target is money exactly when its cell is money.";
|
|
50
|
+
readonly fix: "Change the target field type to match the cell.";
|
|
51
|
+
};
|
|
52
|
+
readonly whenEmptyListSum: {
|
|
53
|
+
readonly id: "form-derive/when-empty-list-sum";
|
|
54
|
+
readonly summary: "whenEmpty of a listSum is not itself a listSum.";
|
|
55
|
+
readonly fix: "Use a from-based derivation as whenEmpty.";
|
|
56
|
+
};
|
|
57
|
+
readonly unknownTarget: {
|
|
58
|
+
readonly id: "form-derive/unknown-target";
|
|
59
|
+
readonly summary: "Every derive key is a field of the screen.";
|
|
60
|
+
readonly fix: "Use a field name of this screen as key.";
|
|
61
|
+
};
|
|
62
|
+
readonly targetNotNumeric: {
|
|
63
|
+
readonly id: "form-derive/target-not-numeric";
|
|
64
|
+
readonly summary: "A derived field is a money, number or decimal field.";
|
|
65
|
+
readonly fix: "Change the target field type to money, number or decimal.";
|
|
66
|
+
};
|
|
67
|
+
readonly invalidOrder: {
|
|
68
|
+
readonly id: "form-derive/invalid-order";
|
|
69
|
+
readonly summary: "Derivations have a valid evaluation order (no cycles).";
|
|
70
|
+
readonly fix: "Remove the dependency cycle between derived fields.";
|
|
71
|
+
};
|
|
72
|
+
readonly handlerNotWrapped: {
|
|
73
|
+
readonly id: "form-derive/handler-not-wrapped";
|
|
74
|
+
readonly summary: "A screen that declares derive uses a handler wrapped with withFormDerivations.";
|
|
75
|
+
readonly fix: "Wrap the handler schema: withFormDerivations(schema, screen) with this screen object.";
|
|
76
|
+
};
|
|
77
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const FORM_DERIVATION_RULES = {
|
|
2
|
+
sourcesMoneyMixed: {
|
|
3
|
+
id: "form-derive/sources-money-mixed",
|
|
4
|
+
summary: "The sources of a sum or subtract derivation are all money or all number/decimal.",
|
|
5
|
+
fix: "Use sources of one kind.",
|
|
6
|
+
},
|
|
7
|
+
targetKindMismatch: {
|
|
8
|
+
id: "form-derive/target-kind-mismatch",
|
|
9
|
+
summary: "A derivation's target is money exactly when its sources are money.",
|
|
10
|
+
fix: "Change the target field type to match the sources.",
|
|
11
|
+
},
|
|
12
|
+
tooManyMoneySources: {
|
|
13
|
+
id: "form-derive/too-many-money-sources",
|
|
14
|
+
summary: "A derivation other than sum/subtract takes at most one money source.",
|
|
15
|
+
fix: "Use at most one money source (for percent: the base, not the rate).",
|
|
16
|
+
},
|
|
17
|
+
percentNeedsTwoSources: {
|
|
18
|
+
id: "form-derive/percent-needs-two-sources",
|
|
19
|
+
summary: 'A "percent" derivation has exactly two sources (base, rate).',
|
|
20
|
+
fix: "List base and rate in from.",
|
|
21
|
+
},
|
|
22
|
+
unknownSourceField: {
|
|
23
|
+
id: "form-derive/unknown-source-field",
|
|
24
|
+
summary: "Every derivation source is a field of the screen.",
|
|
25
|
+
fix: "Name a field of this screen.",
|
|
26
|
+
},
|
|
27
|
+
sourceNotNumeric: {
|
|
28
|
+
id: "form-derive/source-not-numeric",
|
|
29
|
+
summary: "Every derivation source is a money, number or decimal field.",
|
|
30
|
+
fix: "Use money, number or decimal source fields.",
|
|
31
|
+
},
|
|
32
|
+
unknownListField: {
|
|
33
|
+
id: "form-derive/unknown-list-field",
|
|
34
|
+
summary: "The list of a listSum derivation is a field of the screen.",
|
|
35
|
+
fix: "Name a field of this screen.",
|
|
36
|
+
},
|
|
37
|
+
listNotEmbeddedList: {
|
|
38
|
+
id: "form-derive/list-not-embedded-list",
|
|
39
|
+
summary: "The list of a listSum derivation is an embedded list field.",
|
|
40
|
+
fix: "Use an embedded field with multiple: true.",
|
|
41
|
+
},
|
|
42
|
+
cellNotNumeric: {
|
|
43
|
+
id: "form-derive/cell-not-numeric",
|
|
44
|
+
summary: "The cell of a listSum derivation is a money, number or decimal sub-field.",
|
|
45
|
+
fix: "Name a numeric sub-field of the list.",
|
|
46
|
+
},
|
|
47
|
+
listSumKindMismatch: {
|
|
48
|
+
id: "form-derive/list-sum-kind-mismatch",
|
|
49
|
+
summary: "A listSum target is money exactly when its cell is money.",
|
|
50
|
+
fix: "Change the target field type to match the cell.",
|
|
51
|
+
},
|
|
52
|
+
whenEmptyListSum: {
|
|
53
|
+
id: "form-derive/when-empty-list-sum",
|
|
54
|
+
summary: "whenEmpty of a listSum is not itself a listSum.",
|
|
55
|
+
fix: "Use a from-based derivation as whenEmpty.",
|
|
56
|
+
},
|
|
57
|
+
unknownTarget: {
|
|
58
|
+
id: "form-derive/unknown-target",
|
|
59
|
+
summary: "Every derive key is a field of the screen.",
|
|
60
|
+
fix: "Use a field name of this screen as key.",
|
|
61
|
+
},
|
|
62
|
+
targetNotNumeric: {
|
|
63
|
+
id: "form-derive/target-not-numeric",
|
|
64
|
+
summary: "A derived field is a money, number or decimal field.",
|
|
65
|
+
fix: "Change the target field type to money, number or decimal.",
|
|
66
|
+
},
|
|
67
|
+
invalidOrder: {
|
|
68
|
+
id: "form-derive/invalid-order",
|
|
69
|
+
summary: "Derivations have a valid evaluation order (no cycles).",
|
|
70
|
+
fix: "Remove the dependency cycle between derived fields.",
|
|
71
|
+
},
|
|
72
|
+
handlerNotWrapped: {
|
|
73
|
+
id: "form-derive/handler-not-wrapped",
|
|
74
|
+
summary: "A screen that declares derive uses a handler wrapped with withFormDerivations.",
|
|
75
|
+
fix: "Wrap the handler schema: withFormDerivations(schema, screen) with this screen object.",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { orderFormDerivations } from "../form-derivations.js";
|
|
2
2
|
import { parseQn } from "../qualified-name.js";
|
|
3
3
|
import { formDerivationsOfSchema } from "../with-form-derivations.js";
|
|
4
|
+
import { bootRuleError } from "./boot-rule.js";
|
|
5
|
+
import { FORM_DERIVATION_RULES } from "./form-derivations-rules.js";
|
|
4
6
|
const NUMERIC_FORM_FIELD_TYPES = ["money", "number", "decimal"];
|
|
5
7
|
const NUMERIC_SUB_FIELD_TYPES = ["money", "number", "decimal"];
|
|
6
8
|
function isMoneyType(type) {
|
|
@@ -14,32 +16,46 @@ function validateUnitCompatibility({ prefix, screen, target }, derivation) {
|
|
|
14
16
|
const moneyCount = moneyFlags.filter(Boolean).length;
|
|
15
17
|
if (derivation.op === "sum" || derivation.op === "subtract") {
|
|
16
18
|
if (moneyCount !== 0 && moneyCount !== moneyFlags.length) {
|
|
17
|
-
throw
|
|
19
|
+
throw bootRuleError(FORM_DERIVATION_RULES.sourcesMoneyMixed, {
|
|
20
|
+
message: `${prefix}.${target}: "${derivation.op}" sources must be all money or all number/decimal.`,
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
23
|
if (moneyCount > 0 !== targetIsMoney) {
|
|
20
|
-
throw
|
|
24
|
+
throw bootRuleError(FORM_DERIVATION_RULES.targetKindMismatch, {
|
|
25
|
+
message: `${prefix}.${target}: a "${derivation.op}" over ${moneyCount > 0 ? "money" : "number/decimal"} sources needs a ${moneyCount > 0 ? "money" : "number/decimal"} target.`,
|
|
26
|
+
});
|
|
21
27
|
}
|
|
22
28
|
// skip: sum/subtract fully validated above.
|
|
23
29
|
return;
|
|
24
30
|
}
|
|
25
31
|
if (moneyCount > 1 || (derivation.op === "percent" && moneyFlags[1] === true)) {
|
|
26
|
-
throw
|
|
32
|
+
throw bootRuleError(FORM_DERIVATION_RULES.tooManyMoneySources, {
|
|
33
|
+
message: `${prefix}.${target}: "${derivation.op}" takes at most one money source${derivation.op === "percent" ? " (the base, not the rate)" : ""}.`,
|
|
34
|
+
});
|
|
27
35
|
}
|
|
28
36
|
if ((moneyCount === 1) !== targetIsMoney) {
|
|
29
|
-
throw
|
|
37
|
+
throw bootRuleError(FORM_DERIVATION_RULES.targetKindMismatch, {
|
|
38
|
+
message: `${prefix}.${target}: the target must be money exactly when a "${derivation.op}" source is money.`,
|
|
39
|
+
});
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
42
|
function validateFromList({ prefix, screen, target }, derivation) {
|
|
33
43
|
if (derivation.op === "percent" && derivation.from.length !== 2) {
|
|
34
|
-
throw
|
|
44
|
+
throw bootRuleError(FORM_DERIVATION_RULES.percentNeedsTwoSources, {
|
|
45
|
+
message: `${prefix}.${target}: "percent" needs exactly two sources (base, rate).`,
|
|
46
|
+
});
|
|
35
47
|
}
|
|
36
48
|
for (const source of derivation.from) {
|
|
37
49
|
const sourceField = screen.fields[source];
|
|
38
50
|
if (sourceField === undefined) {
|
|
39
|
-
throw
|
|
51
|
+
throw bootRuleError(FORM_DERIVATION_RULES.unknownSourceField, {
|
|
52
|
+
message: `${prefix}.${target}: unknown source field "${source}". Name a field of this screen.`,
|
|
53
|
+
});
|
|
40
54
|
}
|
|
41
55
|
if (!NUMERIC_FORM_FIELD_TYPES.includes(sourceField.type)) {
|
|
42
|
-
throw
|
|
56
|
+
throw bootRuleError(FORM_DERIVATION_RULES.sourceNotNumeric, {
|
|
57
|
+
message: `${prefix}.${target}: source "${source}" must be money, number or decimal, not "${sourceField.type}".`,
|
|
58
|
+
});
|
|
43
59
|
}
|
|
44
60
|
}
|
|
45
61
|
validateUnitCompatibility({ prefix, screen, target }, derivation);
|
|
@@ -48,17 +64,25 @@ function validateListSum(check, derivation) {
|
|
|
48
64
|
const { prefix, screen, target } = check;
|
|
49
65
|
const listField = screen.fields[derivation.list];
|
|
50
66
|
if (listField === undefined) {
|
|
51
|
-
throw
|
|
67
|
+
throw bootRuleError(FORM_DERIVATION_RULES.unknownListField, {
|
|
68
|
+
message: `${prefix}.${target}: unknown list field "${derivation.list}".`,
|
|
69
|
+
});
|
|
52
70
|
}
|
|
53
71
|
if (listField.type !== "embedded" || listField.multiple !== true) {
|
|
54
|
-
throw
|
|
72
|
+
throw bootRuleError(FORM_DERIVATION_RULES.listNotEmbeddedList, {
|
|
73
|
+
message: `${prefix}.${target}: "${derivation.list}" must be an embedded list field (multiple: true).`,
|
|
74
|
+
});
|
|
55
75
|
}
|
|
56
76
|
const cellType = listField.schema[derivation.cell]?.type;
|
|
57
77
|
if (cellType === undefined || !NUMERIC_SUB_FIELD_TYPES.includes(cellType)) {
|
|
58
|
-
throw
|
|
78
|
+
throw bootRuleError(FORM_DERIVATION_RULES.cellNotNumeric, {
|
|
79
|
+
message: `${prefix}.${target}: "${derivation.cell}" must be a money, number or decimal sub-field of "${derivation.list}".`,
|
|
80
|
+
});
|
|
59
81
|
}
|
|
60
82
|
if (isMoneyType(cellType) !== isMoneyType(screen.fields[target]?.type)) {
|
|
61
|
-
throw
|
|
83
|
+
throw bootRuleError(FORM_DERIVATION_RULES.listSumKindMismatch, {
|
|
84
|
+
message: `${prefix}.${target}: a listSum of a ${isMoneyType(cellType) ? "money" : "number/decimal"} cell needs a ${isMoneyType(cellType) ? "money" : "number/decimal"} target.`,
|
|
85
|
+
});
|
|
62
86
|
}
|
|
63
87
|
const { whenEmpty } = derivation;
|
|
64
88
|
// skip: whenEmpty is optional
|
|
@@ -66,7 +90,9 @@ function validateListSum(check, derivation) {
|
|
|
66
90
|
return;
|
|
67
91
|
// Type forbids a nested listSum; JS/cast callers can still pass one.
|
|
68
92
|
if (!("from" in whenEmpty)) {
|
|
69
|
-
throw
|
|
93
|
+
throw bootRuleError(FORM_DERIVATION_RULES.whenEmptyListSum, {
|
|
94
|
+
message: `${prefix}.${target}: whenEmpty must not be a listSum.`,
|
|
95
|
+
});
|
|
70
96
|
}
|
|
71
97
|
validateFromList(check, whenEmpty);
|
|
72
98
|
}
|
|
@@ -81,10 +107,14 @@ export function validateFormDerivations(featureName, screenId, screen) {
|
|
|
81
107
|
for (const [target, derivation] of Object.entries(derive)) {
|
|
82
108
|
const targetField = screen.fields[target];
|
|
83
109
|
if (targetField === undefined) {
|
|
84
|
-
throw
|
|
110
|
+
throw bootRuleError(FORM_DERIVATION_RULES.unknownTarget, {
|
|
111
|
+
message: `${prefix}: key "${target}" is not a field of this screen.`,
|
|
112
|
+
});
|
|
85
113
|
}
|
|
86
114
|
if (!NUMERIC_FORM_FIELD_TYPES.includes(targetField.type)) {
|
|
87
|
-
throw
|
|
115
|
+
throw bootRuleError(FORM_DERIVATION_RULES.targetNotNumeric, {
|
|
116
|
+
message: `${prefix}.${target}: a derived field must be money, number or decimal, not "${targetField.type}".`,
|
|
117
|
+
});
|
|
88
118
|
}
|
|
89
119
|
const check = { prefix, screen, target };
|
|
90
120
|
if (derivation.op === "listSum")
|
|
@@ -96,7 +126,9 @@ export function validateFormDerivations(featureName, screenId, screen) {
|
|
|
96
126
|
orderFormDerivations(derive);
|
|
97
127
|
}
|
|
98
128
|
catch (error) {
|
|
99
|
-
throw
|
|
129
|
+
throw bootRuleError(FORM_DERIVATION_RULES.invalidOrder, {
|
|
130
|
+
message: `${prefix}: ${error instanceof Error ? error.message : String(error)}`,
|
|
131
|
+
});
|
|
100
132
|
}
|
|
101
133
|
}
|
|
102
134
|
// Secure by default: a derive the handler schema doesn't recompute would let a
|
|
@@ -110,7 +142,9 @@ export function validateFormDerivationsEnforced(featureName, screenId, screen, f
|
|
|
110
142
|
// skip: wrapped with this screen
|
|
111
143
|
if (formDerivationsOfSchema(schema) === screen.derive)
|
|
112
144
|
return;
|
|
113
|
-
throw
|
|
114
|
-
`"${
|
|
115
|
-
|
|
145
|
+
throw bootRuleError(FORM_DERIVATION_RULES.handlerNotWrapped, {
|
|
146
|
+
message: `[Feature ${featureName}] Screen "${screenId}" (actionForm) declares derive, but handler ` +
|
|
147
|
+
`"${screen.handler}" does not recompute it on the server. Wrap the handler schema: ` +
|
|
148
|
+
`withFormDerivations(schema, screen) with this screen object.`,
|
|
149
|
+
});
|
|
116
150
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bootRuleError } from "./boot-rule.js";
|
|
2
|
+
import { ENTITY_DECLARATION_RULES } from "./entity-declaration-rules.js";
|
|
1
3
|
// Boot-time twin of event-store-executor-context.ts's buildExecutorContext check —
|
|
2
4
|
// surfaces the systemStream invariant once across all features before any dispatch.
|
|
3
5
|
//
|
|
@@ -9,15 +11,19 @@ export function validateGlobalTenancyEntities(features) {
|
|
|
9
11
|
if (entity.tenancy !== "global")
|
|
10
12
|
continue;
|
|
11
13
|
if (entity.systemStream !== true) {
|
|
12
|
-
throw
|
|
13
|
-
"
|
|
14
|
-
|
|
14
|
+
throw bootRuleError(ENTITY_DECLARATION_RULES.globalWithoutSystemStream, {
|
|
15
|
+
message: `Feature "${feature.name}" entity "${entityName}": tenancy: "global" entities must ` +
|
|
16
|
+
"also declare systemStream: true — a global aggregate's event stream must live on " +
|
|
17
|
+
"the system tenant, not the creating tenant's.",
|
|
18
|
+
});
|
|
15
19
|
}
|
|
16
20
|
if (!feature.systemScope) {
|
|
17
|
-
throw
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
throw bootRuleError(ENTITY_DECLARATION_RULES.globalWithoutSystemScope, {
|
|
22
|
+
message: `Feature "${feature.name}" entity "${entityName}": tenancy: "global" entities require ` +
|
|
23
|
+
"their owning feature to declare r.systemScope() — without it, convention writes run " +
|
|
24
|
+
"in tenant-mode and a global row could end up carrying the creating tenant's id " +
|
|
25
|
+
"instead of the system tenant's.",
|
|
26
|
+
});
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export declare const HANDLER_DECLARATION_RULES: {
|
|
2
|
+
readonly openToAllReasonInvalid: {
|
|
3
|
+
readonly id: "handler/open-to-all-reason-invalid";
|
|
4
|
+
readonly summary: "An openToAll declaration is an object with a valid reason explaining why any authenticated user may call the handler.";
|
|
5
|
+
readonly fix: 'Declare { openToAll: { reason: "<explanation>" } }.';
|
|
6
|
+
};
|
|
7
|
+
readonly escapeHatchGrantsInvalid: {
|
|
8
|
+
readonly id: "handler/escape-hatch-grants-invalid";
|
|
9
|
+
readonly summary: "An escapeHatch declares valid grants.";
|
|
10
|
+
readonly fix: "Correct the escapeHatch grants as named in the error message.";
|
|
11
|
+
};
|
|
12
|
+
readonly escapeHatchReasonInvalid: {
|
|
13
|
+
readonly id: "handler/escape-hatch-reason-invalid";
|
|
14
|
+
readonly summary: "An escapeHatch carries a valid reason.";
|
|
15
|
+
readonly fix: "Write an escapeHatch reason that explains the bypass.";
|
|
16
|
+
};
|
|
17
|
+
readonly personalDataUnsupportedForKind: {
|
|
18
|
+
readonly id: "handler/personal-data-unsupported-for-kind";
|
|
19
|
+
readonly summary: "A personalData declaration appears only on handler kinds whose input is checked for personal-data fields.";
|
|
20
|
+
readonly fix: "Remove the personalData declaration from this handler.";
|
|
21
|
+
};
|
|
22
|
+
readonly openToAllPersonalDataUnknown: {
|
|
23
|
+
readonly id: "handler/open-to-all-personal-data-unknown";
|
|
24
|
+
readonly summary: 'openToAll.personalData is "tenant-members" when set.';
|
|
25
|
+
readonly fix: 'Use personalData: "tenant-members" or remove it.';
|
|
26
|
+
};
|
|
27
|
+
readonly accessPersonalDataUnknown: {
|
|
28
|
+
readonly id: "handler/access-personal-data-unknown";
|
|
29
|
+
readonly summary: 'access.personalData is "public-intake" when set.';
|
|
30
|
+
readonly fix: 'Use personalData: "public-intake" or remove it.';
|
|
31
|
+
};
|
|
32
|
+
readonly publicIntakeWithoutAnonymous: {
|
|
33
|
+
readonly id: "handler/public-intake-without-anonymous";
|
|
34
|
+
readonly summary: 'A handler with access.personalData "public-intake" allows the anonymous role.';
|
|
35
|
+
readonly fix: "Add the anonymous role to access.roles or remove personalData.";
|
|
36
|
+
};
|
|
37
|
+
readonly anySignedInInvalid: {
|
|
38
|
+
readonly id: "handler/any-signed-in-invalid";
|
|
39
|
+
readonly summary: "access.anySignedIn is true when set and appears only next to the anonymous role, on endpoints that are public anyway.";
|
|
40
|
+
readonly fix: 'Add "anonymous" to access.roles, or use { openToAll: { reason } } for every signed-in user without anonymous callers.';
|
|
41
|
+
};
|
|
42
|
+
readonly publicIntakeRateLimitDisabled: {
|
|
43
|
+
readonly id: "handler/public-intake-rate-limit-disabled";
|
|
44
|
+
readonly summary: 'A handler with access.personalData "public-intake" keeps its rateLimit enabled, because it is the only protection for anonymous personal-data writes.';
|
|
45
|
+
readonly fix: 'Declare rateLimit: { per: "ip" or "ip+handler", ... } instead of disabling it.';
|
|
46
|
+
};
|
|
47
|
+
readonly inputSchemaNotIntrospectable: {
|
|
48
|
+
readonly id: "handler/input-schema-not-introspectable";
|
|
49
|
+
readonly summary: "A write handler's input schema is a Zod shape whose keys boot can collect.";
|
|
50
|
+
readonly fix: "Use an object schema the boot validator can walk, as named in the error message.";
|
|
51
|
+
};
|
|
52
|
+
readonly openToAllPersonalDataUnbound: {
|
|
53
|
+
readonly id: "handler/open-to-all-personal-data-unbound";
|
|
54
|
+
readonly summary: "An openToAll write handler accepts personal-data fields only when they are bound to the caller or explicitly declared tenant-members.";
|
|
55
|
+
readonly fix: 'Bind rows to the caller, restrict access to roles, or declare openToAll: { reason, personalData: "tenant-members" }.';
|
|
56
|
+
};
|
|
57
|
+
readonly anonymousPersonalDataUndeclared: {
|
|
58
|
+
readonly id: "handler/anonymous-personal-data-undeclared";
|
|
59
|
+
readonly summary: 'A write handler that allows anonymous callers and accepts personal-data fields declares access.personalData "public-intake".';
|
|
60
|
+
readonly fix: 'Declare access: { roles: [..., "anonymous"], personalData: "public-intake" }.';
|
|
61
|
+
};
|
|
62
|
+
readonly perCommandWithPhase: {
|
|
63
|
+
readonly id: "handler/per-command-with-phase";
|
|
64
|
+
readonly summary: 'A write handler with transaction "perCommand" declares neither beforeTransaction nor reserveBeforeTransaction.';
|
|
65
|
+
readonly fix: "Move the phase into the commands the handler issues via ctx.dispatch.write.";
|
|
66
|
+
};
|
|
67
|
+
readonly nestedSkipWithoutPhase: {
|
|
68
|
+
readonly id: "handler/nested-skip-without-before-transaction";
|
|
69
|
+
readonly summary: "A write handler with beforeTransactionWhenNested also declares beforeTransaction.";
|
|
70
|
+
readonly fix: "Declare beforeTransaction or remove beforeTransactionWhenNested.";
|
|
71
|
+
};
|
|
72
|
+
readonly nestedSkipWithReservation: {
|
|
73
|
+
readonly id: "handler/nested-skip-with-reserve-before-transaction";
|
|
74
|
+
readonly summary: "A write handler with beforeTransactionWhenNested does not declare reserveBeforeTransaction, because a nested run would run unreserved.";
|
|
75
|
+
readonly fix: "Remove reserveBeforeTransaction or beforeTransactionWhenNested.";
|
|
76
|
+
};
|
|
77
|
+
};
|