@elastic/isomer-sdk 0.1.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/README.md +13 -2
- package/THIRD_PARTY_LICENSES.md +1 -885
- package/dist/author/authored_fields.d.ts +93 -18
- package/dist/author/authored_fields.d.ts.map +1 -1
- package/dist/author/authored_fields.js +63 -43
- package/dist/author/authored_fields.js.map +1 -1
- package/dist/author/authoring_input.d.ts +7 -0
- package/dist/author/authoring_input.d.ts.map +1 -0
- package/dist/author/authoring_input.js +66 -0
- package/dist/author/authoring_input.js.map +1 -0
- package/dist/author/authoring_model.d.ts +33 -0
- package/dist/author/authoring_model.d.ts.map +1 -0
- package/dist/author/authoring_model.js +142 -0
- package/dist/author/authoring_model.js.map +1 -0
- package/dist/author/declarations.d.ts +13 -0
- package/dist/author/declarations.d.ts.map +1 -0
- package/dist/author/declarations.js +288 -0
- package/dist/author/declarations.js.map +1 -0
- package/dist/author/index.d.ts +4 -1
- package/dist/author/index.d.ts.map +1 -1
- package/dist/author/index.js +4 -1
- package/dist/author/index.js.map +1 -1
- package/dist/author/jsx_shim.d.ts +50 -30
- package/dist/author/jsx_shim.d.ts.map +1 -1
- package/dist/author/jsx_shim.js +146 -138
- 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 +37 -0
- package/dist/author/schema_to_typescript.d.ts.map +1 -0
- package/dist/author/schema_to_typescript.js +289 -0
- package/dist/author/schema_to_typescript.js.map +1 -0
- package/dist/cjs/author/authored_fields.js +68 -47
- package/dist/cjs/author/authored_fields.js.map +1 -1
- package/dist/cjs/author/authoring_input.js +70 -0
- package/dist/cjs/author/authoring_input.js.map +1 -0
- package/dist/cjs/author/authoring_model.js +149 -0
- package/dist/cjs/author/authoring_model.js.map +1 -0
- package/dist/cjs/author/declarations.js +292 -0
- package/dist/cjs/author/declarations.js.map +1 -0
- package/dist/cjs/author/index.js +10 -1
- package/dist/cjs/author/index.js.map +1 -1
- package/dist/cjs/author/jsx_shim.js +148 -140
- 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 +298 -0
- package/dist/cjs/author/schema_to_typescript.js.map +1 -0
- package/dist/cjs/composition/body_node_base.js +11 -4
- package/dist/cjs/composition/body_node_base.js.map +1 -1
- package/dist/cjs/composition/error.js +2 -0
- package/dist/cjs/composition/error.js.map +1 -1
- package/dist/cjs/composition/index.js +2 -1
- package/dist/cjs/composition/index.js.map +1 -1
- package/dist/cjs/composition/structured_value.js.map +1 -1
- package/dist/cjs/define/frame.js +2 -3
- package/dist/cjs/define/frame.js.map +1 -1
- package/dist/cjs/define/index.js +7 -1
- package/dist/cjs/define/index.js.map +1 -1
- package/dist/cjs/define/primitive_example.js +26 -0
- package/dist/cjs/define/primitive_example.js.map +1 -0
- package/dist/cjs/define/primitive_icon.js +17 -0
- package/dist/cjs/define/primitive_icon.js.map +1 -0
- package/dist/cjs/define/primitive_module.js +24 -7
- package/dist/cjs/define/primitive_module.js.map +1 -1
- package/dist/cjs/define/slack_assets.js.map +1 -1
- package/dist/cjs/entries/index.js +8 -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/entries/slack.js +1 -2
- package/dist/cjs/entries/slack.js.map +1 -1
- package/dist/cjs/pack/capabilities.js +17 -11
- package/dist/cjs/pack/capabilities.js.map +1 -1
- package/dist/cjs/pack/compose.js +4 -1
- package/dist/cjs/pack/compose.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 +27 -5
- package/dist/cjs/pack/primitive_pack.js.map +1 -1
- package/dist/cjs/render/anchors.js +1 -1
- package/dist/cjs/render/anchors.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/layout_check.js.map +1 -1
- package/dist/cjs/render/markdown/builder.js +18 -8
- package/dist/cjs/render/markdown/builder.js.map +1 -1
- package/dist/cjs/render/markdown/format.js +70 -30
- 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/primitive_dispatch.js +11 -25
- package/dist/cjs/render/primitive_dispatch.js.map +1 -1
- package/dist/cjs/render/react/content.js +3 -1
- package/dist/cjs/render/react/content.js.map +1 -1
- package/dist/cjs/render/slack/format.js +1 -601
- package/dist/cjs/render/slack/format.js.map +1 -1
- package/dist/cjs/render/slack/index.js +1 -2
- package/dist/cjs/render/slack/index.js.map +1 -1
- package/dist/cjs/render/slack/markdown_content.js +172 -115
- package/dist/cjs/render/slack/markdown_content.js.map +1 -1
- package/dist/cjs/testing/conformance.js +40 -24
- package/dist/cjs/testing/conformance.js.map +1 -1
- package/dist/cjs/testing/icon.js +248 -0
- package/dist/cjs/testing/icon.js.map +1 -0
- package/dist/cjs/testing/index.js +3 -1
- package/dist/cjs/testing/index.js.map +1 -1
- package/dist/cjs/testing/registration.js +5 -3
- package/dist/cjs/testing/registration.js.map +1 -1
- package/dist/cjs/validate/authoring_schema.js +17 -1
- package/dist/cjs/validate/authoring_schema.js.map +1 -1
- package/dist/cjs/validate/index.js +2 -1
- package/dist/cjs/validate/index.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/cjs/validate/validation.js +2 -45
- package/dist/cjs/validate/validation.js.map +1 -1
- package/dist/composition/body_node_base.d.ts +7 -6
- package/dist/composition/body_node_base.d.ts.map +1 -1
- package/dist/composition/body_node_base.js +10 -3
- package/dist/composition/body_node_base.js.map +1 -1
- package/dist/composition/error.d.ts +2 -0
- package/dist/composition/error.d.ts.map +1 -1
- package/dist/composition/error.js +2 -0
- package/dist/composition/error.js.map +1 -1
- package/dist/composition/index.d.ts +1 -1
- package/dist/composition/index.d.ts.map +1 -1
- package/dist/composition/index.js +1 -1
- package/dist/composition/index.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/frame.d.ts +9 -20
- package/dist/define/frame.d.ts.map +1 -1
- package/dist/define/frame.js +2 -3
- package/dist/define/frame.js.map +1 -1
- package/dist/define/index.d.ts +3 -1
- package/dist/define/index.d.ts.map +1 -1
- package/dist/define/index.js +3 -1
- package/dist/define/index.js.map +1 -1
- package/dist/define/primitive_example.d.ts +30 -0
- package/dist/define/primitive_example.d.ts.map +1 -0
- package/dist/define/primitive_example.js +21 -0
- package/dist/define/primitive_example.js.map +1 -0
- package/dist/define/primitive_icon.d.ts +11 -0
- package/dist/define/primitive_icon.d.ts.map +1 -0
- package/dist/define/primitive_icon.js +14 -0
- package/dist/define/primitive_icon.js.map +1 -0
- package/dist/define/primitive_module.d.ts +45 -24
- package/dist/define/primitive_module.d.ts.map +1 -1
- package/dist/define/primitive_module.js +24 -7
- package/dist/define/primitive_module.js.map +1 -1
- package/dist/define/slack_assets.d.ts +1 -1
- package/dist/define/slack_assets.d.ts.map +1 -1
- package/dist/define/slack_assets.js.map +1 -1
- package/dist/entries/index.d.ts +3 -3
- package/dist/entries/index.d.ts.map +1 -1
- package/dist/entries/index.js +3 -3
- 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/entries/slack.d.ts +1 -1
- package/dist/entries/slack.d.ts.map +1 -1
- package/dist/entries/slack.js +1 -1
- package/dist/entries/slack.js.map +1 -1
- package/dist/pack/capabilities.d.ts +24 -10
- package/dist/pack/capabilities.d.ts.map +1 -1
- package/dist/pack/capabilities.js +17 -11
- package/dist/pack/capabilities.js.map +1 -1
- package/dist/pack/compose.d.ts +4 -1
- package/dist/pack/compose.d.ts.map +1 -1
- package/dist/pack/compose.js +4 -1
- package/dist/pack/compose.js.map +1 -1
- package/dist/pack/index.d.ts +2 -2
- package/dist/pack/index.d.ts.map +1 -1
- package/dist/pack/index.js +2 -2
- package/dist/pack/index.js.map +1 -1
- package/dist/pack/primitive_pack.d.ts +14 -3
- package/dist/pack/primitive_pack.d.ts.map +1 -1
- package/dist/pack/primitive_pack.js +25 -4
- package/dist/pack/primitive_pack.js.map +1 -1
- package/dist/render/anchors.d.ts +2 -2
- package/dist/render/anchors.d.ts.map +1 -1
- package/dist/render/anchors.js +1 -1
- package/dist/render/anchors.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.d.ts +3 -3
- package/dist/render/html/envelope.js +12 -6
- package/dist/render/html/envelope.js.map +1 -1
- package/dist/render/layout_check.d.ts +1 -1
- package/dist/render/layout_check.d.ts.map +1 -1
- package/dist/render/layout_check.js.map +1 -1
- package/dist/render/markdown/builder.d.ts +5 -4
- package/dist/render/markdown/builder.d.ts.map +1 -1
- package/dist/render/markdown/builder.js +16 -7
- package/dist/render/markdown/builder.js.map +1 -1
- package/dist/render/markdown/format.d.ts +9 -0
- package/dist/render/markdown/format.d.ts.map +1 -1
- package/dist/render/markdown/format.js +67 -31
- 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/primitive_dispatch.d.ts +6 -6
- package/dist/render/primitive_dispatch.d.ts.map +1 -1
- package/dist/render/primitive_dispatch.js +12 -26
- package/dist/render/primitive_dispatch.js.map +1 -1
- 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/format.d.ts +0 -25
- package/dist/render/slack/format.d.ts.map +1 -1
- package/dist/render/slack/format.js +1 -599
- package/dist/render/slack/format.js.map +1 -1
- package/dist/render/slack/index.d.ts +1 -1
- package/dist/render/slack/index.d.ts.map +1 -1
- package/dist/render/slack/index.js +1 -1
- package/dist/render/slack/index.js.map +1 -1
- package/dist/render/slack/markdown_content.d.ts +10 -4
- package/dist/render/slack/markdown_content.d.ts.map +1 -1
- package/dist/render/slack/markdown_content.js +169 -113
- package/dist/render/slack/markdown_content.js.map +1 -1
- package/dist/testing/conformance.d.ts +19 -14
- package/dist/testing/conformance.d.ts.map +1 -1
- package/dist/testing/conformance.js +40 -24
- package/dist/testing/conformance.js.map +1 -1
- package/dist/testing/icon.d.ts +11 -0
- package/dist/testing/icon.d.ts.map +1 -0
- package/dist/testing/icon.js +244 -0
- package/dist/testing/icon.js.map +1 -0
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/registration.d.ts +1 -1
- package/dist/testing/registration.d.ts.map +1 -1
- package/dist/testing/registration.js +6 -4
- package/dist/testing/registration.js.map +1 -1
- package/dist/validate/authoring_schema.d.ts +6 -0
- package/dist/validate/authoring_schema.d.ts.map +1 -1
- package/dist/validate/authoring_schema.js +15 -0
- package/dist/validate/authoring_schema.js.map +1 -1
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +1 -1
- package/dist/validate/index.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/dist/validate/validation.d.ts +1 -11
- package/dist/validate/validation.d.ts.map +1 -1
- package/dist/validate/validation.js +3 -46
- package/dist/validate/validation.js.map +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json_schema.js","sourceRoot":"","sources":["../../../src/validate/json_schema.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6BAAsC;AAItC,6DAG8B;AAqB9B;;;;;;GAMG;AACI,MAAM,0BAA0B,GAAG,CACxC,WAA8C,EAC9C,UAAwC,EAAE,EAC9B,EAAE;IACd,qEAAqE;IACrE,sDAAsD;IACtD,MAAM,QAAQ,GAAG,IAAA,sCAAiB,EAAC,WAAW,CAAC,CAAC;IAChD,MAAM,EAAE,cAAc,EAAE,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wDAAwD;SAC3D,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;YACvC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAC,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,OAAC,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,KAAc,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAnEW,QAAA,0BAA0B,8BAmErC","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\nimport type { AnyPrimitiveDefinition } from '../define/primitive_module';\n\nimport {\n buildCompositionSchema,\n resolveVocabulary,\n} from './composition_schema';\n\ntype JsonSchema = Record<string, unknown>;\n\n/** Options for {@link buildCompositionJsonSchema}. */\nexport interface CompositionJsonSchemaOptions {\n /** Base URI for the emitted schema, which `$ref`s resolve against. */\n $id?: string;\n /** Reaches the model, so it keeps the word \"view\". Defaults to `'View'`. */\n title?: string;\n /** Reaches the model too, so write it as guidance rather than as a type note. */\n description?: string;\n /**\n * Extra schemas to name in `$defs`, for types a pack references by `$ref`.\n * Each `id` becomes the `$defs` key, so it must be unique.\n */\n extraDefs?: readonly { schema: ZodType; id: string }[];\n /** `ref` gives a repeated schema its own `$def`; `inline` repeats it. Defaults to `ref`. */\n reused?: 'ref' | 'inline';\n}\n\n/**\n * Projects the composition schema to JSON Schema draft 2020-12, for hosts\n * that validate outside TypeScript.\n *\n * `$defs` are named per primitive type, plus `bodyNode` for the union.\n * Agent-facing prompt text uses `buildAuthoringJsonSchema` instead.\n */\nexport const buildCompositionJsonSchema = (\n definitions: readonly AnyPrimitiveDefinition[],\n options: CompositionJsonSchemaOptions = {}\n): JsonSchema => {\n // Members, not `definition.schema`: a container's member is built by\n // `schemaFor`, and the registry is keyed on identity.\n const composed = resolveVocabulary(definitions);\n const { bodyNodeSchema, members } = composed;\n const compositionSchema = buildCompositionSchema({ bodyNodeSchema });\n\n // `metadata` replaces `z.toJSONSchema`'s default registry rather than\n // extending it, and `z.globalRegistry` is where every `.describe()` lives,\n // so ids are added to the global registry for the duration of this call\n // and the prior entries restored in `finally`. Only a schema's first\n // registration is recorded: a schema named twice (an `extraDefs` entry that\n // is also a member) must restore its original entry, not the first id.\n const previous = new Map<ZodType, unknown>();\n const registerId = (\n schema: ZodType,\n id: string,\n description?: string\n ): void => {\n if (!previous.has(schema)) {\n previous.set(schema, z.globalRegistry.get(schema));\n }\n const current = z.globalRegistry.get(schema);\n z.globalRegistry.add(schema, {\n ...current,\n id,\n ...(description === undefined ? {} : { description }),\n });\n };\n registerId(bodyNodeSchema, 'bodyNode');\n for (const extra of options.extraDefs ?? []) {\n registerId(extra.schema, extra.id);\n }\n // `schemaFor` returns a new schema, so the description is taken from the catalog.\n const described = new Map(\n definitions.map(({ type, catalog }) => [type, catalog.description])\n );\n for (const [type, schema] of members) {\n registerId(schema, type, described.get(type));\n }\n try {\n return {\n ...z.toJSONSchema(compositionSchema, {\n target: 'draft-2020-12',\n metadata: z.globalRegistry,\n reused: options.reused ?? 'ref',\n cycles: 'ref',\n unrepresentable: 'any',\n }),\n ...(options.$id ? { $id: options.$id } : {}),\n title: options.title ?? 'View',\n description:\n options.description ??\n 'A compact view that may include registered primitives.',\n };\n } finally {\n for (const [schema, entry] of previous) {\n if (entry === undefined) {\n z.globalRegistry.remove(schema);\n } else {\n z.globalRegistry.add(schema, entry as never);\n }\n }\n }\n};\n"]}
|
package/dist/cjs/validate/url.js
CHANGED
|
@@ -23,8 +23,9 @@ const NAMED_REFERENCES = {
|
|
|
23
23
|
// named ones that spell a scheme, path, or tag character.
|
|
24
24
|
const CHARACTER_REFERENCE_RE = /&(?:#x([0-9a-f]+);?|#([0-9]+);?|(bsol|colon|gt|lt|newline|sol|tab);)/gi;
|
|
25
25
|
const decodeReference = (match, hex, decimal, name) => {
|
|
26
|
-
if (name)
|
|
26
|
+
if (name) {
|
|
27
27
|
return NAMED_REFERENCES[name.toLowerCase()] ?? match;
|
|
28
|
+
}
|
|
28
29
|
const codePoint = Number.parseInt(hex ?? decimal ?? '', hex ? 16 : 10);
|
|
29
30
|
return codePoint > 0 && codePoint <= 0x10ffff
|
|
30
31
|
? String.fromCodePoint(codePoint)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../src/validate/url.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uDAAuD;AAEvD,0EAA0E;AAC1E,6EAA6E;AAE7E,MAAM,gBAAgB,GAAqC;IACzD,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,GAAG;IACV,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,OAAO,EAAE,IAAI;IACb,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,IAAI;CACV,CAAC;AAEF,4EAA4E;AAC5E,0DAA0D;AAC1D,MAAM,sBAAsB,GAC1B,wEAAwE,CAAC;AAE3E,MAAM,eAAe,GAAG,CACtB,KAAa,EACb,GAAuB,EACvB,OAA2B,EAC3B,IAAwB,EAChB,EAAE;IACV,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../src/validate/url.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uDAAuD;AAEvD,0EAA0E;AAC1E,6EAA6E;AAE7E,MAAM,gBAAgB,GAAqC;IACzD,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,GAAG;IACV,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,OAAO,EAAE,IAAI;IACb,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,IAAI;C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d,yBAAiB,EACjB,OAAO,CACR,CAAC;AANS,QAAA,QAAQ,YAMjB","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 { requiredString } from '../define/zod_helpers';\n\n// The one URL trust policy every URL-bearing field goes through, as a Zod\n// refinement and again as render-time sanitization. See `docs/url-trust.md`.\n\nconst NAMED_REFERENCES: Readonly<Record<string, string>> = {\n bsol: '\\\\',\n colon: ':',\n gt: '>',\n lt: '<',\n newline: '\\n',\n sol: '/',\n tab: '\\t',\n};\n\n// Numeric references, which browsers decode without a trailing `;`, and the\n// named ones that spell a scheme, path, or tag character.\nconst CHARACTER_REFERENCE_RE =\n /&(?:#x([0-9a-f]+);?|#([0-9]+);?|(bsol|colon|gt|lt|newline|sol|tab);)/gi;\n\nconst decodeReference = (\n match: string,\n hex: string | undefined,\n decimal: string | undefined,\n name: string | undefined\n): string => {\n if (name) {\n return NAMED_REFERENCES[name.toLowerCase()] ?? match;\n }\n const codePoint = Number.parseInt(hex ?? decimal ?? '', hex ? 16 : 10);\n return codePoint > 0 && codePoint <= 0x10ffff\n ? String.fromCodePoint(codePoint)\n : '\\ufffd';\n};\n\n// The control characters browsers drop when parsing a URL.\nconst stripControls = (value: string): string =>\n // eslint-disable-next-line no-control-regex -- stripping control characters is the point.\n value.replace(/[\\u0000-\\u001f\\u007f]/g, '').trim();\n\n// The URL as a sink sees it: references decoded once, then controls stripped,\n// so an obfuscated scheme is checked as it would act. Only the decision reads\n// it; the policy returns the authored value, since a consumer that decodes\n// again must decode what was checked, not a decoded copy.\nconst decisionForm = (value: string): string =>\n stripControls(value.replace(CHARACTER_REFERENCE_RE, decodeReference));\n\n// `<` and `>` must be percent-encoded in a URL, so their unencoded presence\n// means the value is malformed or a parser-confusion attempt (an unterminated\n// `<dest` would otherwise read as a relative path). Reject rather than strip.\nconst HAS_ANGLE_BRACKET_RE = /[<>]/;\nconst HAS_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;\nconst NAVIGATION_SCHEME_RE = /^(?:https?|mailto):/i;\nconst ASSET_SCHEME_RE = /^(?:https?:|data:image\\/)/i;\n// `//host` — and the `\\` variants browsers fold into `/` — resolve against the\n// current protocol onto a foreign host, so they are not relative paths.\nconst PROTOCOL_RELATIVE_RE = /^[/\\\\][/\\\\]/;\n\n// Whether a URL in decision form passes, given which schemes are allowed.\nconst passes = (decided: string, schemes: RegExp): boolean =>\n decided !== '' &&\n !PROTOCOL_RELATIVE_RE.test(decided) &&\n !HAS_ANGLE_BRACKET_RE.test(decided) &&\n (!HAS_SCHEME_RE.test(decided) || schemes.test(decided));\n\n/**\n * Returns the URL, trimmed and with control characters stripped, when it\n * satisfies the navigation policy (`https:` / `http:` / `mailto:` / relative\n * path), `null` otherwise.\n */\nexport const sanitizeNavigationHref = (href: string): string | null =>\n passes(decisionForm(href), NAVIGATION_SCHEME_RE) ? stripControls(href) : null;\n\n/**\n * Returns the URL, trimmed and with control characters stripped, when it\n * satisfies the asset policy (`https:` / `http:` / relative path /\n * `data:image/*`), `null` otherwise.\n */\nexport const sanitizeAssetUrl = (url: string): string | null =>\n passes(decisionForm(url), ASSET_SCHEME_RE) ? stripControls(url) : null;\n\n/** Checks a Markdown parser's decoded destination without decoding it again. */\nexport const sanitizeParsedNavigationHref = (href: string): string | null => {\n const normalized = stripControls(href);\n return passes(normalized, NAVIGATION_SCHEME_RE) ? normalized : null;\n};\n\n/** Checks a Markdown parser's decoded image destination. */\nexport const sanitizeParsedAssetUrl = (url: string): string | null => {\n const normalized = stripControls(url);\n return passes(normalized, ASSET_SCHEME_RE) ? normalized : null;\n};\n\n/**\n * Render-time replacement for a navigation href that failed the policy: an\n * inert same-document link, so the label stays visible without a destination.\n */\nexport const BLOCKED_HREF = '#';\n\n/** What {@link navigationHref} accepts, for a field description to state. */\nexport const NAVIGATION_HREF_RULE =\n 'an https, http, or mailto URL, or a relative path';\n\n/** What {@link assetUrl} accepts, for a field description to state. */\nexport const ASSET_URL_RULE =\n 'an https, http, or data:image URL, or a relative path';\n\n/** Validation message for {@link navigationHref}. */\nexport const NAVIGATION_HREF_MESSAGE = `must be ${NAVIGATION_HREF_RULE}`;\n\n/** Validation message for {@link assetUrl}. */\nexport const ASSET_URL_MESSAGE = `must be ${ASSET_URL_RULE}`;\n\n/** Options for {@link navigationHref} and {@link assetUrl}. */\nexport interface UrlSchemaOptions {\n /** Longest accepted value, in characters. */\n max?: number;\n}\n\nconst urlSchema = (\n passes: (value: string) => boolean,\n rule: string,\n message: string,\n { max }: UrlSchemaOptions\n) =>\n (max === undefined ? requiredString() : requiredString().max(max))\n .refine(passes, { error: message })\n .describe(`${rule[0]!.toUpperCase()}${rule.slice(1)}.`);\n\n/**\n * Zod schema for an `href`-like field: the validation layer of the two-layer\n * policy, paired with {@link sanitizeNavigationHref} at render time.\n *\n * Its description states the rule, since a refinement's message does not\n * reach the authoring JSON Schema. A field that describes itself should end\n * with {@link NAVIGATION_HREF_RULE} so the model still reads it.\n */\nexport const navigationHref = (options: UrlSchemaOptions = {}) =>\n urlSchema(\n (value) => sanitizeNavigationHref(value) !== null,\n NAVIGATION_HREF_RULE,\n NAVIGATION_HREF_MESSAGE,\n options\n );\n\n/**\n * Zod schema for a `src`-like field, paired with {@link sanitizeAssetUrl} at\n * render time. Describes itself as {@link navigationHref} does, with\n * {@link ASSET_URL_RULE}.\n */\nexport const assetUrl = (options: UrlSchemaOptions = {}) =>\n urlSchema(\n (value) => sanitizeAssetUrl(value) !== null,\n ASSET_URL_RULE,\n ASSET_URL_MESSAGE,\n options\n );\n"]}
|
|
@@ -70,12 +70,7 @@ const createCompositionValidator = (definitions, options = {}) => {
|
|
|
70
70
|
if (result.success) {
|
|
71
71
|
const { body } = plain;
|
|
72
72
|
const idErrors = collectDuplicateNodeIdErrors(body, walk);
|
|
73
|
-
const warnings =
|
|
74
|
-
...collectEmptySurfaceWarnings(body, walk),
|
|
75
|
-
...(options.sizesFromNodeHeights
|
|
76
|
-
? collectMissingSvgHeightWarnings(body, definitions, walk)
|
|
77
|
-
: []),
|
|
78
|
-
];
|
|
73
|
+
const warnings = collectEmptySurfaceWarnings(body, walk);
|
|
79
74
|
return {
|
|
80
75
|
valid: idErrors.length === 0,
|
|
81
76
|
errors: idErrors,
|
|
@@ -127,48 +122,10 @@ const createCompositionParser = (definitions, { inputBudget } = {}) => {
|
|
|
127
122
|
};
|
|
128
123
|
exports.createCompositionParser = createCompositionParser;
|
|
129
124
|
/** Warns once per surface that the whole body renders nothing on. */
|
|
130
|
-
const collectEmptySurfaceWarnings = (body, walk) => body_node_base_1.
|
|
125
|
+
const collectEmptySurfaceWarnings = (body, walk) => body_node_base_1.SURFACE_NAMES.filter((surface) => !body.some((node) => (0, body_node_base_1.rendersOnSurface)(node, surface, walk))).map((surface) => ({
|
|
131
126
|
surface,
|
|
132
127
|
message: `composition renders no nodes on surface "${surface}"`,
|
|
133
128
|
}));
|
|
134
|
-
/**
|
|
135
|
-
* Warns for each node that renders to `svg` but declares no `svgHeight`.
|
|
136
|
-
*
|
|
137
|
-
* `metrics.svgHeight` is optional, so `dispatcher.estimateSvgHeight` returns
|
|
138
|
-
* `0` for such a node and a frame that sums node heights sizes short.
|
|
139
|
-
*
|
|
140
|
-
* Whether a runtime consults the metric at all is the caller's to decide; see
|
|
141
|
-
* {@link CompositionValidatorOptions.sizesFromNodeHeights}. A fixed-size frame
|
|
142
|
-
* never does, and warning about a value nothing reads is how a warning channel
|
|
143
|
-
* gets ignored.
|
|
144
|
-
*/
|
|
145
|
-
const collectMissingSvgHeightWarnings = (body, definitions, walk) => {
|
|
146
|
-
const unmeasured = new Set(definitions
|
|
147
|
-
.filter((definition) => !definition.metrics?.svgHeight)
|
|
148
|
-
.map((definition) => definition.type));
|
|
149
|
-
if (unmeasured.size === 0) {
|
|
150
|
-
return [];
|
|
151
|
-
}
|
|
152
|
-
const warnings = [];
|
|
153
|
-
const visit = (node, path) => {
|
|
154
|
-
if (!node || typeof node !== 'object' || !(0, body_node_base_1.isVisibleOnSurface)(node, 'svg')) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const { type } = node;
|
|
158
|
-
if (typeof type === 'string' && unmeasured.has(type)) {
|
|
159
|
-
warnings.push({
|
|
160
|
-
surface: 'svg',
|
|
161
|
-
path,
|
|
162
|
-
message: `${path} type ${(0, one_line_1.quoteText)(type)} declares no svgHeight metric and will be measured as 0, sizing the frame short`,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
walk(node).forEach(({ node: child, path: field }) => {
|
|
166
|
-
visit(child, (0, body_node_base_1.childNodePath)(path, field));
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
body.forEach((node, index) => visit(node, `body[${index}]`));
|
|
170
|
-
return warnings;
|
|
171
|
-
};
|
|
172
129
|
/**
|
|
173
130
|
* Errors for each node whose `id` repeats one already seen, naming the first
|
|
174
131
|
* use.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/validate/validation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,kEAOuC;AAGvC,sDAAoD;AACpD,sEAGyC;AAuEhC,2GAzEP,6CAA0B,OAyEO;AApEnC,6DAA0E;AAC1E,iDAIwB;AACxB,+CAAyE;AAsCzE,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAc5E,8EAA8E;AACvE,MAAM,kBAAkB,GAAG,CAChC,MAAwB,EACxB,OAAoB,EACC,EAAE,CACvB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;AAJtD,QAAA,kBAAkB,sBAIoC;AAOnE,0LAA0L;AACnL,MAAM,qBAAqB,GAAG,CACnC,MAAwB,EACxB,IAA0B,EACpB,EA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E,CAAC;iBACxD,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;YAClD,KAAK,CAAC,KAAK,EAAE,IAAA,8BAAa,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC;AAChB,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 {\n BODY_NODE_SURFACES,\n childNodePath,\n createChildNodeWalker,\n isVisibleOnSurface,\n rendersOnSurface,\n type SurfaceName,\n} from '../composition/body_node_base';\nimport type { Composition } from '../composition/composition';\nimport type { PrimitiveNode } from '../composition/node';\nimport { quoteText } from '../composition/one_line';\nimport {\n CompositionValidationError,\n type ValidationError,\n} from '../composition/validation_error';\nimport type { AnyPrimitiveDefinition } from '../define/primitive_module';\n\nimport { getCompositionSchemaForDefinitions } from './composition_schema';\nimport {\n checkInputBudget,\n type InputBudget,\n isInputRefusal,\n} from './input_budget';\nimport { createNodeIssueFormatter, type IssueRoot } from './node_issues';\n\n/**\n * A non-fatal validation finding, scoped to the surface it concerns.\n *\n * Warnings carry `surface` because every one of them is a statement about one\n * render target — a composition that draws nothing on `slack` is not news to a\n * caller rendering HTML. Without the scope a host receives every surface's\n * findings on every call and learns to ignore the channel.\n * {@link warningsForSurface} is the filter.\n */\nexport interface ValidationWarning {\n /** The render target this finding concerns, never the composition as a whole. */\n surface: SurfaceName;\n /**\n * Path of the offending node within the composition, absent for\n * whole-composition findings.\n */\n path?: string;\n /** Safe to show a user, and phrased for whoever can act on it. */\n message: string;\n}\n\n/**\n * The outcome of `validate`: errors are fatal, warnings are advisory.\n *\n * `valid` tracks `errors` only — a composition can be valid and still carry\n * warnings, which is the normal case for a surface gap.\n */\nexport interface ValidationResult {\n /** True when `errors` is empty, regardless of `warnings`. */\n valid: boolean;\n /** Fatal findings. Empty when `valid`. */\n errors: ValidationError[];\n /** Advisory findings, empty when there are none. */\n warnings: ValidationWarning[];\n}\n\nconst checkedComposition = Symbol.for('elastic.isomer.checked_composition');\n\n/** The copy {@link createCompositionValidator} checked, which a validating render draws in place of the caller's value. The brand is type-only. */\nexport type CheckedComposition<TNode extends PrimitiveNode = PrimitiveNode> =\n Composition<TNode> & { readonly [checkedComposition]: true };\n\n/** A {@link ValidationResult} with the composition it describes. */\nexport interface CheckedValidationResult<\n TNode extends PrimitiveNode = PrimitiveNode,\n> extends ValidationResult {\n /** Undefined only when {@link checkInputBudget} refused the input. */\n composition: CheckedComposition<TNode> | undefined;\n}\n\n/** Narrows a result's warnings to the surface a caller is about to render. */\nexport const warningsForSurface = (\n result: ValidationResult,\n surface: SurfaceName\n): ValidationWarning[] =>\n result.warnings.filter((warning) => warning.surface === surface);\n\n/** Whether a render reports validation findings or raises on them. */\nexport type ValidationErrorMode = 'collect' | 'throw';\n\nexport { CompositionValidationError };\n\n/** Raises {@link CompositionValidationError} when `mode` is `throw` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input, which nothing can render. */\nexport const enforceValidationMode = (\n result: ValidationResult,\n mode?: ValidationErrorMode\n): void => {\n if (\n !result.valid &&\n (mode === 'throw' || result.errors.some(isInputRefusal))\n ) {\n throw new CompositionValidationError(result.errors);\n }\n};\n\n/** The composition `result` checked, which is what a render draws. Throws {@link CompositionValidationError} when `mode` is `'throw'` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input. */\nexport const compositionToRender = <TNode extends PrimitiveNode>(\n result: CheckedValidationResult<TNode>,\n mode?: ValidationErrorMode\n): CheckedComposition<TNode> => {\n enforceValidationMode(result, mode);\n const { composition } = result;\n if (composition === undefined) {\n throw new CompositionValidationError(result.errors);\n }\n return composition;\n};\n\n/** Runtime facts the semantic passes need beyond the primitive inventory. */\nexport interface CompositionValidatorOptions {\n /**\n * Whether any frame the runtime can draw with sizes itself from node heights,\n * which is what makes a missing `metrics.svgHeight` matter.\n *\n * A runtime-wide question rather than a per-node one, because a frame is a\n * runtime input: any node can be drawn under any frame, so the metric is\n * load-bearing as soon as one frame consults it. Defaults to `false`, so a\n * runtime with no frame at all reports nothing about a value nothing reads.\n */\n sizesFromNodeHeights?: boolean;\n /** Limits checked before the schema runs; see {@link checkInputBudget}. */\n inputBudget?: InputBudget;\n}\n\n/** The body's nodes, as {@link IssueRoot}s for a node issue formatter. */\nconst bodyRoots = (value: unknown): IssueRoot[] => {\n const { body } = (value ?? {}) as { body?: unknown };\n return Array.isArray(body)\n ? body.map((node, index) => [node, `body[${index}]`] as const)\n : [];\n};\n\n/**\n * Builds the trusted-input validator: {@link checkInputBudget}, then the schema and the semantic passes on its copy, which the result carries.\n *\n * `definitions` is memoized on array identity, so a caller that rebuilds the\n * array per call (`createCompositionValidator(packs.flatMap(…))`) resolves a\n * fresh discriminated union each time. Hold the array `composePacks` returns\n * and reuse it across the validator, the parser, and the authoring context.\n */\nexport const createCompositionValidator = <\n TNode extends PrimitiveNode = PrimitiveNode,\n>(\n definitions: readonly AnyPrimitiveDefinition[],\n options: CompositionValidatorOptions = {}\n): ((composition: Composition<TNode>) => CheckedValidationResult<TNode>) => {\n const schema = getCompositionSchemaForDefinitions(definitions);\n const walk = createChildNodeWalker(definitions);\n const formatIssues = createNodeIssueFormatter(definitions);\n return (composition) => {\n const checked = checkInputBudget(composition, options.inputBudget);\n if (!checked.valid) {\n return {\n valid: false,\n errors: [checked.error],\n warnings: [],\n composition: undefined,\n };\n }\n const plain = checked.value as CheckedComposition<TNode>;\n const result = schema.safeParse(plain, { reportInput: true });\n if (result.success) {\n const { body } = plain;\n const idErrors = collectDuplicateNodeIdErrors(body, walk);\n const warnings = [\n ...collectEmptySurfaceWarnings(body, walk),\n ...(options.sizesFromNodeHeights\n ? collectMissingSvgHeightWarnings(body, definitions, walk)\n : []),\n ];\n return {\n valid: idErrors.length === 0,\n errors: idErrors,\n warnings,\n composition: plain,\n };\n }\n return {\n valid: false,\n errors: formatIssues(bodyRoots(plain), result.error.issues),\n warnings: [],\n composition: plain,\n };\n };\n};\n\n/** The outcome of `parse`. */\nexport interface ParsedComposition {\n /** True when the value matched the schema. Says nothing about id uniqueness. */\n valid: boolean;\n /** Schema failures. Empty when `valid`. */\n errors: ValidationError[];\n /** The parsed document, present only when `valid`. */\n composition?: Composition;\n}\n\n/**\n * Builds the untrusted-input parser: {@link checkInputBudget}, then the schema only on its copy, reported rather than thrown.\n *\n * Deliberately narrower than {@link createCompositionValidator}. This answers\n * \"is this a `Composition`\", not \"is this a good one\" — it does not run the\n * duplicate-id pass or produce warnings, so a composition with two nodes\n * sharing an `id` parses as valid. Id uniqueness is a `validate` guarantee, so\n * a caller that wants the semantic checks runs `validate` on the result.\n *\n * Shares {@link createCompositionValidator}'s memoization identity requirement.\n */\nexport const createCompositionParser = (\n definitions: readonly AnyPrimitiveDefinition[],\n { inputBudget }: Pick<CompositionValidatorOptions, 'inputBudget'> = {}\n): ((value: unknown) => ParsedComposition) => {\n const schema = getCompositionSchemaForDefinitions(definitions);\n const formatIssues = createNodeIssueFormatter(definitions);\n return (value) => {\n const checked = checkInputBudget(value, inputBudget);\n if (!checked.valid) {\n return { valid: false, errors: [checked.error] };\n }\n const result = schema.safeParse(checked.value, { reportInput: true });\n if (result.success) {\n return {\n valid: true,\n errors: [],\n composition: result.data as unknown as Composition,\n };\n }\n return {\n valid: false,\n errors: formatIssues(bodyRoots(checked.value), result.error.issues),\n };\n };\n};\n\n/** Warns once per surface that the whole body renders nothing on. */\nconst collectEmptySurfaceWarnings = (\n body: readonly unknown[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationWarning[] =>\n BODY_NODE_SURFACES.filter(\n (surface) => !body.some((node) => rendersOnSurface(node, surface, walk))\n ).map((surface) => ({\n surface,\n message: `composition renders no nodes on surface \"${surface}\"`,\n }));\n\n/**\n * Warns for each node that renders to `svg` but declares no `svgHeight`.\n *\n * `metrics.svgHeight` is optional, so `dispatcher.estimateSvgHeight` returns\n * `0` for such a node and a frame that sums node heights sizes short.\n *\n * Whether a runtime consults the metric at all is the caller's to decide; see\n * {@link CompositionValidatorOptions.sizesFromNodeHeights}. A fixed-size frame\n * never does, and warning about a value nothing reads is how a warning channel\n * gets ignored.\n */\nconst collectMissingSvgHeightWarnings = (\n body: readonly unknown[],\n definitions: readonly AnyPrimitiveDefinition[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationWarning[] => {\n const unmeasured = new Set(\n definitions\n .filter((definition) => !definition.metrics?.svgHeight)\n .map((definition) => definition.type)\n );\n if (unmeasured.size === 0) {\n return [];\n }\n const warnings: ValidationWarning[] = [];\n const visit = (node: unknown, path: string): void => {\n if (!node || typeof node !== 'object' || !isVisibleOnSurface(node, 'svg')) {\n return;\n }\n const { type } = node as { type?: unknown };\n if (typeof type === 'string' && unmeasured.has(type)) {\n warnings.push({\n surface: 'svg',\n path,\n message: `${path} type ${quoteText(type)} declares no svgHeight metric and will be measured as 0, sizing the frame short`,\n });\n }\n walk(node).forEach(({ node: child, path: field }) => {\n visit(child, childNodePath(path, field));\n });\n };\n body.forEach((node, index) => visit(node, `body[${index}]`));\n return warnings;\n};\n\n/**\n * Errors for each node whose `id` repeats one already seen, naming the first\n * use.\n *\n * Errors rather than warnings, because ids are what a host addresses a node by.\n * Run by `validate` and deliberately not by `parse`; see\n * {@link createCompositionParser}.\n */\nconst collectDuplicateNodeIdErrors = (\n body: readonly unknown[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationError[] => {\n const errors: ValidationError[] = [];\n const seen = new Map<string, string>();\n const visit = (node: unknown, path: string): void => {\n if (!node || typeof node !== 'object') {\n return;\n }\n const { id, type } = node as { id?: unknown; type?: unknown };\n if (typeof id === 'string') {\n const first = seen.get(id);\n if (first) {\n errors.push({\n path: `${path}.id`,\n message: `duplicates id ${quoteText(id)} first used at ${first}`,\n ...(typeof type === 'string' ? { nodeType: type } : {}),\n });\n } else {\n seen.set(id, path);\n }\n }\n walk(node).forEach(({ node: child, path: field }) => {\n visit(child, childNodePath(path, field));\n });\n };\n body.forEach((node, index) => visit(node, `body[${index}]`));\n return errors;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/validate/validation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,kEAMuC;AAGvC,sDAAoD;AACpD,sEAGyC;AAuEhC,2GAzEP,6CAA0B,OAyEO;AApEnC,6DAA0E;AAC1E,iDAIwB;AACxB,+CAAyE;AAsCzE,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAc5E,8EAA8E;AACvE,MAAM,kBAAkB,GAAG,CAChC,MAAwB,EACxB,OAAoB,EACC,EAAE,CACvB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;AAJtD,QAAA,kBAAkB,sBAIoC;AAOnE,0LAA0L;AACnL,MAAM,qBAAqB,GAAG,CACnC,MAAwB,EACxB,IAA0B,EACpB,EAAE;IACR,IACE,CAAC,MAAM,CAAC,KAAK;QACb,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,6BAAc,CAAC,CAAC,EACxD,CAAC;QACD,MAAM,IAAI,6CAA0B,CAAC,MAAM,CAAC,M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IAC7D,OAAO,MAAM,CAAC;AAChB,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 {\n childNodePath,\n createChildNodeWalker,\n rendersOnSurface,\n SURFACE_NAMES,\n type SurfaceName,\n} from '../composition/body_node_base';\nimport type { Composition } from '../composition/composition';\nimport type { PrimitiveNode } from '../composition/node';\nimport { quoteText } from '../composition/one_line';\nimport {\n CompositionValidationError,\n type ValidationError,\n} from '../composition/validation_error';\nimport type { AnyPrimitiveDefinition } from '../define/primitive_module';\n\nimport { getCompositionSchemaForDefinitions } from './composition_schema';\nimport {\n checkInputBudget,\n type InputBudget,\n isInputRefusal,\n} from './input_budget';\nimport { createNodeIssueFormatter, type IssueRoot } from './node_issues';\n\n/**\n * A non-fatal validation finding, scoped to the surface it concerns.\n *\n * Warnings carry `surface` because every one of them is a statement about one\n * render target — a composition that draws nothing on `slack` is not news to a\n * caller rendering HTML. Without the scope a host receives every surface's\n * findings on every call and learns to ignore the channel.\n * {@link warningsForSurface} is the filter.\n */\nexport interface ValidationWarning {\n /** The render target this finding concerns, never the composition as a whole. */\n surface: SurfaceName;\n /**\n * Path of the offending node within the composition, absent for\n * whole-composition findings.\n */\n path?: string;\n /** Safe to show a user, and phrased for whoever can act on it. */\n message: string;\n}\n\n/**\n * The outcome of `validate`: errors are fatal, warnings are advisory.\n *\n * `valid` tracks `errors` only — a composition can be valid and still carry\n * warnings, which is the normal case for a surface gap.\n */\nexport interface ValidationResult {\n /** True when `errors` is empty, regardless of `warnings`. */\n valid: boolean;\n /** Fatal findings. Empty when `valid`. */\n errors: ValidationError[];\n /** Advisory findings, empty when there are none. */\n warnings: ValidationWarning[];\n}\n\nconst checkedComposition = Symbol.for('elastic.isomer.checked_composition');\n\n/** The copy {@link createCompositionValidator} checked, which a validating render draws in place of the caller's value. The brand is type-only. */\nexport type CheckedComposition<TNode extends PrimitiveNode = PrimitiveNode> =\n Composition<TNode> & { readonly [checkedComposition]: true };\n\n/** A {@link ValidationResult} with the composition it describes. */\nexport interface CheckedValidationResult<\n TNode extends PrimitiveNode = PrimitiveNode,\n> extends ValidationResult {\n /** Undefined only when {@link checkInputBudget} refused the input. */\n composition: CheckedComposition<TNode> | undefined;\n}\n\n/** Narrows a result's warnings to the surface a caller is about to render. */\nexport const warningsForSurface = (\n result: ValidationResult,\n surface: SurfaceName\n): ValidationWarning[] =>\n result.warnings.filter((warning) => warning.surface === surface);\n\n/** Whether a render reports validation findings or raises on them. */\nexport type ValidationErrorMode = 'collect' | 'throw';\n\nexport { CompositionValidationError };\n\n/** Raises {@link CompositionValidationError} when `mode` is `throw` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input, which nothing can render. */\nexport const enforceValidationMode = (\n result: ValidationResult,\n mode?: ValidationErrorMode\n): void => {\n if (\n !result.valid &&\n (mode === 'throw' || result.errors.some(isInputRefusal))\n ) {\n throw new CompositionValidationError(result.errors);\n }\n};\n\n/** The composition `result` checked, which is what a render draws. Throws {@link CompositionValidationError} when `mode` is `'throw'` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input. */\nexport const compositionToRender = <TNode extends PrimitiveNode>(\n result: CheckedValidationResult<TNode>,\n mode?: ValidationErrorMode\n): CheckedComposition<TNode> => {\n enforceValidationMode(result, mode);\n const { composition } = result;\n if (composition === undefined) {\n throw new CompositionValidationError(result.errors);\n }\n return composition;\n};\n\n/** Options for {@link createCompositionValidator}. */\nexport interface CompositionValidatorOptions {\n /** Limits checked before the schema runs; see {@link checkInputBudget}. */\n inputBudget?: InputBudget;\n}\n\n/** The body's nodes, as {@link IssueRoot}s for a node issue formatter. */\nconst bodyRoots = (value: unknown): IssueRoot[] => {\n const { body } = (value ?? {}) as { body?: unknown };\n return Array.isArray(body)\n ? body.map((node, index) => [node, `body[${index}]`] as const)\n : [];\n};\n\n/**\n * Builds the trusted-input validator: {@link checkInputBudget}, then the schema and the semantic passes on its copy, which the result carries.\n *\n * `definitions` is memoized on array identity, so a caller that rebuilds the\n * array per call (`createCompositionValidator(packs.flatMap(…))`) resolves a\n * fresh discriminated union each time. Hold the array `composePacks` returns\n * and reuse it across the validator, the parser, and the authoring context.\n */\nexport const createCompositionValidator = <\n TNode extends PrimitiveNode = PrimitiveNode,\n>(\n definitions: readonly AnyPrimitiveDefinition[],\n options: CompositionValidatorOptions = {}\n): ((composition: Composition<TNode>) => CheckedValidationResult<TNode>) => {\n const schema = getCompositionSchemaForDefinitions(definitions);\n const walk = createChildNodeWalker(definitions);\n const formatIssues = createNodeIssueFormatter(definitions);\n return (composition) => {\n const checked = checkInputBudget(composition, options.inputBudget);\n if (!checked.valid) {\n return {\n valid: false,\n errors: [checked.error],\n warnings: [],\n composition: undefined,\n };\n }\n const plain = checked.value as CheckedComposition<TNode>;\n const result = schema.safeParse(plain, { reportInput: true });\n if (result.success) {\n const { body } = plain;\n const idErrors = collectDuplicateNodeIdErrors(body, walk);\n const warnings = collectEmptySurfaceWarnings(body, walk);\n return {\n valid: idErrors.length === 0,\n errors: idErrors,\n warnings,\n composition: plain,\n };\n }\n return {\n valid: false,\n errors: formatIssues(bodyRoots(plain), result.error.issues),\n warnings: [],\n composition: plain,\n };\n };\n};\n\n/** The outcome of `parse`. */\nexport interface ParsedComposition {\n /** True when the value matched the schema. Says nothing about id uniqueness. */\n valid: boolean;\n /** Schema failures. Empty when `valid`. */\n errors: ValidationError[];\n /** The parsed document, present only when `valid`. */\n composition?: Composition;\n}\n\n/**\n * Builds the untrusted-input parser: {@link checkInputBudget}, then the schema only on its copy, reported rather than thrown.\n *\n * Deliberately narrower than {@link createCompositionValidator}. This answers\n * \"is this a `Composition`\", not \"is this a good one\" — it does not run the\n * duplicate-id pass or produce warnings, so a composition with two nodes\n * sharing an `id` parses as valid. Id uniqueness is a `validate` guarantee, so\n * a caller that wants the semantic checks runs `validate` on the result.\n *\n * Shares {@link createCompositionValidator}'s memoization identity requirement.\n */\nexport const createCompositionParser = (\n definitions: readonly AnyPrimitiveDefinition[],\n { inputBudget }: Pick<CompositionValidatorOptions, 'inputBudget'> = {}\n): ((value: unknown) => ParsedComposition) => {\n const schema = getCompositionSchemaForDefinitions(definitions);\n const formatIssues = createNodeIssueFormatter(definitions);\n return (value) => {\n const checked = checkInputBudget(value, inputBudget);\n if (!checked.valid) {\n return { valid: false, errors: [checked.error] };\n }\n const result = schema.safeParse(checked.value, { reportInput: true });\n if (result.success) {\n return {\n valid: true,\n errors: [],\n composition: result.data as unknown as Composition,\n };\n }\n return {\n valid: false,\n errors: formatIssues(bodyRoots(checked.value), result.error.issues),\n };\n };\n};\n\n/** Warns once per surface that the whole body renders nothing on. */\nconst collectEmptySurfaceWarnings = (\n body: readonly unknown[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationWarning[] =>\n SURFACE_NAMES.filter(\n (surface) => !body.some((node) => rendersOnSurface(node, surface, walk))\n ).map((surface) => ({\n surface,\n message: `composition renders no nodes on surface \"${surface}\"`,\n }));\n\n/**\n * Errors for each node whose `id` repeats one already seen, naming the first\n * use.\n *\n * Errors rather than warnings, because ids are what a host addresses a node by.\n * Run by `validate` and deliberately not by `parse`; see\n * {@link createCompositionParser}.\n */\nconst collectDuplicateNodeIdErrors = (\n body: readonly unknown[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationError[] => {\n const errors: ValidationError[] = [];\n const seen = new Map<string, string>();\n const visit = (node: unknown, path: string): void => {\n if (!node || typeof node !== 'object') {\n return;\n }\n const { id, type } = node as { id?: unknown; type?: unknown };\n if (typeof id === 'string') {\n const first = seen.get(id);\n if (first) {\n errors.push({\n path: `${path}.id`,\n message: `duplicates id ${quoteText(id)} first used at ${first}`,\n ...(typeof type === 'string' ? { nodeType: type } : {}),\n });\n } else {\n seen.set(id, path);\n }\n }\n walk(node).forEach(({ node: child, path: field }) => {\n visit(child, childNodePath(path, field));\n });\n };\n body.forEach((node, index) => visit(node, `body[${index}]`));\n return errors;\n};\n"]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Every surface a node renders on or is hidden from, in render order.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* instantiation transfers to another, silently widening to `any`.
|
|
4
|
+
* `html` is not here: the runtime's `html` surface wraps `react` output in a
|
|
5
|
+
* document, and no node targets it.
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
9
|
-
/**
|
|
7
|
+
export declare const SURFACE_NAMES: readonly ["react", "snapshot", "text", "markdown", "slack"];
|
|
8
|
+
/** One of the {@link SURFACE_NAMES}. */
|
|
9
|
+
export type SurfaceName = (typeof SURFACE_NAMES)[number];
|
|
10
|
+
/** @deprecated Use {@link SURFACE_NAMES}. */
|
|
10
11
|
export declare const BODY_NODE_SURFACES: readonly SurfaceName[];
|
|
11
12
|
/** The two fields every primitive node carries, whatever its pack. */
|
|
12
13
|
export interface BodyNodeBase {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body_node_base.d.ts","sourceRoot":"","sources":["../../src/composition/body_node_base.ts"],"names":[],"mappings":"AAOA
|
|
1
|
+
{"version":3,"file":"body_node_base.d.ts","sourceRoot":"","sources":["../../src/composition/body_node_base.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,6DAMhB,CAAC;AAEX,wCAAwC;AACxC,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,6CAA6C;AAC7C,eAAO,MAAM,kBAAkB,EAAE,SAAS,WAAW,EAAkB,CAAC;AAExE,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,qFAAqF;IACrF,IAAI,EAAE,OAAO,CAAC;IACd,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,KAAK,YAAY,EAAE,CAAC,GAAG;IAClE,aAAa,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CACxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,SAAS;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,EAAE,KACF,eAyCF,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MACxC,CAAC;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,SAAS,OAAO,EAAE,EACzB,SAAS,WAAW,EACpB,WAAW,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EACrC,MAAM,eAAe,KACpB,OAcC,CAAC;AAEL,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,OAAO,EACb,SAAS,WAAW,KACnB,OAMF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,OAAO,EACb,SAAS,WAAW,EACpB,MAAM,eAAe,KACpB,OAWF,CAAC"}
|
|
@@ -4,14 +4,21 @@
|
|
|
4
4
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
5
|
* 2.0.
|
|
6
6
|
*/
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Every surface a node renders on or is hidden from, in render order.
|
|
9
|
+
*
|
|
10
|
+
* `html` is not here: the runtime's `html` surface wraps `react` output in a
|
|
11
|
+
* document, and no node targets it.
|
|
12
|
+
*/
|
|
13
|
+
export const SURFACE_NAMES = [
|
|
9
14
|
'react',
|
|
10
|
-
'
|
|
15
|
+
'snapshot',
|
|
11
16
|
'text',
|
|
12
17
|
'markdown',
|
|
13
18
|
'slack',
|
|
14
19
|
];
|
|
20
|
+
/** @deprecated Use {@link SURFACE_NAMES}. */
|
|
21
|
+
export const BODY_NODE_SURFACES = SURFACE_NAMES;
|
|
15
22
|
/**
|
|
16
23
|
* Builds the {@link ChildNodeWalker} for one composition's inventory.
|
|
17
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body_node_base.js","sourceRoot":"","sources":["../../src/composition/body_node_base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"body_node_base.js","sourceRoot":"","sources":["../../src/composition/body_node_base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO;IACP,UAAU;IACV,MAAM;IACN,UAAU;IACV,OAAO;CACC,CAAC;AAKX,6CAA6C;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAA2B,aAAa,CAAC;AAgCxE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,WAIG,EACc,EAAE;IACnB,MAAM,cAAc,GAAG,IAAI,GAAG,EAG3B,CAAC;IACJ,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAsC,CAAC;IACvE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;YAC9C,cAAc,CAAC,GAAG,CAChB,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,QAAsD,CAClE,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,UAAU,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;YACnD,gBAAgB,CAAC,GAAG,CAClB,UAAU,CAAC,I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AAE,IAAI,CAAC,CACvC,CAAC;AACJ,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\n/**\n * Every surface a node renders on or is hidden from, in render order.\n *\n * `html` is not here: the runtime's `html` surface wraps `react` output in a\n * document, and no node targets it.\n */\nexport const SURFACE_NAMES = [\n 'react',\n 'snapshot',\n 'text',\n 'markdown',\n 'slack',\n] as const;\n\n/** One of the {@link SURFACE_NAMES}. */\nexport type SurfaceName = (typeof SURFACE_NAMES)[number];\n\n/** @deprecated Use {@link SURFACE_NAMES}. */\nexport const BODY_NODE_SURFACES: readonly SurfaceName[] = SURFACE_NAMES;\n\n/** The two fields every primitive node carries, whatever its pack. */\nexport interface BodyNodeBase {\n /** Unique within a composition, which `validate` enforces and `parse` does not. */\n id?: string;\n /** Surfaces this node appears on. Absent means every surface. */\n surfaces?: SurfaceName[];\n}\n\n/**\n * A child node together with the field path locating it inside its parent, so\n * an error path can name the field a child actually lives under. A container\n * that returned bare nodes would leave every caller guessing the field name.\n */\nexport interface ChildNodeRef {\n /** Erased: one walker spans every pack's node types, so it can name none of them. */\n node: unknown;\n /** Relative to the parent, e.g. `items[0].node`, `items[2].description`. */\n path: string;\n}\n\n/**\n * Walks nested nodes and, for a hybrid container, reports whether the parent\n * still produces output of its own. A non-empty `children` result is the\n * complete source of rendered content unless\n * {@link ChildNodeWalker.hasOwnContent} is true for that node.\n */\nexport type ChildNodeWalker = ((node: unknown) => ChildNodeRef[]) & {\n hasOwnContent?(node: unknown): boolean;\n};\n\n/**\n * Builds the {@link ChildNodeWalker} for one composition's inventory.\n *\n * Pass every pack's definitions: a walker missing one cannot see children of a\n * container that pack defines, and a tree walk would stop at its boundary.\n */\nexport const createChildNodeWalker = (\n definitions: readonly {\n type: string;\n children?: unknown;\n hasOwnContent?: unknown;\n }[]\n): ChildNodeWalker => {\n const childrenByType = new Map<\n string,\n (node: unknown) => readonly ChildNodeRef[]\n >();\n const ownContentByType = new Map<string, (node: unknown) => boolean>();\n for (const definition of definitions) {\n if (typeof definition.children === 'function') {\n childrenByType.set(\n definition.type,\n definition.children as (node: unknown) => readonly ChildNodeRef[]\n );\n }\n if (typeof definition.hasOwnContent === 'function') {\n ownContentByType.set(\n definition.type,\n definition.hasOwnContent as (node: unknown) => boolean\n );\n }\n }\n const walk = ((node: unknown) => {\n if (!node || typeof node !== 'object') {\n return [];\n }\n const { type } = node as { type?: unknown };\n if (typeof type !== 'string') {\n return [];\n }\n return [...(childrenByType.get(type)?.(node) ?? [])];\n }) as ChildNodeWalker;\n walk.hasOwnContent = (node) => {\n if (!node || typeof node !== 'object') {\n return false;\n }\n const { type } = node as { type?: unknown };\n if (typeof type !== 'string') {\n return false;\n }\n return ownContentByType.get(type)?.(node) ?? false;\n };\n return walk;\n};\n\n/** Joins a parent path with a {@link ChildNodeRef.path} fragment. */\nexport const childNodePath = (parent: string, child: string): string =>\n `${parent}.${child}`;\n\n/**\n * Whether any node visible on `surface` matches, descending through container\n * children via `walk`. A node (or a container ancestor) hidden from `surface`\n * is skipped along with its children.\n *\n * `walk` must span every pack in the composition: a walker built from one\n * pack's definitions cannot see children of a container defined in another.\n */\nexport const someBodyNode = (\n nodes: readonly unknown[],\n surface: SurfaceName,\n predicate: (node: unknown) => boolean,\n walk: ChildNodeWalker\n): boolean =>\n nodes.some((node) => {\n if (!isVisibleOnSurface(node, surface)) {\n return false;\n }\n return (\n predicate(node) ||\n someBodyNode(\n walk(node).map((child) => child.node),\n surface,\n predicate,\n walk\n )\n );\n });\n\n/** Whether `node`'s own `surfaces` hint admits `surface`, ignoring its children. */\nexport const isVisibleOnSurface = (\n node: unknown,\n surface: SurfaceName\n): boolean => {\n if (!node || typeof node !== 'object') {\n return false;\n }\n const { surfaces } = node as { surfaces?: unknown };\n return !Array.isArray(surfaces) || surfaces.includes(surface);\n};\n\n/**\n * Whether `node` puts anything on `surface` — itself or through a descendant.\n *\n * Stronger than {@link isVisibleOnSurface}: a container every one of whose\n * children is hidden renders nothing, even though its own hint allows the\n * surface. A hybrid container that also owns string fields declares\n * {@link ChildNodeWalker.hasOwnContent} and keeps rendering regardless.\n */\nexport const rendersOnSurface = (\n node: unknown,\n surface: SurfaceName,\n walk: ChildNodeWalker\n): boolean => {\n if (!isVisibleOnSurface(node, surface)) {\n return false;\n }\n const children = walk(node);\n if (children.length === 0 || walk.hasOwnContent?.(node)) {\n return true;\n }\n return children.some(({ node: child }) =>\n rendersOnSurface(child, surface, walk)\n );\n};\n"]}
|
|
@@ -14,6 +14,7 @@ export declare const ISOMER_ERROR_CODES: {
|
|
|
14
14
|
readonly CYCLIC_COMPOSITION: "CYCLIC_COMPOSITION";
|
|
15
15
|
readonly DUPLICATE_AUTHORED_CHILD: "DUPLICATE_AUTHORED_CHILD";
|
|
16
16
|
readonly DUPLICATE_ENHANCEMENT: "DUPLICATE_ENHANCEMENT";
|
|
17
|
+
readonly DUPLICATE_FORMAT: "DUPLICATE_FORMAT";
|
|
17
18
|
readonly DUPLICATE_PACK_ID: "DUPLICATE_PACK_ID";
|
|
18
19
|
readonly DUPLICATE_PRIMITIVE_TYPE: "DUPLICATE_PRIMITIVE_TYPE";
|
|
19
20
|
readonly DUPLICATE_VIEW: "DUPLICATE_VIEW";
|
|
@@ -31,6 +32,7 @@ export declare const ISOMER_ERROR_CODES: {
|
|
|
31
32
|
readonly INPUT_OVER_BUDGET: "INPUT_OVER_BUDGET";
|
|
32
33
|
readonly INVALID_BODY_NODE: "INVALID_BODY_NODE";
|
|
33
34
|
readonly INVALID_FRAME_BODY: "INVALID_FRAME_BODY";
|
|
35
|
+
readonly INVALID_PACK_GROUPS: "INVALID_PACK_GROUPS";
|
|
34
36
|
readonly MISSING_AUTHORED_TEXT: "MISSING_AUTHORED_TEXT";
|
|
35
37
|
readonly MISSING_STYLE_ADAPTER: "MISSING_STYLE_ADAPTER";
|
|
36
38
|
readonly RESERVED_NODE_FIELD: "RESERVED_NODE_FIELD";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/composition/error.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/composition/error.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCrB,CAAC;AAEX,yCAAyC;AACzC,MAAM,MAAM,eAAe,GACzB,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE/D;;;;;;;GAOG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;gBAEnB,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAKnD"}
|
|
@@ -20,6 +20,7 @@ export const ISOMER_ERROR_CODES = {
|
|
|
20
20
|
CYCLIC_COMPOSITION: 'CYCLIC_COMPOSITION',
|
|
21
21
|
DUPLICATE_AUTHORED_CHILD: 'DUPLICATE_AUTHORED_CHILD',
|
|
22
22
|
DUPLICATE_ENHANCEMENT: 'DUPLICATE_ENHANCEMENT',
|
|
23
|
+
DUPLICATE_FORMAT: 'DUPLICATE_FORMAT',
|
|
23
24
|
DUPLICATE_PACK_ID: 'DUPLICATE_PACK_ID',
|
|
24
25
|
DUPLICATE_PRIMITIVE_TYPE: 'DUPLICATE_PRIMITIVE_TYPE',
|
|
25
26
|
DUPLICATE_VIEW: 'DUPLICATE_VIEW',
|
|
@@ -37,6 +38,7 @@ export const ISOMER_ERROR_CODES = {
|
|
|
37
38
|
INPUT_OVER_BUDGET: 'INPUT_OVER_BUDGET',
|
|
38
39
|
INVALID_BODY_NODE: 'INVALID_BODY_NODE',
|
|
39
40
|
INVALID_FRAME_BODY: 'INVALID_FRAME_BODY',
|
|
41
|
+
INVALID_PACK_GROUPS: 'INVALID_PACK_GROUPS',
|
|
40
42
|
MISSING_AUTHORED_TEXT: 'MISSING_AUTHORED_TEXT',
|
|
41
43
|
MISSING_STYLE_ADAPTER: 'MISSING_STYLE_ADAPTER',
|
|
42
44
|
RESERVED_NODE_FIELD: 'RESERVED_NODE_FIELD',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/composition/error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,eAAe,EAAE,iBAAiB;IAClC,uBAAuB,EAAE,yBAAyB;IAClD,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;IAChD,mBAAmB,EAAE,qBAAqB;IAC1C,kBAAkB,EAAE,oBAAoB;IACxC,wBAAwB,EAAE,0BAA0B;IACpD,qBAAqB,EAAE,uBAAuB;IAC9C,iBAAiB,EAAE,mBAAmB;IACtC,wBAAwB,EAAE,0BAA0B;IACpD,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,wBAAwB,EAAE,0BAA0B;IACpD,yBAAyB,EAAE,2BAA2B;IACtD,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;IAChD,4BAA4B,EAAE,8BAA8B;IAC5D,oBAAoB,EAAE,sBAAsB;IAC5C,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;IAC9C,qBAAqB,EAAE,uBAAuB;IAC9C,mBAAmB,EAAE,qBAAqB;IAC1C,mBAAmB,EAAE,qBAAqB;IAC1C,aAAa,EAAE,eAAe;IAC9B,sBAAsB,EAAE,wBAAwB;IAChD,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,cAAc;IAC5B,sBAAsB,EAAE,wBAAwB;IAChD,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;CACtC,CAAC;AAMX;;;;;;;GAOG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IAE/B,YAAY,IAAqB,EAAE,OAAe;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","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\n/**\n * Stable codes for {@link IsomerError}, {@link CompositionValidationError},\n * and the runtime's `RegisteredViewInputError`. Hosts branch on `code`, not\n * on `message`. Codes name the condition, not the throwing module: duplicate\n * type at `definePrimitivePack`, `composePacks`, and `createIsomerRuntime` is the same\n * `DUPLICATE_PRIMITIVE_TYPE`; the message names the layer.\n */\nexport const ISOMER_ERROR_CODES = {\n AMBIGUOUS_FRAME: 'AMBIGUOUS_FRAME',\n AMBIGUOUS_STYLE_ADAPTER: 'AMBIGUOUS_STYLE_ADAPTER',\n AUTHOR_TYPE_MISMATCH: 'AUTHOR_TYPE_MISMATCH',\n AUTHORED_SCHEMA_REUSED: 'AUTHORED_SCHEMA_REUSED',\n COMPOSITION_INVALID: 'COMPOSITION_INVALID',\n CYCLIC_COMPOSITION: 'CYCLIC_COMPOSITION',\n DUPLICATE_AUTHORED_CHILD: 'DUPLICATE_AUTHORED_CHILD',\n DUPLICATE_ENHANCEMENT: 'DUPLICATE_ENHANCEMENT',\n DUPLICATE_PACK_ID: 'DUPLICATE_PACK_ID',\n DUPLICATE_PRIMITIVE_TYPE: 'DUPLICATE_PRIMITIVE_TYPE',\n DUPLICATE_VIEW: 'DUPLICATE_VIEW',\n EMPTY_FRAMES: 'EMPTY_FRAMES',\n EMPTY_PACK: 'EMPTY_PACK',\n EMPTY_PACKS: 'EMPTY_PACKS',\n EMPTY_PAGES: 'EMPTY_PAGES',\n EMPTY_VOCABULARY: 'EMPTY_VOCABULARY',\n ENHANCEMENT_ROOT_MISSING: 'ENHANCEMENT_ROOT_MISSING',\n EXPECTED_AUTHOR_COMPONENT: 'EXPECTED_AUTHOR_COMPONENT',\n EXPECTED_JSX_ELEMENT: 'EXPECTED_JSX_ELEMENT',\n EXPECTED_TEXT_CHILDREN: 'EXPECTED_TEXT_CHILDREN',\n INCOMPATIBLE_STYLE_COLLECTOR: 'INCOMPATIBLE_STYLE_COLLECTOR',\n INPUT_NOT_PLAIN_DATA: 'INPUT_NOT_PLAIN_DATA',\n INPUT_OVER_BUDGET: 'INPUT_OVER_BUDGET',\n INVALID_BODY_NODE: 'INVALID_BODY_NODE',\n INVALID_FRAME_BODY: 'INVALID_FRAME_BODY',\n MISSING_AUTHORED_TEXT: 'MISSING_AUTHORED_TEXT',\n MISSING_STYLE_ADAPTER: 'MISSING_STYLE_ADAPTER',\n RESERVED_NODE_FIELD: 'RESERVED_NODE_FIELD',\n UNEXPECTED_CHILDREN: 'UNEXPECTED_CHILDREN',\n UNKNOWN_FRAME: 'UNKNOWN_FRAME',\n UNKNOWN_PRIMITIVE_TYPE: 'UNKNOWN_PRIMITIVE_TYPE',\n UNKNOWN_SURFACE: 'UNKNOWN_SURFACE',\n UNKNOWN_VIEW: 'UNKNOWN_VIEW',\n UNSUPPORTED_CHILD_PATH: 'UNSUPPORTED_CHILD_PATH',\n VIEW_INPUT_INVALID: 'VIEW_INPUT_INVALID',\n VOCABULARY_UNRESOLVED: 'VOCABULARY_UNRESOLVED',\n} as const;\n\n/** One of {@link ISOMER_ERROR_CODES}. */\nexport type IsomerErrorCode =\n (typeof ISOMER_ERROR_CODES)[keyof typeof ISOMER_ERROR_CODES];\n\n/**\n * Thrown for construction and authoring failures that are not a\n * `CompositionValidationError`.\n *\n * Identify it by `name` and `code`, never `instanceof`: the SDK ships both\n * ESM and CJS builds, so a host can hold two copies of this class and an\n * identity check would miss one.\n */\nexport class IsomerError extends Error {\n readonly code: IsomerErrorCode;\n\n constructor(code: IsomerErrorCode, message: string) {\n super(message);\n this.name = 'IsomerError';\n this.code = code;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/composition/error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,eAAe,EAAE,iBAAiB;IAClC,uBAAuB,EAAE,yBAAyB;IAClD,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;IAChD,mBAAmB,EAAE,qBAAqB;IAC1C,kBAAkB,EAAE,oBAAoB;IACxC,wBAAwB,EAAE,0BAA0B;IACpD,qBAAqB,EAAE,uBAAuB;IAC9C,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,wBAAwB,EAAE,0BAA0B;IACpD,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,gBAAgB,EAAE,kBAAkB;IACpC,wBAAwB,EAAE,0BAA0B;IACpD,yBAAyB,EAAE,2BAA2B;IACtD,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;IAChD,4BAA4B,EAAE,8BAA8B;IAC5D,oBAAoB,EAAE,sBAAsB;IAC5C,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IACxC,mBAAmB,EAAE,qBAAqB;IAC1C,qBAAqB,EAAE,uBAAuB;IAC9C,qBAAqB,EAAE,uBAAuB;IAC9C,mBAAmB,EAAE,qBAAqB;IAC1C,mBAAmB,EAAE,qBAAqB;IAC1C,aAAa,EAAE,eAAe;IAC9B,sBAAsB,EAAE,wBAAwB;IAChD,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,cAAc;IAC5B,sBAAsB,EAAE,wBAAwB;IAChD,kBAAkB,EAAE,oBAAoB;IACxC,qBAAqB,EAAE,uBAAuB;CACtC,CAAC;AAMX;;;;;;;GAOG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IAE/B,YAAY,IAAqB,EAAE,OAAe;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","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\n/**\n * Stable codes for {@link IsomerError}, {@link CompositionValidationError},\n * and the runtime's `RegisteredViewInputError`. Hosts branch on `code`, not\n * on `message`. Codes name the condition, not the throwing module: duplicate\n * type at `definePrimitivePack`, `composePacks`, and `createIsomerRuntime` is the same\n * `DUPLICATE_PRIMITIVE_TYPE`; the message names the layer.\n */\nexport const ISOMER_ERROR_CODES = {\n AMBIGUOUS_FRAME: 'AMBIGUOUS_FRAME',\n AMBIGUOUS_STYLE_ADAPTER: 'AMBIGUOUS_STYLE_ADAPTER',\n AUTHOR_TYPE_MISMATCH: 'AUTHOR_TYPE_MISMATCH',\n AUTHORED_SCHEMA_REUSED: 'AUTHORED_SCHEMA_REUSED',\n COMPOSITION_INVALID: 'COMPOSITION_INVALID',\n CYCLIC_COMPOSITION: 'CYCLIC_COMPOSITION',\n DUPLICATE_AUTHORED_CHILD: 'DUPLICATE_AUTHORED_CHILD',\n DUPLICATE_ENHANCEMENT: 'DUPLICATE_ENHANCEMENT',\n DUPLICATE_FORMAT: 'DUPLICATE_FORMAT',\n DUPLICATE_PACK_ID: 'DUPLICATE_PACK_ID',\n DUPLICATE_PRIMITIVE_TYPE: 'DUPLICATE_PRIMITIVE_TYPE',\n DUPLICATE_VIEW: 'DUPLICATE_VIEW',\n EMPTY_FRAMES: 'EMPTY_FRAMES',\n EMPTY_PACK: 'EMPTY_PACK',\n EMPTY_PACKS: 'EMPTY_PACKS',\n EMPTY_PAGES: 'EMPTY_PAGES',\n EMPTY_VOCABULARY: 'EMPTY_VOCABULARY',\n ENHANCEMENT_ROOT_MISSING: 'ENHANCEMENT_ROOT_MISSING',\n EXPECTED_AUTHOR_COMPONENT: 'EXPECTED_AUTHOR_COMPONENT',\n EXPECTED_JSX_ELEMENT: 'EXPECTED_JSX_ELEMENT',\n EXPECTED_TEXT_CHILDREN: 'EXPECTED_TEXT_CHILDREN',\n INCOMPATIBLE_STYLE_COLLECTOR: 'INCOMPATIBLE_STYLE_COLLECTOR',\n INPUT_NOT_PLAIN_DATA: 'INPUT_NOT_PLAIN_DATA',\n INPUT_OVER_BUDGET: 'INPUT_OVER_BUDGET',\n INVALID_BODY_NODE: 'INVALID_BODY_NODE',\n INVALID_FRAME_BODY: 'INVALID_FRAME_BODY',\n INVALID_PACK_GROUPS: 'INVALID_PACK_GROUPS',\n MISSING_AUTHORED_TEXT: 'MISSING_AUTHORED_TEXT',\n MISSING_STYLE_ADAPTER: 'MISSING_STYLE_ADAPTER',\n RESERVED_NODE_FIELD: 'RESERVED_NODE_FIELD',\n UNEXPECTED_CHILDREN: 'UNEXPECTED_CHILDREN',\n UNKNOWN_FRAME: 'UNKNOWN_FRAME',\n UNKNOWN_PRIMITIVE_TYPE: 'UNKNOWN_PRIMITIVE_TYPE',\n UNKNOWN_SURFACE: 'UNKNOWN_SURFACE',\n UNKNOWN_VIEW: 'UNKNOWN_VIEW',\n UNSUPPORTED_CHILD_PATH: 'UNSUPPORTED_CHILD_PATH',\n VIEW_INPUT_INVALID: 'VIEW_INPUT_INVALID',\n VOCABULARY_UNRESOLVED: 'VOCABULARY_UNRESOLVED',\n} as const;\n\n/** One of {@link ISOMER_ERROR_CODES}. */\nexport type IsomerErrorCode =\n (typeof ISOMER_ERROR_CODES)[keyof typeof ISOMER_ERROR_CODES];\n\n/**\n * Thrown for construction and authoring failures that are not a\n * `CompositionValidationError`.\n *\n * Identify it by `name` and `code`, never `instanceof`: the SDK ships both\n * ESM and CJS builds, so a host can hold two copies of this class and an\n * identity check would miss one.\n */\nexport class IsomerError extends Error {\n readonly code: IsomerErrorCode;\n\n constructor(code: IsomerErrorCode, message: string) {\n super(message);\n this.name = 'IsomerError';\n this.code = code;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { type ActionEventRef } from './action_event.js';
|
|
2
|
-
export { type BodyNodeBase, type ChildNodeRef, type ChildNodeWalker, type SurfaceName, BODY_NODE_SURFACES, createChildNodeWalker, isVisibleOnSurface, someBodyNode, } from './body_node_base.js';
|
|
2
|
+
export { type BodyNodeBase, type ChildNodeRef, type ChildNodeWalker, type SurfaceName, BODY_NODE_SURFACES, SURFACE_NAMES, createChildNodeWalker, isVisibleOnSurface, someBodyNode, } from './body_node_base.js';
|
|
3
3
|
export { type Composition, type CompositionMeta } from './composition.js';
|
|
4
4
|
export { type IsomerErrorCode, ISOMER_ERROR_CODES, IsomerError } from './error.js';
|
|
5
5
|
export { mapCompositionNodes } from './map_nodes.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composition/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EACh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D,OAAO,EACL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,eAAe,EACpB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,oBAAoB,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
5
5
|
* 2.0.
|
|
6
6
|
*/
|
|
7
|
-
export { BODY_NODE_SURFACES, createChildNodeWalker, isVisibleOnSurface, someBodyNode, } from './body_node_base.js';
|
|
7
|
+
export { BODY_NODE_SURFACES, SURFACE_NAMES, createChildNodeWalker, isVisibleOnSurface, someBodyNode, } from './body_node_base.js';
|
|
8
8
|
export { ISOMER_ERROR_CODES, IsomerError } from './error.js';
|
|
9
9
|
export { mapCompositionNodes } from './map_nodes.js';
|
|
10
10
|
export { ALL_NAMED_COLORS, } from './named_color.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/composition/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAKL,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAwB,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAIL,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAIL,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,oBAAoB,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\nexport { type ActionEventRef } from './action_event';\nexport {\n type BodyNodeBase,\n type ChildNodeRef,\n type ChildNodeWalker,\n type SurfaceName,\n BODY_NODE_SURFACES,\n createChildNodeWalker,\n isVisibleOnSurface,\n someBodyNode,\n} from './body_node_base';\nexport { type Composition, type CompositionMeta } from './composition';\nexport { type IsomerErrorCode, ISOMER_ERROR_CODES, IsomerError } from './error';\nexport { mapCompositionNodes } from './map_nodes';\nexport {\n type NamedColor,\n type NamedColorPalette,\n type RenderTheme,\n ALL_NAMED_COLORS,\n} from './named_color';\nexport { type PrimitiveNode } from './node';\nexport { nameText, oneLine, quoteText } from './one_line';\nexport {\n type DisplayValue,\n type StructuredValue,\n type StructuredValueFormat,\n STRUCTURED_VALUE_FORMATS,\n} from './structured_value';\nexport {\n type ValidationError,\n CompositionValidationError,\n formatValidationError,\n} from './validation_error';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/composition/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAKL,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAwB,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAIL,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAIL,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,oBAAoB,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\nexport { type ActionEventRef } from './action_event';\nexport {\n type BodyNodeBase,\n type ChildNodeRef,\n type ChildNodeWalker,\n type SurfaceName,\n BODY_NODE_SURFACES,\n SURFACE_NAMES,\n createChildNodeWalker,\n isVisibleOnSurface,\n someBodyNode,\n} from './body_node_base';\nexport { type Composition, type CompositionMeta } from './composition';\nexport { type IsomerErrorCode, ISOMER_ERROR_CODES, IsomerError } from './error';\nexport { mapCompositionNodes } from './map_nodes';\nexport {\n type NamedColor,\n type NamedColorPalette,\n type RenderTheme,\n ALL_NAMED_COLORS,\n} from './named_color';\nexport { type PrimitiveNode } from './node';\nexport { nameText, oneLine, quoteText } from './one_line';\nexport {\n type DisplayValue,\n type StructuredValue,\n type StructuredValueFormat,\n STRUCTURED_VALUE_FORMATS,\n} from './structured_value';\nexport {\n type ValidationError,\n CompositionValidationError,\n formatValidationError,\n} from './validation_error';\n"]}
|
|
@@ -12,15 +12,15 @@ export interface StructuredValue {
|
|
|
12
12
|
/** Unformatted, in base units — a `percent` of `0.42` renders as 42%. */
|
|
13
13
|
raw: number | string;
|
|
14
14
|
/** How to render `raw`. Absent passes a string through and gives a number default formatting. */
|
|
15
|
-
format?: StructuredValueFormat;
|
|
15
|
+
format?: StructuredValueFormat | undefined;
|
|
16
16
|
/**
|
|
17
17
|
* Fraction digits for numeric formats. `number`, `percent`, and `currency`
|
|
18
18
|
* pad to it; omitted, `number` and `percent` keep at most two and `currency`
|
|
19
19
|
* two. `compact` and `bytes` drop trailing zeros and keep one when omitted.
|
|
20
20
|
*/
|
|
21
|
-
precision?: number;
|
|
21
|
+
precision?: number | undefined;
|
|
22
22
|
/** Three-letter currency code for `currency`; defaults to USD. */
|
|
23
|
-
currency?: string;
|
|
23
|
+
currency?: string | undefined;
|
|
24
24
|
}
|
|
25
25
|
/** A value-bearing field: preformatted prose, or a {@link StructuredValue} to format. */
|
|
26
26
|
export type DisplayValue = string | StructuredValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured_value.d.ts","sourceRoot":"","sources":["../../src/composition/structured_value.ts"],"names":[],"mappings":"AAOA,wDAAwD;AACxD,eAAO,MAAM,wBAAwB,oGAS3B,CAAC;AAEX,+CAA+C;AAC/C,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,iGAAiG;IACjG,MAAM,CAAC,EAAE,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"structured_value.d.ts","sourceRoot":"","sources":["../../src/composition/structured_value.ts"],"names":[],"mappings":"AAOA,wDAAwD;AACxD,eAAO,MAAM,wBAAwB,oGAS3B,CAAC;AAEX,+CAA+C;AAC/C,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,iGAAiG;IACjG,MAAM,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAC3C;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,yFAAyF;AACzF,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured_value.js","sourceRoot":"","sources":["../../src/composition/structured_value.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wDAAwD;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,QAAQ;IACR,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;IACP,UAAU;IACV,MAAM;IACN,cAAc;CACN,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\n/** Format hints a {@link StructuredValue} may carry. */\nexport const STRUCTURED_VALUE_FORMATS = [\n 'number',\n 'compact',\n 'percent',\n 'currency',\n 'bytes',\n 'duration',\n 'date',\n 'relativeTime',\n] as const;\n\n/** One of {@link STRUCTURED_VALUE_FORMATS}. */\nexport type StructuredValueFormat = (typeof STRUCTURED_VALUE_FORMATS)[number];\n\n/**\n * A raw quantity plus a format hint, so every surface renders the same string.\n *\n * Formatting happens once, in `formatDisplayValue`, rather than per renderer —\n * otherwise the text and Slack surfaces drift on rounding.\n */\nexport interface StructuredValue {\n /** Unformatted, in base units — a `percent` of `0.42` renders as 42%. */\n raw: number | string;\n /** How to render `raw`. Absent passes a string through and gives a number default formatting. */\n format?: StructuredValueFormat;\n /**\n * Fraction digits for numeric formats. `number`, `percent`, and `currency`\n * pad to it; omitted, `number` and `percent` keep at most two and `currency`\n * two. `compact` and `bytes` drop trailing zeros and keep one when omitted.\n */\n precision?: number;\n /** Three-letter currency code for `currency`; defaults to USD. */\n currency?: string;\n}\n\n/** A value-bearing field: preformatted prose, or a {@link StructuredValue} to format. */\nexport type DisplayValue = string | StructuredValue;\n"]}
|
|
1
|
+
{"version":3,"file":"structured_value.js","sourceRoot":"","sources":["../../src/composition/structured_value.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wDAAwD;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,QAAQ;IACR,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;IACP,UAAU;IACV,MAAM;IACN,cAAc;CACN,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\n/** Format hints a {@link StructuredValue} may carry. */\nexport const STRUCTURED_VALUE_FORMATS = [\n 'number',\n 'compact',\n 'percent',\n 'currency',\n 'bytes',\n 'duration',\n 'date',\n 'relativeTime',\n] as const;\n\n/** One of {@link STRUCTURED_VALUE_FORMATS}. */\nexport type StructuredValueFormat = (typeof STRUCTURED_VALUE_FORMATS)[number];\n\n/**\n * A raw quantity plus a format hint, so every surface renders the same string.\n *\n * Formatting happens once, in `formatDisplayValue`, rather than per renderer —\n * otherwise the text and Slack surfaces drift on rounding.\n */\nexport interface StructuredValue {\n /** Unformatted, in base units — a `percent` of `0.42` renders as 42%. */\n raw: number | string;\n /** How to render `raw`. Absent passes a string through and gives a number default formatting. */\n format?: StructuredValueFormat | undefined;\n /**\n * Fraction digits for numeric formats. `number`, `percent`, and `currency`\n * pad to it; omitted, `number` and `percent` keep at most two and `currency`\n * two. `compact` and `bytes` drop trailing zeros and keep one when omitted.\n */\n precision?: number | undefined;\n /** Three-letter currency code for `currency`; defaults to USD. */\n currency?: string | undefined;\n}\n\n/** A value-bearing field: preformatted prose, or a {@link StructuredValue} to format. */\nexport type DisplayValue = string | StructuredValue;\n"]}
|
package/dist/define/frame.d.ts
CHANGED
|
@@ -33,10 +33,10 @@ export interface FrameViewport<TTheme> {
|
|
|
33
33
|
* written against a narrowed node union while the runtime holds the erased form.
|
|
34
34
|
*/
|
|
35
35
|
export interface FrameDispatcher<TNode extends PrimitiveNode = PrimitiveNode> {
|
|
36
|
-
/** Draws one node on the `
|
|
37
|
-
|
|
38
|
-
/** The node's height in pixels; `0` when it is hidden from `
|
|
39
|
-
|
|
36
|
+
/** Draws one node on the `snapshot` surface. `key` must be unique among its siblings. */
|
|
37
|
+
renderSnapshot(node: TNode, key: string): ReactNode;
|
|
38
|
+
/** The node's height in pixels; `0` when it is hidden from `snapshot` or its primitive declares no `metrics.snapshotHeight`. */
|
|
39
|
+
estimateSnapshotHeight(node: TNode): number;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* What {@link Frame.wrap} is told about the composition it draws around.
|
|
@@ -63,7 +63,7 @@ export interface FrameComposition extends FrameHeader {
|
|
|
63
63
|
*/
|
|
64
64
|
export type FrameBody = readonly ReactNode[];
|
|
65
65
|
/**
|
|
66
|
-
* A document
|
|
66
|
+
* A document a `snapshot` render can produce: its geometry, the surround it draws
|
|
67
67
|
* around the body, and whatever it requires of a composition it is asked to
|
|
68
68
|
* draw.
|
|
69
69
|
*
|
|
@@ -77,16 +77,6 @@ export type FrameBody = readonly ReactNode[];
|
|
|
77
77
|
export interface Frame<TTheme> {
|
|
78
78
|
/** Width used when the caller passes none. */
|
|
79
79
|
defaultWidth: number;
|
|
80
|
-
/**
|
|
81
|
-
* Whether {@link Frame.estimateHeight} sums per-node heights, and so
|
|
82
|
-
* under-sizes the frame for a node whose primitive declares no
|
|
83
|
-
* `metrics.svgHeight` — `dispatcher.estimateSvgHeight` returns `0` for those.
|
|
84
|
-
*
|
|
85
|
-
* Defaults to `true`, because the gap is silent and a frame that measures
|
|
86
|
-
* nodes is the normal case. A fixed-size frame sets `false` once and stops
|
|
87
|
-
* the missing `svgHeight` warning reporting a metric nothing reads.
|
|
88
|
-
*/
|
|
89
|
-
sizesFromNodeHeights?: boolean;
|
|
90
80
|
/**
|
|
91
81
|
* Palette per mode. Frame and palette vary independently — a branded card is
|
|
92
82
|
* this geometry with a host's colors — so a host overrides one by spreading
|
|
@@ -95,8 +85,9 @@ export interface Frame<TTheme> {
|
|
|
95
85
|
theme: ThemePair<TTheme>;
|
|
96
86
|
/**
|
|
97
87
|
* Height for this body when the caller passes none, in the geometry this
|
|
98
|
-
* document defines.
|
|
99
|
-
*
|
|
88
|
+
* document defines. Calling {@link FrameDispatcher.estimateSnapshotHeight} is
|
|
89
|
+
* what makes a missing `metrics.snapshotHeight` size the frame short: that
|
|
90
|
+
* method returns `0` for a node whose primitive declares none.
|
|
100
91
|
*/
|
|
101
92
|
estimateHeight(composition: FrameComposition, dispatcher: FrameDispatcher): number;
|
|
102
93
|
/**
|
|
@@ -106,7 +97,7 @@ export interface Frame<TTheme> {
|
|
|
106
97
|
* Returned rather than thrown so a caller can decide what to do with it, but
|
|
107
98
|
* note where it is *not* checked: composition validation is frame-agnostic,
|
|
108
99
|
* and has to be, because the same composition can be valid in one frame and
|
|
109
|
-
* not another. Only the `
|
|
100
|
+
* not another. Only the `snapshot` surface consults this, on the frame a render
|
|
110
101
|
* actually names, and raises before drawing. A host that wants the answer
|
|
111
102
|
* earlier asks the frame directly.
|
|
112
103
|
*/
|
|
@@ -136,8 +127,6 @@ export interface Frame<TTheme> {
|
|
|
136
127
|
*/
|
|
137
128
|
export interface BoundFrame {
|
|
138
129
|
readonly defaultWidth: number;
|
|
139
|
-
/** See {@link Frame.sizesFromNodeHeights}; defaulted at binding. */
|
|
140
|
-
readonly sizesFromNodeHeights: boolean;
|
|
141
130
|
/** See {@link Frame.estimateHeight}. */
|
|
142
131
|
estimateHeight(composition: FrameComposition, dispatcher: FrameDispatcher): number;
|
|
143
132
|
/** See {@link Frame.validateBody}; empty when this frame states no rule. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/define/frame.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MA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