@cosmicdrift/kumiko-framework 0.409.0 → 0.411.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-engine.md +4 -0
- package/agents/api/framework-ui-types.md +10 -0
- package/agents/api/renderer-web.md +113 -10
- package/agents/api/types.md +22 -0
- package/agents/api.md +1 -1
- package/agents/boot-rules.md +5 -0
- package/agents/examples/anonymous-access.md +23 -1
- package/agents/examples/contact.md +11 -5
- package/agents/examples/realtime-sse.md +37 -2
- package/agents/examples/record-detail-layout.md +35 -2
- package/agents/examples/wizard-form.md +96 -5
- package/agents/features-index.md +1 -1
- package/agents/features.md +9 -2
- package/agents/widgets.md +6 -0
- package/dist/db/queries/session-advisory-lock.js +3 -0
- package/dist/engine/access.js +5 -1
- package/dist/engine/boot-validator/access-declarations.js +19 -0
- package/dist/engine/boot-validator/boot-rules.d.ts +25 -0
- package/dist/engine/boot-validator/handler-declaration-rules.d.ts +5 -0
- package/dist/engine/boot-validator/handler-declaration-rules.js +5 -0
- package/dist/engine/boot-validator/list-table-options.js +1 -0
- package/dist/engine/boot-validator/nav.js +4 -2
- package/dist/engine/boot-validator/screens-forms-layout-rules.d.ts +15 -0
- package/dist/engine/boot-validator/screens-forms-layout-rules.js +15 -0
- package/dist/engine/boot-validator/screens-forms.d.ts +1 -1
- package/dist/engine/boot-validator/screens-forms.js +60 -3
- package/dist/engine/boot-validator/screens-kind-projection-detail-rules.d.ts +5 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail-rules.js +5 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail.js +19 -0
- package/dist/engine/boot-validator/screens-lists.js +2 -2
- package/dist/engine/project-app-schema-for-roles.js +11 -10
- package/dist/engine/screen-helpers.d.ts +1 -0
- package/dist/engine/screen-helpers.js +1 -1
- package/dist/pipeline/context-services.d.ts +1 -0
- package/dist/pipeline/context-services.js +1 -0
- package/dist/pipeline/handler-context-scope.js +5 -1
- package/dist/pipeline/user-live-signals.d.ts +5 -0
- package/dist/pipeline/user-live-signals.js +20 -0
- package/package.json +3 -3
- package/src/changes.json +54 -0
|
@@ -24,6 +24,11 @@ export const PROJECTION_DETAIL_RULES = {
|
|
|
24
24
|
summary: "A metric navigate.tab names a section id of the screen.",
|
|
25
25
|
fix: "Navigate to an existing section id or remove navigate.tab.",
|
|
26
26
|
},
|
|
27
|
+
actionShowOnTabsInvalid: {
|
|
28
|
+
id: "projection-detail/action-show-on-tabs-invalid",
|
|
29
|
+
summary: 'A header action showOnTabs is non-empty, names section ids of the screen and needs layout.mode "tabs".',
|
|
30
|
+
fix: "List existing section ids or remove showOnTabs.",
|
|
31
|
+
},
|
|
27
32
|
metricLabelMissing: {
|
|
28
33
|
id: "projection-detail/metric-label-missing",
|
|
29
34
|
summary: "Every metric has an i18n label key.",
|
|
@@ -255,6 +255,24 @@ function validateProjectionDetailSection(ctx, screenId, screen, section) {
|
|
|
255
255
|
validateProjectionDetailFieldsSection(ctx, screenId, section);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
+
function validateHeaderActionShowOnTabs(featureName, screenId, screen, action) {
|
|
259
|
+
// skip: no showOnTabs declared, the action is shown on every tab
|
|
260
|
+
if (action.showOnTabs === undefined)
|
|
261
|
+
return;
|
|
262
|
+
const sectionIds = screen.layout.sections.map((section) => section.id);
|
|
263
|
+
const unknownTab = action.showOnTabs.find((tab) => !sectionIds.includes(tab));
|
|
264
|
+
if (screen.layout.mode !== "tabs" || action.showOnTabs.length === 0 || unknownTab !== undefined) {
|
|
265
|
+
throw bootRuleError(PROJECTION_DETAIL_RULES.actionShowOnTabsInvalid, {
|
|
266
|
+
message: `[Feature ${featureName}] Screen "${screenId}" (projectionDetail) action "${action.id}" ` +
|
|
267
|
+
`sets showOnTabs ${JSON.stringify(action.showOnTabs)}` +
|
|
268
|
+
(unknownTab !== undefined
|
|
269
|
+
? `, but "${unknownTab}" is not a section id on this screen`
|
|
270
|
+
: "") +
|
|
271
|
+
(screen.layout.mode !== "tabs" ? ` — showOnTabs needs layout.mode "tabs"` : "") +
|
|
272
|
+
`. List existing section ids (at least one) or remove showOnTabs.`,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
258
276
|
// Query-driven like projectionList, but a single row plus layout instead of
|
|
259
277
|
// columns. No entity check is possible: fields resolve against the query
|
|
260
278
|
// response at render time, not against an entity.
|
|
@@ -277,5 +295,6 @@ export function validateProjectionDetailScreen(ctx, screenId, screen) {
|
|
|
277
295
|
for (const action of screen.actions ?? []) {
|
|
278
296
|
validateActionHasIcon(featureName, screenId, "projectionDetail", "action", action);
|
|
279
297
|
validateRecordHeaderAction(ctx, screenId, "projectionDetail", screen.detailFor, action);
|
|
298
|
+
validateHeaderActionShowOnTabs(featureName, screenId, screen, action);
|
|
280
299
|
}
|
|
281
300
|
}
|
|
@@ -3,7 +3,7 @@ import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
|
3
3
|
import { REFERENCE_LOOKUP_SOURCES } from "../../ui-types/list-row-meta.js";
|
|
4
4
|
import { parseRefTarget } from "../parse-ref-target.js";
|
|
5
5
|
import { qualifyEntityName } from "../qualified-name.js";
|
|
6
|
-
import { explicitListScreenId, normalizeListColumn, resolveNavParentScreen, } from "../screen-helpers.js";
|
|
6
|
+
import { explicitListScreenId, normalizeListColumn, resolveNavParentScreen, screenShortId, } from "../screen-helpers.js";
|
|
7
7
|
import { bootRuleError } from "./boot-rule.js";
|
|
8
8
|
import { ENTITY_LIST_RULES } from "./entity-list-screens-rules.js";
|
|
9
9
|
import { validateListBulkActions } from "./list-bulk-actions.js";
|
|
@@ -46,7 +46,7 @@ export function validateExplicitListScreenExists(featureName, screenId, screen,
|
|
|
46
46
|
// skip: no explicit listScreenId, the nav heuristic applies and there is nothing to validate
|
|
47
47
|
if (listScreenId === undefined)
|
|
48
48
|
return;
|
|
49
|
-
const shortId =
|
|
49
|
+
const shortId = screenShortId(listScreenId);
|
|
50
50
|
// skip: the explicit listScreenId resolves to a mounted screen
|
|
51
51
|
if (screensByShortId.has(shortId))
|
|
52
52
|
return;
|
|
@@ -231,15 +231,18 @@ function isTargetKept(target, keptScreenQns) {
|
|
|
231
231
|
return false;
|
|
232
232
|
return keptScreenQns.has(qualifyEntityName(target.featureName, "screen", target.screen.id));
|
|
233
233
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (
|
|
238
|
-
return
|
|
239
|
-
return
|
|
234
|
+
// A QN names exactly one screen; resolving it through the short-id index could land on another
|
|
235
|
+
// feature's same-named screen and keep a reference to a hidden one.
|
|
236
|
+
function isScreenRefKept(ref, indices, keptScreenQns) {
|
|
237
|
+
if (isValidQn(ref))
|
|
238
|
+
return keptScreenQns.has(ref);
|
|
239
|
+
return isTargetKept(indices.screensByShortId.get(ref), keptScreenQns);
|
|
240
240
|
}
|
|
241
241
|
function isNavigateTargetKept(action, indices, keptScreenQns) {
|
|
242
|
-
|
|
242
|
+
if (action.entity === undefined && action.screen !== undefined) {
|
|
243
|
+
return isScreenRefKept(action.screen, indices, keptScreenQns);
|
|
244
|
+
}
|
|
245
|
+
const target = action.entity === undefined ? undefined : indices.detailForScreens.get(action.entity);
|
|
243
246
|
if (target === undefined)
|
|
244
247
|
return false;
|
|
245
248
|
return keptScreenQns.has(qualifyEntityName(target.featureName, "screen", target.screen.id));
|
|
@@ -404,9 +407,7 @@ function projectDashboardPanels(panels, feature, keptScreenQns) {
|
|
|
404
407
|
function projectListScreenId(listScreenId, indices, keptScreenQns) {
|
|
405
408
|
if (listScreenId === undefined)
|
|
406
409
|
return undefined;
|
|
407
|
-
return
|
|
408
|
-
? listScreenId
|
|
409
|
-
: undefined;
|
|
410
|
+
return isScreenRefKept(listScreenId, indices, keptScreenQns) ? listScreenId : undefined;
|
|
410
411
|
}
|
|
411
412
|
// guard:dup-ok sibling of projectListScreenId for a different reference kind with its own keep check
|
|
412
413
|
function projectRedirect(featureName, redirect, keptScreenQns) {
|
|
@@ -2,6 +2,7 @@ import type { FieldDefinition, SelectFieldDef } from "./types/fields.ts";
|
|
|
2
2
|
import type { ActionFormScreenDefinition, ConfigEditScreenDefinition, EditExtensionSection, EditFieldSpec, EditFieldsSection, EditSectionSpec, EditWriteFormSection, EntityEditScreenDefinition, FieldCondition, FormatSpec, ListColumnSpec, ProjectionDetailScreenDefinition, ScreenDefinition, SecretMintScreenDefinition } from "./types/screen.ts";
|
|
3
3
|
export declare const ACTION_FORM_PSEUDO_ENTITY = "__action-form__";
|
|
4
4
|
export declare function explicitListScreenId(screen: ScreenDefinition): string | undefined;
|
|
5
|
+
export declare function screenShortId(ref: string): string;
|
|
5
6
|
export declare function resolveNavParentScreen(screens: readonly ScreenDefinition[], detail: ScreenDefinition, getId: (screen: ScreenDefinition) => string): ScreenDefinition | undefined;
|
|
6
7
|
export type EditLayoutScreen = ProjectionDetailScreenDefinition | EntityEditScreenDefinition | ActionFormScreenDefinition | ConfigEditScreenDefinition | SecretMintScreenDefinition;
|
|
7
8
|
export declare function isEditLayoutScreen(screen: ScreenDefinition): screen is EditLayoutScreen;
|
|
@@ -19,7 +19,7 @@ export function explicitListScreenId(screen) {
|
|
|
19
19
|
}
|
|
20
20
|
// Screen refs may be short ids or `<feature>:screen:<id>` QNs (boot-validator
|
|
21
21
|
// accepts both for navigate targets and listScreenId); compare on the short id.
|
|
22
|
-
function screenShortId(ref) {
|
|
22
|
+
export function screenShortId(ref) {
|
|
23
23
|
return ref.slice(ref.lastIndexOf(":") + 1);
|
|
24
24
|
}
|
|
25
25
|
// Shared by the renderer breadcrumb and the boot-validator so both resolve
|
|
@@ -3,6 +3,7 @@ type ServiceKey = Exclude<keyof ContextServices, "extensions">;
|
|
|
3
3
|
export declare const APP_CONTEXT_KEY_ROLES: {
|
|
4
4
|
readonly redis: "service";
|
|
5
5
|
readonly cacheSync: "service";
|
|
6
|
+
readonly userLiveSignals: "service";
|
|
6
7
|
readonly jobRunner: "service";
|
|
7
8
|
readonly searchAdapter: "service";
|
|
8
9
|
readonly entityCache: "service";
|
|
@@ -3,6 +3,7 @@ import { requestContext } from "../api/request-context.js";
|
|
|
3
3
|
import { createFallbackLogger } from "../logging/utils.js";
|
|
4
4
|
import { createEscapeHatchReporter } from "../observability/escape-hatch-report.js";
|
|
5
5
|
import { resolveDbSource, } from "./dispatch-shared.js";
|
|
6
|
+
import { createUserLiveSignals } from "./user-live-signals.js";
|
|
6
7
|
export function resolveHandlerContextScope(input) {
|
|
7
8
|
const { ctx, type, user, origin, tx, transactionScope } = input;
|
|
8
9
|
const { registry, appContext: context } = ctx;
|
|
@@ -69,8 +70,11 @@ export function buildPreSave(scope, finalContext) {
|
|
|
69
70
|
}
|
|
70
71
|
// Services the dispatcher resolves itself instead of copying from the boot context.
|
|
71
72
|
export function buildRuntimeServices(scope) {
|
|
72
|
-
const { effectiveFeatures, jobRunner, cacheSync } = scope.ctx;
|
|
73
|
+
const { effectiveFeatures, jobRunner, cacheSync, sseBroker } = scope.ctx;
|
|
73
74
|
return {
|
|
75
|
+
...(sseBroker && {
|
|
76
|
+
userLiveSignals: createUserLiveSignals(sseBroker, scope.user.tenantId, scope.context.log ?? createFallbackLogger("dispatcher")),
|
|
77
|
+
}),
|
|
74
78
|
// One resolver for the lifecycle pipeline, MSP runner and ctx.hasFeature.
|
|
75
79
|
...(effectiveFeatures && { effectiveFeatures }),
|
|
76
80
|
...(cacheSync && { cacheSync }),
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UserLiveSignals } from "@cosmicdrift/kumiko-types/handlers";
|
|
2
|
+
import type { TenantId } from "@cosmicdrift/kumiko-types/identifiers";
|
|
3
|
+
import type { SseBroker } from "../api/sse-broker.ts";
|
|
4
|
+
import type { Logger } from "../logging/types.ts";
|
|
5
|
+
export declare function createUserLiveSignals(sseBroker: SseBroker, tenantId: TenantId, log: Pick<Logger, "warn">): UserLiveSignals;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { tenantChannel } from "../engine/constants.js";
|
|
2
|
+
// The tenant is fixed to the caller's own: a handler can address users, never another tenant's channel.
|
|
3
|
+
// Frames carry `data.userId` and no aggregateType, so sse-route delivers each only to its addressee.
|
|
4
|
+
export function createUserLiveSignals(sseBroker, tenantId, log) {
|
|
5
|
+
return {
|
|
6
|
+
async push(userIds, signal) {
|
|
7
|
+
await Promise.all([...new Set(userIds)].map(async (userId) => {
|
|
8
|
+
try {
|
|
9
|
+
await sseBroker.pushToChannel(tenantChannel(tenantId), {
|
|
10
|
+
type: signal.type,
|
|
11
|
+
data: { userId, entity: signal.entity, id: signal.id },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
log.warn(`live signal "${signal.type}" could not be pushed`, { err });
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.411.0",
|
|
4
4
|
"description": "Framework core — engine, pipeline, API, DB, and every other bit that makes Kumiko go.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -203,7 +203,7 @@
|
|
|
203
203
|
"./package.json": "./package.json"
|
|
204
204
|
},
|
|
205
205
|
"dependencies": {
|
|
206
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
206
|
+
"@cosmicdrift/kumiko-types": "0.411.0",
|
|
207
207
|
"bullmq": "^5.81.5",
|
|
208
208
|
"hono": "^4.13.14",
|
|
209
209
|
"i18next": "^26.5.12",
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
}
|
|
226
226
|
},
|
|
227
227
|
"devDependencies": {
|
|
228
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
228
|
+
"@cosmicdrift/kumiko-testing": "0.411.0",
|
|
229
229
|
"bun-types": "^1.4.4",
|
|
230
230
|
"fflate": "^0.8.3",
|
|
231
231
|
"meilisearch": "^0.62.0",
|
package/src/changes.json
CHANGED
|
@@ -1,4 +1,58 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.411.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "Qualified listScreenId and navigate targets survive role projection",
|
|
6
|
+
"detail": "`projectAppSchemaForRoles` looked up `listScreenId` and navigate `screen` by the raw value, so a `<feature>:screen:<id>` reference never matched and the breadcrumb parent was dropped. A qualified reference is now checked against the exact screen it names (never through the short-id index, which could land on another feature's same-named screen and keep a reference to a hidden screen); bare ids still resolve through the short-id index. The original value stays in the projected schema. Applies to all apps."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.411.0",
|
|
10
|
+
"type": "improvement",
|
|
11
|
+
"title": "List table option compactHeader",
|
|
12
|
+
"detail": "`table: { compactHeader: true }` on an entityList, projectionList or relatedList renders the header row in 12px semibold. `ResultTable` takes `compactHeader` too. Wired through the boot validator, `useListTable` and `DataTable` (`compactHeader` prop). Default unchanged."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"version": "0.411.0",
|
|
16
|
+
"type": "improvement",
|
|
17
|
+
"title": "Edit layout hideRequiredMarker",
|
|
18
|
+
"detail": "`layout: { hideRequiredMarker: true }` on an entityEdit, actionForm or projectionDetail hides the asterisk after required field labels. Default shown."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"version": "0.411.0",
|
|
22
|
+
"type": "improvement",
|
|
23
|
+
"title": "projectionDetail header actions per tab",
|
|
24
|
+
"detail": "A projectionDetail header action takes `showOnTabs: [\"<tab id>\"]` and is shown only while one of those tabs is active (needs `layout.mode: \"tabs\"`). The boot validator rejects empty lists, unknown tab ids and a missing tabs mode."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"version": "0.411.0",
|
|
28
|
+
"type": "improvement",
|
|
29
|
+
"title": "Wizard step rail texts and up-next card",
|
|
30
|
+
"detail": "Wizard steps in the rail show the section `subtitle` (opt-in, no fallback to `description`); a completed step shows the value of the new optional `summaryField`. `wizard.aside.finishDescription` adds a finish card with description on the last step. The up-next card shows the next step's `upNextHint`, else `subtitle`, only. Extension sections accept `subtitle`, `description` and `summaryField` too; on an `actionForm`, `summaryField` and `wizard.submitDisabledWhen` may name a field of its `fields` (such a summary shows the raw value unformatted, meant for text and number fields), and `wizard.saveAndCloseOnCreate` also shows \"Save and close\" on the last step next to the submit."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"version": "0.411.0",
|
|
34
|
+
"type": "improvement",
|
|
35
|
+
"title": "Wizard footer options",
|
|
36
|
+
"detail": "`layout.wizard.saveAndCloseOnCreate` shows \"Save and close\" in create mode. `layout.wizard.submitDisabledWhen` is a field condition that disables the submit buttons and blocks the submit. After a create, extension sections are saved with the id of the new entity. The boot validator rejects these options outside wizard mode and unknown fields. `submitDisabledWhen` is UI-only; enforce the rule in a validation hook."
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"version": "0.411.0",
|
|
40
|
+
"type": "improvement",
|
|
41
|
+
"title": "Wizard step upNextHint",
|
|
42
|
+
"detail": "Fields and extension sections in a wizard accept `upNextHint`; the up-next card shows it under the next step's title, falling back to `subtitle`."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"version": "0.411.0",
|
|
46
|
+
"type": "fix",
|
|
47
|
+
"title": "Advisory-lock waiters no longer time out",
|
|
48
|
+
"detail": "`withSessionAdvisoryLock` waits for the lock without the pool's statement_timeout (it is reset before the connection returns to the pool). A replica waiting for a peer, for example during boot seeds, no longer crashes with 57014."
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"version": "0.410.0",
|
|
52
|
+
"type": "improvement",
|
|
53
|
+
"title": "anySignedIn: public handlers admit every signed-in caller",
|
|
54
|
+
"detail": "A role rule that includes `anonymous` may add `anySignedIn: true` (`{ roles: [\"anonymous\"], anySignedIn: true }`). A signed-in caller then passes whatever roles the session carries, because the browser sends the session cookie to a public endpoint and an app-specific role (for example \"Hausmeister\") used to turn away a visitor who is welcome anonymously. `hasAccess` and `isUiAccessGranted` honour the flag, nav entries with such a rule stay visible to every viewer, and feature-ast reads and writes it. The boot validator rejects `anySignedIn` on a rule without `anonymous` (use `openToAll` for \"every signed-in user\") and any value other than `true` (rule `handler/any-signed-in-invalid`). The public handlers of bundled features now set it: waitlist submit, contact challenge and submit, user-data-rights deletion by email and token and download by token, managed-pages published pages and branding, file-derivatives public variants, compliance-profiles sub-processors, tenant-inactivity keep-account, auth-email-password login options and self-registration status, template-resolver by tenant and slug, seo config and subscription-paddle checkout config. Anonymous-only auth flows (signup, reset password, verify email, invite info, account unlock, MFA preauth) are unchanged."
|
|
55
|
+
},
|
|
2
56
|
{
|
|
3
57
|
"version": "0.409.0",
|
|
4
58
|
"type": "improvement",
|