@cosmicdrift/kumiko-framework 0.411.0 → 0.413.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/api/framework-db.md +1 -1
- package/agents/api/framework-engine.md +48 -1
- package/agents/api/framework-errors.md +2 -0
- package/agents/api/types.md +8 -0
- package/agents/api.md +2 -2
- package/agents/boot-rules.md +343 -0
- package/agents/examples/api-docs.md +710 -0
- package/agents/examples/golden-path.md +11 -11
- package/agents/examples/{contact.md → helpdesk.md} +31 -31
- package/agents/examples.md +2 -1
- package/agents/features-index.md +2 -2
- package/agents/features.md +16 -16
- package/dist/api/auth-middleware.d.ts +1 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/pat-auth-reject.d.ts +7 -0
- package/dist/api/pat-auth-reject.js +7 -0
- package/dist/api/server-middleware.js +2 -1
- package/dist/compliance/sub-processors.js +2 -2
- package/dist/config/index.d.ts +25 -0
- package/dist/config/index.js +28 -1
- package/dist/db/event-store-executor-read-paging.d.ts +1 -0
- package/dist/db/event-store-executor-read-paging.js +2 -1
- package/dist/db/read-gate-clause.js +26 -7
- package/dist/db/table-builder.d.ts +1 -2
- package/dist/engine/boot-validator/boot-report.d.ts +3 -0
- package/dist/engine/boot-validator/boot-report.js +2 -2
- package/dist/engine/boot-validator/boot-rules.d.ts +570 -0
- package/dist/engine/boot-validator/boot-rules.js +20 -0
- package/dist/engine/boot-validator/definition-config-events-jobs-rules.d.ts +77 -0
- package/dist/engine/boot-validator/definition-config-events-jobs-rules.js +77 -0
- package/dist/engine/boot-validator/definition-events-rules.d.ts +42 -0
- package/dist/engine/boot-validator/definition-events-rules.js +42 -0
- package/dist/engine/boot-validator/definition-feature-rules.d.ts +42 -0
- package/dist/engine/boot-validator/definition-feature-rules.js +42 -0
- package/dist/engine/boot-validator/definition-field-factories-rules.d.ts +17 -0
- package/dist/engine/boot-validator/definition-field-factories-rules.js +17 -0
- package/dist/engine/boot-validator/definition-handlers-rules.d.ts +72 -0
- package/dist/engine/boot-validator/definition-handlers-rules.js +72 -0
- package/dist/engine/boot-validator/definition-ownership-from-rules.d.ts +27 -0
- package/dist/engine/boot-validator/definition-ownership-from-rules.js +27 -0
- package/dist/engine/boot-validator/definition-probes-rules.d.ts +47 -0
- package/dist/engine/boot-validator/definition-probes-rules.js +47 -0
- package/dist/engine/boot-validator/definition-role-assignment-rules.d.ts +27 -0
- package/dist/engine/boot-validator/definition-role-assignment-rules.js +27 -0
- package/dist/engine/boot-validator/definition-ui-extensions-rules.d.ts +197 -0
- package/dist/engine/boot-validator/definition-ui-extensions-rules.js +197 -0
- package/dist/engine/boot-validator/definition-webhook-events-rules.d.ts +32 -0
- package/dist/engine/boot-validator/definition-webhook-events-rules.js +32 -0
- package/dist/engine/define-feature.js +29 -9
- package/dist/engine/define-handler.js +8 -4
- package/dist/engine/definition-violations.d.ts +14 -0
- package/dist/engine/definition-violations.js +71 -0
- package/dist/engine/entity-handlers.js +39 -13
- package/dist/engine/entity-list-runtime-options.js +12 -0
- package/dist/engine/event-def.js +32 -12
- package/dist/engine/factories.d.ts +2 -0
- package/dist/engine/factories.js +16 -5
- package/dist/engine/feature-builder-state.d.ts +2 -1
- package/dist/engine/feature-builder-state.js +1 -0
- package/dist/engine/feature-config-events-jobs.js +63 -27
- package/dist/engine/feature-entity-handlers.js +15 -6
- package/dist/engine/feature-probes.js +29 -9
- package/dist/engine/feature-ui-extensions.js +178 -92
- package/dist/engine/index.d.ts +5 -2
- package/dist/engine/index.js +4 -1
- package/dist/engine/object-form.js +8 -2
- package/dist/engine/ownership.js +17 -5
- package/dist/engine/registry-facade.js +13 -0
- package/dist/engine/role-assignment.js +17 -5
- package/dist/engine/webhook-contracts.d.ts +12 -0
- package/dist/engine/webhook-contracts.js +172 -0
- package/dist/engine/webhook-events.d.ts +34 -0
- package/dist/engine/webhook-events.js +85 -0
- package/dist/errors/docs-url.js +2 -19
- package/dist/errors/error-codes.d.ts +20 -0
- package/dist/errors/error-codes.js +19 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +1 -0
- package/dist/files/file-routes.js +1 -1
- package/dist/i18n/required-surface-keys.d.ts +4 -0
- package/dist/i18n/required-surface-keys.js +15 -0
- package/dist/schema-cli/shared.d.ts +11 -0
- package/dist/schema-cli/shared.js +37 -3
- package/dist/schema-cli/validate-command.js +10 -3
- package/package.json +3 -3
- package/src/changes.json +42 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const DEFINITION_ROLE_ASSIGNMENT_RULES: {
|
|
2
|
+
readonly nameEmpty: {
|
|
3
|
+
readonly id: "role/assignable-name-empty";
|
|
4
|
+
readonly summary: "Assignable role names are non-empty.";
|
|
5
|
+
readonly fix: "Give the role a name.";
|
|
6
|
+
};
|
|
7
|
+
readonly builtIn: {
|
|
8
|
+
readonly id: "role/assignable-built-in";
|
|
9
|
+
readonly summary: "Assignable roles are not built-in roles.";
|
|
10
|
+
readonly fix: "Pick a different role name.";
|
|
11
|
+
};
|
|
12
|
+
readonly reservedMembership: {
|
|
13
|
+
readonly id: "role/assignable-reserved";
|
|
14
|
+
readonly summary: "Assignable roles are not reserved platform roles.";
|
|
15
|
+
readonly fix: "Pick a different role name.";
|
|
16
|
+
};
|
|
17
|
+
readonly assignableFromInvalid: {
|
|
18
|
+
readonly id: "role/assignable-from-invalid";
|
|
19
|
+
readonly summary: "assignableFrom is one of the allowed roles.";
|
|
20
|
+
readonly fix: "Use a role from the list in the message.";
|
|
21
|
+
};
|
|
22
|
+
readonly assignableFromConflict: {
|
|
23
|
+
readonly id: "role/assignable-from-conflict";
|
|
24
|
+
readonly summary: "A role is declared with one assignableFrom value.";
|
|
25
|
+
readonly fix: "Declare the same assignableFrom everywhere or declare it once.";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const DEFINITION_ROLE_ASSIGNMENT_RULES = {
|
|
2
|
+
nameEmpty: {
|
|
3
|
+
id: "role/assignable-name-empty",
|
|
4
|
+
summary: "Assignable role names are non-empty.",
|
|
5
|
+
fix: "Give the role a name.",
|
|
6
|
+
},
|
|
7
|
+
builtIn: {
|
|
8
|
+
id: "role/assignable-built-in",
|
|
9
|
+
summary: "Assignable roles are not built-in roles.",
|
|
10
|
+
fix: "Pick a different role name.",
|
|
11
|
+
},
|
|
12
|
+
reservedMembership: {
|
|
13
|
+
id: "role/assignable-reserved",
|
|
14
|
+
summary: "Assignable roles are not reserved platform roles.",
|
|
15
|
+
fix: "Pick a different role name.",
|
|
16
|
+
},
|
|
17
|
+
assignableFromInvalid: {
|
|
18
|
+
id: "role/assignable-from-invalid",
|
|
19
|
+
summary: "assignableFrom is one of the allowed roles.",
|
|
20
|
+
fix: "Use a role from the list in the message.",
|
|
21
|
+
},
|
|
22
|
+
assignableFromConflict: {
|
|
23
|
+
id: "role/assignable-from-conflict",
|
|
24
|
+
summary: "A role is declared with one assignableFrom value.",
|
|
25
|
+
fix: "Declare the same assignableFrom everywhere or declare it once.",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
export declare const DEFINITION_UI_EXTENSION_RULES: {
|
|
2
|
+
readonly extensionSelectorPanelIdInvalid: {
|
|
3
|
+
readonly id: "extension-selector/panel-id-invalid";
|
|
4
|
+
readonly summary: "Extension selector panel ids are unique, non-empty and not the reserved selector id.";
|
|
5
|
+
readonly fix: "Give each panel its own id and avoid the reserved selector panel id.";
|
|
6
|
+
};
|
|
7
|
+
readonly extensionSelectorScreenPanelLabel: {
|
|
8
|
+
readonly id: "extension-selector/screen-panel-label";
|
|
9
|
+
readonly summary: "An extension selector screen panel sets no label.";
|
|
10
|
+
readonly fix: "Remove the label; the embedded screen carries its own title.";
|
|
11
|
+
};
|
|
12
|
+
readonly extensionSelectorPanelKindUnsupported: {
|
|
13
|
+
readonly id: "extension-selector/panel-kind-unsupported";
|
|
14
|
+
readonly summary: "Extension selector panels are of kind custom or screen.";
|
|
15
|
+
readonly fix: 'Use a panel of kind "custom" or "screen".';
|
|
16
|
+
};
|
|
17
|
+
readonly navIdNotKebab: {
|
|
18
|
+
readonly id: "nav/id-not-kebab";
|
|
19
|
+
readonly summary: "Nav ids are kebab-case.";
|
|
20
|
+
readonly fix: "Rename the nav id to lowercase letters, digits and dashes, starting with a letter.";
|
|
21
|
+
};
|
|
22
|
+
readonly navIdDuplicate: {
|
|
23
|
+
readonly id: "nav/id-duplicate";
|
|
24
|
+
readonly summary: "Nav ids are unique per feature.";
|
|
25
|
+
readonly fix: "Remove the standalone r.nav() call or the screen's inline nav.";
|
|
26
|
+
};
|
|
27
|
+
readonly hookValidationEscapeHatch: {
|
|
28
|
+
readonly id: "hook/validation-escape-hatch";
|
|
29
|
+
readonly summary: "Validation hooks declare no escapeHatch.";
|
|
30
|
+
readonly fix: "Remove escapeHatch from the validation hook.";
|
|
31
|
+
};
|
|
32
|
+
readonly hookEscapeHatchInvalid: {
|
|
33
|
+
readonly id: "hook/escape-hatch-invalid";
|
|
34
|
+
readonly summary: "A hook escapeHatch carries a valid reason and grants.";
|
|
35
|
+
readonly fix: "Fix the escapeHatch reason or grants as the message describes.";
|
|
36
|
+
};
|
|
37
|
+
readonly hookAllOfUnsupportedType: {
|
|
38
|
+
readonly id: "hook/all-of-unsupported-type";
|
|
39
|
+
readonly summary: "Hooks with target allOf are postSave, preDelete, postDelete or postQuery.";
|
|
40
|
+
readonly fix: "Use a supported hook type or a different target.";
|
|
41
|
+
};
|
|
42
|
+
readonly hookTypeUnknown: {
|
|
43
|
+
readonly id: "hook/type-unknown";
|
|
44
|
+
readonly summary: "Hooks use a known hook type.";
|
|
45
|
+
readonly fix: "Use a valid hook type; preQuery hooks were removed.";
|
|
46
|
+
};
|
|
47
|
+
readonly useExtensionEscapeHatchInvalid: {
|
|
48
|
+
readonly id: "extension/use-escape-hatch-invalid";
|
|
49
|
+
readonly summary: "r.useExtension() escapeHatch carries a valid reason and grants.";
|
|
50
|
+
readonly fix: 'Pass escapeHatch as { reason: "<explanation>" } with valid grants.';
|
|
51
|
+
};
|
|
52
|
+
readonly extensionSelectorDuplicate: {
|
|
53
|
+
readonly id: "extension-selector/duplicate";
|
|
54
|
+
readonly summary: "Each extension point has at most one selector.";
|
|
55
|
+
readonly fix: "Declare one extensionSelector per extension.";
|
|
56
|
+
};
|
|
57
|
+
readonly exposesApiTwice: {
|
|
58
|
+
readonly id: "api/exposes-called-twice";
|
|
59
|
+
readonly summary: "An API name is exposed once per feature.";
|
|
60
|
+
readonly fix: "Remove the duplicate r.exposesApi() call or rename it.";
|
|
61
|
+
};
|
|
62
|
+
readonly projectionNameNotKebab: {
|
|
63
|
+
readonly id: "projection/name-not-kebab";
|
|
64
|
+
readonly summary: "Projection names are kebab-case.";
|
|
65
|
+
readonly fix: "Rename the projection to lowercase letters, digits and dashes.";
|
|
66
|
+
};
|
|
67
|
+
readonly projectionNameDuplicate: {
|
|
68
|
+
readonly id: "projection/name-duplicate";
|
|
69
|
+
readonly summary: "Projection names are unique per feature.";
|
|
70
|
+
readonly fix: "Rename one of the projections.";
|
|
71
|
+
};
|
|
72
|
+
readonly multiStreamProjectionNameNotKebab: {
|
|
73
|
+
readonly id: "projection/multi-stream-name-not-kebab";
|
|
74
|
+
readonly summary: "Multi-stream projection names are kebab-case.";
|
|
75
|
+
readonly fix: "Rename the projection to lowercase letters, digits and dashes.";
|
|
76
|
+
};
|
|
77
|
+
readonly multiStreamProjectionNameDuplicate: {
|
|
78
|
+
readonly id: "projection/multi-stream-name-duplicate";
|
|
79
|
+
readonly summary: "r.projection and r.multiStreamProjection share one name space per feature.";
|
|
80
|
+
readonly fix: "Pick a unique short name.";
|
|
81
|
+
};
|
|
82
|
+
readonly multiStreamProjectionWithoutApply: {
|
|
83
|
+
readonly id: "projection/multi-stream-without-apply";
|
|
84
|
+
readonly summary: "A multi-stream projection declares at least one apply handler.";
|
|
85
|
+
readonly fix: "Declare at least one event type the projection reacts to.";
|
|
86
|
+
};
|
|
87
|
+
readonly extendEntityProjectionWithoutApply: {
|
|
88
|
+
readonly id: "projection/extend-without-apply";
|
|
89
|
+
readonly summary: "extendEntityProjection declares at least one apply handler.";
|
|
90
|
+
readonly fix: "Declare at least one event type to apply.";
|
|
91
|
+
};
|
|
92
|
+
readonly screenIdNotKebab: {
|
|
93
|
+
readonly id: "screen/id-not-kebab";
|
|
94
|
+
readonly summary: "Screen ids are kebab-case.";
|
|
95
|
+
readonly fix: "Rename the screen id to lowercase letters, digits and dashes.";
|
|
96
|
+
};
|
|
97
|
+
readonly screenIdDuplicate: {
|
|
98
|
+
readonly id: "screen/id-duplicate";
|
|
99
|
+
readonly summary: "Screen ids are unique per feature.";
|
|
100
|
+
readonly fix: "Rename one of the screens.";
|
|
101
|
+
};
|
|
102
|
+
readonly contentCollectionIdDuplicate: {
|
|
103
|
+
readonly id: "content-collection/id-duplicate";
|
|
104
|
+
readonly summary: "Content collection ids are unique per feature.";
|
|
105
|
+
readonly fix: "Rename one of the collections.";
|
|
106
|
+
};
|
|
107
|
+
readonly workspaceIdNotKebab: {
|
|
108
|
+
readonly id: "workspace/id-not-kebab";
|
|
109
|
+
readonly summary: "Workspace ids are kebab-case.";
|
|
110
|
+
readonly fix: "Rename the workspace id to lowercase letters, digits and dashes.";
|
|
111
|
+
};
|
|
112
|
+
readonly workspaceIdDuplicate: {
|
|
113
|
+
readonly id: "workspace/id-duplicate";
|
|
114
|
+
readonly summary: "Workspace ids are unique per feature.";
|
|
115
|
+
readonly fix: "Rename one of the workspaces.";
|
|
116
|
+
};
|
|
117
|
+
readonly httpRoutePathNotAbsolute: {
|
|
118
|
+
readonly id: "http-route/path-not-absolute";
|
|
119
|
+
readonly summary: "HTTP route paths start with a slash.";
|
|
120
|
+
readonly fix: 'Prefix the route path with "/".';
|
|
121
|
+
};
|
|
122
|
+
readonly httpRoutePathReserved: {
|
|
123
|
+
readonly id: "http-route/path-reserved";
|
|
124
|
+
readonly summary: "HTTP route paths stay out of the reserved /api namespace.";
|
|
125
|
+
readonly fix: "Pick a path outside /api or use a query or write handler.";
|
|
126
|
+
};
|
|
127
|
+
readonly httpRouteAnonymousMissing: {
|
|
128
|
+
readonly id: "http-route/anonymous-missing";
|
|
129
|
+
readonly summary: "HTTP routes declare anonymous as true or false.";
|
|
130
|
+
readonly fix: "Set anonymous: true for public routes or false for session-authenticated ones.";
|
|
131
|
+
};
|
|
132
|
+
readonly httpRouteRateLimitInvalid: {
|
|
133
|
+
readonly id: "http-route/rate-limit-invalid";
|
|
134
|
+
readonly summary: "HTTP route rateLimit has a positive integer limit and windowSeconds.";
|
|
135
|
+
readonly fix: "Set limit and windowSeconds to positive integers.";
|
|
136
|
+
};
|
|
137
|
+
readonly httpRouteDuplicate: {
|
|
138
|
+
readonly id: "http-route/duplicate";
|
|
139
|
+
readonly summary: "HTTP routes are unique per method and path within a feature.";
|
|
140
|
+
readonly fix: "Remove the duplicate route or change its method or path.";
|
|
141
|
+
};
|
|
142
|
+
readonly webSocketRoutePathPrefix: {
|
|
143
|
+
readonly id: "websocket-route/path-prefix";
|
|
144
|
+
readonly summary: "WebSocket route paths live under the WebSocket namespace prefix.";
|
|
145
|
+
readonly fix: "Start the path with the prefix named in the message.";
|
|
146
|
+
};
|
|
147
|
+
readonly webSocketRoutePathWildcard: {
|
|
148
|
+
readonly id: "websocket-route/path-wildcard";
|
|
149
|
+
readonly summary: "WebSocket route paths contain no wildcard.";
|
|
150
|
+
readonly fix: "Remove the * from the path.";
|
|
151
|
+
};
|
|
152
|
+
readonly webSocketRouteMaxMessageBytesInvalid: {
|
|
153
|
+
readonly id: "websocket-route/max-message-bytes-invalid";
|
|
154
|
+
readonly summary: "WebSocket maxMessageBytes is an integer within the allowed range.";
|
|
155
|
+
readonly fix: "Set maxMessageBytes to an integer within the range in the message.";
|
|
156
|
+
};
|
|
157
|
+
readonly webSocketRouteMaxConnectionsInvalid: {
|
|
158
|
+
readonly id: "websocket-route/max-connections-invalid";
|
|
159
|
+
readonly summary: "WebSocket maxConnectionsPerUser is an integer within the allowed range.";
|
|
160
|
+
readonly fix: "Set maxConnectionsPerUser to an integer within the range in the message.";
|
|
161
|
+
};
|
|
162
|
+
readonly webSocketRouteDuplicate: {
|
|
163
|
+
readonly id: "websocket-route/duplicate";
|
|
164
|
+
readonly summary: "WebSocket route paths are unique per feature.";
|
|
165
|
+
readonly fix: "Remove the duplicate route or change its path.";
|
|
166
|
+
};
|
|
167
|
+
readonly storeTableNameInvalid: {
|
|
168
|
+
readonly id: "store-table/name-invalid";
|
|
169
|
+
readonly summary: "Store table names are valid lowercase identifiers.";
|
|
170
|
+
readonly fix: "Use lowercase letters, digits and underscores, starting with a letter.";
|
|
171
|
+
};
|
|
172
|
+
readonly storeTableDuplicate: {
|
|
173
|
+
readonly id: "store-table/duplicate";
|
|
174
|
+
readonly summary: "Store table names are unique per feature.";
|
|
175
|
+
readonly fix: "Rename one of the store tables.";
|
|
176
|
+
};
|
|
177
|
+
readonly storeTableReadPrefixReserved: {
|
|
178
|
+
readonly id: "store-table/read-prefix-reserved";
|
|
179
|
+
readonly summary: "Store table names do not use the read_ prefix.";
|
|
180
|
+
readonly fix: "Pick an unprefixed name or a distinct prefix such as store_.";
|
|
181
|
+
};
|
|
182
|
+
readonly storeTableMetaNotUnmanaged: {
|
|
183
|
+
readonly id: "store-table/meta-not-unmanaged";
|
|
184
|
+
readonly summary: "r.storeTable() receives table meta with source unmanaged.";
|
|
185
|
+
readonly fix: 'Build the meta with defineUnmanagedTable() or source: "unmanaged".';
|
|
186
|
+
};
|
|
187
|
+
readonly storeTableReasonMissing: {
|
|
188
|
+
readonly id: "store-table/reason-missing";
|
|
189
|
+
readonly summary: "r.storeTable() declares a non-empty options.reason.";
|
|
190
|
+
readonly fix: "Add a reason justifying the audit-trail bypass or declare the data via r.entity().";
|
|
191
|
+
};
|
|
192
|
+
readonly treeActionsTwice: {
|
|
193
|
+
readonly id: "tree-actions/declared-twice";
|
|
194
|
+
readonly summary: "A feature calls r.treeActions() at most once.";
|
|
195
|
+
readonly fix: "Merge the tree actions into a single r.treeActions() call.";
|
|
196
|
+
};
|
|
197
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
export const DEFINITION_UI_EXTENSION_RULES = {
|
|
2
|
+
extensionSelectorPanelIdInvalid: {
|
|
3
|
+
id: "extension-selector/panel-id-invalid",
|
|
4
|
+
summary: "Extension selector panel ids are unique, non-empty and not the reserved selector id.",
|
|
5
|
+
fix: "Give each panel its own id and avoid the reserved selector panel id.",
|
|
6
|
+
},
|
|
7
|
+
extensionSelectorScreenPanelLabel: {
|
|
8
|
+
id: "extension-selector/screen-panel-label",
|
|
9
|
+
summary: "An extension selector screen panel sets no label.",
|
|
10
|
+
fix: "Remove the label; the embedded screen carries its own title.",
|
|
11
|
+
},
|
|
12
|
+
extensionSelectorPanelKindUnsupported: {
|
|
13
|
+
id: "extension-selector/panel-kind-unsupported",
|
|
14
|
+
summary: "Extension selector panels are of kind custom or screen.",
|
|
15
|
+
fix: 'Use a panel of kind "custom" or "screen".',
|
|
16
|
+
},
|
|
17
|
+
navIdNotKebab: {
|
|
18
|
+
id: "nav/id-not-kebab",
|
|
19
|
+
summary: "Nav ids are kebab-case.",
|
|
20
|
+
fix: "Rename the nav id to lowercase letters, digits and dashes, starting with a letter.",
|
|
21
|
+
},
|
|
22
|
+
navIdDuplicate: {
|
|
23
|
+
id: "nav/id-duplicate",
|
|
24
|
+
summary: "Nav ids are unique per feature.",
|
|
25
|
+
fix: "Remove the standalone r.nav() call or the screen's inline nav.",
|
|
26
|
+
},
|
|
27
|
+
hookValidationEscapeHatch: {
|
|
28
|
+
id: "hook/validation-escape-hatch",
|
|
29
|
+
summary: "Validation hooks declare no escapeHatch.",
|
|
30
|
+
fix: "Remove escapeHatch from the validation hook.",
|
|
31
|
+
},
|
|
32
|
+
hookEscapeHatchInvalid: {
|
|
33
|
+
id: "hook/escape-hatch-invalid",
|
|
34
|
+
summary: "A hook escapeHatch carries a valid reason and grants.",
|
|
35
|
+
fix: "Fix the escapeHatch reason or grants as the message describes.",
|
|
36
|
+
},
|
|
37
|
+
hookAllOfUnsupportedType: {
|
|
38
|
+
id: "hook/all-of-unsupported-type",
|
|
39
|
+
summary: "Hooks with target allOf are postSave, preDelete, postDelete or postQuery.",
|
|
40
|
+
fix: "Use a supported hook type or a different target.",
|
|
41
|
+
},
|
|
42
|
+
hookTypeUnknown: {
|
|
43
|
+
id: "hook/type-unknown",
|
|
44
|
+
summary: "Hooks use a known hook type.",
|
|
45
|
+
fix: "Use a valid hook type; preQuery hooks were removed.",
|
|
46
|
+
},
|
|
47
|
+
useExtensionEscapeHatchInvalid: {
|
|
48
|
+
id: "extension/use-escape-hatch-invalid",
|
|
49
|
+
summary: "r.useExtension() escapeHatch carries a valid reason and grants.",
|
|
50
|
+
fix: 'Pass escapeHatch as { reason: "<explanation>" } with valid grants.',
|
|
51
|
+
},
|
|
52
|
+
extensionSelectorDuplicate: {
|
|
53
|
+
id: "extension-selector/duplicate",
|
|
54
|
+
summary: "Each extension point has at most one selector.",
|
|
55
|
+
fix: "Declare one extensionSelector per extension.",
|
|
56
|
+
},
|
|
57
|
+
exposesApiTwice: {
|
|
58
|
+
id: "api/exposes-called-twice",
|
|
59
|
+
summary: "An API name is exposed once per feature.",
|
|
60
|
+
fix: "Remove the duplicate r.exposesApi() call or rename it.",
|
|
61
|
+
},
|
|
62
|
+
projectionNameNotKebab: {
|
|
63
|
+
id: "projection/name-not-kebab",
|
|
64
|
+
summary: "Projection names are kebab-case.",
|
|
65
|
+
fix: "Rename the projection to lowercase letters, digits and dashes.",
|
|
66
|
+
},
|
|
67
|
+
projectionNameDuplicate: {
|
|
68
|
+
id: "projection/name-duplicate",
|
|
69
|
+
summary: "Projection names are unique per feature.",
|
|
70
|
+
fix: "Rename one of the projections.",
|
|
71
|
+
},
|
|
72
|
+
multiStreamProjectionNameNotKebab: {
|
|
73
|
+
id: "projection/multi-stream-name-not-kebab",
|
|
74
|
+
summary: "Multi-stream projection names are kebab-case.",
|
|
75
|
+
fix: "Rename the projection to lowercase letters, digits and dashes.",
|
|
76
|
+
},
|
|
77
|
+
multiStreamProjectionNameDuplicate: {
|
|
78
|
+
id: "projection/multi-stream-name-duplicate",
|
|
79
|
+
summary: "r.projection and r.multiStreamProjection share one name space per feature.",
|
|
80
|
+
fix: "Pick a unique short name.",
|
|
81
|
+
},
|
|
82
|
+
multiStreamProjectionWithoutApply: {
|
|
83
|
+
id: "projection/multi-stream-without-apply",
|
|
84
|
+
summary: "A multi-stream projection declares at least one apply handler.",
|
|
85
|
+
fix: "Declare at least one event type the projection reacts to.",
|
|
86
|
+
},
|
|
87
|
+
extendEntityProjectionWithoutApply: {
|
|
88
|
+
id: "projection/extend-without-apply",
|
|
89
|
+
summary: "extendEntityProjection declares at least one apply handler.",
|
|
90
|
+
fix: "Declare at least one event type to apply.",
|
|
91
|
+
},
|
|
92
|
+
screenIdNotKebab: {
|
|
93
|
+
id: "screen/id-not-kebab",
|
|
94
|
+
summary: "Screen ids are kebab-case.",
|
|
95
|
+
fix: "Rename the screen id to lowercase letters, digits and dashes.",
|
|
96
|
+
},
|
|
97
|
+
screenIdDuplicate: {
|
|
98
|
+
id: "screen/id-duplicate",
|
|
99
|
+
summary: "Screen ids are unique per feature.",
|
|
100
|
+
fix: "Rename one of the screens.",
|
|
101
|
+
},
|
|
102
|
+
contentCollectionIdDuplicate: {
|
|
103
|
+
id: "content-collection/id-duplicate",
|
|
104
|
+
summary: "Content collection ids are unique per feature.",
|
|
105
|
+
fix: "Rename one of the collections.",
|
|
106
|
+
},
|
|
107
|
+
workspaceIdNotKebab: {
|
|
108
|
+
id: "workspace/id-not-kebab",
|
|
109
|
+
summary: "Workspace ids are kebab-case.",
|
|
110
|
+
fix: "Rename the workspace id to lowercase letters, digits and dashes.",
|
|
111
|
+
},
|
|
112
|
+
workspaceIdDuplicate: {
|
|
113
|
+
id: "workspace/id-duplicate",
|
|
114
|
+
summary: "Workspace ids are unique per feature.",
|
|
115
|
+
fix: "Rename one of the workspaces.",
|
|
116
|
+
},
|
|
117
|
+
httpRoutePathNotAbsolute: {
|
|
118
|
+
id: "http-route/path-not-absolute",
|
|
119
|
+
summary: "HTTP route paths start with a slash.",
|
|
120
|
+
fix: 'Prefix the route path with "/".',
|
|
121
|
+
},
|
|
122
|
+
httpRoutePathReserved: {
|
|
123
|
+
id: "http-route/path-reserved",
|
|
124
|
+
summary: "HTTP route paths stay out of the reserved /api namespace.",
|
|
125
|
+
fix: "Pick a path outside /api or use a query or write handler.",
|
|
126
|
+
},
|
|
127
|
+
httpRouteAnonymousMissing: {
|
|
128
|
+
id: "http-route/anonymous-missing",
|
|
129
|
+
summary: "HTTP routes declare anonymous as true or false.",
|
|
130
|
+
fix: "Set anonymous: true for public routes or false for session-authenticated ones.",
|
|
131
|
+
},
|
|
132
|
+
httpRouteRateLimitInvalid: {
|
|
133
|
+
id: "http-route/rate-limit-invalid",
|
|
134
|
+
summary: "HTTP route rateLimit has a positive integer limit and windowSeconds.",
|
|
135
|
+
fix: "Set limit and windowSeconds to positive integers.",
|
|
136
|
+
},
|
|
137
|
+
httpRouteDuplicate: {
|
|
138
|
+
id: "http-route/duplicate",
|
|
139
|
+
summary: "HTTP routes are unique per method and path within a feature.",
|
|
140
|
+
fix: "Remove the duplicate route or change its method or path.",
|
|
141
|
+
},
|
|
142
|
+
webSocketRoutePathPrefix: {
|
|
143
|
+
id: "websocket-route/path-prefix",
|
|
144
|
+
summary: "WebSocket route paths live under the WebSocket namespace prefix.",
|
|
145
|
+
fix: "Start the path with the prefix named in the message.",
|
|
146
|
+
},
|
|
147
|
+
webSocketRoutePathWildcard: {
|
|
148
|
+
id: "websocket-route/path-wildcard",
|
|
149
|
+
summary: "WebSocket route paths contain no wildcard.",
|
|
150
|
+
fix: "Remove the * from the path.",
|
|
151
|
+
},
|
|
152
|
+
webSocketRouteMaxMessageBytesInvalid: {
|
|
153
|
+
id: "websocket-route/max-message-bytes-invalid",
|
|
154
|
+
summary: "WebSocket maxMessageBytes is an integer within the allowed range.",
|
|
155
|
+
fix: "Set maxMessageBytes to an integer within the range in the message.",
|
|
156
|
+
},
|
|
157
|
+
webSocketRouteMaxConnectionsInvalid: {
|
|
158
|
+
id: "websocket-route/max-connections-invalid",
|
|
159
|
+
summary: "WebSocket maxConnectionsPerUser is an integer within the allowed range.",
|
|
160
|
+
fix: "Set maxConnectionsPerUser to an integer within the range in the message.",
|
|
161
|
+
},
|
|
162
|
+
webSocketRouteDuplicate: {
|
|
163
|
+
id: "websocket-route/duplicate",
|
|
164
|
+
summary: "WebSocket route paths are unique per feature.",
|
|
165
|
+
fix: "Remove the duplicate route or change its path.",
|
|
166
|
+
},
|
|
167
|
+
storeTableNameInvalid: {
|
|
168
|
+
id: "store-table/name-invalid",
|
|
169
|
+
summary: "Store table names are valid lowercase identifiers.",
|
|
170
|
+
fix: "Use lowercase letters, digits and underscores, starting with a letter.",
|
|
171
|
+
},
|
|
172
|
+
storeTableDuplicate: {
|
|
173
|
+
id: "store-table/duplicate",
|
|
174
|
+
summary: "Store table names are unique per feature.",
|
|
175
|
+
fix: "Rename one of the store tables.",
|
|
176
|
+
},
|
|
177
|
+
storeTableReadPrefixReserved: {
|
|
178
|
+
id: "store-table/read-prefix-reserved",
|
|
179
|
+
summary: "Store table names do not use the read_ prefix.",
|
|
180
|
+
fix: "Pick an unprefixed name or a distinct prefix such as store_.",
|
|
181
|
+
},
|
|
182
|
+
storeTableMetaNotUnmanaged: {
|
|
183
|
+
id: "store-table/meta-not-unmanaged",
|
|
184
|
+
summary: "r.storeTable() receives table meta with source unmanaged.",
|
|
185
|
+
fix: 'Build the meta with defineUnmanagedTable() or source: "unmanaged".',
|
|
186
|
+
},
|
|
187
|
+
storeTableReasonMissing: {
|
|
188
|
+
id: "store-table/reason-missing",
|
|
189
|
+
summary: "r.storeTable() declares a non-empty options.reason.",
|
|
190
|
+
fix: "Add a reason justifying the audit-trail bypass or declare the data via r.entity().",
|
|
191
|
+
},
|
|
192
|
+
treeActionsTwice: {
|
|
193
|
+
id: "tree-actions/declared-twice",
|
|
194
|
+
summary: "A feature calls r.treeActions() at most once.",
|
|
195
|
+
fix: "Merge the tree actions into a single r.treeActions() call.",
|
|
196
|
+
},
|
|
197
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const DEFINITION_WEBHOOK_EVENT_RULES: {
|
|
2
|
+
readonly nameNotKebab: {
|
|
3
|
+
readonly id: "webhook-event/name-not-kebab";
|
|
4
|
+
readonly summary: "Webhook event names are kebab-case.";
|
|
5
|
+
readonly fix: "Rename the event to lowercase letters, digits and dashes.";
|
|
6
|
+
};
|
|
7
|
+
readonly descriptionEmpty: {
|
|
8
|
+
readonly id: "webhook-event/description-empty";
|
|
9
|
+
readonly summary: "Webhook events carry a non-empty description sentence.";
|
|
10
|
+
readonly fix: "Add a description.";
|
|
11
|
+
};
|
|
12
|
+
readonly payloadNotZodObject: {
|
|
13
|
+
readonly id: "webhook-event/payload-not-zod-object";
|
|
14
|
+
readonly summary: "Webhook event payloads are Zod object schemas.";
|
|
15
|
+
readonly fix: "Pass z.object({ ... }) as payload.";
|
|
16
|
+
};
|
|
17
|
+
readonly versionInvalid: {
|
|
18
|
+
readonly id: "webhook-event/version-invalid";
|
|
19
|
+
readonly summary: "Webhook event version is a positive integer.";
|
|
20
|
+
readonly fix: "Set version to an integer of 1 or higher.";
|
|
21
|
+
};
|
|
22
|
+
readonly wireNameEmpty: {
|
|
23
|
+
readonly id: "webhook-event/wire-name-empty";
|
|
24
|
+
readonly summary: "Webhook event wireName is a non-empty string when set.";
|
|
25
|
+
readonly fix: "Set a wireName or omit it.";
|
|
26
|
+
};
|
|
27
|
+
readonly duplicate: {
|
|
28
|
+
readonly id: "webhook-event/duplicate";
|
|
29
|
+
readonly summary: "Webhook event names are unique per feature.";
|
|
30
|
+
readonly fix: "Rename one of the events.";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const DEFINITION_WEBHOOK_EVENT_RULES = {
|
|
2
|
+
nameNotKebab: {
|
|
3
|
+
id: "webhook-event/name-not-kebab",
|
|
4
|
+
summary: "Webhook event names are kebab-case.",
|
|
5
|
+
fix: "Rename the event to lowercase letters, digits and dashes.",
|
|
6
|
+
},
|
|
7
|
+
descriptionEmpty: {
|
|
8
|
+
id: "webhook-event/description-empty",
|
|
9
|
+
summary: "Webhook events carry a non-empty description sentence.",
|
|
10
|
+
fix: "Add a description.",
|
|
11
|
+
},
|
|
12
|
+
payloadNotZodObject: {
|
|
13
|
+
id: "webhook-event/payload-not-zod-object",
|
|
14
|
+
summary: "Webhook event payloads are Zod object schemas.",
|
|
15
|
+
fix: "Pass z.object({ ... }) as payload.",
|
|
16
|
+
},
|
|
17
|
+
versionInvalid: {
|
|
18
|
+
id: "webhook-event/version-invalid",
|
|
19
|
+
summary: "Webhook event version is a positive integer.",
|
|
20
|
+
fix: "Set version to an integer of 1 or higher.",
|
|
21
|
+
},
|
|
22
|
+
wireNameEmpty: {
|
|
23
|
+
id: "webhook-event/wire-name-empty",
|
|
24
|
+
summary: "Webhook event wireName is a non-empty string when set.",
|
|
25
|
+
fix: "Set a wireName or omit it.",
|
|
26
|
+
},
|
|
27
|
+
duplicate: {
|
|
28
|
+
id: "webhook-event/duplicate",
|
|
29
|
+
summary: "Webhook event names are unique per feature.",
|
|
30
|
+
fix: "Rename one of the events.",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { bootRuleError } from "./boot-validator/boot-rule.js";
|
|
2
|
+
import { FEATURE_DEFINITION_RULES } from "./boot-validator/definition-feature-rules.js";
|
|
3
|
+
import { collectingRegistrar, runDefinitionStep } from "./definition-violations.js";
|
|
1
4
|
import { createInitialFeatureBuilderState } from "./feature-builder-state.js";
|
|
2
5
|
import { buildConfigEventsJobsMethods } from "./feature-config-events-jobs.js";
|
|
3
6
|
import { buildEntityHandlerMethods } from "./feature-entity-handlers.js";
|
|
4
7
|
import { buildProbeMethods } from "./feature-probes.js";
|
|
5
8
|
import { buildUiExtensionsMethods } from "./feature-ui-extensions.js";
|
|
6
9
|
import { isObjectArgument, throwObjectArgumentRequired, unwrapArrayForm } from "./object-form.js";
|
|
10
|
+
import { buildWebhookEventMethods } from "./webhook-events.js";
|
|
7
11
|
// `TExports` lets the setup callback hand back a typed object that
|
|
8
12
|
// downstream features can import (e.g. `tenantFeature.exports.config`). The
|
|
9
13
|
// runtime always packs whatever setup returns into `featureDef.exports` —
|
|
@@ -27,23 +31,29 @@ function resolveFeatureNamesArgs(args) {
|
|
|
27
31
|
function assertDedupeOptionsComparable(featureName, options) {
|
|
28
32
|
for (const [key, value] of Object.entries(options ?? {})) {
|
|
29
33
|
if (typeof value === "object" && value !== null) {
|
|
30
|
-
throw
|
|
34
|
+
throw bootRuleError(FEATURE_DEFINITION_RULES.dedupeOptionsNotComparable, {
|
|
35
|
+
message: `[Feature ${featureName}] dedupeOptions.${key} must be a primitive or a stable function reference; dedupeOptions are compared shallowly, so a nested object never matches a second mount`,
|
|
36
|
+
});
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
export function defineFeature(name, setup, settings) {
|
|
35
|
-
assertDedupeOptionsComparable(name, settings?.dedupeOptions);
|
|
41
|
+
runDefinitionStep(name, "defineFeature", () => assertDedupeOptionsComparable(name, settings?.dedupeOptions));
|
|
36
42
|
const state = createInitialFeatureBuilderState();
|
|
37
|
-
const
|
|
43
|
+
const plainRegistrar = {
|
|
38
44
|
systemScope() {
|
|
39
45
|
state.isSystemScoped = true;
|
|
40
46
|
},
|
|
41
47
|
describe(text) {
|
|
42
48
|
if (state.description !== undefined) {
|
|
43
|
-
throw
|
|
49
|
+
throw bootRuleError(FEATURE_DEFINITION_RULES.describeTwice, {
|
|
50
|
+
message: `[Feature ${name}] r.describe() called twice — a feature's description is declared once`,
|
|
51
|
+
});
|
|
44
52
|
}
|
|
45
53
|
if (typeof text !== "string" || text.trim().length === 0) {
|
|
46
|
-
throw
|
|
54
|
+
throw bootRuleError(FEATURE_DEFINITION_RULES.describeTextEmpty, {
|
|
55
|
+
message: `[Feature ${name}] r.describe(): text must be a non-empty string`,
|
|
56
|
+
});
|
|
47
57
|
}
|
|
48
58
|
state.description = text.trim();
|
|
49
59
|
},
|
|
@@ -56,7 +66,9 @@ export function defineFeature(name, setup, settings) {
|
|
|
56
66
|
// Untyped callers can pass `{ feature: [...] }`; without this the object would be
|
|
57
67
|
// registered as a dependency name.
|
|
58
68
|
if (!Array.isArray(first.features) || !first.features.every((f) => typeof f === "string")) {
|
|
59
|
-
throw
|
|
69
|
+
throw bootRuleError(FEATURE_DEFINITION_RULES.requiresNeedsFeatures, {
|
|
70
|
+
message: `[Feature ${name}] r.requires() needs { features: string[] }`,
|
|
71
|
+
});
|
|
60
72
|
}
|
|
61
73
|
state.requires.push(...first.features);
|
|
62
74
|
};
|
|
@@ -74,7 +86,9 @@ export function defineFeature(name, setup, settings) {
|
|
|
74
86
|
},
|
|
75
87
|
toggleable(options) {
|
|
76
88
|
if (state.toggleableDefault !== undefined) {
|
|
77
|
-
throw
|
|
89
|
+
throw bootRuleError(FEATURE_DEFINITION_RULES.toggleableTwice, {
|
|
90
|
+
message: `[Feature ${name}] r.toggleable() called twice — a feature's toggleable status is declared once`,
|
|
91
|
+
});
|
|
78
92
|
}
|
|
79
93
|
state.toggleableDefault = options.default;
|
|
80
94
|
},
|
|
@@ -83,16 +97,21 @@ export function defineFeature(name, setup, settings) {
|
|
|
83
97
|
},
|
|
84
98
|
uiHints(hints) {
|
|
85
99
|
if (state.uiHints !== undefined) {
|
|
86
|
-
throw
|
|
100
|
+
throw bootRuleError(FEATURE_DEFINITION_RULES.uiHintsTwice, {
|
|
101
|
+
message: `[Feature ${name}] r.uiHints() called twice — UI hints are declared once`,
|
|
102
|
+
});
|
|
87
103
|
}
|
|
88
104
|
state.uiHints = hints;
|
|
89
105
|
},
|
|
90
106
|
...buildEntityHandlerMethods(state, name),
|
|
91
107
|
...buildConfigEventsJobsMethods(state, name),
|
|
108
|
+
...buildWebhookEventMethods(state, name),
|
|
92
109
|
...buildUiExtensionsMethods(state, name),
|
|
93
110
|
...buildProbeMethods(state, name),
|
|
94
111
|
};
|
|
95
|
-
const
|
|
112
|
+
const registrar = collectingRegistrar(name, plainRegistrar);
|
|
113
|
+
// Undefined only while collecting definition violations; those features never reach the runtime.
|
|
114
|
+
const exports = runDefinitionStep(name, "defineFeature", () => setup(registrar)); // @cast-boundary engine-bridge
|
|
96
115
|
return {
|
|
97
116
|
name,
|
|
98
117
|
...(state.description !== undefined && { description: state.description }),
|
|
@@ -143,6 +162,7 @@ export function defineFeature(name, setup, settings) {
|
|
|
143
162
|
bootChecks: state.bootChecks,
|
|
144
163
|
referenceData: state.referenceData,
|
|
145
164
|
events: state.events,
|
|
165
|
+
...(Object.keys(state.webhookEvents).length > 0 && { webhookEvents: state.webhookEvents }),
|
|
146
166
|
eventMigrations: state.eventMigrations,
|
|
147
167
|
configReads: state.configReads,
|
|
148
168
|
handlerEntityMappings: state.handlerEntityMappings,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ENTITY_CONVENTION_QUERY_BRAND } from "@cosmicdrift/kumiko-types/handlers";
|
|
2
2
|
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
3
|
+
import { bootRuleError } from "./boot-validator/boot-rule.js";
|
|
4
|
+
import { DEFINITION_HANDLER_RULES } from "./boot-validator/definition-handlers-rules.js";
|
|
3
5
|
import { runPipeline } from "./run-pipeline.js";
|
|
4
6
|
function pickPreTransactionPhases(def) {
|
|
5
7
|
return {
|
|
@@ -42,10 +44,12 @@ export function defineWriteHandler(def,
|
|
|
42
44
|
// a name-and-explanation error message instead.
|
|
43
45
|
const handlerName = def.name;
|
|
44
46
|
if (hasHandlerAndPerform(def)) {
|
|
45
|
-
throw
|
|
46
|
-
`
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
throw bootRuleError(DEFINITION_HANDLER_RULES.handlerAndPerformBoth, {
|
|
48
|
+
message: `defineWriteHandler("${handlerName}"): both \`handler\` and \`perform\` are set. ` +
|
|
49
|
+
`Pick one — \`handler\` for the free-form async function, ` +
|
|
50
|
+
`\`perform: stepsPipeline(...)\` for the step-pipeline form. ` +
|
|
51
|
+
`(See step-vocabulary.md for which form fits.)`,
|
|
52
|
+
});
|
|
49
53
|
}
|
|
50
54
|
// Conditional spreads (`...(def.access && { access: def.access })`)
|
|
51
55
|
// mirror the existing convention in entity-handlers.ts /
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BootViolation } from "./boot-validator/boot-rule.ts";
|
|
2
|
+
export type DefinitionLoadOutcome<T> = {
|
|
3
|
+
readonly loaded: true;
|
|
4
|
+
readonly value: T;
|
|
5
|
+
} | {
|
|
6
|
+
readonly loaded: false;
|
|
7
|
+
readonly thrown: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare function collectDefinitionViolations<T>(load: () => Promise<T>): Promise<{
|
|
10
|
+
readonly violations: readonly BootViolation[];
|
|
11
|
+
readonly outcome: DefinitionLoadOutcome<T>;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function runDefinitionStep<T>(feature: string, check: string, step: () => T): T | undefined;
|
|
14
|
+
export declare function collectingRegistrar<R extends object>(feature: string, registrar: R): R;
|