@keemakr/ui-sdk 1.5.0-dev-20261020144104 → 1.5.0-dev-20261020180147
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/README.md +66 -0
- package/dist/conform.d.ts +21 -0
- package/dist/conform.js +189 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/negotiate.d.ts +161 -0
- package/dist/negotiate.js +549 -0
- package/dist/published/index.d.ts +4 -0
- package/dist/published/index.js +18 -0
- package/dist/published/v1.1.0/schema.d.ts +439 -0
- package/dist/published/v1.1.0/schema.js +405 -0
- package/dist/published/v1.4.0/dataset-view.d.ts +160 -0
- package/dist/published/v1.4.0/dataset-view.js +702 -0
- package/dist/published/v1.4.0/dataset.d.ts +331 -0
- package/dist/published/v1.4.0/dataset.js +628 -0
- package/dist/published/v1.4.0/schema.d.ts +1132 -0
- package/dist/published/v1.4.0/schema.js +1410 -0
- package/dist/schema.d.ts +229 -3
- package/dist/schema.js +12 -3
- package/dist/testkit.d.ts +38 -0
- package/dist/testkit.js +68 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -120,3 +120,69 @@ calls the module runtime. Availability controls UI placement. Existing authentic
|
|
|
120
120
|
still control who may enter Dashboard or a Kee client.
|
|
121
121
|
|
|
122
122
|
See [`examples/campaigns`](./examples/campaigns) for one complete in-memory example.
|
|
123
|
+
|
|
124
|
+
## 6. Check that each app can draw your screen
|
|
125
|
+
|
|
126
|
+
An app parses a screen with the ui-sdk inside the sdk it was built with, frozen the day it shipped,
|
|
127
|
+
and it does not draw every node. Before core sends a screen, it reads the app from `X-Kee-Client`
|
|
128
|
+
and fits the screen to that app:
|
|
129
|
+
|
|
130
|
+
- each node the app cannot draw becomes a `text` or `markdown` line that says what the node said
|
|
131
|
+
(a pager, a select or an alert button stops being pressable);
|
|
132
|
+
- a value the app's parse refuses is folded to one it takes (an `info` or `accent` tone becomes
|
|
133
|
+
`default`; a date field's `min` and `max` are dropped), or the node becomes its text line;
|
|
134
|
+
- a control whose safety the app would lose (a form's `submit.confirm`, a `disabled` flag) becomes
|
|
135
|
+
"Open this in the web app to finish this step.", or is dropped from its list of controls, so
|
|
136
|
+
nothing acts without asking.
|
|
137
|
+
|
|
138
|
+
| App | Parses with | Draws |
|
|
139
|
+
| ------------------- | ------------ | ---------------------------------------------------------------------------------------- |
|
|
140
|
+
| web | ui-sdk 1.4.0 | Every node, breadcrumbs, disabled buttons, row sections, every field kind, form confirms |
|
|
141
|
+
| mobile 0.2.0 | ui-sdk 1.1.0 | The 15 nodes of 1.1.0, and none of those features |
|
|
142
|
+
| mobile 0.2.3 and on | ui-sdk 1.4.0 | The 15 nodes of 1.1.0, breadcrumbs, disabled buttons, every field kind, form confirms |
|
|
143
|
+
| desktop | (floor) | Renders no module screens |
|
|
144
|
+
| no `X-Kee-Client` | this package | Keemakr's own web app: every node, as sent |
|
|
145
|
+
|
|
146
|
+
`CLIENT_RELEASES` holds the full table. Test against it with the testkit:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { assertDrawableOn, renderForClients } from '@keemakr/ui-sdk/testkit';
|
|
150
|
+
|
|
151
|
+
// Fails, naming each node and client, when a target client would get a fallback.
|
|
152
|
+
assertDrawableOn(await screen.load(ctx), ['web']);
|
|
153
|
+
|
|
154
|
+
// Accept the fallback, and assert on the tree that client gets.
|
|
155
|
+
const [mobile] = assertDrawableOn(tree, ['mobile'], { allowFallback: true });
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
With no targets, the testkit checks every app that renders module screens (web and mobile). An app
|
|
159
|
+
named alone is checked at every release it has, so `['mobile']` covers mobile 0.2.0 as well as the
|
|
160
|
+
newest build.
|
|
161
|
+
|
|
162
|
+
## 7. Return the new screen from an action
|
|
163
|
+
|
|
164
|
+
An action runs on your runtime, and by default the client then asks core to load the screen
|
|
165
|
+
again: two more round trips before the person sees the change. An action can return the screen
|
|
166
|
+
itself, as `load` would return it now, for the same screen and the same params the action ran
|
|
167
|
+
with:
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
export default defineScreen({
|
|
171
|
+
load: async (ctx, params) => buildScreen(ctx, params),
|
|
172
|
+
actions: {
|
|
173
|
+
approve: async (ctx, input, params) => {
|
|
174
|
+
await approve(ctx, input);
|
|
175
|
+
return { toast: 'Approved', tree: await buildScreen(ctx, params) };
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- A client that knows `tree` draws it and does not call `load`. A client built before this field
|
|
182
|
+
ignores it and reloads, because `refresh` stays `true`. Send `tree` and leave `refresh` alone.
|
|
183
|
+
- `navigate` wins over `tree`. To show another page of the screen, return `navigate`, as before.
|
|
184
|
+
- Core sends the tree through the same checks as a loaded one: every node the client cannot draw
|
|
185
|
+
becomes a fallback (section 6), and the cards for `pending_request` slots come beside it in
|
|
186
|
+
`pendingRequests`. Test the tree with `assertDrawableOn(result.tree, ['web'])`.
|
|
187
|
+
- A tree that does not validate is dropped, and the client reloads: the action has already run, so core does not fail it for a tree that only saves a reload.
|
|
188
|
+
- When core answers a retried action from its log, it sends no tree, and the client reloads.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { Fallback } from './negotiate.js';
|
|
3
|
+
type Json = Record<string, unknown>;
|
|
4
|
+
export interface ConformOptions {
|
|
5
|
+
/** The node's own fallback (negotiate.ts `fallbackNode`). */
|
|
6
|
+
fallback: (node: unknown) => Json;
|
|
7
|
+
/** The line that replaces a control whose safety field this app would lose. */
|
|
8
|
+
safetyText: string;
|
|
9
|
+
/** The line that replaces a node whose own fallback this app still refuses. */
|
|
10
|
+
genericText: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Conformed {
|
|
13
|
+
tree: Json;
|
|
14
|
+
fallbacks: Fallback[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The tree as `parser` takes it, with every change listed. The input is not touched. Each change
|
|
18
|
+
* keeps the tree valid against this package's own schema.
|
|
19
|
+
*/
|
|
20
|
+
export declare function conformTree(tree: unknown, parser: z.ZodType, options: ConformOptions): Conformed;
|
|
21
|
+
export {};
|
package/dist/conform.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// Fit a negotiated tree to the schema an app really parses with (published/index.ts).
|
|
2
|
+
//
|
|
3
|
+
// Negotiation (negotiate.ts) swaps the node TYPES an app cannot draw. Two kinds of drift are left,
|
|
4
|
+
// and this file closes both against the app's own published schema:
|
|
5
|
+
//
|
|
6
|
+
// 1. A value or shape the app's parse REFUSES fails the whole screen. Known ones are folded to the
|
|
7
|
+
// nearest value the parse takes; anything else replaces the smallest node that holds it:
|
|
8
|
+
// - `tone: 'info' | 'accent'` (badge cells, tags, board columns, calendar entries, progress
|
|
9
|
+
// bars; after 1.4.0) -> 'default', or the first tone that parse lists
|
|
10
|
+
// - a string `min`/`max` on a date or datetime field (after 1.4.0) -> dropped
|
|
11
|
+
// - anything else the parse refuses (a longer label, a larger list, a value no fold knows)
|
|
12
|
+
// -> the node's own text fallback
|
|
13
|
+
// 2. A SAFETY field the app's parse STRIPS while it keeps the control (a `confirm`, or
|
|
14
|
+
// `disabled: true`) would leave a control that acts without asking, or acts when it must not.
|
|
15
|
+
// Found by comparing the tree with what the parse returns, so every such field is caught, not
|
|
16
|
+
// only the ones listed here. Known today: a form's `submit.confirm` (ui-sdk 1.1.0 drops it).
|
|
17
|
+
// A control in a list of controls (header `actions`, row `actions`, bulk `actions`, form
|
|
18
|
+
// `secondary`, `headerControls`) is dropped; any other node becomes one calm line.
|
|
19
|
+
//
|
|
20
|
+
// Pure, and bounded: each step changes the tree, and after MAX_STEPS the screen becomes one line.
|
|
21
|
+
const MAX_STEPS = 200;
|
|
22
|
+
/** Lists of controls a client can lose one of without losing the node that holds them. */
|
|
23
|
+
const CONTROL_LISTS = new Set(['actions', 'secondary', 'headerControls']);
|
|
24
|
+
/** Keys of a tree's root that are not optional: the tree cannot do without them. */
|
|
25
|
+
const ROOT_REQUIRED = new Set(['version', 'title', 'children']);
|
|
26
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
27
|
+
const pathText = (path) => path
|
|
28
|
+
.map((part, index) => typeof part === 'number' ? `[${part}]` : index === 0 ? part : `.${part}`)
|
|
29
|
+
.join('');
|
|
30
|
+
function at(root, path) {
|
|
31
|
+
let here = root;
|
|
32
|
+
for (const part of path) {
|
|
33
|
+
if (here === null || typeof here !== 'object')
|
|
34
|
+
return undefined;
|
|
35
|
+
here = here[part];
|
|
36
|
+
}
|
|
37
|
+
return here;
|
|
38
|
+
}
|
|
39
|
+
/** The deepest `children[i]` on the path: the node that holds whatever the path points at. */
|
|
40
|
+
function nodeAt(path) {
|
|
41
|
+
for (let i = path.length - 1; i >= 1; i--) {
|
|
42
|
+
if (path[i - 1] === 'children' && typeof path[i] === 'number')
|
|
43
|
+
return path.slice(0, i + 1);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
/** The deepest element of a list of controls on the path, if it is nearer than any node. */
|
|
48
|
+
function controlAt(path) {
|
|
49
|
+
const node = nodeAt(path);
|
|
50
|
+
for (let i = path.length - 1; i >= 1; i--) {
|
|
51
|
+
if (node && i < node.length)
|
|
52
|
+
break;
|
|
53
|
+
const list = path[i - 1];
|
|
54
|
+
if (typeof list === 'string' && CONTROL_LISTS.has(list) && typeof path[i] === 'number') {
|
|
55
|
+
return path.slice(0, i + 1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/** Remove one control from its list; an emptied list goes, and so does a bulk bar left empty. */
|
|
61
|
+
function dropControl(tree, path) {
|
|
62
|
+
const listPath = path.slice(0, -1);
|
|
63
|
+
const list = at(tree, listPath);
|
|
64
|
+
list.splice(path[path.length - 1], 1);
|
|
65
|
+
if (list.length > 0)
|
|
66
|
+
return;
|
|
67
|
+
const holderPath = listPath.slice(0, -1);
|
|
68
|
+
const holder = at(tree, holderPath);
|
|
69
|
+
delete holder[listPath[listPath.length - 1]];
|
|
70
|
+
if (holderPath[holderPath.length - 1] === 'bulk') {
|
|
71
|
+
const table = at(tree, holderPath.slice(0, -1));
|
|
72
|
+
delete table.bulk;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function setAt(tree, path, value) {
|
|
76
|
+
const holder = at(tree, path.slice(0, -1));
|
|
77
|
+
holder[path[path.length - 1]] = value;
|
|
78
|
+
}
|
|
79
|
+
/** The first object whose `confirm` or `disabled: true` the parse dropped while keeping it. */
|
|
80
|
+
function strippedSafety(sent, kept, path = []) {
|
|
81
|
+
if (Array.isArray(sent)) {
|
|
82
|
+
if (!Array.isArray(kept))
|
|
83
|
+
return null;
|
|
84
|
+
for (let i = 0; i < sent.length; i++) {
|
|
85
|
+
const found = strippedSafety(sent[i], kept[i], [...path, i]);
|
|
86
|
+
if (found)
|
|
87
|
+
return found;
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
if (!isObject(sent) || !isObject(kept))
|
|
92
|
+
return null;
|
|
93
|
+
if (typeof sent.confirm === 'string' && kept.confirm !== sent.confirm)
|
|
94
|
+
return path;
|
|
95
|
+
if (sent.disabled === true && kept.disabled !== true)
|
|
96
|
+
return path;
|
|
97
|
+
for (const [key, value] of Object.entries(sent)) {
|
|
98
|
+
const found = strippedSafety(value, kept[key], [...path, key]);
|
|
99
|
+
if (found)
|
|
100
|
+
return found;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The tree as `parser` takes it, with every change listed. The input is not touched. Each change
|
|
106
|
+
* keeps the tree valid against this package's own schema.
|
|
107
|
+
*/
|
|
108
|
+
export function conformTree(tree, parser, options) {
|
|
109
|
+
const work = structuredClone(tree);
|
|
110
|
+
const fallbacks = [];
|
|
111
|
+
const replaceNode = (path, reason, line) => {
|
|
112
|
+
const node = at(work, path);
|
|
113
|
+
const type = typeof node?.type === 'string' ? node.type : 'unknown';
|
|
114
|
+
let next = line ? { type: 'text', value: line, muted: true } : options.fallback(node);
|
|
115
|
+
// A node that is already its own fallback (a text this parse still refuses) says less instead.
|
|
116
|
+
if (JSON.stringify(next) === JSON.stringify(node)) {
|
|
117
|
+
next = { type: 'text', value: options.genericText, muted: true };
|
|
118
|
+
}
|
|
119
|
+
setAt(work, path, next);
|
|
120
|
+
fallbacks.push({ path: pathText(path), type, reason, as: next.type });
|
|
121
|
+
};
|
|
122
|
+
const repair = (issue) => {
|
|
123
|
+
const path = issue.path;
|
|
124
|
+
const key = path[path.length - 1];
|
|
125
|
+
const holder = at(work, path.slice(0, -1));
|
|
126
|
+
if (key === 'tone' && issue.code === 'invalid_value' && isObject(holder)) {
|
|
127
|
+
const values = issue.values ?? [];
|
|
128
|
+
holder.tone = values.includes('default') ? 'default' : values[0];
|
|
129
|
+
fallbacks.push({ path: pathText(path), type: 'tone', reason: 'parse', as: 'folded' });
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
if ((key === 'min' || key === 'max') && isObject(holder) && key in holder) {
|
|
133
|
+
delete holder[key];
|
|
134
|
+
fallbacks.push({ path: pathText(path), type: String(key), reason: 'parse', as: 'folded' });
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
const control = controlAt(path);
|
|
138
|
+
if (control) {
|
|
139
|
+
dropControl(work, control);
|
|
140
|
+
fallbacks.push({ path: pathText(control), type: 'control', reason: 'parse', as: 'dropped' });
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
const node = nodeAt(path);
|
|
144
|
+
if (node) {
|
|
145
|
+
replaceNode(node, 'parse');
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
const root = path[0];
|
|
149
|
+
if (typeof root === 'string' && !ROOT_REQUIRED.has(root) && root in work) {
|
|
150
|
+
delete work[root];
|
|
151
|
+
fallbacks.push({ path: root, type: root, reason: 'parse', as: 'dropped' });
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
};
|
|
156
|
+
for (let step = 0; step < MAX_STEPS; step++) {
|
|
157
|
+
const parsed = parser.safeParse(work);
|
|
158
|
+
if (!parsed.success) {
|
|
159
|
+
const issue = parsed.error.issues[0];
|
|
160
|
+
if (issue && repair(issue))
|
|
161
|
+
continue;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
const unsafe = strippedSafety(work, parsed.data);
|
|
165
|
+
if (!unsafe)
|
|
166
|
+
return { tree: work, fallbacks };
|
|
167
|
+
const control = controlAt(unsafe);
|
|
168
|
+
if (control) {
|
|
169
|
+
dropControl(work, control);
|
|
170
|
+
fallbacks.push({ path: pathText(control), type: 'control', reason: 'safety', as: 'dropped' });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const node = nodeAt(unsafe);
|
|
174
|
+
if (!node)
|
|
175
|
+
break;
|
|
176
|
+
replaceNode(node, 'safety', options.safetyText);
|
|
177
|
+
}
|
|
178
|
+
// Nothing above made the tree acceptable: send the screen as one line rather than a broken one.
|
|
179
|
+
const title = typeof work.title === 'string' ? work.title : '';
|
|
180
|
+
fallbacks.push({ path: 'children', type: 'screen', reason: 'parse', as: 'text' });
|
|
181
|
+
return {
|
|
182
|
+
tree: {
|
|
183
|
+
version: 1,
|
|
184
|
+
title,
|
|
185
|
+
children: [{ type: 'text', value: options.genericText, muted: true }],
|
|
186
|
+
},
|
|
187
|
+
fallbacks,
|
|
188
|
+
};
|
|
189
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export type { Press, ScreenPresentation, ScreenNode, ScreenRootNode, ScreenTree,
|
|
|
3
3
|
export { childNodesOf, KNOWN_CONTAINERS, KNOWN_NODE_TYPES } from './nodes.js';
|
|
4
4
|
export type { ContainerChild, ContainerNodeType, KnownNodeType } from './nodes.js';
|
|
5
5
|
export { pageRangeLabel, pageWindow, pressWithValue } from './pager.js';
|
|
6
|
+
export { CLIENT_RELEASES, CORE_DRAWN_NODE_TYPES, CURRENT_UI_SDK_SNAPSHOT, FLOOR_NODE_SET, GENERIC_FALLBACK_TEXT, SAFETY_FALLBACK_TEXT, UI_SDK_SNAPSHOTS, fallbackNode, latestRelease, negotiateTree, nodeSetForClient, } from './negotiate.js';
|
|
7
|
+
export type { ClientRelease, ClientTarget, Fallback, NegotiatedTree, NodeSet, UiFeature, UiSdkSnapshot, } from './negotiate.js';
|
|
8
|
+
export { PUBLISHED_PARSERS, type PublishedParser } from './published/index.js';
|
|
6
9
|
export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
|
|
7
10
|
export { formPress, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, } from './form.js';
|
|
8
11
|
export type { FormDraft, FormFieldKind, FormFieldLike, FormSubmit } from './form.js';
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
export { UI_SCHEMA_VERSION, pressSchema, buttonSchema, cellSchema, dateFormatSchema, nodeSchema, screenPresentationSchema, screenTreeSchema, actionResultSchema, screenLoadRequestSchema, screenLoadResponseSchema, screenActionRequestSchema, interfaceFamilySchema, surfaceDefinitionSchema, surfaceSchema, screenRegistrationSchema, uiManifestSchema, jobIdSchema, jobStatusSchema, screenJobRequestSchema, mediaPathSchema, } from './schema.js';
|
|
10
10
|
export { childNodesOf, KNOWN_CONTAINERS, KNOWN_NODE_TYPES } from './nodes.js';
|
|
11
11
|
export { pageRangeLabel, pageWindow, pressWithValue } from './pager.js';
|
|
12
|
+
export { CLIENT_RELEASES, CORE_DRAWN_NODE_TYPES, CURRENT_UI_SDK_SNAPSHOT, FLOOR_NODE_SET, GENERIC_FALLBACK_TEXT, SAFETY_FALLBACK_TEXT, UI_SDK_SNAPSHOTS, fallbackNode, latestRelease, negotiateTree, nodeSetForClient, } from './negotiate.js';
|
|
13
|
+
export { PUBLISHED_PARSERS } from './published/index.js';
|
|
12
14
|
export { MEDIA_CONTENT_TYPES, mediaContentType, mediaPathOf } from './media.js';
|
|
13
15
|
export { formPress, formSubmits, initialDraft, isoToLocalInput, localInputToIso, postedValue, } from './form.js';
|
|
14
16
|
export { composerPress, composerShortcut } from './composer.js';
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { ScreenRootNode, ScreenTree } from './schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tree features below the node level that a client may or may not draw.
|
|
4
|
+
*
|
|
5
|
+
* - `breadcrumbs`: drawn as a trail. Without it, one muted line.
|
|
6
|
+
* - `button.disabled`: a disabled button is drawn disabled and refuses the press. Without it, a
|
|
7
|
+
* disabled button becomes muted text and a disabled header action is dropped.
|
|
8
|
+
* - `section.row`: NEWER ENUM VALUE `layout: 'row'`. Without it, `stack`.
|
|
9
|
+
* - `form.field_kinds`: the field kinds added after 1.2.0 (`number`, `date`, `datetime`,
|
|
10
|
+
* `checkbox`, `multiselect`, `combobox`, `list`). Without it, `text`, `select` or `textarea`.
|
|
11
|
+
* - `form.confirm`: the client asks `submit.confirm` (and a `secondary` send's `confirm`) before
|
|
12
|
+
* the form posts. Without it, a form that carries one becomes one calm line, so nothing posts
|
|
13
|
+
* without asking.
|
|
14
|
+
*/
|
|
15
|
+
export type UiFeature = 'breadcrumbs' | 'button.disabled' | 'section.row' | 'form.field_kinds' | 'form.confirm';
|
|
16
|
+
/** The node types and features one ui-sdk release, or one client, draws. */
|
|
17
|
+
export interface NodeSet {
|
|
18
|
+
/** For messages: "ui-sdk 1.4.0", "mobile 0.2.5". */
|
|
19
|
+
name: string;
|
|
20
|
+
nodes: readonly string[];
|
|
21
|
+
features: readonly UiFeature[];
|
|
22
|
+
/**
|
|
23
|
+
* The published schema the client parses with. Its tree is fitted to it (conform.ts). Absent, or
|
|
24
|
+
* `current`, means this package's own schema: nothing to fit.
|
|
25
|
+
*/
|
|
26
|
+
parses?: UiSdkSnapshot;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Nodes a module may send that core draws itself before any client sees the tree: a `dataset`
|
|
30
|
+
* node becomes plain blocks from the module's rows (dataset-view.ts). No client parses them, so
|
|
31
|
+
* no snapshot lists them; one that reached negotiation undrawn gets its own fallback.
|
|
32
|
+
*/
|
|
33
|
+
export declare const CORE_DRAWN_NODE_TYPES: readonly ["dataset"];
|
|
34
|
+
/**
|
|
35
|
+
* What each schema a client can parse with admits. `1.1.0` and `1.4.0` are published releases
|
|
36
|
+
* (frozen copies in published/); `current` is this package, newer than any released app.
|
|
37
|
+
*/
|
|
38
|
+
export declare const UI_SDK_SNAPSHOTS: {
|
|
39
|
+
readonly '1.1.0': {
|
|
40
|
+
readonly name: "ui-sdk 1.1.0";
|
|
41
|
+
readonly nodes: readonly ["heading", "text", "markdown", "stat", "button", "form", "table", "timeline", "pending_request", "pending_requests", "choice_cards", "progress", "chart", "section", "tabs"];
|
|
42
|
+
readonly features: readonly [];
|
|
43
|
+
};
|
|
44
|
+
readonly '1.4.0': {
|
|
45
|
+
readonly name: "ui-sdk 1.4.0";
|
|
46
|
+
readonly nodes: readonly ["heading", "text", "markdown", "stat", "button", "form", "table", "timeline", "pending_request", "pending_requests", "choice_cards", "progress", "chart", "section", "tabs", "pagination", "select", "alert", "details", "timestamp", "divider", "board", "link", "tags", "toggle", "segmented", "progress_bar", "conversation", "composer", "calendar", "image", "video"];
|
|
47
|
+
readonly features: readonly ["breadcrumbs", "button.disabled", "section.row", "form.field_kinds", "form.confirm"];
|
|
48
|
+
};
|
|
49
|
+
readonly current: {
|
|
50
|
+
readonly name: "ui-sdk (this package)";
|
|
51
|
+
readonly nodes: readonly ["heading", "text", "markdown", "stat", "button", "form", "table", "timeline", "pending_request", "pending_requests", "choice_cards", "progress", "chart", "section", "tabs", "pagination", "select", "alert", "details", "timestamp", "divider", "board", "link", "tags", "toggle", "segmented", "progress_bar", "conversation", "composer", "calendar", "image", "video"];
|
|
52
|
+
readonly features: readonly ["breadcrumbs", "button.disabled", "section.row", "form.field_kinds", "form.confirm"];
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export type UiSdkSnapshot = keyof typeof UI_SDK_SNAPSHOTS;
|
|
56
|
+
/** The snapshot this package is. Core's own renderer draws all of it. */
|
|
57
|
+
export declare const CURRENT_UI_SDK_SNAPSHOT: UiSdkSnapshot;
|
|
58
|
+
/** The clients that send `X-Kee-Client`. Same names as core's ClientPlatform. */
|
|
59
|
+
export type ClientTarget = 'web' | 'mobile' | 'desktop' | 'extension' | 'cli';
|
|
60
|
+
export interface ClientRelease {
|
|
61
|
+
client: ClientTarget;
|
|
62
|
+
/** The first client version (x.y.z) this row applies to. */
|
|
63
|
+
since: string;
|
|
64
|
+
/** The schema this release parses with: the ui-sdk inside the sdk it was built with. */
|
|
65
|
+
parses: UiSdkSnapshot;
|
|
66
|
+
/** What its renderer draws: always within `parses`. */
|
|
67
|
+
draws: Omit<NodeSet, 'name' | 'parses'>;
|
|
68
|
+
/** Why the row says what it says. */
|
|
69
|
+
note: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Every client release core negotiates for, oldest first per client. A client
|
|
73
|
+
* version below every row of its client gets the floor (ui-sdk 1.1.0).
|
|
74
|
+
*
|
|
75
|
+
* Checked 2026-10-20 against kee-clients' release tags and their lockfiles (which sdk, and so which
|
|
76
|
+
* ui-sdk, each build parses with) and their renderers.
|
|
77
|
+
*/
|
|
78
|
+
export declare const CLIENT_RELEASES: readonly ClientRelease[];
|
|
79
|
+
/** The floor: what every client that sends `X-Kee-Client` can take. */
|
|
80
|
+
export declare const FLOOR_NODE_SET: NodeSet;
|
|
81
|
+
/** The rows of one client, oldest first. */
|
|
82
|
+
export declare function releasesOf(client: string, releases?: readonly ClientRelease[]): ClientRelease[];
|
|
83
|
+
/**
|
|
84
|
+
* What a client draws, from its `X-Kee-Client` platform and version: the newest
|
|
85
|
+
* row of that client whose `since` it has reached. An unknown platform, or a
|
|
86
|
+
* version below every row, gets the floor. A version core cannot read counts as
|
|
87
|
+
* 0.0.0: a client core cannot identify is treated as the oldest, never the newest.
|
|
88
|
+
*/
|
|
89
|
+
export declare function nodeSetForClient(platform: string, version: string, releases?: readonly ClientRelease[]): NodeSet;
|
|
90
|
+
/** The newest release row of a client: what a module targets when it names only the client. */
|
|
91
|
+
export declare function latestRelease(client: ClientTarget): ClientRelease;
|
|
92
|
+
/** One node core replaced, or one header action it dropped. */
|
|
93
|
+
export interface Fallback {
|
|
94
|
+
/** Where it was, as a property path: `children[2].children[0]`, `actions[1]`, `breadcrumbs`. */
|
|
95
|
+
path: string;
|
|
96
|
+
/** The node type (or `breadcrumbs`) the client cannot draw. */
|
|
97
|
+
type: string;
|
|
98
|
+
/**
|
|
99
|
+
* Why: the node type is not drawn, a feature of it is not, the client's published schema
|
|
100
|
+
* refuses something in it (`parse`), or that schema would strip a `confirm` or a `disabled`
|
|
101
|
+
* flag from a control it keeps (`safety`).
|
|
102
|
+
*/
|
|
103
|
+
reason: 'node' | UiFeature | 'parse' | 'safety';
|
|
104
|
+
/**
|
|
105
|
+
* What took its place. A header action can only be dropped: the header holds buttons only. A
|
|
106
|
+
* newer enum value is `folded`: the node stays, with the nearest value the client knows.
|
|
107
|
+
*/
|
|
108
|
+
as: 'text' | 'markdown' | 'dropped' | 'folded';
|
|
109
|
+
}
|
|
110
|
+
export interface NegotiatedTree {
|
|
111
|
+
tree: ScreenTree;
|
|
112
|
+
fallbacks: Fallback[];
|
|
113
|
+
}
|
|
114
|
+
/** The fallback for a node type that has no specific one: a sign that something is there. */
|
|
115
|
+
export declare const GENERIC_FALLBACK_TEXT = "Open this in the web app to see this part of the screen.";
|
|
116
|
+
/**
|
|
117
|
+
* What stands in for a control that would act without its safety on this client: a form that
|
|
118
|
+
* would post without its confirm, a button that would press although it is disabled.
|
|
119
|
+
*/
|
|
120
|
+
export declare const SAFETY_FALLBACK_TEXT = "Open this in the web app to finish this step.";
|
|
121
|
+
/**
|
|
122
|
+
* The tree a client with `set` receives: every node it cannot draw replaced with
|
|
123
|
+
* `text` or `markdown`, every feature it cannot draw folded away. The result
|
|
124
|
+
* still validates against the ui-sdk schema. A tree that needs nothing is
|
|
125
|
+
* returned as the same object.
|
|
126
|
+
*/
|
|
127
|
+
export declare function negotiateTree(tree: ScreenTree, set: NodeSet): NegotiatedTree;
|
|
128
|
+
type FormNode = Extract<ScreenRootNode, {
|
|
129
|
+
type: 'form';
|
|
130
|
+
}>;
|
|
131
|
+
type FormField = FormNode['fields'][number];
|
|
132
|
+
/**
|
|
133
|
+
* A form field of a kind the client's parse does not know, as the nearest kind it does. It keeps
|
|
134
|
+
* the label, the name and the starting value; what it posts becomes a string (the older kinds post
|
|
135
|
+
* strings), so a module that types its input must accept that from an older client.
|
|
136
|
+
* number, date, datetime -> text (the value is already a string)
|
|
137
|
+
* combobox -> select (the same options; typed text is not offered)
|
|
138
|
+
* checkbox -> select with "Yes" and "No"
|
|
139
|
+
* multiselect -> select, starting at the first chosen value
|
|
140
|
+
* list -> textarea, one item per line
|
|
141
|
+
*/
|
|
142
|
+
export declare function foldFormField(field: FormField): FormField;
|
|
143
|
+
type FallbackNode = {
|
|
144
|
+
type: 'text';
|
|
145
|
+
value: string;
|
|
146
|
+
muted: boolean;
|
|
147
|
+
} | {
|
|
148
|
+
type: 'markdown';
|
|
149
|
+
value: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* What a node becomes on a client that cannot draw it. It keeps what the node
|
|
153
|
+
* SAYS; it cannot keep what the node DOES, so a pager, a select or an alert's
|
|
154
|
+
* button is not pressable in the fallback.
|
|
155
|
+
*/
|
|
156
|
+
export declare function fallbackNode(node: ScreenRootNode | {
|
|
157
|
+
type: string;
|
|
158
|
+
}): FallbackNode;
|
|
159
|
+
/** Module text is plain text: escape it so it reads the same inside a markdown fallback. */
|
|
160
|
+
export declare function escapeMarkdown(value: string): string;
|
|
161
|
+
export {};
|