@petrarca/sonnet-core 0.8.0 → 0.9.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/README.md +18 -5
- package/dist/{chunk-XAEHYRXC.js → chunk-LOWDCP73.js} +1 -1
- package/dist/chunk-ZM3U3HR2.js +98 -0
- package/dist/chunk-ZM3U3HR2.js.map +1 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/entityOptions/index.d.ts +2 -2
- package/dist/hooks/index.d.ts +100 -3
- package/dist/hooks/index.js +123 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +35 -11
- package/dist/index.js.map +1 -1
- package/dist/lazyTree-C0oThxCS.d.ts +139 -0
- package/dist/logger/index.d.ts +6 -0
- package/dist/logger/index.js +13 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/schema/index.d.ts +106 -407
- package/dist/schema/index.js +408 -41
- package/dist/schema/index.js.map +1 -1
- package/dist/search/index.d.ts +18 -1
- package/dist/search/index.js +26 -1
- package/dist/search/index.js.map +1 -1
- package/dist/terminology/index.d.ts +161 -0
- package/dist/terminology/index.js +178 -0
- package/dist/terminology/index.js.map +1 -0
- package/dist/{types-DJ4hb97y.d.ts → types-BiFVnfqr.d.ts} +1 -1
- package/dist/types-HhzIKd1R.d.ts +582 -0
- package/package.json +18 -10
- /package/dist/{chunk-XAEHYRXC.js.map → chunk-LOWDCP73.js.map} +0 -0
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,382 +1,8 @@
|
|
|
1
|
+
import { J as JsonSchemaProperty, a as JsonSchema, U as UIRule, A as AdditionalBinding, C as ConceptCoding, b as CodeableConcept, F as FormDiff } from '../types-HhzIKd1R.js';
|
|
2
|
+
export { c as ArrayItemChange, B as Binding, d as BindingStrength, e as CODEABLE_CONCEPT_TYPE, f as CODEABLE_CONCEPT_TYPE_ID, g as CODING_TYPE, h as CODING_TYPE_ID, i as CORE_TYPES_BASE, j as CORE_VALUE_TYPES, k as Coding, l as CodingMatch, m as FieldDiff, Q as QUANTITY_TYPE, n as QUANTITY_TYPE_ID, o as Quantity, p as QuantityComparator, R as RefResolver, q as UCUM_SYSTEM, r as UILayoutConfig, s as UILayoutGroupConfig, t as UILayoutRowConfig, u as UIRuleCondition, v as UIRuleEffect, w as UISchema, x as UISchemaOptions, y as UIValidate, z as UIValidateRef, V as ValueChange, D as ValueType, W as WIDTH_TOKEN_REMS, E as WidthToken, G as bindingLists, H as bindingOf, I as codeToken, K as codingKey, L as coreType, M as coreTypeOf, N as parseCodeToken, O as resolveRefs, P as valueTypeResolver } from '../types-HhzIKd1R.js';
|
|
1
3
|
import Ajv from 'ajv';
|
|
2
4
|
import { z } from 'zod';
|
|
3
5
|
|
|
4
|
-
/**
|
|
5
|
-
* Generic JSON Schema type definitions.
|
|
6
|
-
*
|
|
7
|
-
* These types follow Draft 2020-12 and include x-ui-* extension points
|
|
8
|
-
* for form/widget integration. They are domain-agnostic -- no
|
|
9
|
-
* application-specific entity concepts live here.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* A declarative presentation rule (JSONForms-style) attached to a field.
|
|
13
|
-
*
|
|
14
|
-
* The rule lives on the field it controls (the target). Its `condition` points
|
|
15
|
-
* at another field's value via a JSON Pointer (RFC 6901) into the form DATA
|
|
16
|
-
* (rooted at the whole form), and validates that value against `condition.schema`.
|
|
17
|
-
* When the condition holds, `effect` is applied to the target:
|
|
18
|
-
* - "show" -- render only when the condition holds
|
|
19
|
-
* - "hide" -- render only when the condition does NOT hold
|
|
20
|
-
* - "enable" -- interactive only when the condition holds
|
|
21
|
-
* - "disable"-- non-interactive when the condition holds
|
|
22
|
-
*
|
|
23
|
-
* Example: show `pregnancy_status` when `gender` equals "female":
|
|
24
|
-
* ```json
|
|
25
|
-
* { "effect": "show",
|
|
26
|
-
* "condition": { "scope": "/gender", "schema": { "const": "female" } } }
|
|
27
|
-
* ```
|
|
28
|
-
* Unlike if/then/else, the target field stays declared at its own position, so
|
|
29
|
-
* layout placement is stable.
|
|
30
|
-
*/
|
|
31
|
-
interface UIRuleCondition {
|
|
32
|
-
/** JSON Pointer (RFC 6901) into the form data, e.g. "/gender" or "/patient/gender". */
|
|
33
|
-
scope: string;
|
|
34
|
-
/** Schema the value at `scope` is validated against (e.g. { const: "female" }). */
|
|
35
|
-
schema: JsonSchemaProperty;
|
|
36
|
-
}
|
|
37
|
-
type UIRuleEffect = "show" | "hide" | "enable" | "disable";
|
|
38
|
-
interface UIRule {
|
|
39
|
-
effect: UIRuleEffect;
|
|
40
|
-
condition: UIRuleCondition;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* A named validator reference carried by `x-ui-validate`. The bare-string form
|
|
44
|
-
* is the no-config common case (`"ibanValid"`); the object form supplies
|
|
45
|
-
* per-reference config and, for async form validators, the inputs that trigger
|
|
46
|
-
* a re-run (`dependsOn`). See the custom-validation design in sonnet-forms.
|
|
47
|
-
*/
|
|
48
|
-
interface UIValidateRef {
|
|
49
|
-
/** Registered validator name, resolved against the ValidatorRegistry. */
|
|
50
|
-
name: string;
|
|
51
|
-
/** Per-reference config, passed to the validator as `ctx.args`. */
|
|
52
|
-
args?: Record<string, unknown>;
|
|
53
|
-
/**
|
|
54
|
-
* For an async FORM validator: the field names whose values trigger a re-run.
|
|
55
|
-
* The engine keys/debounces the async result on these values. Ignored for
|
|
56
|
-
* sync validators and for field validators.
|
|
57
|
-
*/
|
|
58
|
-
dependsOn?: string[];
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* The value of `x-ui-validate`: one validator or a list. On a property it
|
|
62
|
-
* selects field validators (`(value, ctx) => ...`); on the root object it
|
|
63
|
-
* selects form validators (`(data, ctx) => FieldError[]`). A bare string is
|
|
64
|
-
* shorthand for `{ name }`.
|
|
65
|
-
*/
|
|
66
|
-
type UIValidate = string | UIValidateRef | Array<string | UIValidateRef>;
|
|
67
|
-
/**
|
|
68
|
-
* JSON Schema property definition following Draft 2020-12 specification.
|
|
69
|
-
* Supports basic types, validation constraints, conditionals, and custom extensions.
|
|
70
|
-
*/
|
|
71
|
-
type JsonSchemaProperty = {
|
|
72
|
-
type?: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
|
|
73
|
-
title?: string;
|
|
74
|
-
description?: string;
|
|
75
|
-
default?: any;
|
|
76
|
-
const?: any;
|
|
77
|
-
enum?: any[];
|
|
78
|
-
pattern?: string;
|
|
79
|
-
format?: string;
|
|
80
|
-
minLength?: number;
|
|
81
|
-
maxLength?: number;
|
|
82
|
-
minimum?: number;
|
|
83
|
-
maximum?: number;
|
|
84
|
-
exclusiveMinimum?: number;
|
|
85
|
-
exclusiveMaximum?: number;
|
|
86
|
-
items?: JsonSchemaProperty;
|
|
87
|
-
minItems?: number;
|
|
88
|
-
maxItems?: number;
|
|
89
|
-
properties?: Record<string, JsonSchemaProperty>;
|
|
90
|
-
required?: string[];
|
|
91
|
-
$ref?: string;
|
|
92
|
-
$defs?: Record<string, JsonSchemaProperty>;
|
|
93
|
-
definitions?: Record<string, JsonSchemaProperty>;
|
|
94
|
-
allOf?: JsonSchemaProperty[];
|
|
95
|
-
anyOf?: JsonSchemaProperty[];
|
|
96
|
-
oneOf?: JsonSchemaProperty[];
|
|
97
|
-
not?: JsonSchemaProperty;
|
|
98
|
-
/**
|
|
99
|
-
* Discriminator for a `oneOf` union (OpenAPI convention). `propertyName` is
|
|
100
|
-
* the shared property whose `const` value tags the active branch. When
|
|
101
|
-
* absent, the discriminator is auto-detected as the property that is const
|
|
102
|
-
* in every branch.
|
|
103
|
-
*/
|
|
104
|
-
discriminator?: {
|
|
105
|
-
propertyName: string;
|
|
106
|
-
};
|
|
107
|
-
if?: JsonSchemaProperty;
|
|
108
|
-
then?: JsonSchemaProperty;
|
|
109
|
-
else?: JsonSchemaProperty;
|
|
110
|
-
"x-ui-order"?: string[];
|
|
111
|
-
"x-ui-rule"?: UIRule;
|
|
112
|
-
"x-ui-widget"?: string;
|
|
113
|
-
"x-ui-options"?: Record<string, any>;
|
|
114
|
-
"x-ui-layout"?: UILayoutConfig;
|
|
115
|
-
"x-ui-title"?: string;
|
|
116
|
-
"x-ui-placeholder"?: string;
|
|
117
|
-
"x-ui-description"?: string;
|
|
118
|
-
"x-ui-validate"?: UIValidate;
|
|
119
|
-
"x-ui-column"?: {
|
|
120
|
-
/**
|
|
121
|
-
* Display order (ascending). Properties without an order are appended
|
|
122
|
-
* after the ordered ones, keeping their schema declaration order.
|
|
123
|
-
*/
|
|
124
|
-
order?: number;
|
|
125
|
-
/** Exclude this column from the table entirely. */
|
|
126
|
-
hidden?: boolean;
|
|
127
|
-
/** Fixed column width in pixels. */
|
|
128
|
-
width?: number;
|
|
129
|
-
/** Minimum column width in pixels. */
|
|
130
|
-
minWidth?: number;
|
|
131
|
-
};
|
|
132
|
-
/** Cell renderer name. Inferred from type+format when absent. */
|
|
133
|
-
"x-ui-cell"?: string;
|
|
134
|
-
/** Cell renderer configuration options (colors, href template, etc.). */
|
|
135
|
-
"x-ui-cell-options"?: Record<string, unknown>;
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* JSON Schema following Draft 2020-12 specification.
|
|
139
|
-
*
|
|
140
|
-
* This is the generic base type. Domain-specific consumers extend it
|
|
141
|
-
* with their own x-* extension keys via intersection types in their
|
|
142
|
-
* own type files.
|
|
143
|
-
*/
|
|
144
|
-
type JsonSchema = {
|
|
145
|
-
$schema?: string;
|
|
146
|
-
title: string;
|
|
147
|
-
type: "object";
|
|
148
|
-
properties: Record<string, JsonSchemaProperty>;
|
|
149
|
-
required?: string[];
|
|
150
|
-
allOf?: JsonSchemaProperty[];
|
|
151
|
-
anyOf?: JsonSchemaProperty[];
|
|
152
|
-
oneOf?: JsonSchemaProperty[];
|
|
153
|
-
not?: JsonSchemaProperty;
|
|
154
|
-
if?: JsonSchemaProperty;
|
|
155
|
-
then?: JsonSchemaProperty;
|
|
156
|
-
else?: JsonSchemaProperty;
|
|
157
|
-
$defs?: Record<string, JsonSchemaProperty>;
|
|
158
|
-
definitions?: Record<string, JsonSchemaProperty>;
|
|
159
|
-
"x-ui-order"?: string[];
|
|
160
|
-
"x-ui-validate"?: UIValidate;
|
|
161
|
-
[key: `x-${string}`]: unknown;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* WidthToken -- the shared semantic sizing vocabulary used across the form
|
|
165
|
-
* layout system: per-field slot width (x-ui-width) and per-column width
|
|
166
|
-
* (UILayoutRowConfig.widths). "full" fills available space; sm/md/lg are
|
|
167
|
-
* fixed inline sizes. Raw CSS remains available as an advanced escape hatch.
|
|
168
|
-
*/
|
|
169
|
-
type WidthToken = "sm" | "md" | "lg" | "full";
|
|
170
|
-
/**
|
|
171
|
-
* The fixed rem values for each non-full WidthToken. This is the single source
|
|
172
|
-
* of truth for token sizing used by:
|
|
173
|
-
* - the CSS grid track map in JsonSchemaFormRenderer (sm -> "8rem" track)
|
|
174
|
-
* - the Tailwind class map in FormFieldRenderer (sm -> w-32 = 8rem)
|
|
175
|
-
* Consumers that need px can multiply by 16.
|
|
176
|
-
*/
|
|
177
|
-
declare const WIDTH_TOKEN_REMS: Record<WidthToken, string>;
|
|
178
|
-
/**
|
|
179
|
-
* UISchema - User Interface Schema configuration.
|
|
180
|
-
*
|
|
181
|
-
* Defines how form fields should be rendered and behave in the UI.
|
|
182
|
-
* Separate from JSON Schema (which defines data structure) and focuses
|
|
183
|
-
* on presentation, widgets, and user interaction.
|
|
184
|
-
*/
|
|
185
|
-
interface UISchema {
|
|
186
|
-
/** Widget name (string) or direct component reference */
|
|
187
|
-
"x-ui-widget"?: string | object;
|
|
188
|
-
"x-ui-options"?: UISchemaOptions;
|
|
189
|
-
"x-ui-globalOptions"?: UISchemaOptions;
|
|
190
|
-
"x-ui-order"?: string[];
|
|
191
|
-
/** Declarative show/hide or enable/disable rule (see UIRule). */
|
|
192
|
-
"x-ui-rule"?: UIRule;
|
|
193
|
-
/** Custom validators by name (override of the schema-level x-ui-validate). */
|
|
194
|
-
"x-ui-validate"?: UIValidate;
|
|
195
|
-
"x-ui-title"?: string | false;
|
|
196
|
-
"x-ui-description"?: string;
|
|
197
|
-
"x-ui-placeholder"?: string;
|
|
198
|
-
/** Semantic field-slot width (default "full"). */
|
|
199
|
-
"x-ui-width"?: WidthToken;
|
|
200
|
-
/** Column override -- merged over schema-level x-ui-column, UI schema wins. */
|
|
201
|
-
"x-ui-column"?: JsonSchemaProperty["x-ui-column"] & {
|
|
202
|
-
label?: string;
|
|
203
|
-
};
|
|
204
|
-
/** Cell renderer override. */
|
|
205
|
-
"x-ui-cell"?: string;
|
|
206
|
-
/** Cell renderer options override -- shallow-merged over schema-level x-ui-cell-options. */
|
|
207
|
-
"x-ui-cell-options"?: Record<string, unknown>;
|
|
208
|
-
/** Per-field UISchema for nested sub-forms (ObjectWidget / ArrayWidget) */
|
|
209
|
-
"x-ui-fields"?: {
|
|
210
|
-
[fieldName: string]: UISchema;
|
|
211
|
-
};
|
|
212
|
-
/** Layout config forwarded to the active template (ObjectWidget / ArrayWidget) */
|
|
213
|
-
"x-ui-layout"?: UILayoutConfig;
|
|
214
|
-
/** Extension keys not yet enumerated above */
|
|
215
|
-
[key: `x-ui-${string}`]: unknown;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* UILayoutRowConfig -- one horizontal row in a multi-column object form layout.
|
|
219
|
-
*
|
|
220
|
-
* `fields` lists the field names to place in this row, left to right.
|
|
221
|
-
* Column sizing (grid mode) is resolved in this precedence:
|
|
222
|
-
* 1. `columns` -- raw CSS grid-template-columns (advanced escape hatch).
|
|
223
|
-
* 2. `widths` -- per-cell semantic tokens (the designer-friendly path).
|
|
224
|
-
* 3. default -- equal 1fr per field.
|
|
225
|
-
* `gap` overrides the parent layout gap for this row only.
|
|
226
|
-
*
|
|
227
|
-
* `group` renders the row inside a titled fieldset (presentation-only grouping
|
|
228
|
-
* over flat schema fields -- the data shape is unchanged).
|
|
229
|
-
*
|
|
230
|
-
* Examples:
|
|
231
|
-
* { fields: ["first_name", "last_name"], widths: ["md", "full"] }
|
|
232
|
-
* { fields: ["npi", "specialty", "email"], columns: "20% 1fr 1fr" }
|
|
233
|
-
* { group: "Contact", fields: ["email", "phone"] }
|
|
234
|
-
*/
|
|
235
|
-
interface UILayoutRowConfig {
|
|
236
|
-
fields: string[];
|
|
237
|
-
columns?: string;
|
|
238
|
-
/**
|
|
239
|
-
* Per-cell semantic widths, aligned to `fields` by index. Translated to grid
|
|
240
|
-
* tracks: sm/md/lg -> fixed rem tracks, full -> 1fr. Ignored when `columns`
|
|
241
|
-
* is set (raw CSS wins) or in "flow" mode. Missing/short entries default to
|
|
242
|
-
* "full".
|
|
243
|
-
*/
|
|
244
|
-
widths?: WidthToken[];
|
|
245
|
-
gap?: number;
|
|
246
|
-
/**
|
|
247
|
-
* Optional title. When set, the row renders inside a <fieldset> with a
|
|
248
|
-
* <legend>, grouping its fields visually without nesting them in the schema.
|
|
249
|
-
*/
|
|
250
|
-
group?: string;
|
|
251
|
-
/**
|
|
252
|
-
* How this row arranges its fields:
|
|
253
|
-
* - "grid" (default): CSS grid using `columns`/`widths` (equal 1fr per field
|
|
254
|
-
* when neither is set).
|
|
255
|
-
* - "flow": flex row, fields at their natural width, left-to-right, wrapping.
|
|
256
|
-
* Use for compact toolbars / tight field groups. `columns`/`widths` are
|
|
257
|
-
* ignored.
|
|
258
|
-
*/
|
|
259
|
-
arrange?: "grid" | "flow";
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* One named group of a grouped form layout. A group holds rows of fields under
|
|
263
|
-
* a label; the data stays flat (grouping is presentation only, like `group` on
|
|
264
|
-
* a single row). How groups are shown -- tabs, wizard steps, stacked sections
|
|
265
|
-
* -- is chosen by {@link UILayoutConfig.variant}, not by this structure.
|
|
266
|
-
*
|
|
267
|
-
* A group may carry an `x-ui-rule`-style {@link UIRule} to appear conditionally
|
|
268
|
-
* (e.g. show an "Address" group only when "provide address" is checked). The
|
|
269
|
-
* rule is evaluated against the form data exactly as a field-level rule is.
|
|
270
|
-
*/
|
|
271
|
-
interface UILayoutGroupConfig {
|
|
272
|
-
/** Label shown on the group's trigger or heading. */
|
|
273
|
-
label: string;
|
|
274
|
-
/** Rows of fields in this group (same shape as UILayoutConfig.rows). */
|
|
275
|
-
rows: UILayoutRowConfig[];
|
|
276
|
-
/**
|
|
277
|
-
* Optional show/hide rule for the whole group: a hidden group disappears
|
|
278
|
-
* along with its fields. Narrowed to the visibility effects -- a disabled
|
|
279
|
-
* group has no meaning, and permitting the effect would let it be authored
|
|
280
|
-
* and then silently ignored.
|
|
281
|
-
*/
|
|
282
|
-
rule?: UIRule & {
|
|
283
|
-
effect: "show" | "hide";
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* UILayoutConfig -- layout configuration for ObjectWidget and ArrayWidget.
|
|
288
|
-
*
|
|
289
|
-
* Configures the built-in default templates. Has no effect when a custom
|
|
290
|
-
* template is registered for the field.
|
|
291
|
-
*/
|
|
292
|
-
interface UILayoutConfig {
|
|
293
|
-
direction?: "vertical" | "horizontal";
|
|
294
|
-
rows?: UILayoutRowConfig[];
|
|
295
|
-
groups?: UILayoutGroupConfig[];
|
|
296
|
-
variant?: "tabs" | "stepper" | "sections" | (string & {});
|
|
297
|
-
columns?: string;
|
|
298
|
-
gap?: number;
|
|
299
|
-
labels?: boolean;
|
|
300
|
-
compact?: boolean;
|
|
301
|
-
labelPlacement?: "top" | "start";
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* ValueChange -- a single scalar or nested-object field that changed value.
|
|
305
|
-
*
|
|
306
|
-
* `path` is a dot-separated field path: "name", "address.city".
|
|
307
|
-
*/
|
|
308
|
-
type ValueChange = {
|
|
309
|
-
type: "value";
|
|
310
|
-
path: string;
|
|
311
|
-
from: unknown;
|
|
312
|
-
to: unknown;
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* ArrayItemChange -- one item-level change within an array field.
|
|
316
|
-
*
|
|
317
|
-
* Items are identified by their form-internal `_fid` (never the server ID).
|
|
318
|
-
* A single item can appear as both "moved" and "modified" if it was
|
|
319
|
-
* repositioned and its values also changed -- these are emitted as two
|
|
320
|
-
* separate entries with the same `fid`.
|
|
321
|
-
*/
|
|
322
|
-
type ArrayItemChange = {
|
|
323
|
-
type: "added";
|
|
324
|
-
fid: string;
|
|
325
|
-
index: number;
|
|
326
|
-
item: unknown;
|
|
327
|
-
} | {
|
|
328
|
-
type: "removed";
|
|
329
|
-
fid: string;
|
|
330
|
-
index: number;
|
|
331
|
-
item: unknown;
|
|
332
|
-
} | {
|
|
333
|
-
type: "moved";
|
|
334
|
-
fid: string;
|
|
335
|
-
from: number;
|
|
336
|
-
to: number;
|
|
337
|
-
} | {
|
|
338
|
-
type: "modified";
|
|
339
|
-
fid: string;
|
|
340
|
-
index: number;
|
|
341
|
-
changes: ValueChange[];
|
|
342
|
-
};
|
|
343
|
-
/**
|
|
344
|
-
* FieldDiff -- the diff for one top-level form field.
|
|
345
|
-
*/
|
|
346
|
-
type FieldDiff = ValueChange | {
|
|
347
|
-
type: "array";
|
|
348
|
-
field: string;
|
|
349
|
-
changes: ArrayItemChange[];
|
|
350
|
-
};
|
|
351
|
-
/**
|
|
352
|
-
* FormDiff -- structured diff produced by diffFormData().
|
|
353
|
-
*
|
|
354
|
-
* One entry per changed top-level field. Fields whose value is deeply
|
|
355
|
-
* equal between original and updated are omitted.
|
|
356
|
-
*/
|
|
357
|
-
type FormDiff = FieldDiff[];
|
|
358
|
-
/**
|
|
359
|
-
* UISchemaOptions - Widget configuration options.
|
|
360
|
-
*/
|
|
361
|
-
interface UISchemaOptions {
|
|
362
|
-
label?: string | false;
|
|
363
|
-
disabled?: boolean;
|
|
364
|
-
readonly?: boolean;
|
|
365
|
-
compact?: boolean;
|
|
366
|
-
enumNames?: Record<string | number, string>;
|
|
367
|
-
inputType?: string;
|
|
368
|
-
rows?: number;
|
|
369
|
-
searchable?: boolean;
|
|
370
|
-
clearable?: boolean;
|
|
371
|
-
/** Allow the user to type and submit a value not in the enum list (combobox / open-choice). */
|
|
372
|
-
creatable?: boolean;
|
|
373
|
-
/** Label placement: "top" (default, above) or "start" (inline, RTL-safe). */
|
|
374
|
-
labelPlacement?: "top" | "start";
|
|
375
|
-
/** Semantic field-slot width (default "full"). */
|
|
376
|
-
width?: WidthToken;
|
|
377
|
-
[key: string]: any;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
6
|
/**
|
|
381
7
|
* Schema Service - Pure functions for JSON Schema manipulation.
|
|
382
8
|
*
|
|
@@ -405,11 +31,28 @@ declare function getFieldType(property: JsonSchemaProperty): JsonSchemaType;
|
|
|
405
31
|
* Used for tri-state checkbox rendering.
|
|
406
32
|
*/
|
|
407
33
|
declare function isNullableBoolean(property: JsonSchemaProperty): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Lift the non-null member of a nullable `anyOf` onto the property.
|
|
36
|
+
*
|
|
37
|
+
* Pydantic and Zod emit `Optional[T]` as `{ anyOf: [{ type: T, ...keywords },
|
|
38
|
+
* { type: "null" }], title, default }`: the keywords a widget reads (`minimum`,
|
|
39
|
+
* `maximum`, `minLength`, `pattern`, `format`, `items`) sit on the member, out of
|
|
40
|
+
* reach of `propertySchema.minimum`. This returns the property with the
|
|
41
|
+
* member's keywords merged in -- the property's own keys (title, description,
|
|
42
|
+
* default, x-ui-*) win -- and `anyOf` kept, so nullability checks
|
|
43
|
+
* (`isNullableBoolean`, `isFieldOptional`) still see it.
|
|
44
|
+
*
|
|
45
|
+
* Any other shape -- no anyOf, several non-null members, an object member -- is
|
|
46
|
+
* returned unchanged.
|
|
47
|
+
*/
|
|
48
|
+
declare function liftNullableMember(property: JsonSchemaProperty): JsonSchemaProperty;
|
|
408
49
|
/**
|
|
409
50
|
* Extract enum values from a property schema.
|
|
410
51
|
*
|
|
411
|
-
* Handles
|
|
412
|
-
*
|
|
52
|
+
* Handles the simple case (`{ enum: [...] }`), the nullable pattern produced
|
|
53
|
+
* by Zod (`{ anyOf: [{ type: "string", enum: [...] }, { type: "null" }] }`),
|
|
54
|
+
* and an array of enum items (`{ type: "array", items: { enum: [...] } }`) --
|
|
55
|
+
* the choices of a multi-select.
|
|
413
56
|
*
|
|
414
57
|
* Returns the enum array if found, or an empty array.
|
|
415
58
|
*/
|
|
@@ -617,6 +260,8 @@ declare function evaluateUiRule(rule: UIRule | undefined, formData: unknown): Ru
|
|
|
617
260
|
* For each property in the schema that has a `default` value, if the
|
|
618
261
|
* corresponding key is absent (`undefined`) in `data`, the default is applied.
|
|
619
262
|
* Existing values — including `null` and `false` — are never overwritten.
|
|
263
|
+
* A nested object's properties are filled the same way, at any depth -- a
|
|
264
|
+
* group absent from `data` is added when one of its properties has a default.
|
|
620
265
|
*
|
|
621
266
|
* @param data - Existing form data (may be partial)
|
|
622
267
|
* @param schema - JSON Schema containing property defaults
|
|
@@ -626,8 +271,9 @@ declare function applySchemaDefaults(data: Record<string, unknown>, schema: Json
|
|
|
626
271
|
/**
|
|
627
272
|
* Extract all default values declared in a JSON Schema.
|
|
628
273
|
*
|
|
629
|
-
* Walks the schema's
|
|
630
|
-
*
|
|
274
|
+
* Walks the schema's properties and collects any `default` values -- a
|
|
275
|
+
* nested object's at any depth, under its key. Properties without a
|
|
276
|
+
* `default` are omitted from the result.
|
|
631
277
|
*
|
|
632
278
|
* @param schema - JSON Schema to extract defaults from
|
|
633
279
|
* @returns Record of field names to their default values
|
|
@@ -704,36 +350,80 @@ declare function generateJsonSchemaFromVariables(variables: string[], existingSc
|
|
|
704
350
|
declare function toJsonSchema(schema: z.ZodType): JsonSchema;
|
|
705
351
|
|
|
706
352
|
/**
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
* A caller may inject a `RefResolver` to resolve ANY ref string (e.g. a schema
|
|
714
|
-
* registry id like `sdf_...`, or a canonical URI). The injected resolver is
|
|
715
|
-
* tried first; the in-document `$defs`/`definitions` lookup is the fallback, so
|
|
716
|
-
* both ref styles work together. The resolver is synchronous: consumers that
|
|
717
|
-
* fetch schemas asynchronously (e.g. from a registry over HTTP) pre-load them
|
|
718
|
-
* into a map and pass a `(ref) => map[ref]` lookup. This keeps the toolkit pure
|
|
719
|
-
* (no HTTP, no async).
|
|
720
|
-
*
|
|
721
|
-
* Properties on the referencing node are merged on top of the resolved target,
|
|
722
|
-
* so context-specific overrides (e.g. a custom title) work without duplicating
|
|
723
|
-
* the definition. Refs that no resolver can satisfy are left as-is.
|
|
353
|
+
* A codeable concept's codings by its lists -- shared by its widget and its
|
|
354
|
+
* validation. A list on a code system claims the coding of that system; a list
|
|
355
|
+
* on a value set -- whose codes carry the system of the code system they come
|
|
356
|
+
* from -- takes the codings left, in their order. A coding no list claims is
|
|
357
|
+
* one of a list the field does not name. See docs/design/codeable-concepts.md
|
|
358
|
+
* (workspace).
|
|
724
359
|
*/
|
|
725
360
|
|
|
726
|
-
/**
|
|
727
|
-
|
|
361
|
+
/** A value as a codeable concept: an object, else an empty one. */
|
|
362
|
+
declare function conceptOf(value: unknown): CodeableConcept;
|
|
363
|
+
/** A value's codings by list -- the lists in their order -- and those of no list. */
|
|
364
|
+
declare function codingsByList(value: unknown, lists: AdditionalBinding[]): {
|
|
365
|
+
byList: (ConceptCoding | undefined)[];
|
|
366
|
+
others: ConceptCoding[];
|
|
367
|
+
};
|
|
368
|
+
/** What a list is called beside the others: its title, its purpose's label, else its identifier's last part. */
|
|
369
|
+
declare function listTitle(list: AdditionalBinding): string;
|
|
728
370
|
/**
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
371
|
+
* The required lists a value has no coding of. Only a value with codings is
|
|
372
|
+
* held to them: a text alone is the answer when no code fits.
|
|
373
|
+
*/
|
|
374
|
+
declare function missingLists(prop: JsonSchemaProperty, value: unknown): AdditionalBinding[];
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* A property of a value type: its `$ref` -- or, when it also takes a text of
|
|
378
|
+
* one's own, `anyOf: [{ $ref }, { type: "string" }]`. The second is the open
|
|
379
|
+
* question of FHIR (R4 `open-choice`, R5 `optionsOrString`) and openEHR's
|
|
380
|
+
* `DV_TEXT` where `DV_CODED_TEXT` is offered: the answer is a value of the
|
|
381
|
+
* type, or a text -- never a value of the type without its own content. See
|
|
382
|
+
* docs/design/coded-values.md (workspace).
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
/** The value type a property is of, whether it also takes a text, and whether it takes several. */
|
|
386
|
+
interface ValueRef {
|
|
387
|
+
ref: string;
|
|
388
|
+
orText: boolean;
|
|
389
|
+
/** Several answers: an array of the type (or of it or a text). */
|
|
390
|
+
multiple: boolean;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* The value type of a property: its `$ref`, or that of a `$ref` or a text --
|
|
394
|
+
* or of an array of either, for several answers; undefined for none of them.
|
|
395
|
+
*/
|
|
396
|
+
declare function valueRefOf(prop: JsonSchemaProperty): ValueRef | undefined;
|
|
397
|
+
/**
|
|
398
|
+
* The keywords of a property of a value type -- its `$ref`, or that or a text;
|
|
399
|
+
* several answers an array of it -- the others undefined, so writing them
|
|
400
|
+
* replaces the shape a property had.
|
|
735
401
|
*/
|
|
736
|
-
declare function
|
|
402
|
+
declare function valueRefKeywords(ref: string, orText: boolean, multiple?: boolean): Pick<JsonSchemaProperty, "$ref" | "anyOf" | "type" | "items">;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* A quantity's range per unit -- 0 to 300 kg, 0 to 660 lb -- in standard JSON
|
|
406
|
+
* Schema, beside the quantity's `$ref`: one `allOf` entry per unit, "if the
|
|
407
|
+
* unit is kg, then the value is in its range". A range is the unit's, as a
|
|
408
|
+
* number means nothing without one. See docs/design/core-types.md.
|
|
409
|
+
*/
|
|
410
|
+
|
|
411
|
+
/** A unit's range: its least and greatest value, either optional. */
|
|
412
|
+
interface UnitRange {
|
|
413
|
+
min?: number;
|
|
414
|
+
max?: number;
|
|
415
|
+
}
|
|
416
|
+
/** The ranges of a quantity's units, by unit code. */
|
|
417
|
+
type UnitRanges = Record<string, UnitRange>;
|
|
418
|
+
/**
|
|
419
|
+
* The ranges a quantity's schema sets per unit; empty when it sets none, and
|
|
420
|
+
* undefined when its `allOf` says something else -- not ranges to edit.
|
|
421
|
+
*/
|
|
422
|
+
declare function unitRangesOf(prop: JsonSchemaProperty): UnitRanges | undefined;
|
|
423
|
+
/** The keywords that set a quantity's ranges, by unit; a unit without a bound sets none. */
|
|
424
|
+
declare function unitRangesKeywords(ranges: UnitRanges): {
|
|
425
|
+
allOf?: JsonSchemaProperty[];
|
|
426
|
+
};
|
|
737
427
|
|
|
738
428
|
/**
|
|
739
429
|
* Recursive form data validation against a JSON Schema.
|
|
@@ -874,5 +564,14 @@ declare function diffFormData(original: Record<string, unknown>, updated: Record
|
|
|
874
564
|
* declares. Returns the input unchanged when nothing needed stamping.
|
|
875
565
|
*/
|
|
876
566
|
declare function ensureFormItemIds(data: Record<string, unknown>, schema: JsonSchema): Record<string, unknown>;
|
|
567
|
+
/**
|
|
568
|
+
* Return `data` without any `_fid` -- the inverse of `ensureFormItemIds`.
|
|
569
|
+
*
|
|
570
|
+
* Item ids are the renderer's own bookkeeping: they must not reach a consumer
|
|
571
|
+
* nor be validated against the schema (an item schema with
|
|
572
|
+
* `additionalProperties: false` would reject them).
|
|
573
|
+
*/
|
|
574
|
+
declare function stripFormItemIds(data: Record<string, unknown>): Record<string, unknown>;
|
|
877
575
|
|
|
878
|
-
export {
|
|
576
|
+
export { AdditionalBinding, CodeableConcept, ConceptCoding, FormDiff, JsonSchema, JsonSchemaProperty, UIRule, ajv, applySchemaDefaults, codingsByList, conceptOf, diffFormData, ensureFormItemIds, evaluateUiRule, extractEnumValues, extractSchemaDefaults, findActiveBranch, generateJsonSchemaFromVariables, getAtPointer, getBranchLabel, getBranchValue, getDiscriminator, getFieldConstraints, getFieldDefault, getFieldHelpText, getFieldPlaceholder, getFieldTitle, getFieldType, getFieldWidget, getOptionalFields, getRequiredFields, getSchemaProperties, hasConditionals, hasProperties, isFieldOptional, isFieldRequired, isNullableBoolean, isOneOf, liftNullableMember, listTitle, matchesConst, mergeFieldErrors, missingLists, resolveSchema, stripFormItemIds, toJsonSchema, unitRangesKeywords, unitRangesOf, validateContentConstraints, validateFormData, validateSchema, valueRefKeywords, valueRefOf };
|
|
577
|
+
export type { FieldError, RuleState, UnitRange, UnitRanges, ValidationResult, ValueRef };
|