@elastic/isomer-sdk 0.2.0 → 0.3.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/NOTICE.txt +0 -286
- package/THIRD_PARTY_LICENSES.md +1 -885
- package/dist/author/authored_fields.d.ts +37 -12
- package/dist/author/authored_fields.d.ts.map +1 -1
- package/dist/author/authored_fields.js +45 -69
- package/dist/author/authored_fields.js.map +1 -1
- package/dist/author/authoring_input.d.ts.map +1 -1
- package/dist/author/authoring_input.js +12 -6
- package/dist/author/authoring_input.js.map +1 -1
- package/dist/author/authoring_model.d.ts +8 -2
- package/dist/author/authoring_model.d.ts.map +1 -1
- package/dist/author/authoring_model.js +67 -23
- package/dist/author/authoring_model.js.map +1 -1
- package/dist/author/declarations.d.ts.map +1 -1
- package/dist/author/declarations.js +45 -34
- package/dist/author/declarations.js.map +1 -1
- package/dist/author/index.d.ts +2 -1
- package/dist/author/index.d.ts.map +1 -1
- package/dist/author/index.js +2 -1
- package/dist/author/index.js.map +1 -1
- package/dist/author/jsx_shim.d.ts +49 -30
- package/dist/author/jsx_shim.d.ts.map +1 -1
- package/dist/author/jsx_shim.js +131 -40
- package/dist/author/jsx_shim.js.map +1 -1
- package/dist/author/print_jsx.d.ts +19 -0
- package/dist/author/print_jsx.d.ts.map +1 -0
- package/dist/author/print_jsx.js +372 -0
- package/dist/author/print_jsx.js.map +1 -0
- package/dist/author/prompt.d.ts +2 -2
- package/dist/author/prompt.d.ts.map +1 -1
- package/dist/author/prompt.js +7 -2
- package/dist/author/prompt.js.map +1 -1
- package/dist/author/schema_to_typescript.d.ts.map +1 -1
- package/dist/author/schema_to_typescript.js +6 -3
- package/dist/author/schema_to_typescript.js.map +1 -1
- package/dist/cjs/author/authored_fields.js +47 -70
- package/dist/cjs/author/authored_fields.js.map +1 -1
- package/dist/cjs/author/authoring_input.js +12 -6
- package/dist/cjs/author/authoring_input.js.map +1 -1
- package/dist/cjs/author/authoring_model.js +69 -24
- package/dist/cjs/author/authoring_model.js.map +1 -1
- package/dist/cjs/author/declarations.js +44 -33
- package/dist/cjs/author/declarations.js.map +1 -1
- package/dist/cjs/author/index.js +5 -1
- package/dist/cjs/author/index.js.map +1 -1
- package/dist/cjs/author/jsx_shim.js +130 -39
- package/dist/cjs/author/jsx_shim.js.map +1 -1
- package/dist/cjs/author/print_jsx.js +378 -0
- package/dist/cjs/author/print_jsx.js.map +1 -0
- package/dist/cjs/author/prompt.js +7 -2
- package/dist/cjs/author/prompt.js.map +1 -1
- package/dist/cjs/author/schema_to_typescript.js +6 -3
- package/dist/cjs/author/schema_to_typescript.js.map +1 -1
- package/dist/cjs/composition/error.js +1 -0
- package/dist/cjs/composition/error.js.map +1 -1
- package/dist/cjs/composition/structured_value.js.map +1 -1
- package/dist/cjs/define/primitive_module.js +10 -4
- package/dist/cjs/define/primitive_module.js.map +1 -1
- package/dist/cjs/entries/index.js +3 -2
- package/dist/cjs/entries/index.js.map +1 -1
- package/dist/cjs/entries/markdown.js +2 -1
- package/dist/cjs/entries/markdown.js.map +1 -1
- package/dist/cjs/pack/index.js +2 -1
- package/dist/cjs/pack/index.js.map +1 -1
- package/dist/cjs/pack/primitive_pack.js +14 -4
- package/dist/cjs/pack/primitive_pack.js.map +1 -1
- package/dist/cjs/render/format_number.js +2 -1
- package/dist/cjs/render/format_number.js.map +1 -1
- package/dist/cjs/render/html/envelope.js +12 -6
- package/dist/cjs/render/html/envelope.js.map +1 -1
- package/dist/cjs/render/markdown/builder.js +6 -2
- package/dist/cjs/render/markdown/builder.js.map +1 -1
- package/dist/cjs/render/markdown/format.js +46 -24
- package/dist/cjs/render/markdown/format.js.map +1 -1
- package/dist/cjs/render/markdown/host_tags.js +67 -0
- package/dist/cjs/render/markdown/host_tags.js.map +1 -0
- package/dist/cjs/render/markdown/index.js +3 -1
- package/dist/cjs/render/markdown/index.js.map +1 -1
- package/dist/cjs/render/markdown/split.js +325 -0
- package/dist/cjs/render/markdown/split.js.map +1 -0
- package/dist/cjs/render/react/content.js +3 -1
- package/dist/cjs/render/react/content.js.map +1 -1
- package/dist/cjs/render/slack/markdown_content.js +7 -1
- package/dist/cjs/render/slack/markdown_content.js.map +1 -1
- package/dist/cjs/validate/json_schema.js +10 -3
- package/dist/cjs/validate/json_schema.js.map +1 -1
- package/dist/cjs/validate/url.js +2 -1
- package/dist/cjs/validate/url.js.map +1 -1
- package/dist/composition/error.d.ts +1 -0
- package/dist/composition/error.d.ts.map +1 -1
- package/dist/composition/error.js +1 -0
- package/dist/composition/error.js.map +1 -1
- package/dist/composition/structured_value.d.ts +3 -3
- package/dist/composition/structured_value.d.ts.map +1 -1
- package/dist/composition/structured_value.js.map +1 -1
- package/dist/define/primitive_module.d.ts +7 -0
- package/dist/define/primitive_module.d.ts.map +1 -1
- package/dist/define/primitive_module.js +10 -4
- package/dist/define/primitive_module.js.map +1 -1
- package/dist/entries/index.d.ts +1 -1
- package/dist/entries/index.d.ts.map +1 -1
- package/dist/entries/index.js +1 -1
- package/dist/entries/index.js.map +1 -1
- package/dist/entries/markdown.d.ts +1 -1
- package/dist/entries/markdown.d.ts.map +1 -1
- package/dist/entries/markdown.js +1 -1
- package/dist/entries/markdown.js.map +1 -1
- package/dist/pack/index.d.ts +1 -1
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +1 -1
- package/dist/pack/index.js.map +1 -1
- package/dist/pack/primitive_pack.d.ts +3 -1
- package/dist/pack/primitive_pack.d.ts.map +1 -1
- package/dist/pack/primitive_pack.js +13 -3
- package/dist/pack/primitive_pack.js.map +1 -1
- package/dist/render/format_number.d.ts.map +1 -1
- package/dist/render/format_number.js +2 -1
- package/dist/render/format_number.js.map +1 -1
- package/dist/render/html/envelope.js +12 -6
- package/dist/render/html/envelope.js.map +1 -1
- package/dist/render/markdown/builder.d.ts +3 -0
- package/dist/render/markdown/builder.d.ts.map +1 -1
- package/dist/render/markdown/builder.js +3 -1
- package/dist/render/markdown/builder.js.map +1 -1
- package/dist/render/markdown/format.d.ts +2 -0
- package/dist/render/markdown/format.d.ts.map +1 -1
- package/dist/render/markdown/format.js +42 -22
- package/dist/render/markdown/format.js.map +1 -1
- package/dist/render/markdown/host_tags.d.ts +14 -0
- package/dist/render/markdown/host_tags.d.ts.map +1 -0
- package/dist/render/markdown/host_tags.js +63 -0
- package/dist/render/markdown/host_tags.js.map +1 -0
- package/dist/render/markdown/index.d.ts +1 -0
- package/dist/render/markdown/index.d.ts.map +1 -1
- package/dist/render/markdown/index.js +1 -0
- package/dist/render/markdown/index.js.map +1 -1
- package/dist/render/markdown/split.d.ts +32 -0
- package/dist/render/markdown/split.d.ts.map +1 -0
- package/dist/render/markdown/split.js +321 -0
- package/dist/render/markdown/split.js.map +1 -0
- package/dist/render/react/content.d.ts +1 -1
- package/dist/render/react/content.d.ts.map +1 -1
- package/dist/render/react/content.js +3 -1
- package/dist/render/react/content.js.map +1 -1
- package/dist/render/slack/markdown_content.d.ts.map +1 -1
- package/dist/render/slack/markdown_content.js +7 -1
- package/dist/render/slack/markdown_content.js.map +1 -1
- package/dist/validate/json_schema.d.ts.map +1 -1
- package/dist/validate/json_schema.js +10 -3
- package/dist/validate/json_schema.js.map +1 -1
- package/dist/validate/url.d.ts.map +1 -1
- package/dist/validate/url.js +2 -1
- package/dist/validate/url.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { ZodType } from 'zod';
|
|
3
3
|
import type { PrimitiveNode } from '../define/primitive_module.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Member name of the child component a schema field is filled from.
|
|
6
6
|
*
|
|
7
7
|
* `Symbol.for`: ESM and CJS builds must agree, same as `authorType`.
|
|
8
8
|
*/
|
|
@@ -11,6 +11,8 @@ export declare const authoredChild: unique symbol;
|
|
|
11
11
|
export declare const authoredProps: unique symbol;
|
|
12
12
|
/** Set when a field is filled from text children. */
|
|
13
13
|
export declare const authoredText: unique symbol;
|
|
14
|
+
/** Set when a field is filled from primitive elements no other field claims. */
|
|
15
|
+
export declare const authoredNodes: unique symbol;
|
|
14
16
|
/** Holds a {@link fromChildren} brand's `toItem`. */
|
|
15
17
|
export declare const authoredToItem: unique symbol;
|
|
16
18
|
/**
|
|
@@ -31,6 +33,10 @@ export interface AuthoredToItemBrand {
|
|
|
31
33
|
export interface AuthoredTextBrand {
|
|
32
34
|
readonly [authoredText]: true;
|
|
33
35
|
}
|
|
36
|
+
/** A field filled from primitive elements, like a child slot the tree walk does not visit. */
|
|
37
|
+
export interface AuthoredNodesBrand {
|
|
38
|
+
readonly [authoredNodes]: true;
|
|
39
|
+
}
|
|
34
40
|
/** What {@link fromChildren}'s `toItem` receives. */
|
|
35
41
|
export interface AuthorChildContext {
|
|
36
42
|
/** Nested elements, parsed as body nodes. */
|
|
@@ -77,7 +83,9 @@ type ChildProps<TItem, TOptional extends PropertyKey> = [TOptional] extends [
|
|
|
77
83
|
children?: ReactNode;
|
|
78
84
|
};
|
|
79
85
|
/**
|
|
80
|
-
* Brands `schema` as JSX children of `
|
|
86
|
+
* Brands `schema` as JSX children of the member `name`, capitalized on the
|
|
87
|
+
* primitive's component: `fromChildren('item', …)` on `slideList` is
|
|
88
|
+
* `<SlideList.Item>`. Names are unique across a primitive's child tree.
|
|
81
89
|
*
|
|
82
90
|
* `options.text` copies leftover text onto that field. `options.toItem` replaces
|
|
83
91
|
* the default prop copy; its props annotation is the child component's props.
|
|
@@ -85,12 +93,12 @@ type ChildProps<TItem, TOptional extends PropertyKey> = [TOptional] extends [
|
|
|
85
93
|
* `.readonly()`; any other method clones without it, so call it on `schema`
|
|
86
94
|
* before passing it in.
|
|
87
95
|
*/
|
|
88
|
-
export declare function fromChildren<const TName extends string, TSchema extends ZodType>(
|
|
89
|
-
export declare function fromChildren<const TName extends string, TSchema extends ZodType, const TText extends string>(
|
|
96
|
+
export declare function fromChildren<const TName extends string, TSchema extends ZodType>(name: TName, schema: TSchema): TSchema & AuthoredChildBrand<TName, ChildProps<ArrayItem<TSchema>, ChildBrandedKeys<ItemSchema<TSchema>>>>;
|
|
97
|
+
export declare function fromChildren<const TName extends string, TSchema extends ZodType, const TText extends string>(name: TName, schema: TSchema, options: {
|
|
90
98
|
text: TText;
|
|
91
99
|
toItem?: never;
|
|
92
100
|
}): TSchema & AuthoredChildBrand<TName, ChildProps<ArrayItem<TSchema>, TText | ChildBrandedKeys<ItemSchema<TSchema>>>>;
|
|
93
|
-
export declare function fromChildren<const TName extends string, TSchema extends ZodType, TPropsSchema extends ZodType>(
|
|
101
|
+
export declare function fromChildren<const TName extends string, TSchema extends ZodType, TPropsSchema extends ZodType>(name: TName, schema: TSchema, options: {
|
|
94
102
|
text?: string;
|
|
95
103
|
propsSchema: TPropsSchema;
|
|
96
104
|
toItem(props: zInput<TPropsSchema> & {
|
|
@@ -99,7 +107,7 @@ export declare function fromChildren<const TName extends string, TSchema extends
|
|
|
99
107
|
}): TSchema & AuthoredChildBrand<TName, zInput<TPropsSchema> & {
|
|
100
108
|
children?: ReactNode;
|
|
101
109
|
}> & AuthoredToItemBrand;
|
|
102
|
-
export declare function fromChildren<const TName extends string, TSchema extends ZodType, TProps>(
|
|
110
|
+
export declare function fromChildren<const TName extends string, TSchema extends ZodType, TProps>(name: TName, schema: TSchema, options: {
|
|
103
111
|
text?: string;
|
|
104
112
|
toItem(props: TProps, context: AuthorChildContext): unknown;
|
|
105
113
|
propsSchema?: never;
|
|
@@ -107,15 +115,24 @@ export declare function fromChildren<const TName extends string, TSchema extends
|
|
|
107
115
|
/**
|
|
108
116
|
* Brands `schema` as text children.
|
|
109
117
|
*
|
|
110
|
-
* Whitespace collapses unless `collapseWhitespace` is `false`.
|
|
118
|
+
* Whitespace collapses unless `collapseWhitespace` is `false`. `dedent` keeps
|
|
119
|
+
* it and reads the text as source, as {@link textFromChildren} does.
|
|
111
120
|
*/
|
|
112
121
|
export declare const fromTextChildren: <TSchema extends ZodType>(schema: TSchema, options?: {
|
|
113
122
|
collapseWhitespace?: boolean;
|
|
123
|
+
dedent?: boolean;
|
|
114
124
|
}) => TSchema & AuthoredTextBrand;
|
|
125
|
+
/**
|
|
126
|
+
* Brands `schema`, a node or an array of nodes, as the primitive elements among
|
|
127
|
+
* the children that no other field claims. Use it for nodes the tree walk does
|
|
128
|
+
* not visit; a walked child slot fills from children already.
|
|
129
|
+
*/
|
|
130
|
+
export declare const fromNodeChildren: <TSchema extends ZodType>(schema: TSchema) => TSchema & AuthoredNodesBrand;
|
|
115
131
|
/** One {@link fromChildren} field as the shim reads it. */
|
|
116
132
|
export interface AuthoredChildField {
|
|
117
133
|
field: string;
|
|
118
|
-
|
|
134
|
+
/** The member name `fromChildren` was given, before capitalizing. */
|
|
135
|
+
name: string;
|
|
119
136
|
/** Field leftover text children fill. */
|
|
120
137
|
textField?: string;
|
|
121
138
|
/** Replaces the default prop copy. */
|
|
@@ -128,21 +145,29 @@ export interface AuthoredChildField {
|
|
|
128
145
|
array: boolean;
|
|
129
146
|
/** Whether the field accepts `undefined`, so children may be omitted. */
|
|
130
147
|
optional: boolean;
|
|
131
|
-
/** Structural input-schema fingerprint shared by fields branding one child type. */
|
|
132
|
-
signature: string;
|
|
133
148
|
}
|
|
134
149
|
/** One {@link fromTextChildren} field as the shim reads it. */
|
|
135
150
|
export interface AuthoredTextField {
|
|
136
151
|
field: string;
|
|
137
|
-
/** `true` unless the brand was given `collapseWhitespace: false`. */
|
|
152
|
+
/** `true` unless the brand was given `collapseWhitespace: false` or `dedent`. */
|
|
138
153
|
collapseWhitespace: boolean;
|
|
154
|
+
/** Set when the brand was given `dedent`. */
|
|
155
|
+
dedent?: true;
|
|
139
156
|
/** Whether the field accepts `undefined`, so text children may be omitted. */
|
|
140
157
|
optional: boolean;
|
|
141
158
|
}
|
|
159
|
+
/** One {@link fromNodeChildren} field as the shim reads it. */
|
|
160
|
+
export interface AuthoredNodesField {
|
|
161
|
+
field: string;
|
|
162
|
+
/** Whether the field holds an array of nodes rather than one. */
|
|
163
|
+
array: boolean;
|
|
164
|
+
}
|
|
142
165
|
/** The branded fields found on one object schema. */
|
|
143
166
|
export interface AuthoredSpec {
|
|
144
167
|
children: AuthoredChildField[];
|
|
145
168
|
text: AuthoredTextField[];
|
|
169
|
+
/** Absent on a spec built by hand; read as none. */
|
|
170
|
+
nodes?: AuthoredNodesField[];
|
|
146
171
|
}
|
|
147
172
|
/**
|
|
148
173
|
* The branded fields on an object schema, top level only: read a child's own
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored_fields.d.ts","sourceRoot":"","sources":["../../src/author/authored_fields.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"authored_fields.d.ts","sourceRoot":"","sources":["../../src/author/authored_fields.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAGnC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,aAAa,eAA8C,CAAC;AAEzE,sEAAsE;AACtE,eAAO,MAAM,aAAa,eAA8C,CAAC;AAEzE,qDAAqD;AACrD,eAAO,MAAM,YAAY,eAA6C,CAAC;AAEvE,gFAAgF;AAChF,eAAO,MAAM,aAAa,eAA8C,CAAC;AAEzE,qDAAqD;AACrD,eAAO,MAAM,cAAc,eAAgD,CAAC;AAM5E;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM;IAC9D,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC;IAChC,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,sGAAsG;AACtG,MAAM,WAAW,mBAAmB;IAClC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AAE,IAAI,CAAC;IACd,8EAA8E;IAC9E,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,+DAA+D;AAC/D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC1B,oDAAoD;IACpD,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AA6HD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,OAAO,KAAG,YA0BlD,CAAC"}
|
|
@@ -4,11 +4,9 @@
|
|
|
4
4
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
5
|
* 2.0.
|
|
6
6
|
*/
|
|
7
|
-
import { z } from 'zod';
|
|
8
7
|
import { ISOMER_ERROR_CODES, IsomerError } from '../composition/error.js';
|
|
9
|
-
import { prepareAuthoringInput } from './authoring_input.js';
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
9
|
+
* Member name of the child component a schema field is filled from.
|
|
12
10
|
*
|
|
13
11
|
* `Symbol.for`: ESM and CJS builds must agree, same as `authorType`.
|
|
14
12
|
*/
|
|
@@ -17,17 +15,22 @@ export const authoredChild = Symbol.for('elastic.isomer.authored_child');
|
|
|
17
15
|
export const authoredProps = Symbol.for('elastic.isomer.authored_props');
|
|
18
16
|
/** Set when a field is filled from text children. */
|
|
19
17
|
export const authoredText = Symbol.for('elastic.isomer.authored_text');
|
|
18
|
+
/** Set when a field is filled from primitive elements no other field claims. */
|
|
19
|
+
export const authoredNodes = Symbol.for('elastic.isomer.authored_nodes');
|
|
20
20
|
/** Holds a {@link fromChildren} brand's `toItem`. */
|
|
21
21
|
export const authoredToItem = Symbol.for('elastic.isomer.authored_to_item');
|
|
22
22
|
const authoredTextField = Symbol.for('elastic.isomer.authored_text_field');
|
|
23
23
|
const authoredCollapse = Symbol.for('elastic.isomer.authored_collapse');
|
|
24
|
+
const authoredDedent = Symbol.for('elastic.isomer.authored_dedent');
|
|
24
25
|
const authoredPropsSchema = Symbol.for('elastic.isomer.authored_props_schema');
|
|
25
26
|
const BRANDS = [
|
|
26
27
|
authoredChild,
|
|
27
28
|
authoredTextField,
|
|
28
29
|
authoredToItem,
|
|
29
30
|
authoredText,
|
|
31
|
+
authoredNodes,
|
|
30
32
|
authoredCollapse,
|
|
33
|
+
authoredDedent,
|
|
31
34
|
authoredPropsSchema,
|
|
32
35
|
];
|
|
33
36
|
// Applies a complete branding. Branding an instance again is allowed only with
|
|
@@ -35,8 +38,9 @@ const BRANDS = [
|
|
|
35
38
|
const brand = (caller, schema, config) => {
|
|
36
39
|
const record = schema;
|
|
37
40
|
if (BRANDS.some((key) => Object.hasOwn(schema, key))) {
|
|
38
|
-
if (BRANDS.every((key) => record[key] === config[key]))
|
|
41
|
+
if (BRANDS.every((key) => record[key] === config[key])) {
|
|
39
42
|
return;
|
|
43
|
+
}
|
|
40
44
|
throw new IsomerError(ISOMER_ERROR_CODES.AUTHORED_SCHEMA_REUSED, `${caller}: this schema instance is already branded another way; pass each field its own schema.`);
|
|
41
45
|
}
|
|
42
46
|
for (const key of BRANDS) {
|
|
@@ -48,9 +52,9 @@ const brand = (caller, schema, config) => {
|
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
};
|
|
51
|
-
export function fromChildren(
|
|
55
|
+
export function fromChildren(name, schema, options) {
|
|
52
56
|
brand('fromChildren', schema, {
|
|
53
|
-
[authoredChild]:
|
|
57
|
+
[authoredChild]: name,
|
|
54
58
|
[authoredTextField]: options?.text,
|
|
55
59
|
[authoredToItem]: options?.toItem,
|
|
56
60
|
[authoredPropsSchema]: options?.propsSchema,
|
|
@@ -60,15 +64,28 @@ export function fromChildren(childType, schema, options) {
|
|
|
60
64
|
/**
|
|
61
65
|
* Brands `schema` as text children.
|
|
62
66
|
*
|
|
63
|
-
* Whitespace collapses unless `collapseWhitespace` is `false`.
|
|
67
|
+
* Whitespace collapses unless `collapseWhitespace` is `false`. `dedent` keeps
|
|
68
|
+
* it and reads the text as source, as {@link textFromChildren} does.
|
|
64
69
|
*/
|
|
65
70
|
export const fromTextChildren = (schema, options) => {
|
|
66
71
|
brand('fromTextChildren', schema, {
|
|
67
72
|
[authoredText]: true,
|
|
68
|
-
[authoredCollapse]: options?.collapseWhitespace === false
|
|
73
|
+
[authoredCollapse]: options?.collapseWhitespace === false || options?.dedent
|
|
74
|
+
? false
|
|
75
|
+
: undefined,
|
|
76
|
+
[authoredDedent]: options?.dedent ? true : undefined,
|
|
69
77
|
});
|
|
70
78
|
return schema;
|
|
71
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Brands `schema`, a node or an array of nodes, as the primitive elements among
|
|
82
|
+
* the children that no other field claims. Use it for nodes the tree walk does
|
|
83
|
+
* not visit; a walked child slot fills from children already.
|
|
84
|
+
*/
|
|
85
|
+
export const fromNodeChildren = (schema) => {
|
|
86
|
+
brand('fromNodeChildren', schema, { [authoredNodes]: true });
|
|
87
|
+
return schema;
|
|
88
|
+
};
|
|
72
89
|
const zodDefType = (schema) => schema._zod?.def?.type;
|
|
73
90
|
const WRAPPER_TYPES = new Set(['optional', 'nullable', 'default', 'readonly']);
|
|
74
91
|
const innerSchema = (schema) => {
|
|
@@ -86,8 +103,9 @@ const brandHolder = (schema, key) => {
|
|
|
86
103
|
// Whether any wrapper layer of `schema` accepts `undefined`.
|
|
87
104
|
const optionalThrough = (schema) => {
|
|
88
105
|
for (let current = schema; current; current = innerSchema(current)) {
|
|
89
|
-
if (isOptionalSchema(current))
|
|
106
|
+
if (isOptionalSchema(current)) {
|
|
90
107
|
return true;
|
|
108
|
+
}
|
|
91
109
|
}
|
|
92
110
|
return false;
|
|
93
111
|
};
|
|
@@ -103,58 +121,6 @@ const isOptionalSchema = (schema) => {
|
|
|
103
121
|
const type = zodDefType(schema);
|
|
104
122
|
return type === 'optional' || type === 'default';
|
|
105
123
|
};
|
|
106
|
-
const UNORDERED_SCHEMA_ARRAYS = new Set([
|
|
107
|
-
'allOf',
|
|
108
|
-
'anyOf',
|
|
109
|
-
'enum',
|
|
110
|
-
'oneOf',
|
|
111
|
-
'required',
|
|
112
|
-
'type',
|
|
113
|
-
]);
|
|
114
|
-
const schemaSignature = (schema) => {
|
|
115
|
-
const { schema: input } = prepareAuthoringInput(schema);
|
|
116
|
-
const projected = z.toJSONSchema(input, {
|
|
117
|
-
io: 'input',
|
|
118
|
-
target: 'draft-2020-12',
|
|
119
|
-
cycles: 'ref',
|
|
120
|
-
reused: 'inline',
|
|
121
|
-
unrepresentable: 'any',
|
|
122
|
-
metadata: z.registry(),
|
|
123
|
-
});
|
|
124
|
-
const active = new Map();
|
|
125
|
-
const canonical = (value, key = '') => {
|
|
126
|
-
if (Array.isArray(value)) {
|
|
127
|
-
const members = value.map((member) => canonical(member));
|
|
128
|
-
if (UNORDERED_SCHEMA_ARRAYS.has(key))
|
|
129
|
-
members.sort();
|
|
130
|
-
return `[${members.join(',')}]`;
|
|
131
|
-
}
|
|
132
|
-
if (typeof value !== 'object' || value === null) {
|
|
133
|
-
return JSON.stringify(value) ?? 'undefined';
|
|
134
|
-
}
|
|
135
|
-
const cycle = active.get(value);
|
|
136
|
-
if (cycle !== undefined)
|
|
137
|
-
return `cycle:${cycle}`;
|
|
138
|
-
const object = value;
|
|
139
|
-
const ref = object.$ref;
|
|
140
|
-
const target = ref === '#'
|
|
141
|
-
? projected
|
|
142
|
-
: typeof ref === 'string' && ref.startsWith('#/$defs/')
|
|
143
|
-
? projected.$defs?.[ref.slice('#/$defs/'.length)]
|
|
144
|
-
: undefined;
|
|
145
|
-
if (target && Object.keys(object).length === 1)
|
|
146
|
-
return canonical(target);
|
|
147
|
-
active.set(value, active.size);
|
|
148
|
-
const result = `{${Object.entries(object)
|
|
149
|
-
.filter(([key]) => value !== projected || key !== '$defs')
|
|
150
|
-
.sort(([first], [second]) => first.localeCompare(second))
|
|
151
|
-
.map(([key, member]) => `${JSON.stringify(key)}:${canonical(key === '$ref' && target ? target : member, key)}`)
|
|
152
|
-
.join(',')}}`;
|
|
153
|
-
active.delete(value);
|
|
154
|
-
return result;
|
|
155
|
-
};
|
|
156
|
-
return canonical(projected);
|
|
157
|
-
};
|
|
158
124
|
const arrayElement = (schema) => {
|
|
159
125
|
const inner = unwrapAll(schema);
|
|
160
126
|
return zodDefType(inner) === 'array' && 'element' in inner
|
|
@@ -163,8 +129,8 @@ const arrayElement = (schema) => {
|
|
|
163
129
|
};
|
|
164
130
|
const readChild = (field, schema) => {
|
|
165
131
|
const holder = brandHolder(schema, authoredChild);
|
|
166
|
-
const
|
|
167
|
-
if (!holder || typeof
|
|
132
|
+
const name = holder?.[authoredChild];
|
|
133
|
+
if (!holder || typeof name !== 'string') {
|
|
168
134
|
return undefined;
|
|
169
135
|
}
|
|
170
136
|
const textField = holder[authoredTextField];
|
|
@@ -174,14 +140,14 @@ const readChild = (field, schema) => {
|
|
|
174
140
|
const itemSchema = element ?? unwrapAll(holder);
|
|
175
141
|
const child = {
|
|
176
142
|
field,
|
|
177
|
-
|
|
143
|
+
name,
|
|
178
144
|
itemSchema,
|
|
179
145
|
array: element !== undefined,
|
|
180
146
|
optional: optionalThrough(schema),
|
|
181
|
-
signature: `${schemaSignature(itemSchema)}|${typeof textField === 'string' ? textField : ''}|${propsSchema ? schemaSignature(propsSchema) : ''}`,
|
|
182
147
|
};
|
|
183
|
-
if (propsSchema)
|
|
148
|
+
if (propsSchema) {
|
|
184
149
|
child.propsSchema = propsSchema;
|
|
150
|
+
}
|
|
185
151
|
if (typeof textField === 'string') {
|
|
186
152
|
child.textField = textField;
|
|
187
153
|
}
|
|
@@ -195,11 +161,15 @@ const readText = (field, schema) => {
|
|
|
195
161
|
if (!holder) {
|
|
196
162
|
return undefined;
|
|
197
163
|
}
|
|
198
|
-
|
|
164
|
+
const text = {
|
|
199
165
|
field,
|
|
200
166
|
collapseWhitespace: holder[authoredCollapse] !== false,
|
|
201
167
|
optional: optionalThrough(schema),
|
|
202
168
|
};
|
|
169
|
+
if (holder[authoredDedent] === true) {
|
|
170
|
+
text.dedent = true;
|
|
171
|
+
}
|
|
172
|
+
return text;
|
|
203
173
|
};
|
|
204
174
|
/**
|
|
205
175
|
* The branded fields on an object schema, top level only: read a child's own
|
|
@@ -207,10 +177,11 @@ const readText = (field, schema) => {
|
|
|
207
177
|
*/
|
|
208
178
|
export const readAuthoredSpec = (schema) => {
|
|
209
179
|
if (zodDefType(schema) !== 'object' || !('shape' in schema)) {
|
|
210
|
-
return { children: [], text: [] };
|
|
180
|
+
return { children: [], text: [], nodes: [] };
|
|
211
181
|
}
|
|
212
182
|
const children = [];
|
|
213
183
|
const text = [];
|
|
184
|
+
const nodes = [];
|
|
214
185
|
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
215
186
|
const child = readChild(field, fieldSchema);
|
|
216
187
|
if (child) {
|
|
@@ -220,8 +191,13 @@ export const readAuthoredSpec = (schema) => {
|
|
|
220
191
|
const textField = readText(field, fieldSchema);
|
|
221
192
|
if (textField) {
|
|
222
193
|
text.push(textField);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const holder = brandHolder(fieldSchema, authoredNodes);
|
|
197
|
+
if (holder) {
|
|
198
|
+
nodes.push({ field, array: arrayElement(holder) !== undefined });
|
|
223
199
|
}
|
|
224
200
|
}
|
|
225
|
-
return { children, text };
|
|
201
|
+
return { children, text, nodes };
|
|
226
202
|
};
|
|
227
203
|
//# sourceMappingURL=authored_fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored_fields.js","sourceRoot":"","sources":["../../src/author/authored_fields.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,CAAC,EAAgB,MAAM,KAAK,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CA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,IAAI,MAAM,CAAC,OAAO,CAC/C,MAAM,CAAC,KAAgC,CACxC,EAAE,CAAC;QACF,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC5C,IAAI,KAAK,EAAE,CAAC;YACV,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC/C,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { ReactNode } from 'react';\nimport { z, type ZodType } from 'zod';\n\nimport { ISOMER_ERROR_CODES, IsomerError } from '../composition/error';\nimport type { PrimitiveNode } from '../define/primitive_module';\n\nimport { prepareAuthoringInput } from './authoring_input';\n\n/**\n * Child-element type a schema field is filled from.\n *\n * `Symbol.for`: ESM and CJS builds must agree, same as `authorType`.\n */\nexport const authoredChild = Symbol.for('elastic.isomer.authored_child');\n\n/** Phantom props type for the child component. Not set at runtime. */\nexport const authoredProps = Symbol.for('elastic.isomer.authored_props');\n\n/** Set when a field is filled from text children. */\nexport const authoredText = Symbol.for('elastic.isomer.authored_text');\n\n/** Holds a {@link fromChildren} brand's `toItem`. */\nexport const authoredToItem = Symbol.for('elastic.isomer.authored_to_item');\nconst authoredTextField = Symbol.for('elastic.isomer.authored_text_field');\nconst authoredCollapse = Symbol.for('elastic.isomer.authored_collapse');\nconst authoredPropsSchema = Symbol.for('elastic.isomer.authored_props_schema');\n\n/**\n * A field filled from child elements of `TName`.\n *\n * Phantom: `z.infer` still reads the underlying schema. The shim reads `TName`\n * and `TProps` off the field type, and the symbols off the schema value.\n */\nexport interface AuthoredChildBrand<TName extends string, TProps> {\n readonly [authoredChild]: TName;\n readonly [authoredProps]: TProps;\n}\n\n/** A child field whose `toItem` builds each item, so the shim fills none of the item's own brands. */\nexport interface AuthoredToItemBrand {\n readonly [authoredToItem]: (\n props: never,\n context: AuthorChildContext\n ) => unknown;\n}\n\n/** A field filled from text children. */\nexport interface AuthoredTextBrand {\n readonly [authoredText]: true;\n}\n\n/** What {@link fromChildren}'s `toItem` receives. */\nexport interface AuthorChildContext {\n /** Nested elements, parsed as body nodes. */\n parseChildren: (children: ReactNode) => PrimitiveNode[];\n}\n\ntype ArrayItem<TSchema extends ZodType> =\n NonNullable<zOutput<TSchema>> extends readonly (infer Item)[]\n ? Item\n : NonNullable<zOutput<TSchema>>;\n\ntype zInput<TSchema> = TSchema extends { _zod: { input: infer Input } }\n ? Input\n : never;\n\ntype zOutput<TSchema> = TSchema extends { _zod: { output: infer Output } }\n ? Output\n : never;\n\ntype WrapperOf<TInner> = {\n _zod: {\n def: {\n type: 'optional' | 'nullable' | 'default' | 'readonly';\n innerType: TInner;\n };\n };\n};\n\ntype Unwrapped<TSchema> =\n TSchema extends WrapperOf<infer Inner> ? Unwrapped<Inner> : TSchema;\n\n/** Whether `F`, or a wrapper layer of it, carries a {@link fromChildren} brand. */\ntype IsChildBranded<F> =\n F extends AuthoredChildBrand<string, unknown>\n ? true\n : F extends WrapperOf<infer Inner>\n ? IsChildBranded<Inner>\n : false;\n\n/** A branded field's item schema: the array element through any wrapper, or the unwrapped schema. */\nexport type ItemSchema<TSchema> =\n Unwrapped<TSchema> extends { element: infer Element }\n ? Element\n : Unwrapped<TSchema>;\n\n/** Item fields a nested {@link fromChildren} brand fills from child elements. */\ntype ChildBrandedKeys<TItemSchema> = TItemSchema extends {\n shape: infer Shape;\n}\n ? string extends keyof Shape\n ? never\n : {\n [K in keyof Shape]: IsChildBranded<Shape[K]> extends true ? K : never;\n }[keyof Shape]\n : never;\n\n/** `TOptional` is optional on the child props because text or child elements fill it. */\ntype ChildProps<TItem, TOptional extends PropertyKey> = [TOptional] extends [\n never,\n]\n ? TItem & { children?: ReactNode }\n : Omit<TItem, TOptional> &\n Partial<Pick<TItem, Extract<TOptional, keyof TItem>>> & {\n children?: ReactNode;\n };\n\nconst BRANDS = [\n authoredChild,\n authoredTextField,\n authoredToItem,\n authoredText,\n authoredCollapse,\n authoredPropsSchema,\n] as const;\n\n// Applies a complete branding. Branding an instance again is allowed only with\n// the same configuration, absent options included, since both fields share it.\nconst brand = (\n caller: 'fromChildren' | 'fromTextChildren',\n schema: object,\n config: Partial<Record<(typeof BRANDS)[number], unknown>>\n): void => {\n const record = schema as Record<symbol, unknown>;\n if (BRANDS.some((key) => Object.hasOwn(schema, key))) {\n if (BRANDS.every((key) => record[key] === config[key])) return;\n throw new IsomerError(\n ISOMER_ERROR_CODES.AUTHORED_SCHEMA_REUSED,\n `${caller}: this schema instance is already branded another way; pass each field its own schema.`\n );\n }\n for (const key of BRANDS) {\n if (config[key] !== undefined) {\n Object.defineProperty(schema, key, {\n value: config[key],\n enumerable: false,\n });\n }\n }\n};\n\n/**\n * Brands `schema` as JSX children of `childType`.\n *\n * `options.text` copies leftover text onto that field. `options.toItem` replaces\n * the default prop copy; its props annotation is the child component's props.\n * The brand is read through `.optional()`, `.nullable()`, `.default()`, and\n * `.readonly()`; any other method clones without it, so call it on `schema`\n * before passing it in.\n */\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n>(\n childType: TName,\n schema: TSchema\n): TSchema &\n AuthoredChildBrand<\n TName,\n ChildProps<ArrayItem<TSchema>, ChildBrandedKeys<ItemSchema<TSchema>>>\n >;\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n const TText extends string,\n>(\n childType: TName,\n schema: TSchema,\n options: { text: TText; toItem?: never }\n): TSchema &\n AuthoredChildBrand<\n TName,\n ChildProps<\n ArrayItem<TSchema>,\n TText | ChildBrandedKeys<ItemSchema<TSchema>>\n >\n >;\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n TPropsSchema extends ZodType,\n>(\n childType: TName,\n schema: TSchema,\n options: {\n text?: string;\n propsSchema: TPropsSchema;\n toItem(\n props: zInput<TPropsSchema> & { children?: ReactNode },\n context: AuthorChildContext\n ): unknown;\n }\n): TSchema &\n AuthoredChildBrand<TName, zInput<TPropsSchema> & { children?: ReactNode }> &\n AuthoredToItemBrand;\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n TProps,\n>(\n childType: TName,\n schema: TSchema,\n options: {\n text?: string;\n toItem(props: TProps, context: AuthorChildContext): unknown;\n propsSchema?: never;\n }\n): TSchema & AuthoredChildBrand<TName, TProps> & AuthoredToItemBrand;\nexport function fromChildren(\n childType: string,\n schema: ZodType,\n options?: {\n text?: string;\n toItem?: (this: void, props: never, context: AuthorChildContext) => unknown;\n propsSchema?: ZodType;\n }\n): ZodType {\n brand('fromChildren', schema, {\n [authoredChild]: childType,\n [authoredTextField]: options?.text,\n [authoredToItem]: options?.toItem,\n [authoredPropsSchema]: options?.propsSchema,\n });\n return schema;\n}\n\n/**\n * Brands `schema` as text children.\n *\n * Whitespace collapses unless `collapseWhitespace` is `false`.\n */\nexport const fromTextChildren = <TSchema extends ZodType>(\n schema: TSchema,\n options?: { collapseWhitespace?: boolean }\n): TSchema & AuthoredTextBrand => {\n brand('fromTextChildren', schema, {\n [authoredText]: true,\n [authoredCollapse]:\n options?.collapseWhitespace === false ? false : undefined,\n });\n return schema as TSchema & AuthoredTextBrand;\n};\n\n/** One {@link fromChildren} field as the shim reads it. */\nexport interface AuthoredChildField {\n field: string;\n childType: string;\n /** Field leftover text children fill. */\n textField?: string;\n /** Replaces the default prop copy. */\n toItem?: (props: object, context: AuthorChildContext) => unknown;\n /** The array element schema, or the field schema itself when it is not an array. */\n itemSchema: ZodType;\n /** Input props for a custom `toItem`, excluding JSX children. */\n propsSchema?: ZodType;\n /** Whether the field holds an array of items rather than one item. */\n array: boolean;\n /** Whether the field accepts `undefined`, so children may be omitted. */\n optional: boolean;\n /** Structural input-schema fingerprint shared by fields branding one child type. */\n signature: string;\n}\n\n/** One {@link fromTextChildren} field as the shim reads it. */\nexport interface AuthoredTextField {\n field: string;\n /** `true` unless the brand was given `collapseWhitespace: false`. */\n collapseWhitespace: boolean;\n /** Whether the field accepts `undefined`, so text children may be omitted. */\n optional: boolean;\n}\n\n/** The branded fields found on one object schema. */\nexport interface AuthoredSpec {\n children: AuthoredChildField[];\n text: AuthoredTextField[];\n}\n\nconst zodDefType = (schema: object): string | undefined =>\n (schema as { _zod?: { def?: { type?: string } } })._zod?.def?.type;\n\nconst WRAPPER_TYPES = new Set(['optional', 'nullable', 'default', 'readonly']);\n\ninterface WrapperDef {\n type?: string;\n innerType?: ZodType;\n}\n\nconst innerSchema = (schema: ZodType): ZodType | undefined => {\n const def: WrapperDef | undefined = (\n schema as { _zod?: { def?: WrapperDef } }\n )._zod?.def;\n return def?.type && WRAPPER_TYPES.has(def.type) ? def.innerType : undefined;\n};\n\n// The schema holding `brand`: `schema` or one it wraps.\nconst brandHolder = (schema: ZodType, key: symbol): ZodType | undefined => {\n let current: ZodType | undefined = schema;\n while (current && !Object.hasOwn(current, key)) {\n current = innerSchema(current);\n }\n return current;\n};\n\n// Whether any wrapper layer of `schema` accepts `undefined`.\nconst optionalThrough = (schema: ZodType): boolean => {\n for (\n let current: ZodType | undefined = schema;\n current;\n current = innerSchema(current)\n ) {\n if (isOptionalSchema(current)) return true;\n }\n return false;\n};\n\nconst unwrapAll = (schema: ZodType): ZodType => {\n let current = schema;\n for (let inner = innerSchema(current); inner; inner = innerSchema(current)) {\n current = inner;\n }\n return current;\n};\n\n/** `undefined` is a valid value, so children may be omitted. */\nconst isOptionalSchema = (schema: ZodType): boolean => {\n const type = zodDefType(schema);\n return type === 'optional' || type === 'default';\n};\n\nconst UNORDERED_SCHEMA_ARRAYS = new Set([\n 'allOf',\n 'anyOf',\n 'enum',\n 'oneOf',\n 'required',\n 'type',\n]);\n\nconst schemaSignature = (schema: ZodType): string => {\n const { schema: input } = prepareAuthoringInput(schema);\n const projected = z.toJSONSchema(input, {\n io: 'input',\n target: 'draft-2020-12',\n cycles: 'ref',\n reused: 'inline',\n unrepresentable: 'any',\n metadata: z.registry(),\n });\n const active = new Map<object, number>();\n const canonical = (value: unknown, key = ''): string => {\n if (Array.isArray(value)) {\n const members = value.map((member) => canonical(member));\n if (UNORDERED_SCHEMA_ARRAYS.has(key)) members.sort();\n return `[${members.join(',')}]`;\n }\n if (typeof value !== 'object' || value === null) {\n return JSON.stringify(value) ?? 'undefined';\n }\n const cycle = active.get(value);\n if (cycle !== undefined) return `cycle:${cycle}`;\n const object = value as Record<string, unknown>;\n const ref = object.$ref;\n const target =\n ref === '#'\n ? projected\n : typeof ref === 'string' && ref.startsWith('#/$defs/')\n ? projected.$defs?.[ref.slice('#/$defs/'.length)]\n : undefined;\n if (target && Object.keys(object).length === 1) return canonical(target);\n active.set(value, active.size);\n const result = `{${Object.entries(object)\n .filter(([key]) => value !== projected || key !== '$defs')\n .sort(([first], [second]) => first.localeCompare(second))\n .map(\n ([key, member]) =>\n `${JSON.stringify(key)}:${canonical(key === '$ref' && target ? target : member, key)}`\n )\n .join(',')}}`;\n active.delete(value);\n return result;\n };\n return canonical(projected);\n};\n\nconst arrayElement = (schema: ZodType): ZodType | undefined => {\n const inner = unwrapAll(schema);\n return zodDefType(inner) === 'array' && 'element' in inner\n ? (inner as { element: ZodType }).element\n : undefined;\n};\n\nconst readChild = (\n field: string,\n schema: ZodType\n): AuthoredChildField | undefined => {\n const holder = brandHolder(schema, authoredChild);\n const childType = (holder as { [authoredChild]?: unknown } | undefined)?.[\n authoredChild\n ];\n if (!holder || typeof childType !== 'string') {\n return undefined;\n }\n const textField = (holder as { [authoredTextField]?: unknown })[\n authoredTextField\n ];\n const toItem = (holder as { [authoredToItem]?: unknown })[authoredToItem];\n const propsSchema = (holder as { [authoredPropsSchema]?: ZodType })[\n authoredPropsSchema\n ];\n const element = arrayElement(holder);\n const itemSchema = element ?? unwrapAll(holder);\n const child: AuthoredChildField = {\n field,\n childType,\n itemSchema,\n array: element !== undefined,\n optional: optionalThrough(schema),\n signature: `${schemaSignature(itemSchema)}|${typeof textField === 'string' ? textField : ''}|${propsSchema ? schemaSignature(propsSchema) : ''}`,\n };\n if (propsSchema) child.propsSchema = propsSchema;\n if (typeof textField === 'string') {\n child.textField = textField;\n }\n if (typeof toItem === 'function') {\n child.toItem = toItem as (\n props: object,\n context: AuthorChildContext\n ) => unknown;\n }\n return child;\n};\n\nconst readText = (\n field: string,\n schema: ZodType\n): AuthoredTextField | undefined => {\n const holder = brandHolder(schema, authoredText);\n if (!holder) {\n return undefined;\n }\n return {\n field,\n collapseWhitespace:\n (holder as { [authoredCollapse]?: unknown })[authoredCollapse] !== false,\n optional: optionalThrough(schema),\n };\n};\n\n/**\n * The branded fields on an object schema, top level only: read a child's own\n * brands from its {@link AuthoredChildField.itemSchema}.\n */\nexport const readAuthoredSpec = (schema: ZodType): AuthoredSpec => {\n if (zodDefType(schema) !== 'object' || !('shape' in schema)) {\n return { children: [], text: [] };\n }\n const children: AuthoredChildField[] = [];\n const text: AuthoredTextField[] = [];\n for (const [field, fieldSchema] of Object.entries(\n schema.shape as Record<string, ZodType>\n )) {\n const child = readChild(field, fieldSchema);\n if (child) {\n children.push(child);\n continue;\n }\n const textField = readText(field, fieldSchema);\n if (textField) {\n text.push(textField);\n }\n }\n return { children, text };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"authored_fields.js","sourceRoot":"","sources":["../../src/author/authored_fields.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAEzE,sEA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M,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,EAAE,CAAC;QAC5D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC/C,CAAC;IACD,MAAM,QAAQ,GAAyB,EAAE,CAAC;IAC1C,MAAM,IAAI,GAAwB,EAAE,CAAC;IACrC,MAAM,KAAK,GAAyB,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAC/C,MAAM,CAAC,KAAgC,CACxC,EAAE,CAAC;QACF,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC5C,IAAI,KAAK,EAAE,CAAC;YACV,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC/C,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACrB,SAAS;QACX,CAAC;QACD,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACvD,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { ReactNode } from 'react';\nimport type { ZodType } from 'zod';\n\nimport { ISOMER_ERROR_CODES, IsomerError } from '../composition/error';\nimport type { PrimitiveNode } from '../define/primitive_module';\n\n/**\n * Member name of the child component a schema field is filled from.\n *\n * `Symbol.for`: ESM and CJS builds must agree, same as `authorType`.\n */\nexport const authoredChild = Symbol.for('elastic.isomer.authored_child');\n\n/** Phantom props type for the child component. Not set at runtime. */\nexport const authoredProps = Symbol.for('elastic.isomer.authored_props');\n\n/** Set when a field is filled from text children. */\nexport const authoredText = Symbol.for('elastic.isomer.authored_text');\n\n/** Set when a field is filled from primitive elements no other field claims. */\nexport const authoredNodes = Symbol.for('elastic.isomer.authored_nodes');\n\n/** Holds a {@link fromChildren} brand's `toItem`. */\nexport const authoredToItem = Symbol.for('elastic.isomer.authored_to_item');\nconst authoredTextField = Symbol.for('elastic.isomer.authored_text_field');\nconst authoredCollapse = Symbol.for('elastic.isomer.authored_collapse');\nconst authoredDedent = Symbol.for('elastic.isomer.authored_dedent');\nconst authoredPropsSchema = Symbol.for('elastic.isomer.authored_props_schema');\n\n/**\n * A field filled from child elements of `TName`.\n *\n * Phantom: `z.infer` still reads the underlying schema. The shim reads `TName`\n * and `TProps` off the field type, and the symbols off the schema value.\n */\nexport interface AuthoredChildBrand<TName extends string, TProps> {\n readonly [authoredChild]: TName;\n readonly [authoredProps]: TProps;\n}\n\n/** A child field whose `toItem` builds each item, so the shim fills none of the item's own brands. */\nexport interface AuthoredToItemBrand {\n readonly [authoredToItem]: (\n props: never,\n context: AuthorChildContext\n ) => unknown;\n}\n\n/** A field filled from text children. */\nexport interface AuthoredTextBrand {\n readonly [authoredText]: true;\n}\n\n/** A field filled from primitive elements, like a child slot the tree walk does not visit. */\nexport interface AuthoredNodesBrand {\n readonly [authoredNodes]: true;\n}\n\n/** What {@link fromChildren}'s `toItem` receives. */\nexport interface AuthorChildContext {\n /** Nested elements, parsed as body nodes. */\n parseChildren: (children: ReactNode) => PrimitiveNode[];\n}\n\ntype ArrayItem<TSchema extends ZodType> =\n NonNullable<zOutput<TSchema>> extends readonly (infer Item)[]\n ? Item\n : NonNullable<zOutput<TSchema>>;\n\ntype zInput<TSchema> = TSchema extends { _zod: { input: infer Input } }\n ? Input\n : never;\n\ntype zOutput<TSchema> = TSchema extends { _zod: { output: infer Output } }\n ? Output\n : never;\n\ntype WrapperOf<TInner> = {\n _zod: {\n def: {\n type: 'optional' | 'nullable' | 'default' | 'readonly';\n innerType: TInner;\n };\n };\n};\n\ntype Unwrapped<TSchema> =\n TSchema extends WrapperOf<infer Inner> ? Unwrapped<Inner> : TSchema;\n\n/** Whether `F`, or a wrapper layer of it, carries a {@link fromChildren} brand. */\ntype IsChildBranded<F> =\n F extends AuthoredChildBrand<string, unknown>\n ? true\n : F extends WrapperOf<infer Inner>\n ? IsChildBranded<Inner>\n : false;\n\n/** A branded field's item schema: the array element through any wrapper, or the unwrapped schema. */\nexport type ItemSchema<TSchema> =\n Unwrapped<TSchema> extends { element: infer Element }\n ? Element\n : Unwrapped<TSchema>;\n\n/** Item fields a nested {@link fromChildren} brand fills from child elements. */\ntype ChildBrandedKeys<TItemSchema> = TItemSchema extends {\n shape: infer Shape;\n}\n ? string extends keyof Shape\n ? never\n : {\n [K in keyof Shape]: IsChildBranded<Shape[K]> extends true ? K : never;\n }[keyof Shape]\n : never;\n\n/** `TOptional` is optional on the child props because text or child elements fill it. */\ntype ChildProps<TItem, TOptional extends PropertyKey> = [TOptional] extends [\n never,\n]\n ? TItem & { children?: ReactNode }\n : Omit<TItem, TOptional> &\n Partial<Pick<TItem, Extract<TOptional, keyof TItem>>> & {\n children?: ReactNode;\n };\n\nconst BRANDS = [\n authoredChild,\n authoredTextField,\n authoredToItem,\n authoredText,\n authoredNodes,\n authoredCollapse,\n authoredDedent,\n authoredPropsSchema,\n] as const;\n\n// Applies a complete branding. Branding an instance again is allowed only with\n// the same configuration, absent options included, since both fields share it.\nconst brand = (\n caller: 'fromChildren' | 'fromNodeChildren' | 'fromTextChildren',\n schema: object,\n config: Partial<Record<(typeof BRANDS)[number], unknown>>\n): void => {\n const record = schema as Record<symbol, unknown>;\n if (BRANDS.some((key) => Object.hasOwn(schema, key))) {\n if (BRANDS.every((key) => record[key] === config[key])) {\n return;\n }\n throw new IsomerError(\n ISOMER_ERROR_CODES.AUTHORED_SCHEMA_REUSED,\n `${caller}: this schema instance is already branded another way; pass each field its own schema.`\n );\n }\n for (const key of BRANDS) {\n if (config[key] !== undefined) {\n Object.defineProperty(schema, key, {\n value: config[key],\n enumerable: false,\n });\n }\n }\n};\n\n/**\n * Brands `schema` as JSX children of the member `name`, capitalized on the\n * primitive's component: `fromChildren('item', …)` on `slideList` is\n * `<SlideList.Item>`. Names are unique across a primitive's child tree.\n *\n * `options.text` copies leftover text onto that field. `options.toItem` replaces\n * the default prop copy; its props annotation is the child component's props.\n * The brand is read through `.optional()`, `.nullable()`, `.default()`, and\n * `.readonly()`; any other method clones without it, so call it on `schema`\n * before passing it in.\n */\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n>(\n name: TName,\n schema: TSchema\n): TSchema &\n AuthoredChildBrand<\n TName,\n ChildProps<ArrayItem<TSchema>, ChildBrandedKeys<ItemSchema<TSchema>>>\n >;\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n const TText extends string,\n>(\n name: TName,\n schema: TSchema,\n options: { text: TText; toItem?: never }\n): TSchema &\n AuthoredChildBrand<\n TName,\n ChildProps<\n ArrayItem<TSchema>,\n TText | ChildBrandedKeys<ItemSchema<TSchema>>\n >\n >;\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n TPropsSchema extends ZodType,\n>(\n name: TName,\n schema: TSchema,\n options: {\n text?: string;\n propsSchema: TPropsSchema;\n toItem(\n props: zInput<TPropsSchema> & { children?: ReactNode },\n context: AuthorChildContext\n ): unknown;\n }\n): TSchema &\n AuthoredChildBrand<TName, zInput<TPropsSchema> & { children?: ReactNode }> &\n AuthoredToItemBrand;\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n TProps,\n>(\n name: TName,\n schema: TSchema,\n options: {\n text?: string;\n toItem(props: TProps, context: AuthorChildContext): unknown;\n propsSchema?: never;\n }\n): TSchema & AuthoredChildBrand<TName, TProps> & AuthoredToItemBrand;\nexport function fromChildren(\n name: string,\n schema: ZodType,\n options?: {\n text?: string;\n toItem?: (this: void, props: never, context: AuthorChildContext) => unknown;\n propsSchema?: ZodType;\n }\n): ZodType {\n brand('fromChildren', schema, {\n [authoredChild]: name,\n [authoredTextField]: options?.text,\n [authoredToItem]: options?.toItem,\n [authoredPropsSchema]: options?.propsSchema,\n });\n return schema;\n}\n\n/**\n * Brands `schema` as text children.\n *\n * Whitespace collapses unless `collapseWhitespace` is `false`. `dedent` keeps\n * it and reads the text as source, as {@link textFromChildren} does.\n */\nexport const fromTextChildren = <TSchema extends ZodType>(\n schema: TSchema,\n options?: { collapseWhitespace?: boolean; dedent?: boolean }\n): TSchema & AuthoredTextBrand => {\n brand('fromTextChildren', schema, {\n [authoredText]: true,\n [authoredCollapse]:\n options?.collapseWhitespace === false || options?.dedent\n ? false\n : undefined,\n [authoredDedent]: options?.dedent ? true : undefined,\n });\n return schema as TSchema & AuthoredTextBrand;\n};\n\n/**\n * Brands `schema`, a node or an array of nodes, as the primitive elements among\n * the children that no other field claims. Use it for nodes the tree walk does\n * not visit; a walked child slot fills from children already.\n */\nexport const fromNodeChildren = <TSchema extends ZodType>(\n schema: TSchema\n): TSchema & AuthoredNodesBrand => {\n brand('fromNodeChildren', schema, { [authoredNodes]: true });\n return schema as TSchema & AuthoredNodesBrand;\n};\n\n/** One {@link fromChildren} field as the shim reads it. */\nexport interface AuthoredChildField {\n field: string;\n /** The member name `fromChildren` was given, before capitalizing. */\n name: string;\n /** Field leftover text children fill. */\n textField?: string;\n /** Replaces the default prop copy. */\n toItem?: (props: object, context: AuthorChildContext) => unknown;\n /** The array element schema, or the field schema itself when it is not an array. */\n itemSchema: ZodType;\n /** Input props for a custom `toItem`, excluding JSX children. */\n propsSchema?: ZodType;\n /** Whether the field holds an array of items rather than one item. */\n array: boolean;\n /** Whether the field accepts `undefined`, so children may be omitted. */\n optional: boolean;\n}\n\n/** One {@link fromTextChildren} field as the shim reads it. */\nexport interface AuthoredTextField {\n field: string;\n /** `true` unless the brand was given `collapseWhitespace: false` or `dedent`. */\n collapseWhitespace: boolean;\n /** Set when the brand was given `dedent`. */\n dedent?: true;\n /** Whether the field accepts `undefined`, so text children may be omitted. */\n optional: boolean;\n}\n\n/** One {@link fromNodeChildren} field as the shim reads it. */\nexport interface AuthoredNodesField {\n field: string;\n /** Whether the field holds an array of nodes rather than one. */\n array: boolean;\n}\n\n/** The branded fields found on one object schema. */\nexport interface AuthoredSpec {\n children: AuthoredChildField[];\n text: AuthoredTextField[];\n /** Absent on a spec built by hand; read as none. */\n nodes?: AuthoredNodesField[];\n}\n\nconst zodDefType = (schema: object): string | undefined =>\n (schema as { _zod?: { def?: { type?: string } } })._zod?.def?.type;\n\nconst WRAPPER_TYPES = new Set(['optional', 'nullable', 'default', 'readonly']);\n\ninterface WrapperDef {\n type?: string;\n innerType?: ZodType;\n}\n\nconst innerSchema = (schema: ZodType): ZodType | undefined => {\n const def: WrapperDef | undefined = (\n schema as { _zod?: { def?: WrapperDef } }\n )._zod?.def;\n return def?.type && WRAPPER_TYPES.has(def.type) ? def.innerType : undefined;\n};\n\n// The schema holding `brand`: `schema` or one it wraps.\nconst brandHolder = (schema: ZodType, key: symbol): ZodType | undefined => {\n let current: ZodType | undefined = schema;\n while (current && !Object.hasOwn(current, key)) {\n current = innerSchema(current);\n }\n return current;\n};\n\n// Whether any wrapper layer of `schema` accepts `undefined`.\nconst optionalThrough = (schema: ZodType): boolean => {\n for (\n let current: ZodType | undefined = schema;\n current;\n current = innerSchema(current)\n ) {\n if (isOptionalSchema(current)) {\n return true;\n }\n }\n return false;\n};\n\nconst unwrapAll = (schema: ZodType): ZodType => {\n let current = schema;\n for (let inner = innerSchema(current); inner; inner = innerSchema(current)) {\n current = inner;\n }\n return current;\n};\n\n/** `undefined` is a valid value, so children may be omitted. */\nconst isOptionalSchema = (schema: ZodType): boolean => {\n const type = zodDefType(schema);\n return type === 'optional' || type === 'default';\n};\n\nconst arrayElement = (schema: ZodType): ZodType | undefined => {\n const inner = unwrapAll(schema);\n return zodDefType(inner) === 'array' && 'element' in inner\n ? (inner as { element: ZodType }).element\n : undefined;\n};\n\nconst readChild = (\n field: string,\n schema: ZodType\n): AuthoredChildField | undefined => {\n const holder = brandHolder(schema, authoredChild);\n const name = (holder as { [authoredChild]?: unknown } | undefined)?.[\n authoredChild\n ];\n if (!holder || typeof name !== 'string') {\n return undefined;\n }\n const textField = (holder as { [authoredTextField]?: unknown })[\n authoredTextField\n ];\n const toItem = (holder as { [authoredToItem]?: unknown })[authoredToItem];\n const propsSchema = (holder as { [authoredPropsSchema]?: ZodType })[\n authoredPropsSchema\n ];\n const element = arrayElement(holder);\n const itemSchema = element ?? unwrapAll(holder);\n const child: AuthoredChildField = {\n field,\n name,\n itemSchema,\n array: element !== undefined,\n optional: optionalThrough(schema),\n };\n if (propsSchema) {\n child.propsSchema = propsSchema;\n }\n if (typeof textField === 'string') {\n child.textField = textField;\n }\n if (typeof toItem === 'function') {\n child.toItem = toItem as (\n props: object,\n context: AuthorChildContext\n ) => unknown;\n }\n return child;\n};\n\nconst readText = (\n field: string,\n schema: ZodType\n): AuthoredTextField | undefined => {\n const holder = brandHolder(schema, authoredText);\n if (!holder) {\n return undefined;\n }\n const text: AuthoredTextField = {\n field,\n collapseWhitespace:\n (holder as { [authoredCollapse]?: unknown })[authoredCollapse] !== false,\n optional: optionalThrough(schema),\n };\n if ((holder as { [authoredDedent]?: unknown })[authoredDedent] === true) {\n text.dedent = true;\n }\n return text;\n};\n\n/**\n * The branded fields on an object schema, top level only: read a child's own\n * brands from its {@link AuthoredChildField.itemSchema}.\n */\nexport const readAuthoredSpec = (schema: ZodType): AuthoredSpec => {\n if (zodDefType(schema) !== 'object' || !('shape' in schema)) {\n return { children: [], text: [], nodes: [] };\n }\n const children: AuthoredChildField[] = [];\n const text: AuthoredTextField[] = [];\n const nodes: AuthoredNodesField[] = [];\n for (const [field, fieldSchema] of Object.entries(\n schema.shape as Record<string, ZodType>\n )) {\n const child = readChild(field, fieldSchema);\n if (child) {\n children.push(child);\n continue;\n }\n const textField = readText(field, fieldSchema);\n if (textField) {\n text.push(textField);\n continue;\n }\n const holder = brandHolder(fieldSchema, authoredNodes);\n if (holder) {\n nodes.push({ field, array: arrayElement(holder) !== undefined });\n }\n }\n return { children, text, nodes };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring_input.d.ts","sourceRoot":"","sources":["../../src/author/authoring_input.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAQtC,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,GAAI,QAAQ,OAAO;;;
|
|
1
|
+
{"version":3,"file":"authoring_input.d.ts","sourceRoot":"","sources":["../../src/author/authoring_input.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAQtC,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,GAAI,QAAQ,OAAO;;;CAyDpD,CAAC"}
|
|
@@ -14,21 +14,26 @@ export const prepareAuthoringInput = (schema) => {
|
|
|
14
14
|
const copies = new Map();
|
|
15
15
|
const metadata = z.registry();
|
|
16
16
|
const copyValue = (value) => {
|
|
17
|
-
if (isSchema(value))
|
|
17
|
+
if (isSchema(value)) {
|
|
18
18
|
return copySchema(value);
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(value)) {
|
|
20
21
|
return value.map(copyValue);
|
|
21
|
-
|
|
22
|
+
}
|
|
23
|
+
if (typeof value !== 'object' || value === null) {
|
|
22
24
|
return value;
|
|
25
|
+
}
|
|
23
26
|
const prototype = Object.getPrototypeOf(value);
|
|
24
|
-
if (prototype !== Object.prototype && prototype !== null)
|
|
27
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
25
28
|
return value;
|
|
29
|
+
}
|
|
26
30
|
return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, copyValue(member)]));
|
|
27
31
|
};
|
|
28
32
|
const copySchema = (source) => {
|
|
29
33
|
const cached = copies.get(source);
|
|
30
|
-
if (cached)
|
|
34
|
+
if (cached) {
|
|
31
35
|
return cached;
|
|
36
|
+
}
|
|
32
37
|
let result;
|
|
33
38
|
copies.set(source, z.lazy(() => result));
|
|
34
39
|
const { def } = source._zod;
|
|
@@ -51,8 +56,9 @@ export const prepareAuthoringInput = (schema) => {
|
|
|
51
56
|
}
|
|
52
57
|
copies.set(source, result);
|
|
53
58
|
const meta = z.globalRegistry.get(source);
|
|
54
|
-
if (meta)
|
|
59
|
+
if (meta) {
|
|
55
60
|
metadata.add(result, meta);
|
|
61
|
+
}
|
|
56
62
|
return result;
|
|
57
63
|
};
|
|
58
64
|
return { schema: copySchema(schema), metadata };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring_input.js","sourceRoot":"","sources":["../../src/author/authoring_input.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAgB,MAAM,KAAK,CAAC;AAEtC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoB,EAAE,CACpD,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,MAAM,IAAI,KAAK;IACf,OAAQ,KAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,KAAK,QAAQ,CAAC;AAEzD,qEAAqE;AACrE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAe,EAAE,EAAE;IACvD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC3C,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,EAAgB,CAAC;IAC5C,MAAM,SAAS,GAAG,CAAC,KAAc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,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAe,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,MAAM,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,IAAI,EAAE,CAAC;YACT,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;AAClD,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport { z, type ZodType } from 'zod';\n\nconst isSchema = (value: unknown): value is ZodType =>\n typeof value === 'object' &&\n value !== null &&\n '_zod' in value &&\n typeof (value as ZodType)._zod?.def?.type === 'string';\n\n/** Input-schema copy without executable defaults or catch values. */\nexport const prepareAuthoringInput = (schema: ZodType) => {\n const copies = new Map<ZodType, ZodType>();\n const metadata = z.registry<z.GlobalMeta>();\n const copyValue = (value: unknown): unknown => {\n if (isSchema(value)) {\n return copySchema(value);\n }\n if (Array.isArray(value)) {\n return value.map(copyValue);\n }\n if (typeof value !== 'object' || value === null) {\n return value;\n }\n const prototype: unknown = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return value;\n }\n return Object.fromEntries(\n Object.entries(value).map(([key, member]) => [key, copyValue(member)])\n );\n };\n const copySchema = (source: ZodType): ZodType => {\n const cached = copies.get(source);\n if (cached) {\n return cached;\n }\n let result: ZodType;\n copies.set(\n source,\n z.lazy(() => result)\n );\n const { def } = source._zod;\n if (\n def.type === 'default' ||\n def.type === 'prefault' ||\n def.type === 'catch'\n ) {\n const { innerType } = def as { type: string; innerType: ZodType };\n const inner = copySchema(innerType);\n result =\n def.type === 'catch'\n ? z.clone(inner, inner._zod.def)\n : z.optional(inner);\n } else if (def.type === 'lazy') {\n const { getter } = def as { type: string; getter: () => ZodType };\n result = z.lazy(() => copySchema(getter()));\n } else {\n result = z.clone(source, copyValue(def) as typeof def);\n }\n copies.set(source, result);\n const meta = z.globalRegistry.get(source);\n if (meta) {\n metadata.add(result, meta);\n }\n return result;\n };\n return { schema: copySchema(schema), metadata };\n};\n"]}
|
|
@@ -6,16 +6,22 @@ export interface ChildSlot {
|
|
|
6
6
|
export interface AuthoringChild {
|
|
7
7
|
field: AuthoredChildField;
|
|
8
8
|
primitiveType: string;
|
|
9
|
+
/** Property name on the primitive's component, e.g. `Item`. */
|
|
10
|
+
member: string;
|
|
11
|
+
/** What the member's elements carry as {@link authorType}, e.g. `slideList.Item`. */
|
|
12
|
+
authorType: string;
|
|
9
13
|
path: readonly AuthoredChildField[];
|
|
10
14
|
}
|
|
15
|
+
/** The {@link AuthoringChild.authorType} of `field`'s elements under the primitive `owner`. */
|
|
16
|
+
export declare const memberType: (owner: string, { name }: Pick<AuthoredChildField, "name">) => string;
|
|
11
17
|
export declare const createAuthoringModel: (primitives: readonly {
|
|
12
18
|
type: string;
|
|
13
19
|
schema?: unknown;
|
|
14
20
|
children?: unknown;
|
|
15
21
|
}[]) => {
|
|
16
22
|
authoredByType: Map<string, AuthoredSpec>;
|
|
17
|
-
|
|
18
|
-
childSlotsByType: Map<string,
|
|
23
|
+
membersByType: Map<string, AuthoringChild[]>;
|
|
24
|
+
childSlotsByType: Map<string, ChildSlot[]>;
|
|
19
25
|
};
|
|
20
26
|
/**
|
|
21
27
|
* Reads {@link PrimitiveDefinition.children} against a probe node so JSX can
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring_model.d.ts","sourceRoot":"","sources":["../../src/author/authoring_model.ts"],"names":[],"mappings":"AAYA,OAAO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