@elastic/isomer-sdk 0.0.0 → 0.2.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 (492) hide show
  1. package/LICENSE.txt +93 -0
  2. package/NOTICE.txt +1861 -0
  3. package/README.md +69 -0
  4. package/THIRD_PARTY_LICENSES.md +957 -0
  5. package/dist/author/authored_fields.d.ts +153 -0
  6. package/dist/author/authored_fields.d.ts.map +1 -0
  7. package/dist/author/authored_fields.js +227 -0
  8. package/dist/author/authored_fields.js.map +1 -0
  9. package/dist/author/authoring_input.d.ts +7 -0
  10. package/dist/author/authoring_input.d.ts.map +1 -0
  11. package/dist/author/authoring_input.js +60 -0
  12. package/dist/author/authoring_input.js.map +1 -0
  13. package/dist/author/authoring_model.d.ts +27 -0
  14. package/dist/author/authoring_model.d.ts.map +1 -0
  15. package/dist/author/authoring_model.js +98 -0
  16. package/dist/author/authoring_model.js.map +1 -0
  17. package/dist/author/declarations.d.ts +13 -0
  18. package/dist/author/declarations.d.ts.map +1 -0
  19. package/dist/author/declarations.js +277 -0
  20. package/dist/author/declarations.js.map +1 -0
  21. package/dist/author/index.d.ts +7 -0
  22. package/dist/author/index.d.ts.map +1 -0
  23. package/dist/author/index.js +12 -0
  24. package/dist/author/index.js.map +1 -0
  25. package/dist/author/jsx.d.ts +21 -0
  26. package/dist/author/jsx.d.ts.map +1 -0
  27. package/dist/author/jsx.js +20 -0
  28. package/dist/author/jsx.js.map +1 -0
  29. package/dist/author/jsx_shim.d.ts +117 -0
  30. package/dist/author/jsx_shim.d.ts.map +1 -0
  31. package/dist/author/jsx_shim.js +270 -0
  32. package/dist/author/jsx_shim.js.map +1 -0
  33. package/dist/author/prompt.d.ts +58 -0
  34. package/dist/author/prompt.d.ts.map +1 -0
  35. package/dist/author/prompt.js +148 -0
  36. package/dist/author/prompt.js.map +1 -0
  37. package/dist/author/schema_to_typescript.d.ts +37 -0
  38. package/dist/author/schema_to_typescript.d.ts.map +1 -0
  39. package/dist/author/schema_to_typescript.js +286 -0
  40. package/dist/author/schema_to_typescript.js.map +1 -0
  41. package/dist/cjs/author/authored_fields.js +233 -0
  42. package/dist/cjs/author/authored_fields.js.map +1 -0
  43. package/dist/cjs/author/authoring_input.js +64 -0
  44. package/dist/cjs/author/authoring_input.js.map +1 -0
  45. package/dist/cjs/author/authoring_model.js +104 -0
  46. package/dist/cjs/author/authoring_model.js.map +1 -0
  47. package/dist/cjs/author/declarations.js +281 -0
  48. package/dist/cjs/author/declarations.js.map +1 -0
  49. package/dist/cjs/author/index.js +25 -0
  50. package/dist/cjs/author/index.js.map +1 -0
  51. package/dist/cjs/author/jsx.js +24 -0
  52. package/dist/cjs/author/jsx.js.map +1 -0
  53. package/dist/cjs/author/jsx_shim.js +276 -0
  54. package/dist/cjs/author/jsx_shim.js.map +1 -0
  55. package/dist/cjs/author/prompt.js +153 -0
  56. package/dist/cjs/author/prompt.js.map +1 -0
  57. package/dist/cjs/author/schema_to_typescript.js +295 -0
  58. package/dist/cjs/author/schema_to_typescript.js.map +1 -0
  59. package/dist/cjs/composition/action_event.js +9 -0
  60. package/dist/cjs/composition/action_event.js.map +1 -0
  61. package/dist/cjs/composition/body_node_base.js +112 -0
  62. package/dist/cjs/composition/body_node_base.js.map +1 -0
  63. package/dist/cjs/composition/composition.js +9 -0
  64. package/dist/cjs/composition/composition.js.map +1 -0
  65. package/dist/cjs/composition/error.js +73 -0
  66. package/dist/cjs/composition/error.js.map +1 -0
  67. package/dist/cjs/composition/index.js +32 -0
  68. package/dist/cjs/composition/index.js.map +1 -0
  69. package/dist/cjs/composition/map_nodes.js +85 -0
  70. package/dist/cjs/composition/map_nodes.js.map +1 -0
  71. package/dist/cjs/composition/named_color.js +20 -0
  72. package/dist/cjs/composition/named_color.js.map +1 -0
  73. package/dist/cjs/composition/node.js +9 -0
  74. package/dist/cjs/composition/node.js.map +1 -0
  75. package/dist/cjs/composition/one_line.js +23 -0
  76. package/dist/cjs/composition/one_line.js.map +1 -0
  77. package/dist/cjs/composition/structured_value.js +21 -0
  78. package/dist/cjs/composition/structured_value.js.map +1 -0
  79. package/dist/cjs/composition/validation_error.js +40 -0
  80. package/dist/cjs/composition/validation_error.js.map +1 -0
  81. package/dist/cjs/define/frame.js +31 -0
  82. package/dist/cjs/define/frame.js.map +1 -0
  83. package/dist/cjs/define/index.js +31 -0
  84. package/dist/cjs/define/index.js.map +1 -0
  85. package/dist/cjs/define/markdown_content.js +12 -0
  86. package/dist/cjs/define/markdown_content.js.map +1 -0
  87. package/dist/cjs/define/primitive_example.js +26 -0
  88. package/dist/cjs/define/primitive_example.js.map +1 -0
  89. package/dist/cjs/define/primitive_icon.js +17 -0
  90. package/dist/cjs/define/primitive_icon.js.map +1 -0
  91. package/dist/cjs/define/primitive_module.js +118 -0
  92. package/dist/cjs/define/primitive_module.js.map +1 -0
  93. package/dist/cjs/define/slack_assets.js +9 -0
  94. package/dist/cjs/define/slack_assets.js.map +1 -0
  95. package/dist/cjs/define/slack_blocks.js +9 -0
  96. package/dist/cjs/define/slack_blocks.js.map +1 -0
  97. package/dist/cjs/define/zod_format.js +122 -0
  98. package/dist/cjs/define/zod_format.js.map +1 -0
  99. package/dist/cjs/define/zod_helpers.js +26 -0
  100. package/dist/cjs/define/zod_helpers.js.map +1 -0
  101. package/dist/cjs/entries/html.js +12 -0
  102. package/dist/cjs/entries/html.js.map +1 -0
  103. package/dist/cjs/entries/index.js +80 -0
  104. package/dist/cjs/entries/index.js.map +1 -0
  105. package/dist/cjs/entries/markdown.js +14 -0
  106. package/dist/cjs/entries/markdown.js.map +1 -0
  107. package/dist/cjs/entries/react.js +20 -0
  108. package/dist/cjs/entries/react.js.map +1 -0
  109. package/dist/cjs/entries/slack.js +25 -0
  110. package/dist/cjs/entries/slack.js.map +1 -0
  111. package/dist/cjs/entries/text.js +12 -0
  112. package/dist/cjs/entries/text.js.map +1 -0
  113. package/dist/cjs/pack/capabilities.js +40 -0
  114. package/dist/cjs/pack/capabilities.js.map +1 -0
  115. package/dist/cjs/pack/compose.js +59 -0
  116. package/dist/cjs/pack/compose.js.map +1 -0
  117. package/dist/cjs/pack/enhancements.js +65 -0
  118. package/dist/cjs/pack/enhancements.js.map +1 -0
  119. package/dist/cjs/pack/index.js +18 -0
  120. package/dist/cjs/pack/index.js.map +1 -0
  121. package/dist/cjs/pack/primitive_pack.js +97 -0
  122. package/dist/cjs/pack/primitive_pack.js.map +1 -0
  123. package/dist/cjs/package.json +3 -0
  124. package/dist/cjs/render/anchors.js +167 -0
  125. package/dist/cjs/render/anchors.js.map +1 -0
  126. package/dist/cjs/render/context_view.js +54 -0
  127. package/dist/cjs/render/context_view.js.map +1 -0
  128. package/dist/cjs/render/format_display_value.js +143 -0
  129. package/dist/cjs/render/format_display_value.js.map +1 -0
  130. package/dist/cjs/render/format_number.js +46 -0
  131. package/dist/cjs/render/format_number.js.map +1 -0
  132. package/dist/cjs/render/html/enhancements.js +30 -0
  133. package/dist/cjs/render/html/enhancements.js.map +1 -0
  134. package/dist/cjs/render/html/envelope.js +218 -0
  135. package/dist/cjs/render/html/envelope.js.map +1 -0
  136. package/dist/cjs/render/html/index.js +12 -0
  137. package/dist/cjs/render/html/index.js.map +1 -0
  138. package/dist/cjs/render/index.js +25 -0
  139. package/dist/cjs/render/index.js.map +1 -0
  140. package/dist/cjs/render/layout_check.js +133 -0
  141. package/dist/cjs/render/layout_check.js.map +1 -0
  142. package/dist/cjs/render/markdown/builder.js +195 -0
  143. package/dist/cjs/render/markdown/builder.js.map +1 -0
  144. package/dist/cjs/render/markdown/envelope.js +33 -0
  145. package/dist/cjs/render/markdown/envelope.js.map +1 -0
  146. package/dist/cjs/render/markdown/format.js +208 -0
  147. package/dist/cjs/render/markdown/format.js.map +1 -0
  148. package/dist/cjs/render/markdown/index.js +15 -0
  149. package/dist/cjs/render/markdown/index.js.map +1 -0
  150. package/dist/cjs/render/measure_dom.js +61 -0
  151. package/dist/cjs/render/measure_dom.js.map +1 -0
  152. package/dist/cjs/render/payload.js +13 -0
  153. package/dist/cjs/render/payload.js.map +1 -0
  154. package/dist/cjs/render/primitive_dispatch.js +173 -0
  155. package/dist/cjs/render/primitive_dispatch.js.map +1 -0
  156. package/dist/cjs/render/react/content.js +44 -0
  157. package/dist/cjs/render/react/content.js.map +1 -0
  158. package/dist/cjs/render/react/enhancements.js +32 -0
  159. package/dist/cjs/render/react/enhancements.js.map +1 -0
  160. package/dist/cjs/render/react/index.js +15 -0
  161. package/dist/cjs/render/react/index.js.map +1 -0
  162. package/dist/cjs/render/slack/assets.js +45 -0
  163. package/dist/cjs/render/slack/assets.js.map +1 -0
  164. package/dist/cjs/render/slack/blocks.js +80 -0
  165. package/dist/cjs/render/slack/blocks.js.map +1 -0
  166. package/dist/cjs/render/slack/envelope.js +551 -0
  167. package/dist/cjs/render/slack/envelope.js.map +1 -0
  168. package/dist/cjs/render/slack/format.js +225 -0
  169. package/dist/cjs/render/slack/format.js.map +1 -0
  170. package/dist/cjs/render/slack/index.js +30 -0
  171. package/dist/cjs/render/slack/index.js.map +1 -0
  172. package/dist/cjs/render/slack/markdown_content.js +409 -0
  173. package/dist/cjs/render/slack/markdown_content.js.map +1 -0
  174. package/dist/cjs/render/text/envelope.js +21 -0
  175. package/dist/cjs/render/text/envelope.js.map +1 -0
  176. package/dist/cjs/render/text/index.js +12 -0
  177. package/dist/cjs/render/text/index.js.map +1 -0
  178. package/dist/cjs/testing/conformance.js +312 -0
  179. package/dist/cjs/testing/conformance.js.map +1 -0
  180. package/dist/cjs/testing/icon.js +248 -0
  181. package/dist/cjs/testing/icon.js.map +1 -0
  182. package/dist/cjs/testing/index.js +18 -0
  183. package/dist/cjs/testing/index.js.map +1 -0
  184. package/dist/cjs/testing/registration.js +142 -0
  185. package/dist/cjs/testing/registration.js.map +1 -0
  186. package/dist/cjs/validate/authoring_schema.js +312 -0
  187. package/dist/cjs/validate/authoring_schema.js.map +1 -0
  188. package/dist/cjs/validate/composition_schema.js +135 -0
  189. package/dist/cjs/validate/composition_schema.js.map +1 -0
  190. package/dist/cjs/validate/index.js +53 -0
  191. package/dist/cjs/validate/index.js.map +1 -0
  192. package/dist/cjs/validate/input_budget.js +156 -0
  193. package/dist/cjs/validate/input_budget.js.map +1 -0
  194. package/dist/cjs/validate/json_schema.js +72 -0
  195. package/dist/cjs/validate/json_schema.js.map +1 -0
  196. package/dist/cjs/validate/node_issues.js +65 -0
  197. package/dist/cjs/validate/node_issues.js.map +1 -0
  198. package/dist/cjs/validate/url.js +116 -0
  199. package/dist/cjs/validate/url.js.map +1 -0
  200. package/dist/cjs/validate/validation.js +165 -0
  201. package/dist/cjs/validate/validation.js.map +1 -0
  202. package/dist/cjs/validate/value_schemas.js +53 -0
  203. package/dist/cjs/validate/value_schemas.js.map +1 -0
  204. package/dist/composition/action_event.d.ts +13 -0
  205. package/dist/composition/action_event.d.ts.map +1 -0
  206. package/dist/composition/action_event.js +8 -0
  207. package/dist/composition/action_event.js.map +1 -0
  208. package/dist/composition/body_node_base.d.ts +72 -0
  209. package/dist/composition/body_node_base.d.ts.map +1 -0
  210. package/dist/composition/body_node_base.js +104 -0
  211. package/dist/composition/body_node_base.js.map +1 -0
  212. package/dist/composition/composition.d.ts +71 -0
  213. package/dist/composition/composition.d.ts.map +1 -0
  214. package/dist/composition/composition.js +8 -0
  215. package/dist/composition/composition.js.map +1 -0
  216. package/dist/composition/error.d.ts +61 -0
  217. package/dist/composition/error.d.ts.map +1 -0
  218. package/dist/composition/error.js +69 -0
  219. package/dist/composition/error.js.map +1 -0
  220. package/dist/composition/index.d.ts +11 -0
  221. package/dist/composition/index.d.ts.map +1 -0
  222. package/dist/composition/index.js +14 -0
  223. package/dist/composition/index.js.map +1 -0
  224. package/dist/composition/map_nodes.d.ts +16 -0
  225. package/dist/composition/map_nodes.d.ts.map +1 -0
  226. package/dist/composition/map_nodes.js +81 -0
  227. package/dist/composition/map_nodes.js.map +1 -0
  228. package/dist/composition/named_color.d.ts +9 -0
  229. package/dist/composition/named_color.d.ts.map +1 -0
  230. package/dist/composition/named_color.js +17 -0
  231. package/dist/composition/named_color.js.map +1 -0
  232. package/dist/composition/node.d.ts +11 -0
  233. package/dist/composition/node.d.ts.map +1 -0
  234. package/dist/composition/node.js +8 -0
  235. package/dist/composition/node.js.map +1 -0
  236. package/dist/composition/one_line.d.ts +7 -0
  237. package/dist/composition/one_line.d.ts.map +1 -0
  238. package/dist/composition/one_line.js +17 -0
  239. package/dist/composition/one_line.js.map +1 -0
  240. package/dist/composition/structured_value.d.ts +27 -0
  241. package/dist/composition/structured_value.d.ts.map +1 -0
  242. package/dist/composition/structured_value.js +18 -0
  243. package/dist/composition/structured_value.js.map +1 -0
  244. package/dist/composition/validation_error.d.ts +33 -0
  245. package/dist/composition/validation_error.d.ts.map +1 -0
  246. package/dist/composition/validation_error.js +35 -0
  247. package/dist/composition/validation_error.js.map +1 -0
  248. package/dist/define/frame.d.ts +155 -0
  249. package/dist/define/frame.d.ts.map +1 -0
  250. package/dist/define/frame.js +27 -0
  251. package/dist/define/frame.js.map +1 -0
  252. package/dist/define/index.d.ts +10 -0
  253. package/dist/define/index.d.ts.map +1 -0
  254. package/dist/define/index.js +13 -0
  255. package/dist/define/index.js.map +1 -0
  256. package/dist/define/markdown_content.d.ts +15 -0
  257. package/dist/define/markdown_content.d.ts.map +1 -0
  258. package/dist/define/markdown_content.js +9 -0
  259. package/dist/define/markdown_content.js.map +1 -0
  260. package/dist/define/primitive_example.d.ts +30 -0
  261. package/dist/define/primitive_example.d.ts.map +1 -0
  262. package/dist/define/primitive_example.js +21 -0
  263. package/dist/define/primitive_example.js.map +1 -0
  264. package/dist/define/primitive_icon.d.ts +11 -0
  265. package/dist/define/primitive_icon.d.ts.map +1 -0
  266. package/dist/define/primitive_icon.js +14 -0
  267. package/dist/define/primitive_icon.js.map +1 -0
  268. package/dist/define/primitive_module.d.ts +435 -0
  269. package/dist/define/primitive_module.d.ts.map +1 -0
  270. package/dist/define/primitive_module.js +112 -0
  271. package/dist/define/primitive_module.js.map +1 -0
  272. package/dist/define/slack_assets.d.ts +28 -0
  273. package/dist/define/slack_assets.d.ts.map +1 -0
  274. package/dist/define/slack_assets.js +8 -0
  275. package/dist/define/slack_assets.js.map +1 -0
  276. package/dist/define/slack_blocks.d.ts +234 -0
  277. package/dist/define/slack_blocks.d.ts.map +1 -0
  278. package/dist/define/slack_blocks.js +8 -0
  279. package/dist/define/slack_blocks.js.map +1 -0
  280. package/dist/define/zod_format.d.ts +33 -0
  281. package/dist/define/zod_format.d.ts.map +1 -0
  282. package/dist/define/zod_format.js +114 -0
  283. package/dist/define/zod_format.js.map +1 -0
  284. package/dist/define/zod_helpers.d.ts +10 -0
  285. package/dist/define/zod_helpers.d.ts.map +1 -0
  286. package/dist/define/zod_helpers.js +22 -0
  287. package/dist/define/zod_helpers.js.map +1 -0
  288. package/dist/entries/html.d.ts +3 -0
  289. package/dist/entries/html.d.ts.map +1 -0
  290. package/dist/entries/html.js +8 -0
  291. package/dist/entries/html.js.map +1 -0
  292. package/dist/entries/index.d.ts +6 -0
  293. package/dist/entries/index.d.ts.map +1 -0
  294. package/dist/entries/index.js +12 -0
  295. package/dist/entries/index.js.map +1 -0
  296. package/dist/entries/markdown.d.ts +3 -0
  297. package/dist/entries/markdown.d.ts.map +1 -0
  298. package/dist/entries/markdown.js +8 -0
  299. package/dist/entries/markdown.js.map +1 -0
  300. package/dist/entries/react.d.ts +5 -0
  301. package/dist/entries/react.d.ts.map +1 -0
  302. package/dist/entries/react.js +11 -0
  303. package/dist/entries/react.js.map +1 -0
  304. package/dist/entries/slack.d.ts +2 -0
  305. package/dist/entries/slack.d.ts.map +1 -0
  306. package/dist/entries/slack.js +8 -0
  307. package/dist/entries/slack.js.map +1 -0
  308. package/dist/entries/text.d.ts +2 -0
  309. package/dist/entries/text.d.ts.map +1 -0
  310. package/dist/entries/text.js +8 -0
  311. package/dist/entries/text.js.map +1 -0
  312. package/dist/pack/capabilities.d.ts +41 -0
  313. package/dist/pack/capabilities.d.ts.map +1 -0
  314. package/dist/pack/capabilities.js +36 -0
  315. package/dist/pack/capabilities.js.map +1 -0
  316. package/dist/pack/compose.d.ts +24 -0
  317. package/dist/pack/compose.d.ts.map +1 -0
  318. package/dist/pack/compose.js +55 -0
  319. package/dist/pack/compose.js.map +1 -0
  320. package/dist/pack/enhancements.d.ts +65 -0
  321. package/dist/pack/enhancements.d.ts.map +1 -0
  322. package/dist/pack/enhancements.js +59 -0
  323. package/dist/pack/enhancements.js.map +1 -0
  324. package/dist/pack/index.d.ts +5 -0
  325. package/dist/pack/index.d.ts.map +1 -0
  326. package/dist/pack/index.js +11 -0
  327. package/dist/pack/index.js.map +1 -0
  328. package/dist/pack/primitive_pack.d.ts +164 -0
  329. package/dist/pack/primitive_pack.d.ts.map +1 -0
  330. package/dist/pack/primitive_pack.js +92 -0
  331. package/dist/pack/primitive_pack.js.map +1 -0
  332. package/dist/render/anchors.d.ts +82 -0
  333. package/dist/render/anchors.d.ts.map +1 -0
  334. package/dist/render/anchors.js +153 -0
  335. package/dist/render/anchors.js.map +1 -0
  336. package/dist/render/context_view.d.ts +10 -0
  337. package/dist/render/context_view.d.ts.map +1 -0
  338. package/dist/render/context_view.js +49 -0
  339. package/dist/render/context_view.js.map +1 -0
  340. package/dist/render/format_display_value.d.ts +20 -0
  341. package/dist/render/format_display_value.d.ts.map +1 -0
  342. package/dist/render/format_display_value.js +137 -0
  343. package/dist/render/format_display_value.js.map +1 -0
  344. package/dist/render/format_number.d.ts +9 -0
  345. package/dist/render/format_number.d.ts.map +1 -0
  346. package/dist/render/format_number.js +42 -0
  347. package/dist/render/format_number.js.map +1 -0
  348. package/dist/render/html/enhancements.d.ts +10 -0
  349. package/dist/render/html/enhancements.d.ts.map +1 -0
  350. package/dist/render/html/enhancements.js +25 -0
  351. package/dist/render/html/enhancements.js.map +1 -0
  352. package/dist/render/html/envelope.d.ts +182 -0
  353. package/dist/render/html/envelope.d.ts.map +1 -0
  354. package/dist/render/html/envelope.js +214 -0
  355. package/dist/render/html/envelope.js.map +1 -0
  356. package/dist/render/html/index.d.ts +3 -0
  357. package/dist/render/html/index.d.ts.map +1 -0
  358. package/dist/render/html/index.js +8 -0
  359. package/dist/render/html/index.js.map +1 -0
  360. package/dist/render/index.d.ts +6 -0
  361. package/dist/render/index.d.ts.map +1 -0
  362. package/dist/render/index.js +11 -0
  363. package/dist/render/index.js.map +1 -0
  364. package/dist/render/layout_check.d.ts +43 -0
  365. package/dist/render/layout_check.d.ts.map +1 -0
  366. package/dist/render/layout_check.js +129 -0
  367. package/dist/render/layout_check.js.map +1 -0
  368. package/dist/render/markdown/builder.d.ts +46 -0
  369. package/dist/render/markdown/builder.d.ts.map +1 -0
  370. package/dist/render/markdown/builder.js +190 -0
  371. package/dist/render/markdown/builder.js.map +1 -0
  372. package/dist/render/markdown/envelope.d.ts +20 -0
  373. package/dist/render/markdown/envelope.d.ts.map +1 -0
  374. package/dist/render/markdown/envelope.js +29 -0
  375. package/dist/render/markdown/envelope.js.map +1 -0
  376. package/dist/render/markdown/format.d.ts +10 -0
  377. package/dist/render/markdown/format.d.ts.map +1 -0
  378. package/dist/render/markdown/format.js +202 -0
  379. package/dist/render/markdown/format.js.map +1 -0
  380. package/dist/render/markdown/index.d.ts +3 -0
  381. package/dist/render/markdown/index.d.ts.map +1 -0
  382. package/dist/render/markdown/index.js +9 -0
  383. package/dist/render/markdown/index.js.map +1 -0
  384. package/dist/render/measure_dom.d.ts +10 -0
  385. package/dist/render/measure_dom.d.ts.map +1 -0
  386. package/dist/render/measure_dom.js +57 -0
  387. package/dist/render/measure_dom.js.map +1 -0
  388. package/dist/render/payload.d.ts +16 -0
  389. package/dist/render/payload.d.ts.map +1 -0
  390. package/dist/render/payload.js +9 -0
  391. package/dist/render/payload.js.map +1 -0
  392. package/dist/render/primitive_dispatch.d.ts +72 -0
  393. package/dist/render/primitive_dispatch.d.ts.map +1 -0
  394. package/dist/render/primitive_dispatch.js +169 -0
  395. package/dist/render/primitive_dispatch.js.map +1 -0
  396. package/dist/render/react/content.d.ts +40 -0
  397. package/dist/render/react/content.d.ts.map +1 -0
  398. package/dist/render/react/content.js +39 -0
  399. package/dist/render/react/content.js.map +1 -0
  400. package/dist/render/react/enhancements.d.ts +15 -0
  401. package/dist/render/react/enhancements.d.ts.map +1 -0
  402. package/dist/render/react/enhancements.js +28 -0
  403. package/dist/render/react/enhancements.js.map +1 -0
  404. package/dist/render/react/index.d.ts +3 -0
  405. package/dist/render/react/index.d.ts.map +1 -0
  406. package/dist/render/react/index.js +9 -0
  407. package/dist/render/react/index.js.map +1 -0
  408. package/dist/render/slack/assets.d.ts +16 -0
  409. package/dist/render/slack/assets.d.ts.map +1 -0
  410. package/dist/render/slack/assets.js +40 -0
  411. package/dist/render/slack/assets.js.map +1 -0
  412. package/dist/render/slack/blocks.d.ts +72 -0
  413. package/dist/render/slack/blocks.d.ts.map +1 -0
  414. package/dist/render/slack/blocks.js +77 -0
  415. package/dist/render/slack/blocks.js.map +1 -0
  416. package/dist/render/slack/envelope.d.ts +52 -0
  417. package/dist/render/slack/envelope.d.ts.map +1 -0
  418. package/dist/render/slack/envelope.js +547 -0
  419. package/dist/render/slack/envelope.js.map +1 -0
  420. package/dist/render/slack/format.d.ts +70 -0
  421. package/dist/render/slack/format.d.ts.map +1 -0
  422. package/dist/render/slack/format.js +209 -0
  423. package/dist/render/slack/format.js.map +1 -0
  424. package/dist/render/slack/index.d.ts +6 -0
  425. package/dist/render/slack/index.d.ts.map +1 -0
  426. package/dist/render/slack/index.js +12 -0
  427. package/dist/render/slack/index.js.map +1 -0
  428. package/dist/render/slack/markdown_content.d.ts +17 -0
  429. package/dist/render/slack/markdown_content.d.ts.map +1 -0
  430. package/dist/render/slack/markdown_content.js +404 -0
  431. package/dist/render/slack/markdown_content.js.map +1 -0
  432. package/dist/render/text/envelope.d.ts +15 -0
  433. package/dist/render/text/envelope.d.ts.map +1 -0
  434. package/dist/render/text/envelope.js +17 -0
  435. package/dist/render/text/envelope.js.map +1 -0
  436. package/dist/render/text/index.d.ts +2 -0
  437. package/dist/render/text/index.d.ts.map +1 -0
  438. package/dist/render/text/index.js +8 -0
  439. package/dist/render/text/index.js.map +1 -0
  440. package/dist/testing/conformance.d.ts +145 -0
  441. package/dist/testing/conformance.d.ts.map +1 -0
  442. package/dist/testing/conformance.js +303 -0
  443. package/dist/testing/conformance.js.map +1 -0
  444. package/dist/testing/icon.d.ts +11 -0
  445. package/dist/testing/icon.d.ts.map +1 -0
  446. package/dist/testing/icon.js +244 -0
  447. package/dist/testing/icon.js.map +1 -0
  448. package/dist/testing/index.d.ts +4 -0
  449. package/dist/testing/index.d.ts.map +1 -0
  450. package/dist/testing/index.js +10 -0
  451. package/dist/testing/index.js.map +1 -0
  452. package/dist/testing/registration.d.ts +32 -0
  453. package/dist/testing/registration.d.ts.map +1 -0
  454. package/dist/testing/registration.js +105 -0
  455. package/dist/testing/registration.js.map +1 -0
  456. package/dist/validate/authoring_schema.d.ts +33 -0
  457. package/dist/validate/authoring_schema.d.ts.map +1 -0
  458. package/dist/validate/authoring_schema.js +306 -0
  459. package/dist/validate/authoring_schema.js.map +1 -0
  460. package/dist/validate/composition_schema.d.ts +80 -0
  461. package/dist/validate/composition_schema.d.ts.map +1 -0
  462. package/dist/validate/composition_schema.js +127 -0
  463. package/dist/validate/composition_schema.js.map +1 -0
  464. package/dist/validate/index.d.ts +9 -0
  465. package/dist/validate/index.d.ts.map +1 -0
  466. package/dist/validate/index.js +15 -0
  467. package/dist/validate/index.js.map +1 -0
  468. package/dist/validate/input_budget.d.ts +35 -0
  469. package/dist/validate/input_budget.d.ts.map +1 -0
  470. package/dist/validate/input_budget.js +151 -0
  471. package/dist/validate/input_budget.js.map +1 -0
  472. package/dist/validate/json_schema.d.ts +32 -0
  473. package/dist/validate/json_schema.d.ts.map +1 -0
  474. package/dist/validate/json_schema.js +68 -0
  475. package/dist/validate/json_schema.js.map +1 -0
  476. package/dist/validate/node_issues.d.ts +12 -0
  477. package/dist/validate/node_issues.d.ts.map +1 -0
  478. package/dist/validate/node_issues.js +61 -0
  479. package/dist/validate/node_issues.js.map +1 -0
  480. package/dist/validate/url.d.ts +50 -0
  481. package/dist/validate/url.d.ts.map +1 -0
  482. package/dist/validate/url.js +107 -0
  483. package/dist/validate/url.js.map +1 -0
  484. package/dist/validate/validation.d.ts +95 -0
  485. package/dist/validate/validation.d.ts.map +1 -0
  486. package/dist/validate/validation.js +157 -0
  487. package/dist/validate/validation.js.map +1 -0
  488. package/dist/validate/value_schemas.d.ts +53 -0
  489. package/dist/validate/value_schemas.d.ts.map +1 -0
  490. package/dist/validate/value_schemas.js +50 -0
  491. package/dist/validate/value_schemas.js.map +1 -0
  492. package/package.json +119 -5
@@ -0,0 +1,95 @@
1
+ import { type SurfaceName } from '../composition/body_node_base.js';
2
+ import type { Composition } from '../composition/composition.js';
3
+ import type { PrimitiveNode } from '../composition/node.js';
4
+ import { CompositionValidationError, type ValidationError } from '../composition/validation_error.js';
5
+ import type { AnyPrimitiveDefinition } from '../define/primitive_module.js';
6
+ import { type InputBudget } from './input_budget.js';
7
+ /**
8
+ * A non-fatal validation finding, scoped to the surface it concerns.
9
+ *
10
+ * Warnings carry `surface` because every one of them is a statement about one
11
+ * render target — a composition that draws nothing on `slack` is not news to a
12
+ * caller rendering HTML. Without the scope a host receives every surface's
13
+ * findings on every call and learns to ignore the channel.
14
+ * {@link warningsForSurface} is the filter.
15
+ */
16
+ export interface ValidationWarning {
17
+ /** The render target this finding concerns, never the composition as a whole. */
18
+ surface: SurfaceName;
19
+ /**
20
+ * Path of the offending node within the composition, absent for
21
+ * whole-composition findings.
22
+ */
23
+ path?: string;
24
+ /** Safe to show a user, and phrased for whoever can act on it. */
25
+ message: string;
26
+ }
27
+ /**
28
+ * The outcome of `validate`: errors are fatal, warnings are advisory.
29
+ *
30
+ * `valid` tracks `errors` only — a composition can be valid and still carry
31
+ * warnings, which is the normal case for a surface gap.
32
+ */
33
+ export interface ValidationResult {
34
+ /** True when `errors` is empty, regardless of `warnings`. */
35
+ valid: boolean;
36
+ /** Fatal findings. Empty when `valid`. */
37
+ errors: ValidationError[];
38
+ /** Advisory findings, empty when there are none. */
39
+ warnings: ValidationWarning[];
40
+ }
41
+ declare const checkedComposition: unique symbol;
42
+ /** The copy {@link createCompositionValidator} checked, which a validating render draws in place of the caller's value. The brand is type-only. */
43
+ export type CheckedComposition<TNode extends PrimitiveNode = PrimitiveNode> = Composition<TNode> & {
44
+ readonly [checkedComposition]: true;
45
+ };
46
+ /** A {@link ValidationResult} with the composition it describes. */
47
+ export interface CheckedValidationResult<TNode extends PrimitiveNode = PrimitiveNode> extends ValidationResult {
48
+ /** Undefined only when {@link checkInputBudget} refused the input. */
49
+ composition: CheckedComposition<TNode> | undefined;
50
+ }
51
+ /** Narrows a result's warnings to the surface a caller is about to render. */
52
+ export declare const warningsForSurface: (result: ValidationResult, surface: SurfaceName) => ValidationWarning[];
53
+ /** Whether a render reports validation findings or raises on them. */
54
+ export type ValidationErrorMode = 'collect' | 'throw';
55
+ export { CompositionValidationError };
56
+ /** 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. */
57
+ export declare const enforceValidationMode: (result: ValidationResult, mode?: ValidationErrorMode) => void;
58
+ /** 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. */
59
+ export declare const compositionToRender: <TNode extends PrimitiveNode>(result: CheckedValidationResult<TNode>, mode?: ValidationErrorMode) => CheckedComposition<TNode>;
60
+ /** Options for {@link createCompositionValidator}. */
61
+ export interface CompositionValidatorOptions {
62
+ /** Limits checked before the schema runs; see {@link checkInputBudget}. */
63
+ inputBudget?: InputBudget;
64
+ }
65
+ /**
66
+ * Builds the trusted-input validator: {@link checkInputBudget}, then the schema and the semantic passes on its copy, which the result carries.
67
+ *
68
+ * `definitions` is memoized on array identity, so a caller that rebuilds the
69
+ * array per call (`createCompositionValidator(packs.flatMap(…))`) resolves a
70
+ * fresh discriminated union each time. Hold the array `composePacks` returns
71
+ * and reuse it across the validator, the parser, and the authoring context.
72
+ */
73
+ export declare const createCompositionValidator: <TNode extends PrimitiveNode = PrimitiveNode>(definitions: readonly AnyPrimitiveDefinition[], options?: CompositionValidatorOptions) => ((composition: Composition<TNode>) => CheckedValidationResult<TNode>);
74
+ /** The outcome of `parse`. */
75
+ export interface ParsedComposition {
76
+ /** True when the value matched the schema. Says nothing about id uniqueness. */
77
+ valid: boolean;
78
+ /** Schema failures. Empty when `valid`. */
79
+ errors: ValidationError[];
80
+ /** The parsed document, present only when `valid`. */
81
+ composition?: Composition;
82
+ }
83
+ /**
84
+ * Builds the untrusted-input parser: {@link checkInputBudget}, then the schema only on its copy, reported rather than thrown.
85
+ *
86
+ * Deliberately narrower than {@link createCompositionValidator}. This answers
87
+ * "is this a `Composition`", not "is this a good one" — it does not run the
88
+ * duplicate-id pass or produce warnings, so a composition with two nodes
89
+ * sharing an `id` parses as valid. Id uniqueness is a `validate` guarantee, so
90
+ * a caller that wants the semantic checks runs `validate` on the result.
91
+ *
92
+ * Shares {@link createCompositionValidator}'s memoization identity requirement.
93
+ */
94
+ export declare const createCompositionParser: (definitions: readonly AnyPrimitiveDefinition[], { inputBudget }?: Pick<CompositionValidatorOptions, "inputBudget">) => ((value: unknown) => ParsedComposition);
95
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validate/validation.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EACL,0BAA0B,EAC1B,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,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AAM,mBAAmB,GAAI,KAAK,SAAS,aAAa,EAC7D,QAAQ,uBAAuB,CAAC,KAAK,CAAC,EACtC,OAAO,mBAAmB,KACzB,kBAAkB,CAAC,KAAK,CAO1B,CAAC;AAEF,sDAAsD;AACtD,MAAM,WAAW,2BAA2B;IAC1C,2EAA2E;IAC3E,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAUD;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,KAAK,SAAS,aAAa,GAAG,aAAa,EAE3C,aAAa,SAAS,sBAAsB,EAAE,EAC9C,UAAS,2BAAgC,KACxC,CAAC,CAAC,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,KAAK,uBAAuB,CAAC,KAAK,CAAC,CAkCtE,CAAC;AAEF,8BAA8B;AAC9B,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,KAAK,EAAE,OAAO,CAAC;IACf,2CAA2C;IAC3C,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,sDAAsD;IACtD,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAa,SAAS,sBAAsB,EAAE,EAC9C,kBAAiB,IAAI,CAAC,2BAA2B,EAAE,aAAa,CAAM,KACrE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,iBAAiB,CAqBxC,CAAC"}
@@ -0,0 +1,157 @@
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
+ import { childNodePath, createChildNodeWalker, rendersOnSurface, SURFACE_NAMES, } from '../composition/body_node_base.js';
8
+ import { quoteText } from '../composition/one_line.js';
9
+ import { CompositionValidationError, } from '../composition/validation_error.js';
10
+ import { getCompositionSchemaForDefinitions } from './composition_schema.js';
11
+ import { checkInputBudget, isInputRefusal, } from './input_budget.js';
12
+ import { createNodeIssueFormatter } from './node_issues.js';
13
+ const checkedComposition = Symbol.for('elastic.isomer.checked_composition');
14
+ /** Narrows a result's warnings to the surface a caller is about to render. */
15
+ export const warningsForSurface = (result, surface) => result.warnings.filter((warning) => warning.surface === surface);
16
+ export { CompositionValidationError };
17
+ /** 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. */
18
+ export const enforceValidationMode = (result, mode) => {
19
+ if (!result.valid &&
20
+ (mode === 'throw' || result.errors.some(isInputRefusal))) {
21
+ throw new CompositionValidationError(result.errors);
22
+ }
23
+ };
24
+ /** 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. */
25
+ export const compositionToRender = (result, mode) => {
26
+ enforceValidationMode(result, mode);
27
+ const { composition } = result;
28
+ if (composition === undefined) {
29
+ throw new CompositionValidationError(result.errors);
30
+ }
31
+ return composition;
32
+ };
33
+ /** The body's nodes, as {@link IssueRoot}s for a node issue formatter. */
34
+ const bodyRoots = (value) => {
35
+ const { body } = (value ?? {});
36
+ return Array.isArray(body)
37
+ ? body.map((node, index) => [node, `body[${index}]`])
38
+ : [];
39
+ };
40
+ /**
41
+ * Builds the trusted-input validator: {@link checkInputBudget}, then the schema and the semantic passes on its copy, which the result carries.
42
+ *
43
+ * `definitions` is memoized on array identity, so a caller that rebuilds the
44
+ * array per call (`createCompositionValidator(packs.flatMap(…))`) resolves a
45
+ * fresh discriminated union each time. Hold the array `composePacks` returns
46
+ * and reuse it across the validator, the parser, and the authoring context.
47
+ */
48
+ export const createCompositionValidator = (definitions, options = {}) => {
49
+ const schema = getCompositionSchemaForDefinitions(definitions);
50
+ const walk = createChildNodeWalker(definitions);
51
+ const formatIssues = createNodeIssueFormatter(definitions);
52
+ return (composition) => {
53
+ const checked = checkInputBudget(composition, options.inputBudget);
54
+ if (!checked.valid) {
55
+ return {
56
+ valid: false,
57
+ errors: [checked.error],
58
+ warnings: [],
59
+ composition: undefined,
60
+ };
61
+ }
62
+ const plain = checked.value;
63
+ const result = schema.safeParse(plain, { reportInput: true });
64
+ if (result.success) {
65
+ const { body } = plain;
66
+ const idErrors = collectDuplicateNodeIdErrors(body, walk);
67
+ const warnings = collectEmptySurfaceWarnings(body, walk);
68
+ return {
69
+ valid: idErrors.length === 0,
70
+ errors: idErrors,
71
+ warnings,
72
+ composition: plain,
73
+ };
74
+ }
75
+ return {
76
+ valid: false,
77
+ errors: formatIssues(bodyRoots(plain), result.error.issues),
78
+ warnings: [],
79
+ composition: plain,
80
+ };
81
+ };
82
+ };
83
+ /**
84
+ * Builds the untrusted-input parser: {@link checkInputBudget}, then the schema only on its copy, reported rather than thrown.
85
+ *
86
+ * Deliberately narrower than {@link createCompositionValidator}. This answers
87
+ * "is this a `Composition`", not "is this a good one" — it does not run the
88
+ * duplicate-id pass or produce warnings, so a composition with two nodes
89
+ * sharing an `id` parses as valid. Id uniqueness is a `validate` guarantee, so
90
+ * a caller that wants the semantic checks runs `validate` on the result.
91
+ *
92
+ * Shares {@link createCompositionValidator}'s memoization identity requirement.
93
+ */
94
+ export const createCompositionParser = (definitions, { inputBudget } = {}) => {
95
+ const schema = getCompositionSchemaForDefinitions(definitions);
96
+ const formatIssues = createNodeIssueFormatter(definitions);
97
+ return (value) => {
98
+ const checked = checkInputBudget(value, inputBudget);
99
+ if (!checked.valid) {
100
+ return { valid: false, errors: [checked.error] };
101
+ }
102
+ const result = schema.safeParse(checked.value, { reportInput: true });
103
+ if (result.success) {
104
+ return {
105
+ valid: true,
106
+ errors: [],
107
+ composition: result.data,
108
+ };
109
+ }
110
+ return {
111
+ valid: false,
112
+ errors: formatIssues(bodyRoots(checked.value), result.error.issues),
113
+ };
114
+ };
115
+ };
116
+ /** Warns once per surface that the whole body renders nothing on. */
117
+ const collectEmptySurfaceWarnings = (body, walk) => SURFACE_NAMES.filter((surface) => !body.some((node) => rendersOnSurface(node, surface, walk))).map((surface) => ({
118
+ surface,
119
+ message: `composition renders no nodes on surface "${surface}"`,
120
+ }));
121
+ /**
122
+ * Errors for each node whose `id` repeats one already seen, naming the first
123
+ * use.
124
+ *
125
+ * Errors rather than warnings, because ids are what a host addresses a node by.
126
+ * Run by `validate` and deliberately not by `parse`; see
127
+ * {@link createCompositionParser}.
128
+ */
129
+ const collectDuplicateNodeIdErrors = (body, walk) => {
130
+ const errors = [];
131
+ const seen = new Map();
132
+ const visit = (node, path) => {
133
+ if (!node || typeof node !== 'object') {
134
+ return;
135
+ }
136
+ const { id, type } = node;
137
+ if (typeof id === 'string') {
138
+ const first = seen.get(id);
139
+ if (first) {
140
+ errors.push({
141
+ path: `${path}.id`,
142
+ message: `duplicates id ${quoteText(id)} first used at ${first}`,
143
+ ...(typeof type === 'string' ? { nodeType: type } : {}),
144
+ });
145
+ }
146
+ else {
147
+ seen.set(id, path);
148
+ }
149
+ }
150
+ walk(node).forEach(({ node: child, path: field }) => {
151
+ visit(child, childNodePath(path, field));
152
+ });
153
+ };
154
+ body.forEach((node, index) => visit(node, `body[${index}]`));
155
+ return errors;
156
+ };
157
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/validate/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,GAEd,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EACL,0BAA0B,GAE3B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,kCAAkC,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EACL,gBAAgB,EAEhB,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAkB,MAAM,eAAe,CAAC;AAsCzE,MAAM,kBAA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,EAAE,IAAI,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;YAClD,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,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 childNodePath,\n createChildNodeWalker,\n rendersOnSurface,\n SURFACE_NAMES,\n type SurfaceName,\n} from '../composition/body_node_base';\nimport type { Composition } from '../composition/composition';\nimport type { PrimitiveNode } from '../composition/node';\nimport { quoteText } from '../composition/one_line';\nimport {\n CompositionValidationError,\n type ValidationError,\n} from '../composition/validation_error';\nimport type { AnyPrimitiveDefinition } from '../define/primitive_module';\n\nimport { getCompositionSchemaForDefinitions } from './composition_schema';\nimport {\n checkInputBudget,\n type InputBudget,\n isInputRefusal,\n} from './input_budget';\nimport { createNodeIssueFormatter, type IssueRoot } from './node_issues';\n\n/**\n * A non-fatal validation finding, scoped to the surface it concerns.\n *\n * Warnings carry `surface` because every one of them is a statement about one\n * render target — a composition that draws nothing on `slack` is not news to a\n * caller rendering HTML. Without the scope a host receives every surface's\n * findings on every call and learns to ignore the channel.\n * {@link warningsForSurface} is the filter.\n */\nexport interface ValidationWarning {\n /** The render target this finding concerns, never the composition as a whole. */\n surface: SurfaceName;\n /**\n * Path of the offending node within the composition, absent for\n * whole-composition findings.\n */\n path?: string;\n /** Safe to show a user, and phrased for whoever can act on it. */\n message: string;\n}\n\n/**\n * The outcome of `validate`: errors are fatal, warnings are advisory.\n *\n * `valid` tracks `errors` only — a composition can be valid and still carry\n * warnings, which is the normal case for a surface gap.\n */\nexport interface ValidationResult {\n /** True when `errors` is empty, regardless of `warnings`. */\n valid: boolean;\n /** Fatal findings. Empty when `valid`. */\n errors: ValidationError[];\n /** Advisory findings, empty when there are none. */\n warnings: ValidationWarning[];\n}\n\nconst checkedComposition = Symbol.for('elastic.isomer.checked_composition');\n\n/** The copy {@link createCompositionValidator} checked, which a validating render draws in place of the caller's value. The brand is type-only. */\nexport type CheckedComposition<TNode extends PrimitiveNode = PrimitiveNode> =\n Composition<TNode> & { readonly [checkedComposition]: true };\n\n/** A {@link ValidationResult} with the composition it describes. */\nexport interface CheckedValidationResult<\n TNode extends PrimitiveNode = PrimitiveNode,\n> extends ValidationResult {\n /** Undefined only when {@link checkInputBudget} refused the input. */\n composition: CheckedComposition<TNode> | undefined;\n}\n\n/** Narrows a result's warnings to the surface a caller is about to render. */\nexport const warningsForSurface = (\n result: ValidationResult,\n surface: SurfaceName\n): ValidationWarning[] =>\n result.warnings.filter((warning) => warning.surface === surface);\n\n/** Whether a render reports validation findings or raises on them. */\nexport type ValidationErrorMode = 'collect' | 'throw';\n\nexport { CompositionValidationError };\n\n/** Raises {@link CompositionValidationError} when `mode` is `throw` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input, which nothing can render. */\nexport const enforceValidationMode = (\n result: ValidationResult,\n mode?: ValidationErrorMode\n): void => {\n if (\n !result.valid &&\n (mode === 'throw' || result.errors.some(isInputRefusal))\n ) {\n throw new CompositionValidationError(result.errors);\n }\n};\n\n/** The composition `result` checked, which is what a render draws. Throws {@link CompositionValidationError} when `mode` is `'throw'` and `result` is invalid, or in any mode when {@link checkInputBudget} refused the input. */\nexport const compositionToRender = <TNode extends PrimitiveNode>(\n result: CheckedValidationResult<TNode>,\n mode?: ValidationErrorMode\n): CheckedComposition<TNode> => {\n enforceValidationMode(result, mode);\n const { composition } = result;\n if (composition === undefined) {\n throw new CompositionValidationError(result.errors);\n }\n return composition;\n};\n\n/** Options for {@link createCompositionValidator}. */\nexport interface CompositionValidatorOptions {\n /** Limits checked before the schema runs; see {@link checkInputBudget}. */\n inputBudget?: InputBudget;\n}\n\n/** The body's nodes, as {@link IssueRoot}s for a node issue formatter. */\nconst bodyRoots = (value: unknown): IssueRoot[] => {\n const { body } = (value ?? {}) as { body?: unknown };\n return Array.isArray(body)\n ? body.map((node, index) => [node, `body[${index}]`] as const)\n : [];\n};\n\n/**\n * Builds the trusted-input validator: {@link checkInputBudget}, then the schema and the semantic passes on its copy, which the result carries.\n *\n * `definitions` is memoized on array identity, so a caller that rebuilds the\n * array per call (`createCompositionValidator(packs.flatMap(…))`) resolves a\n * fresh discriminated union each time. Hold the array `composePacks` returns\n * and reuse it across the validator, the parser, and the authoring context.\n */\nexport const createCompositionValidator = <\n TNode extends PrimitiveNode = PrimitiveNode,\n>(\n definitions: readonly AnyPrimitiveDefinition[],\n options: CompositionValidatorOptions = {}\n): ((composition: Composition<TNode>) => CheckedValidationResult<TNode>) => {\n const schema = getCompositionSchemaForDefinitions(definitions);\n const walk = createChildNodeWalker(definitions);\n const formatIssues = createNodeIssueFormatter(definitions);\n return (composition) => {\n const checked = checkInputBudget(composition, options.inputBudget);\n if (!checked.valid) {\n return {\n valid: false,\n errors: [checked.error],\n warnings: [],\n composition: undefined,\n };\n }\n const plain = checked.value as CheckedComposition<TNode>;\n const result = schema.safeParse(plain, { reportInput: true });\n if (result.success) {\n const { body } = plain;\n const idErrors = collectDuplicateNodeIdErrors(body, walk);\n const warnings = collectEmptySurfaceWarnings(body, walk);\n return {\n valid: idErrors.length === 0,\n errors: idErrors,\n warnings,\n composition: plain,\n };\n }\n return {\n valid: false,\n errors: formatIssues(bodyRoots(plain), result.error.issues),\n warnings: [],\n composition: plain,\n };\n };\n};\n\n/** The outcome of `parse`. */\nexport interface ParsedComposition {\n /** True when the value matched the schema. Says nothing about id uniqueness. */\n valid: boolean;\n /** Schema failures. Empty when `valid`. */\n errors: ValidationError[];\n /** The parsed document, present only when `valid`. */\n composition?: Composition;\n}\n\n/**\n * Builds the untrusted-input parser: {@link checkInputBudget}, then the schema only on its copy, reported rather than thrown.\n *\n * Deliberately narrower than {@link createCompositionValidator}. This answers\n * \"is this a `Composition`\", not \"is this a good one\" — it does not run the\n * duplicate-id pass or produce warnings, so a composition with two nodes\n * sharing an `id` parses as valid. Id uniqueness is a `validate` guarantee, so\n * a caller that wants the semantic checks runs `validate` on the result.\n *\n * Shares {@link createCompositionValidator}'s memoization identity requirement.\n */\nexport const createCompositionParser = (\n definitions: readonly AnyPrimitiveDefinition[],\n { inputBudget }: Pick<CompositionValidatorOptions, 'inputBudget'> = {}\n): ((value: unknown) => ParsedComposition) => {\n const schema = getCompositionSchemaForDefinitions(definitions);\n const formatIssues = createNodeIssueFormatter(definitions);\n return (value) => {\n const checked = checkInputBudget(value, inputBudget);\n if (!checked.valid) {\n return { valid: false, errors: [checked.error] };\n }\n const result = schema.safeParse(checked.value, { reportInput: true });\n if (result.success) {\n return {\n valid: true,\n errors: [],\n composition: result.data as unknown as Composition,\n };\n }\n return {\n valid: false,\n errors: formatIssues(bodyRoots(checked.value), result.error.issues),\n };\n };\n};\n\n/** Warns once per surface that the whole body renders nothing on. */\nconst collectEmptySurfaceWarnings = (\n body: readonly unknown[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationWarning[] =>\n SURFACE_NAMES.filter(\n (surface) => !body.some((node) => rendersOnSurface(node, surface, walk))\n ).map((surface) => ({\n surface,\n message: `composition renders no nodes on surface \"${surface}\"`,\n }));\n\n/**\n * Errors for each node whose `id` repeats one already seen, naming the first\n * use.\n *\n * Errors rather than warnings, because ids are what a host addresses a node by.\n * Run by `validate` and deliberately not by `parse`; see\n * {@link createCompositionParser}.\n */\nconst collectDuplicateNodeIdErrors = (\n body: readonly unknown[],\n walk: ReturnType<typeof createChildNodeWalker>\n): ValidationError[] => {\n const errors: ValidationError[] = [];\n const seen = new Map<string, string>();\n const visit = (node: unknown, path: string): void => {\n if (!node || typeof node !== 'object') {\n return;\n }\n const { id, type } = node as { id?: unknown; type?: unknown };\n if (typeof id === 'string') {\n const first = seen.get(id);\n if (first) {\n errors.push({\n path: `${path}.id`,\n message: `duplicates id ${quoteText(id)} first used at ${first}`,\n ...(typeof type === 'string' ? { nodeType: type } : {}),\n });\n } else {\n seen.set(id, path);\n }\n }\n walk(node).forEach(({ node: child, path: field }) => {\n visit(child, childNodePath(path, field));\n });\n };\n body.forEach((node, index) => visit(node, `body[${index}]`));\n return errors;\n};\n"]}
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ /** Derived from {@link ALL_NAMED_COLORS} rather than restating the literals. */
3
+ export declare const namedColorSchema: z.ZodEnum<{
4
+ primary: "primary";
5
+ danger: "danger";
6
+ success: "success";
7
+ neutral: "neutral";
8
+ accent: "accent";
9
+ warning: "warning";
10
+ risk: "risk";
11
+ }>;
12
+ /** `RenderTheme`: the light/dark preference a caller asks for. */
13
+ export declare const renderThemeSchema: z.ZodEnum<{
14
+ auto: "auto";
15
+ light: "light";
16
+ dark: "dark";
17
+ }>;
18
+ /**
19
+ * The raw quantity plus a format hint, formatted once in a primitive's model so
20
+ * every surface renders the same string. See `StructuredValue`.
21
+ */
22
+ export declare const structuredValueSchema: z.ZodObject<{
23
+ raw: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
24
+ format: z.ZodOptional<z.ZodEnum<{
25
+ number: "number";
26
+ date: "date";
27
+ compact: "compact";
28
+ percent: "percent";
29
+ currency: "currency";
30
+ bytes: "bytes";
31
+ duration: "duration";
32
+ relativeTime: "relativeTime";
33
+ }>>;
34
+ precision: z.ZodOptional<z.ZodNumber>;
35
+ currency: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>;
37
+ /** Value-bearing fields accept preformatted prose or a structured value. */
38
+ export declare const displayValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
39
+ raw: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
40
+ format: z.ZodOptional<z.ZodEnum<{
41
+ number: "number";
42
+ date: "date";
43
+ compact: "compact";
44
+ percent: "percent";
45
+ currency: "currency";
46
+ bytes: "bytes";
47
+ duration: "duration";
48
+ relativeTime: "relativeTime";
49
+ }>>;
50
+ precision: z.ZodOptional<z.ZodNumber>;
51
+ currency: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strip>]>;
53
+ //# sourceMappingURL=value_schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value_schemas.d.ts","sourceRoot":"","sources":["../../src/validate/value_schemas.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,gFAAgF;AAChF,eAAO,MAAM,gBAAgB;;;;;;;;EAE5B,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,iBAAiB;;;;EAAwC,CAAC;AAEvE;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;iBAiBhC,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;mBAM9B,CAAC"}
@@ -0,0 +1,50 @@
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
+ // Zod for the value shapes the sdk already owns types for: `NamedColor`, and
8
+ // the structured display value.
9
+ //
10
+ // Only the shapes the sdk owns belong here. That is what lets any vocabulary
11
+ // package validate a color or a display value without depending on another
12
+ // pack's schemas.
13
+ import { z } from 'zod';
14
+ import { ALL_NAMED_COLORS } from '../composition/named_color.js';
15
+ import { STRUCTURED_VALUE_FORMATS } from '../composition/structured_value.js';
16
+ import { oneOf } from '../define/zod_format.js';
17
+ import { requiredString } from '../define/zod_helpers.js';
18
+ // An enum whose own message names the accepted values, as validation reports it.
19
+ const closedEnum = (values) => z.enum(values, { error: () => oneOf(values) });
20
+ /** Derived from {@link ALL_NAMED_COLORS} rather than restating the literals. */
21
+ export const namedColorSchema = closedEnum(ALL_NAMED_COLORS);
22
+ /** `RenderTheme`: the light/dark preference a caller asks for. */
23
+ export const renderThemeSchema = closedEnum(['auto', 'light', 'dark']);
24
+ /**
25
+ * The raw quantity plus a format hint, formatted once in a primitive's model so
26
+ * every surface renders the same string. See `StructuredValue`.
27
+ */
28
+ export const structuredValueSchema = z.object({
29
+ raw: z.union([z.number(), requiredString()], {
30
+ error: () => 'must be a finite number or a non-empty string',
31
+ }),
32
+ format: closedEnum(STRUCTURED_VALUE_FORMATS).optional(),
33
+ precision: z
34
+ .number({ error: () => 'must be an integer between 0 and 6' })
35
+ .int({ error: 'must be an integer between 0 and 6' })
36
+ .min(0, { error: 'must be an integer between 0 and 6' })
37
+ .max(6, { error: 'must be an integer between 0 and 6' })
38
+ .optional(),
39
+ currency: z
40
+ .string({ error: () => 'must be a three-letter currency code' })
41
+ .regex(/^[A-Za-z]{3}$/, {
42
+ error: 'must be a three-letter currency code',
43
+ })
44
+ .optional(),
45
+ });
46
+ /** Value-bearing fields accept preformatted prose or a structured value. */
47
+ export const displayValueSchema = z.union([requiredString(), structuredValueSchema], {
48
+ error: () => 'must be a non-empty string or a structured value ({ raw, format?, precision?, currency? })',
49
+ });
50
+ //# 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,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAA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AAK,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;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CACvC,CAAC,cAAc,EAAE,EAAE,qBAAqB,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"]}
package/package.json CHANGED
@@ -1,6 +1,120 @@
1
1
  {
2
- "name": "@elastic/isomer-sdk",
3
- "version": "0.0.0",
4
- "description": "Placeholder to enable Trusted Publisher configuration.",
5
- "repository": { "type": "git", "url": "https://github.com/elastic/isomer" }
6
- }
2
+ "name": "@elastic/isomer-sdk",
3
+ "version": "0.2.0",
4
+ "description": "Shared primitive-pack toolkit for Isomer: the composition contract, validation, and rendering.",
5
+ "license": "Elastic-2.0",
6
+ "author": "Elastic",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/elastic/isomer.git",
10
+ "directory": "packages/isomer-sdk"
11
+ },
12
+ "type": "module",
13
+ "sideEffects": false,
14
+ "engines": {
15
+ "node": ">=22.13.0"
16
+ },
17
+ "main": "./dist/cjs/entries/index.js",
18
+ "module": "./dist/entries/index.js",
19
+ "types": "./dist/entries/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/entries/index.d.ts",
23
+ "import": "./dist/entries/index.js",
24
+ "require": "./dist/cjs/entries/index.js"
25
+ },
26
+ "./html": {
27
+ "types": "./dist/entries/html.d.ts",
28
+ "import": "./dist/entries/html.js",
29
+ "require": "./dist/cjs/entries/html.js"
30
+ },
31
+ "./slack": {
32
+ "types": "./dist/entries/slack.d.ts",
33
+ "import": "./dist/entries/slack.js",
34
+ "require": "./dist/cjs/entries/slack.js"
35
+ },
36
+ "./text": {
37
+ "types": "./dist/entries/text.d.ts",
38
+ "import": "./dist/entries/text.js",
39
+ "require": "./dist/cjs/entries/text.js"
40
+ },
41
+ "./markdown": {
42
+ "types": "./dist/entries/markdown.d.ts",
43
+ "import": "./dist/entries/markdown.js",
44
+ "require": "./dist/cjs/entries/markdown.js"
45
+ },
46
+ "./react": {
47
+ "types": "./dist/entries/react.d.ts",
48
+ "import": "./dist/entries/react.js",
49
+ "require": "./dist/cjs/entries/react.js"
50
+ },
51
+ "./author": {
52
+ "types": "./dist/author/index.d.ts",
53
+ "import": "./dist/author/index.js",
54
+ "require": "./dist/cjs/author/index.js"
55
+ },
56
+ "./testing": {
57
+ "types": "./dist/testing/index.d.ts",
58
+ "import": "./dist/testing/index.js",
59
+ "require": "./dist/cjs/testing/index.js"
60
+ }
61
+ },
62
+ "typesVersions": {
63
+ "*": {
64
+ "html": [
65
+ "./dist/entries/html.d.ts"
66
+ ],
67
+ "slack": [
68
+ "./dist/entries/slack.d.ts"
69
+ ],
70
+ "text": [
71
+ "./dist/entries/text.d.ts"
72
+ ],
73
+ "markdown": [
74
+ "./dist/entries/markdown.d.ts"
75
+ ],
76
+ "react": [
77
+ "./dist/entries/react.d.ts"
78
+ ],
79
+ "author": [
80
+ "./dist/author/index.d.ts"
81
+ ],
82
+ "testing": [
83
+ "./dist/testing/index.d.ts"
84
+ ]
85
+ }
86
+ },
87
+ "files": [
88
+ "dist",
89
+ "NOTICE.txt",
90
+ "THIRD_PARTY_LICENSES.md",
91
+ "LICENSE.txt"
92
+ ],
93
+ "publishConfig": {
94
+ "access": "public"
95
+ },
96
+ "peerDependencies": {
97
+ "react": ">=18 <20",
98
+ "react-dom": ">=18 <20",
99
+ "zod": "^4.4.1"
100
+ },
101
+ "peerDependenciesMeta": {
102
+ "react-dom": {
103
+ "optional": true
104
+ }
105
+ },
106
+ "dependencies": {
107
+ "acorn": "^8.18.0",
108
+ "mdast-util-from-markdown": "^2.0.3",
109
+ "mdast-util-gfm": "^3.1.0",
110
+ "mdast-util-to-markdown": "^2.1.2",
111
+ "micromark-extension-gfm": "^3.0.0"
112
+ },
113
+ "devDependencies": {
114
+ "@types/mdast": "^4.0.4",
115
+ "parse5": "^7.3.0"
116
+ },
117
+ "scripts": {
118
+ "typecheck": "tsc -p tsconfig.json --noEmit"
119
+ }
120
+ }