@xemahq/ui-kernel 0.6.1 → 0.8.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/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/biome-host/frontend-biome.d.ts +6 -3
- package/dist/lib/biome-host/frontend-biome.d.ts.map +1 -1
- package/dist/lib/biome-host/frontend-biome.js +9 -0
- package/dist/lib/biome-host/frontend-biome.js.map +1 -1
- package/dist/offline/id.d.ts +2 -0
- package/dist/offline/id.d.ts.map +1 -0
- package/dist/offline/id.js +15 -0
- package/dist/offline/id.js.map +1 -0
- package/dist/offline/index.d.ts +9 -0
- package/dist/offline/index.d.ts.map +1 -0
- package/dist/offline/index.js +26 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/offline/mutation.d.ts +15 -0
- package/dist/offline/mutation.d.ts.map +1 -0
- package/dist/offline/mutation.js +37 -0
- package/dist/offline/mutation.js.map +1 -0
- package/dist/offline/offline-status-badge.d.ts +7 -0
- package/dist/offline/offline-status-badge.d.ts.map +1 -0
- package/dist/offline/offline-status-badge.js +21 -0
- package/dist/offline/offline-status-badge.js.map +1 -0
- package/dist/offline/online-controller.d.ts +18 -0
- package/dist/offline/online-controller.d.ts.map +1 -0
- package/dist/offline/online-controller.js +79 -0
- package/dist/offline/online-controller.js.map +1 -0
- package/dist/offline/outbox.d.ts +57 -0
- package/dist/offline/outbox.d.ts.map +1 -0
- package/dist/offline/outbox.js +257 -0
- package/dist/offline/outbox.js.map +1 -0
- package/dist/offline/react.d.ts +13 -0
- package/dist/offline/react.d.ts.map +1 -0
- package/dist/offline/react.js +42 -0
- package/dist/offline/react.js.map +1 -0
- package/dist/offline/storage.d.ts +22 -0
- package/dist/offline/storage.d.ts.map +1 -0
- package/dist/offline/storage.js +90 -0
- package/dist/offline/storage.js.map +1 -0
- package/dist/offline/types.d.ts +38 -0
- package/dist/offline/types.d.ts.map +1 -0
- package/dist/offline/types.js +11 -0
- package/dist/offline/types.js.map +1 -0
- package/dist/ui/branding/app-branding-provider.d.ts +1 -1
- package/dist/ui/branding/app-branding-provider.d.ts.map +1 -1
- package/dist/ui/capture/document-preview.d.ts +12 -0
- package/dist/ui/capture/document-preview.d.ts.map +1 -0
- package/dist/ui/capture/document-preview.js +31 -0
- package/dist/ui/capture/document-preview.js.map +1 -0
- package/dist/ui/capture/field-spec-to-zod.d.ts +5 -0
- package/dist/ui/capture/field-spec-to-zod.d.ts.map +1 -0
- package/dist/ui/capture/field-spec-to-zod.js +79 -0
- package/dist/ui/capture/field-spec-to-zod.js.map +1 -0
- package/dist/ui/capture/field-spec.d.ts +54 -0
- package/dist/ui/capture/field-spec.d.ts.map +1 -0
- package/dist/ui/capture/field-spec.js +62 -0
- package/dist/ui/capture/field-spec.js.map +1 -0
- package/dist/ui/capture/index.d.ts +11 -0
- package/dist/ui/capture/index.d.ts.map +1 -0
- package/dist/ui/capture/index.js +31 -0
- package/dist/ui/capture/index.js.map +1 -0
- package/dist/ui/capture/schema-field-input.d.ts +20 -0
- package/dist/ui/capture/schema-field-input.d.ts.map +1 -0
- package/dist/ui/capture/schema-field-input.js +127 -0
- package/dist/ui/capture/schema-field-input.js.map +1 -0
- package/dist/ui/capture/schema-form.d.ts +18 -0
- package/dist/ui/capture/schema-form.d.ts.map +1 -0
- package/dist/ui/capture/schema-form.js +26 -0
- package/dist/ui/capture/schema-form.js.map +1 -0
- package/dist/ui/capture/use-prefill.d.ts +18 -0
- package/dist/ui/capture/use-prefill.d.ts.map +1 -0
- package/dist/ui/capture/use-prefill.js +94 -0
- package/dist/ui/capture/use-prefill.js.map +1 -0
- package/dist/ui/capture/use-schema-validation.d.ts +11 -0
- package/dist/ui/capture/use-schema-validation.d.ts.map +1 -0
- package/dist/ui/capture/use-schema-validation.js +69 -0
- package/dist/ui/capture/use-schema-validation.js.map +1 -0
- package/dist/ui/capture/use-wizard.d.ts +28 -0
- package/dist/ui/capture/use-wizard.d.ts.map +1 -0
- package/dist/ui/capture/use-wizard.js +63 -0
- package/dist/ui/capture/use-wizard.js.map +1 -0
- package/dist/ui/capture/value-format.d.ts +4 -0
- package/dist/ui/capture/value-format.d.ts.map +1 -0
- package/dist/ui/capture/value-format.js +23 -0
- package/dist/ui/capture/value-format.js.map +1 -0
- package/dist/ui/capture/wizard.d.ts +19 -0
- package/dist/ui/capture/wizard.d.ts.map +1 -0
- package/dist/ui/capture/wizard.js +34 -0
- package/dist/ui/capture/wizard.js.map +1 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/primitives/badge.d.ts +1 -1
- package/dist/ui/primitives/button.d.ts +1 -1
- package/dist/ui/primitives/sheet.d.ts +1 -1
- package/package.json +4 -3
- package/src/index.ts +9 -0
- package/src/lib/biome-host/define-web-biome.spec.ts +221 -0
- package/src/lib/biome-host/frontend-biome.ts +32 -5
- package/src/offline/id.ts +16 -0
- package/src/offline/index.ts +52 -0
- package/src/offline/mutation.ts +75 -0
- package/src/offline/offline-status-badge.tsx +51 -0
- package/src/offline/online-controller.ts +105 -0
- package/src/offline/outbox.test.ts +156 -0
- package/src/offline/outbox.ts +344 -0
- package/src/offline/react.tsx +71 -0
- package/src/offline/storage.ts +107 -0
- package/src/offline/types.ts +77 -0
- package/src/ui/branding/app-branding-provider.tsx +1 -1
- package/src/ui/capture/document-preview.tsx +101 -0
- package/src/ui/capture/field-spec-to-zod.test.ts +81 -0
- package/src/ui/capture/field-spec-to-zod.ts +104 -0
- package/src/ui/capture/field-spec.test.ts +49 -0
- package/src/ui/capture/field-spec.ts +181 -0
- package/src/ui/capture/index.ts +43 -0
- package/src/ui/capture/schema-field-input.tsx +314 -0
- package/src/ui/capture/schema-form.tsx +108 -0
- package/src/ui/capture/use-prefill.ts +150 -0
- package/src/ui/capture/use-schema-validation.ts +113 -0
- package/src/ui/capture/use-wizard.ts +134 -0
- package/src/ui/capture/value-format.ts +22 -0
- package/src/ui/capture/wizard.tsx +100 -0
- package/src/ui/index.ts +3 -0
- package/src/lib/biome-host/define-web-biome.test.js +0 -93
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// useWizard — headless multi-step engine
|
|
3
|
+
//
|
|
4
|
+
// The state machine the hand-rolled wizards lack: step index, next/prev, goTo,
|
|
5
|
+
// isFirst/isLast, per-step advance gating, and a `status(i)` that maps 1:1 onto
|
|
6
|
+
// the presentational `FormStepper`'s `FormStepStatus`. Controlled (pass `step`)
|
|
7
|
+
// and uncontrolled (pass `initialStep`) modes. No timers, no side effects.
|
|
8
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
9
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
import { FormStepStatus } from '../primitives/form-stepper';
|
|
12
|
+
|
|
13
|
+
export interface WizardStepDef {
|
|
14
|
+
readonly key: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly hint?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface UseWizardOptions {
|
|
20
|
+
readonly steps: readonly WizardStepDef[];
|
|
21
|
+
/**
|
|
22
|
+
* Per-step forward gate. `canAdvance(i)` must return true before the wizard
|
|
23
|
+
* will move PAST step `i`. Backward navigation is always allowed. Defaults to
|
|
24
|
+
* always-advanceable.
|
|
25
|
+
*/
|
|
26
|
+
readonly canAdvance?: (index: number) => boolean;
|
|
27
|
+
/** Uncontrolled initial index (default 0). Ignored when `step` is provided. */
|
|
28
|
+
readonly initialStep?: number;
|
|
29
|
+
/** Controlled active index. When set, the hook is controlled. */
|
|
30
|
+
readonly step?: number;
|
|
31
|
+
/** Fired on every requested index change (both modes). */
|
|
32
|
+
readonly onStepChange?: (index: number) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface WizardApi {
|
|
36
|
+
readonly steps: readonly WizardStepDef[];
|
|
37
|
+
readonly activeIndex: number;
|
|
38
|
+
readonly activeStep: WizardStepDef;
|
|
39
|
+
readonly isFirst: boolean;
|
|
40
|
+
readonly isLast: boolean;
|
|
41
|
+
/** Whether the CURRENT step's forward gate is satisfied. */
|
|
42
|
+
readonly canAdvance: boolean;
|
|
43
|
+
/** 0..1 progress across the steps. */
|
|
44
|
+
readonly progress: number;
|
|
45
|
+
readonly next: () => void;
|
|
46
|
+
readonly prev: () => void;
|
|
47
|
+
/** Jump to `index`. Backward is free; forward requires every intervening gate. */
|
|
48
|
+
readonly goTo: (index: number) => void;
|
|
49
|
+
/** {@link FormStepStatus} for step `index` — feeds `<FormStepper>`. */
|
|
50
|
+
readonly status: (index: number) => FormStepStatus;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @example
|
|
55
|
+
* const wizard = useWizard({
|
|
56
|
+
* steps: [{ key: 'details', label: 'Details' }, { key: 'review', label: 'Review' }],
|
|
57
|
+
* canAdvance: (i) => (i === 0 ? isValid : true),
|
|
58
|
+
* });
|
|
59
|
+
* <Wizard api={wizard} onFinish={submit}>
|
|
60
|
+
* <WizardStep stepKey="details"><SchemaForm … /></WizardStep>
|
|
61
|
+
* <WizardStep stepKey="review"><DocumentPreview … /></WizardStep>
|
|
62
|
+
* </Wizard>
|
|
63
|
+
*/
|
|
64
|
+
export function useWizard(options: UseWizardOptions): WizardApi {
|
|
65
|
+
const { steps, canAdvance, initialStep = 0, step, onStepChange } = options;
|
|
66
|
+
const count = steps.length;
|
|
67
|
+
const clamp = useCallback((i: number) => Math.max(0, Math.min(count - 1, i)), [count]);
|
|
68
|
+
|
|
69
|
+
const isControlled = step !== undefined;
|
|
70
|
+
const [internal, setInternal] = useState(() => clamp(initialStep));
|
|
71
|
+
const activeIndex = clamp(isControlled ? (step as number) : internal);
|
|
72
|
+
|
|
73
|
+
const gate = useCallback((i: number) => (canAdvance ? canAdvance(i) : true), [canAdvance]);
|
|
74
|
+
|
|
75
|
+
const request = useCallback(
|
|
76
|
+
(target: number) => {
|
|
77
|
+
const next = clamp(target);
|
|
78
|
+
if (next === activeIndex) return;
|
|
79
|
+
onStepChange?.(next);
|
|
80
|
+
if (!isControlled) setInternal(next);
|
|
81
|
+
},
|
|
82
|
+
[activeIndex, clamp, isControlled, onStepChange],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const goTo = useCallback(
|
|
86
|
+
(index: number) => {
|
|
87
|
+
const target = clamp(index);
|
|
88
|
+
if (target <= activeIndex) {
|
|
89
|
+
request(target); // backward is always allowed
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Forward: every step from active..target-1 must pass its gate.
|
|
93
|
+
for (let i = activeIndex; i < target; i += 1) {
|
|
94
|
+
if (!gate(i)) return;
|
|
95
|
+
}
|
|
96
|
+
request(target);
|
|
97
|
+
},
|
|
98
|
+
[activeIndex, clamp, gate, request],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const next = useCallback(() => {
|
|
102
|
+
if (activeIndex >= count - 1) return;
|
|
103
|
+
if (!gate(activeIndex)) return;
|
|
104
|
+
request(activeIndex + 1);
|
|
105
|
+
}, [activeIndex, count, gate, request]);
|
|
106
|
+
|
|
107
|
+
const prev = useCallback(() => request(activeIndex - 1), [activeIndex, request]);
|
|
108
|
+
|
|
109
|
+
const status = useCallback(
|
|
110
|
+
(index: number): FormStepStatus => {
|
|
111
|
+
if (index < activeIndex) return FormStepStatus.DONE;
|
|
112
|
+
if (index === activeIndex) return FormStepStatus.ACTIVE;
|
|
113
|
+
return FormStepStatus.PENDING;
|
|
114
|
+
},
|
|
115
|
+
[activeIndex],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return useMemo<WizardApi>(
|
|
119
|
+
() => ({
|
|
120
|
+
steps,
|
|
121
|
+
activeIndex,
|
|
122
|
+
activeStep: steps[activeIndex],
|
|
123
|
+
isFirst: activeIndex === 0,
|
|
124
|
+
isLast: activeIndex === count - 1,
|
|
125
|
+
canAdvance: gate(activeIndex),
|
|
126
|
+
progress: count <= 1 ? 1 : activeIndex / (count - 1),
|
|
127
|
+
next,
|
|
128
|
+
prev,
|
|
129
|
+
goTo,
|
|
130
|
+
status,
|
|
131
|
+
}),
|
|
132
|
+
[steps, activeIndex, count, gate, next, prev, goTo, status],
|
|
133
|
+
);
|
|
134
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Shared value coercion/formatting for the capture kit — used by the input
|
|
2
|
+
// boundary (SchemaForm) and the read-only view (DocumentPreview) so the two
|
|
3
|
+
// never disagree on how a stored value maps to its display/edit string.
|
|
4
|
+
import { CaptureFieldType, type CaptureFieldSpec } from './field-spec';
|
|
5
|
+
|
|
6
|
+
/** Coerce any stored value to a display/edit string (empty for absent). */
|
|
7
|
+
export function asString(value: unknown): string {
|
|
8
|
+
if (typeof value === 'string') return value;
|
|
9
|
+
if (value === undefined || value === null) return '';
|
|
10
|
+
return String(value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Human-readable rendering of a scalar field value for the read-only preview. */
|
|
14
|
+
export function formatScalar(field: CaptureFieldSpec, value: unknown, emptyText: string): string {
|
|
15
|
+
if (value === undefined || value === null || value === '') return emptyText;
|
|
16
|
+
switch (field.type) {
|
|
17
|
+
case CaptureFieldType.Boolean:
|
|
18
|
+
return value === true ? 'Yes' : 'No';
|
|
19
|
+
default:
|
|
20
|
+
return asString(value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// <Wizard> / <WizardStep> — thin presentational shell over useWizard
|
|
3
|
+
//
|
|
4
|
+
// Composes the existing `<FormStepper>` for the numbered rail (with the ACTIVE
|
|
5
|
+
// step's body rendered inline, guided-style — pending steps stay empty) and
|
|
6
|
+
// renders a Back / Next / Finish nav bar. All state lives in the `useWizard`
|
|
7
|
+
// engine you pass via `api`; this component is presentation only.
|
|
8
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
9
|
+
import { Children, isValidElement, type ReactElement, type ReactNode } from 'react';
|
|
10
|
+
|
|
11
|
+
import { cn } from '../cn';
|
|
12
|
+
import { Button } from '../primitives/button';
|
|
13
|
+
import { FormStepper, type FormStep } from '../primitives/form-stepper';
|
|
14
|
+
|
|
15
|
+
import type { WizardApi } from './use-wizard';
|
|
16
|
+
|
|
17
|
+
export interface WizardStepProps {
|
|
18
|
+
/** Must match a `useWizard` step `key`. */
|
|
19
|
+
readonly stepKey: string;
|
|
20
|
+
readonly children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Declarative wrapper for one wizard step's body. Rendered by `<Wizard>` only
|
|
25
|
+
* when its `stepKey` is the active step.
|
|
26
|
+
*/
|
|
27
|
+
export function WizardStep(_props: WizardStepProps): null {
|
|
28
|
+
// Rendering is orchestrated by <Wizard>; this component only carries props.
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface WizardProps {
|
|
33
|
+
readonly api: WizardApi;
|
|
34
|
+
readonly children: ReactNode;
|
|
35
|
+
/** Called when Finish is pressed on the last step (gate already satisfied). */
|
|
36
|
+
readonly onFinish?: () => void;
|
|
37
|
+
readonly nextLabel?: string;
|
|
38
|
+
readonly backLabel?: string;
|
|
39
|
+
readonly finishLabel?: string;
|
|
40
|
+
/** Hide the built-in nav bar (caller renders its own using `api`). */
|
|
41
|
+
readonly hideNav?: boolean;
|
|
42
|
+
readonly className?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function stepBodies(children: ReactNode): Map<string, ReactNode> {
|
|
46
|
+
const map = new Map<string, ReactNode>();
|
|
47
|
+
Children.forEach(children, (child) => {
|
|
48
|
+
if (isValidElement(child) && (child as ReactElement<WizardStepProps>).props?.stepKey) {
|
|
49
|
+
const p = (child as ReactElement<WizardStepProps>).props;
|
|
50
|
+
map.set(p.stepKey, p.children);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return map;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function Wizard({
|
|
57
|
+
api,
|
|
58
|
+
children,
|
|
59
|
+
onFinish,
|
|
60
|
+
nextLabel = 'Continue',
|
|
61
|
+
backLabel = 'Back',
|
|
62
|
+
finishLabel = 'Finish',
|
|
63
|
+
hideNav = false,
|
|
64
|
+
className,
|
|
65
|
+
}: WizardProps) {
|
|
66
|
+
const bodies = stepBodies(children);
|
|
67
|
+
|
|
68
|
+
const formSteps: FormStep[] = api.steps.map((step, index) => ({
|
|
69
|
+
key: step.key,
|
|
70
|
+
label: step.label,
|
|
71
|
+
hint: step.hint,
|
|
72
|
+
status: api.status(index),
|
|
73
|
+
// Render the active step's body inline; pending/done steps stay empty so
|
|
74
|
+
// the rail reads as a guided one-step-at-a-time flow.
|
|
75
|
+
children: index === api.activeIndex ? bodies.get(step.key) ?? null : null,
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div className={cn('space-y-5', className)}>
|
|
80
|
+
<FormStepper steps={formSteps} />
|
|
81
|
+
|
|
82
|
+
{!hideNav && (
|
|
83
|
+
<div className="flex items-center justify-between gap-2 border-t border-rule pt-4">
|
|
84
|
+
<Button variant="ghost" onClick={api.prev} disabled={api.isFirst}>
|
|
85
|
+
{backLabel}
|
|
86
|
+
</Button>
|
|
87
|
+
{api.isLast ? (
|
|
88
|
+
<Button onClick={onFinish} disabled={!api.canAdvance}>
|
|
89
|
+
{finishLabel}
|
|
90
|
+
</Button>
|
|
91
|
+
) : (
|
|
92
|
+
<Button onClick={api.next} disabled={!api.canAdvance}>
|
|
93
|
+
{nextLabel}
|
|
94
|
+
</Button>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
package/src/ui/index.ts
CHANGED
|
@@ -88,3 +88,6 @@ export { default as LoadingState, type LoadingStateVariant } from './chrome/Load
|
|
|
88
88
|
export { default as AsyncBoundary } from './chrome/AsyncBoundary';
|
|
89
89
|
|
|
90
90
|
export { PdfPreview, type PdfPreviewProps } from './pdf/pdf-preview';
|
|
91
|
+
|
|
92
|
+
// ── guided-capture UX kit (B5 — wizard, validation, prefill, schema form) ──
|
|
93
|
+
export * from './capture';
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// Test suite for defineWebBiome's define-time scope/access validation and the
|
|
2
|
-
// chrome default. Runs on Node's native test runner against the COMPILED dist
|
|
3
|
-
// (CommonJS), so the package needs no jest/vitest/ts-jest toolchain — the
|
|
4
|
-
// `test` script builds first, then runs this file with `node --test`.
|
|
5
|
-
//
|
|
6
|
-
// Covered:
|
|
7
|
-
// 1. A `public` page with access `'member'` (or omitted) throws at define time.
|
|
8
|
-
// 2. A `public` + access `'public'` page is accepted; its route carries no
|
|
9
|
-
// nav item and mounts with access `'public'`.
|
|
10
|
-
// 3. A non-public page declaring access `'public'` throws at define time.
|
|
11
|
-
// 4. `chrome` defaults to `'host'` when a page omits it; `'none'` passes through.
|
|
12
|
-
|
|
13
|
-
'use strict';
|
|
14
|
-
|
|
15
|
-
const test = require('node:test');
|
|
16
|
-
const assert = require('node:assert/strict');
|
|
17
|
-
|
|
18
|
-
const { defineWebBiome } = require('../../../dist/lib/biome-host/define-web-biome.js');
|
|
19
|
-
|
|
20
|
-
const load = () => Promise.resolve({ default: () => null });
|
|
21
|
-
const bridge = /** @type {any} */ ({});
|
|
22
|
-
|
|
23
|
-
test('rejects a public page whose access is not public (member default)', () => {
|
|
24
|
-
assert.throws(
|
|
25
|
-
() =>
|
|
26
|
-
defineWebBiome({
|
|
27
|
-
id: 'test-biome',
|
|
28
|
-
displayName: 'Test',
|
|
29
|
-
pages: [{ slug: 'ext/:id', label: 'Ext', scope: 'public', load }],
|
|
30
|
-
}),
|
|
31
|
-
/a 'public' scope page MUST declare access: 'public'/,
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('rejects a public page with an explicit non-public access tier', () => {
|
|
36
|
-
assert.throws(
|
|
37
|
-
() =>
|
|
38
|
-
defineWebBiome({
|
|
39
|
-
id: 'test-biome',
|
|
40
|
-
displayName: 'Test',
|
|
41
|
-
pages: [
|
|
42
|
-
{ slug: 'ext/:id', label: 'Ext', scope: 'public', access: 'org-admin', load },
|
|
43
|
-
],
|
|
44
|
-
}),
|
|
45
|
-
/a 'public' scope page MUST declare access: 'public'/,
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('rejects a non-public page that declares access public', () => {
|
|
50
|
-
assert.throws(
|
|
51
|
-
() =>
|
|
52
|
-
defineWebBiome({
|
|
53
|
-
id: 'test-biome',
|
|
54
|
-
displayName: 'Test',
|
|
55
|
-
pages: [{ slug: 'system/x', label: 'X', access: 'public', load }],
|
|
56
|
-
}),
|
|
57
|
-
/access: 'public' is only valid on a 'public' scope page/,
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('accepts a public + access:public page and emits no nav item', () => {
|
|
62
|
-
const factory = defineWebBiome({
|
|
63
|
-
id: 'test-biome',
|
|
64
|
-
displayName: 'Test',
|
|
65
|
-
pages: [
|
|
66
|
-
{ slug: 'ext/:id', label: 'Ext', scope: 'public', access: 'public', load },
|
|
67
|
-
],
|
|
68
|
-
});
|
|
69
|
-
const biome = factory(bridge);
|
|
70
|
-
assert.equal(biome.routes.length, 1);
|
|
71
|
-
const route = biome.routes[0];
|
|
72
|
-
assert.equal(route.path, 'ext/:id');
|
|
73
|
-
assert.equal(route.access, 'public');
|
|
74
|
-
assert.equal(route.projectScoped, false);
|
|
75
|
-
// Public routes never enter the authenticated app rail.
|
|
76
|
-
assert.equal(biome.navItems.length, 0);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('chrome defaults to host and none passes through', () => {
|
|
80
|
-
const factory = defineWebBiome({
|
|
81
|
-
id: 'test-biome',
|
|
82
|
-
displayName: 'Test',
|
|
83
|
-
pages: [
|
|
84
|
-
{ slug: 'system/a', label: 'A', load },
|
|
85
|
-
{ slug: 'system/b', label: 'B', chrome: 'none', load },
|
|
86
|
-
],
|
|
87
|
-
});
|
|
88
|
-
const biome = factory(bridge);
|
|
89
|
-
const a = biome.routes.find((r) => r.path === 'system/a');
|
|
90
|
-
const b = biome.routes.find((r) => r.path === 'system/b');
|
|
91
|
-
assert.equal(a.chrome, 'host');
|
|
92
|
-
assert.equal(b.chrome, 'none');
|
|
93
|
-
});
|