@elastic/isomer-sdk 0.0.0 → 0.1.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/LICENSE.txt +93 -0
- package/NOTICE.txt +1861 -0
- package/README.md +58 -0
- package/THIRD_PARTY_LICENSES.md +957 -0
- package/dist/author/authored_fields.d.ts +103 -0
- package/dist/author/authored_fields.d.ts.map +1 -0
- package/dist/author/authored_fields.js +183 -0
- package/dist/author/authored_fields.js.map +1 -0
- package/dist/author/index.d.ts +5 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +10 -0
- package/dist/author/index.js.map +1 -0
- package/dist/author/jsx.d.ts +21 -0
- package/dist/author/jsx.d.ts.map +1 -0
- package/dist/author/jsx.js +20 -0
- package/dist/author/jsx.js.map +1 -0
- package/dist/author/jsx_shim.d.ts +116 -0
- package/dist/author/jsx_shim.d.ts.map +1 -0
- package/dist/author/jsx_shim.js +353 -0
- package/dist/author/jsx_shim.js.map +1 -0
- package/dist/author/prompt.d.ts +58 -0
- package/dist/author/prompt.d.ts.map +1 -0
- package/dist/author/prompt.js +148 -0
- package/dist/author/prompt.js.map +1 -0
- package/dist/cjs/author/authored_fields.js +189 -0
- package/dist/cjs/author/authored_fields.js.map +1 -0
- package/dist/cjs/author/index.js +20 -0
- package/dist/cjs/author/index.js.map +1 -0
- package/dist/cjs/author/jsx.js +24 -0
- package/dist/cjs/author/jsx.js.map +1 -0
- package/dist/cjs/author/jsx_shim.js +359 -0
- package/dist/cjs/author/jsx_shim.js.map +1 -0
- package/dist/cjs/author/prompt.js +153 -0
- package/dist/cjs/author/prompt.js.map +1 -0
- package/dist/cjs/composition/action_event.js +9 -0
- package/dist/cjs/composition/action_event.js.map +1 -0
- package/dist/cjs/composition/body_node_base.js +105 -0
- package/dist/cjs/composition/body_node_base.js.map +1 -0
- package/dist/cjs/composition/composition.js +9 -0
- package/dist/cjs/composition/composition.js.map +1 -0
- package/dist/cjs/composition/error.js +72 -0
- package/dist/cjs/composition/error.js.map +1 -0
- package/dist/cjs/composition/index.js +31 -0
- package/dist/cjs/composition/index.js.map +1 -0
- package/dist/cjs/composition/map_nodes.js +85 -0
- package/dist/cjs/composition/map_nodes.js.map +1 -0
- package/dist/cjs/composition/named_color.js +20 -0
- package/dist/cjs/composition/named_color.js.map +1 -0
- package/dist/cjs/composition/node.js +9 -0
- package/dist/cjs/composition/node.js.map +1 -0
- package/dist/cjs/composition/one_line.js +23 -0
- package/dist/cjs/composition/one_line.js.map +1 -0
- package/dist/cjs/composition/structured_value.js +21 -0
- package/dist/cjs/composition/structured_value.js.map +1 -0
- package/dist/cjs/composition/validation_error.js +40 -0
- package/dist/cjs/composition/validation_error.js.map +1 -0
- package/dist/cjs/define/frame.js +32 -0
- package/dist/cjs/define/frame.js.map +1 -0
- package/dist/cjs/define/index.js +25 -0
- package/dist/cjs/define/index.js.map +1 -0
- package/dist/cjs/define/markdown_content.js +12 -0
- package/dist/cjs/define/markdown_content.js.map +1 -0
- package/dist/cjs/define/primitive_module.js +107 -0
- package/dist/cjs/define/primitive_module.js.map +1 -0
- package/dist/cjs/define/slack_assets.js +9 -0
- package/dist/cjs/define/slack_assets.js.map +1 -0
- package/dist/cjs/define/slack_blocks.js +9 -0
- package/dist/cjs/define/slack_blocks.js.map +1 -0
- package/dist/cjs/define/zod_format.js +122 -0
- package/dist/cjs/define/zod_format.js.map +1 -0
- package/dist/cjs/define/zod_helpers.js +26 -0
- package/dist/cjs/define/zod_helpers.js.map +1 -0
- package/dist/cjs/entries/html.js +12 -0
- package/dist/cjs/entries/html.js.map +1 -0
- package/dist/cjs/entries/index.js +75 -0
- package/dist/cjs/entries/index.js.map +1 -0
- package/dist/cjs/entries/markdown.js +14 -0
- package/dist/cjs/entries/markdown.js.map +1 -0
- package/dist/cjs/entries/react.js +20 -0
- package/dist/cjs/entries/react.js.map +1 -0
- package/dist/cjs/entries/slack.js +26 -0
- package/dist/cjs/entries/slack.js.map +1 -0
- package/dist/cjs/entries/text.js +12 -0
- package/dist/cjs/entries/text.js.map +1 -0
- package/dist/cjs/pack/capabilities.js +34 -0
- package/dist/cjs/pack/capabilities.js.map +1 -0
- package/dist/cjs/pack/compose.js +56 -0
- package/dist/cjs/pack/compose.js.map +1 -0
- package/dist/cjs/pack/enhancements.js +65 -0
- package/dist/cjs/pack/enhancements.js.map +1 -0
- package/dist/cjs/pack/index.js +18 -0
- package/dist/cjs/pack/index.js.map +1 -0
- package/dist/cjs/pack/primitive_pack.js +85 -0
- package/dist/cjs/pack/primitive_pack.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/render/anchors.js +167 -0
- package/dist/cjs/render/anchors.js.map +1 -0
- package/dist/cjs/render/context_view.js +54 -0
- package/dist/cjs/render/context_view.js.map +1 -0
- package/dist/cjs/render/format_display_value.js +143 -0
- package/dist/cjs/render/format_display_value.js.map +1 -0
- package/dist/cjs/render/format_number.js +46 -0
- package/dist/cjs/render/format_number.js.map +1 -0
- package/dist/cjs/render/html/enhancements.js +30 -0
- package/dist/cjs/render/html/enhancements.js.map +1 -0
- package/dist/cjs/render/html/envelope.js +218 -0
- package/dist/cjs/render/html/envelope.js.map +1 -0
- package/dist/cjs/render/html/index.js +12 -0
- package/dist/cjs/render/html/index.js.map +1 -0
- package/dist/cjs/render/index.js +25 -0
- package/dist/cjs/render/index.js.map +1 -0
- package/dist/cjs/render/layout_check.js +133 -0
- package/dist/cjs/render/layout_check.js.map +1 -0
- package/dist/cjs/render/markdown/builder.js +189 -0
- package/dist/cjs/render/markdown/builder.js.map +1 -0
- package/dist/cjs/render/markdown/envelope.js +33 -0
- package/dist/cjs/render/markdown/envelope.js.map +1 -0
- package/dist/cjs/render/markdown/format.js +190 -0
- package/dist/cjs/render/markdown/format.js.map +1 -0
- package/dist/cjs/render/markdown/index.js +15 -0
- package/dist/cjs/render/markdown/index.js.map +1 -0
- package/dist/cjs/render/measure_dom.js +61 -0
- package/dist/cjs/render/measure_dom.js.map +1 -0
- package/dist/cjs/render/payload.js +13 -0
- package/dist/cjs/render/payload.js.map +1 -0
- package/dist/cjs/render/primitive_dispatch.js +187 -0
- package/dist/cjs/render/primitive_dispatch.js.map +1 -0
- package/dist/cjs/render/react/content.js +44 -0
- package/dist/cjs/render/react/content.js.map +1 -0
- package/dist/cjs/render/react/enhancements.js +32 -0
- package/dist/cjs/render/react/enhancements.js.map +1 -0
- package/dist/cjs/render/react/index.js +15 -0
- package/dist/cjs/render/react/index.js.map +1 -0
- package/dist/cjs/render/slack/assets.js +45 -0
- package/dist/cjs/render/slack/assets.js.map +1 -0
- package/dist/cjs/render/slack/blocks.js +80 -0
- package/dist/cjs/render/slack/blocks.js.map +1 -0
- package/dist/cjs/render/slack/envelope.js +551 -0
- package/dist/cjs/render/slack/envelope.js.map +1 -0
- package/dist/cjs/render/slack/format.js +825 -0
- package/dist/cjs/render/slack/format.js.map +1 -0
- package/dist/cjs/render/slack/index.js +31 -0
- package/dist/cjs/render/slack/index.js.map +1 -0
- package/dist/cjs/render/slack/markdown_content.js +358 -0
- package/dist/cjs/render/slack/markdown_content.js.map +1 -0
- package/dist/cjs/render/text/envelope.js +21 -0
- package/dist/cjs/render/text/envelope.js.map +1 -0
- package/dist/cjs/render/text/index.js +12 -0
- package/dist/cjs/render/text/index.js.map +1 -0
- package/dist/cjs/testing/conformance.js +296 -0
- package/dist/cjs/testing/conformance.js.map +1 -0
- package/dist/cjs/testing/index.js +16 -0
- package/dist/cjs/testing/index.js.map +1 -0
- package/dist/cjs/testing/registration.js +140 -0
- package/dist/cjs/testing/registration.js.map +1 -0
- package/dist/cjs/validate/authoring_schema.js +296 -0
- package/dist/cjs/validate/authoring_schema.js.map +1 -0
- package/dist/cjs/validate/composition_schema.js +135 -0
- package/dist/cjs/validate/composition_schema.js.map +1 -0
- package/dist/cjs/validate/index.js +52 -0
- package/dist/cjs/validate/index.js.map +1 -0
- package/dist/cjs/validate/input_budget.js +156 -0
- package/dist/cjs/validate/input_budget.js.map +1 -0
- package/dist/cjs/validate/json_schema.js +72 -0
- package/dist/cjs/validate/json_schema.js.map +1 -0
- package/dist/cjs/validate/node_issues.js +65 -0
- package/dist/cjs/validate/node_issues.js.map +1 -0
- package/dist/cjs/validate/url.js +116 -0
- package/dist/cjs/validate/url.js.map +1 -0
- package/dist/cjs/validate/validation.js +208 -0
- package/dist/cjs/validate/validation.js.map +1 -0
- package/dist/cjs/validate/value_schemas.js +53 -0
- package/dist/cjs/validate/value_schemas.js.map +1 -0
- package/dist/composition/action_event.d.ts +13 -0
- package/dist/composition/action_event.d.ts.map +1 -0
- package/dist/composition/action_event.js +8 -0
- package/dist/composition/action_event.js.map +1 -0
- package/dist/composition/body_node_base.d.ts +71 -0
- package/dist/composition/body_node_base.d.ts.map +1 -0
- package/dist/composition/body_node_base.js +97 -0
- package/dist/composition/body_node_base.js.map +1 -0
- package/dist/composition/composition.d.ts +71 -0
- package/dist/composition/composition.d.ts.map +1 -0
- package/dist/composition/composition.js +8 -0
- package/dist/composition/composition.js.map +1 -0
- package/dist/composition/error.d.ts +60 -0
- package/dist/composition/error.d.ts.map +1 -0
- package/dist/composition/error.js +68 -0
- package/dist/composition/error.js.map +1 -0
- package/dist/composition/index.d.ts +11 -0
- package/dist/composition/index.d.ts.map +1 -0
- package/dist/composition/index.js +14 -0
- package/dist/composition/index.js.map +1 -0
- package/dist/composition/map_nodes.d.ts +16 -0
- package/dist/composition/map_nodes.d.ts.map +1 -0
- package/dist/composition/map_nodes.js +81 -0
- package/dist/composition/map_nodes.js.map +1 -0
- package/dist/composition/named_color.d.ts +9 -0
- package/dist/composition/named_color.d.ts.map +1 -0
- package/dist/composition/named_color.js +17 -0
- package/dist/composition/named_color.js.map +1 -0
- package/dist/composition/node.d.ts +11 -0
- package/dist/composition/node.d.ts.map +1 -0
- package/dist/composition/node.js +8 -0
- package/dist/composition/node.js.map +1 -0
- package/dist/composition/one_line.d.ts +7 -0
- package/dist/composition/one_line.d.ts.map +1 -0
- package/dist/composition/one_line.js +17 -0
- package/dist/composition/one_line.js.map +1 -0
- package/dist/composition/structured_value.d.ts +27 -0
- package/dist/composition/structured_value.d.ts.map +1 -0
- package/dist/composition/structured_value.js +18 -0
- package/dist/composition/structured_value.js.map +1 -0
- package/dist/composition/validation_error.d.ts +33 -0
- package/dist/composition/validation_error.d.ts.map +1 -0
- package/dist/composition/validation_error.js +35 -0
- package/dist/composition/validation_error.js.map +1 -0
- package/dist/define/frame.d.ts +166 -0
- package/dist/define/frame.d.ts.map +1 -0
- package/dist/define/frame.js +28 -0
- package/dist/define/frame.js.map +1 -0
- package/dist/define/index.d.ts +8 -0
- package/dist/define/index.d.ts.map +1 -0
- package/dist/define/index.js +11 -0
- package/dist/define/index.js.map +1 -0
- package/dist/define/markdown_content.d.ts +15 -0
- package/dist/define/markdown_content.d.ts.map +1 -0
- package/dist/define/markdown_content.js +9 -0
- package/dist/define/markdown_content.js.map +1 -0
- package/dist/define/primitive_module.d.ts +421 -0
- package/dist/define/primitive_module.d.ts.map +1 -0
- package/dist/define/primitive_module.js +101 -0
- package/dist/define/primitive_module.js.map +1 -0
- package/dist/define/slack_assets.d.ts +28 -0
- package/dist/define/slack_assets.d.ts.map +1 -0
- package/dist/define/slack_assets.js +8 -0
- package/dist/define/slack_assets.js.map +1 -0
- package/dist/define/slack_blocks.d.ts +234 -0
- package/dist/define/slack_blocks.d.ts.map +1 -0
- package/dist/define/slack_blocks.js +8 -0
- package/dist/define/slack_blocks.js.map +1 -0
- package/dist/define/zod_format.d.ts +33 -0
- package/dist/define/zod_format.d.ts.map +1 -0
- package/dist/define/zod_format.js +114 -0
- package/dist/define/zod_format.js.map +1 -0
- package/dist/define/zod_helpers.d.ts +10 -0
- package/dist/define/zod_helpers.d.ts.map +1 -0
- package/dist/define/zod_helpers.js +22 -0
- package/dist/define/zod_helpers.js.map +1 -0
- package/dist/entries/html.d.ts +3 -0
- package/dist/entries/html.d.ts.map +1 -0
- package/dist/entries/html.js +8 -0
- package/dist/entries/html.js.map +1 -0
- package/dist/entries/index.d.ts +6 -0
- package/dist/entries/index.d.ts.map +1 -0
- package/dist/entries/index.js +12 -0
- package/dist/entries/index.js.map +1 -0
- package/dist/entries/markdown.d.ts +3 -0
- package/dist/entries/markdown.d.ts.map +1 -0
- package/dist/entries/markdown.js +8 -0
- package/dist/entries/markdown.js.map +1 -0
- package/dist/entries/react.d.ts +5 -0
- package/dist/entries/react.d.ts.map +1 -0
- package/dist/entries/react.js +11 -0
- package/dist/entries/react.js.map +1 -0
- package/dist/entries/slack.d.ts +2 -0
- package/dist/entries/slack.d.ts.map +1 -0
- package/dist/entries/slack.js +8 -0
- package/dist/entries/slack.js.map +1 -0
- package/dist/entries/text.d.ts +2 -0
- package/dist/entries/text.d.ts.map +1 -0
- package/dist/entries/text.js +8 -0
- package/dist/entries/text.js.map +1 -0
- package/dist/pack/capabilities.d.ts +27 -0
- package/dist/pack/capabilities.d.ts.map +1 -0
- package/dist/pack/capabilities.js +30 -0
- package/dist/pack/capabilities.js.map +1 -0
- package/dist/pack/compose.d.ts +21 -0
- package/dist/pack/compose.d.ts.map +1 -0
- package/dist/pack/compose.js +52 -0
- package/dist/pack/compose.js.map +1 -0
- package/dist/pack/enhancements.d.ts +65 -0
- package/dist/pack/enhancements.d.ts.map +1 -0
- package/dist/pack/enhancements.js +59 -0
- package/dist/pack/enhancements.js.map +1 -0
- package/dist/pack/index.d.ts +5 -0
- package/dist/pack/index.d.ts.map +1 -0
- package/dist/pack/index.js +11 -0
- package/dist/pack/index.js.map +1 -0
- package/dist/pack/primitive_pack.d.ts +155 -0
- package/dist/pack/primitive_pack.d.ts.map +1 -0
- package/dist/pack/primitive_pack.js +81 -0
- package/dist/pack/primitive_pack.js.map +1 -0
- package/dist/render/anchors.d.ts +82 -0
- package/dist/render/anchors.d.ts.map +1 -0
- package/dist/render/anchors.js +153 -0
- package/dist/render/anchors.js.map +1 -0
- package/dist/render/context_view.d.ts +10 -0
- package/dist/render/context_view.d.ts.map +1 -0
- package/dist/render/context_view.js +49 -0
- package/dist/render/context_view.js.map +1 -0
- package/dist/render/format_display_value.d.ts +20 -0
- package/dist/render/format_display_value.d.ts.map +1 -0
- package/dist/render/format_display_value.js +137 -0
- package/dist/render/format_display_value.js.map +1 -0
- package/dist/render/format_number.d.ts +9 -0
- package/dist/render/format_number.d.ts.map +1 -0
- package/dist/render/format_number.js +42 -0
- package/dist/render/format_number.js.map +1 -0
- package/dist/render/html/enhancements.d.ts +10 -0
- package/dist/render/html/enhancements.d.ts.map +1 -0
- package/dist/render/html/enhancements.js +25 -0
- package/dist/render/html/enhancements.js.map +1 -0
- package/dist/render/html/envelope.d.ts +182 -0
- package/dist/render/html/envelope.d.ts.map +1 -0
- package/dist/render/html/envelope.js +214 -0
- package/dist/render/html/envelope.js.map +1 -0
- package/dist/render/html/index.d.ts +3 -0
- package/dist/render/html/index.d.ts.map +1 -0
- package/dist/render/html/index.js +8 -0
- package/dist/render/html/index.js.map +1 -0
- package/dist/render/index.d.ts +6 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +11 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/layout_check.d.ts +43 -0
- package/dist/render/layout_check.d.ts.map +1 -0
- package/dist/render/layout_check.js +129 -0
- package/dist/render/layout_check.js.map +1 -0
- package/dist/render/markdown/builder.d.ts +48 -0
- package/dist/render/markdown/builder.d.ts.map +1 -0
- package/dist/render/markdown/builder.js +183 -0
- package/dist/render/markdown/builder.js.map +1 -0
- package/dist/render/markdown/envelope.d.ts +20 -0
- package/dist/render/markdown/envelope.d.ts.map +1 -0
- package/dist/render/markdown/envelope.js +29 -0
- package/dist/render/markdown/envelope.js.map +1 -0
- package/dist/render/markdown/format.d.ts +3 -0
- package/dist/render/markdown/format.d.ts.map +1 -0
- package/dist/render/markdown/format.js +186 -0
- package/dist/render/markdown/format.js.map +1 -0
- package/dist/render/markdown/index.d.ts +3 -0
- package/dist/render/markdown/index.d.ts.map +1 -0
- package/dist/render/markdown/index.js +9 -0
- package/dist/render/markdown/index.js.map +1 -0
- package/dist/render/measure_dom.d.ts +10 -0
- package/dist/render/measure_dom.d.ts.map +1 -0
- package/dist/render/measure_dom.js +57 -0
- package/dist/render/measure_dom.js.map +1 -0
- package/dist/render/payload.d.ts +16 -0
- package/dist/render/payload.d.ts.map +1 -0
- package/dist/render/payload.js +9 -0
- package/dist/render/payload.js.map +1 -0
- package/dist/render/primitive_dispatch.d.ts +72 -0
- package/dist/render/primitive_dispatch.d.ts.map +1 -0
- package/dist/render/primitive_dispatch.js +183 -0
- package/dist/render/primitive_dispatch.js.map +1 -0
- package/dist/render/react/content.d.ts +40 -0
- package/dist/render/react/content.d.ts.map +1 -0
- package/dist/render/react/content.js +39 -0
- package/dist/render/react/content.js.map +1 -0
- package/dist/render/react/enhancements.d.ts +15 -0
- package/dist/render/react/enhancements.d.ts.map +1 -0
- package/dist/render/react/enhancements.js +28 -0
- package/dist/render/react/enhancements.js.map +1 -0
- package/dist/render/react/index.d.ts +3 -0
- package/dist/render/react/index.d.ts.map +1 -0
- package/dist/render/react/index.js +9 -0
- package/dist/render/react/index.js.map +1 -0
- package/dist/render/slack/assets.d.ts +16 -0
- package/dist/render/slack/assets.d.ts.map +1 -0
- package/dist/render/slack/assets.js +40 -0
- package/dist/render/slack/assets.js.map +1 -0
- package/dist/render/slack/blocks.d.ts +72 -0
- package/dist/render/slack/blocks.d.ts.map +1 -0
- package/dist/render/slack/blocks.js +77 -0
- package/dist/render/slack/blocks.js.map +1 -0
- package/dist/render/slack/envelope.d.ts +52 -0
- package/dist/render/slack/envelope.d.ts.map +1 -0
- package/dist/render/slack/envelope.js +547 -0
- package/dist/render/slack/envelope.js.map +1 -0
- package/dist/render/slack/format.d.ts +95 -0
- package/dist/render/slack/format.d.ts.map +1 -0
- package/dist/render/slack/format.js +807 -0
- package/dist/render/slack/format.js.map +1 -0
- package/dist/render/slack/index.d.ts +6 -0
- package/dist/render/slack/index.d.ts.map +1 -0
- package/dist/render/slack/index.js +12 -0
- package/dist/render/slack/index.js.map +1 -0
- package/dist/render/slack/markdown_content.d.ts +11 -0
- package/dist/render/slack/markdown_content.d.ts.map +1 -0
- package/dist/render/slack/markdown_content.js +354 -0
- package/dist/render/slack/markdown_content.js.map +1 -0
- package/dist/render/text/envelope.d.ts +15 -0
- package/dist/render/text/envelope.d.ts.map +1 -0
- package/dist/render/text/envelope.js +17 -0
- package/dist/render/text/envelope.js.map +1 -0
- package/dist/render/text/index.d.ts +2 -0
- package/dist/render/text/index.d.ts.map +1 -0
- package/dist/render/text/index.js +8 -0
- package/dist/render/text/index.js.map +1 -0
- package/dist/testing/conformance.d.ts +140 -0
- package/dist/testing/conformance.d.ts.map +1 -0
- package/dist/testing/conformance.js +287 -0
- package/dist/testing/conformance.js.map +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +9 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/registration.d.ts +32 -0
- package/dist/testing/registration.d.ts.map +1 -0
- package/dist/testing/registration.js +103 -0
- package/dist/testing/registration.js.map +1 -0
- package/dist/validate/authoring_schema.d.ts +27 -0
- package/dist/validate/authoring_schema.d.ts.map +1 -0
- package/dist/validate/authoring_schema.js +291 -0
- package/dist/validate/authoring_schema.js.map +1 -0
- package/dist/validate/composition_schema.d.ts +80 -0
- package/dist/validate/composition_schema.d.ts.map +1 -0
- package/dist/validate/composition_schema.js +127 -0
- package/dist/validate/composition_schema.js.map +1 -0
- package/dist/validate/index.d.ts +9 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +15 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/input_budget.d.ts +35 -0
- package/dist/validate/input_budget.d.ts.map +1 -0
- package/dist/validate/input_budget.js +151 -0
- package/dist/validate/input_budget.js.map +1 -0
- package/dist/validate/json_schema.d.ts +32 -0
- package/dist/validate/json_schema.d.ts.map +1 -0
- package/dist/validate/json_schema.js +68 -0
- package/dist/validate/json_schema.js.map +1 -0
- package/dist/validate/node_issues.d.ts +12 -0
- package/dist/validate/node_issues.d.ts.map +1 -0
- package/dist/validate/node_issues.js +61 -0
- package/dist/validate/node_issues.js.map +1 -0
- package/dist/validate/url.d.ts +50 -0
- package/dist/validate/url.d.ts.map +1 -0
- package/dist/validate/url.js +107 -0
- package/dist/validate/url.js.map +1 -0
- package/dist/validate/validation.d.ts +105 -0
- package/dist/validate/validation.d.ts.map +1 -0
- package/dist/validate/validation.js +200 -0
- package/dist/validate/validation.js.map +1 -0
- package/dist/validate/value_schemas.d.ts +53 -0
- package/dist/validate/value_schemas.d.ts.map +1 -0
- package/dist/validate/value_schemas.js +50 -0
- package/dist/validate/value_schemas.js.map +1 -0
- package/package.json +118 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/author/prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAUlD,wCAAwC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAkC;IAClE,SAAS;IACT,wBAAwB;IACxB,yBAAyB;CAC1B,CAAC;AA0CF,MAAM,4BAA4B,GAChC,sIAAsI,CAAC;AAEzI,MAAM,WAAW,GACf,yKAAyK,CAAC;AAE5K,MAAM,cAAc,GAAuC;IACzD,OAAO,EACL,uNAAuN;IACzN,wBAAwB,EACtB,kPAAkP;IACpP,yBAAyB,EACvB,mNAAmN;CACtN,CAAC;AAEF,4FAA4F;AAC5F,MAAM,sBAAsB,GAAuC;IACjE,OAAO,EAAE,CAAC;IACV,wBAAwB,EAAE,CAAC;IAC3B,yBAAyB,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,uBAAuB,GAAwC;IACnE,OAAO,EAAE,IAAI;IACb,wBAAwB,EAAE,KAAK;IAC/B,yBAAyB,EAAE,IAAI;CAChC,CAAC;AAEF,qFAAqF;AACrF,MAAM,WAAW,GAAG,CAAC,KAA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IACxC,QAAQ,CAAC,IAAI,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;IACpD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,QAAQ,CAAC,IAAI,CACX,iCAAiC,WAAW,CAAC,MAAM,CAAC,UAAU,CAC/D,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,kBAAkB,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/B,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 { oneLine } from '../composition/one_line';\nimport type { PrimitiveCatalogEntry } from '../define/primitive_module';\nimport type { PrimitiveGroup } from '../pack/primitive_pack';\n\ntype JsonSchema = Record<string, unknown>;\n\n/** Which authoring job the prompt frames for the model. */\nexport type AuthoringProfileId =\n 'general' | 'registered-view-router' | 'compose-from-primitives';\n\n/** Every {@link AuthoringProfileId}. */\nexport const AUTHORING_PROFILE_IDS: readonly AuthoringProfileId[] = [\n 'general',\n 'registered-view-router',\n 'compose-from-primitives',\n];\n\n/**\n * A registered view, declared structurally so this module does not import the\n * runtime. {@link RegisteredViewSummary} must stay assignable to this.\n */\nexport interface AuthoringViewSummary {\n id: string;\n title: string;\n description?: string;\n /** Natural-language queries the view answers, printed so the model can route by them. */\n answers: readonly string[];\n /** JSON Schema for the view's input, printed inline when present. */\n inputSchema?: JsonSchema;\n}\n\n/** The pack-supplied material {@link buildAuthoringPrompt} assembles. */\nexport interface AuthoringPromptContext {\n guide: string;\n /** Absent or empty drops the `## Rules` section. */\n rules?: string;\n /** JSON Schema for a whole composition. Absent, or under the router profile, it is not inlined. */\n schema?: JsonSchema;\n /** Rendered as a bullet per entry, with its `useWhen`, `avoidWhen`, and `example`. */\n primitives: readonly PrimitiveCatalogEntry[];\n /** `'index'` lists each primitive's type and purpose only, for a host that serves the rest on request. */\n catalog?: 'full' | 'index';\n /** Headings an index sorts primitives under; a type in none is listed under \"Other\". */\n groups?: readonly PrimitiveGroup[];\n /**\n * Extra host-supplied compositions beyond each primitive's catalog example.\n * Trimmed to the profile's budget. An empty list drops `## Examples`.\n */\n examples: readonly unknown[];\n /** Registered views the model can request by id. An empty list drops the section. */\n views?: readonly AuthoringViewSummary[];\n /** Defaults to `'# View authoring'`. */\n heading?: string;\n /** Replaces the profile's own framing sentence. */\n intro?: string;\n}\n\nconst COMPOSE_INTRO_WITHOUT_SCHEMA =\n 'You compose views from scratch. Build a single JSON object that answers the question using only the primitives in the catalog below.';\n\nconst INDEX_INTRO =\n 'Each primitive is listed by type and purpose. Before using one, request its catalog entry and JSON Schema by type; compose only from primitives whose details you have.';\n\nconst PROFILE_INTROS: Record<AuthoringProfileId, string> = {\n general:\n 'You author views: compact, host-portable operational displays expressed as a single JSON object. Route to a registered view when one answers the question; otherwise compose a view from the primitive catalog below.',\n 'registered-view-router':\n 'You route questions to registered views. Prefer an existing registered view whose answers index matches the question; request it by id with its input. Only fall back to composing a view when no registered view fits, using the catalog below.',\n 'compose-from-primitives':\n 'You compose views from scratch. Build a single JSON object that answers the question using only the primitives in the catalog below, and validate your output mentally against the JSON Schema before responding.',\n};\n\n/** Host-supplied composition examples kept after each primitive already shows its shape. */\nconst PROFILE_EXAMPLE_LIMITS: Record<AuthoringProfileId, number> = {\n general: 1,\n 'registered-view-router': 0,\n 'compose-from-primitives': 1,\n};\n\nconst PROFILE_INCLUDES_SCHEMA: Record<AuthoringProfileId, boolean> = {\n general: true,\n 'registered-view-router': false,\n 'compose-from-primitives': true,\n};\n\n/** Minified JSON with U+2028 and U+2029 escaped, so it always prints on one line. */\nconst compactJson = (value: unknown): string =>\n String(JSON.stringify(value)).replace(\n /[\\u2028\\u2029]/g,\n (separator) => `\\\\u${separator.charCodeAt(0).toString(16)}`\n );\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/** Host examples show composition, not provenance. */\nconst withoutMeta = (value: unknown): unknown => {\n if (!isRecord(value) || !('meta' in value)) {\n return value;\n }\n const rest = { ...value };\n delete rest.meta;\n return rest;\n};\n\n/** `text` as a Markdown code span, fenced longer than any backtick run inside it. */\nconst codeSpan = (text: string): string => {\n const longestRun = Math.max(\n 0,\n ...(text.match(/`+/g) ?? []).map(({ length }) => length)\n );\n const fence = '`'.repeat(longestRun + 1);\n const pad = /^`|`$/.test(text) ? ' ' : '';\n return `${fence}${pad}${text}${pad}${fence}`;\n};\n\n/** A lookup key as a code span, JSON-quoted when it would not survive printing bare. */\nconst keySpan = (key: string): string =>\n codeSpan(\n key !== '' && key.trim() === key && !/[\\p{Cc}\\p{Cs}\\u2028\\u2029]/u.test(key)\n ? key\n : compactJson(key)\n );\n\n/** One primitive's catalog bullet: its purpose, `useWhen`, `avoidWhen`, and example. */\nexport const formatPrimitiveEntry = (entry: PrimitiveCatalogEntry): string => {\n const lines = [`- ${keySpan(entry.type)} — ${oneLine(entry.purpose)}`];\n if (entry.useWhen.length > 0) {\n lines.push(` - Use when: ${oneLine(entry.useWhen.join(' '))}`);\n }\n if (entry.avoidWhen.length > 0) {\n lines.push(` - Avoid when: ${oneLine(entry.avoidWhen.join(' '))}`);\n }\n lines.push(` - Example: ${codeSpan(compactJson(entry.example))}`);\n return lines.join('\\n');\n};\n\nconst renderCatalog = (primitives: readonly PrimitiveCatalogEntry[]): string =>\n primitives.map(formatPrimitiveEntry).join('\\n');\n\nconst renderIndex = (\n primitives: readonly PrimitiveCatalogEntry[],\n groups: readonly PrimitiveGroup[] = []\n): string => {\n const byType = new Map(primitives.map((entry) => [entry.type, entry]));\n const grouped = new Set(groups.flatMap(({ types }) => types));\n const sections = [\n ...groups.map(({ title, types }) => ({\n title,\n entries: types.flatMap((type) => byType.get(type) ?? []),\n })),\n {\n title: 'Other',\n entries: primitives.filter(({ type }) => !grouped.has(type)),\n },\n ];\n return [\n INDEX_INTRO,\n ...sections\n .filter(({ entries }) => entries.length > 0)\n .map(\n ({ title, entries }) =>\n `### ${oneLine(title)}\\n\\n${entries\n .map(\n ({ type, purpose }) => `- ${keySpan(type)} — ${oneLine(purpose)}`\n )\n .join('\\n')}`\n ),\n ].join('\\n\\n');\n};\n\nconst renderViews = (views: readonly AuthoringViewSummary[]): string =>\n views\n .map((view) => {\n const lines = [`- ${keySpan(view.id)} — ${oneLine(view.title)}`];\n if (view.description !== undefined && view.description.length > 0) {\n lines.push(` - ${oneLine(view.description)}`);\n }\n if (view.answers.length > 0) {\n lines.push(` - Answers: ${oneLine(view.answers.join('; '))}`);\n }\n if (view.inputSchema !== undefined) {\n lines.push(` - Input: ${codeSpan(compactJson(view.inputSchema))}`);\n }\n return lines.join('\\n');\n })\n .join('\\n');\n\nconst renderExamples = (examples: readonly unknown[]): string =>\n examples\n .map(\n (example) => `\\`\\`\\`json\\n${compactJson(withoutMeta(example))}\\n\\`\\`\\``\n )\n .join('\\n\\n');\n\n/**\n * Assembles `context` into the prompt for `profile`, trimming the examples to\n * that profile's budget.\n *\n * The copy says \"view\" throughout because that is the wire discriminator and\n * the word models are trained and prompted on; pass `heading` and `intro` to\n * override it per host.\n */\nexport const buildAuthoringPrompt = (\n profile: AuthoringProfileId,\n context: AuthoringPromptContext\n): string => {\n const examples = context.examples\n .slice(0, PROFILE_EXAMPLE_LIMITS[profile])\n .map(withoutMeta);\n const views = context.views ?? [];\n const schema = PROFILE_INCLUDES_SCHEMA[profile] ? context.schema : undefined;\n const intro =\n profile === 'compose-from-primitives' && schema === undefined\n ? COMPOSE_INTRO_WITHOUT_SCHEMA\n : PROFILE_INTROS[profile];\n const sections = [\n context.heading ?? '# View authoring',\n context.intro ?? intro,\n `## Guide\\n\\n${context.guide}`,\n ];\n if (context.rules !== undefined && context.rules.length > 0) {\n sections.push(`## Rules\\n\\n${context.rules}`);\n }\n if (views.length > 0) {\n sections.push(`## Registered views\\n\\n${renderViews(views)}`);\n }\n const catalog =\n context.catalog === 'index'\n ? renderIndex(context.primitives, context.groups)\n : renderCatalog(context.primitives);\n sections.push(`## Primitive catalog\\n\\n${catalog}`);\n if (schema !== undefined) {\n sections.push(\n `## JSON Schema\\n\\n\\`\\`\\`json\\n${compactJson(schema)}\\n\\`\\`\\``\n );\n }\n if (examples.length > 0) {\n sections.push(`## Examples\\n\\n${renderExamples(examples)}`);\n }\n return sections.join('\\n\\n');\n};\n"]}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.readAuthoredSpec = exports.fromTextChildren = exports.authoredText = exports.authoredProps = exports.authoredChild = void 0;
|
|
10
|
+
exports.fromChildren = fromChildren;
|
|
11
|
+
const error_1 = require("../composition/error");
|
|
12
|
+
/**
|
|
13
|
+
* Child-element type a schema field is filled from.
|
|
14
|
+
*
|
|
15
|
+
* `Symbol.for`: ESM and CJS builds must agree, same as `authorType`.
|
|
16
|
+
*/
|
|
17
|
+
exports.authoredChild = Symbol.for('elastic.isomer.authored_child');
|
|
18
|
+
/** Phantom props type for the child component. Not set at runtime. */
|
|
19
|
+
exports.authoredProps = Symbol.for('elastic.isomer.authored_props');
|
|
20
|
+
/** Set when a field is filled from text children. */
|
|
21
|
+
exports.authoredText = Symbol.for('elastic.isomer.authored_text');
|
|
22
|
+
const authoredToItem = Symbol.for('elastic.isomer.authored_to_item');
|
|
23
|
+
const authoredTextField = Symbol.for('elastic.isomer.authored_text_field');
|
|
24
|
+
const authoredCollapse = Symbol.for('elastic.isomer.authored_collapse');
|
|
25
|
+
const BRANDS = [
|
|
26
|
+
exports.authoredChild,
|
|
27
|
+
authoredTextField,
|
|
28
|
+
authoredToItem,
|
|
29
|
+
exports.authoredText,
|
|
30
|
+
authoredCollapse,
|
|
31
|
+
];
|
|
32
|
+
// Applies a complete branding. Branding an instance again is allowed only with
|
|
33
|
+
// the same configuration, absent options included, since both fields share it.
|
|
34
|
+
const brand = (caller, schema, config) => {
|
|
35
|
+
const record = schema;
|
|
36
|
+
if (BRANDS.some((key) => Object.hasOwn(schema, key))) {
|
|
37
|
+
if (BRANDS.every((key) => record[key] === config[key]))
|
|
38
|
+
return;
|
|
39
|
+
throw new error_1.IsomerError(error_1.ISOMER_ERROR_CODES.AUTHORED_SCHEMA_REUSED, `${caller}: this schema instance is already branded another way; pass each field its own schema.`);
|
|
40
|
+
}
|
|
41
|
+
for (const key of BRANDS) {
|
|
42
|
+
if (config[key] !== undefined) {
|
|
43
|
+
Object.defineProperty(schema, key, {
|
|
44
|
+
value: config[key],
|
|
45
|
+
enumerable: false,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function fromChildren(childType, schema, options) {
|
|
51
|
+
brand('fromChildren', schema, {
|
|
52
|
+
[exports.authoredChild]: childType,
|
|
53
|
+
[authoredTextField]: options?.text,
|
|
54
|
+
[authoredToItem]: options?.toItem,
|
|
55
|
+
});
|
|
56
|
+
return schema;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Brands `schema` as text children.
|
|
60
|
+
*
|
|
61
|
+
* Whitespace collapses unless `collapseWhitespace` is `false`.
|
|
62
|
+
*/
|
|
63
|
+
const fromTextChildren = (schema, options) => {
|
|
64
|
+
brand('fromTextChildren', schema, {
|
|
65
|
+
[exports.authoredText]: true,
|
|
66
|
+
[authoredCollapse]: options?.collapseWhitespace === false ? false : undefined,
|
|
67
|
+
});
|
|
68
|
+
return schema;
|
|
69
|
+
};
|
|
70
|
+
exports.fromTextChildren = fromTextChildren;
|
|
71
|
+
const zodDefType = (schema) => schema._zod?.def?.type;
|
|
72
|
+
const WRAPPER_TYPES = new Set(['optional', 'nullable', 'default', 'readonly']);
|
|
73
|
+
const innerSchema = (schema) => {
|
|
74
|
+
const def = schema._zod?.def;
|
|
75
|
+
return def?.type && WRAPPER_TYPES.has(def.type) ? def.innerType : undefined;
|
|
76
|
+
};
|
|
77
|
+
// The schema holding `brand`: `schema` or one it wraps.
|
|
78
|
+
const brandHolder = (schema, key) => {
|
|
79
|
+
let current = schema;
|
|
80
|
+
while (current && !Object.hasOwn(current, key)) {
|
|
81
|
+
current = innerSchema(current);
|
|
82
|
+
}
|
|
83
|
+
return current;
|
|
84
|
+
};
|
|
85
|
+
// Whether any wrapper layer of `schema` accepts `undefined`.
|
|
86
|
+
const optionalThrough = (schema) => {
|
|
87
|
+
for (let current = schema; current; current = innerSchema(current)) {
|
|
88
|
+
if (isOptionalSchema(current))
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
};
|
|
93
|
+
const unwrapAll = (schema) => {
|
|
94
|
+
let current = schema;
|
|
95
|
+
for (let inner = innerSchema(current); inner; inner = innerSchema(current)) {
|
|
96
|
+
current = inner;
|
|
97
|
+
}
|
|
98
|
+
return current;
|
|
99
|
+
};
|
|
100
|
+
/** `undefined` is a valid value, so children may be omitted. */
|
|
101
|
+
const isOptionalSchema = (schema) => {
|
|
102
|
+
const type = zodDefType(schema);
|
|
103
|
+
return type === 'optional' || type === 'default';
|
|
104
|
+
};
|
|
105
|
+
const schemaSignature = (schema, seen = new Set()) => {
|
|
106
|
+
if (seen.has(schema)) {
|
|
107
|
+
return 'cycle';
|
|
108
|
+
}
|
|
109
|
+
seen.add(schema);
|
|
110
|
+
const type = zodDefType(schema) ?? '?';
|
|
111
|
+
if (type === 'object' && 'shape' in schema) {
|
|
112
|
+
const shape = schema.shape;
|
|
113
|
+
const fields = Object.keys(shape)
|
|
114
|
+
.sort()
|
|
115
|
+
.map((key) => `${key}:${schemaSignature(shape[key], seen)}`);
|
|
116
|
+
return `{${fields.join(',')}}`;
|
|
117
|
+
}
|
|
118
|
+
if (type === 'array' && 'element' in schema) {
|
|
119
|
+
return `[${schemaSignature(schema.element, seen)}]`;
|
|
120
|
+
}
|
|
121
|
+
const inner = innerSchema(schema);
|
|
122
|
+
if (inner) {
|
|
123
|
+
return `${type}(${schemaSignature(inner, seen)})`;
|
|
124
|
+
}
|
|
125
|
+
return type;
|
|
126
|
+
};
|
|
127
|
+
const arrayElement = (schema) => {
|
|
128
|
+
const inner = unwrapAll(schema);
|
|
129
|
+
if (zodDefType(inner) === 'array' && 'element' in inner) {
|
|
130
|
+
return inner.element;
|
|
131
|
+
}
|
|
132
|
+
return inner;
|
|
133
|
+
};
|
|
134
|
+
const readChild = (field, schema) => {
|
|
135
|
+
const holder = brandHolder(schema, exports.authoredChild);
|
|
136
|
+
const childType = holder?.[exports.authoredChild];
|
|
137
|
+
if (!holder || typeof childType !== 'string') {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
const textField = holder[authoredTextField];
|
|
141
|
+
const toItem = holder[authoredToItem];
|
|
142
|
+
const child = {
|
|
143
|
+
field,
|
|
144
|
+
childType,
|
|
145
|
+
itemSchema: arrayElement(holder),
|
|
146
|
+
optional: optionalThrough(schema),
|
|
147
|
+
signature: schemaSignature(arrayElement(holder)),
|
|
148
|
+
};
|
|
149
|
+
if (typeof textField === 'string') {
|
|
150
|
+
child.textField = textField;
|
|
151
|
+
}
|
|
152
|
+
if (typeof toItem === 'function') {
|
|
153
|
+
child.toItem = toItem;
|
|
154
|
+
}
|
|
155
|
+
return child;
|
|
156
|
+
};
|
|
157
|
+
const readText = (field, schema) => {
|
|
158
|
+
const holder = brandHolder(schema, exports.authoredText);
|
|
159
|
+
if (!holder) {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
field,
|
|
164
|
+
collapseWhitespace: holder[authoredCollapse] !== false,
|
|
165
|
+
optional: optionalThrough(schema),
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
/** Top-level branded fields on an object schema. Nested brands stay on the item schema. */
|
|
169
|
+
const readAuthoredSpec = (schema) => {
|
|
170
|
+
if (zodDefType(schema) !== 'object' || !('shape' in schema)) {
|
|
171
|
+
return { children: [], text: [] };
|
|
172
|
+
}
|
|
173
|
+
const children = [];
|
|
174
|
+
const text = [];
|
|
175
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
176
|
+
const child = readChild(field, fieldSchema);
|
|
177
|
+
if (child) {
|
|
178
|
+
children.push(child);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const textField = readText(field, fieldSchema);
|
|
182
|
+
if (textField) {
|
|
183
|
+
text.push(textField);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return { children, text };
|
|
187
|
+
};
|
|
188
|
+
exports.readAuthoredSpec = readAuthoredSpec;
|
|
189
|
+
//# sourceMappingURL=authored_fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authored_fields.js","sourceRoot":"","sources":["../../../src/author/authored_fields.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAyIH,oCAcC;AAlJD,gDAAuE;AAGvE;;;;GAIG;AACU,QAAA,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAEzE,sEAAsE;AACzD,QAAA,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAEzE,qDAAqD;AACxC,QAAA,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAEvE,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AACrE,MAAM,iBAAiB,GAAG,MAAM,CAAC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AAC,IAAI,MAAM,CAAC,OAAO,CAC/C,MAAM,CAAC,KAAgC,CACxC,EAAE,CAAC;QACF,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC5C,IAAI,KAAK,EAAE,CAAC;YACV,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC/C,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC,CAAC;AApBW,QAAA,gBAAgB,oBAoB3B","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport type { ReactNode } from 'react';\nimport type { ZodType } from 'zod';\n\nimport { ISOMER_ERROR_CODES, IsomerError } from '../composition/error';\nimport type { PrimitiveNode } from '../define/primitive_module';\n\n/**\n * Child-element type a schema field is filled from.\n *\n * `Symbol.for`: ESM and CJS builds must agree, same as `authorType`.\n */\nexport const authoredChild = Symbol.for('elastic.isomer.authored_child');\n\n/** Phantom props type for the child component. Not set at runtime. */\nexport const authoredProps = Symbol.for('elastic.isomer.authored_props');\n\n/** Set when a field is filled from text children. */\nexport const authoredText = Symbol.for('elastic.isomer.authored_text');\n\nconst authoredToItem = Symbol.for('elastic.isomer.authored_to_item');\nconst authoredTextField = Symbol.for('elastic.isomer.authored_text_field');\nconst authoredCollapse = Symbol.for('elastic.isomer.authored_collapse');\n\n/**\n * A field filled from child elements of `TName`.\n *\n * Phantom: `z.infer` still reads the underlying schema. The shim reads `TName`\n * and `TProps` off the field type, and the symbols off the schema value.\n */\nexport interface AuthoredChildBrand<TName extends string, TProps> {\n readonly [authoredChild]: TName;\n readonly [authoredProps]: TProps;\n}\n\n/** A field filled from text children. */\nexport interface AuthoredTextBrand {\n readonly [authoredText]: true;\n}\n\n/** What {@link fromChildren}'s `toItem` receives. */\nexport interface AuthorChildContext {\n /** Nested elements, parsed as body nodes. */\n parseChildren: (children: ReactNode) => PrimitiveNode[];\n}\n\ntype ArrayItem<TSchema extends ZodType> =\n NonNullable<zOutput<TSchema>> extends readonly (infer Item)[]\n ? Item\n : NonNullable<zOutput<TSchema>>;\n\ntype zOutput<TSchema> = TSchema extends { _zod: { output: infer Output } }\n ? Output\n : never;\n\n/** `TText` is optional on the child props because leftover text fills it. */\ntype ChildProps<TItem, TText extends string | undefined> = [TText] extends [\n string,\n]\n ? Omit<TItem, TText> &\n Partial<Pick<TItem, Extract<TText, keyof TItem>>> & {\n children?: ReactNode;\n }\n : TItem & { children?: ReactNode };\n\nconst BRANDS = [\n authoredChild,\n authoredTextField,\n authoredToItem,\n authoredText,\n authoredCollapse,\n] as const;\n\n// Applies a complete branding. Branding an instance again is allowed only with\n// the same configuration, absent options included, since both fields share it.\nconst brand = (\n caller: 'fromChildren' | 'fromTextChildren',\n schema: object,\n config: Partial<Record<(typeof BRANDS)[number], unknown>>\n): void => {\n const record = schema as Record<symbol, unknown>;\n if (BRANDS.some((key) => Object.hasOwn(schema, key))) {\n if (BRANDS.every((key) => record[key] === config[key])) return;\n throw new IsomerError(\n ISOMER_ERROR_CODES.AUTHORED_SCHEMA_REUSED,\n `${caller}: this schema instance is already branded another way; pass each field its own schema.`\n );\n }\n for (const key of BRANDS) {\n if (config[key] !== undefined) {\n Object.defineProperty(schema, key, {\n value: config[key],\n enumerable: false,\n });\n }\n }\n};\n\n/**\n * Brands `schema` as JSX children of `childType`.\n *\n * `options.text` copies leftover text onto that field. `options.toItem` replaces\n * the default prop copy; its props annotation is the child component's props.\n * The brand is read through `.optional()`, `.nullable()`, `.default()`, and\n * `.readonly()`; any other method clones without it, so call it on `schema`\n * before passing it in.\n */\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n>(\n childType: TName,\n schema: TSchema\n): TSchema &\n AuthoredChildBrand<TName, ChildProps<ArrayItem<TSchema>, undefined>>;\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n const TText extends string,\n>(\n childType: TName,\n schema: TSchema,\n options: { text: TText }\n): TSchema & AuthoredChildBrand<TName, ChildProps<ArrayItem<TSchema>, TText>>;\nexport function fromChildren<\n const TName extends string,\n TSchema extends ZodType,\n TProps,\n>(\n childType: TName,\n schema: TSchema,\n options: {\n text?: string;\n toItem(props: TProps, context: AuthorChildContext): unknown;\n }\n): TSchema & AuthoredChildBrand<TName, TProps>;\nexport function fromChildren(\n childType: string,\n schema: ZodType,\n options?: {\n text?: string;\n toItem?: (this: void, props: never, context: AuthorChildContext) => unknown;\n }\n): ZodType {\n brand('fromChildren', schema, {\n [authoredChild]: childType,\n [authoredTextField]: options?.text,\n [authoredToItem]: options?.toItem,\n });\n return schema;\n}\n\n/**\n * Brands `schema` as text children.\n *\n * Whitespace collapses unless `collapseWhitespace` is `false`.\n */\nexport const fromTextChildren = <TSchema extends ZodType>(\n schema: TSchema,\n options?: { collapseWhitespace?: boolean }\n): TSchema & AuthoredTextBrand => {\n brand('fromTextChildren', schema, {\n [authoredText]: true,\n [authoredCollapse]:\n options?.collapseWhitespace === false ? false : undefined,\n });\n return schema as TSchema & AuthoredTextBrand;\n};\n\n/** One {@link fromChildren} field as the shim reads it. */\nexport interface AuthoredChildField {\n field: string;\n childType: string;\n /** Field leftover text children fill. */\n textField?: string;\n /** Replaces the default prop copy. */\n toItem?: (props: object, context: AuthorChildContext) => unknown;\n /** The array element schema, or the field schema itself when it is not an array. */\n itemSchema: ZodType;\n /** Whether the field accepts `undefined`, so children may be omitted. */\n optional: boolean;\n /** Structural fingerprint of `itemSchema`; every field branding one child type must share it. */\n signature: string;\n}\n\n/** One {@link fromTextChildren} field as the shim reads it. */\nexport interface AuthoredTextField {\n field: string;\n /** `true` unless the brand was given `collapseWhitespace: false`. */\n collapseWhitespace: boolean;\n /** Whether the field accepts `undefined`, so text children may be omitted. */\n optional: boolean;\n}\n\n/** The branded fields found on one object schema. */\nexport interface AuthoredSpec {\n children: AuthoredChildField[];\n text: AuthoredTextField[];\n}\n\nconst zodDefType = (schema: object): string | undefined =>\n (schema as { _zod?: { def?: { type?: string } } })._zod?.def?.type;\n\nconst WRAPPER_TYPES = new Set(['optional', 'nullable', 'default', 'readonly']);\n\ninterface WrapperDef {\n type?: string;\n innerType?: ZodType;\n}\n\nconst innerSchema = (schema: ZodType): ZodType | undefined => {\n const def: WrapperDef | undefined = (\n schema as { _zod?: { def?: WrapperDef } }\n )._zod?.def;\n return def?.type && WRAPPER_TYPES.has(def.type) ? def.innerType : undefined;\n};\n\n// The schema holding `brand`: `schema` or one it wraps.\nconst brandHolder = (schema: ZodType, key: symbol): ZodType | undefined => {\n let current: ZodType | undefined = schema;\n while (current && !Object.hasOwn(current, key)) {\n current = innerSchema(current);\n }\n return current;\n};\n\n// Whether any wrapper layer of `schema` accepts `undefined`.\nconst optionalThrough = (schema: ZodType): boolean => {\n for (\n let current: ZodType | undefined = schema;\n current;\n current = innerSchema(current)\n ) {\n if (isOptionalSchema(current)) return true;\n }\n return false;\n};\n\nconst unwrapAll = (schema: ZodType): ZodType => {\n let current = schema;\n for (let inner = innerSchema(current); inner; inner = innerSchema(current)) {\n current = inner;\n }\n return current;\n};\n\n/** `undefined` is a valid value, so children may be omitted. */\nconst isOptionalSchema = (schema: ZodType): boolean => {\n const type = zodDefType(schema);\n return type === 'optional' || type === 'default';\n};\n\nconst schemaSignature = (\n schema: ZodType,\n seen: Set<object> = new Set()\n): string => {\n if (seen.has(schema)) {\n return 'cycle';\n }\n seen.add(schema);\n const type = zodDefType(schema) ?? '?';\n if (type === 'object' && 'shape' in schema) {\n const shape = schema.shape as Record<string, ZodType>;\n const fields = Object.keys(shape)\n .sort()\n .map((key) => `${key}:${schemaSignature(shape[key] as ZodType, seen)}`);\n return `{${fields.join(',')}}`;\n }\n if (type === 'array' && 'element' in schema) {\n return `[${schemaSignature((schema as { element: ZodType }).element, seen)}]`;\n }\n const inner = innerSchema(schema);\n if (inner) {\n return `${type}(${schemaSignature(inner, seen)})`;\n }\n return type;\n};\n\nconst arrayElement = (schema: ZodType): ZodType => {\n const inner = unwrapAll(schema);\n if (zodDefType(inner) === 'array' && 'element' in inner) {\n return (inner as { element: ZodType }).element;\n }\n return inner;\n};\n\nconst readChild = (\n field: string,\n schema: ZodType\n): AuthoredChildField | undefined => {\n const holder = brandHolder(schema, authoredChild);\n const childType = (holder as { [authoredChild]?: unknown } | undefined)?.[\n authoredChild\n ];\n if (!holder || typeof childType !== 'string') {\n return undefined;\n }\n const textField = (holder as { [authoredTextField]?: unknown })[\n authoredTextField\n ];\n const toItem = (holder as { [authoredToItem]?: unknown })[authoredToItem];\n const child: AuthoredChildField = {\n field,\n childType,\n itemSchema: arrayElement(holder),\n optional: optionalThrough(schema),\n signature: schemaSignature(arrayElement(holder)),\n };\n if (typeof textField === 'string') {\n child.textField = textField;\n }\n if (typeof toItem === 'function') {\n child.toItem = toItem as (\n props: object,\n context: AuthorChildContext\n ) => unknown;\n }\n return child;\n};\n\nconst readText = (\n field: string,\n schema: ZodType\n): AuthoredTextField | undefined => {\n const holder = brandHolder(schema, authoredText);\n if (!holder) {\n return undefined;\n }\n return {\n field,\n collapseWhitespace:\n (holder as { [authoredCollapse]?: unknown })[authoredCollapse] !== false,\n optional: optionalThrough(schema),\n };\n};\n\n/** Top-level branded fields on an object schema. Nested brands stay on the item schema. */\nexport const readAuthoredSpec = (schema: ZodType): AuthoredSpec => {\n if (zodDefType(schema) !== 'object' || !('shape' in schema)) {\n return { children: [], text: [] };\n }\n const children: AuthoredChildField[] = [];\n const text: AuthoredTextField[] = [];\n for (const [field, fieldSchema] of Object.entries(\n schema.shape as Record<string, ZodType>\n )) {\n const child = readChild(field, fieldSchema);\n if (child) {\n children.push(child);\n continue;\n }\n const textField = readText(field, fieldSchema);\n if (textField) {\n text.push(textField);\n }\n }\n return { children, text };\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.formatPrimitiveEntry = exports.buildAuthoringPrompt = exports.AUTHORING_PROFILE_IDS = exports.textFromChildren = exports.buildJsxShim = exports.fromTextChildren = exports.fromChildren = void 0;
|
|
10
|
+
var authored_fields_1 = require("./authored_fields");
|
|
11
|
+
Object.defineProperty(exports, "fromChildren", { enumerable: true, get: function () { return authored_fields_1.fromChildren; } });
|
|
12
|
+
Object.defineProperty(exports, "fromTextChildren", { enumerable: true, get: function () { return authored_fields_1.fromTextChildren; } });
|
|
13
|
+
var jsx_shim_1 = require("./jsx_shim");
|
|
14
|
+
Object.defineProperty(exports, "buildJsxShim", { enumerable: true, get: function () { return jsx_shim_1.buildJsxShim; } });
|
|
15
|
+
Object.defineProperty(exports, "textFromChildren", { enumerable: true, get: function () { return jsx_shim_1.textFromChildren; } });
|
|
16
|
+
var prompt_1 = require("./prompt");
|
|
17
|
+
Object.defineProperty(exports, "AUTHORING_PROFILE_IDS", { enumerable: true, get: function () { return prompt_1.AUTHORING_PROFILE_IDS; } });
|
|
18
|
+
Object.defineProperty(exports, "buildAuthoringPrompt", { enumerable: true, get: function () { return prompt_1.buildAuthoringPrompt; } });
|
|
19
|
+
Object.defineProperty(exports, "formatPrimitiveEntry", { enumerable: true, get: function () { return prompt_1.formatPrimitiveEntry; } });
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/author/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qDAM2B;AAFzB,+GAAA,YAAY,OAAA;AACZ,mHAAA,gBAAgB,OAAA;AAGlB,uCAOoB;AAFlB,wGAAA,YAAY,OAAA;AACZ,4GAAA,gBAAgB,OAAA;AAElB,mCAOkB;AAHhB,+GAAA,qBAAqB,OAAA;AACrB,8GAAA,oBAAoB,OAAA;AACpB,8GAAA,oBAAoB,OAAA","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 AuthorChildContext,\n type AuthoredChildBrand,\n type AuthoredTextBrand,\n fromChildren,\n fromTextChildren,\n} from './authored_fields';\nexport { type AuthorComponent } from './jsx';\nexport {\n type AuthorComposition,\n type CompositionAuthorProps,\n type JsxShim,\n type PrimitiveComponentMap,\n buildJsxShim,\n textFromChildren,\n} from './jsx_shim';\nexport {\n type AuthoringProfileId,\n type AuthoringPromptContext,\n type AuthoringViewSummary,\n AUTHORING_PROFILE_IDS,\n buildAuthoringPrompt,\n formatPrimitiveEntry,\n} from './prompt';\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
6
|
+
* 2.0.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.defineAuthorComponent = exports.authorType = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Brand carrying the primitive type an authoring component stands for.
|
|
12
|
+
*
|
|
13
|
+
* `Symbol.for` rather than `Symbol()`: the SDK ships both ESM and CJS builds,
|
|
14
|
+
* so a host can hold two copies of this module and a unique symbol would make
|
|
15
|
+
* one build's components unreadable to the other's shim.
|
|
16
|
+
*/
|
|
17
|
+
exports.authorType = Symbol.for('elastic.isomer.author_type');
|
|
18
|
+
/** The {@link AuthorComponent} for one primitive `type`. */
|
|
19
|
+
const defineAuthorComponent = (type) => Object.assign(() => null, {
|
|
20
|
+
[exports.authorType]: type,
|
|
21
|
+
displayName: type,
|
|
22
|
+
});
|
|
23
|
+
exports.defineAuthorComponent = defineAuthorComponent;
|
|
24
|
+
//# sourceMappingURL=jsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.js","sourceRoot":"","sources":["../../../src/author/jsx.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;GAMG;AACU,QAAA,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAanE,4DAA4D;AACrD,MAAM,qBAAqB,GAAG,CACnC,IAAW,EACqB,EAAE,CAClC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE;IACxB,CAAC,kBAAU,CAAC,EAAE,IAAI;IAClB,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AANQ,QAAA,qBAAqB,yBAM7B","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 * Brand carrying the primitive type an authoring component stands for.\n *\n * `Symbol.for` rather than `Symbol()`: the SDK ships both ESM and CJS builds,\n * so a host can hold two copies of this module and a unique symbol would make\n * one build's components unreadable to the other's shim.\n */\nexport const authorType = Symbol.for('elastic.isomer.author_type');\n\n/**\n * A JSX component that renders `null` and exists only to carry `TType` through\n * the tree until the shim converts it to a composition.\n */\nexport interface AuthorComponent<TProps, TType extends string> {\n (props: TProps): null;\n readonly [authorType]: TType;\n /** Set to `type` by the shim. */\n displayName?: string;\n}\n\n/** The {@link AuthorComponent} for one primitive `type`. */\nexport const defineAuthorComponent = <TProps, TType extends string>(\n type: TType\n): AuthorComponent<TProps, TType> =>\n Object.assign(() => null, {\n [authorType]: type,\n displayName: type,\n });\n"]}
|