@zeyos/zx 5.5.0 → 5.7.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/CHANGELOG.md +210 -0
- package/README.md +73 -7
- package/bin/zx-css.js +328 -0
- package/dist/types/components/account-menu/account-menu.d.ts +4 -2
- package/dist/types/components/activity-list/activity-list.d.ts +14 -8
- package/dist/types/components/agent-thread/ag-ui.d.ts +340 -0
- package/dist/types/components/agent-thread/agent-thread.d.ts +711 -0
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +401 -0
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +14 -8
- package/dist/types/components/approval-card/approval-card.d.ts +596 -0
- package/dist/types/components/avatar/avatar.d.ts +91 -4
- package/dist/types/components/block-view/block-view.d.ts +205 -0
- package/dist/types/components/breadcrumb/breadcrumb.d.ts +3 -3
- package/dist/types/components/calendar/calendar-model.d.ts +9 -2
- package/dist/types/components/calendar/calendar.d.ts +12 -4
- package/dist/types/components/chart/chart.d.ts +25 -13
- package/dist/types/components/code-editor/code-editor.d.ts +7 -2
- package/dist/types/components/composer/composer.d.ts +938 -0
- package/dist/types/components/composer/queue.d.ts +76 -0
- package/dist/types/components/copy/copy-button.d.ts +6 -4
- package/dist/types/components/copy/copy-input.d.ts +10 -6
- package/dist/types/components/datebox/date-range-box.d.ts +33 -0
- package/dist/types/components/datebox/placeholder.d.ts +7 -0
- package/dist/types/components/dock/dock.d.ts +12 -3
- package/dist/types/components/entity-ref/entity-ref.d.ts +5 -3
- package/dist/types/components/field-upload/field-upload.d.ts +3 -2
- package/dist/types/components/file-item/file-item.d.ts +3 -2
- package/dist/types/components/file-list/file-list.d.ts +14 -8
- package/dist/types/components/filter/filter-model.d.ts +31 -1
- package/dist/types/components/filter/filter.d.ts +20 -2
- package/dist/types/components/finder/finder.d.ts +14 -6
- package/dist/types/components/flag/flag.d.ts +99 -0
- package/dist/types/components/grid/grid.d.ts +1 -1
- package/dist/types/components/kanban-view/kanban-view.d.ts +8 -66
- package/dist/types/components/launcher/launcher.d.ts +2 -0
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +3 -2
- package/dist/types/components/number-field/number-field.d.ts +17 -6
- package/dist/types/components/prompt-starters/prompt-starters.d.ts +107 -0
- package/dist/types/components/prose/prose.d.ts +9 -6
- package/dist/types/components/questionnaire/conditions.d.ts +270 -0
- package/dist/types/components/questionnaire/items.d.ts +52 -30
- package/dist/types/components/questionnaire/questionnaire.d.ts +44 -4
- package/dist/types/components/rating/rating.d.ts +5 -3
- package/dist/types/components/run-status/run-status.d.ts +393 -0
- package/dist/types/components/run-trace/run-trace.d.ts +624 -0
- package/dist/types/components/select/country.d.ts +106 -0
- package/dist/types/components/select/field-adapter.d.ts +2 -1
- package/dist/types/components/select/locale.d.ts +102 -0
- package/dist/types/components/select/select.d.ts +41 -2
- package/dist/types/components/slider/slider.d.ts +1 -0
- package/dist/types/components/sort-control/sort-control.d.ts +7 -3
- package/dist/types/components/source-list/source-list.d.ts +179 -0
- package/dist/types/components/split-view/split-view.d.ts +5 -3
- package/dist/types/components/surface/catalog.d.ts +260 -0
- package/dist/types/components/surface/elicit.d.ts +81 -0
- package/dist/types/components/surface/mcp.d.ts +165 -0
- package/dist/types/components/surface/schema.d.ts +314 -0
- package/dist/types/components/surface/stream.d.ts +118 -0
- package/dist/types/components/surface/surface.d.ts +718 -0
- package/dist/types/components/surface/text.d.ts +277 -0
- package/dist/types/components/surface/validate.d.ts +339 -0
- package/dist/types/components/table/table.d.ts +55 -3
- package/dist/types/components/table/window.d.ts +203 -0
- package/dist/types/components/toolbar/toolbar.d.ts +10 -6
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/tree/tree.d.ts +20 -13
- package/dist/types/core/component.d.ts +10 -0
- package/dist/types/core/date.d.ts +8 -1
- package/dist/types/core/dom.d.ts +1 -0
- package/dist/types/core/http.d.ts +10 -0
- package/dist/types/core/i18n.d.ts +38 -0
- package/dist/types/core/messages.d.ts +479 -1
- package/dist/types/core/storage.d.ts +7 -2
- package/dist/types/elements/define.d.ts +21 -46
- package/dist/types/elements/definitions.d.ts +147 -0
- package/dist/types/elements/kit.d.ts +7 -0
- package/dist/types/elements/reflect.d.ts +6 -3
- package/dist/types/index.d.ts +18 -1
- package/dist/types/internal/agent-model.d.ts +587 -0
- package/dist/types/internal/date-locale.d.ts +7 -0
- package/dist/types/internal/highlight.d.ts +24 -0
- package/dist/types/internal/json-patch.d.ts +146 -0
- package/dist/types/internal/presence-loop.d.ts +148 -0
- package/dist/types/locales/de.d.ts +13 -0
- package/dist/types/locales/en.d.ts +2 -0
- package/dist/types/locales/index.d.ts +823 -0
- package/dist/types/zeyos/view.d.ts +8 -1
- package/dist/zx-zeyos.esm.js +20505 -18748
- package/dist/zx-zeyos.esm.min.js +5 -5
- package/dist/zx.core.css +1276 -0
- package/dist/zx.core.min.css +1 -0
- package/dist/zx.css +2424 -134
- package/dist/zx.esm.js +46167 -28468
- package/dist/zx.esm.min.js +40 -8
- package/dist/zx.global.js +46167 -28468
- package/dist/zx.global.min.js +40 -8
- package/dist/zx.layered.css +17302 -0
- package/dist/zx.layered.min.css +1 -0
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +12501 -0
- package/docs/agent-surfaces.md +340 -0
- package/docs/api.json +2057 -166
- package/docs/llms.md +1458 -58
- package/docs/llms.txt +38 -8
- package/package.json +29 -6
- package/src/components/account-menu/account-menu.js +6 -3
- package/src/components/activity-item/activity-item.js +2 -1
- package/src/components/activity-list/activity-list.js +16 -10
- package/src/components/agent-thread/ag-ui.js +1439 -0
- package/src/components/agent-thread/agent-thread.css +417 -0
- package/src/components/agent-thread/agent-thread.js +1670 -0
- package/src/components/agent-thread/ui-message-stream.js +1281 -0
- package/src/components/app-sidebar/app-sidebar.js +18 -8
- package/src/components/approval-card/approval-card.css +289 -0
- package/src/components/approval-card/approval-card.js +1378 -0
- package/src/components/avatar/avatar.css +56 -1
- package/src/components/avatar/avatar.js +148 -26
- package/src/components/block-view/block-view.css +300 -0
- package/src/components/block-view/block-view.js +524 -0
- package/src/components/breadcrumb/breadcrumb.js +8 -5
- package/src/components/calendar/calendar-model.js +8 -2
- package/src/components/calendar/calendar.js +53 -18
- package/src/components/chart/chart.js +54 -23
- package/src/components/code-editor/code-editor.js +45 -8
- package/src/components/code-editor/field-adapter.js +1 -1
- package/src/components/composer/composer.css +482 -0
- package/src/components/composer/composer.js +1815 -0
- package/src/components/composer/queue.js +78 -0
- package/src/components/context-menu/context-menu.js +12 -1
- package/src/components/copy/copy-button.js +9 -7
- package/src/components/copy/copy-input.js +10 -6
- package/src/components/date-picker/date-picker.js +2 -1
- package/src/components/date-picker/date-range-picker.js +8 -7
- package/src/components/datebox/date-range-box.js +3 -9
- package/src/components/datebox/datebox.js +18 -21
- package/src/components/datebox/placeholder.js +18 -0
- package/src/components/dialog/dialog.js +1 -1
- package/src/components/dock/dock.js +34 -13
- package/src/components/entity-ref/entity-ref.js +16 -5
- package/src/components/field-upload/field-upload.js +81 -38
- package/src/components/file-item/file-item.js +70 -40
- package/src/components/file-list/file-list.js +15 -9
- package/src/components/filter/filter-model.js +46 -8
- package/src/components/filter/filter.css +3 -3
- package/src/components/filter/filter.js +29 -10
- package/src/components/filter-panel/filter-panel.js +13 -5
- package/src/components/finder/finder.js +50 -26
- package/src/components/flag/flag.css +40 -0
- package/src/components/flag/flag.js +177 -0
- package/src/components/form/form.js +1 -1
- package/src/components/grid/grid.js +22 -8
- package/src/components/kanban-view/kanban-view.js +51 -81
- package/src/components/launcher/launcher.js +17 -2
- package/src/components/list-toolbar/list-toolbar.js +2 -1
- package/src/components/master-panel/master-panel.js +1 -1
- package/src/components/menu-button/menu-button.js +4 -0
- package/src/components/message/message.js +3 -0
- package/src/components/multi-value-editor/multi-value-editor.js +10 -9
- package/src/components/navigation-bar/navigation-bar.js +3 -3
- package/src/components/number-field/number-field.js +29 -13
- package/src/components/prompt-starters/prompt-starters.css +91 -0
- package/src/components/prompt-starters/prompt-starters.js +206 -0
- package/src/components/prose/prose.js +14 -10
- package/src/components/questionnaire/conditions.js +666 -0
- package/src/components/questionnaire/items.js +150 -41
- package/src/components/questionnaire/questionnaire.js +126 -32
- package/src/components/rating/rating.js +5 -4
- package/src/components/run-status/run-status.css +208 -0
- package/src/components/run-status/run-status.js +782 -0
- package/src/components/run-trace/run-trace.css +443 -0
- package/src/components/run-trace/run-trace.js +1209 -0
- package/src/components/select/country.js +136 -0
- package/src/components/select/field-adapter.js +7 -2
- package/src/components/select/locale.js +219 -0
- package/src/components/select/select.css +20 -22
- package/src/components/select/select.js +94 -12
- package/src/components/sheet/sheet-stack.js +10 -1
- package/src/components/slider/slider.js +7 -2
- package/src/components/sort-control/sort-control.js +15 -5
- package/src/components/source-list/source-list.css +208 -0
- package/src/components/source-list/source-list.js +358 -0
- package/src/components/split-view/split-view.js +5 -3
- package/src/components/surface/catalog.js +1334 -0
- package/src/components/surface/elicit.js +107 -0
- package/src/components/surface/mcp.js +243 -0
- package/src/components/surface/schema.js +644 -0
- package/src/components/surface/stream.js +245 -0
- package/src/components/surface/surface.css +308 -0
- package/src/components/surface/surface.js +2291 -0
- package/src/components/surface/text.js +513 -0
- package/src/components/surface/validate.js +2218 -0
- package/src/components/tabbox/tabbox.js +9 -0
- package/src/components/table/table.css +63 -3
- package/src/components/table/table.js +167 -28
- package/src/components/table/window.js +317 -0
- package/src/components/toolbar/toolbar.js +12 -7
- package/src/components/tooltip/tooltip.css +2 -3
- package/src/components/tooltip/tooltip.js +32 -5
- package/src/components/tree/tree.js +53 -23
- package/src/core/component.js +25 -1
- package/src/core/date.js +62 -16
- package/src/core/dom.js +22 -2
- package/src/core/format.js +15 -13
- package/src/core/http.js +29 -20
- package/src/core/i18n.js +83 -10
- package/src/core/keyboard.js +79 -8
- package/src/core/messages.js +519 -2
- package/src/core/overlay-host.js +1 -0
- package/src/core/storage.js +59 -6
- package/src/elements/define.js +178 -130
- package/src/elements/definitions.js +229 -0
- package/src/elements/kit.js +444 -0
- package/src/elements/reflect.js +8 -3
- package/src/index.js +18 -1
- package/src/internal/agent-model.js +488 -0
- package/src/internal/date-locale.js +11 -0
- package/src/internal/highlight.js +104 -0
- package/src/internal/json-patch.js +405 -0
- package/src/internal/presence-loop.js +343 -0
- package/src/locales/de.js +911 -0
- package/src/locales/en.js +2 -0
- package/src/locales/index.js +7 -0
- package/src/zeyos/calendar.js +2 -1
- package/src/zeyos/form.js +2 -1
- package/src/zeyos/launcher.js +7 -6
- package/src/zeyos/module-bar.js +2 -1
- package/src/zeyos/schema.js +37 -23
- package/src/zeyos/select.js +4 -3
- package/src/zeyos/table.js +2 -13
- package/src/zeyos/view.js +57 -17
- package/styles/core.css +11 -0
- package/styles/tokens/semantic.css +1 -0
- package/styles/zeyos.css +2 -0
- package/styles/zx.css +11 -8
- package/styles/zx.layered.css +1 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
export type RuleMessage = import('../questionnaire/conditions.js').RuleMessage;
|
|
2
|
+
export type Condition = import('../questionnaire/conditions.js').Condition;
|
|
3
|
+
export type ConditionProblem = import('../questionnaire/conditions.js').ConditionProblem;
|
|
4
|
+
export type SchemaFormat = 'date' | 'date-time' | 'time' | 'email' | 'uri';
|
|
5
|
+
export type SchemaChoice = {
|
|
6
|
+
const: string;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
export type SchemaHint = {
|
|
10
|
+
/**
|
|
11
|
+
* The Field type that draws the property; see `FIELD_TYPES`.
|
|
12
|
+
*/
|
|
13
|
+
field?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Shows the property only while the condition holds.
|
|
16
|
+
*/
|
|
17
|
+
visible?: Condition;
|
|
18
|
+
};
|
|
19
|
+
export type SchemaProperty = {
|
|
20
|
+
/**
|
|
21
|
+
* What the value is.
|
|
22
|
+
*/
|
|
23
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array';
|
|
24
|
+
/**
|
|
25
|
+
* The label. Every property should have one.
|
|
26
|
+
*/
|
|
27
|
+
title?: string;
|
|
28
|
+
/**
|
|
29
|
+
* A supporting line under the field.
|
|
30
|
+
*/
|
|
31
|
+
description?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The value the field starts with.
|
|
34
|
+
*/
|
|
35
|
+
default?: unknown;
|
|
36
|
+
/**
|
|
37
|
+
* The allowed values of a `string`, shown as they are.
|
|
38
|
+
*/
|
|
39
|
+
enum?: string[];
|
|
40
|
+
/**
|
|
41
|
+
* The allowed values of a `string`, each with a title.
|
|
42
|
+
*/
|
|
43
|
+
oneOf?: SchemaChoice[];
|
|
44
|
+
/**
|
|
45
|
+
* A named format of a `string`.
|
|
46
|
+
*/
|
|
47
|
+
format?: SchemaFormat;
|
|
48
|
+
/**
|
|
49
|
+
* Lowest number.
|
|
50
|
+
*/
|
|
51
|
+
minimum?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Highest number.
|
|
54
|
+
*/
|
|
55
|
+
maximum?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Fewest characters.
|
|
58
|
+
*/
|
|
59
|
+
minLength?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Most characters.
|
|
62
|
+
*/
|
|
63
|
+
maxLength?: number;
|
|
64
|
+
/**
|
|
65
|
+
* The choices of
|
|
66
|
+
* an `array`.
|
|
67
|
+
*/
|
|
68
|
+
items?: {
|
|
69
|
+
type?: 'string';
|
|
70
|
+
enum?: string[];
|
|
71
|
+
anyOf?: SchemaChoice[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Fewest choices of an `array`.
|
|
75
|
+
*/
|
|
76
|
+
minItems?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Most choices of an `array`.
|
|
79
|
+
*/
|
|
80
|
+
maxItems?: number;
|
|
81
|
+
/**
|
|
82
|
+
* The surface's own hint.
|
|
83
|
+
*/
|
|
84
|
+
"x-zx"?: SchemaHint;
|
|
85
|
+
};
|
|
86
|
+
export type InputSchema = {
|
|
87
|
+
/**
|
|
88
|
+
* Always `object`.
|
|
89
|
+
*/
|
|
90
|
+
type: 'object';
|
|
91
|
+
/**
|
|
92
|
+
* The inputs, in the order they are shown.
|
|
93
|
+
*/
|
|
94
|
+
properties: Record<string, SchemaProperty>;
|
|
95
|
+
/**
|
|
96
|
+
* The inputs that need a value.
|
|
97
|
+
*/
|
|
98
|
+
required?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* The JSON Schema dialect; ignored.
|
|
101
|
+
*/
|
|
102
|
+
$schema?: string;
|
|
103
|
+
};
|
|
104
|
+
export type SchemaProblem = {
|
|
105
|
+
path: string;
|
|
106
|
+
message: string;
|
|
107
|
+
};
|
|
108
|
+
export type SchemaField = {
|
|
109
|
+
/**
|
|
110
|
+
* Registered Field type.
|
|
111
|
+
*/
|
|
112
|
+
type: string;
|
|
113
|
+
/**
|
|
114
|
+
* Visible label: the title, or the property name.
|
|
115
|
+
*/
|
|
116
|
+
label: string;
|
|
117
|
+
/**
|
|
118
|
+
* Supporting line.
|
|
119
|
+
*/
|
|
120
|
+
description?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Whether a value is needed.
|
|
123
|
+
*/
|
|
124
|
+
required: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* The starting value.
|
|
127
|
+
*/
|
|
128
|
+
value?: unknown;
|
|
129
|
+
/**
|
|
130
|
+
* Placeholder text.
|
|
131
|
+
*/
|
|
132
|
+
placeholder?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Values and labels of a `select` or `optionlist`.
|
|
135
|
+
*/
|
|
136
|
+
options?: Record<string, string>;
|
|
137
|
+
/**
|
|
138
|
+
* Properties of the control.
|
|
139
|
+
*/
|
|
140
|
+
props?: Record<string, unknown>;
|
|
141
|
+
};
|
|
142
|
+
export type ValueProblem = {
|
|
143
|
+
name: string;
|
|
144
|
+
message: string;
|
|
145
|
+
};
|
|
146
|
+
export type CheckedValues = {
|
|
147
|
+
/**
|
|
148
|
+
* The submitted values as JSON:
|
|
149
|
+
* every visible property that has a value, in schema order. Hidden properties, empty optional
|
|
150
|
+
* ones and names outside the schema are left out.
|
|
151
|
+
*/
|
|
152
|
+
values: Record<string, string | number | boolean | string[]>;
|
|
153
|
+
/**
|
|
154
|
+
* One entry per invalid property, in schema order.
|
|
155
|
+
*/
|
|
156
|
+
errors: ValueProblem[];
|
|
157
|
+
};
|
|
158
|
+
/** @typedef {import('../questionnaire/conditions.js').RuleMessage} RuleMessage */
|
|
159
|
+
/** @typedef {import('../questionnaire/conditions.js').Condition} Condition */
|
|
160
|
+
/** @typedef {import('../questionnaire/conditions.js').ConditionProblem} ConditionProblem */
|
|
161
|
+
/** @typedef {'date'|'date-time'|'time'|'email'|'uri'} SchemaFormat */
|
|
162
|
+
/**
|
|
163
|
+
* One choice of an `enum` written with its title.
|
|
164
|
+
* @typedef {{const: string, title: string}} SchemaChoice
|
|
165
|
+
*/
|
|
166
|
+
/**
|
|
167
|
+
* The surface's own hint on a property.
|
|
168
|
+
* @typedef {Object} SchemaHint
|
|
169
|
+
* @property {string} [field] The Field type that draws the property; see `FIELD_TYPES`.
|
|
170
|
+
* @property {Condition} [visible] Shows the property only while the condition holds.
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* One property of an input schema.
|
|
174
|
+
* @typedef {Object} SchemaProperty
|
|
175
|
+
* @property {'string'|'number'|'integer'|'boolean'|'array'} type What the value is.
|
|
176
|
+
* @property {string} [title] The label. Every property should have one.
|
|
177
|
+
* @property {string} [description] A supporting line under the field.
|
|
178
|
+
* @property {unknown} [default] The value the field starts with.
|
|
179
|
+
* @property {string[]} [enum] The allowed values of a `string`, shown as they are.
|
|
180
|
+
* @property {SchemaChoice[]} [oneOf] The allowed values of a `string`, each with a title.
|
|
181
|
+
* @property {SchemaFormat} [format] A named format of a `string`.
|
|
182
|
+
* @property {number} [minimum] Lowest number.
|
|
183
|
+
* @property {number} [maximum] Highest number.
|
|
184
|
+
* @property {number} [minLength] Fewest characters.
|
|
185
|
+
* @property {number} [maxLength] Most characters.
|
|
186
|
+
* @property {{type?: 'string', enum?: string[], anyOf?: SchemaChoice[]}} [items] The choices of
|
|
187
|
+
* an `array`.
|
|
188
|
+
* @property {number} [minItems] Fewest choices of an `array`.
|
|
189
|
+
* @property {number} [maxItems] Most choices of an `array`.
|
|
190
|
+
* @property {SchemaHint} [x-zx] The surface's own hint.
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* An input schema: one flat object.
|
|
194
|
+
* @typedef {Object} InputSchema
|
|
195
|
+
* @property {'object'} type Always `object`.
|
|
196
|
+
* @property {Record<string, SchemaProperty>} properties The inputs, in the order they are shown.
|
|
197
|
+
* @property {string[]} [required] The inputs that need a value.
|
|
198
|
+
* @property {string} [$schema] The JSON Schema dialect; ignored.
|
|
199
|
+
*/
|
|
200
|
+
/**
|
|
201
|
+
* A construct outside the subset, or a malformed one. `path` is a JSON Pointer into the schema.
|
|
202
|
+
* @typedef {{path: string, message: string}} SchemaProblem
|
|
203
|
+
*/
|
|
204
|
+
/**
|
|
205
|
+
* The options of one Fieldset field, as `schemaToFields()` returns them.
|
|
206
|
+
* @typedef {Object} SchemaField
|
|
207
|
+
* @property {string} type Registered Field type.
|
|
208
|
+
* @property {string} label Visible label: the title, or the property name.
|
|
209
|
+
* @property {string} [description] Supporting line.
|
|
210
|
+
* @property {boolean} required Whether a value is needed.
|
|
211
|
+
* @property {unknown} [value] The starting value.
|
|
212
|
+
* @property {string} [placeholder] Placeholder text.
|
|
213
|
+
* @property {Record<string, string>} [options] Values and labels of a `select` or `optionlist`.
|
|
214
|
+
* @property {Record<string, unknown>} [props] Properties of the control.
|
|
215
|
+
*/
|
|
216
|
+
/**
|
|
217
|
+
* A value that failed its schema.
|
|
218
|
+
* @typedef {{name: string, message: string}} ValueProblem
|
|
219
|
+
*/
|
|
220
|
+
/**
|
|
221
|
+
* What `checkValue()` returns.
|
|
222
|
+
* @typedef {Object} CheckedValues
|
|
223
|
+
* @property {Record<string, string|number|boolean|string[]>} values The submitted values as JSON:
|
|
224
|
+
* every visible property that has a value, in schema order. Hidden properties, empty optional
|
|
225
|
+
* ones and names outside the schema are left out.
|
|
226
|
+
* @property {ValueProblem[]} errors One entry per invalid property, in schema order.
|
|
227
|
+
*/
|
|
228
|
+
/** The named string formats. */
|
|
229
|
+
export declare const SCHEMA_FORMATS: readonly SchemaFormat[];
|
|
230
|
+
/** Most properties one schema may declare. */
|
|
231
|
+
export declare const MAX_SCHEMA_PROPERTIES = 50;
|
|
232
|
+
/** Most choices one property may offer. */
|
|
233
|
+
export declare const MAX_SCHEMA_CHOICES = 64;
|
|
234
|
+
/**
|
|
235
|
+
* The Field types a property may name in `x-zx.field`, by what the property is. The first is the
|
|
236
|
+
* default. No kind offers a password, hidden, HTML, upload or custom field.
|
|
237
|
+
*/
|
|
238
|
+
export declare const FIELD_TYPES: Readonly<{
|
|
239
|
+
text: readonly string[];
|
|
240
|
+
date: readonly string[];
|
|
241
|
+
'date-time': readonly string[];
|
|
242
|
+
time: readonly string[];
|
|
243
|
+
email: readonly string[];
|
|
244
|
+
uri: readonly string[];
|
|
245
|
+
choice: readonly string[];
|
|
246
|
+
number: readonly string[];
|
|
247
|
+
boolean: readonly string[];
|
|
248
|
+
multiple: readonly string[];
|
|
249
|
+
}>;
|
|
250
|
+
/**
|
|
251
|
+
* Lists the constructs of a schema that lie outside the subset, and the malformed ones. An empty
|
|
252
|
+
* list means `schemaToFields()` and `checkValue()` can take the schema. An `x-zx.visible`
|
|
253
|
+
* condition is only checked for being an object here; its grammar and the inputs it may name
|
|
254
|
+
* belong to the surface that holds the schema.
|
|
255
|
+
* @param {unknown} schema Schema to check.
|
|
256
|
+
* @returns {SchemaProblem[]}
|
|
257
|
+
*/
|
|
258
|
+
export declare function unsupported(schema: unknown): SchemaProblem[];
|
|
259
|
+
/**
|
|
260
|
+
* Lists what is wrong with one property. Paths are relative to the property.
|
|
261
|
+
* @param {unknown} property
|
|
262
|
+
* @returns {SchemaProblem[]}
|
|
263
|
+
*/
|
|
264
|
+
export declare function propertyProblems(property: unknown): SchemaProblem[];
|
|
265
|
+
/**
|
|
266
|
+
* Turns a schema into the options of Fieldset fields, keyed and ordered by property name. Run
|
|
267
|
+
* `unsupported()` first: a schema outside the subset throws.
|
|
268
|
+
* @param {InputSchema} schema An input schema within the subset.
|
|
269
|
+
* @returns {Record<string, SchemaField>}
|
|
270
|
+
* @throws {TypeError} When the schema is outside the subset.
|
|
271
|
+
*/
|
|
272
|
+
export declare function schemaToFields(schema: InputSchema): Record<string, SchemaField>;
|
|
273
|
+
/**
|
|
274
|
+
* Checks submitted values against a schema and returns them as JSON. Hidden properties are skipped
|
|
275
|
+
* entirely: they are not required and not part of the result. Whatever a Field holds internally
|
|
276
|
+
* comes back as JSON: a `Date` becomes `YYYY-MM-DD` for a `date`, a local `YYYY-MM-DDTHH:MM:SS`
|
|
277
|
+
* for a `date-time` and `HH:MM` for a `time`; a numeric string becomes a number for a `number` or
|
|
278
|
+
* `integer`.
|
|
279
|
+
* @param {InputSchema} schema An input schema within the subset.
|
|
280
|
+
* @param {Record<string, unknown>} values The submitted values by property name.
|
|
281
|
+
* @param {Iterable<string>} [hidden=[]] Names of the properties hidden at the moment.
|
|
282
|
+
* @param {RuleMessage} [message] Resolves a message key, as `checkRules()` does.
|
|
283
|
+
* @returns {CheckedValues}
|
|
284
|
+
* @throws {TypeError} When the schema is outside the subset.
|
|
285
|
+
*/
|
|
286
|
+
export declare function checkValue(schema: InputSchema, values: Record<string, unknown>, hidden?: Iterable<string>, message?: RuleMessage): CheckedValues;
|
|
287
|
+
/**
|
|
288
|
+
* Brings what a Field holds into the JSON a reply carries. Values that cannot be brought are
|
|
289
|
+
* returned as they are, for `checkValue()` to report.
|
|
290
|
+
* @param {SchemaProperty} property The property's schema.
|
|
291
|
+
* @param {unknown} value What the Field holds.
|
|
292
|
+
* @returns {unknown}
|
|
293
|
+
*/
|
|
294
|
+
export declare function toJsonValue(property: SchemaProperty, value: unknown): unknown;
|
|
295
|
+
/**
|
|
296
|
+
* The values a property offers, each with its label, in order.
|
|
297
|
+
* @param {SchemaProperty} property
|
|
298
|
+
* @returns {Array<[string, string]>}
|
|
299
|
+
*/
|
|
300
|
+
export declare function choicesOf(property: SchemaProperty): Array<[string, string]>;
|
|
301
|
+
/**
|
|
302
|
+
* What a property is, which decides the Field types it may use.
|
|
303
|
+
* @param {SchemaProperty} property
|
|
304
|
+
* @returns {keyof typeof FIELD_TYPES}
|
|
305
|
+
*/
|
|
306
|
+
export declare function kindOf(property: SchemaProperty): keyof typeof FIELD_TYPES;
|
|
307
|
+
/** English texts of the type messages, used when the message function does not know the key. */
|
|
308
|
+
export declare const TYPE_MESSAGES: Readonly<{
|
|
309
|
+
string: "Enter text.";
|
|
310
|
+
number: "Enter a number.";
|
|
311
|
+
integer: "Enter a whole number.";
|
|
312
|
+
boolean: "Choose yes or no.";
|
|
313
|
+
array: "Choose from the list.";
|
|
314
|
+
}>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splitting streamed text into the operation lines of a surface.
|
|
3
|
+
*
|
|
4
|
+
* A surface arrives as JSON Lines. `lineSplitter()` turns string chunks of any size into whole
|
|
5
|
+
* lines, and `inlineSplitter()` separates the lines of a fenced surface from the prose of an answer
|
|
6
|
+
* that carries one, without holding the prose back.
|
|
7
|
+
*
|
|
8
|
+
* The module touches no DOM and imports nothing, so it runs unchanged in a browser and on a server.
|
|
9
|
+
*/
|
|
10
|
+
/** Longest line `lineSplitter()` buffers by default: 256 KiB of characters. */
|
|
11
|
+
export declare const MAX_LINE = 262144;
|
|
12
|
+
/** The line that opens a surface inside answer text. */
|
|
13
|
+
export declare const OPEN_FENCE = "```zx-surface";
|
|
14
|
+
/** The line that closes it. */
|
|
15
|
+
export declare const CLOSE_FENCE = "```";
|
|
16
|
+
export type StreamError = {
|
|
17
|
+
/**
|
|
18
|
+
* What went wrong.
|
|
19
|
+
*/
|
|
20
|
+
code: 'line-too-long' | 'unterminated-fence';
|
|
21
|
+
/**
|
|
22
|
+
* Human-readable description.
|
|
23
|
+
*/
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
export type LineSplitterOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* Longest line, in characters, that is buffered. A longer one
|
|
29
|
+
* is reported once and dropped up to its end rather than held in memory.
|
|
30
|
+
*/
|
|
31
|
+
maxLine?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Receives an over-long line's report.
|
|
34
|
+
*/
|
|
35
|
+
onerror?: (error: StreamError) => void;
|
|
36
|
+
};
|
|
37
|
+
export type StreamSplitter = {
|
|
38
|
+
/**
|
|
39
|
+
* Takes the next chunk. Chunk boundaries may fall
|
|
40
|
+
* anywhere, between `\r` and `\n` included.
|
|
41
|
+
*/
|
|
42
|
+
write: (chunk: string) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Flushes what is left: a last line without a line break is emitted.
|
|
45
|
+
* Writing after `end()` is ignored.
|
|
46
|
+
*/
|
|
47
|
+
end: () => void;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A problem found while splitting a stream.
|
|
51
|
+
* - `line-too-long`: a line grew past `maxLine`; it is dropped up to its end.
|
|
52
|
+
* - `unterminated-fence`: the text ended inside a surface fence.
|
|
53
|
+
* @typedef {Object} StreamError
|
|
54
|
+
* @property {'line-too-long'|'unterminated-fence'} code What went wrong.
|
|
55
|
+
* @property {string} message Human-readable description.
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Options of `lineSplitter()`.
|
|
59
|
+
* @typedef {Object} LineSplitterOptions
|
|
60
|
+
* @property {number} [maxLine=262144] Longest line, in characters, that is buffered. A longer one
|
|
61
|
+
* is reported once and dropped up to its end rather than held in memory.
|
|
62
|
+
* @property {(error: StreamError) => void} [onerror] Receives an over-long line's report.
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* What both splitters return: feed it chunks, then end it once.
|
|
66
|
+
* @typedef {Object} StreamSplitter
|
|
67
|
+
* @property {(chunk: string) => void} write Takes the next chunk. Chunk boundaries may fall
|
|
68
|
+
* anywhere, between `\r` and `\n` included.
|
|
69
|
+
* @property {() => void} end Flushes what is left: a last line without a line break is emitted.
|
|
70
|
+
* Writing after `end()` is ignored.
|
|
71
|
+
*/
|
|
72
|
+
/**
|
|
73
|
+
* Splits string chunks into whole lines. Lines end at `\n`; a `\r` right before it is removed, so
|
|
74
|
+
* `\r\n` works too. Every line is emitted, empty ones included, without its line break.
|
|
75
|
+
* @param {(line: string) => void} onLine Receives each complete line.
|
|
76
|
+
* @param {LineSplitterOptions} [options]
|
|
77
|
+
* @returns {StreamSplitter}
|
|
78
|
+
*/
|
|
79
|
+
export declare function lineSplitter(onLine: (line: string) => void, options?: LineSplitterOptions): StreamSplitter;
|
|
80
|
+
export type InlineSplitterOptions = {
|
|
81
|
+
/**
|
|
82
|
+
* Receives prose, as it arrives, unchanged.
|
|
83
|
+
*/
|
|
84
|
+
ontext?: (text: string) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Receives each line inside a surface fence.
|
|
87
|
+
*/
|
|
88
|
+
online?: (line: string) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Receives an over-long line inside a fence and
|
|
91
|
+
* a fence still open at `end()`.
|
|
92
|
+
*/
|
|
93
|
+
onerror?: (error: StreamError) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Longest line inside a fence.
|
|
96
|
+
*/
|
|
97
|
+
maxLine?: number;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Callbacks of `inlineSplitter()`.
|
|
101
|
+
* @typedef {Object} InlineSplitterOptions
|
|
102
|
+
* @property {(text: string) => void} [ontext] Receives prose, as it arrives, unchanged.
|
|
103
|
+
* @property {(line: string) => void} [online] Receives each line inside a surface fence.
|
|
104
|
+
* @property {(error: StreamError) => void} [onerror] Receives an over-long line inside a fence and
|
|
105
|
+
* a fence still open at `end()`.
|
|
106
|
+
* @property {number} [maxLine=262144] Longest line inside a fence.
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* Separates surface fences from the prose of an answer. A fence opens with a line reading exactly
|
|
110
|
+
* `` ```zx-surface `` and closes with a line reading exactly `` ``` ``; the fence lines themselves
|
|
111
|
+
* go nowhere, and each line between them goes to `online`. Prose goes to `ontext` as soon as it
|
|
112
|
+
* arrives: only the start of a line that could still turn out to be the opening fence is held
|
|
113
|
+
* back, and only until it can no longer be one. Any other line starting with three backticks stays
|
|
114
|
+
* prose.
|
|
115
|
+
* @param {InlineSplitterOptions} options
|
|
116
|
+
* @returns {StreamSplitter}
|
|
117
|
+
*/
|
|
118
|
+
export declare function inlineSplitter(options?: InlineSplitterOptions): StreamSplitter;
|