@elastic/isomer-sdk 0.2.0 → 0.4.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 +2 -0
- package/dist/cjs/composition/error.js.map +1 -1
- package/dist/cjs/composition/structured_value.js.map +1 -1
- package/dist/cjs/define/index.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/define/slack_blocks.js.map +1 -1
- package/dist/cjs/entries/index.js +5 -2
- package/dist/cjs/entries/index.js.map +1 -1
- package/dist/cjs/entries/markdown.js +3 -1
- package/dist/cjs/entries/markdown.js.map +1 -1
- package/dist/cjs/entries/react.js +2 -1
- package/dist/cjs/entries/react.js.map +1 -1
- package/dist/cjs/entries/slack.js +5 -1
- package/dist/cjs/entries/slack.js.map +1 -1
- package/dist/cjs/pack/enhancements.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/blocks.js +82 -0
- package/dist/cjs/render/markdown/blocks.js.map +1 -0
- 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 +5 -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 +36 -6
- 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/react/index.js +3 -1
- package/dist/cjs/render/react/index.js.map +1 -1
- package/dist/cjs/render/react/markdown_content.js +143 -0
- package/dist/cjs/render/react/markdown_content.js.map +1 -0
- package/dist/cjs/render/slack/blocks.js +7 -0
- package/dist/cjs/render/slack/blocks.js.map +1 -1
- package/dist/cjs/render/slack/container.js +62 -0
- package/dist/cjs/render/slack/container.js.map +1 -0
- package/dist/cjs/render/slack/envelope.js +70 -14
- package/dist/cjs/render/slack/envelope.js.map +1 -1
- package/dist/cjs/render/slack/format.js +56 -6
- package/dist/cjs/render/slack/format.js.map +1 -1
- package/dist/cjs/render/slack/index.js +7 -1
- package/dist/cjs/render/slack/index.js.map +1 -1
- package/dist/cjs/render/slack/markdown_content.js +36 -77
- package/dist/cjs/render/slack/markdown_content.js.map +1 -1
- package/dist/cjs/render/slack/unmodeled.js +38 -0
- package/dist/cjs/render/slack/unmodeled.js.map +1 -0
- package/dist/cjs/testing/conformance.js +15 -1
- package/dist/cjs/testing/conformance.js.map +1 -1
- package/dist/cjs/testing/index.js +2 -1
- package/dist/cjs/testing/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/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/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/index.d.ts +1 -1
- package/dist/define/index.d.ts.map +1 -1
- package/dist/define/index.js.map +1 -1
- package/dist/define/primitive_module.d.ts +14 -5
- 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/define/slack_blocks.d.ts +31 -1
- package/dist/define/slack_blocks.d.ts.map +1 -1
- package/dist/define/slack_blocks.js.map +1 -1
- package/dist/entries/index.d.ts +2 -2
- package/dist/entries/index.d.ts.map +1 -1
- package/dist/entries/index.js +2 -2
- 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/react.d.ts +1 -1
- package/dist/entries/react.d.ts.map +1 -1
- package/dist/entries/react.js +1 -1
- package/dist/entries/react.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/enhancements.d.ts +4 -0
- package/dist/pack/enhancements.d.ts.map +1 -1
- package/dist/pack/enhancements.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/blocks.d.ts +6 -0
- package/dist/render/markdown/blocks.d.ts.map +1 -0
- package/dist/render/markdown/blocks.js +77 -0
- package/dist/render/markdown/blocks.js.map +1 -0
- 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 +2 -0
- package/dist/render/markdown/index.d.ts.map +1 -1
- package/dist/render/markdown/index.js +2 -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 +4 -2
- package/dist/render/primitive_dispatch.d.ts.map +1 -1
- package/dist/render/primitive_dispatch.js +36 -6
- 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/react/index.d.ts +1 -0
- package/dist/render/react/index.d.ts.map +1 -1
- package/dist/render/react/index.js +1 -0
- package/dist/render/react/index.js.map +1 -1
- package/dist/render/react/markdown_content.d.ts +9 -0
- package/dist/render/react/markdown_content.d.ts.map +1 -0
- package/dist/render/react/markdown_content.js +139 -0
- package/dist/render/react/markdown_content.js.map +1 -0
- package/dist/render/slack/blocks.d.ts +8 -1
- package/dist/render/slack/blocks.d.ts.map +1 -1
- package/dist/render/slack/blocks.js +7 -0
- package/dist/render/slack/blocks.js.map +1 -1
- package/dist/render/slack/container.d.ts +25 -0
- package/dist/render/slack/container.d.ts.map +1 -0
- package/dist/render/slack/container.js +55 -0
- package/dist/render/slack/container.js.map +1 -0
- package/dist/render/slack/envelope.d.ts +6 -4
- package/dist/render/slack/envelope.d.ts.map +1 -1
- package/dist/render/slack/envelope.js +71 -15
- package/dist/render/slack/envelope.js.map +1 -1
- package/dist/render/slack/format.d.ts +15 -3
- package/dist/render/slack/format.d.ts.map +1 -1
- package/dist/render/slack/format.js +54 -5
- package/dist/render/slack/format.js.map +1 -1
- package/dist/render/slack/index.d.ts +4 -2
- package/dist/render/slack/index.d.ts.map +1 -1
- package/dist/render/slack/index.js +2 -0
- package/dist/render/slack/index.js.map +1 -1
- package/dist/render/slack/markdown_content.d.ts +3 -2
- package/dist/render/slack/markdown_content.d.ts.map +1 -1
- package/dist/render/slack/markdown_content.js +27 -68
- package/dist/render/slack/markdown_content.js.map +1 -1
- package/dist/render/slack/unmodeled.d.ts +16 -0
- package/dist/render/slack/unmodeled.d.ts.map +1 -0
- package/dist/render/slack/unmodeled.js +32 -0
- package/dist/render/slack/unmodeled.js.map +1 -0
- package/dist/testing/conformance.d.ts +3 -1
- package/dist/testing/conformance.d.ts.map +1 -1
- package/dist/testing/conformance.js +14 -0
- package/dist/testing/conformance.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/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/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conformance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C,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;KACF;CACF,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// The behaviour every primitive definition owes its callers, expressed once.\n//\n// Framework-agnostic on purpose: only `node:assert/strict` and Node builtins,\n// so this ships on a public entry without dragging vitest into a vocabulary\n// package's dependency set. Each pack drives the array with `it.each`, so a\n// second vocabulary costs one package and one test file.\n\nimport assert from 'node:assert/strict';\n\nimport type { ChildNodeWalker } from '../composition/body_node_base';\nimport type { Composition } from '../composition/composition';\nimport type { ValidationError } from '../composition/validation_error';\nimport { exampleNodes, primitiveExamples } from '../define/primitive_example';\nimport type {\n AnyPrimitiveDefinition,\n PrimitiveNode,\n} from '../define/primitive_module';\nimport {\n anchoredNodes,\n anchorValue,\n NODE_ANCHOR_ATTRIBUTE,\n nodeType,\n} from '../render/anchors';\nimport type { HTMLRenderResult } from '../render/html/envelope';\nimport type { SlackBlock } from '../render/slack/blocks';\nimport { checkInputBudget } from '../validate/input_budget';\nimport type { ValidationResult } from '../validate/validation';\n\n/**\n * The foreign node {@link PrimitiveConformanceHarness.nestForeignChild}\n * hands a container must render text/markdown containing this string, or the\n * cross-pack nesting case cannot tell a dropped child from an empty one.\n */\nexport const CONFORMANCE_FOREIGN_MARKER = 'isomerConformanceForeign';\n\n/** One example node, paired with the definition that published it. */\nexport interface PrimitiveConformanceExample {\n readonly definition: AnyPrimitiveDefinition;\n /** Always `definition.type`, lifted onto the row so `it.each` titles can read it. */\n readonly type: string;\n /** Index into {@link AnyPrimitiveDefinition.examples}, and half of the preview hint a failure prints. */\n readonly exampleIndex: number;\n /** The example's `name`, absent for a bare node. */\n readonly exampleName?: string;\n readonly node: PrimitiveNode;\n}\n\n/** The subset of a host's HTML render options the cases exercise. */\nexport interface PrimitiveConformanceHtmlOptions {\n /** `'separate'` must move the stylesheet out of the markup and into `css`; the CSS cases assert against that field. */\n readonly css?: 'inline' | 'separate';\n /** `'readable'` must emit human-legible class names, which the CSS coverage case matches back against the emitted selectors. */\n readonly names?: string;\n /** Must render node anchors, as the `anchors` HTML render option does. */\n readonly anchors?: boolean;\n}\n\n/** The subset of a host's `snapshot` render result the cases assert on. */\nexport interface PrimitiveConformanceSnapshotResult {\n /** Must be empty for every published example. */\n readonly validationErrors: readonly ValidationError[];\n /** The frame's markup, stylesheet included or not. */\n readonly html: string;\n /** `total` is the rendered byte size, and must be positive. */\n readonly measurement: { readonly total: number };\n}\n\n/** The subset of a host's Slack render result the cases assert on. */\nexport interface PrimitiveConformanceSlackResult {\n readonly blocks: readonly SlackBlock[];\n /** Notification fallback text. Must be non-empty. */\n readonly text: string;\n}\n\n/**\n * Pack-owned render and validation bindings. The cases cannot import a\n * vocabulary package, so the pack closes over its dispatcher, frame, and\n * theme when it builds this object.\n *\n * Unsuffixed members take a single node; the `Composition`-suffixed ones take\n * a whole {@link Composition}. Optional members gate the cases that need\n * them, so a pack supplies only what its surfaces can answer.\n */\nexport interface PrimitiveConformanceHarness {\n /**\n * The smallest composition that carries one node. Its `title` must be\n * `'Conformance fixture'`, which the envelope cases look for as\n * `CONFORMANCE FIXTURE` in text and `# Conformance fixture` in markdown.\n */\n wrapComposition(node: PrimitiveNode): Composition;\n /** Validation errors for the node on its own. Must be empty for every published example. */\n validateNode(node: PrimitiveNode): readonly ValidationError[];\n /** Whole-composition validation. Must be `valid` with no `errors` for a wrapped example. */\n validateComposition(composition: Composition): ValidationResult;\n /** Must return something other than `undefined`; the case does not mount the element. */\n renderReact(node: PrimitiveNode): unknown;\n /** Drives the pack's style collection for one node. Must not throw. */\n collectStyles(node: PrimitiveNode): void;\n /** Must return a string with non-whitespace content. */\n renderText(node: PrimitiveNode): string;\n /** Must return a string with non-whitespace content. */\n renderMarkdown(node: PrimitiveNode): string;\n /** Must return at least one block, each an object with a string `type`. */\n renderSlack(node: PrimitiveNode): readonly SlackBlock[];\n /** `key` is unique per example and only has to survive into the React tree. Must not throw. Omit for a pack with no `snapshot` path. */\n renderSnapshot?(node: PrimitiveNode, key: string): unknown;\n /** Must be finite and greater than zero, so a frame can lay the node out unrendered. Omit for a pack with no `snapshot` path. */\n estimateSnapshotHeight?(node: PrimitiveNode): number;\n /**\n * Set `false` for a pack whose frame is a fixed size, so its primitives are\n * not required to report a positive `metrics.snapshotHeight`. Skips the\n * positive-finite height assertion.\n */\n sizesFromNodeHeights?: boolean;\n /**\n * For a container example, returns `container` with one of its children\n * replaced by a node from a pack the harness composed in only for this\n * check — never one `container`'s own pack registers. That node's `text`\n * and `markdown` renderers must emit {@link CONFORMANCE_FOREIGN_MARKER}.\n * Omit to skip the cross-pack nesting case.\n */\n nestForeignChild?(container: PrimitiveNode): PrimitiveNode;\n /**\n * Must honor {@link PrimitiveConformanceHtmlOptions}. Cases assert the\n * markup wraps the body in a `<section>`, that `measurement.js` is zero, and\n * that `validationErrors` is empty. Omit to skip the HTML cases.\n */\n renderHTML?(\n composition: Composition,\n options?: PrimitiveConformanceHtmlOptions\n ): HTMLRenderResult;\n /**\n * The child walker over every definition the harness renders with. Set it\n * once every `react` renderer spreads `nodeAnchor` on its root; the anchor\n * case then asserts each node renders one.\n */\n anchorWalk?: ChildNodeWalker;\n /** Must throw when `css` references a `var(--name)` it never declares. Omit to skip the CSS variable case. */\n assertVarRefsHaveDeclarations?(css: string): void;\n /** Whole-composition text render, title envelope included. */\n renderTextComposition(composition: Composition): string;\n /** Whole-composition markdown render, title heading included. */\n renderMarkdownComposition(composition: Composition): string;\n /** Must lead with a `plain_text` header block carrying the composition title. */\n renderSlackComposition(\n composition: Composition\n ): PrimitiveConformanceSlackResult;\n /** Must resolve to non-empty markup with no validation errors. Omit for a pack with no frame. */\n renderSnapshotComposition?(\n composition: Composition\n ): Promise<PrimitiveConformanceSnapshotResult>;\n}\n\n/** One assertion, run once per example. */\nexport interface PrimitiveConformanceCase {\n readonly name: string;\n /** Signals failure by throwing. May be async, so a pack must await it. */\n readonly run: (\n example: PrimitiveConformanceExample,\n harness: PrimitiveConformanceHarness\n ) => void | Promise<void>;\n}\n\n/** Every definition's examples, flattened to one row each. */\nexport const examplesFromDefinitions = (\n definitions: readonly AnyPrimitiveDefinition[]\n): readonly PrimitiveConformanceExample[] =>\n definitions.flatMap((definition) =>\n primitiveExamples(definition).map(({ name, node }, exampleIndex) => ({\n definition,\n type: definition.type,\n exampleIndex,\n ...(name === undefined ? {} : { exampleName: name }),\n node,\n }))\n );\n\n/** Every example crossed with every case, shaped for `it.each`. */\nexport const primitiveConformanceRows = (\n definitions: readonly AnyPrimitiveDefinition[]\n): readonly (PrimitiveConformanceExample & PrimitiveConformanceCase)[] =>\n examplesFromDefinitions(definitions).flatMap((example) =>\n primitiveConformanceCases.map((conformanceCase) => ({\n ...example,\n ...conformanceCase,\n }))\n );\n\n/**\n * Asserts the inventory itself holds up: the pack has examples, every\n * definition contributes one, `catalog.name` and example names are non-empty,\n * example names are unique within their definition, each example's `type` matches its definition, and\n * `catalog.example` is within the input budget and parses or matches a\n * published example.\n */\nexport const runPrimitiveInventoryConformance = (\n definitions: readonly AnyPrimitiveDefinition[]\n): void => {\n const examples = examplesFromDefinitions(definitions);\n assert.ok(examples.length > 0, 'expected at least one primitive example');\n for (const definition of definitions) {\n assert.ok(\n definition.examples.length > 0,\n `${definition.type} primitive must expose at least one example`\n );\n const { name: catalogName } = definition.catalog;\n assert.ok(\n catalogName === undefined || catalogName.trim().length > 0,\n `${definition.type} catalog.name must be non-empty when present`\n );\n const names = new Set<string>();\n for (const { name } of primitiveExamples(definition)) {\n if (name === undefined) {\n continue;\n }\n assert.ok(\n name.trim().length > 0,\n `${definition.type} example names must be non-empty`\n );\n assert.ok(\n !names.has(name),\n `${definition.type} has two examples named ${JSON.stringify(name)}`\n );\n names.add(name);\n }\n const checked = checkInputBudget(definition.catalog.example);\n if (!checked.valid) {\n assert.fail(\n `${definition.type} catalog.example must be within the input budget: ${checked.error.message}`\n );\n }\n const catalogExample = checked.value;\n const matchesPublished = exampleNodes(definition).some((node) => {\n const published = checkInputBudget(node);\n return (\n published.valid &&\n JSON.stringify(published.value) === JSON.stringify(catalogExample)\n );\n });\n if (matchesPublished) {\n continue;\n }\n const parsed = definition.schema.safeParse(catalogExample);\n assert.ok(\n parsed.success,\n `${definition.type} catalog.example must parse against its schema or match a published example`\n );\n }\n for (const { type, node } of examples) {\n assert.equal(node.type, type);\n }\n};\n\nconst previewHint = ({\n type,\n exampleIndex,\n exampleName,\n}: PrimitiveConformanceExample): string =>\n `Failing example: \\`${type}\\` definition, examples[${exampleIndex}]` +\n `${exampleName === undefined ? '' : ` (${JSON.stringify(exampleName)})`}.`;\n\nconst renderedClassNames = (html: string): string[] => {\n const classNames = new Set<string>();\n for (const match of html.matchAll(/\\bclass=\"([^\"]+)\"/g)) {\n match[1]!\n .split(/\\s+/)\n .filter(Boolean)\n .forEach((className) => classNames.add(className));\n }\n return [...classNames].sort();\n};\n\n/** The node anchor values in serialized `html`, in document order. */\nconst renderedAnchors = (html: string): string[] => {\n const attribute = new RegExp(`\\\\s${NODE_ANCHOR_ATTRIBUTE}=\"([^\"]*)\"`);\n // Only opening tags: the serializer escapes `<`, `>`, and `\"` in text and attribute values.\n return [...html.matchAll(/<[a-zA-Z][^>]*>/g)].flatMap(([tag]) => {\n const [, value] = attribute.exec(tag) ?? [];\n return value === undefined ? [] : [value];\n });\n};\n\nconst cssEscapeClass = (className: string): string =>\n className.replace(/([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^`{|}~])/g, '\\\\$1');\n\nconst cssHasClassSelector = (css: string, className: string): boolean =>\n new RegExp(`\\\\.${cssEscapeClass(className)}(?![\\\\w-])`).test(css);\n\n/**\n * Every assertion a primitive owes its callers, for a pack to drive with\n * `it.each`.\n */\nexport const primitiveConformanceCases: readonly PrimitiveConformanceCase[] = [\n {\n name: 'validates as a primitive node and inside a composition',\n run: (example, harness) => {\n const { node } = example;\n const hint = previewHint(example);\n const primitiveErrors = [...harness.validateNode(node)];\n assert.deepEqual(primitiveErrors, [], hint);\n const result = harness.validateComposition(harness.wrapComposition(node));\n assert.equal(result.valid, true, hint);\n assert.deepEqual(result.errors, [], hint);\n },\n },\n {\n name: 'renders through React without throwing',\n run: ({ node }, harness) => {\n const rendered = harness.renderReact(node);\n assert.notEqual(rendered, undefined);\n },\n },\n {\n name: 'collects styles without throwing',\n run: ({ node }, harness) => {\n assert.doesNotThrow(() => harness.collectStyles(node));\n },\n },\n {\n name: 'a container recurses through scope for a node from another pack',\n run: ({ definition, node }, harness) => {\n if (!definition.children || !harness.nestForeignChild) {\n return;\n }\n const nested = harness.nestForeignChild(node);\n assert.notEqual(harness.renderReact(nested), undefined);\n assert.ok(\n harness.renderText(nested).includes(CONFORMANCE_FOREIGN_MARKER)\n );\n assert.ok(\n harness.renderMarkdown(nested).includes(CONFORMANCE_FOREIGN_MARKER)\n );\n },\n },\n {\n name: 'renders through plain text with non-empty output',\n run: ({ node }, harness) => {\n const text = harness.renderText(node);\n assert.equal(typeof text, 'string');\n assert.ok(text.trim().length > 0);\n },\n },\n {\n name: 'renders through markdown with non-empty output',\n run: ({ node }, harness) => {\n const markdown = harness.renderMarkdown(node);\n assert.equal(typeof markdown, 'string');\n assert.ok(markdown.trim().length > 0);\n },\n },\n {\n name: 'renders through Slack dispatch returning at least one block',\n run: ({ node }, harness) => {\n const blocks = harness.renderSlack(node);\n assert.ok(blocks.length > 0);\n for (const block of blocks) {\n assert.equal(typeof block, 'object');\n assert.equal(typeof block.type, 'string');\n }\n },\n },\n {\n name: 'renders through snapshot primitive dispatch without throwing',\n run: ({ type, exampleIndex, node }, harness) => {\n if (!harness.renderSnapshot) {\n return;\n }\n assert.doesNotThrow(() =>\n harness.renderSnapshot?.(node, `conformance-${type}-${exampleIndex}`)\n );\n },\n },\n {\n name: 'reports a positive finite snapshot height estimate',\n run: ({ node }, harness) => {\n if (\n harness.sizesFromNodeHeights === false ||\n !harness.estimateSnapshotHeight\n ) {\n return;\n }\n const height = harness.estimateSnapshotHeight(node);\n assert.equal(Number.isFinite(height), true);\n assert.ok(height > 0);\n },\n },\n {\n name: 'renders through renderHTML wrapped in a minimal composition',\n run: ({ node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node));\n assert.deepEqual(result.validationErrors, []);\n assert.ok(result.html.includes('<section'));\n assert.equal(result.measurement.js, 0);\n assert.ok(result.measurement.total > 0);\n },\n },\n {\n name: 'renders no node anchors unless asked',\n run: ({ node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const { body } = harness.renderHTML(harness.wrapComposition(node));\n assert.deepEqual(renderedAnchors(body), []);\n },\n },\n {\n name: 'renders a node anchor on every node when asked',\n run: (example, harness) => {\n if (!harness.renderHTML || !harness.anchorWalk) {\n return;\n }\n const composition = harness.wrapComposition(example.node);\n const { body } = harness.renderHTML(composition, { anchors: true });\n const expected = anchoredNodes(\n composition.body,\n harness.anchorWalk\n ).flatMap((anchored) => {\n const anchoredType = nodeType(anchored);\n return anchoredType === undefined ? [] : [anchorValue(anchoredType)];\n });\n assert.deepEqual(\n renderedAnchors(body),\n expected,\n `Expected one anchor per node, in walker order. ${previewHint(example)}`\n );\n },\n },\n {\n name: 'emits CSS where every var(...) reference has a matching declaration',\n run: ({ node }, harness) => {\n if (!harness.renderHTML || !harness.assertVarRefsHaveDeclarations) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node), {\n css: 'separate',\n });\n harness.assertVarRefsHaveDeclarations(result.css);\n },\n },\n {\n name: 'reaches every rendered readable class in compact CSS collection',\n run: (example, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const { type, exampleIndex, node } = example;\n const result = harness.renderHTML(harness.wrapComposition(node), {\n css: 'separate',\n names: 'readable',\n });\n const missing = renderedClassNames(result.body).filter(\n (className) => !cssHasClassSelector(result.css, className)\n );\n const hint =\n `Missing CSS for ${type} example #${exampleIndex}: ` +\n `${missing.join(', ') || '(none)'}. ` +\n previewHint(example);\n assert.deepEqual(missing, [], hint);\n },\n },\n {\n name: 'renders through renderText wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const text = harness.renderTextComposition(harness.wrapComposition(node));\n assert.ok(text.length > 0);\n assert.ok(text.includes('CONFORMANCE FIXTURE'));\n },\n },\n {\n name: 'renders through renderMarkdown wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const markdown = harness.renderMarkdownComposition(\n harness.wrapComposition(node)\n );\n assert.ok(markdown.length > 0);\n assert.ok(markdown.includes('# Conformance fixture'));\n },\n },\n {\n name: 'renders through renderSlack wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const result = harness.renderSlackComposition(\n harness.wrapComposition(node)\n );\n assert.ok(result.blocks.length > 0);\n assert.ok(result.text.length > 0);\n const first = result.blocks[0];\n assert.ok(first);\n if (first.type !== 'header') {\n assert.fail(`expected a header block, got ${first.type}`);\n }\n assert.equal(first.text.type, 'plain_text');\n },\n },\n {\n name: 'renders a snapshot wrapped in a minimal composition',\n run: async ({ node }, harness) => {\n if (!harness.renderSnapshotComposition) {\n return;\n }\n const result = await harness.renderSnapshotComposition(\n harness.wrapComposition(node)\n );\n assert.deepEqual(result.validationErrors, []);\n assert.ok(result.html.trim().length > 0);\n assert.ok(result.measurement.total > 0);\n },\n },\n];\n"]}
|
|
1
|
+
{"version":3,"file":"conformance.js","sourceRoot":"","sources":["../../src/testing/conformance.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,6EAA6E;AAC7E,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,4EAA4E;AAC5E,yDAAyD;AAEzD,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAKxC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B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,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC9C,CAAC;KACF;IACD;QACE,IAAI,EAAE,qDAAqD;QAC3D,GAAG,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE;YAC/B,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC;gBACvC,OAAO;YACT,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,yBAAyB,CACpD,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAC9B,CAAC;YACF,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;YAC9C,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;KACF;CACF,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// The behaviour every primitive definition owes its callers, expressed once.\n//\n// Framework-agnostic on purpose: only `node:assert/strict` and Node builtins,\n// so this ships on a public entry without dragging vitest into a vocabulary\n// package's dependency set. Each pack drives the array with `it.each`, so a\n// second vocabulary costs one package and one test file.\n\nimport assert from 'node:assert/strict';\n\nimport type { ChildNodeWalker } from '../composition/body_node_base';\nimport type { Composition } from '../composition/composition';\nimport type { ValidationError } from '../composition/validation_error';\nimport { exampleNodes, primitiveExamples } from '../define/primitive_example';\nimport type {\n AnyPrimitiveDefinition,\n PrimitiveNode,\n} from '../define/primitive_module';\nimport {\n anchoredNodes,\n anchorValue,\n NODE_ANCHOR_ATTRIBUTE,\n nodeType,\n} from '../render/anchors';\nimport type { HTMLRenderResult } from '../render/html/envelope';\nimport type { SlackBlock } from '../render/slack/blocks';\nimport {\n isModeledSlackBlockType,\n isUnmodeledSlackBlock,\n} from '../render/slack/unmodeled';\nimport { checkInputBudget } from '../validate/input_budget';\nimport type { ValidationResult } from '../validate/validation';\n\n/**\n * The foreign node {@link PrimitiveConformanceHarness.nestForeignChild}\n * hands a container must render text/markdown containing this string, or the\n * cross-pack nesting case cannot tell a dropped child from an empty one.\n */\nexport const CONFORMANCE_FOREIGN_MARKER = 'isomerConformanceForeign';\n\n/** The `title` {@link PrimitiveConformanceHarness.wrapComposition} must give its composition. */\nexport const CONFORMANCE_FIXTURE_TITLE = 'Conformance fixture';\n\n/** One example node, paired with the definition that published it. */\nexport interface PrimitiveConformanceExample {\n readonly definition: AnyPrimitiveDefinition;\n /** Always `definition.type`, lifted onto the row so `it.each` titles can read it. */\n readonly type: string;\n /** Index into {@link AnyPrimitiveDefinition.examples}, and half of the preview hint a failure prints. */\n readonly exampleIndex: number;\n /** The example's `name`, absent for a bare node. */\n readonly exampleName?: string;\n readonly node: PrimitiveNode;\n}\n\n/** The subset of a host's HTML render options the cases exercise. */\nexport interface PrimitiveConformanceHtmlOptions {\n /** `'separate'` must move the stylesheet out of the markup and into `css`; the CSS cases assert against that field. */\n readonly css?: 'inline' | 'separate';\n /** `'readable'` must emit human-legible class names, which the CSS coverage case matches back against the emitted selectors. */\n readonly names?: string;\n /** Must render node anchors, as the `anchors` HTML render option does. */\n readonly anchors?: boolean;\n}\n\n/** The subset of a host's `snapshot` render result the cases assert on. */\nexport interface PrimitiveConformanceSnapshotResult {\n /** Must be empty for every published example. */\n readonly validationErrors: readonly ValidationError[];\n /** The frame's markup, stylesheet included or not. */\n readonly html: string;\n /** `total` is the rendered byte size, and must be positive. */\n readonly measurement: { readonly total: number };\n}\n\n/** The subset of a host's Slack render result the cases assert on. */\nexport interface PrimitiveConformanceSlackResult {\n readonly blocks: readonly SlackBlock[];\n /** Notification fallback text. Must be non-empty. */\n readonly text: string;\n}\n\n/**\n * Pack-owned render and validation bindings. The cases cannot import a\n * vocabulary package, so the pack closes over its dispatcher, frame, and\n * theme when it builds this object.\n *\n * Unsuffixed members take a single node; the `Composition`-suffixed ones take\n * a whole {@link Composition}. Optional members gate the cases that need\n * them, so a pack supplies only what its surfaces can answer.\n */\nexport interface PrimitiveConformanceHarness {\n /**\n * The smallest composition that carries one node. Its `title` must be\n * {@link CONFORMANCE_FIXTURE_TITLE}, which the envelope cases look for as\n * `CONFORMANCE FIXTURE` in text and `# Conformance fixture` in markdown.\n */\n wrapComposition(node: PrimitiveNode): Composition;\n /** Validation errors for the node on its own. Must be empty for every published example. */\n validateNode(node: PrimitiveNode): readonly ValidationError[];\n /** Whole-composition validation. Must be `valid` with no `errors` for a wrapped example. */\n validateComposition(composition: Composition): ValidationResult;\n /** Must return something other than `undefined`; the case does not mount the element. */\n renderReact(node: PrimitiveNode): unknown;\n /** Drives the pack's style collection for one node. Must not throw. */\n collectStyles(node: PrimitiveNode): void;\n /** Must return a string with non-whitespace content. */\n renderText(node: PrimitiveNode): string;\n /** Must return a string with non-whitespace content. */\n renderMarkdown(node: PrimitiveNode): string;\n /** Must return at least one block, each an object with a string `type`. */\n renderSlack(node: PrimitiveNode): readonly SlackBlock[];\n /** `key` is unique per example and only has to survive into the React tree. Must not throw. Omit for a pack with no `snapshot` path. */\n renderSnapshot?(node: PrimitiveNode, key: string): unknown;\n /** Must be finite and greater than zero, so a frame can lay the node out unrendered. Omit for a pack with no `snapshot` path. */\n estimateSnapshotHeight?(node: PrimitiveNode): number;\n /**\n * Set `false` for a pack whose frame is a fixed size, so its primitives are\n * not required to report a positive `metrics.snapshotHeight`. Skips the\n * positive-finite height assertion.\n */\n sizesFromNodeHeights?: boolean;\n /**\n * For a container example, returns `container` with one of its children\n * replaced by a node from a pack the harness composed in only for this\n * check — never one `container`'s own pack registers. That node's `text`\n * and `markdown` renderers must emit {@link CONFORMANCE_FOREIGN_MARKER}.\n * Omit to skip the cross-pack nesting case.\n */\n nestForeignChild?(container: PrimitiveNode): PrimitiveNode;\n /**\n * Must honor {@link PrimitiveConformanceHtmlOptions}. Cases assert the\n * markup wraps the body in a `<section>`, that `measurement.js` is zero, and\n * that `validationErrors` is empty. Omit to skip the HTML cases.\n */\n renderHTML?(\n composition: Composition,\n options?: PrimitiveConformanceHtmlOptions\n ): HTMLRenderResult;\n /**\n * The child walker over every definition the harness renders with. Set it\n * once every `react` renderer spreads `nodeAnchor` on its root; the anchor\n * case then asserts each node renders one.\n */\n anchorWalk?: ChildNodeWalker;\n /** Must throw when `css` references a `var(--name)` it never declares. Omit to skip the CSS variable case. */\n assertVarRefsHaveDeclarations?(css: string): void;\n /** Whole-composition text render, title envelope included. */\n renderTextComposition(composition: Composition): string;\n /** Whole-composition markdown render, title heading included. */\n renderMarkdownComposition(composition: Composition): string;\n /** Must lead with a `plain_text` header block carrying the composition title. */\n renderSlackComposition(\n composition: Composition\n ): PrimitiveConformanceSlackResult;\n /** Must resolve to non-empty markup with no validation errors. Omit for a pack with no frame. */\n renderSnapshotComposition?(\n composition: Composition\n ): Promise<PrimitiveConformanceSnapshotResult>;\n}\n\n/** One assertion, run once per example. */\nexport interface PrimitiveConformanceCase {\n readonly name: string;\n /** Signals failure by throwing. May be async, so a pack must await it. */\n readonly run: (\n example: PrimitiveConformanceExample,\n harness: PrimitiveConformanceHarness\n ) => void | Promise<void>;\n}\n\n/** Every definition's examples, flattened to one row each. */\nexport const examplesFromDefinitions = (\n definitions: readonly AnyPrimitiveDefinition[]\n): readonly PrimitiveConformanceExample[] =>\n definitions.flatMap((definition) =>\n primitiveExamples(definition).map(({ name, node }, exampleIndex) => ({\n definition,\n type: definition.type,\n exampleIndex,\n ...(name === undefined ? {} : { exampleName: name }),\n node,\n }))\n );\n\n/** Every example crossed with every case, shaped for `it.each`. */\nexport const primitiveConformanceRows = (\n definitions: readonly AnyPrimitiveDefinition[]\n): readonly (PrimitiveConformanceExample & PrimitiveConformanceCase)[] =>\n examplesFromDefinitions(definitions).flatMap((example) =>\n primitiveConformanceCases.map((conformanceCase) => ({\n ...example,\n ...conformanceCase,\n }))\n );\n\n/**\n * Asserts the inventory itself holds up: the pack has examples, every\n * definition contributes one, `catalog.name` and example names are non-empty,\n * example names are unique within their definition, each example's `type` matches its definition, and\n * `catalog.example` is within the input budget and parses or matches a\n * published example.\n */\nexport const runPrimitiveInventoryConformance = (\n definitions: readonly AnyPrimitiveDefinition[]\n): void => {\n const examples = examplesFromDefinitions(definitions);\n assert.ok(examples.length > 0, 'expected at least one primitive example');\n for (const definition of definitions) {\n assert.ok(\n definition.examples.length > 0,\n `${definition.type} primitive must expose at least one example`\n );\n const { name: catalogName } = definition.catalog;\n assert.ok(\n catalogName === undefined || catalogName.trim().length > 0,\n `${definition.type} catalog.name must be non-empty when present`\n );\n const names = new Set<string>();\n for (const { name } of primitiveExamples(definition)) {\n if (name === undefined) {\n continue;\n }\n assert.ok(\n name.trim().length > 0,\n `${definition.type} example names must be non-empty`\n );\n assert.ok(\n !names.has(name),\n `${definition.type} has two examples named ${JSON.stringify(name)}`\n );\n names.add(name);\n }\n const checked = checkInputBudget(definition.catalog.example);\n if (!checked.valid) {\n assert.fail(\n `${definition.type} catalog.example must be within the input budget: ${checked.error.message}`\n );\n }\n const catalogExample = checked.value;\n const matchesPublished = exampleNodes(definition).some((node) => {\n const published = checkInputBudget(node);\n return (\n published.valid &&\n JSON.stringify(published.value) === JSON.stringify(catalogExample)\n );\n });\n if (matchesPublished) {\n continue;\n }\n const parsed = definition.schema.safeParse(catalogExample);\n assert.ok(\n parsed.success,\n `${definition.type} catalog.example must parse against its schema or match a published example`\n );\n }\n for (const { type, node } of examples) {\n assert.equal(node.type, type);\n }\n};\n\nconst previewHint = ({\n type,\n exampleIndex,\n exampleName,\n}: PrimitiveConformanceExample): string =>\n `Failing example: \\`${type}\\` definition, examples[${exampleIndex}]` +\n `${exampleName === undefined ? '' : ` (${JSON.stringify(exampleName)})`}.`;\n\nconst renderedClassNames = (html: string): string[] => {\n const classNames = new Set<string>();\n for (const match of html.matchAll(/\\bclass=\"([^\"]+)\"/g)) {\n match[1]!\n .split(/\\s+/)\n .filter(Boolean)\n .forEach((className) => classNames.add(className));\n }\n return [...classNames].sort();\n};\n\n/** The node anchor values in serialized `html`, in document order. */\nconst renderedAnchors = (html: string): string[] => {\n const attribute = new RegExp(`\\\\s${NODE_ANCHOR_ATTRIBUTE}=\"([^\"]*)\"`);\n // Only opening tags: the serializer escapes `<`, `>`, and `\"` in text and attribute values.\n return [...html.matchAll(/<[a-zA-Z][^>]*>/g)].flatMap(([tag]) => {\n const [, value] = attribute.exec(tag) ?? [];\n return value === undefined ? [] : [value];\n });\n};\n\nconst cssEscapeClass = (className: string): string =>\n className.replace(/([!\"#$%&'()*+,./:;<=>?@[\\\\\\]^`{|}~])/g, '\\\\$1');\n\nconst cssHasClassSelector = (css: string, className: string): boolean =>\n new RegExp(`\\\\.${cssEscapeClass(className)}(?![\\\\w-])`).test(css);\n\n/**\n * Every assertion a primitive owes its callers, for a pack to drive with\n * `it.each`.\n */\nexport const primitiveConformanceCases: readonly PrimitiveConformanceCase[] = [\n {\n name: 'validates as a primitive node and inside a composition',\n run: (example, harness) => {\n const { node } = example;\n const hint = previewHint(example);\n const primitiveErrors = [...harness.validateNode(node)];\n assert.deepEqual(primitiveErrors, [], hint);\n const result = harness.validateComposition(harness.wrapComposition(node));\n assert.equal(result.valid, true, hint);\n assert.deepEqual(result.errors, [], hint);\n },\n },\n {\n name: 'renders through React without throwing',\n run: ({ node }, harness) => {\n const rendered = harness.renderReact(node);\n assert.notEqual(rendered, undefined);\n },\n },\n {\n name: 'collects styles without throwing',\n run: ({ node }, harness) => {\n assert.doesNotThrow(() => harness.collectStyles(node));\n },\n },\n {\n name: 'a container recurses through scope for a node from another pack',\n run: ({ definition, node }, harness) => {\n if (!definition.children || !harness.nestForeignChild) {\n return;\n }\n const nested = harness.nestForeignChild(node);\n assert.notEqual(harness.renderReact(nested), undefined);\n assert.ok(\n harness.renderText(nested).includes(CONFORMANCE_FOREIGN_MARKER)\n );\n assert.ok(\n harness.renderMarkdown(nested).includes(CONFORMANCE_FOREIGN_MARKER)\n );\n },\n },\n {\n name: 'renders through plain text with non-empty output',\n run: ({ node }, harness) => {\n const text = harness.renderText(node);\n assert.equal(typeof text, 'string');\n assert.ok(text.trim().length > 0);\n },\n },\n {\n name: 'renders through markdown with non-empty output',\n run: ({ node }, harness) => {\n const markdown = harness.renderMarkdown(node);\n assert.equal(typeof markdown, 'string');\n assert.ok(markdown.trim().length > 0);\n },\n },\n {\n name: 'renders through Slack dispatch returning at least one block',\n run: ({ node }, harness) => {\n const blocks = harness.renderSlack(node);\n assert.ok(blocks.length > 0);\n for (const block of blocks) {\n assert.equal(typeof block, 'object');\n assert.equal(typeof block.type, 'string');\n }\n },\n },\n {\n name: 'wraps only Slack blocks Isomer does not model',\n run: (example, harness) => {\n for (const { type } of harness\n .renderSlack(example.node)\n .flatMap((block): readonly SlackBlock[] =>\n block.type === 'container' ? [block, ...block.child_blocks] : [block]\n )\n .filter(isUnmodeledSlackBlock)) {\n assert.ok(\n !isModeledSlackBlockType(type),\n `Isomer models \\`${type}\\` blocks: return this one without \\`unmodeledSlackBlock\\`. ${previewHint(example)}`\n );\n }\n },\n },\n {\n name: 'renders through snapshot primitive dispatch without throwing',\n run: ({ type, exampleIndex, node }, harness) => {\n if (!harness.renderSnapshot) {\n return;\n }\n assert.doesNotThrow(() =>\n harness.renderSnapshot?.(node, `conformance-${type}-${exampleIndex}`)\n );\n },\n },\n {\n name: 'reports a positive finite snapshot height estimate',\n run: ({ node }, harness) => {\n if (\n harness.sizesFromNodeHeights === false ||\n !harness.estimateSnapshotHeight\n ) {\n return;\n }\n const height = harness.estimateSnapshotHeight(node);\n assert.equal(Number.isFinite(height), true);\n assert.ok(height > 0);\n },\n },\n {\n name: 'renders through renderHTML wrapped in a minimal composition',\n run: ({ node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node));\n assert.deepEqual(result.validationErrors, []);\n assert.ok(result.html.includes('<section'));\n assert.equal(result.measurement.js, 0);\n assert.ok(result.measurement.total > 0);\n },\n },\n {\n name: 'renders no node anchors unless asked',\n run: ({ node }, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const { body } = harness.renderHTML(harness.wrapComposition(node));\n assert.deepEqual(renderedAnchors(body), []);\n },\n },\n {\n name: 'renders a node anchor on every node when asked',\n run: (example, harness) => {\n if (!harness.renderHTML || !harness.anchorWalk) {\n return;\n }\n const composition = harness.wrapComposition(example.node);\n const { body } = harness.renderHTML(composition, { anchors: true });\n const expected = anchoredNodes(\n composition.body,\n harness.anchorWalk\n ).flatMap((anchored) => {\n const anchoredType = nodeType(anchored);\n return anchoredType === undefined ? [] : [anchorValue(anchoredType)];\n });\n assert.deepEqual(\n renderedAnchors(body),\n expected,\n `Expected one anchor per node, in walker order. ${previewHint(example)}`\n );\n },\n },\n {\n name: 'emits CSS where every var(...) reference has a matching declaration',\n run: ({ node }, harness) => {\n if (!harness.renderHTML || !harness.assertVarRefsHaveDeclarations) {\n return;\n }\n const result = harness.renderHTML(harness.wrapComposition(node), {\n css: 'separate',\n });\n harness.assertVarRefsHaveDeclarations(result.css);\n },\n },\n {\n name: 'reaches every rendered readable class in compact CSS collection',\n run: (example, harness) => {\n if (!harness.renderHTML) {\n return;\n }\n const { type, exampleIndex, node } = example;\n const result = harness.renderHTML(harness.wrapComposition(node), {\n css: 'separate',\n names: 'readable',\n });\n const missing = renderedClassNames(result.body).filter(\n (className) => !cssHasClassSelector(result.css, className)\n );\n const hint =\n `Missing CSS for ${type} example #${exampleIndex}: ` +\n `${missing.join(', ') || '(none)'}. ` +\n previewHint(example);\n assert.deepEqual(missing, [], hint);\n },\n },\n {\n name: 'renders through renderText wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const text = harness.renderTextComposition(harness.wrapComposition(node));\n assert.ok(text.length > 0);\n assert.ok(text.includes('CONFORMANCE FIXTURE'));\n },\n },\n {\n name: 'renders through renderMarkdown wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const markdown = harness.renderMarkdownComposition(\n harness.wrapComposition(node)\n );\n assert.ok(markdown.length > 0);\n assert.ok(markdown.includes('# Conformance fixture'));\n },\n },\n {\n name: 'renders through renderSlack wrapped in a minimal composition',\n run: ({ node }, harness) => {\n const result = harness.renderSlackComposition(\n harness.wrapComposition(node)\n );\n assert.ok(result.blocks.length > 0);\n assert.ok(result.text.length > 0);\n const first = result.blocks[0];\n assert.ok(first);\n if (first.type !== 'header') {\n assert.fail(`expected a header block, got ${first.type}`);\n }\n assert.equal(first.text.type, 'plain_text');\n },\n },\n {\n name: 'renders a snapshot wrapped in a minimal composition',\n run: async ({ node }, harness) => {\n if (!harness.renderSnapshotComposition) {\n return;\n }\n const result = await harness.renderSnapshotComposition(\n harness.wrapComposition(node)\n );\n assert.deepEqual(result.validationErrors, []);\n assert.ok(result.html.trim().length > 0);\n assert.ok(result.measurement.total > 0);\n },\n },\n];\n"]}
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type PrimitiveConformanceCase, type PrimitiveConformanceExample, type PrimitiveConformanceHarness, type PrimitiveConformanceHtmlOptions, type PrimitiveConformanceSlackResult, type PrimitiveConformanceSnapshotResult, CONFORMANCE_FOREIGN_MARKER, primitiveConformanceRows, runPrimitiveInventoryConformance, } from './conformance.js';
|
|
1
|
+
export { type PrimitiveConformanceCase, type PrimitiveConformanceExample, type PrimitiveConformanceHarness, type PrimitiveConformanceHtmlOptions, type PrimitiveConformanceSlackResult, type PrimitiveConformanceSnapshotResult, CONFORMANCE_FIXTURE_TITLE, CONFORMANCE_FOREIGN_MARKER, primitiveConformanceRows, runPrimitiveInventoryConformance, } from './conformance.js';
|
|
2
2
|
export { assertPackIconsValid } from './icon.js';
|
|
3
3
|
export { type PackRegistrationOptions, assertPackRegistrationComplete, } from './registration.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,0BAA0B,EAC1B,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,KAAK,uBAAuB,EAC5B,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,KAAK,uBAAuB,EAC5B,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC"}
|
package/dist/testing/index.js
CHANGED
|
@@ -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 { CONFORMANCE_FOREIGN_MARKER, primitiveConformanceRows, runPrimitiveInventoryConformance, } from './conformance.js';
|
|
7
|
+
export { CONFORMANCE_FIXTURE_TITLE, CONFORMANCE_FOREIGN_MARKER, primitiveConformanceRows, runPrimitiveInventoryConformance, } from './conformance.js';
|
|
8
8
|
export { assertPackIconsValid } from './icon.js';
|
|
9
9
|
export { assertPackRegistrationComplete, } from './registration.js';
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAOL,0BAA0B,EAC1B,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAEL,8BAA8B,GAC/B,MAAM,gBAAgB,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 {\n type PrimitiveConformanceCase,\n type PrimitiveConformanceExample,\n type PrimitiveConformanceHarness,\n type PrimitiveConformanceHtmlOptions,\n type PrimitiveConformanceSlackResult,\n type PrimitiveConformanceSnapshotResult,\n CONFORMANCE_FOREIGN_MARKER,\n primitiveConformanceRows,\n runPrimitiveInventoryConformance,\n} from './conformance';\nexport { assertPackIconsValid } from './icon';\nexport {\n type PackRegistrationOptions,\n assertPackRegistrationComplete,\n} from './registration';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAOL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAEL,8BAA8B,GAC/B,MAAM,gBAAgB,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 {\n type PrimitiveConformanceCase,\n type PrimitiveConformanceExample,\n type PrimitiveConformanceHarness,\n type PrimitiveConformanceHtmlOptions,\n type PrimitiveConformanceSlackResult,\n type PrimitiveConformanceSnapshotResult,\n CONFORMANCE_FIXTURE_TITLE,\n CONFORMANCE_FOREIGN_MARKER,\n primitiveConformanceRows,\n runPrimitiveInventoryConformance,\n} from './conformance';\nexport { assertPackIconsValid } from './icon';\nexport {\n type PackRegistrationOptions,\n assertPackRegistrationComplete,\n} from './registration';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json_schema.d.ts","sourceRoot":"","sources":["../../src/validate/json_schema.ts"],"names":[],"mappings":"AAOA,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAOzE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,sDAAsD;AACtD,MAAM,WAAW,4BAA4B;IAC3C,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvD,4FAA4F;IAC5F,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACrC,aAAa,SAAS,sBAAsB,EAAE,EAC9C,UAAS,4BAAiC,KACzC,
|
|
1
|
+
{"version":3,"file":"json_schema.d.ts","sourceRoot":"","sources":["../../src/validate/json_schema.ts"],"names":[],"mappings":"AAOA,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAOzE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,sDAAsD;AACtD,MAAM,WAAW,4BAA4B;IAC3C,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvD,4FAA4F;IAC5F,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GACrC,aAAa,SAAS,sBAAsB,EAAE,EAC9C,UAAS,4BAAiC,KACzC,UAgEF,CAAC"}
|
|
@@ -26,18 +26,25 @@ export const buildCompositionJsonSchema = (definitions, options = {}) => {
|
|
|
26
26
|
// registration is recorded: a schema named twice (an `extraDefs` entry that
|
|
27
27
|
// is also a member) must restore its original entry, not the first id.
|
|
28
28
|
const previous = new Map();
|
|
29
|
-
const registerId = (schema, id) => {
|
|
29
|
+
const registerId = (schema, id, description) => {
|
|
30
30
|
if (!previous.has(schema)) {
|
|
31
31
|
previous.set(schema, z.globalRegistry.get(schema));
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
const current = z.globalRegistry.get(schema);
|
|
34
|
+
z.globalRegistry.add(schema, {
|
|
35
|
+
...current,
|
|
36
|
+
id,
|
|
37
|
+
...(description === undefined ? {} : { description }),
|
|
38
|
+
});
|
|
34
39
|
};
|
|
35
40
|
registerId(bodyNodeSchema, 'bodyNode');
|
|
36
41
|
for (const extra of options.extraDefs ?? []) {
|
|
37
42
|
registerId(extra.schema, extra.id);
|
|
38
43
|
}
|
|
44
|
+
// `schemaFor` returns a new schema, so the description is taken from the catalog.
|
|
45
|
+
const described = new Map(definitions.map(({ type, catalog }) => [type, catalog.description]));
|
|
39
46
|
for (const [type, schema] of members) {
|
|
40
|
-
registerId(schema, type);
|
|
47
|
+
registerId(schema, type, described.get(type));
|
|
41
48
|
}
|
|
42
49
|
try {
|
|
43
50
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json_schema.js","sourceRoot":"","sources":["../../src/validate/json_schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAgB,MAAM,KAAK,CAAC;AAItC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAqB9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,WAA8C,EAC9C,UAAwC,EAAE,EAC9B,EAAE;IACd,qEAAqE;IACrE,sDAAsD;IACtD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAChD,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC7C,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;IAErE,sEAAsE;IACtE,2EAA2E;IAC3E,wEAAwE;IACxE,qEAAqE;IACrE,4EAA4E;IAC5E,uEAAuE;IACvE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC7C,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"json_schema.js","sourceRoot":"","sources":["../../src/validate/json_schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAgB,MAAM,KAAK,CAAC;AAItC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAqB9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,WAA8C,EAC9C,UAAwC,EAAE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,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CACpE,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACrC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,CAAC;QACH,OAAO;YACL,GAAG,CAAC,CAAC,YAAY,CAAC,iBAAiB,EAAE;gBACnC,MAAM,EAAE,eAAe;gBACvB,QAAQ,EAAE,CAAC,CAAC,cAAc;gBAC1B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;gBAC/B,MAAM,EAAE,KAAK;gBACb,eAAe,EAAE,KAAK;aACvB,CAAC;YACF,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,MAAM;YAC9B,WAAW,EACT,OAAO,CAAC,WAAW;gBACnB,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,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,KAAc,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;AACH,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\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/validate/url.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/validate/url.ts"],"names":[],"mappings":"AAwEA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IACgB,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IACgB,CAAC;AAEzE,gFAAgF;AAChF,eAAO,MAAM,4BAA4B,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAGpE,CAAC;AAEF,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAG7D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,sDACoB,CAAC;AAEtD,uEAAuE;AACvE,eAAO,MAAM,cAAc,0DAC8B,CAAC;AAE1D,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,8DAAoC,CAAC;AAEzE,+CAA+C;AAC/C,eAAO,MAAM,iBAAiB,kEAA8B,CAAC;AAE7D,+DAA+D;AAC/D,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAYD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,UAAS,gBAAqB,4BAM1D,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,UAAS,gBAAqB,4BAMpD,CAAC"}
|
package/dist/validate/url.js
CHANGED
|
@@ -20,8 +20,9 @@ const NAMED_REFERENCES = {
|
|
|
20
20
|
// named ones that spell a scheme, path, or tag character.
|
|
21
21
|
const CHARACTER_REFERENCE_RE = /&(?:#x([0-9a-f]+);?|#([0-9]+);?|(bsol|colon|gt|lt|newline|sol|tab);)/gi;
|
|
22
22
|
const decodeReference = (match, hex, decimal, name) => {
|
|
23
|
-
if (name)
|
|
23
|
+
if (name) {
|
|
24
24
|
return NAMED_REFERENCES[name.toLowerCase()] ?? match;
|
|
25
|
+
}
|
|
25
26
|
const codePoint = Number.parseInt(hex ?? decimal ?? '', hex ? 16 : 10);
|
|
26
27
|
return codePoint > 0 && codePoint <= 0x10ffff
|
|
27
28
|
? String.fromCodePoint(codePoint)
|
package/dist/validate/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/validate/url.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,0EAA0E;AAC1E,6EAA6E;AAE7E,MAAM,gBAAgB,GAAqC;IACzD,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,GAAG;IACV,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,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,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;KAClC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAA4B,EAAE,EAAE,EAAE,CAC/D,SAAS,CACP,CAAC,KAAK,EAAE,EAAE,CAAC,sBAAsB,CAAC,KAAK,CAAC,KAAK,IAAI,EACjD,oBAAoB,EACpB,uBAAuB,EACvB,OAAO,CACR,CAAC;AAEJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,UAA4B,EAAE,EAAE,EAAE,CACzD,SAAS,CACP,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,IAAI,EAC3C,cAAc,EACd,iBAAiB,EACjB,OAAO,CACR,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 { 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/isomer-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Shared primitive-pack toolkit for Isomer: the composition contract, validation, and rendering.",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"author": "Elastic",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"react": ">=18 <20",
|
|
98
98
|
"react-dom": ">=18 <20",
|
|
99
|
-
"zod": "^4.4
|
|
99
|
+
"zod": "^4.5.4"
|
|
100
100
|
},
|
|
101
101
|
"peerDependenciesMeta": {
|
|
102
102
|
"react-dom": {
|