@cosmicdrift/kumiko-framework 0.406.0 → 0.409.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.
Files changed (209) hide show
  1. package/agents/api/framework-db.md +1 -0
  2. package/agents/api/framework-engine.md +15 -2
  3. package/agents/api/framework-ui-types.md +15 -0
  4. package/agents/api/renderer-web.md +156 -2
  5. package/agents/api/types.md +113 -71
  6. package/agents/api.md +4 -4
  7. package/agents/boot-rules.md +743 -0
  8. package/agents/examples/contact.md +167 -0
  9. package/agents/examples/delivery-notifications.md +34 -1
  10. package/agents/examples/record-detail-layout.md +13 -2
  11. package/agents/examples/search.md +65 -3
  12. package/agents/examples/secrets-demo.md +96 -2
  13. package/agents/examples/tenant-inactivity.md +138 -0
  14. package/agents/examples.md +2 -0
  15. package/agents/features-index.md +4 -0
  16. package/agents/features.md +24 -1
  17. package/agents/widgets.md +12 -1
  18. package/dist/api/export/export-rows.js +1 -0
  19. package/dist/compliance/index.d.ts +1 -1
  20. package/dist/db/event-store-executor-read-where.js +15 -5
  21. package/dist/db/index.d.ts +1 -1
  22. package/dist/db/index.js +1 -1
  23. package/dist/db/migrate-generator.js +3 -1
  24. package/dist/db/queries/event-consumer.js +11 -7
  25. package/dist/db/queries/event-store.d.ts +2 -1
  26. package/dist/db/queries/event-store.js +25 -6
  27. package/dist/db/queries/rls-boot-catalog.js +3 -1
  28. package/dist/db/queries/session-advisory-lock.d.ts +7 -0
  29. package/dist/db/queries/session-advisory-lock.js +23 -0
  30. package/dist/db/query.js +7 -10
  31. package/dist/db/row-level-security-connection.js +4 -2
  32. package/dist/engine/active-membership.js +1 -0
  33. package/dist/engine/boot-validator/access-declarations.js +57 -33
  34. package/dist/engine/boot-validator/action-wiring.js +8 -6
  35. package/dist/engine/boot-validator/agent-effect-rules.d.ts +12 -0
  36. package/dist/engine/boot-validator/agent-effect-rules.js +12 -0
  37. package/dist/engine/boot-validator/agent-effect.d.ts +2 -0
  38. package/dist/engine/boot-validator/agent-effect.js +20 -0
  39. package/dist/engine/boot-validator/boot-context.js +5 -1
  40. package/dist/engine/boot-validator/boot-environment-rules.d.ts +12 -0
  41. package/dist/engine/boot-validator/boot-environment-rules.js +12 -0
  42. package/dist/engine/boot-validator/boot-phases-app.js +5 -1
  43. package/dist/engine/boot-validator/boot-phases.js +3 -1
  44. package/dist/engine/boot-validator/boot-rules.d.ts +2619 -0
  45. package/dist/engine/boot-validator/boot-rules.js +58 -0
  46. package/dist/engine/boot-validator/bundled-lists-table.js +23 -9
  47. package/dist/engine/boot-validator/config-deps.js +71 -23
  48. package/dist/engine/boot-validator/config-edit-action-rules.d.ts +17 -0
  49. package/dist/engine/boot-validator/config-edit-action-rules.js +17 -0
  50. package/dist/engine/boot-validator/config-key-rules.d.ts +117 -0
  51. package/dist/engine/boot-validator/config-key-rules.js +117 -0
  52. package/dist/engine/boot-validator/custom-screen-write-qns.js +6 -2
  53. package/dist/engine/boot-validator/derived-sql-fields-rules.d.ts +77 -0
  54. package/dist/engine/boot-validator/derived-sql-fields-rules.js +77 -0
  55. package/dist/engine/boot-validator/derived-sql-fields.js +53 -17
  56. package/dist/engine/boot-validator/detail-screens.js +10 -4
  57. package/dist/engine/boot-validator/entity-declaration-rules.d.ts +92 -0
  58. package/dist/engine/boot-validator/entity-declaration-rules.js +92 -0
  59. package/dist/engine/boot-validator/entity-handler-access-rules.d.ts +102 -0
  60. package/dist/engine/boot-validator/entity-handler-access-rules.js +102 -0
  61. package/dist/engine/boot-validator/entity-handler.d.ts +0 -7
  62. package/dist/engine/boot-validator/entity-handler.js +259 -355
  63. package/dist/engine/boot-validator/entity-image-variants.d.ts +2 -0
  64. package/dist/engine/boot-validator/entity-image-variants.js +91 -0
  65. package/dist/engine/boot-validator/entity-list-aggregate-options.js +8 -2
  66. package/dist/engine/boot-validator/entity-reference-embedded-rules.d.ts +117 -0
  67. package/dist/engine/boot-validator/entity-reference-embedded-rules.js +117 -0
  68. package/dist/engine/boot-validator/entity-select-image-rules.d.ts +122 -0
  69. package/dist/engine/boot-validator/entity-select-image-rules.js +122 -0
  70. package/dist/engine/boot-validator/entity-select.d.ts +8 -0
  71. package/dist/engine/boot-validator/entity-select.js +197 -0
  72. package/dist/engine/boot-validator/entity-structure-rules.d.ts +107 -0
  73. package/dist/engine/boot-validator/entity-structure-rules.js +107 -0
  74. package/dist/engine/boot-validator/field-conditions-rules.d.ts +92 -0
  75. package/dist/engine/boot-validator/field-conditions-rules.js +92 -0
  76. package/dist/engine/boot-validator/field-conditions.js +67 -22
  77. package/dist/engine/boot-validator/form-derivations-rules.d.ts +77 -0
  78. package/dist/engine/boot-validator/form-derivations-rules.js +77 -0
  79. package/dist/engine/boot-validator/form-derivations.js +52 -18
  80. package/dist/engine/boot-validator/global-tenancy.js +13 -7
  81. package/dist/engine/boot-validator/handler-declaration-rules.d.ts +72 -0
  82. package/dist/engine/boot-validator/handler-declaration-rules.js +72 -0
  83. package/dist/engine/boot-validator/handler-field-references-rules.d.ts +22 -0
  84. package/dist/engine/boot-validator/handler-field-references-rules.js +22 -0
  85. package/dist/engine/boot-validator/handler-field-references.js +14 -6
  86. package/dist/engine/boot-validator/list-bulk-actions-rules.d.ts +42 -0
  87. package/dist/engine/boot-validator/list-bulk-actions-rules.js +42 -0
  88. package/dist/engine/boot-validator/list-bulk-actions.js +29 -11
  89. package/dist/engine/boot-validator/list-column-layout.js +22 -10
  90. package/dist/engine/boot-validator/list-query-rules.d.ts +107 -0
  91. package/dist/engine/boot-validator/list-query-rules.js +107 -0
  92. package/dist/engine/boot-validator/list-table-aggregate-options.js +43 -15
  93. package/dist/engine/boot-validator/list-table-aggregate-query.js +7 -3
  94. package/dist/engine/boot-validator/list-table-aggregate-rules.d.ts +82 -0
  95. package/dist/engine/boot-validator/list-table-aggregate-rules.js +82 -0
  96. package/dist/engine/boot-validator/list-table-export-options.js +19 -7
  97. package/dist/engine/boot-validator/list-table-options.js +33 -13
  98. package/dist/engine/boot-validator/list-table-reject-unknown-keys.js +6 -2
  99. package/dist/engine/boot-validator/list-table-rules.d.ts +132 -0
  100. package/dist/engine/boot-validator/list-table-rules.js +132 -0
  101. package/dist/engine/boot-validator/nav-rules.d.ts +42 -0
  102. package/dist/engine/boot-validator/nav-rules.js +42 -0
  103. package/dist/engine/boot-validator/nav.js +29 -15
  104. package/dist/engine/boot-validator/ownership-rules.d.ts +27 -0
  105. package/dist/engine/boot-validator/ownership-rules.js +27 -0
  106. package/dist/engine/boot-validator/ownership.js +28 -12
  107. package/dist/engine/boot-validator/parent-ref.js +32 -20
  108. package/dist/engine/boot-validator/projection-list-screens.js +76 -35
  109. package/dist/engine/boot-validator/query-output-columns.js +9 -3
  110. package/dist/engine/boot-validator/query-refs.js +20 -10
  111. package/dist/engine/boot-validator/query-rules.d.ts +37 -0
  112. package/dist/engine/boot-validator/query-rules.js +37 -0
  113. package/dist/engine/boot-validator/read-gate.js +14 -10
  114. package/dist/engine/boot-validator/record-owned.js +5 -1
  115. package/dist/engine/boot-validator/related-list-table-rules.js +17 -7
  116. package/dist/engine/boot-validator/screens-actions-rules.d.ts +185 -0
  117. package/dist/engine/boot-validator/screens-actions-rules.js +185 -0
  118. package/dist/engine/boot-validator/screens-actions.js +169 -93
  119. package/dist/engine/boot-validator/screens-dashboard-chart-rules.d.ts +87 -0
  120. package/dist/engine/boot-validator/screens-dashboard-chart-rules.js +87 -0
  121. package/dist/engine/boot-validator/screens-dashboard-rules.d.ts +227 -0
  122. package/dist/engine/boot-validator/screens-dashboard-rules.js +227 -0
  123. package/dist/engine/boot-validator/screens-dashboard.js +222 -85
  124. package/dist/engine/boot-validator/screens-forms-layout-rules.d.ts +122 -0
  125. package/dist/engine/boot-validator/screens-forms-layout-rules.js +122 -0
  126. package/dist/engine/boot-validator/screens-forms-rules.d.ts +152 -0
  127. package/dist/engine/boot-validator/screens-forms-rules.js +152 -0
  128. package/dist/engine/boot-validator/screens-forms.js +240 -112
  129. package/dist/engine/boot-validator/screens-kind-config-edit.js +72 -16
  130. package/dist/engine/boot-validator/screens-kind-entity-edit.js +15 -7
  131. package/dist/engine/boot-validator/screens-kind-entity-list.js +57 -32
  132. package/dist/engine/boot-validator/screens-kind-projection-detail-rules.d.ts +92 -0
  133. package/dist/engine/boot-validator/screens-kind-projection-detail-rules.js +92 -0
  134. package/dist/engine/boot-validator/screens-kind-projection-detail.js +85 -47
  135. package/dist/engine/boot-validator/screens-kind-rules.d.ts +137 -0
  136. package/dist/engine/boot-validator/screens-kind-rules.js +137 -0
  137. package/dist/engine/boot-validator/screens-kind-secret-mint.js +18 -8
  138. package/dist/engine/boot-validator/screens-kind-shared.js +40 -22
  139. package/dist/engine/boot-validator/screens-lists-rules.d.ts +82 -0
  140. package/dist/engine/boot-validator/screens-lists-rules.js +82 -0
  141. package/dist/engine/boot-validator/screens-lists.js +90 -45
  142. package/dist/engine/boot-validator/screens-rules.d.ts +57 -0
  143. package/dist/engine/boot-validator/screens-rules.js +57 -0
  144. package/dist/engine/boot-validator/screens.js +17 -12
  145. package/dist/engine/boot-validator/transaction-phases.js +12 -4
  146. package/dist/engine/boot-validator/transfer-graph.js +17 -11
  147. package/dist/engine/boot-validator/url-prefill-fields.js +9 -5
  148. package/dist/engine/boot-validator/workspaces.js +11 -5
  149. package/dist/engine/boot-validator/zod-shape.js +6 -2
  150. package/dist/engine/entity-handlers.d.ts +1 -0
  151. package/dist/engine/entity-handlers.js +3 -0
  152. package/dist/engine/entity-list-runtime-options.js +23 -29
  153. package/dist/engine/extensions/tenant-data.d.ts +3 -0
  154. package/dist/engine/factories.d.ts +1 -1
  155. package/dist/engine/factories.js +4 -3
  156. package/dist/engine/index.d.ts +4 -2
  157. package/dist/engine/index.js +2 -0
  158. package/dist/engine/project-app-schema-for-roles.js +29 -14
  159. package/dist/engine/registry-facade.js +7 -8
  160. package/dist/engine/registry-validate.js +5 -1
  161. package/dist/engine/soft-delete-cleanup.d.ts +1 -0
  162. package/dist/engine/soft-delete-cleanup.js +5 -0
  163. package/dist/engine/steps/describe-workflow-step-error.js +1 -0
  164. package/dist/es-ops/operations-schema.d.ts +1 -1
  165. package/dist/event-store/ensure-dead-letter-table.d.ts +2 -0
  166. package/dist/event-store/ensure-dead-letter-table.js +10 -0
  167. package/dist/event-store/rebuild-dead-letter.js +2 -8
  168. package/dist/event-store/upcaster-dead-letter.js +2 -8
  169. package/dist/files/copy-pending-file-refs-to-tenant.d.ts +28 -0
  170. package/dist/files/copy-pending-file-refs-to-tenant.js +87 -0
  171. package/dist/files/file-routes.d.ts +1 -1
  172. package/dist/files/file-routes.js +21 -6
  173. package/dist/files/index.d.ts +2 -0
  174. package/dist/files/index.js +1 -0
  175. package/dist/i18n/required-surface-keys.js +1 -0
  176. package/dist/jobs/job-runner-helpers.js +1 -0
  177. package/dist/jobs/job-runner.js +7 -12
  178. package/dist/logging/utils.js +30 -60
  179. package/dist/observability/metrics-handle.js +10 -21
  180. package/dist/pipeline/cascade-handler.js +7 -6
  181. package/dist/pipeline/dispatch-query.js +18 -5
  182. package/dist/pipeline/dispatch-shared.d.ts +1 -0
  183. package/dist/pipeline/dispatch-shared.js +3 -1
  184. package/dist/pipeline/dispatch-write.js +10 -12
  185. package/dist/pipeline/dispatcher.js +12 -14
  186. package/dist/pipeline/event-dispatcher-admin.js +9 -8
  187. package/dist/pipeline/event-dispatcher-delivery.d.ts +19 -1
  188. package/dist/pipeline/event-dispatcher-delivery.js +121 -29
  189. package/dist/pipeline/event-dispatcher.d.ts +5 -1
  190. package/dist/pipeline/event-dispatcher.js +28 -21
  191. package/dist/pipeline/handler-context-phase-denials.js +2 -0
  192. package/dist/pipeline/multi-stream-apply-context.js +12 -20
  193. package/dist/pipeline/system-hooks.d.ts +4 -1
  194. package/dist/pipeline/system-hooks.js +79 -6
  195. package/dist/pipeline/system-identity-switch.js +10 -7
  196. package/dist/search/build-search-snippet.d.ts +9 -0
  197. package/dist/search/build-search-snippet.js +40 -0
  198. package/dist/search/index.d.ts +1 -0
  199. package/dist/search/index.js +1 -0
  200. package/dist/search/meilisearch-adapter.d.ts +32 -0
  201. package/dist/search/meilisearch-adapter.js +153 -56
  202. package/dist/search/meilisearch-chunking.d.ts +21 -0
  203. package/dist/search/meilisearch-chunking.js +96 -0
  204. package/dist/search/reindex-entity.d.ts +1 -0
  205. package/dist/search/reindex-entity.js +97 -52
  206. package/dist/ui-types/index.d.ts +1 -1
  207. package/dist/upgrade-cli.js +3 -14
  208. package/package.json +3 -3
  209. package/src/changes.json +73 -0
@@ -1,11 +1,40 @@
1
+ import { AGENT_EFFECT_RULES } from "./agent-effect-rules.js";
1
2
  import { API_EXT_RULES } from "./api-ext-rules.js";
2
3
  import { BOOT_CHECK_RULES } from "./boot-check-rules.js";
4
+ import { BOOT_ENVIRONMENT_RULES } from "./boot-environment-rules.js";
3
5
  import { CARD_META_OVERFLOW_RULES } from "./card-meta-overflow-rules.js";
6
+ import { CONFIG_EDIT_ACTION_RULES } from "./config-edit-action-rules.js";
7
+ import { CONFIG_KEY_RULES } from "./config-key-rules.js";
8
+ import { DERIVED_SQL_FIELD_RULES } from "./derived-sql-fields-rules.js";
9
+ import { ENTITY_DECLARATION_RULES } from "./entity-declaration-rules.js";
10
+ import { HANDLER_ACCESS_RULES } from "./entity-handler-access-rules.js";
4
11
  import { ENTITY_LIST_RULES } from "./entity-list-screens-rules.js";
12
+ import { ENTITY_REFERENCE_EMBEDDED_RULES } from "./entity-reference-embedded-rules.js";
13
+ import { ENTITY_SELECT_IMAGE_RULES } from "./entity-select-image-rules.js";
14
+ import { ENTITY_STRUCTURE_RULES } from "./entity-structure-rules.js";
15
+ import { FIELD_CONDITION_RULES } from "./field-conditions-rules.js";
16
+ import { FORM_DERIVATION_RULES } from "./form-derivations-rules.js";
17
+ import { HANDLER_DECLARATION_RULES } from "./handler-declaration-rules.js";
18
+ import { HANDLER_FIELD_REFERENCE_RULES } from "./handler-field-references-rules.js";
5
19
  import { I18N_RULES } from "./i18n-keys-rules.js";
20
+ import { LIST_BULK_ACTION_RULES } from "./list-bulk-actions-rules.js";
21
+ import { LIST_QUERY_RULES } from "./list-query-rules.js";
22
+ import { LIST_TABLE_AGGREGATE_RULES } from "./list-table-aggregate-rules.js";
23
+ import { LIST_TABLE_RULES } from "./list-table-rules.js";
6
24
  import { NAMED_FILTER_RULES } from "./named-filter-rules.js";
25
+ import { NAV_RULES } from "./nav-rules.js";
26
+ import { OWNERSHIP_RULES } from "./ownership-rules.js";
7
27
  import { PII_RULES } from "./pii-retention-rules.js";
28
+ import { QUERY_RULES } from "./query-rules.js";
8
29
  import { SCREEN_ACTION_RULES } from "./screens-actions-rules.js";
30
+ import { DASHBOARD_CHART_RULES } from "./screens-dashboard-chart-rules.js";
31
+ import { DASHBOARD_RULES } from "./screens-dashboard-rules.js";
32
+ import { FORM_LAYOUT_RULES } from "./screens-forms-layout-rules.js";
33
+ import { FORM_FIELD_RULES } from "./screens-forms-rules.js";
34
+ import { PROJECTION_DETAIL_RULES } from "./screens-kind-projection-detail-rules.js";
35
+ import { SCREEN_KIND_RULES } from "./screens-kind-rules.js";
36
+ import { LIST_SCREEN_RULES } from "./screens-lists-rules.js";
37
+ import { SCREEN_RULES } from "./screens-rules.js";
9
38
  export const FRAMEWORK_BOOT_RULE_TABLES = [
10
39
  PII_RULES,
11
40
  ENTITY_LIST_RULES,
@@ -13,7 +42,36 @@ export const FRAMEWORK_BOOT_RULE_TABLES = [
13
42
  I18N_RULES,
14
43
  CARD_META_OVERFLOW_RULES,
15
44
  SCREEN_ACTION_RULES,
45
+ CONFIG_EDIT_ACTION_RULES,
16
46
  API_EXT_RULES,
17
47
  BOOT_CHECK_RULES,
48
+ DASHBOARD_RULES,
49
+ DASHBOARD_CHART_RULES,
50
+ FORM_FIELD_RULES,
51
+ FORM_LAYOUT_RULES,
52
+ LIST_SCREEN_RULES,
53
+ SCREEN_KIND_RULES,
54
+ PROJECTION_DETAIL_RULES,
55
+ SCREEN_RULES,
56
+ DERIVED_SQL_FIELD_RULES,
57
+ HANDLER_ACCESS_RULES,
58
+ ENTITY_REFERENCE_EMBEDDED_RULES,
59
+ ENTITY_SELECT_IMAGE_RULES,
60
+ ENTITY_STRUCTURE_RULES,
61
+ FIELD_CONDITION_RULES,
62
+ FORM_DERIVATION_RULES,
63
+ HANDLER_FIELD_REFERENCE_RULES,
64
+ LIST_TABLE_RULES,
65
+ LIST_TABLE_AGGREGATE_RULES,
66
+ LIST_QUERY_RULES,
67
+ LIST_BULK_ACTION_RULES,
68
+ QUERY_RULES,
69
+ BOOT_ENVIRONMENT_RULES,
70
+ CONFIG_KEY_RULES,
71
+ ENTITY_DECLARATION_RULES,
72
+ HANDLER_DECLARATION_RULES,
73
+ NAV_RULES,
74
+ OWNERSHIP_RULES,
75
+ AGENT_EFFECT_RULES,
18
76
  ];
19
77
  export const FRAMEWORK_BOOT_RULES = FRAMEWORK_BOOT_RULE_TABLES.flatMap((table) => Object.values(table));
@@ -1,36 +1,50 @@
1
1
  import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
2
2
  import { LIST_TABLE_OPTION_KEYS } from "../types/screen.js";
3
+ import { bootRuleError } from "./boot-rule.js";
3
4
  import { validateListTableOptions } from "./list-table-options.js";
5
+ import { LIST_TABLE_RULES } from "./list-table-rules.js";
4
6
  export const BUNDLED_LISTS_OPTION_KEYS = ["table", "pinFirstColumn"];
5
7
  // grouping and totals name fields of one list, so they cannot be shared across lists
6
8
  const SCREEN_ONLY_TABLE_KEYS = ["grouping", "totals"];
7
9
  export function validateBundledListsOptions(options) {
8
10
  if (!isPlainObject(options)) {
9
- throw new Error("bundledLists must be an object like { table: { columnPicker: true } }.");
11
+ throw bootRuleError(LIST_TABLE_RULES.bundledListsNotObject, {
12
+ message: "bundledLists must be an object like { table: { columnPicker: true } }.",
13
+ });
10
14
  }
11
15
  const unknownKeys = Object.keys(options).filter((key) => !BUNDLED_LISTS_OPTION_KEYS.some((allowed) => allowed === key));
12
16
  if (unknownKeys.length > 0) {
13
- throw new Error(`bundledLists has unknown key(s) ${unknownKeys.map((k) => `"${k}"`).join(", ")}. ` +
14
- `Allowed keys: ${BUNDLED_LISTS_OPTION_KEYS.join(", ")}.`);
17
+ throw bootRuleError(LIST_TABLE_RULES.bundledListsUnknownKey, {
18
+ message: `bundledLists has unknown key(s) ${unknownKeys.map((k) => `"${k}"`).join(", ")}. ` +
19
+ `Allowed keys: ${BUNDLED_LISTS_OPTION_KEYS.join(", ")}.`,
20
+ });
15
21
  }
16
22
  const table = options["table"];
17
23
  if (!isPlainObject(table)) {
18
24
  const allowed = LIST_TABLE_OPTION_KEYS.filter((key) => !SCREEN_ONLY_TABLE_KEYS.some((screenOnly) => screenOnly === key));
19
- throw new Error(`bundledLists.table must be an object like { columnPicker: true }. ` +
20
- `Allowed keys: ${allowed.join(", ")}.`);
25
+ throw bootRuleError(LIST_TABLE_RULES.bundledListsTableNotObject, {
26
+ message: `bundledLists.table must be an object like { columnPicker: true }. ` +
27
+ `Allowed keys: ${allowed.join(", ")}.`,
28
+ });
21
29
  }
22
30
  for (const key of SCREEN_ONLY_TABLE_KEYS) {
23
31
  if (table[key] !== undefined) {
24
- throw new Error(`bundledLists.table.${key} is not allowed: ${key} depends on the fields of one list. ` +
25
- `Set it in the table block of that screen.`);
32
+ throw bootRuleError(LIST_TABLE_RULES.bundledListsScreenOnlyKey, {
33
+ message: `bundledLists.table.${key} is not allowed: ${key} depends on the fields of one list. ` +
34
+ `Set it in the table block of that screen.`,
35
+ });
26
36
  }
27
37
  }
28
38
  validateListTableOptions("bundledLists", table, [], true);
29
39
  const pinFirstColumn = options["pinFirstColumn"];
30
40
  if (pinFirstColumn !== undefined && typeof pinFirstColumn !== "boolean") {
31
- throw new Error("bundledLists.pinFirstColumn must be a boolean.");
41
+ throw bootRuleError(LIST_TABLE_RULES.bundledListsPinFirstColumnNotBoolean, {
42
+ message: "bundledLists.pinFirstColumn must be a boolean.",
43
+ });
32
44
  }
33
45
  if (pinFirstColumn === true && table["pinning"] !== true) {
34
- throw new Error("bundledLists.pinFirstColumn needs bundledLists.table.pinning: true.");
46
+ throw bootRuleError(LIST_TABLE_RULES.bundledListsPinFirstColumnWithoutPinning, {
47
+ message: "bundledLists.pinFirstColumn needs bundledLists.table.pinning: true.",
48
+ });
35
49
  }
36
50
  }
@@ -1,6 +1,8 @@
1
1
  import { optionsQueryFieldRefs } from "@cosmicdrift/kumiko-types/fields";
2
2
  import { createFallbackLogger } from "../../logging/utils.js";
3
3
  import { isEncryptedAtRest } from "../config-helpers.js";
4
+ import { bootRuleError } from "./boot-rule.js";
5
+ import { CONFIG_KEY_RULES } from "./config-key-rules.js";
4
6
  const log = createFallbackLogger("kumiko:boot");
5
7
  // --- Toggleable-dependency warnings ---
6
8
  //
@@ -35,19 +37,27 @@ export function validateConfigKeyBounds(feature) {
35
37
  // already rejects this, but catch it at boot as defence in depth (e.g.
36
38
  // a hand-rolled key definition that bypasses createTenantConfig).
37
39
  if (keyDef.type !== "number") {
38
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has bounds but type is "${keyDef.type}" — bounds are only valid for type="number"`);
40
+ throw bootRuleError(CONFIG_KEY_RULES.boundsNonNumber, {
41
+ message: `[Feature ${feature.name}] Config key "${keyName}" has bounds but type is "${keyDef.type}" — bounds are only valid for type="number"`,
42
+ });
39
43
  }
40
44
  const { min, max } = bounds;
41
45
  if (min !== undefined && max !== undefined && min > max) {
42
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has bounds.min (${min}) > bounds.max (${max}). Set bounds.min to a value at or below bounds.max.`);
46
+ throw bootRuleError(CONFIG_KEY_RULES.boundsMinAboveMax, {
47
+ message: `[Feature ${feature.name}] Config key "${keyName}" has bounds.min (${min}) > bounds.max (${max}). Set bounds.min to a value at or below bounds.max.`,
48
+ });
43
49
  }
44
50
  if (keyDef.default !== undefined) {
45
51
  const defaultNum = keyDef.default; // @cast-boundary engine-payload
46
52
  if (min !== undefined && defaultNum < min) {
47
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" default (${defaultNum}) is below bounds.min (${min}). Raise the default or lower bounds.min.`);
53
+ throw bootRuleError(CONFIG_KEY_RULES.defaultBelowMin, {
54
+ message: `[Feature ${feature.name}] Config key "${keyName}" default (${defaultNum}) is below bounds.min (${min}). Raise the default or lower bounds.min.`,
55
+ });
48
56
  }
49
57
  if (max !== undefined && defaultNum > max) {
50
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" default (${defaultNum}) is above bounds.max (${max}). Lower the default or raise bounds.max.`);
58
+ throw bootRuleError(CONFIG_KEY_RULES.defaultAboveMax, {
59
+ message: `[Feature ${feature.name}] Config key "${keyName}" default (${defaultNum}) is above bounds.max (${max}). Lower the default or raise bounds.max.`,
60
+ });
51
61
  }
52
62
  }
53
63
  }
@@ -62,7 +72,9 @@ export function validateConfigKeyComputed(feature) {
62
72
  // cascade doesn't know which one to prefer on write. Rejecting at boot
63
73
  // is cheaper than surprising behaviour at runtime.
64
74
  if (isEncryptedAtRest(keyDef)) {
65
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has both encrypted/backing="secrets" and a computed resolver — these are mutually exclusive paradigms. Use either encrypted/backing="secrets" or a computed resolver on one key.`);
75
+ throw bootRuleError(CONFIG_KEY_RULES.computedAndEncrypted, {
76
+ message: `[Feature ${feature.name}] Config key "${keyName}" has both encrypted/backing="secrets" and a computed resolver — these are mutually exclusive paradigms. Use either encrypted/backing="secrets" or a computed resolver on one key.`,
77
+ });
66
78
  }
67
79
  }
68
80
  }
@@ -75,12 +87,16 @@ export function validateConfigKeyRequired(feature) {
75
87
  // or computed resolver means the key can never be unset, so readiness could
76
88
  // never report the omission and the flag would be misleading.
77
89
  if (keyDef.computed !== undefined) {
78
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has required=true AND a computed resolver — a computed key can never be missing; drop one of the two`);
90
+ throw bootRuleError(CONFIG_KEY_RULES.requiredWithComputed, {
91
+ message: `[Feature ${feature.name}] Config key "${keyName}" has required=true AND a computed resolver — a computed key can never be missing; drop one of the two`,
92
+ });
79
93
  }
80
94
  const d = keyDef.default;
81
95
  const nonEmptyDefault = d !== undefined && !(typeof d === "string" && d.trim().length === 0);
82
96
  if (nonEmptyDefault) {
83
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has required=true AND a non-empty default (${JSON.stringify(d)}) — the key can never be unset, readiness would never flag it; use default "" or drop required`);
97
+ throw bootRuleError(CONFIG_KEY_RULES.requiredWithDefault, {
98
+ message: `[Feature ${feature.name}] Config key "${keyName}" has required=true AND a non-empty default (${JSON.stringify(d)}) — the key can never be unset, readiness would never flag it; use default "" or drop required`,
99
+ });
84
100
  }
85
101
  }
86
102
  }
@@ -93,13 +109,17 @@ export function validateConfigKeyAllowPerRequest(feature) {
93
109
  // anyway, but declaring allowPerRequest on a text key is a
94
110
  // misconfiguration that should fail loudly at boot.
95
111
  if (keyDef.type === "text") {
96
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has allowPerRequest=true but type="text" — text keys are permanently ineligible for per-request overrides (XSS/injection risk). Remove allowPerRequest or change the key type.`);
112
+ throw bootRuleError(CONFIG_KEY_RULES.perRequestText, {
113
+ message: `[Feature ${feature.name}] Config key "${keyName}" has allowPerRequest=true but type="text" — text keys are permanently ineligible for per-request overrides (XSS/injection risk). Remove allowPerRequest or change the key type.`,
114
+ });
97
115
  }
98
116
  // encrypted + per-request would expose a cipher-text interpretation
99
117
  // to query-strings. The secret-value shouldn't be transported this
100
118
  // way — reject as a paradigm-mismatch.
101
119
  if (isEncryptedAtRest(keyDef)) {
102
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has allowPerRequest=true but encrypted/backing="secrets" — secret values may not be set via query-params`);
120
+ throw bootRuleError(CONFIG_KEY_RULES.perRequestEncrypted, {
121
+ message: `[Feature ${feature.name}] Config key "${keyName}" has allowPerRequest=true but encrypted/backing="secrets" — secret values may not be set via query-params`,
122
+ });
103
123
  }
104
124
  }
105
125
  }
@@ -108,25 +128,37 @@ export function validateConfigKeyOptionsQuery(feature) {
108
128
  for (const [keyName, keyDef] of Object.entries(feature.configKeys)) {
109
129
  const prefix = `[Feature ${feature.name}] Config key "${keyName}"`;
110
130
  if ("conditionalOptions" in keyDef) {
111
- throw new Error(`${prefix} declares conditionalOptions — conditionalOptions is only supported on entity select fields (enforced by the entity write path). Remove conditionalOptions from the config key.`);
131
+ throw bootRuleError(CONFIG_KEY_RULES.conditionalOptions, {
132
+ message: `${prefix} declares conditionalOptions — conditionalOptions is only supported on entity select fields (enforced by the entity write path). Remove conditionalOptions from the config key.`,
133
+ });
112
134
  }
113
135
  if (keyDef.optionsQuery === undefined) {
114
136
  if (keyDef.optionsQueryPayload !== undefined) {
115
- throw new Error(`${prefix} has optionsQueryPayload without optionsQuery. Set optionsQuery or remove optionsQueryPayload.`);
137
+ throw bootRuleError(CONFIG_KEY_RULES.optionsQueryPayloadWithoutQuery, {
138
+ message: `${prefix} has optionsQueryPayload without optionsQuery. Set optionsQuery or remove optionsQueryPayload.`,
139
+ });
116
140
  }
117
141
  continue;
118
142
  }
119
143
  if (keyDef.optionsQuery.length === 0) {
120
- throw new Error(`${prefix} has an empty optionsQuery. Set it to a query name or remove it.`);
144
+ throw bootRuleError(CONFIG_KEY_RULES.optionsQueryEmpty, {
145
+ message: `${prefix} has an empty optionsQuery. Set it to a query name or remove it.`,
146
+ });
121
147
  }
122
148
  if (keyDef.type !== "select") {
123
- throw new Error(`${prefix} has optionsQuery but type="${keyDef.type}" — optionsQuery is only valid on select keys`);
149
+ throw bootRuleError(CONFIG_KEY_RULES.optionsQueryNotSelect, {
150
+ message: `${prefix} has optionsQuery but type="${keyDef.type}" — optionsQuery is only valid on select keys`,
151
+ });
124
152
  }
125
153
  if (keyDef.options !== undefined && keyDef.options.length > 0) {
126
- throw new Error(`${prefix} declares both options and optionsQuery — pick one`);
154
+ throw bootRuleError(CONFIG_KEY_RULES.optionsAndOptionsQuery, {
155
+ message: `${prefix} declares both options and optionsQuery — pick one`,
156
+ });
127
157
  }
128
158
  if (keyDef.allowPerRequest) {
129
- throw new Error(`${prefix} has optionsQuery AND allowPerRequest=true — a per-request value would bypass the option set unchecked`);
159
+ throw bootRuleError(CONFIG_KEY_RULES.optionsQueryPerRequest, {
160
+ message: `${prefix} has optionsQuery AND allowPerRequest=true — a per-request value would bypass the option set unchecked`,
161
+ });
130
162
  }
131
163
  validateOptionsQueryKeyRefs(feature, keyName, keyDef);
132
164
  }
@@ -135,10 +167,14 @@ function validateOptionsQueryKeyRefs(feature, keyName, keyDef) {
135
167
  const prefix = `[Feature ${feature.name}] Config key "${keyName}"`;
136
168
  for (const ref of optionsQueryFieldRefs(keyDef.optionsQueryPayload)) {
137
169
  if (ref === keyName) {
138
- throw new Error(`${prefix} optionsQueryPayload references itself ({ field: "${ref}" }). Reference a different config key.`);
170
+ throw bootRuleError(CONFIG_KEY_RULES.optionsQueryPayloadSelfReference, {
171
+ message: `${prefix} optionsQueryPayload references itself ({ field: "${ref}" }). Reference a different config key.`,
172
+ });
139
173
  }
140
174
  if (feature.configKeys[ref] === undefined) {
141
- throw new Error(`${prefix} optionsQueryPayload references unknown config key "${ref}" of feature "${feature.name}"`);
175
+ throw bootRuleError(CONFIG_KEY_RULES.optionsQueryPayloadUnknownKey, {
176
+ message: `${prefix} optionsQueryPayload references unknown config key "${ref}" of feature "${feature.name}"`,
177
+ });
142
178
  }
143
179
  }
144
180
  }
@@ -151,7 +187,9 @@ export function validateConfigKeyBacking(feature) {
151
187
  // so a tenant- or user-scoped secret could never inherit a system default.
152
188
  // Permanent rule: secrets-backed keys must be system-scoped.
153
189
  if (keyDef.scope !== "system") {
154
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has backing="secrets" but scope="${keyDef.scope}" — secrets storage is flat per (tenant,key) and does not cascade; backing="secrets" requires scope="system"`);
190
+ throw bootRuleError(CONFIG_KEY_RULES.secretsScopeNotSystem, {
191
+ message: `[Feature ${feature.name}] Config key "${keyName}" has backing="secrets" but scope="${keyDef.scope}" — secrets storage is flat per (tenant,key) and does not cascade; backing="secrets" requires scope="system"`,
192
+ });
155
193
  }
156
194
  // system-scoped backing="secrets" is wired end-to-end: reads dispatch
157
195
  // through the resolver's secretsReader, writes through config:write:set/
@@ -167,12 +205,16 @@ export function validateConfigKeyPiiEncrypted(feature) {
167
205
  if (!keyDef.piiEncrypted)
168
206
  continue;
169
207
  if (keyDef.type !== "text") {
170
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has piiEncrypted=true but type="${keyDef.type}" — piiEncrypted only applies to text keys. Use type="text" or remove piiEncrypted.`);
208
+ throw bootRuleError(CONFIG_KEY_RULES.piiEncryptedNotText, {
209
+ message: `[Feature ${feature.name}] Config key "${keyName}" has piiEncrypted=true but type="${keyDef.type}" — piiEncrypted only applies to text keys. Use type="text" or remove piiEncrypted.`,
210
+ });
171
211
  }
172
212
  // system scope has no subject (no tenant, no user) for the subject-KMS
173
213
  // to encrypt under.
174
214
  if (keyDef.scope === "system") {
175
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has piiEncrypted=true but scope="system" — system-scope has no subject (tenant/user) for the subject-KMS to encrypt under. Use scope="tenant" or "user", or remove piiEncrypted.`);
215
+ throw bootRuleError(CONFIG_KEY_RULES.piiEncryptedSystemScope, {
216
+ message: `[Feature ${feature.name}] Config key "${keyName}" has piiEncrypted=true but scope="system" — system-scope has no subject (tenant/user) for the subject-KMS to encrypt under. Use scope="tenant" or "user", or remove piiEncrypted.`,
217
+ });
176
218
  }
177
219
  // Mutually exclusive with the shared-cipher path: a config value is
178
220
  // either subject-keyed (piiEncrypted) or master-key-keyed (encrypted/
@@ -182,7 +224,9 @@ export function validateConfigKeyPiiEncrypted(feature) {
182
224
  // layers. Config values have no such pipeline; picking one keeps the
183
225
  // resolver simple.
184
226
  if (isEncryptedAtRest(keyDef)) {
185
- throw new Error(`[Feature ${feature.name}] Config key "${keyName}" has both piiEncrypted=true and encrypted/backing="secrets" — pick one: piiEncrypted (subject-KMS, user-visible) or encrypted (shared cipher, server-only values)`);
227
+ throw bootRuleError(CONFIG_KEY_RULES.piiEncryptedAndEncrypted, {
228
+ message: `[Feature ${feature.name}] Config key "${keyName}" has both piiEncrypted=true and encrypted/backing="secrets" — pick one: piiEncrypted (subject-KMS, user-visible) or encrypted (shared cipher, server-only values)`,
229
+ });
186
230
  }
187
231
  }
188
232
  }
@@ -191,7 +235,9 @@ export function validateConfigReads(features, allConfigKeys) {
191
235
  for (const feature of features) {
192
236
  for (const key of feature.configReads) {
193
237
  if (!allConfigKeys.has(key)) {
194
- throw new Error(`Feature "${feature.name}" reads config "${key}" but no feature defines that key. Declare the key via r.config(...) in a feature, or fix the key name.`);
238
+ throw bootRuleError(CONFIG_KEY_RULES.unknownConfigRead, {
239
+ message: `Feature "${feature.name}" reads config "${key}" but no feature defines that key. Declare the key via r.config(...) in a feature, or fix the key name.`,
240
+ });
195
241
  }
196
242
  }
197
243
  }
@@ -202,7 +248,9 @@ export function validateCircularDeps(featureName, featureMap) {
202
248
  const stack = new Set();
203
249
  function visit(name, path) {
204
250
  if (stack.has(name)) {
205
- throw new Error(`Circular dependency: ${[...path, name].join(" → ")}. Break the cycle by removing one requires() link.`);
251
+ throw bootRuleError(CONFIG_KEY_RULES.circularDependency, {
252
+ message: `Circular dependency: ${[...path, name].join(" → ")}. Break the cycle by removing one requires() link.`,
253
+ });
206
254
  }
207
255
  // skip: node already visited in DFS traversal
208
256
  if (visited.has(name))
@@ -0,0 +1,17 @@
1
+ export declare const CONFIG_EDIT_ACTION_RULES: {
2
+ readonly duplicateId: {
3
+ readonly id: "config-edit-action/duplicate-id";
4
+ readonly summary: "A configEdit screen declares each action id once.";
5
+ readonly fix: "Rename or remove the repeated action id.";
6
+ };
7
+ readonly unknownHandler: {
8
+ readonly id: "config-edit-action/unknown-handler";
9
+ readonly summary: "A configEdit action points at a registered write handler.";
10
+ readonly fix: 'Use the qualified write handler name "<feature>:write:<handler>" of a registered handler.';
11
+ };
12
+ readonly unknownAfterField: {
13
+ readonly id: "config-edit-action/unknown-after-field";
14
+ readonly summary: "A configEdit action sits after a field that is part of the layout.";
15
+ readonly fix: "Set afterField to a field name that appears in one of the layout sections.";
16
+ };
17
+ };
@@ -0,0 +1,17 @@
1
+ export const CONFIG_EDIT_ACTION_RULES = {
2
+ duplicateId: {
3
+ id: "config-edit-action/duplicate-id",
4
+ summary: "A configEdit screen declares each action id once.",
5
+ fix: "Rename or remove the repeated action id.",
6
+ },
7
+ unknownHandler: {
8
+ id: "config-edit-action/unknown-handler",
9
+ summary: "A configEdit action points at a registered write handler.",
10
+ fix: 'Use the qualified write handler name "<feature>:write:<handler>" of a registered handler.',
11
+ },
12
+ unknownAfterField: {
13
+ id: "config-edit-action/unknown-after-field",
14
+ summary: "A configEdit action sits after a field that is part of the layout.",
15
+ fix: "Set afterField to a field name that appears in one of the layout sections.",
16
+ },
17
+ };
@@ -0,0 +1,117 @@
1
+ export declare const CONFIG_KEY_RULES: {
2
+ readonly boundsNonNumber: {
3
+ readonly id: "config-key/bounds-non-number";
4
+ readonly summary: "A config key declares bounds only when its type is number.";
5
+ readonly fix: 'Remove bounds or change the key type to "number".';
6
+ };
7
+ readonly boundsMinAboveMax: {
8
+ readonly id: "config-key/bounds-min-above-max";
9
+ readonly summary: "A config key's bounds.min is at or below its bounds.max.";
10
+ readonly fix: "Set bounds.min to a value at or below bounds.max.";
11
+ };
12
+ readonly defaultBelowMin: {
13
+ readonly id: "config-key/default-below-min";
14
+ readonly summary: "A config key's default is not below its bounds.min.";
15
+ readonly fix: "Raise the default or lower bounds.min.";
16
+ };
17
+ readonly defaultAboveMax: {
18
+ readonly id: "config-key/default-above-max";
19
+ readonly summary: "A config key's default is not above its bounds.max.";
20
+ readonly fix: "Lower the default or raise bounds.max.";
21
+ };
22
+ readonly computedAndEncrypted: {
23
+ readonly id: "config-key/computed-and-encrypted";
24
+ readonly summary: 'A config key is either encrypted (encrypted or backing="secrets") or computed, never both.';
25
+ readonly fix: 'Use either encrypted/backing="secrets" or a computed resolver on the key.';
26
+ };
27
+ readonly requiredWithComputed: {
28
+ readonly id: "config-key/required-with-computed";
29
+ readonly summary: "A computed config key is not marked required, because it can never be missing.";
30
+ readonly fix: "Drop required or the computed resolver.";
31
+ };
32
+ readonly requiredWithDefault: {
33
+ readonly id: "config-key/required-with-default";
34
+ readonly summary: "A required config key has no non-empty default, otherwise it can never be unset and readiness never flags it.";
35
+ readonly fix: 'Use default "" or drop required.';
36
+ };
37
+ readonly perRequestText: {
38
+ readonly id: "config-key/per-request-text";
39
+ readonly summary: 'A config key of type "text" does not set allowPerRequest (XSS/injection risk).';
40
+ readonly fix: "Remove allowPerRequest or change the key type.";
41
+ };
42
+ readonly perRequestEncrypted: {
43
+ readonly id: "config-key/per-request-encrypted";
44
+ readonly summary: 'A config key with encrypted/backing="secrets" does not set allowPerRequest.';
45
+ readonly fix: "Remove allowPerRequest or the secrets storage from the key.";
46
+ };
47
+ readonly conditionalOptions: {
48
+ readonly id: "config-key/conditional-options";
49
+ readonly summary: "A config key does not declare conditionalOptions, which only entity select fields support.";
50
+ readonly fix: "Remove conditionalOptions from the config key.";
51
+ };
52
+ readonly optionsQueryPayloadWithoutQuery: {
53
+ readonly id: "config-key/options-query-payload-without-query";
54
+ readonly summary: "A config key that declares optionsQueryPayload also declares optionsQuery.";
55
+ readonly fix: "Set optionsQuery or remove optionsQueryPayload.";
56
+ };
57
+ readonly optionsQueryEmpty: {
58
+ readonly id: "config-key/options-query-empty";
59
+ readonly summary: "A config key's optionsQuery is a non-empty query name when present.";
60
+ readonly fix: "Set it to a query name or remove it.";
61
+ };
62
+ readonly optionsQueryNotSelect: {
63
+ readonly id: "config-key/options-query-not-select";
64
+ readonly summary: 'A config key declares optionsQuery only when its type is "select".';
65
+ readonly fix: 'Change the key type to "select" or remove optionsQuery.';
66
+ };
67
+ readonly optionsAndOptionsQuery: {
68
+ readonly id: "config-key/options-and-options-query";
69
+ readonly summary: "A config key declares either static options or optionsQuery, not both.";
70
+ readonly fix: "Remove options or optionsQuery.";
71
+ };
72
+ readonly optionsQueryPerRequest: {
73
+ readonly id: "config-key/options-query-per-request";
74
+ readonly summary: "A config key with optionsQuery does not set allowPerRequest, which would bypass the option set unchecked.";
75
+ readonly fix: "Remove allowPerRequest or optionsQuery.";
76
+ };
77
+ readonly optionsQueryPayloadSelfReference: {
78
+ readonly id: "config-key/options-query-payload-self-reference";
79
+ readonly summary: "A config key's optionsQueryPayload does not reference the key itself.";
80
+ readonly fix: "Reference a different config key.";
81
+ };
82
+ readonly optionsQueryPayloadUnknownKey: {
83
+ readonly id: "config-key/options-query-payload-unknown-key";
84
+ readonly summary: "A config key's optionsQueryPayload references only config keys of the same feature.";
85
+ readonly fix: "Reference an existing config key of the feature or remove the entry.";
86
+ };
87
+ readonly secretsScopeNotSystem: {
88
+ readonly id: "config-key/secrets-scope-not-system";
89
+ readonly summary: 'A config key with backing="secrets" has scope "system", because secrets storage does not cascade.';
90
+ readonly fix: 'Set scope to "system" or drop backing="secrets".';
91
+ };
92
+ readonly piiEncryptedNotText: {
93
+ readonly id: "config-key/pii-encrypted-not-text";
94
+ readonly summary: 'A config key with piiEncrypted has type "text".';
95
+ readonly fix: 'Use type="text" or remove piiEncrypted.';
96
+ };
97
+ readonly piiEncryptedSystemScope: {
98
+ readonly id: "config-key/pii-encrypted-system-scope";
99
+ readonly summary: "A config key with piiEncrypted is not system-scoped, because system scope has no subject to encrypt under.";
100
+ readonly fix: 'Use scope="tenant" or "user", or remove piiEncrypted.';
101
+ };
102
+ readonly piiEncryptedAndEncrypted: {
103
+ readonly id: "config-key/pii-encrypted-and-encrypted";
104
+ readonly summary: 'A config key uses piiEncrypted or encrypted/backing="secrets", never both.';
105
+ readonly fix: "Pick one of piiEncrypted (subject-KMS) or encrypted (shared cipher).";
106
+ };
107
+ readonly unknownConfigRead: {
108
+ readonly id: "config-key/unknown-config-read";
109
+ readonly summary: "A feature reads only config keys that some feature defines.";
110
+ readonly fix: "Declare the key via r.config(...) in a feature, or fix the key name.";
111
+ };
112
+ readonly circularDependency: {
113
+ readonly id: "feature/circular-dependency";
114
+ readonly summary: "Feature requires() links form no cycle.";
115
+ readonly fix: "Break the cycle by removing one requires() link.";
116
+ };
117
+ };
@@ -0,0 +1,117 @@
1
+ export const CONFIG_KEY_RULES = {
2
+ boundsNonNumber: {
3
+ id: "config-key/bounds-non-number",
4
+ summary: "A config key declares bounds only when its type is number.",
5
+ fix: 'Remove bounds or change the key type to "number".',
6
+ },
7
+ boundsMinAboveMax: {
8
+ id: "config-key/bounds-min-above-max",
9
+ summary: "A config key's bounds.min is at or below its bounds.max.",
10
+ fix: "Set bounds.min to a value at or below bounds.max.",
11
+ },
12
+ defaultBelowMin: {
13
+ id: "config-key/default-below-min",
14
+ summary: "A config key's default is not below its bounds.min.",
15
+ fix: "Raise the default or lower bounds.min.",
16
+ },
17
+ defaultAboveMax: {
18
+ id: "config-key/default-above-max",
19
+ summary: "A config key's default is not above its bounds.max.",
20
+ fix: "Lower the default or raise bounds.max.",
21
+ },
22
+ computedAndEncrypted: {
23
+ id: "config-key/computed-and-encrypted",
24
+ summary: 'A config key is either encrypted (encrypted or backing="secrets") or computed, never both.',
25
+ fix: 'Use either encrypted/backing="secrets" or a computed resolver on the key.',
26
+ },
27
+ requiredWithComputed: {
28
+ id: "config-key/required-with-computed",
29
+ summary: "A computed config key is not marked required, because it can never be missing.",
30
+ fix: "Drop required or the computed resolver.",
31
+ },
32
+ requiredWithDefault: {
33
+ id: "config-key/required-with-default",
34
+ summary: "A required config key has no non-empty default, otherwise it can never be unset and readiness never flags it.",
35
+ fix: 'Use default "" or drop required.',
36
+ },
37
+ perRequestText: {
38
+ id: "config-key/per-request-text",
39
+ summary: 'A config key of type "text" does not set allowPerRequest (XSS/injection risk).',
40
+ fix: "Remove allowPerRequest or change the key type.",
41
+ },
42
+ perRequestEncrypted: {
43
+ id: "config-key/per-request-encrypted",
44
+ summary: 'A config key with encrypted/backing="secrets" does not set allowPerRequest.',
45
+ fix: "Remove allowPerRequest or the secrets storage from the key.",
46
+ },
47
+ conditionalOptions: {
48
+ id: "config-key/conditional-options",
49
+ summary: "A config key does not declare conditionalOptions, which only entity select fields support.",
50
+ fix: "Remove conditionalOptions from the config key.",
51
+ },
52
+ optionsQueryPayloadWithoutQuery: {
53
+ id: "config-key/options-query-payload-without-query",
54
+ summary: "A config key that declares optionsQueryPayload also declares optionsQuery.",
55
+ fix: "Set optionsQuery or remove optionsQueryPayload.",
56
+ },
57
+ optionsQueryEmpty: {
58
+ id: "config-key/options-query-empty",
59
+ summary: "A config key's optionsQuery is a non-empty query name when present.",
60
+ fix: "Set it to a query name or remove it.",
61
+ },
62
+ optionsQueryNotSelect: {
63
+ id: "config-key/options-query-not-select",
64
+ summary: 'A config key declares optionsQuery only when its type is "select".',
65
+ fix: 'Change the key type to "select" or remove optionsQuery.',
66
+ },
67
+ optionsAndOptionsQuery: {
68
+ id: "config-key/options-and-options-query",
69
+ summary: "A config key declares either static options or optionsQuery, not both.",
70
+ fix: "Remove options or optionsQuery.",
71
+ },
72
+ optionsQueryPerRequest: {
73
+ id: "config-key/options-query-per-request",
74
+ summary: "A config key with optionsQuery does not set allowPerRequest, which would bypass the option set unchecked.",
75
+ fix: "Remove allowPerRequest or optionsQuery.",
76
+ },
77
+ optionsQueryPayloadSelfReference: {
78
+ id: "config-key/options-query-payload-self-reference",
79
+ summary: "A config key's optionsQueryPayload does not reference the key itself.",
80
+ fix: "Reference a different config key.",
81
+ },
82
+ optionsQueryPayloadUnknownKey: {
83
+ id: "config-key/options-query-payload-unknown-key",
84
+ summary: "A config key's optionsQueryPayload references only config keys of the same feature.",
85
+ fix: "Reference an existing config key of the feature or remove the entry.",
86
+ },
87
+ secretsScopeNotSystem: {
88
+ id: "config-key/secrets-scope-not-system",
89
+ summary: 'A config key with backing="secrets" has scope "system", because secrets storage does not cascade.',
90
+ fix: 'Set scope to "system" or drop backing="secrets".',
91
+ },
92
+ piiEncryptedNotText: {
93
+ id: "config-key/pii-encrypted-not-text",
94
+ summary: 'A config key with piiEncrypted has type "text".',
95
+ fix: 'Use type="text" or remove piiEncrypted.',
96
+ },
97
+ piiEncryptedSystemScope: {
98
+ id: "config-key/pii-encrypted-system-scope",
99
+ summary: "A config key with piiEncrypted is not system-scoped, because system scope has no subject to encrypt under.",
100
+ fix: 'Use scope="tenant" or "user", or remove piiEncrypted.',
101
+ },
102
+ piiEncryptedAndEncrypted: {
103
+ id: "config-key/pii-encrypted-and-encrypted",
104
+ summary: 'A config key uses piiEncrypted or encrypted/backing="secrets", never both.',
105
+ fix: "Pick one of piiEncrypted (subject-KMS) or encrypted (shared cipher).",
106
+ },
107
+ unknownConfigRead: {
108
+ id: "config-key/unknown-config-read",
109
+ summary: "A feature reads only config keys that some feature defines.",
110
+ fix: "Declare the key via r.config(...) in a feature, or fix the key name.",
111
+ },
112
+ circularDependency: {
113
+ id: "feature/circular-dependency",
114
+ summary: "Feature requires() links form no cycle.",
115
+ fix: "Break the cycle by removing one requires() link.",
116
+ },
117
+ };