@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.
Files changed (450) hide show
  1. package/LICENSE.txt +93 -0
  2. package/NOTICE.txt +1861 -0
  3. package/README.md +58 -0
  4. package/THIRD_PARTY_LICENSES.md +957 -0
  5. package/dist/author/authored_fields.d.ts +103 -0
  6. package/dist/author/authored_fields.d.ts.map +1 -0
  7. package/dist/author/authored_fields.js +183 -0
  8. package/dist/author/authored_fields.js.map +1 -0
  9. package/dist/author/index.d.ts +5 -0
  10. package/dist/author/index.d.ts.map +1 -0
  11. package/dist/author/index.js +10 -0
  12. package/dist/author/index.js.map +1 -0
  13. package/dist/author/jsx.d.ts +21 -0
  14. package/dist/author/jsx.d.ts.map +1 -0
  15. package/dist/author/jsx.js +20 -0
  16. package/dist/author/jsx.js.map +1 -0
  17. package/dist/author/jsx_shim.d.ts +116 -0
  18. package/dist/author/jsx_shim.d.ts.map +1 -0
  19. package/dist/author/jsx_shim.js +353 -0
  20. package/dist/author/jsx_shim.js.map +1 -0
  21. package/dist/author/prompt.d.ts +58 -0
  22. package/dist/author/prompt.d.ts.map +1 -0
  23. package/dist/author/prompt.js +148 -0
  24. package/dist/author/prompt.js.map +1 -0
  25. package/dist/cjs/author/authored_fields.js +189 -0
  26. package/dist/cjs/author/authored_fields.js.map +1 -0
  27. package/dist/cjs/author/index.js +20 -0
  28. package/dist/cjs/author/index.js.map +1 -0
  29. package/dist/cjs/author/jsx.js +24 -0
  30. package/dist/cjs/author/jsx.js.map +1 -0
  31. package/dist/cjs/author/jsx_shim.js +359 -0
  32. package/dist/cjs/author/jsx_shim.js.map +1 -0
  33. package/dist/cjs/author/prompt.js +153 -0
  34. package/dist/cjs/author/prompt.js.map +1 -0
  35. package/dist/cjs/composition/action_event.js +9 -0
  36. package/dist/cjs/composition/action_event.js.map +1 -0
  37. package/dist/cjs/composition/body_node_base.js +105 -0
  38. package/dist/cjs/composition/body_node_base.js.map +1 -0
  39. package/dist/cjs/composition/composition.js +9 -0
  40. package/dist/cjs/composition/composition.js.map +1 -0
  41. package/dist/cjs/composition/error.js +72 -0
  42. package/dist/cjs/composition/error.js.map +1 -0
  43. package/dist/cjs/composition/index.js +31 -0
  44. package/dist/cjs/composition/index.js.map +1 -0
  45. package/dist/cjs/composition/map_nodes.js +85 -0
  46. package/dist/cjs/composition/map_nodes.js.map +1 -0
  47. package/dist/cjs/composition/named_color.js +20 -0
  48. package/dist/cjs/composition/named_color.js.map +1 -0
  49. package/dist/cjs/composition/node.js +9 -0
  50. package/dist/cjs/composition/node.js.map +1 -0
  51. package/dist/cjs/composition/one_line.js +23 -0
  52. package/dist/cjs/composition/one_line.js.map +1 -0
  53. package/dist/cjs/composition/structured_value.js +21 -0
  54. package/dist/cjs/composition/structured_value.js.map +1 -0
  55. package/dist/cjs/composition/validation_error.js +40 -0
  56. package/dist/cjs/composition/validation_error.js.map +1 -0
  57. package/dist/cjs/define/frame.js +32 -0
  58. package/dist/cjs/define/frame.js.map +1 -0
  59. package/dist/cjs/define/index.js +25 -0
  60. package/dist/cjs/define/index.js.map +1 -0
  61. package/dist/cjs/define/markdown_content.js +12 -0
  62. package/dist/cjs/define/markdown_content.js.map +1 -0
  63. package/dist/cjs/define/primitive_module.js +107 -0
  64. package/dist/cjs/define/primitive_module.js.map +1 -0
  65. package/dist/cjs/define/slack_assets.js +9 -0
  66. package/dist/cjs/define/slack_assets.js.map +1 -0
  67. package/dist/cjs/define/slack_blocks.js +9 -0
  68. package/dist/cjs/define/slack_blocks.js.map +1 -0
  69. package/dist/cjs/define/zod_format.js +122 -0
  70. package/dist/cjs/define/zod_format.js.map +1 -0
  71. package/dist/cjs/define/zod_helpers.js +26 -0
  72. package/dist/cjs/define/zod_helpers.js.map +1 -0
  73. package/dist/cjs/entries/html.js +12 -0
  74. package/dist/cjs/entries/html.js.map +1 -0
  75. package/dist/cjs/entries/index.js +75 -0
  76. package/dist/cjs/entries/index.js.map +1 -0
  77. package/dist/cjs/entries/markdown.js +14 -0
  78. package/dist/cjs/entries/markdown.js.map +1 -0
  79. package/dist/cjs/entries/react.js +20 -0
  80. package/dist/cjs/entries/react.js.map +1 -0
  81. package/dist/cjs/entries/slack.js +26 -0
  82. package/dist/cjs/entries/slack.js.map +1 -0
  83. package/dist/cjs/entries/text.js +12 -0
  84. package/dist/cjs/entries/text.js.map +1 -0
  85. package/dist/cjs/pack/capabilities.js +34 -0
  86. package/dist/cjs/pack/capabilities.js.map +1 -0
  87. package/dist/cjs/pack/compose.js +56 -0
  88. package/dist/cjs/pack/compose.js.map +1 -0
  89. package/dist/cjs/pack/enhancements.js +65 -0
  90. package/dist/cjs/pack/enhancements.js.map +1 -0
  91. package/dist/cjs/pack/index.js +18 -0
  92. package/dist/cjs/pack/index.js.map +1 -0
  93. package/dist/cjs/pack/primitive_pack.js +85 -0
  94. package/dist/cjs/pack/primitive_pack.js.map +1 -0
  95. package/dist/cjs/package.json +3 -0
  96. package/dist/cjs/render/anchors.js +167 -0
  97. package/dist/cjs/render/anchors.js.map +1 -0
  98. package/dist/cjs/render/context_view.js +54 -0
  99. package/dist/cjs/render/context_view.js.map +1 -0
  100. package/dist/cjs/render/format_display_value.js +143 -0
  101. package/dist/cjs/render/format_display_value.js.map +1 -0
  102. package/dist/cjs/render/format_number.js +46 -0
  103. package/dist/cjs/render/format_number.js.map +1 -0
  104. package/dist/cjs/render/html/enhancements.js +30 -0
  105. package/dist/cjs/render/html/enhancements.js.map +1 -0
  106. package/dist/cjs/render/html/envelope.js +218 -0
  107. package/dist/cjs/render/html/envelope.js.map +1 -0
  108. package/dist/cjs/render/html/index.js +12 -0
  109. package/dist/cjs/render/html/index.js.map +1 -0
  110. package/dist/cjs/render/index.js +25 -0
  111. package/dist/cjs/render/index.js.map +1 -0
  112. package/dist/cjs/render/layout_check.js +133 -0
  113. package/dist/cjs/render/layout_check.js.map +1 -0
  114. package/dist/cjs/render/markdown/builder.js +189 -0
  115. package/dist/cjs/render/markdown/builder.js.map +1 -0
  116. package/dist/cjs/render/markdown/envelope.js +33 -0
  117. package/dist/cjs/render/markdown/envelope.js.map +1 -0
  118. package/dist/cjs/render/markdown/format.js +190 -0
  119. package/dist/cjs/render/markdown/format.js.map +1 -0
  120. package/dist/cjs/render/markdown/index.js +15 -0
  121. package/dist/cjs/render/markdown/index.js.map +1 -0
  122. package/dist/cjs/render/measure_dom.js +61 -0
  123. package/dist/cjs/render/measure_dom.js.map +1 -0
  124. package/dist/cjs/render/payload.js +13 -0
  125. package/dist/cjs/render/payload.js.map +1 -0
  126. package/dist/cjs/render/primitive_dispatch.js +187 -0
  127. package/dist/cjs/render/primitive_dispatch.js.map +1 -0
  128. package/dist/cjs/render/react/content.js +44 -0
  129. package/dist/cjs/render/react/content.js.map +1 -0
  130. package/dist/cjs/render/react/enhancements.js +32 -0
  131. package/dist/cjs/render/react/enhancements.js.map +1 -0
  132. package/dist/cjs/render/react/index.js +15 -0
  133. package/dist/cjs/render/react/index.js.map +1 -0
  134. package/dist/cjs/render/slack/assets.js +45 -0
  135. package/dist/cjs/render/slack/assets.js.map +1 -0
  136. package/dist/cjs/render/slack/blocks.js +80 -0
  137. package/dist/cjs/render/slack/blocks.js.map +1 -0
  138. package/dist/cjs/render/slack/envelope.js +551 -0
  139. package/dist/cjs/render/slack/envelope.js.map +1 -0
  140. package/dist/cjs/render/slack/format.js +825 -0
  141. package/dist/cjs/render/slack/format.js.map +1 -0
  142. package/dist/cjs/render/slack/index.js +31 -0
  143. package/dist/cjs/render/slack/index.js.map +1 -0
  144. package/dist/cjs/render/slack/markdown_content.js +358 -0
  145. package/dist/cjs/render/slack/markdown_content.js.map +1 -0
  146. package/dist/cjs/render/text/envelope.js +21 -0
  147. package/dist/cjs/render/text/envelope.js.map +1 -0
  148. package/dist/cjs/render/text/index.js +12 -0
  149. package/dist/cjs/render/text/index.js.map +1 -0
  150. package/dist/cjs/testing/conformance.js +296 -0
  151. package/dist/cjs/testing/conformance.js.map +1 -0
  152. package/dist/cjs/testing/index.js +16 -0
  153. package/dist/cjs/testing/index.js.map +1 -0
  154. package/dist/cjs/testing/registration.js +140 -0
  155. package/dist/cjs/testing/registration.js.map +1 -0
  156. package/dist/cjs/validate/authoring_schema.js +296 -0
  157. package/dist/cjs/validate/authoring_schema.js.map +1 -0
  158. package/dist/cjs/validate/composition_schema.js +135 -0
  159. package/dist/cjs/validate/composition_schema.js.map +1 -0
  160. package/dist/cjs/validate/index.js +52 -0
  161. package/dist/cjs/validate/index.js.map +1 -0
  162. package/dist/cjs/validate/input_budget.js +156 -0
  163. package/dist/cjs/validate/input_budget.js.map +1 -0
  164. package/dist/cjs/validate/json_schema.js +72 -0
  165. package/dist/cjs/validate/json_schema.js.map +1 -0
  166. package/dist/cjs/validate/node_issues.js +65 -0
  167. package/dist/cjs/validate/node_issues.js.map +1 -0
  168. package/dist/cjs/validate/url.js +116 -0
  169. package/dist/cjs/validate/url.js.map +1 -0
  170. package/dist/cjs/validate/validation.js +208 -0
  171. package/dist/cjs/validate/validation.js.map +1 -0
  172. package/dist/cjs/validate/value_schemas.js +53 -0
  173. package/dist/cjs/validate/value_schemas.js.map +1 -0
  174. package/dist/composition/action_event.d.ts +13 -0
  175. package/dist/composition/action_event.d.ts.map +1 -0
  176. package/dist/composition/action_event.js +8 -0
  177. package/dist/composition/action_event.js.map +1 -0
  178. package/dist/composition/body_node_base.d.ts +71 -0
  179. package/dist/composition/body_node_base.d.ts.map +1 -0
  180. package/dist/composition/body_node_base.js +97 -0
  181. package/dist/composition/body_node_base.js.map +1 -0
  182. package/dist/composition/composition.d.ts +71 -0
  183. package/dist/composition/composition.d.ts.map +1 -0
  184. package/dist/composition/composition.js +8 -0
  185. package/dist/composition/composition.js.map +1 -0
  186. package/dist/composition/error.d.ts +60 -0
  187. package/dist/composition/error.d.ts.map +1 -0
  188. package/dist/composition/error.js +68 -0
  189. package/dist/composition/error.js.map +1 -0
  190. package/dist/composition/index.d.ts +11 -0
  191. package/dist/composition/index.d.ts.map +1 -0
  192. package/dist/composition/index.js +14 -0
  193. package/dist/composition/index.js.map +1 -0
  194. package/dist/composition/map_nodes.d.ts +16 -0
  195. package/dist/composition/map_nodes.d.ts.map +1 -0
  196. package/dist/composition/map_nodes.js +81 -0
  197. package/dist/composition/map_nodes.js.map +1 -0
  198. package/dist/composition/named_color.d.ts +9 -0
  199. package/dist/composition/named_color.d.ts.map +1 -0
  200. package/dist/composition/named_color.js +17 -0
  201. package/dist/composition/named_color.js.map +1 -0
  202. package/dist/composition/node.d.ts +11 -0
  203. package/dist/composition/node.d.ts.map +1 -0
  204. package/dist/composition/node.js +8 -0
  205. package/dist/composition/node.js.map +1 -0
  206. package/dist/composition/one_line.d.ts +7 -0
  207. package/dist/composition/one_line.d.ts.map +1 -0
  208. package/dist/composition/one_line.js +17 -0
  209. package/dist/composition/one_line.js.map +1 -0
  210. package/dist/composition/structured_value.d.ts +27 -0
  211. package/dist/composition/structured_value.d.ts.map +1 -0
  212. package/dist/composition/structured_value.js +18 -0
  213. package/dist/composition/structured_value.js.map +1 -0
  214. package/dist/composition/validation_error.d.ts +33 -0
  215. package/dist/composition/validation_error.d.ts.map +1 -0
  216. package/dist/composition/validation_error.js +35 -0
  217. package/dist/composition/validation_error.js.map +1 -0
  218. package/dist/define/frame.d.ts +166 -0
  219. package/dist/define/frame.d.ts.map +1 -0
  220. package/dist/define/frame.js +28 -0
  221. package/dist/define/frame.js.map +1 -0
  222. package/dist/define/index.d.ts +8 -0
  223. package/dist/define/index.d.ts.map +1 -0
  224. package/dist/define/index.js +11 -0
  225. package/dist/define/index.js.map +1 -0
  226. package/dist/define/markdown_content.d.ts +15 -0
  227. package/dist/define/markdown_content.d.ts.map +1 -0
  228. package/dist/define/markdown_content.js +9 -0
  229. package/dist/define/markdown_content.js.map +1 -0
  230. package/dist/define/primitive_module.d.ts +421 -0
  231. package/dist/define/primitive_module.d.ts.map +1 -0
  232. package/dist/define/primitive_module.js +101 -0
  233. package/dist/define/primitive_module.js.map +1 -0
  234. package/dist/define/slack_assets.d.ts +28 -0
  235. package/dist/define/slack_assets.d.ts.map +1 -0
  236. package/dist/define/slack_assets.js +8 -0
  237. package/dist/define/slack_assets.js.map +1 -0
  238. package/dist/define/slack_blocks.d.ts +234 -0
  239. package/dist/define/slack_blocks.d.ts.map +1 -0
  240. package/dist/define/slack_blocks.js +8 -0
  241. package/dist/define/slack_blocks.js.map +1 -0
  242. package/dist/define/zod_format.d.ts +33 -0
  243. package/dist/define/zod_format.d.ts.map +1 -0
  244. package/dist/define/zod_format.js +114 -0
  245. package/dist/define/zod_format.js.map +1 -0
  246. package/dist/define/zod_helpers.d.ts +10 -0
  247. package/dist/define/zod_helpers.d.ts.map +1 -0
  248. package/dist/define/zod_helpers.js +22 -0
  249. package/dist/define/zod_helpers.js.map +1 -0
  250. package/dist/entries/html.d.ts +3 -0
  251. package/dist/entries/html.d.ts.map +1 -0
  252. package/dist/entries/html.js +8 -0
  253. package/dist/entries/html.js.map +1 -0
  254. package/dist/entries/index.d.ts +6 -0
  255. package/dist/entries/index.d.ts.map +1 -0
  256. package/dist/entries/index.js +12 -0
  257. package/dist/entries/index.js.map +1 -0
  258. package/dist/entries/markdown.d.ts +3 -0
  259. package/dist/entries/markdown.d.ts.map +1 -0
  260. package/dist/entries/markdown.js +8 -0
  261. package/dist/entries/markdown.js.map +1 -0
  262. package/dist/entries/react.d.ts +5 -0
  263. package/dist/entries/react.d.ts.map +1 -0
  264. package/dist/entries/react.js +11 -0
  265. package/dist/entries/react.js.map +1 -0
  266. package/dist/entries/slack.d.ts +2 -0
  267. package/dist/entries/slack.d.ts.map +1 -0
  268. package/dist/entries/slack.js +8 -0
  269. package/dist/entries/slack.js.map +1 -0
  270. package/dist/entries/text.d.ts +2 -0
  271. package/dist/entries/text.d.ts.map +1 -0
  272. package/dist/entries/text.js +8 -0
  273. package/dist/entries/text.js.map +1 -0
  274. package/dist/pack/capabilities.d.ts +27 -0
  275. package/dist/pack/capabilities.d.ts.map +1 -0
  276. package/dist/pack/capabilities.js +30 -0
  277. package/dist/pack/capabilities.js.map +1 -0
  278. package/dist/pack/compose.d.ts +21 -0
  279. package/dist/pack/compose.d.ts.map +1 -0
  280. package/dist/pack/compose.js +52 -0
  281. package/dist/pack/compose.js.map +1 -0
  282. package/dist/pack/enhancements.d.ts +65 -0
  283. package/dist/pack/enhancements.d.ts.map +1 -0
  284. package/dist/pack/enhancements.js +59 -0
  285. package/dist/pack/enhancements.js.map +1 -0
  286. package/dist/pack/index.d.ts +5 -0
  287. package/dist/pack/index.d.ts.map +1 -0
  288. package/dist/pack/index.js +11 -0
  289. package/dist/pack/index.js.map +1 -0
  290. package/dist/pack/primitive_pack.d.ts +155 -0
  291. package/dist/pack/primitive_pack.d.ts.map +1 -0
  292. package/dist/pack/primitive_pack.js +81 -0
  293. package/dist/pack/primitive_pack.js.map +1 -0
  294. package/dist/render/anchors.d.ts +82 -0
  295. package/dist/render/anchors.d.ts.map +1 -0
  296. package/dist/render/anchors.js +153 -0
  297. package/dist/render/anchors.js.map +1 -0
  298. package/dist/render/context_view.d.ts +10 -0
  299. package/dist/render/context_view.d.ts.map +1 -0
  300. package/dist/render/context_view.js +49 -0
  301. package/dist/render/context_view.js.map +1 -0
  302. package/dist/render/format_display_value.d.ts +20 -0
  303. package/dist/render/format_display_value.d.ts.map +1 -0
  304. package/dist/render/format_display_value.js +137 -0
  305. package/dist/render/format_display_value.js.map +1 -0
  306. package/dist/render/format_number.d.ts +9 -0
  307. package/dist/render/format_number.d.ts.map +1 -0
  308. package/dist/render/format_number.js +42 -0
  309. package/dist/render/format_number.js.map +1 -0
  310. package/dist/render/html/enhancements.d.ts +10 -0
  311. package/dist/render/html/enhancements.d.ts.map +1 -0
  312. package/dist/render/html/enhancements.js +25 -0
  313. package/dist/render/html/enhancements.js.map +1 -0
  314. package/dist/render/html/envelope.d.ts +182 -0
  315. package/dist/render/html/envelope.d.ts.map +1 -0
  316. package/dist/render/html/envelope.js +214 -0
  317. package/dist/render/html/envelope.js.map +1 -0
  318. package/dist/render/html/index.d.ts +3 -0
  319. package/dist/render/html/index.d.ts.map +1 -0
  320. package/dist/render/html/index.js +8 -0
  321. package/dist/render/html/index.js.map +1 -0
  322. package/dist/render/index.d.ts +6 -0
  323. package/dist/render/index.d.ts.map +1 -0
  324. package/dist/render/index.js +11 -0
  325. package/dist/render/index.js.map +1 -0
  326. package/dist/render/layout_check.d.ts +43 -0
  327. package/dist/render/layout_check.d.ts.map +1 -0
  328. package/dist/render/layout_check.js +129 -0
  329. package/dist/render/layout_check.js.map +1 -0
  330. package/dist/render/markdown/builder.d.ts +48 -0
  331. package/dist/render/markdown/builder.d.ts.map +1 -0
  332. package/dist/render/markdown/builder.js +183 -0
  333. package/dist/render/markdown/builder.js.map +1 -0
  334. package/dist/render/markdown/envelope.d.ts +20 -0
  335. package/dist/render/markdown/envelope.d.ts.map +1 -0
  336. package/dist/render/markdown/envelope.js +29 -0
  337. package/dist/render/markdown/envelope.js.map +1 -0
  338. package/dist/render/markdown/format.d.ts +3 -0
  339. package/dist/render/markdown/format.d.ts.map +1 -0
  340. package/dist/render/markdown/format.js +186 -0
  341. package/dist/render/markdown/format.js.map +1 -0
  342. package/dist/render/markdown/index.d.ts +3 -0
  343. package/dist/render/markdown/index.d.ts.map +1 -0
  344. package/dist/render/markdown/index.js +9 -0
  345. package/dist/render/markdown/index.js.map +1 -0
  346. package/dist/render/measure_dom.d.ts +10 -0
  347. package/dist/render/measure_dom.d.ts.map +1 -0
  348. package/dist/render/measure_dom.js +57 -0
  349. package/dist/render/measure_dom.js.map +1 -0
  350. package/dist/render/payload.d.ts +16 -0
  351. package/dist/render/payload.d.ts.map +1 -0
  352. package/dist/render/payload.js +9 -0
  353. package/dist/render/payload.js.map +1 -0
  354. package/dist/render/primitive_dispatch.d.ts +72 -0
  355. package/dist/render/primitive_dispatch.d.ts.map +1 -0
  356. package/dist/render/primitive_dispatch.js +183 -0
  357. package/dist/render/primitive_dispatch.js.map +1 -0
  358. package/dist/render/react/content.d.ts +40 -0
  359. package/dist/render/react/content.d.ts.map +1 -0
  360. package/dist/render/react/content.js +39 -0
  361. package/dist/render/react/content.js.map +1 -0
  362. package/dist/render/react/enhancements.d.ts +15 -0
  363. package/dist/render/react/enhancements.d.ts.map +1 -0
  364. package/dist/render/react/enhancements.js +28 -0
  365. package/dist/render/react/enhancements.js.map +1 -0
  366. package/dist/render/react/index.d.ts +3 -0
  367. package/dist/render/react/index.d.ts.map +1 -0
  368. package/dist/render/react/index.js +9 -0
  369. package/dist/render/react/index.js.map +1 -0
  370. package/dist/render/slack/assets.d.ts +16 -0
  371. package/dist/render/slack/assets.d.ts.map +1 -0
  372. package/dist/render/slack/assets.js +40 -0
  373. package/dist/render/slack/assets.js.map +1 -0
  374. package/dist/render/slack/blocks.d.ts +72 -0
  375. package/dist/render/slack/blocks.d.ts.map +1 -0
  376. package/dist/render/slack/blocks.js +77 -0
  377. package/dist/render/slack/blocks.js.map +1 -0
  378. package/dist/render/slack/envelope.d.ts +52 -0
  379. package/dist/render/slack/envelope.d.ts.map +1 -0
  380. package/dist/render/slack/envelope.js +547 -0
  381. package/dist/render/slack/envelope.js.map +1 -0
  382. package/dist/render/slack/format.d.ts +95 -0
  383. package/dist/render/slack/format.d.ts.map +1 -0
  384. package/dist/render/slack/format.js +807 -0
  385. package/dist/render/slack/format.js.map +1 -0
  386. package/dist/render/slack/index.d.ts +6 -0
  387. package/dist/render/slack/index.d.ts.map +1 -0
  388. package/dist/render/slack/index.js +12 -0
  389. package/dist/render/slack/index.js.map +1 -0
  390. package/dist/render/slack/markdown_content.d.ts +11 -0
  391. package/dist/render/slack/markdown_content.d.ts.map +1 -0
  392. package/dist/render/slack/markdown_content.js +354 -0
  393. package/dist/render/slack/markdown_content.js.map +1 -0
  394. package/dist/render/text/envelope.d.ts +15 -0
  395. package/dist/render/text/envelope.d.ts.map +1 -0
  396. package/dist/render/text/envelope.js +17 -0
  397. package/dist/render/text/envelope.js.map +1 -0
  398. package/dist/render/text/index.d.ts +2 -0
  399. package/dist/render/text/index.d.ts.map +1 -0
  400. package/dist/render/text/index.js +8 -0
  401. package/dist/render/text/index.js.map +1 -0
  402. package/dist/testing/conformance.d.ts +140 -0
  403. package/dist/testing/conformance.d.ts.map +1 -0
  404. package/dist/testing/conformance.js +287 -0
  405. package/dist/testing/conformance.js.map +1 -0
  406. package/dist/testing/index.d.ts +3 -0
  407. package/dist/testing/index.d.ts.map +1 -0
  408. package/dist/testing/index.js +9 -0
  409. package/dist/testing/index.js.map +1 -0
  410. package/dist/testing/registration.d.ts +32 -0
  411. package/dist/testing/registration.d.ts.map +1 -0
  412. package/dist/testing/registration.js +103 -0
  413. package/dist/testing/registration.js.map +1 -0
  414. package/dist/validate/authoring_schema.d.ts +27 -0
  415. package/dist/validate/authoring_schema.d.ts.map +1 -0
  416. package/dist/validate/authoring_schema.js +291 -0
  417. package/dist/validate/authoring_schema.js.map +1 -0
  418. package/dist/validate/composition_schema.d.ts +80 -0
  419. package/dist/validate/composition_schema.d.ts.map +1 -0
  420. package/dist/validate/composition_schema.js +127 -0
  421. package/dist/validate/composition_schema.js.map +1 -0
  422. package/dist/validate/index.d.ts +9 -0
  423. package/dist/validate/index.d.ts.map +1 -0
  424. package/dist/validate/index.js +15 -0
  425. package/dist/validate/index.js.map +1 -0
  426. package/dist/validate/input_budget.d.ts +35 -0
  427. package/dist/validate/input_budget.d.ts.map +1 -0
  428. package/dist/validate/input_budget.js +151 -0
  429. package/dist/validate/input_budget.js.map +1 -0
  430. package/dist/validate/json_schema.d.ts +32 -0
  431. package/dist/validate/json_schema.d.ts.map +1 -0
  432. package/dist/validate/json_schema.js +68 -0
  433. package/dist/validate/json_schema.js.map +1 -0
  434. package/dist/validate/node_issues.d.ts +12 -0
  435. package/dist/validate/node_issues.d.ts.map +1 -0
  436. package/dist/validate/node_issues.js +61 -0
  437. package/dist/validate/node_issues.js.map +1 -0
  438. package/dist/validate/url.d.ts +50 -0
  439. package/dist/validate/url.d.ts.map +1 -0
  440. package/dist/validate/url.js +107 -0
  441. package/dist/validate/url.js.map +1 -0
  442. package/dist/validate/validation.d.ts +105 -0
  443. package/dist/validate/validation.d.ts.map +1 -0
  444. package/dist/validate/validation.js +200 -0
  445. package/dist/validate/validation.js.map +1 -0
  446. package/dist/validate/value_schemas.d.ts +53 -0
  447. package/dist/validate/value_schemas.d.ts.map +1 -0
  448. package/dist/validate/value_schemas.js +50 -0
  449. package/dist/validate/value_schemas.js.map +1 -0
  450. package/package.json +118 -5
@@ -0,0 +1,208 @@
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.createCompositionParser = exports.createCompositionValidator = exports.compositionToRender = exports.enforceValidationMode = exports.CompositionValidationError = exports.warningsForSurface = void 0;
10
+ const body_node_base_1 = require("../composition/body_node_base");
11
+ const one_line_1 = require("../composition/one_line");
12
+ const validation_error_1 = require("../composition/validation_error");
13
+ Object.defineProperty(exports, "CompositionValidationError", { enumerable: true, get: function () { return validation_error_1.CompositionValidationError; } });
14
+ const composition_schema_1 = require("./composition_schema");
15
+ const input_budget_1 = require("./input_budget");
16
+ const node_issues_1 = require("./node_issues");
17
+ const checkedComposition = Symbol.for('elastic.isomer.checked_composition');
18
+ /** Narrows a result's warnings to the surface a caller is about to render. */
19
+ const warningsForSurface = (result, surface) => result.warnings.filter((warning) => warning.surface === surface);
20
+ exports.warningsForSurface = warningsForSurface;
21
+ /** Raises {@link CompositionValidationError} when `mode` is `throw` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input, which nothing can render. */
22
+ const enforceValidationMode = (result, mode) => {
23
+ if (!result.valid &&
24
+ (mode === 'throw' || result.errors.some(input_budget_1.isInputRefusal))) {
25
+ throw new validation_error_1.CompositionValidationError(result.errors);
26
+ }
27
+ };
28
+ exports.enforceValidationMode = enforceValidationMode;
29
+ /** The composition `result` checked, which is what a render draws. Throws {@link CompositionValidationError} when `mode` is `'throw'` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input. */
30
+ const compositionToRender = (result, mode) => {
31
+ (0, exports.enforceValidationMode)(result, mode);
32
+ const { composition } = result;
33
+ if (composition === undefined) {
34
+ throw new validation_error_1.CompositionValidationError(result.errors);
35
+ }
36
+ return composition;
37
+ };
38
+ exports.compositionToRender = compositionToRender;
39
+ /** The body's nodes, as {@link IssueRoot}s for a node issue formatter. */
40
+ const bodyRoots = (value) => {
41
+ const { body } = (value ?? {});
42
+ return Array.isArray(body)
43
+ ? body.map((node, index) => [node, `body[${index}]`])
44
+ : [];
45
+ };
46
+ /**
47
+ * Builds the trusted-input validator: {@link checkInputBudget}, then the schema and the semantic passes on its copy, which the result carries.
48
+ *
49
+ * `definitions` is memoized on array identity, so a caller that rebuilds the
50
+ * array per call (`createCompositionValidator(packs.flatMap(…))`) resolves a
51
+ * fresh discriminated union each time. Hold the array `composePacks` returns
52
+ * and reuse it across the validator, the parser, and the authoring context.
53
+ */
54
+ const createCompositionValidator = (definitions, options = {}) => {
55
+ const schema = (0, composition_schema_1.getCompositionSchemaForDefinitions)(definitions);
56
+ const walk = (0, body_node_base_1.createChildNodeWalker)(definitions);
57
+ const formatIssues = (0, node_issues_1.createNodeIssueFormatter)(definitions);
58
+ return (composition) => {
59
+ const checked = (0, input_budget_1.checkInputBudget)(composition, options.inputBudget);
60
+ if (!checked.valid) {
61
+ return {
62
+ valid: false,
63
+ errors: [checked.error],
64
+ warnings: [],
65
+ composition: undefined,
66
+ };
67
+ }
68
+ const plain = checked.value;
69
+ const result = schema.safeParse(plain, { reportInput: true });
70
+ if (result.success) {
71
+ const { body } = plain;
72
+ const idErrors = collectDuplicateNodeIdErrors(body, walk);
73
+ const warnings = [
74
+ ...collectEmptySurfaceWarnings(body, walk),
75
+ ...(options.sizesFromNodeHeights
76
+ ? collectMissingSvgHeightWarnings(body, definitions, walk)
77
+ : []),
78
+ ];
79
+ return {
80
+ valid: idErrors.length === 0,
81
+ errors: idErrors,
82
+ warnings,
83
+ composition: plain,
84
+ };
85
+ }
86
+ return {
87
+ valid: false,
88
+ errors: formatIssues(bodyRoots(plain), result.error.issues),
89
+ warnings: [],
90
+ composition: plain,
91
+ };
92
+ };
93
+ };
94
+ exports.createCompositionValidator = createCompositionValidator;
95
+ /**
96
+ * Builds the untrusted-input parser: {@link checkInputBudget}, then the schema only on its copy, reported rather than thrown.
97
+ *
98
+ * Deliberately narrower than {@link createCompositionValidator}. This answers
99
+ * "is this a `Composition`", not "is this a good one" — it does not run the
100
+ * duplicate-id pass or produce warnings, so a composition with two nodes
101
+ * sharing an `id` parses as valid. Id uniqueness is a `validate` guarantee, so
102
+ * a caller that wants the semantic checks runs `validate` on the result.
103
+ *
104
+ * Shares {@link createCompositionValidator}'s memoization identity requirement.
105
+ */
106
+ const createCompositionParser = (definitions, { inputBudget } = {}) => {
107
+ const schema = (0, composition_schema_1.getCompositionSchemaForDefinitions)(definitions);
108
+ const formatIssues = (0, node_issues_1.createNodeIssueFormatter)(definitions);
109
+ return (value) => {
110
+ const checked = (0, input_budget_1.checkInputBudget)(value, inputBudget);
111
+ if (!checked.valid) {
112
+ return { valid: false, errors: [checked.error] };
113
+ }
114
+ const result = schema.safeParse(checked.value, { reportInput: true });
115
+ if (result.success) {
116
+ return {
117
+ valid: true,
118
+ errors: [],
119
+ composition: result.data,
120
+ };
121
+ }
122
+ return {
123
+ valid: false,
124
+ errors: formatIssues(bodyRoots(checked.value), result.error.issues),
125
+ };
126
+ };
127
+ };
128
+ exports.createCompositionParser = createCompositionParser;
129
+ /** Warns once per surface that the whole body renders nothing on. */
130
+ const collectEmptySurfaceWarnings = (body, walk) => body_node_base_1.BODY_NODE_SURFACES.filter((surface) => !body.some((node) => (0, body_node_base_1.rendersOnSurface)(node, surface, walk))).map((surface) => ({
131
+ surface,
132
+ message: `composition renders no nodes on surface "${surface}"`,
133
+ }));
134
+ /**
135
+ * Warns for each node that renders to `svg` but declares no `svgHeight`.
136
+ *
137
+ * `metrics.svgHeight` is optional, so `dispatcher.estimateSvgHeight` returns
138
+ * `0` for such a node and a frame that sums node heights sizes short.
139
+ *
140
+ * Whether a runtime consults the metric at all is the caller's to decide; see
141
+ * {@link CompositionValidatorOptions.sizesFromNodeHeights}. A fixed-size frame
142
+ * never does, and warning about a value nothing reads is how a warning channel
143
+ * gets ignored.
144
+ */
145
+ const collectMissingSvgHeightWarnings = (body, definitions, walk) => {
146
+ const unmeasured = new Set(definitions
147
+ .filter((definition) => !definition.metrics?.svgHeight)
148
+ .map((definition) => definition.type));
149
+ if (unmeasured.size === 0) {
150
+ return [];
151
+ }
152
+ const warnings = [];
153
+ const visit = (node, path) => {
154
+ if (!node || typeof node !== 'object' || !(0, body_node_base_1.isVisibleOnSurface)(node, 'svg')) {
155
+ return;
156
+ }
157
+ const { type } = node;
158
+ if (typeof type === 'string' && unmeasured.has(type)) {
159
+ warnings.push({
160
+ surface: 'svg',
161
+ path,
162
+ message: `${path} type ${(0, one_line_1.quoteText)(type)} declares no svgHeight metric and will be measured as 0, sizing the frame short`,
163
+ });
164
+ }
165
+ walk(node).forEach(({ node: child, path: field }) => {
166
+ visit(child, (0, body_node_base_1.childNodePath)(path, field));
167
+ });
168
+ };
169
+ body.forEach((node, index) => visit(node, `body[${index}]`));
170
+ return warnings;
171
+ };
172
+ /**
173
+ * Errors for each node whose `id` repeats one already seen, naming the first
174
+ * use.
175
+ *
176
+ * Errors rather than warnings, because ids are what a host addresses a node by.
177
+ * Run by `validate` and deliberately not by `parse`; see
178
+ * {@link createCompositionParser}.
179
+ */
180
+ const collectDuplicateNodeIdErrors = (body, walk) => {
181
+ const errors = [];
182
+ const seen = new Map();
183
+ const visit = (node, path) => {
184
+ if (!node || typeof node !== 'object') {
185
+ return;
186
+ }
187
+ const { id, type } = node;
188
+ if (typeof id === 'string') {
189
+ const first = seen.get(id);
190
+ if (first) {
191
+ errors.push({
192
+ path: `${path}.id`,
193
+ message: `duplicates id ${(0, one_line_1.quoteText)(id)} first used at ${first}`,
194
+ ...(typeof type === 'string' ? { nodeType: type } : {}),
195
+ });
196
+ }
197
+ else {
198
+ seen.set(id, path);
199
+ }
200
+ }
201
+ walk(node).forEach(({ node: child, path: field }) => {
202
+ visit(child, (0, body_node_base_1.childNodePath)(path, field));
203
+ });
204
+ };
205
+ body.forEach((node, index) => visit(node, `body[${index}]`));
206
+ return errors;
207
+ };
208
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/validate/validation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,kEAOuC;AAGvC,sDAAoD;AACpD,sEAGyC;AAuEhC,2GAzEP,6CAA0B,OAyEO;AApEnC,6DAA0E;AAC1E,iDAIwB;AACxB,+CAAyE;AAsCzE,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAc5E,8EAA8E;AACvE,MAAM,kBAAkB,GAAG,CAChC,MAAwB,EACxB,OAAoB,EACC,EAAE,CACvB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;AAJtD,QAAA,kBAAkB,sBAIoC;AAOnE,0LAA0L;AACnL,MAAM,qBAAqB,GAAG,CACnC,MAAwB,EACxB,IAA0B,EACpB,EAAE;IACR,IACE,CAAC,MAAM,CAAC,KAAK;QACb,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,6BAAc,CAAC,CAAC,EACxD,CAAC;QACD,MAAM,IAAI,6CAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,qBAAqB,yBAUhC;AAEF,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,CAAC,KAAK,EAAE,IAAA,8BAAa,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nimport {\n BODY_NODE_SURFACES,\n childNodePath,\n createChildNodeWalker,\n isVisibleOnSurface,\n rendersOnSurface,\n type SurfaceName,\n} from '../composition/body_node_base';\nimport type { Composition } from '../composition/composition';\nimport type { PrimitiveNode } from '../composition/node';\nimport { quoteText } from '../composition/one_line';\nimport {\n CompositionValidationError,\n type ValidationError,\n} from '../composition/validation_error';\nimport type { AnyPrimitiveDefinition } from '../define/primitive_module';\n\nimport { getCompositionSchemaForDefinitions } from './composition_schema';\nimport {\n checkInputBudget,\n type InputBudget,\n isInputRefusal,\n} from './input_budget';\nimport { createNodeIssueFormatter, type IssueRoot } from './node_issues';\n\n/**\n * A non-fatal validation finding, scoped to the surface it concerns.\n *\n * Warnings carry `surface` because every one of them is a statement about one\n * render target — a composition that draws nothing on `slack` is not news to a\n * caller rendering HTML. Without the scope a host receives every surface's\n * findings on every call and learns to ignore the channel.\n * {@link warningsForSurface} is the filter.\n */\nexport interface ValidationWarning {\n /** The render target this finding concerns, never the composition as a whole. */\n surface: SurfaceName;\n /**\n * Path of the offending node within the composition, absent for\n * whole-composition findings.\n */\n path?: string;\n /** Safe to show a user, and phrased for whoever can act on it. */\n message: string;\n}\n\n/**\n * The outcome of `validate`: errors are fatal, warnings are advisory.\n *\n * `valid` tracks `errors` only — a composition can be valid and still carry\n * warnings, which is the normal case for a surface gap.\n */\nexport interface ValidationResult {\n /** True when `errors` is empty, regardless of `warnings`. */\n valid: boolean;\n /** Fatal findings. Empty when `valid`. */\n errors: ValidationError[];\n /** Advisory findings, empty when there are none. */\n warnings: ValidationWarning[];\n}\n\nconst checkedComposition = Symbol.for('elastic.isomer.checked_composition');\n\n/** The copy {@link createCompositionValidator} checked, which a validating render draws in place of the caller's value. The brand is type-only. */\nexport type CheckedComposition<TNode extends PrimitiveNode = PrimitiveNode> =\n Composition<TNode> & { readonly [checkedComposition]: true };\n\n/** A {@link ValidationResult} with the composition it describes. */\nexport interface CheckedValidationResult<\n TNode extends PrimitiveNode = PrimitiveNode,\n> extends ValidationResult {\n /** Undefined only when {@link checkInputBudget} refused the input. */\n composition: CheckedComposition<TNode> | undefined;\n}\n\n/** Narrows a result's warnings to the surface a caller is about to render. */\nexport const warningsForSurface = (\n result: ValidationResult,\n surface: SurfaceName\n): ValidationWarning[] =>\n result.warnings.filter((warning) => warning.surface === surface);\n\n/** Whether a render reports validation findings or raises on them. */\nexport type ValidationErrorMode = 'collect' | 'throw';\n\nexport { CompositionValidationError };\n\n/** Raises {@link CompositionValidationError} when `mode` is `throw` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input, which nothing can render. */\nexport const enforceValidationMode = (\n result: ValidationResult,\n mode?: ValidationErrorMode\n): void => {\n if (\n !result.valid &&\n (mode === 'throw' || result.errors.some(isInputRefusal))\n ) {\n throw new CompositionValidationError(result.errors);\n }\n};\n\n/** The composition `result` checked, which is what a render draws. Throws {@link CompositionValidationError} when `mode` is `'throw'` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input. */\nexport const compositionToRender = <TNode extends PrimitiveNode>(\n result: CheckedValidationResult<TNode>,\n mode?: ValidationErrorMode\n): CheckedComposition<TNode> => {\n enforceValidationMode(result, mode);\n const { composition } = result;\n if (composition === undefined) {\n throw new CompositionValidationError(result.errors);\n }\n return composition;\n};\n\n/** Runtime facts the semantic passes need beyond the primitive inventory. */\nexport interface CompositionValidatorOptions {\n /**\n * Whether any frame the runtime can draw with sizes itself from node heights,\n * which is what makes a missing `metrics.svgHeight` matter.\n *\n * A runtime-wide question rather than a per-node one, because a frame is a\n * runtime input: any node can be drawn under any frame, so the metric is\n * load-bearing as soon as one frame consults it. Defaults to `false`, so a\n * runtime with no frame at all reports nothing about a value nothing reads.\n */\n sizesFromNodeHeights?: boolean;\n /** Limits checked before the schema runs; see {@link checkInputBudget}. */\n inputBudget?: InputBudget;\n}\n\n/** The body's nodes, as {@link IssueRoot}s for a node issue formatter. */\nconst bodyRoots = (value: unknown): IssueRoot[] => {\n const { body } = (value ?? {}) as { body?: unknown };\n return Array.isArray(body)\n ? body.map((node, index) => [node, `body[${index}]`] as const)\n : [];\n};\n\n/**\n * Builds the trusted-input validator: {@link checkInputBudget}, then the schema and the semantic passes on its copy, which the result carries.\n *\n * `definitions` is memoized on array identity, so a caller that rebuilds the\n * array per call (`createCompositionValidator(packs.flatMap(…))`) resolves a\n * fresh discriminated union each time. Hold the array `composePacks` returns\n * and reuse it across the validator, the parser, and the authoring context.\n */\nexport const createCompositionValidator = <\n TNode extends PrimitiveNode = PrimitiveNode,\n>(\n definitions: readonly AnyPrimitiveDefinition[],\n options: CompositionValidatorOptions = {}\n): ((composition: Composition<TNode>) => CheckedValidationResult<TNode>) => {\n const schema = getCompositionSchemaForDefinitions(definitions);\n const walk = createChildNodeWalker(definitions);\n const formatIssues = createNodeIssueFormatter(definitions);\n return (composition) => {\n const checked = checkInputBudget(composition, options.inputBudget);\n if (!checked.valid) {\n return {\n valid: false,\n errors: [checked.error],\n warnings: [],\n composition: undefined,\n };\n }\n const plain = checked.value as CheckedComposition<TNode>;\n const result = schema.safeParse(plain, { reportInput: true });\n if (result.success) {\n const { body } = plain;\n const idErrors = collectDuplicateNodeIdErrors(body, walk);\n const warnings = [\n ...collectEmptySurfaceWarnings(body, walk),\n ...(options.sizesFromNodeHeights\n ? collectMissingSvgHeightWarnings(body, definitions, walk)\n : []),\n ];\n return {\n valid: idErrors.length === 0,\n errors: idErrors,\n warnings,\n composition: plain,\n };\n }\n return {\n valid: false,\n errors: formatIssues(bodyRoots(plain), result.error.issues),\n warnings: [],\n composition: plain,\n };\n };\n};\n\n/** The outcome of `parse`. */\nexport interface ParsedComposition {\n /** True when the value matched the schema. Says nothing about id uniqueness. */\n valid: boolean;\n /** Schema failures. Empty when `valid`. */\n errors: ValidationError[];\n /** The parsed document, present only when `valid`. */\n composition?: Composition;\n}\n\n/**\n * Builds the untrusted-input parser: {@link checkInputBudget}, then the schema only on its copy, reported rather than thrown.\n *\n * Deliberately narrower than {@link createCompositionValidator}. This answers\n * \"is this a `Composition`\", not \"is this a good one\" — it does not run the\n * duplicate-id pass or produce warnings, so a composition with two nodes\n * sharing an `id` parses as valid. Id uniqueness is a `validate` guarantee, so\n * a caller that wants the semantic checks runs `validate` on the result.\n *\n * Shares {@link createCompositionValidator}'s memoization identity requirement.\n */\nexport const createCompositionParser = (\n definitions: readonly AnyPrimitiveDefinition[],\n { inputBudget }: Pick<CompositionValidatorOptions, 'inputBudget'> = {}\n): ((value: unknown) => ParsedComposition) => {\n const schema = getCompositionSchemaForDefinitions(definitions);\n const formatIssues = createNodeIssueFormatter(definitions);\n return (value) => {\n const checked = checkInputBudget(value, inputBudget);\n if (!checked.valid) {\n return { valid: false, errors: [checked.error] };\n }\n const result = schema.safeParse(checked.value, { reportInput: true });\n if (result.success) {\n return {\n valid: true,\n errors: [],\n composition: result.data as unknown as Composition,\n };\n }\n return {\n valid: false,\n errors: formatIssues(bodyRoots(checked.value), result.error.issues),\n };\n };\n};\n\n/** Warns once per surface that the whole body renders nothing on. */\nconst collectEmptySurfaceWarnings = (\n body: readonly unknown[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationWarning[] =>\n BODY_NODE_SURFACES.filter(\n (surface) => !body.some((node) => rendersOnSurface(node, surface, walk))\n ).map((surface) => ({\n surface,\n message: `composition renders no nodes on surface \"${surface}\"`,\n }));\n\n/**\n * Warns for each node that renders to `svg` but declares no `svgHeight`.\n *\n * `metrics.svgHeight` is optional, so `dispatcher.estimateSvgHeight` returns\n * `0` for such a node and a frame that sums node heights sizes short.\n *\n * Whether a runtime consults the metric at all is the caller's to decide; see\n * {@link CompositionValidatorOptions.sizesFromNodeHeights}. A fixed-size frame\n * never does, and warning about a value nothing reads is how a warning channel\n * gets ignored.\n */\nconst collectMissingSvgHeightWarnings = (\n body: readonly unknown[],\n definitions: readonly AnyPrimitiveDefinition[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationWarning[] => {\n const unmeasured = new Set(\n definitions\n .filter((definition) => !definition.metrics?.svgHeight)\n .map((definition) => definition.type)\n );\n if (unmeasured.size === 0) {\n return [];\n }\n const warnings: ValidationWarning[] = [];\n const visit = (node: unknown, path: string): void => {\n if (!node || typeof node !== 'object' || !isVisibleOnSurface(node, 'svg')) {\n return;\n }\n const { type } = node as { type?: unknown };\n if (typeof type === 'string' && unmeasured.has(type)) {\n warnings.push({\n surface: 'svg',\n path,\n message: `${path} type ${quoteText(type)} declares no svgHeight metric and will be measured as 0, sizing the frame short`,\n });\n }\n walk(node).forEach(({ node: child, path: field }) => {\n visit(child, childNodePath(path, field));\n });\n };\n body.forEach((node, index) => visit(node, `body[${index}]`));\n return warnings;\n};\n\n/**\n * Errors for each node whose `id` repeats one already seen, naming the first\n * use.\n *\n * Errors rather than warnings, because ids are what a host addresses a node by.\n * Run by `validate` and deliberately not by `parse`; see\n * {@link createCompositionParser}.\n */\nconst collectDuplicateNodeIdErrors = (\n body: readonly unknown[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationError[] => {\n const errors: ValidationError[] = [];\n const seen = new Map<string, string>();\n const visit = (node: unknown, path: string): void => {\n if (!node || typeof node !== 'object') {\n return;\n }\n const { id, type } = node as { id?: unknown; type?: unknown };\n if (typeof id === 'string') {\n const first = seen.get(id);\n if (first) {\n errors.push({\n path: `${path}.id`,\n message: `duplicates id ${quoteText(id)} first used at ${first}`,\n ...(typeof type === 'string' ? { nodeType: type } : {}),\n });\n } else {\n seen.set(id, path);\n }\n }\n walk(node).forEach(({ node: child, path: field }) => {\n visit(child, childNodePath(path, field));\n });\n };\n body.forEach((node, index) => visit(node, `body[${index}]`));\n return errors;\n};\n"]}
@@ -0,0 +1,53 @@
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.displayValueSchema = exports.structuredValueSchema = exports.renderThemeSchema = exports.namedColorSchema = void 0;
10
+ // Zod for the value shapes the sdk already owns types for: `NamedColor`, and
11
+ // the structured display value.
12
+ //
13
+ // Only the shapes the sdk owns belong here. That is what lets any vocabulary
14
+ // package validate a color or a display value without depending on another
15
+ // pack's schemas.
16
+ const zod_1 = require("zod");
17
+ const named_color_1 = require("../composition/named_color");
18
+ const structured_value_1 = require("../composition/structured_value");
19
+ const zod_format_1 = require("../define/zod_format");
20
+ const zod_helpers_1 = require("../define/zod_helpers");
21
+ // An enum whose own message names the accepted values, as validation reports it.
22
+ const closedEnum = (values) => zod_1.z.enum(values, { error: () => (0, zod_format_1.oneOf)(values) });
23
+ /** Derived from {@link ALL_NAMED_COLORS} rather than restating the literals. */
24
+ exports.namedColorSchema = closedEnum(named_color_1.ALL_NAMED_COLORS);
25
+ /** `RenderTheme`: the light/dark preference a caller asks for. */
26
+ exports.renderThemeSchema = closedEnum(['auto', 'light', 'dark']);
27
+ /**
28
+ * The raw quantity plus a format hint, formatted once in a primitive's model so
29
+ * every surface renders the same string. See `StructuredValue`.
30
+ */
31
+ exports.structuredValueSchema = zod_1.z.object({
32
+ raw: zod_1.z.union([zod_1.z.number(), (0, zod_helpers_1.requiredString)()], {
33
+ error: () => 'must be a finite number or a non-empty string',
34
+ }),
35
+ format: closedEnum(structured_value_1.STRUCTURED_VALUE_FORMATS).optional(),
36
+ precision: zod_1.z
37
+ .number({ error: () => 'must be an integer between 0 and 6' })
38
+ .int({ error: 'must be an integer between 0 and 6' })
39
+ .min(0, { error: 'must be an integer between 0 and 6' })
40
+ .max(6, { error: 'must be an integer between 0 and 6' })
41
+ .optional(),
42
+ currency: zod_1.z
43
+ .string({ error: () => 'must be a three-letter currency code' })
44
+ .regex(/^[A-Za-z]{3}$/, {
45
+ error: 'must be a three-letter currency code',
46
+ })
47
+ .optional(),
48
+ });
49
+ /** Value-bearing fields accept preformatted prose or a structured value. */
50
+ exports.displayValueSchema = zod_1.z.union([(0, zod_helpers_1.requiredString)(), exports.structuredValueSchema], {
51
+ error: () => 'must be a non-empty string or a structured value ({ raw, format?, precision?, currency? })',
52
+ });
53
+ //# sourceMappingURL=value_schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value_schemas.js","sourceRoot":"","sources":["../../../src/validate/value_schemas.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6EAA6E;AAC7E,gCAAgC;AAChC,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,kBAAkB;AAElB,6BAAwB;AAExB,4DAA+E;AAC/E,sEAA2E;AAC3E,qDAA6C;AAC7C,uDAAuD;AAEvD,iFAAiF;AACjF,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,EAAE,CAAC,OAAC,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAK,EAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEpD,gFAAgF;AACnE,QAAA,gBAAgB,GAAG,UAAU,CACxC,8BAAiD,CAClD,CAAC;AAEF,kEAAkE;AACrD,QAAA,iBAAiB,GAAG,UAAU,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvE;;;GAGG;AACU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,IAAA,4BAAc,GAAE,CAAC,EAAE;QAC3C,KAAK,EAAE,GAAG,EAAE,CAAC,+CAA+C;KAC7D,CAAC;IACF,MAAM,EAAE,UAAU,CAAC,2CAAwB,CAAC,CAAC,QAAQ,EAAE;IACvD,SAAS,EAAE,OAAC;SACT,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,oCAAoC,EAAE,CAAC;SAC7D,GAAG,CAAC,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC;SACpD,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC;SACvD,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC;SACvD,QAAQ,EAAE;IACb,QAAQ,EAAE,OAAC;SACR,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,sCAAsC,EAAE,CAAC;SAC/D,KAAK,CAAC,eAAe,EAAE;QACtB,KAAK,EAAE,sCAAsC;KAC9C,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC;AAEH,4EAA4E;AAC/D,QAAA,kBAAkB,GAAG,OAAC,CAAC,KAAK,CACvC,CAAC,IAAA,4BAAc,GAAE,EAAE,6BAAqB,CAAC,EACzC;IACE,KAAK,EAAE,GAAG,EAAE,CACV,4FAA4F;CAC/F,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// Zod for the value shapes the sdk already owns types for: `NamedColor`, and\n// the structured display value.\n//\n// Only the shapes the sdk owns belong here. That is what lets any vocabulary\n// package validate a color or a display value without depending on another\n// pack's schemas.\n\nimport { z } from 'zod';\n\nimport { ALL_NAMED_COLORS, type NamedColor } from '../composition/named_color';\nimport { STRUCTURED_VALUE_FORMATS } from '../composition/structured_value';\nimport { oneOf } from '../define/zod_format';\nimport { requiredString } from '../define/zod_helpers';\n\n// An enum whose own message names the accepted values, as validation reports it.\nconst closedEnum = <const T extends readonly [string, ...string[]]>(\n values: T\n) => z.enum(values, { error: () => oneOf(values) });\n\n/** Derived from {@link ALL_NAMED_COLORS} rather than restating the literals. */\nexport const namedColorSchema = closedEnum(\n ALL_NAMED_COLORS as [NamedColor, ...NamedColor[]]\n);\n\n/** `RenderTheme`: the light/dark preference a caller asks for. */\nexport const renderThemeSchema = closedEnum(['auto', 'light', 'dark']);\n\n/**\n * The raw quantity plus a format hint, formatted once in a primitive's model so\n * every surface renders the same string. See `StructuredValue`.\n */\nexport const structuredValueSchema = z.object({\n raw: z.union([z.number(), requiredString()], {\n error: () => 'must be a finite number or a non-empty string',\n }),\n format: closedEnum(STRUCTURED_VALUE_FORMATS).optional(),\n precision: z\n .number({ error: () => 'must be an integer between 0 and 6' })\n .int({ error: 'must be an integer between 0 and 6' })\n .min(0, { error: 'must be an integer between 0 and 6' })\n .max(6, { error: 'must be an integer between 0 and 6' })\n .optional(),\n currency: z\n .string({ error: () => 'must be a three-letter currency code' })\n .regex(/^[A-Za-z]{3}$/, {\n error: 'must be a three-letter currency code',\n })\n .optional(),\n});\n\n/** Value-bearing fields accept preformatted prose or a structured value. */\nexport const displayValueSchema = z.union(\n [requiredString(), structuredValueSchema],\n {\n error: () =>\n 'must be a non-empty string or a structured value ({ raw, format?, precision?, currency? })',\n }\n);\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A named event a node can raise, for the host to interpret.
3
+ *
4
+ * The SDK carries the reference and never dispatches it: side effects are the
5
+ * host's, so `name` means whatever its handler decides.
6
+ */
7
+ export interface ActionEventRef {
8
+ /** Agreed between the composition's author and the host's handler. */
9
+ name: string;
10
+ /** Payload passed through untouched, so it must be JSON-serializable. */
11
+ context?: Record<string, unknown>;
12
+ }
13
+ //# sourceMappingURL=action_event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action_event.d.ts","sourceRoot":"","sources":["../../src/composition/action_event.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC"}
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=action_event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action_event.js","sourceRoot":"","sources":["../../src/composition/action_event.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","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 * A named event a node can raise, for the host to interpret.\n *\n * The SDK carries the reference and never dispatches it: side effects are the\n * host's, so `name` means whatever its handler decides.\n */\nexport interface ActionEventRef {\n /** Agreed between the composition's author and the host's handler. */\n name: string;\n /** Payload passed through untouched, so it must be JSON-serializable. */\n context?: Record<string, unknown>;\n}\n"]}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The five surfaces a node renders on or is hidden from.
3
+ *
4
+ * Spelled out rather than derived as `keyof SurfaceMap<…>`: the keys never vary
5
+ * with the pack types, and TypeScript can fail to prove a `keyof` over one
6
+ * instantiation transfers to another, silently widening to `any`.
7
+ */
8
+ export type SurfaceName = 'react' | 'svg' | 'text' | 'markdown' | 'slack';
9
+ /** Every {@link SurfaceName}, for callers that iterate them. */
10
+ export declare const BODY_NODE_SURFACES: readonly SurfaceName[];
11
+ /** The two fields every primitive node carries, whatever its pack. */
12
+ export interface BodyNodeBase {
13
+ /** Unique within a composition, which `validate` enforces and `parse` does not. */
14
+ id?: string;
15
+ /** Surfaces this node appears on. Absent means every surface. */
16
+ surfaces?: SurfaceName[];
17
+ }
18
+ /**
19
+ * A child node together with the field path locating it inside its parent, so
20
+ * an error path can name the field a child actually lives under. A container
21
+ * that returned bare nodes would leave every caller guessing the field name.
22
+ */
23
+ export interface ChildNodeRef {
24
+ /** Erased: one walker spans every pack's node types, so it can name none of them. */
25
+ node: unknown;
26
+ /** Relative to the parent, e.g. `items[0].node`, `items[2].description`. */
27
+ path: string;
28
+ }
29
+ /**
30
+ * Walks nested nodes and, for a hybrid container, reports whether the parent
31
+ * still produces output of its own. A non-empty `children` result is the
32
+ * complete source of rendered content unless
33
+ * {@link ChildNodeWalker.hasOwnContent} is true for that node.
34
+ */
35
+ export type ChildNodeWalker = ((node: unknown) => ChildNodeRef[]) & {
36
+ hasOwnContent?(node: unknown): boolean;
37
+ };
38
+ /**
39
+ * Builds the {@link ChildNodeWalker} for one composition's inventory.
40
+ *
41
+ * Pass every pack's definitions: a walker missing one cannot see children of a
42
+ * container that pack defines, and a tree walk would stop at its boundary.
43
+ */
44
+ export declare const createChildNodeWalker: (definitions: readonly {
45
+ type: string;
46
+ children?: unknown;
47
+ hasOwnContent?: unknown;
48
+ }[]) => ChildNodeWalker;
49
+ /** Joins a parent path with a {@link ChildNodeRef.path} fragment. */
50
+ export declare const childNodePath: (parent: string, child: string) => string;
51
+ /**
52
+ * Whether any node visible on `surface` matches, descending through container
53
+ * children via `walk`. A node (or a container ancestor) hidden from `surface`
54
+ * is skipped along with its children.
55
+ *
56
+ * `walk` must span every pack in the composition: a walker built from one
57
+ * pack's definitions cannot see children of a container defined in another.
58
+ */
59
+ export declare const someBodyNode: (nodes: readonly unknown[], surface: SurfaceName, predicate: (node: unknown) => boolean, walk: ChildNodeWalker) => boolean;
60
+ /** Whether `node`'s own `surfaces` hint admits `surface`, ignoring its children. */
61
+ export declare const isVisibleOnSurface: (node: unknown, surface: SurfaceName) => boolean;
62
+ /**
63
+ * Whether `node` puts anything on `surface` — itself or through a descendant.
64
+ *
65
+ * Stronger than {@link isVisibleOnSurface}: a container every one of whose
66
+ * children is hidden renders nothing, even though its own hint allows the
67
+ * surface. A hybrid container that also owns string fields declares
68
+ * {@link ChildNodeWalker.hasOwnContent} and keeps rendering regardless.
69
+ */
70
+ export declare const rendersOnSurface: (node: unknown, surface: SurfaceName, walk: ChildNodeWalker) => boolean;
71
+ //# sourceMappingURL=body_node_base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"body_node_base.d.ts","sourceRoot":"","sources":["../../src/composition/body_node_base.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;AAE1E,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,EAAE,SAAS,WAAW,EAMpD,CAAC;AAEF,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,qFAAqF;IACrF,IAAI,EAAE,OAAO,CAAC;IACd,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,KAAK,YAAY,EAAE,CAAC,GAAG;IAClE,aAAa,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CACxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,SAAS;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,EAAE,KACF,eAyCF,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,aAAa,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MACxC,CAAC;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,SAAS,OAAO,EAAE,EACzB,SAAS,WAAW,EACpB,WAAW,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EACrC,MAAM,eAAe,KACpB,OAcC,CAAC;AAEL,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,GAC7B,MAAM,OAAO,EACb,SAAS,WAAW,KACnB,OAMF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,OAAO,EACb,SAAS,WAAW,EACpB,MAAM,eAAe,KACpB,OAWF,CAAC"}
@@ -0,0 +1,97 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ /** Every {@link SurfaceName}, for callers that iterate them. */
8
+ export const BODY_NODE_SURFACES = [
9
+ 'react',
10
+ 'svg',
11
+ 'text',
12
+ 'markdown',
13
+ 'slack',
14
+ ];
15
+ /**
16
+ * Builds the {@link ChildNodeWalker} for one composition's inventory.
17
+ *
18
+ * Pass every pack's definitions: a walker missing one cannot see children of a
19
+ * container that pack defines, and a tree walk would stop at its boundary.
20
+ */
21
+ export const createChildNodeWalker = (definitions) => {
22
+ const childrenByType = new Map();
23
+ const ownContentByType = new Map();
24
+ for (const definition of definitions) {
25
+ if (typeof definition.children === 'function') {
26
+ childrenByType.set(definition.type, definition.children);
27
+ }
28
+ if (typeof definition.hasOwnContent === 'function') {
29
+ ownContentByType.set(definition.type, definition.hasOwnContent);
30
+ }
31
+ }
32
+ const walk = ((node) => {
33
+ if (!node || typeof node !== 'object') {
34
+ return [];
35
+ }
36
+ const { type } = node;
37
+ if (typeof type !== 'string') {
38
+ return [];
39
+ }
40
+ return [...(childrenByType.get(type)?.(node) ?? [])];
41
+ });
42
+ walk.hasOwnContent = (node) => {
43
+ if (!node || typeof node !== 'object') {
44
+ return false;
45
+ }
46
+ const { type } = node;
47
+ if (typeof type !== 'string') {
48
+ return false;
49
+ }
50
+ return ownContentByType.get(type)?.(node) ?? false;
51
+ };
52
+ return walk;
53
+ };
54
+ /** Joins a parent path with a {@link ChildNodeRef.path} fragment. */
55
+ export const childNodePath = (parent, child) => `${parent}.${child}`;
56
+ /**
57
+ * Whether any node visible on `surface` matches, descending through container
58
+ * children via `walk`. A node (or a container ancestor) hidden from `surface`
59
+ * is skipped along with its children.
60
+ *
61
+ * `walk` must span every pack in the composition: a walker built from one
62
+ * pack's definitions cannot see children of a container defined in another.
63
+ */
64
+ export const someBodyNode = (nodes, surface, predicate, walk) => nodes.some((node) => {
65
+ if (!isVisibleOnSurface(node, surface)) {
66
+ return false;
67
+ }
68
+ return (predicate(node) ||
69
+ someBodyNode(walk(node).map((child) => child.node), surface, predicate, walk));
70
+ });
71
+ /** Whether `node`'s own `surfaces` hint admits `surface`, ignoring its children. */
72
+ export const isVisibleOnSurface = (node, surface) => {
73
+ if (!node || typeof node !== 'object') {
74
+ return false;
75
+ }
76
+ const { surfaces } = node;
77
+ return !Array.isArray(surfaces) || surfaces.includes(surface);
78
+ };
79
+ /**
80
+ * Whether `node` puts anything on `surface` — itself or through a descendant.
81
+ *
82
+ * Stronger than {@link isVisibleOnSurface}: a container every one of whose
83
+ * children is hidden renders nothing, even though its own hint allows the
84
+ * surface. A hybrid container that also owns string fields declares
85
+ * {@link ChildNodeWalker.hasOwnContent} and keeps rendering regardless.
86
+ */
87
+ export const rendersOnSurface = (node, surface, walk) => {
88
+ if (!isVisibleOnSurface(node, surface)) {
89
+ return false;
90
+ }
91
+ const children = walk(node);
92
+ if (children.length === 0 || walk.hasOwnContent?.(node)) {
93
+ return true;
94
+ }
95
+ return children.some(({ node: child }) => rendersOnSurface(child, surface, walk));
96
+ };
97
+ //# sourceMappingURL=body_node_base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"body_node_base.js","sourceRoot":"","sources":["../../src/composition/body_node_base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACxD,OAAO;IACP,KAAK;IACL,MAAM;IACN,UAAU;IACV,OAAO;CACR,CAAC;AAgCF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,WAIG,EACc,EAAE;IACnB,MAAM,cAAc,GAAG,IAAI,GAAG,EAG3B,CAAC;IACJ,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAsC,CAAC;IACvE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;YAC9C,cAAc,CAAC,GAAG,CAChB,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,QAAsD,CAClE,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,UAAU,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;YACnD,gBAAgB,CAAC,GAAG,CAClB,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,aAA2C,CACvD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,CAAC,IAAa,EAAE,EAAE;QAC9B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,IAA0B,CAAC;QAC5C,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,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,CAAC,MAAM,kBAAkB,GAAG,CAChC,IAAa,EACb,OAAoB,EACX,EAAE;IACX,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAA8B,CAAC;IACpD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAa,EACb,OAAoB,EACpB,IAAqB,EACZ,EAAE;IACX,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CACvC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CACvC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n/**\n * The five surfaces a node renders on or is hidden from.\n *\n * Spelled out rather than derived as `keyof SurfaceMap<…>`: the keys never vary\n * with the pack types, and TypeScript can fail to prove a `keyof` over one\n * instantiation transfers to another, silently widening to `any`.\n */\nexport type SurfaceName = 'react' | 'svg' | 'text' | 'markdown' | 'slack';\n\n/** Every {@link SurfaceName}, for callers that iterate them. */\nexport const BODY_NODE_SURFACES: readonly SurfaceName[] = [\n 'react',\n 'svg',\n 'text',\n 'markdown',\n 'slack',\n];\n\n/** The two fields every primitive node carries, whatever its pack. */\nexport interface BodyNodeBase {\n /** Unique within a composition, which `validate` enforces and `parse` does not. */\n id?: string;\n /** Surfaces this node appears on. Absent means every surface. */\n surfaces?: SurfaceName[];\n}\n\n/**\n * A child node together with the field path locating it inside its parent, so\n * an error path can name the field a child actually lives under. A container\n * that returned bare nodes would leave every caller guessing the field name.\n */\nexport interface ChildNodeRef {\n /** Erased: one walker spans every pack's node types, so it can name none of them. */\n node: unknown;\n /** Relative to the parent, e.g. `items[0].node`, `items[2].description`. */\n path: string;\n}\n\n/**\n * Walks nested nodes and, for a hybrid container, reports whether the parent\n * still produces output of its own. A non-empty `children` result is the\n * complete source of rendered content unless\n * {@link ChildNodeWalker.hasOwnContent} is true for that node.\n */\nexport type ChildNodeWalker = ((node: unknown) => ChildNodeRef[]) & {\n hasOwnContent?(node: unknown): boolean;\n};\n\n/**\n * Builds the {@link ChildNodeWalker} for one composition's inventory.\n *\n * Pass every pack's definitions: a walker missing one cannot see children of a\n * container that pack defines, and a tree walk would stop at its boundary.\n */\nexport const createChildNodeWalker = (\n definitions: readonly {\n type: string;\n children?: unknown;\n hasOwnContent?: unknown;\n }[]\n): ChildNodeWalker => {\n const childrenByType = new Map<\n string,\n (node: unknown) => readonly ChildNodeRef[]\n >();\n const ownContentByType = new Map<string, (node: unknown) => boolean>();\n for (const definition of definitions) {\n if (typeof definition.children === 'function') {\n childrenByType.set(\n definition.type,\n definition.children as (node: unknown) => readonly ChildNodeRef[]\n );\n }\n if (typeof definition.hasOwnContent === 'function') {\n ownContentByType.set(\n definition.type,\n definition.hasOwnContent as (node: unknown) => boolean\n );\n }\n }\n const walk = ((node: unknown) => {\n if (!node || typeof node !== 'object') {\n return [];\n }\n const { type } = node as { type?: unknown };\n if (typeof type !== 'string') {\n return [];\n }\n return [...(childrenByType.get(type)?.(node) ?? [])];\n }) as ChildNodeWalker;\n walk.hasOwnContent = (node) => {\n if (!node || typeof node !== 'object') {\n return false;\n }\n const { type } = node as { type?: unknown };\n if (typeof type !== 'string') {\n return false;\n }\n return ownContentByType.get(type)?.(node) ?? false;\n };\n return walk;\n};\n\n/** Joins a parent path with a {@link ChildNodeRef.path} fragment. */\nexport const childNodePath = (parent: string, child: string): string =>\n `${parent}.${child}`;\n\n/**\n * Whether any node visible on `surface` matches, descending through container\n * children via `walk`. A node (or a container ancestor) hidden from `surface`\n * is skipped along with its children.\n *\n * `walk` must span every pack in the composition: a walker built from one\n * pack's definitions cannot see children of a container defined in another.\n */\nexport const someBodyNode = (\n nodes: readonly unknown[],\n surface: SurfaceName,\n predicate: (node: unknown) => boolean,\n walk: ChildNodeWalker\n): boolean =>\n nodes.some((node) => {\n if (!isVisibleOnSurface(node, surface)) {\n return false;\n }\n return (\n predicate(node) ||\n someBodyNode(\n walk(node).map((child) => child.node),\n surface,\n predicate,\n walk\n )\n );\n });\n\n/** Whether `node`'s own `surfaces` hint admits `surface`, ignoring its children. */\nexport const isVisibleOnSurface = (\n node: unknown,\n surface: SurfaceName\n): boolean => {\n if (!node || typeof node !== 'object') {\n return false;\n }\n const { surfaces } = node as { surfaces?: unknown };\n return !Array.isArray(surfaces) || surfaces.includes(surface);\n};\n\n/**\n * Whether `node` puts anything on `surface` — itself or through a descendant.\n *\n * Stronger than {@link isVisibleOnSurface}: a container every one of whose\n * children is hidden renders nothing, even though its own hint allows the\n * surface. A hybrid container that also owns string fields declares\n * {@link ChildNodeWalker.hasOwnContent} and keeps rendering regardless.\n */\nexport const rendersOnSurface = (\n node: unknown,\n surface: SurfaceName,\n walk: ChildNodeWalker\n): boolean => {\n if (!isVisibleOnSurface(node, surface)) {\n return false;\n }\n const children = walk(node);\n if (children.length === 0 || walk.hasOwnContent?.(node)) {\n return true;\n }\n return children.some(({ node: child }) =>\n rendersOnSurface(child, surface, walk)\n );\n};\n"]}
@@ -0,0 +1,71 @@
1
+ import type { RenderTheme } from './named_color.js';
2
+ import type { PrimitiveNode } from './node.js';
3
+ /**
4
+ * The wire format: one typed document that every surface renders from.
5
+ *
6
+ * Crosses process and vendor boundaries, so the JSON shape is the contract and
7
+ * the TypeScript name is not: {@link Composition.type} reads `view`, the
8
+ * discriminator an agent is prompted on.
9
+ */
10
+ export interface Composition<TNode extends PrimitiveNode = PrimitiveNode> {
11
+ /** Root marker. Always `view`; see the note on {@link Composition}. */
12
+ type: 'view';
13
+ /**
14
+ * Wire-format version. A literal rather than `number` so an unknown future
15
+ * version cannot parse as valid, and optional with no default because absent
16
+ * already means v1 — writing one in would rewrite stored documents.
17
+ */
18
+ version?: 1;
19
+ title?: string;
20
+ subtitle?: string;
21
+ /** Light/dark preference, not a resolved value; `auto` resolves light. */
22
+ theme?: RenderTheme;
23
+ /** At least one node, which the schema enforces via `.min(1)`. */
24
+ body: TNode[];
25
+ meta?: CompositionMeta;
26
+ }
27
+ /**
28
+ * Context a host may surface beside the render.
29
+ *
30
+ * Advisory and pass-through throughout: nothing here changes what the body
31
+ * renders to, and the SDK reads none of it. Timestamps are plain strings by
32
+ * convention ISO 8601, which the schema does not enforce — a host that parses
33
+ * one should tolerate anything.
34
+ */
35
+ export interface CompositionMeta {
36
+ /** Origin of the composition itself, e.g. the agent or feature that composed it. */
37
+ source?: string;
38
+ /** When the composition was produced. */
39
+ generatedAt?: string;
40
+ /** Overrides the accessible name a surface derives from `title`. */
41
+ ariaLabel?: string;
42
+ /** Where the underlying data came from, as opposed to who composed it. */
43
+ provenance?: {
44
+ /** Data origin, e.g. an index or dataset name. */
45
+ source?: string;
46
+ /** The query that produced the data, for a host that offers "show me how". */
47
+ query?: string;
48
+ /** Service or connector that answered the query. */
49
+ provider?: string;
50
+ };
51
+ /** How current the data is, for a host that shows an as-of or staleness badge. */
52
+ freshness?: {
53
+ /** When the data was current, which may precede `generatedAt`. */
54
+ asOf?: string;
55
+ /** Asserted by the producer rather than derived, so a host should prefer it to comparing `asOf`. */
56
+ stale?: boolean;
57
+ /** How long `asOf` stays current. Not range-checked. */
58
+ ttlSeconds?: number;
59
+ };
60
+ /**
61
+ * Set when the composition rendered anyway despite losing some data, so a
62
+ * host can mark it incomplete rather than presenting it as whole.
63
+ */
64
+ partialFailure?: {
65
+ /** True when some of the data behind the composition was lost before it rendered. */
66
+ degraded?: boolean;
67
+ /** Human-readable cause, safe to show a user. */
68
+ reason?: string;
69
+ };
70
+ }
71
+ //# sourceMappingURL=composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../../src/composition/composition.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,SAAS,aAAa,GAAG,aAAa;IACtE,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,kEAAkE;IAClE,IAAI,EAAE,KAAK,EAAE,CAAC;IACd,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,UAAU,CAAC,EAAE;QACX,kDAAkD;QAClD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,8EAA8E;QAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,oDAAoD;QACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,kFAAkF;IAClF,SAAS,CAAC,EAAE;QACV,kEAAkE;QAClE,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,oGAAoG;QACpG,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,wDAAwD;QACxD,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF;;;OAGG;IACH,cAAc,CAAC,EAAE;QACf,qFAAqF;QACrF,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,iDAAiD;QACjD,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH"}
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.js","sourceRoot":"","sources":["../../src/composition/composition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG","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 { RenderTheme } from './named_color';\nimport type { PrimitiveNode } from './node';\n\n/**\n * The wire format: one typed document that every surface renders from.\n *\n * Crosses process and vendor boundaries, so the JSON shape is the contract and\n * the TypeScript name is not: {@link Composition.type} reads `view`, the\n * discriminator an agent is prompted on.\n */\nexport interface Composition<TNode extends PrimitiveNode = PrimitiveNode> {\n /** Root marker. Always `view`; see the note on {@link Composition}. */\n type: 'view';\n /**\n * Wire-format version. A literal rather than `number` so an unknown future\n * version cannot parse as valid, and optional with no default because absent\n * already means v1 — writing one in would rewrite stored documents.\n */\n version?: 1;\n title?: string;\n subtitle?: string;\n /** Light/dark preference, not a resolved value; `auto` resolves light. */\n theme?: RenderTheme;\n /** At least one node, which the schema enforces via `.min(1)`. */\n body: TNode[];\n meta?: CompositionMeta;\n}\n\n/**\n * Context a host may surface beside the render.\n *\n * Advisory and pass-through throughout: nothing here changes what the body\n * renders to, and the SDK reads none of it. Timestamps are plain strings by\n * convention ISO 8601, which the schema does not enforce — a host that parses\n * one should tolerate anything.\n */\nexport interface CompositionMeta {\n /** Origin of the composition itself, e.g. the agent or feature that composed it. */\n source?: string;\n /** When the composition was produced. */\n generatedAt?: string;\n /** Overrides the accessible name a surface derives from `title`. */\n ariaLabel?: string;\n /** Where the underlying data came from, as opposed to who composed it. */\n provenance?: {\n /** Data origin, e.g. an index or dataset name. */\n source?: string;\n /** The query that produced the data, for a host that offers \"show me how\". */\n query?: string;\n /** Service or connector that answered the query. */\n provider?: string;\n };\n /** How current the data is, for a host that shows an as-of or staleness badge. */\n freshness?: {\n /** When the data was current, which may precede `generatedAt`. */\n asOf?: string;\n /** Asserted by the producer rather than derived, so a host should prefer it to comparing `asOf`. */\n stale?: boolean;\n /** How long `asOf` stays current. Not range-checked. */\n ttlSeconds?: number;\n };\n /**\n * Set when the composition rendered anyway despite losing some data, so a\n * host can mark it incomplete rather than presenting it as whole.\n */\n partialFailure?: {\n /** True when some of the data behind the composition was lost before it rendered. */\n degraded?: boolean;\n /** Human-readable cause, safe to show a user. */\n reason?: string;\n };\n}\n"]}