@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 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/composition/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,mDAU0B;AALxB,oHAAA,kBAAkB,OAAA;AAClB,+GAAA,aAAa,OAAA;AACb,uHAAA,qBAAqB,OAAA;AACrB,oHAAA,kBAAkB,OAAA;AAClB,8GAAA,YAAY,OAAA;AAGd,iCAAgF;AAAjD,2GAAA,kBAAkB,OAAA;AAAE,oGAAA,WAAW,OAAA;AAC9D,yCAAkD;AAAzC,gHAAA,mBAAmB,OAAA;AAC5B,6CAKuB;AADrB,+GAAA,gBAAgB,OAAA;AAGlB,uCAA0D;AAAjD,oGAAA,QAAQ,OAAA;AAAE,mGAAA,OAAO,OAAA;AAAE,qGAAA,SAAS,OAAA;AACrC,uDAK4B;AAD1B,4HAAA,wBAAwB,OAAA;AAE1B,uDAI4B;AAF1B,8HAAA,0BAA0B,OAAA;AAC1B,yHAAA,qBAAqB,OAAA","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nexport { type ActionEventRef } from './action_event';\nexport {\n type BodyNodeBase,\n type ChildNodeRef,\n type ChildNodeWalker,\n type SurfaceName,\n BODY_NODE_SURFACES,\n SURFACE_NAMES,\n createChildNodeWalker,\n isVisibleOnSurface,\n someBodyNode,\n} from './body_node_base';\nexport { type Composition, type CompositionMeta } from './composition';\nexport { type IsomerErrorCode, ISOMER_ERROR_CODES, IsomerError } from './error';\nexport { mapCompositionNodes } from './map_nodes';\nexport {\n type NamedColor,\n type NamedColorPalette,\n type RenderTheme,\n ALL_NAMED_COLORS,\n} from './named_color';\nexport { type PrimitiveNode } from './node';\nexport { nameText, oneLine, quoteText } from './one_line';\nexport {\n type DisplayValue,\n type StructuredValue,\n type StructuredValueFormat,\n STRUCTURED_VALUE_FORMATS,\n} from './structured_value';\nexport {\n type ValidationError,\n CompositionValidationError,\n formatValidationError,\n} from './validation_error';\n"]}
@@ -0,0 +1,85 @@
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.mapCompositionNodes = void 0;
10
+ const error_1 = require("./error");
11
+ /** One dotted step of a child path: `field` or `field[index]`. */
12
+ const PATH_STEP = /^([A-Za-z_$][\w$]*)(?:\[(\d+)\])?$/;
13
+ const unsupportedPath = (path) => new error_1.IsomerError('UNSUPPORTED_CHILD_PATH', `mapCompositionNodes: cannot rewrite child at path "${path}"; expected dotted "field" or "field[index]" steps`);
14
+ /** `parent` with the value at `steps` replaced, every touched object and array copied. */
15
+ const withValueAt = (parent, steps, value, path) => {
16
+ const [step, ...rest] = steps;
17
+ const match = step === undefined ? null : PATH_STEP.exec(step);
18
+ if (!match || typeof parent !== 'object' || parent === null) {
19
+ throw unsupportedPath(path);
20
+ }
21
+ const field = match[1];
22
+ const record = parent;
23
+ if (match[2] === undefined) {
24
+ const next = rest.length === 0 ? value : withValueAt(record[field], rest, value, path);
25
+ return { ...record, [field]: next };
26
+ }
27
+ const index = Number(match[2]);
28
+ const current = record[field];
29
+ if (!Array.isArray(current)) {
30
+ throw unsupportedPath(path);
31
+ }
32
+ const array = [...current];
33
+ array[index] =
34
+ rest.length === 0 ? value : withValueAt(array[index], rest, value, path);
35
+ return { ...record, [field]: array };
36
+ };
37
+ /**
38
+ * Rebuilds `composition`'s body with `fn` applied to every node, including
39
+ * the nested children `walk` yields.
40
+ *
41
+ * Post-order: a container reaches `fn` after its children have been mapped,
42
+ * so `fn` sees the finished replacements in place. Build `walk` with
43
+ * {@link createChildNodeWalker} over every pack in the composition.
44
+ * A child path is the dotted `field` / `field[index]` form the SDK documents
45
+ * (`items[0].node`); any other shape throws `UNSUPPORTED_CHILD_PATH`.
46
+ * Walked without recursion, so depth is bounded by memory, not the call stack; a node nested in itself throws `CYCLIC_COMPOSITION`.
47
+ */
48
+ const mapCompositionNodes = (composition, walk, fn) => {
49
+ const mapNode = (root) => {
50
+ const open = new Set();
51
+ const stack = [];
52
+ const enter = (node) => {
53
+ if (open.has(node)) {
54
+ throw new error_1.IsomerError('CYCLIC_COMPOSITION', 'mapCompositionNodes: a node is nested in itself');
55
+ }
56
+ open.add(node);
57
+ stack.push({ node, children: walk(node), next: 0, result: node });
58
+ };
59
+ enter(root);
60
+ for (;;) {
61
+ const frame = stack[stack.length - 1];
62
+ const child = frame.children[frame.next];
63
+ if (child) {
64
+ enter(child.node);
65
+ continue;
66
+ }
67
+ stack.pop();
68
+ open.delete(frame.node);
69
+ const mapped = fn(frame.result);
70
+ const parent = stack[stack.length - 1];
71
+ if (!parent) {
72
+ return mapped;
73
+ }
74
+ const { path } = parent.children[parent.next];
75
+ parent.result = withValueAt(parent.result, path.split('.'), mapped, path);
76
+ parent.next += 1;
77
+ }
78
+ };
79
+ return {
80
+ ...composition,
81
+ body: composition.body.map((node) => mapNode(node)),
82
+ };
83
+ };
84
+ exports.mapCompositionNodes = mapCompositionNodes;
85
+ //# sourceMappingURL=map_nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map_nodes.js","sourceRoot":"","sources":["../../../src/composition/map_nodes.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,mCAAsC;AAGtC,kEAAkE;AAClE,MAAM,SAAS,GAAG,oCAAoC,CAAC;AAEvD,MAAM,eAAe,GAAG,CAAC,IAAY,EAAe,EAAE,CACpD,IAAI,mBAAW,CACb,wBAAwB,EACxB,sDAAsD,IAAI,oDAAoD,CAC/G,CAAC;AAEJ,0FAA0F;AAC1F,MAAM,WAAW,GAAG,CAClB,MAAe,EACf,KAAwB,EACxB,KAAc,EACd,IAAY,EACH,EAAE;IACX,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,IAAI,CAAC,KAAK,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAC5D,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAW,CAAC;IACjC,MAAM,MAAM,GAAG,MAAiC,CAAC;IACjD,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,GACR,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC5E,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACtC,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,GAAI,OAAqB,CAAC,CAAC;IAC1C,KAAK,CAAC,KAAK,CAAC;QACV,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3E,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;AACvC,CAAC,CAAC;AAUF;;;;;;;;;;GAUG;AACI,MAAM,mBAAmB,GAAG,CAGjC,WAA+B,EAC/B,IAAqB,EACrB,EAA0C,EACtB,EAAE;IACtB,MAAM,OAAO,GAAG,CAAC,IAAmB,EAAiB,EAAE;QACrD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAiB,CAAC;QACtC,MAAM,KAAK,GAAY,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,CAAC,IAAmB,EAAE,EAAE;YACpC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,MAAM,IAAI,mBAAW,CACnB,oBAAoB,EACpB,iDAAiD,CAClD,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC;QACF,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,SAAS,CAAC;YACR,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;YACvC,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzC,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,KAAK,CAAC,IAAqB,CAAC,CAAC;gBACnC,SAAS;YACX,CAAC;YACD,KAAK,CAAC,GAAG,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxB,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAChC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACvC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAE,CAAC;YAC/C,MAAM,CAAC,MAAM,GAAG,WAAW,CACzB,MAAM,CAAC,MAAM,EACb,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EACf,MAAM,EACN,IAAI,CACY,CAAC;YACnB,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;IACF,OAAO;QACL,GAAG,WAAW;QACd,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAU,CAAC;KAC7D,CAAC;AACJ,CAAC,CAAC;AAjDW,QAAA,mBAAmB,uBAiD9B","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 { ChildNodeRef, ChildNodeWalker } from './body_node_base';\nimport type { Composition } from './composition';\nimport { IsomerError } from './error';\nimport type { PrimitiveNode } from './node';\n\n/** One dotted step of a child path: `field` or `field[index]`. */\nconst PATH_STEP = /^([A-Za-z_$][\\w$]*)(?:\\[(\\d+)\\])?$/;\n\nconst unsupportedPath = (path: string): IsomerError =>\n new IsomerError(\n 'UNSUPPORTED_CHILD_PATH',\n `mapCompositionNodes: cannot rewrite child at path \"${path}\"; expected dotted \"field\" or \"field[index]\" steps`\n );\n\n/** `parent` with the value at `steps` replaced, every touched object and array copied. */\nconst withValueAt = (\n parent: unknown,\n steps: readonly string[],\n value: unknown,\n path: string\n): unknown => {\n const [step, ...rest] = steps;\n const match = step === undefined ? null : PATH_STEP.exec(step);\n if (!match || typeof parent !== 'object' || parent === null) {\n throw unsupportedPath(path);\n }\n const field = match[1] as string;\n const record = parent as Record<string, unknown>;\n if (match[2] === undefined) {\n const next =\n rest.length === 0 ? value : withValueAt(record[field], rest, value, path);\n return { ...record, [field]: next };\n }\n const index = Number(match[2]);\n const current = record[field];\n if (!Array.isArray(current)) {\n throw unsupportedPath(path);\n }\n const array = [...(current as unknown[])];\n array[index] =\n rest.length === 0 ? value : withValueAt(array[index], rest, value, path);\n return { ...record, [field]: array };\n};\n\n/** A node being mapped: its children, how many are done, and its copy so far. */\ninterface Frame {\n node: PrimitiveNode;\n children: ChildNodeRef[];\n next: number;\n result: PrimitiveNode;\n}\n\n/**\n * Rebuilds `composition`'s body with `fn` applied to every node, including\n * the nested children `walk` yields.\n *\n * Post-order: a container reaches `fn` after its children have been mapped,\n * so `fn` sees the finished replacements in place. Build `walk` with\n * {@link createChildNodeWalker} over every pack in the composition.\n * A child path is the dotted `field` / `field[index]` form the SDK documents\n * (`items[0].node`); any other shape throws `UNSUPPORTED_CHILD_PATH`.\n * Walked without recursion, so depth is bounded by memory, not the call stack; a node nested in itself throws `CYCLIC_COMPOSITION`.\n */\nexport const mapCompositionNodes = <\n TNode extends PrimitiveNode = PrimitiveNode,\n>(\n composition: Composition<TNode>,\n walk: ChildNodeWalker,\n fn: (node: PrimitiveNode) => PrimitiveNode\n): Composition<TNode> => {\n const mapNode = (root: PrimitiveNode): PrimitiveNode => {\n const open = new Set<PrimitiveNode>();\n const stack: Frame[] = [];\n const enter = (node: PrimitiveNode) => {\n if (open.has(node)) {\n throw new IsomerError(\n 'CYCLIC_COMPOSITION',\n 'mapCompositionNodes: a node is nested in itself'\n );\n }\n open.add(node);\n stack.push({ node, children: walk(node), next: 0, result: node });\n };\n enter(root);\n for (;;) {\n const frame = stack[stack.length - 1]!;\n const child = frame.children[frame.next];\n if (child) {\n enter(child.node as PrimitiveNode);\n continue;\n }\n stack.pop();\n open.delete(frame.node);\n const mapped = fn(frame.result);\n const parent = stack[stack.length - 1];\n if (!parent) {\n return mapped;\n }\n const { path } = parent.children[parent.next]!;\n parent.result = withValueAt(\n parent.result,\n path.split('.'),\n mapped,\n path\n ) as PrimitiveNode;\n parent.next += 1;\n }\n };\n return {\n ...composition,\n body: composition.body.map((node) => mapNode(node) as TNode),\n };\n};\n"]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0; you may not use this file except in compliance with the Elastic License
6
+ * 2.0.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ALL_NAMED_COLORS = void 0;
10
+ /** Every {@link NamedColor}, and the source `namedColorSchema` derives from. */
11
+ exports.ALL_NAMED_COLORS = [
12
+ 'neutral',
13
+ 'primary',
14
+ 'accent',
15
+ 'success',
16
+ 'warning',
17
+ 'risk',
18
+ 'danger',
19
+ ];
20
+ //# sourceMappingURL=named_color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"named_color.js","sourceRoot":"","sources":["../../../src/composition/named_color.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAMH,gFAAgF;AACnE,QAAA,gBAAgB,GAA0B;IACrD,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;IACT,SAAS;IACT,MAAM;IACN,QAAQ;CACT,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/** Portable color names shared by primitive packs and renderers. An exact subset of EUI's `NamedColor`. */\nexport type NamedColor =\n 'neutral' | 'primary' | 'accent' | 'success' | 'warning' | 'risk' | 'danger';\n\n/** Every {@link NamedColor}, and the source `namedColorSchema` derives from. */\nexport const ALL_NAMED_COLORS: readonly NamedColor[] = [\n 'neutral',\n 'primary',\n 'accent',\n 'success',\n 'warning',\n 'risk',\n 'danger',\n];\n\n/** Light/dark preference. `auto` resolves light wherever media queries are unavailable. */\nexport type RenderTheme = 'auto' | 'light' | 'dark';\n\n/** A pack's colors by name. Partial: an unmapped name falls back to the renderer's default. */\nexport type NamedColorPalette = Partial<Record<NamedColor, string>>;\n"]}
@@ -0,0 +1,9 @@
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
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/composition/node.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 { BodyNodeBase } from './body_node_base';\n\n/**\n * One node in a `Composition`'s body, erased to its discriminator.\n *\n * A pack narrows `type` to its own literal union; the SDK holds this form\n * because a heterogeneous inventory has no single node type to name.\n */\nexport interface PrimitiveNode extends BodyNodeBase {\n type: string;\n}\n"]}
@@ -0,0 +1,23 @@
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.nameText = exports.quoteText = exports.oneLine = void 0;
10
+ const LINE_TERMINATOR_RE = /[\r\n\u2028\u2029]/;
11
+ /** `text` on one line: each run of whitespace holding a line terminator becomes one space, and other whitespace stays as is. */
12
+ const oneLine = (text) => text.replace(/\s+/g, (run) => (LINE_TERMINATOR_RE.test(run) ? ' ' : run));
13
+ exports.oneLine = oneLine;
14
+ /** `text` as a JSON string on one line: `JSON.stringify` leaves U+2028 and U+2029 raw. */
15
+ const quoteText = (text) => JSON.stringify(text)
16
+ .replace(/\u2028/g, '\\u2028')
17
+ .replace(/\u2029/g, '\\u2029');
18
+ exports.quoteText = quoteText;
19
+ const PLAIN_NAME = /^[\w$-]+$/;
20
+ /** A name for a one-line message: as it is when plain, else as {@link quoteText} quotes it. */
21
+ const nameText = (name) => PLAIN_NAME.test(name) ? name : (0, exports.quoteText)(name);
22
+ exports.nameText = nameText;
23
+ //# sourceMappingURL=one_line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one_line.js","sourceRoot":"","sources":["../../../src/composition/one_line.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEhD,gIAAgI;AACzH,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,CAC9C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAD/D,QAAA,OAAO,WACwD;AAE5E,0FAA0F;AACnF,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE,CAChD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KACjB,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC;KAC7B,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAHtB,QAAA,SAAS,aAGa;AAEnC,MAAM,UAAU,GAAG,WAAW,CAAC;AAE/B,+FAA+F;AACxF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE,CAC/C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,IAAI,CAAC,CAAC;AADpC,QAAA,QAAQ,YAC4B","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\nconst LINE_TERMINATOR_RE = /[\\r\\n\\u2028\\u2029]/;\n\n/** `text` on one line: each run of whitespace holding a line terminator becomes one space, and other whitespace stays as is. */\nexport const oneLine = (text: string): string =>\n text.replace(/\\s+/g, (run) => (LINE_TERMINATOR_RE.test(run) ? ' ' : run));\n\n/** `text` as a JSON string on one line: `JSON.stringify` leaves U+2028 and U+2029 raw. */\nexport const quoteText = (text: string): string =>\n JSON.stringify(text)\n .replace(/\\u2028/g, '\\\\u2028')\n .replace(/\\u2029/g, '\\\\u2029');\n\nconst PLAIN_NAME = /^[\\w$-]+$/;\n\n/** A name for a one-line message: as it is when plain, else as {@link quoteText} quotes it. */\nexport const nameText = (name: string): string =>\n PLAIN_NAME.test(name) ? name : quoteText(name);\n"]}
@@ -0,0 +1,21 @@
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.STRUCTURED_VALUE_FORMATS = void 0;
10
+ /** Format hints a {@link StructuredValue} may carry. */
11
+ exports.STRUCTURED_VALUE_FORMATS = [
12
+ 'number',
13
+ 'compact',
14
+ 'percent',
15
+ 'currency',
16
+ 'bytes',
17
+ 'duration',
18
+ 'date',
19
+ 'relativeTime',
20
+ ];
21
+ //# sourceMappingURL=structured_value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structured_value.js","sourceRoot":"","sources":["../../../src/composition/structured_value.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,wDAAwD;AAC3C,QAAA,wBAAwB,GAAG;IACtC,QAAQ;IACR,SAAS;IACT,SAAS;IACT,UAAU;IACV,OAAO;IACP,UAAU;IACV,MAAM;IACN,cAAc;CACN,CAAC","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n/** Format hints a {@link StructuredValue} may carry. */\nexport const STRUCTURED_VALUE_FORMATS = [\n 'number',\n 'compact',\n 'percent',\n 'currency',\n 'bytes',\n 'duration',\n 'date',\n 'relativeTime',\n] as const;\n\n/** One of {@link STRUCTURED_VALUE_FORMATS}. */\nexport type StructuredValueFormat = (typeof STRUCTURED_VALUE_FORMATS)[number];\n\n/**\n * A raw quantity plus a format hint, so every surface renders the same string.\n *\n * Formatting happens once, in `formatDisplayValue`, rather than per renderer —\n * otherwise the text and Slack surfaces drift on rounding.\n */\nexport interface StructuredValue {\n /** Unformatted, in base units — a `percent` of `0.42` renders as 42%. */\n raw: number | string;\n /** How to render `raw`. Absent passes a string through and gives a number default formatting. */\n format?: StructuredValueFormat;\n /**\n * Fraction digits for numeric formats. `number`, `percent`, and `currency`\n * pad to it; omitted, `number` and `percent` keep at most two and `currency`\n * two. `compact` and `bytes` drop trailing zeros and keep one when omitted.\n */\n precision?: number;\n /** Three-letter currency code for `currency`; defaults to USD. */\n currency?: string;\n}\n\n/** A value-bearing field: preformatted prose, or a {@link StructuredValue} to format. */\nexport type DisplayValue = string | StructuredValue;\n"]}
@@ -0,0 +1,40 @@
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.CompositionValidationError = exports.formatValidationError = void 0;
10
+ const error_1 = require("./error");
11
+ const one_line_1 = require("./one_line");
12
+ /** `<path> (in <nodeType>) <message>`, or the message alone for a root finding. */
13
+ const formatValidationError = ({ path, message, nodeType, }) => {
14
+ if (!path) {
15
+ return message;
16
+ }
17
+ return nodeType === undefined
18
+ ? `${path} ${message}`
19
+ : `${path} (in ${(0, one_line_1.nameText)(nodeType)}) ${message}`;
20
+ };
21
+ exports.formatValidationError = formatValidationError;
22
+ /**
23
+ * Thrown when a `Composition` fails validation, carrying every finding
24
+ * rather than only the first.
25
+ *
26
+ * Identify it by `name`, `code`, and `errors`, never `instanceof`: the SDK
27
+ * ships both ESM and CJS builds, so a host can hold two copies of this class
28
+ * and an identity check would miss one.
29
+ */
30
+ class CompositionValidationError extends Error {
31
+ code = error_1.ISOMER_ERROR_CODES.COMPOSITION_INVALID;
32
+ errors;
33
+ constructor(errors) {
34
+ super(`Invalid Composition:\n ${errors.map(exports.formatValidationError).join('\n ') || '(no detail)'}`);
35
+ this.name = 'CompositionValidationError';
36
+ this.errors = errors;
37
+ }
38
+ }
39
+ exports.CompositionValidationError = CompositionValidationError;
40
+ //# sourceMappingURL=validation_error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation_error.js","sourceRoot":"","sources":["../../../src/composition/validation_error.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAmE;AACnE,yCAAsC;AAmBtC,mFAAmF;AAC5E,MAAM,qBAAqB,GAAG,CAAC,EACpC,IAAI,EACJ,OAAO,EACP,QAAQ,GACQ,EAAU,EAAE;IAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,QAAQ,KAAK,SAAS;QAC3B,CAAC,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE;QACtB,CAAC,CAAC,GAAG,IAAI,QAAQ,IAAA,mBAAQ,EAAC,QAAQ,CAAC,KAAK,OAAO,EAAE,CAAC;AACtD,CAAC,CAAC;AAXW,QAAA,qBAAqB,yBAWhC;AAEF;;;;;;;GAOG;AACH,MAAa,0BAA2B,SAAQ,KAAK;IAC1C,IAAI,GAAG,0BAAkB,CAAC,mBAAmB,CAAC;IAC9C,MAAM,CAAoB;IAEnC,YAAY,MAAyB;QACnC,KAAK,CACH,2BACE,MAAM,CAAC,GAAG,CAAC,6BAAqB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,aACpD,EAAE,CACH,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAbD,gEAaC","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 { ISOMER_ERROR_CODES, type IsomerErrorCode } from './error';\nimport { nameText } from './one_line';\n\n/**\n * One fatal validation finding.\n *\n * `path` locates the offending value (`body[3].items[0].label`) and is empty\n * for a finding about the document as a whole. `message` is a predicate\n * (`is required`, `must be one of: a, b`) so the two read as one sentence\n * through {@link formatValidationError}.\n */\nexport interface ValidationError {\n path: string;\n message: string;\n /** The `type` of the innermost primitive node `path` lands in, when there is one. */\n nodeType?: string;\n /** Set only on a refusal from `checkInputBudget`: `INPUT_OVER_BUDGET` or `INPUT_NOT_PLAIN_DATA`. */\n code?: IsomerErrorCode;\n}\n\n/** `<path> (in <nodeType>) <message>`, or the message alone for a root finding. */\nexport const formatValidationError = ({\n path,\n message,\n nodeType,\n}: ValidationError): string => {\n if (!path) {\n return message;\n }\n return nodeType === undefined\n ? `${path} ${message}`\n : `${path} (in ${nameText(nodeType)}) ${message}`;\n};\n\n/**\n * Thrown when a `Composition` fails validation, carrying every finding\n * rather than only the first.\n *\n * Identify it by `name`, `code`, and `errors`, never `instanceof`: the SDK\n * ships both ESM and CJS builds, so a host can hold two copies of this class\n * and an identity check would miss one.\n */\nexport class CompositionValidationError extends Error {\n readonly code = ISOMER_ERROR_CODES.COMPOSITION_INVALID;\n readonly errors: ValidationError[];\n\n constructor(errors: ValidationError[]) {\n super(\n `Invalid Composition:\\n ${\n errors.map(formatValidationError).join('\\n ') || '(no detail)'\n }`\n );\n this.name = 'CompositionValidationError';\n this.errors = errors;\n }\n}\n"]}
@@ -0,0 +1,31 @@
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.bindFrame = void 0;
10
+ /**
11
+ * Erases a {@link Frame}'s `TTheme` into a {@link BoundFrame}, resolving the
12
+ * palette per render and composing the generic body walk with the frame's own
13
+ * surround.
14
+ */
15
+ const bindFrame = (frame) => {
16
+ const themeFor = (mode) => mode === 'dark' ? frame.theme.dark : frame.theme.light;
17
+ return {
18
+ defaultWidth: frame.defaultWidth,
19
+ estimateHeight: (composition, dispatcher) => frame.estimateHeight(composition, dispatcher),
20
+ validateBody: (body) => frame.validateBody?.(body) ?? [],
21
+ resolveTheme: (mode) => themeFor(mode),
22
+ render: (composition, viewport, dispatcher) => {
23
+ const theme = themeFor(viewport.mode);
24
+ const { title, subtitle, theme: mode } = composition;
25
+ return frame.wrap({ title, subtitle, theme: mode }, composition.body.map((node, index) => dispatcher.renderSnapshot(node, `body-${index}`)), { ...viewport, theme });
26
+ },
27
+ renderNode: (node, dispatcher) => dispatcher.renderSnapshot(node, node.type),
28
+ };
29
+ };
30
+ exports.bindFrame = bindFrame;
31
+ //# sourceMappingURL=frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.js","sourceRoot":"","sources":["../../../src/define/frame.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA8KH;;;;GAIG;AACI,MAAM,SAAS,GAAG,CAAS,KAAoB,EAAc,EAAE;IACpE,MAAM,QAAQ,GAAG,CAAC,IAA6B,EAAU,EAAE,CACzD,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;IACzD,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,CAC1C,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,UAAU,CAAC;QAC/C,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE;QACxD,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtC,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE;YAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACtC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;YACrD,OAAO,KAAK,CAAC,IAAI,CACf,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAChC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACnC,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,KAAK,EAAE,CAAC,CACjD,EACD,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,CACvB,CAAC;QACJ,CAAC;QACD,UAAU,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAC/B,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC;KAC7C,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,SAAS,aAuBpB","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\n// The frame a `snapshot` render is drawn inside, and the geometry that sizes it.\n// Frame is a runtime input, not a pack asset: vocabulary is additive, the\n// document is exclusive.\n\nimport type { ReactNode } from 'react';\n\nimport type { RenderTheme } from '../composition/named_color';\nimport type { PrimitiveNode } from '../composition/node';\n\n/**\n * A frame's palette, per mode. An image has no media queries, so it must\n * commit to one; `auto` resolves light.\n */\nexport interface ThemePair<TTheme> {\n light: TTheme;\n dark: TTheme;\n}\n\n/**\n * Geometry and resolved theme a frame draws within.\n *\n * Named for the viewport rather than the frame because {@link Frame.wrap}\n * draws *a* frame within it; the two would otherwise read as the same thing.\n */\nexport interface FrameViewport<TTheme> {\n width: number;\n height: number;\n /** Resolved from {@link Frame.theme} for `mode`. */\n theme: TTheme;\n /** What the caller asked for, before resolution. `undefined` and `auto` both resolve light. */\n mode: RenderTheme | undefined;\n}\n\n/**\n * The two dispatcher methods a frame needs.\n *\n * The render context the nodes are drawn with is bound by the caller rather\n * than passed here: it carries the class-name resolution that pairs with the\n * stylesheet emitted alongside the frame's output, which is the surface's\n * concern and not the document's. Generic in `TNode` so a helper can be\n * written against a narrowed node union while the runtime holds the erased form.\n */\nexport interface FrameDispatcher<TNode extends PrimitiveNode = PrimitiveNode> {\n /** Draws one node on the `snapshot` surface. `key` must be unique among its siblings. */\n renderSnapshot(node: TNode, key: string): ReactNode;\n /** The node's height in pixels; `0` when it is hidden from `snapshot` or its primitive declares no `metrics.snapshotHeight`. */\n estimateSnapshotHeight(node: TNode): number;\n}\n\n/**\n * What {@link Frame.wrap} is told about the composition it draws around.\n *\n * The body is withheld, and {@link bindFrame} copies only these fields into a\n * fresh value, so the surround cannot branch on a pack's node types.\n */\nexport interface FrameHeader {\n title?: string | undefined;\n subtitle?: string | undefined;\n /** The caller's preference, not a resolved palette. Use {@link FrameViewport.theme} to draw. */\n theme?: RenderTheme | undefined;\n}\n\n/** {@link FrameHeader} plus the body, for the sizing and validation hooks. */\nexport interface FrameComposition extends FrameHeader {\n /** Raw nodes, for measuring and checking only. {@link FrameBody} is what gets drawn. */\n body: PrimitiveNode[];\n}\n\n/**\n * Body nodes already rendered to elements, ready to be surrounded.\n *\n * Distinct from `Composition.body`, which is the raw {@link PrimitiveNode}\n * array a frame never sees.\n */\nexport type FrameBody = readonly ReactNode[];\n\n/**\n * A document a `snapshot` render can produce: its geometry, the surround it draws\n * around the body, and whatever it requires of a composition it is asked to\n * draw.\n *\n * A host registers frames with the runtime and picks one per render. That is\n * what lets one runtime serve a 760px card, a 1920x1080 slide, and a\n * host-branded variant of either from the same vocabulary — and what keeps a\n * vocabulary pack additive, since nothing about a primitive decides the frame.\n * A frame is named by the key a host registers it under, not by a field it\n * carries.\n */\nexport interface Frame<TTheme> {\n /** Width used when the caller passes none. */\n defaultWidth: number;\n /**\n * Palette per mode. Frame and palette vary independently — a branded card is\n * this geometry with a host's colors — so a host overrides one by spreading\n * this value rather than rebuilding anything.\n */\n theme: ThemePair<TTheme>;\n /**\n * Height for this body when the caller passes none, in the geometry this\n * document defines. Calling {@link FrameDispatcher.estimateSnapshotHeight} is\n * what makes a missing `metrics.snapshotHeight` size the frame short: that\n * method returns `0` for a node whose primitive declares none.\n */\n estimateHeight(\n composition: FrameComposition,\n dispatcher: FrameDispatcher\n ): number;\n /**\n * What this document requires of a body. A slide document's\n * exactly-one-`slideFrame` rule is the example.\n *\n * Returned rather than thrown so a caller can decide what to do with it, but\n * note where it is *not* checked: composition validation is frame-agnostic,\n * and has to be, because the same composition can be valid in one frame and\n * not another. Only the `snapshot` surface consults this, on the frame a render\n * actually names, and raises before drawing. A host that wants the answer\n * earlier asks the frame directly.\n */\n validateBody?(body: readonly PrimitiveNode[]): readonly string[];\n /**\n * Draws the surround around the already-rendered body nodes, including a\n * title header if this document wants one.\n *\n * Takes the nodes as an array rather than a single `ReactNode` so a frame\n * that draws no surround can return its one root element — image layout\n * starts from a single element, and an array or a fragment is not one.\n *\n * Declared property-style, so it is checked contravariantly in `TTheme` under\n * `strictFunctionTypes`. A method signature is bivariant, which would admit a\n * frame needing a richer theme into a slot typed for a narrower one, where it\n * would read a token nothing supplies.\n */\n wrap: (\n header: FrameHeader,\n body: FrameBody,\n viewport: FrameViewport<TTheme>\n ) => ReactNode;\n}\n\n/**\n * A {@link Frame} as the runtime stores it, with its theme resolved away.\n *\n * The erasure is a closure rather than a type parameter because the runtime\n * dispatches nodes through one inventory keyed by node type, which has no\n * single theme to name. A runtime's frames are homogeneous in `TTheme`, so the\n * palette is known where it is resolved and only the resolved result is stored.\n */\nexport interface BoundFrame {\n readonly defaultWidth: number;\n /** See {@link Frame.estimateHeight}. */\n estimateHeight(\n composition: FrameComposition,\n dispatcher: FrameDispatcher\n ): number;\n /** See {@link Frame.validateBody}; empty when this frame states no rule. */\n validateBody(body: readonly PrimitiveNode[]): readonly string[];\n /**\n * Resolves {@link Frame.theme} for `mode`, erased to `unknown` like the rest\n * of this type. Lets a caller hand the palette to a primitive's `env.theme`\n * without itself knowing `TTheme`.\n */\n resolveTheme(mode: RenderTheme | undefined): unknown;\n /** Renders the body and its surround at `viewport`'s geometry. */\n render(\n composition: FrameComposition,\n viewport: { width: number; height: number; mode: RenderTheme | undefined },\n dispatcher: FrameDispatcher\n ): ReactNode;\n /** One node, no surround. */\n renderNode(node: PrimitiveNode, dispatcher: FrameDispatcher): ReactNode;\n}\n\n/**\n * Erases a {@link Frame}'s `TTheme` into a {@link BoundFrame}, resolving the\n * palette per render and composing the generic body walk with the frame's own\n * surround.\n */\nexport const bindFrame = <TTheme>(frame: Frame<TTheme>): BoundFrame => {\n const themeFor = (mode: RenderTheme | undefined): TTheme =>\n mode === 'dark' ? frame.theme.dark : frame.theme.light;\n return {\n defaultWidth: frame.defaultWidth,\n estimateHeight: (composition, dispatcher) =>\n frame.estimateHeight(composition, dispatcher),\n validateBody: (body) => frame.validateBody?.(body) ?? [],\n resolveTheme: (mode) => themeFor(mode),\n render: (composition, viewport, dispatcher) => {\n const theme = themeFor(viewport.mode);\n const { title, subtitle, theme: mode } = composition;\n return frame.wrap(\n { title, subtitle, theme: mode },\n composition.body.map((node, index) =>\n dispatcher.renderSnapshot(node, `body-${index}`)\n ),\n { ...viewport, theme }\n );\n },\n renderNode: (node, dispatcher) =>\n dispatcher.renderSnapshot(node, node.type),\n };\n};\n"]}
@@ -0,0 +1,31 @@
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.z = exports.requiredString = exports.formatZodIssues = exports.declaredFieldsNote = exports.validateWithSchema = exports.unresolvedBodyNodeSchema = exports.definePrimitiveFor = exports.definePrimitive = exports.bodyNodeSurfacesSchema = exports.bodyNodeIdSchema = exports.OPTIONAL_SURFACES = exports.ICON_VARS = exports.primitiveExamples = exports.exampleNodes = exports.bindFrame = void 0;
10
+ var frame_1 = require("./frame");
11
+ Object.defineProperty(exports, "bindFrame", { enumerable: true, get: function () { return frame_1.bindFrame; } });
12
+ var primitive_example_1 = require("./primitive_example");
13
+ Object.defineProperty(exports, "exampleNodes", { enumerable: true, get: function () { return primitive_example_1.exampleNodes; } });
14
+ Object.defineProperty(exports, "primitiveExamples", { enumerable: true, get: function () { return primitive_example_1.primitiveExamples; } });
15
+ var primitive_icon_1 = require("./primitive_icon");
16
+ Object.defineProperty(exports, "ICON_VARS", { enumerable: true, get: function () { return primitive_icon_1.ICON_VARS; } });
17
+ var primitive_module_1 = require("./primitive_module");
18
+ Object.defineProperty(exports, "OPTIONAL_SURFACES", { enumerable: true, get: function () { return primitive_module_1.OPTIONAL_SURFACES; } });
19
+ Object.defineProperty(exports, "bodyNodeIdSchema", { enumerable: true, get: function () { return primitive_module_1.bodyNodeIdSchema; } });
20
+ Object.defineProperty(exports, "bodyNodeSurfacesSchema", { enumerable: true, get: function () { return primitive_module_1.bodyNodeSurfacesSchema; } });
21
+ Object.defineProperty(exports, "definePrimitive", { enumerable: true, get: function () { return primitive_module_1.definePrimitive; } });
22
+ Object.defineProperty(exports, "definePrimitiveFor", { enumerable: true, get: function () { return primitive_module_1.definePrimitiveFor; } });
23
+ Object.defineProperty(exports, "unresolvedBodyNodeSchema", { enumerable: true, get: function () { return primitive_module_1.unresolvedBodyNodeSchema; } });
24
+ Object.defineProperty(exports, "validateWithSchema", { enumerable: true, get: function () { return primitive_module_1.validateWithSchema; } });
25
+ var zod_format_1 = require("./zod_format");
26
+ Object.defineProperty(exports, "declaredFieldsNote", { enumerable: true, get: function () { return zod_format_1.declaredFieldsNote; } });
27
+ Object.defineProperty(exports, "formatZodIssues", { enumerable: true, get: function () { return zod_format_1.formatZodIssues; } });
28
+ var zod_helpers_1 = require("./zod_helpers");
29
+ Object.defineProperty(exports, "requiredString", { enumerable: true, get: function () { return zod_helpers_1.requiredString; } });
30
+ Object.defineProperty(exports, "z", { enumerable: true, get: function () { return zod_helpers_1.z; } });
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/define/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,iCAUiB;AADf,kGAAA,SAAS,OAAA;AAQX,yDAM6B;AAF3B,iHAAA,YAAY,OAAA;AACZ,sHAAA,iBAAiB,OAAA;AAEnB,mDAAiE;AAApC,2GAAA,SAAS,OAAA;AACtC,uDA8B4B;AAP1B,qHAAA,iBAAiB,OAAA;AACjB,oHAAA,gBAAgB,OAAA;AAChB,0HAAA,sBAAsB,OAAA;AACtB,mHAAA,eAAe,OAAA;AACf,sHAAA,kBAAkB,OAAA;AAClB,4HAAA,wBAAwB,OAAA;AACxB,sHAAA,kBAAkB,OAAA;AAgDpB,2CAAmE;AAA1D,gHAAA,kBAAkB,OAAA;AAAE,6GAAA,eAAe,OAAA;AAC5C,6CAAkD;AAAzC,6GAAA,cAAc,OAAA;AAAE,gGAAA,CAAC,OAAA","sourcesContent":["/*\n * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one\n * or more contributor license agreements. Licensed under the Elastic License\n * 2.0; you may not use this file except in compliance with the Elastic License\n * 2.0.\n */\n\nexport {\n type BoundFrame,\n type Frame,\n type FrameBody,\n type FrameComposition,\n type FrameDispatcher,\n type FrameHeader,\n type FrameViewport,\n type ThemePair,\n bindFrame,\n} from './frame';\nexport {\n type MarkdownBlock,\n type MarkdownContent,\n type MarkdownInline,\n type MarkdownInlineInput,\n} from './markdown_content';\nexport {\n type ExampleNode,\n type NormalizedPrimitiveExample,\n type PrimitiveExample,\n exampleNodes,\n primitiveExamples,\n} from './primitive_example';\nexport { type PrimitiveIcon, ICON_VARS } from './primitive_icon';\nexport {\n type AnyPrimitiveDefinition,\n type DefaultPackTypes,\n type OptionalSurface,\n type PackTypes,\n type PrimitiveCatalogEntry,\n type PrimitiveChildRef,\n type PrimitiveDefinition,\n type PrimitiveMetrics,\n type PrimitiveNode,\n type PrimitiveRenderContext,\n type PrimitiveSchema,\n type PrimitiveStyleCollectionContext,\n type PrimitiveStyleCollector,\n type ReactContextArg,\n type Renderer,\n type Renderers,\n type RenderScope,\n type StyledRenderContext,\n type StyleHandle,\n type SurfaceMap,\n type ThemeTokenPath,\n type WithNodeFields,\n OPTIONAL_SURFACES,\n bodyNodeIdSchema,\n bodyNodeSurfacesSchema,\n definePrimitive,\n definePrimitiveFor,\n unresolvedBodyNodeSchema,\n validateWithSchema,\n} from './primitive_module';\nexport {\n type SlackAssetCollector,\n type SlackAssetRequest,\n} from './slack_assets';\nexport {\n type SlackActionElement,\n type SlackActionsBlock,\n type SlackBlock,\n type SlackButtonElement,\n type SlackCheckboxesElement,\n type SlackContextBlock,\n type SlackDividerBlock,\n type SlackFileReference,\n type SlackHeaderBlock,\n type SlackHeaderLevel,\n type SlackImageBlock,\n type SlackImageElement,\n type SlackMrkdwnTextObject,\n type SlackMultiStaticSelectElement,\n type SlackOptionGroup,\n type SlackOptionObject,\n type SlackOverflowElement,\n type SlackPlainTextObject,\n type SlackRadioButtonsElement,\n type SlackRawTextElement,\n type SlackRichTextBlock,\n type SlackRichTextBlockElement,\n type SlackRichTextInline,\n type SlackRichTextLink,\n type SlackRichTextList,\n type SlackRichTextPreformatted,\n type SlackRichTextQuote,\n type SlackRichTextSection,\n type SlackRichTextStyle,\n type SlackRichTextTag,\n type SlackRichTextText,\n type SlackSectionAccessory,\n type SlackSectionBlock,\n type SlackStaticSelectElement,\n type SlackTableBlock,\n type SlackTableCell,\n type SlackTableColumnSetting,\n type SlackTagColor,\n type SlackTextObject,\n type SlackVideoBlock,\n} from './slack_blocks';\nexport { declaredFieldsNote, formatZodIssues } from './zod_format';\nexport { requiredString, z } from './zod_helpers';\n"]}
@@ -0,0 +1,12 @@
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.markdownContent = void 0;
10
+ /** Brands `md` output. `Symbol.for`: ESM and CJS builds must agree. */
11
+ exports.markdownContent = Symbol.for('elastic.isomer.markdown_content');
12
+ //# sourceMappingURL=markdown_content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown_content.js","sourceRoot":"","sources":["../../../src/define/markdown_content.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,uEAAuE;AAC1D,QAAA,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,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/** Brands `md` output. `Symbol.for`: ESM and CJS builds must agree. */\nexport const markdownContent = Symbol.for('elastic.isomer.markdown_content');\n\n/** Inline Markdown built with `md`. */\nexport interface MarkdownInline {\n readonly [markdownContent]: 'inline';\n}\n\n/** Block Markdown built with `md`. */\nexport interface MarkdownBlock {\n readonly [markdownContent]: 'block';\n}\n\n/** What a `markdown` renderer may return in place of a string. Nested lists flatten. */\nexport type MarkdownContent = MarkdownBlock | readonly MarkdownContent[];\n\n/** A string is text: escaped wherever it would read as Markdown, line breaks as spaces. */\nexport type MarkdownInlineInput = string | MarkdownInline;\n"]}
@@ -0,0 +1,26 @@
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.exampleNodes = exports.primitiveExamples = void 0;
10
+ const isPrimitiveExample = (entry) => !('type' in entry) && 'node' in entry;
11
+ const normalize = (entry) => {
12
+ if (!isPrimitiveExample(entry)) {
13
+ return { node: entry };
14
+ }
15
+ const { name, description, node } = entry;
16
+ return description === undefined
17
+ ? { name, node }
18
+ : { name, description, node };
19
+ };
20
+ /** A definition's examples, bare or named, as {@link NormalizedPrimitiveExample}s. */
21
+ const primitiveExamples = ({ examples, }) => examples.map(normalize);
22
+ exports.primitiveExamples = primitiveExamples;
23
+ /** A definition's example nodes, without names. */
24
+ const exampleNodes = ({ examples, }) => examples.map((entry) => normalize(entry).node);
25
+ exports.exampleNodes = exampleNodes;
26
+ //# sourceMappingURL=primitive_example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive_example.js","sourceRoot":"","sources":["../../../src/define/primitive_example.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAqCH,MAAM,kBAAkB,GAAG,CACzB,KAAuC,EACZ,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,MAAM,IAAI,KAAK,CAAC;AAEtE,MAAM,SAAS,GAAG,CAChB,KAAuC,EACX,EAAE;IAC9B,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAC1C,OAAO,WAAW,KAAK,SAAS;QAC9B,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE;QAChB,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAClC,CAAC,CAAC;AAEF,sFAAsF;AAC/E,MAAM,iBAAiB,GAAG,CAAmC,EAClE,QAAQ,GACI,EAAqD,EAAE,CACnE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAsD,CAAC;AAHlE,QAAA,iBAAiB,qBAGiD;AAE/E,mDAAmD;AAC5C,MAAM,YAAY,GAAG,CAAmC,EAC7D,QAAQ,GACI,EAAyB,EAAE,CACvC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAA0B,CAAC;AAH7D,QAAA,YAAY,gBAGiD","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 { PrimitiveNode } from '../composition/node';\n\n/** A published example with a name hosts can list it by. */\nexport interface PrimitiveExample<TNode extends PrimitiveNode = PrimitiveNode> {\n /** Short and unique within the primitive, such as `Warning tone`. */\n name: string;\n /** What the example demonstrates. */\n description?: string;\n node: TNode;\n /** Never set: an entry is a bare node exactly when it has a `type`. */\n type?: never;\n}\n\n/** An entry of `examples` read as one shape; `name` is absent for a bare node. */\nexport interface NormalizedPrimitiveExample<\n TNode extends PrimitiveNode = PrimitiveNode,\n> {\n name?: string;\n description?: string;\n node: TNode;\n}\n\n/** The node type an `examples` entry holds. */\nexport type ExampleNode<TEntry> =\n TEntry extends PrimitiveExample<infer TNode> ? TNode : TEntry;\n\ninterface WithExamples {\n readonly examples: readonly (PrimitiveNode | PrimitiveExample)[];\n}\n\n/** Distributes over a union of definitions, so a mixed registry keeps every node type. */\ntype NodeOf<TDefinition extends WithExamples> = ExampleNode<\n TDefinition['examples'][number]\n>;\n\nconst isPrimitiveExample = (\n entry: PrimitiveNode | PrimitiveExample\n): entry is PrimitiveExample => !('type' in entry) && 'node' in entry;\n\nconst normalize = (\n entry: PrimitiveNode | PrimitiveExample\n): NormalizedPrimitiveExample => {\n if (!isPrimitiveExample(entry)) {\n return { node: entry };\n }\n const { name, description, node } = entry;\n return description === undefined\n ? { name, node }\n : { name, description, node };\n};\n\n/** A definition's examples, bare or named, as {@link NormalizedPrimitiveExample}s. */\nexport const primitiveExamples = <TDefinition extends WithExamples>({\n examples,\n}: TDefinition): NormalizedPrimitiveExample<NodeOf<TDefinition>>[] =>\n examples.map(normalize) as NormalizedPrimitiveExample<NodeOf<TDefinition>>[];\n\n/** A definition's example nodes, without names. */\nexport const exampleNodes = <TDefinition extends WithExamples>({\n examples,\n}: TDefinition): NodeOf<TDefinition>[] =>\n examples.map((entry) => normalize(entry).node) as NodeOf<TDefinition>[];\n"]}
@@ -0,0 +1,17 @@
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.ICON_VARS = void 0;
10
+ /** The colour slots an icon may paint with, which a host sets per theme and mode. */
11
+ exports.ICON_VARS = [
12
+ '--isomer-icon-accent',
13
+ '--isomer-icon-bg',
14
+ '--isomer-icon-fg',
15
+ '--isomer-icon-muted',
16
+ ];
17
+ //# sourceMappingURL=primitive_icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive_icon.js","sourceRoot":"","sources":["../../../src/define/primitive_icon.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAWH,qFAAqF;AACxE,QAAA,SAAS,GAAG;IACvB,sBAAsB;IACtB,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;CACb,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 * A 16×16 glyph a host shows beside the primitive: static SVG, inlinable without a renderer.\n *\n * Colours go through {@link ICON_VARS}, optionally with a `currentColor` or hex fallback; `assertPackIconsValid` from `./testing` enforces the rules.\n */\nexport interface PrimitiveIcon {\n svg: string;\n}\n\n/** The colour slots an icon may paint with, which a host sets per theme and mode. */\nexport const ICON_VARS = [\n '--isomer-icon-accent',\n '--isomer-icon-bg',\n '--isomer-icon-fg',\n '--isomer-icon-muted',\n] as const;\n"]}
@@ -0,0 +1,118 @@
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.definePrimitiveFor = exports.definePrimitive = exports.unresolvedBodyNodeSchema = exports.bodyNodeSurfacesSchema = exports.bodyNodeIdSchema = exports.validateWithSchema = exports.OPTIONAL_SURFACES = void 0;
10
+ const zod_1 = require("zod");
11
+ const body_node_base_1 = require("../composition/body_node_base");
12
+ const error_1 = require("../composition/error");
13
+ const zod_format_1 = require("./zod_format");
14
+ const zod_helpers_1 = require("./zod_helpers");
15
+ /**
16
+ * The surface a pack may declare beyond the mandatory three.
17
+ *
18
+ * Only `slack`, and even that stays optional per primitive: the dispatcher
19
+ * converts the mandatory markdown to Block Kit, so a missing Slack renderer
20
+ * degrades rather than disappearing. `snapshot` is not here because no primitive
21
+ * implements it — the surface reuses `react`.
22
+ */
23
+ exports.OPTIONAL_SURFACES = [
24
+ 'slack',
25
+ ];
26
+ /** Parses `node` against `schema`, appending path-prefixed messages to `errors`. */
27
+ const validateWithSchema = (schema, node, path, errors) => {
28
+ const result = schema.safeParse(node, { reportInput: true });
29
+ if (!result.success) {
30
+ errors.push(...(0, zod_format_1.formatZodIssues)(result.error.issues, path));
31
+ }
32
+ };
33
+ exports.validateWithSchema = validateWithSchema;
34
+ /** The `id` every node may carry, unique within a composition. */
35
+ exports.bodyNodeIdSchema = (0, zod_helpers_1.requiredString)('must be a non-empty string');
36
+ /** The `surfaces` allowlist on a node. Absent means every surface; empty is rejected. */
37
+ exports.bodyNodeSurfacesSchema = zod_1.z
38
+ .array(zod_1.z.enum(body_node_base_1.SURFACE_NAMES, {
39
+ error: () => (0, zod_format_1.oneOf)(body_node_base_1.SURFACE_NAMES),
40
+ }))
41
+ .min(1, { error: 'must contain at least one surface' });
42
+ /**
43
+ * The child slot in a container's standalone {@link PrimitiveDefinition.schema},
44
+ * where no body-node union is available.
45
+ *
46
+ * Deliberately permissive rather than `z.unknown()`: it still rejects a child
47
+ * that is not a node at all, which is the error worth catching without an
48
+ * inventory. Anything that depends on *which* types are legal — the validator,
49
+ * the parser, the JSON Schema projection — goes through
50
+ * {@link PrimitiveDefinition.schemaFor} and sees the real union.
51
+ */
52
+ exports.unresolvedBodyNodeSchema = zod_1.z.looseObject({
53
+ type: (0, zod_helpers_1.requiredString)('must be a non-empty string'),
54
+ });
55
+ /**
56
+ * Declares one primitive, extending its schema with the `id` and `surfaces`
57
+ * fields every node carries, and closing it to unknown keys so a node is held
58
+ * to the same rule as the composition root and the JSON Schema an agent reads.
59
+ * A schema with its own catchall (`z.looseObject`) keeps it.
60
+ *
61
+ * A pack normally calls the form {@link definePrimitiveFor} binds to its own
62
+ * {@link PackTypes}, so each primitive names only `TNode`.
63
+ */
64
+ const definePrimitive = (definition) => {
65
+ const { schemaFor } = definition;
66
+ return {
67
+ ...definition,
68
+ schema: withNodeFields(definition.schema),
69
+ // Both forms get the node fields, or a container would accept `id` and
70
+ // `surfaces` standalone and reject them inside a composition.
71
+ ...(schemaFor
72
+ ? {
73
+ schemaFor: (bodyNodeSchema) => withNodeFields(schemaFor(bodyNodeSchema)),
74
+ }
75
+ : {}),
76
+ };
77
+ };
78
+ exports.definePrimitive = definePrimitive;
79
+ /**
80
+ * {@link definePrimitive} bound to one pack's {@link PackTypes}.
81
+ *
82
+ * ```ts
83
+ * const define = definePrimitiveFor<SlidesPackTypes>();
84
+ * export const note = define({ type: 'note', … });
85
+ * ```
86
+ */
87
+ const definePrimitiveFor = () => (definition) => (0, exports.definePrimitive)(definition);
88
+ exports.definePrimitiveFor = definePrimitiveFor;
89
+ // Marks the field schemas `definePrimitive` adds. A schema derived from a
90
+ // defined one shares them by reference, and `Symbol.for` matches across ESM and
91
+ // CommonJS copies of the SDK.
92
+ const NODE_FIELD = Symbol.for('elastic.isomer.node_field');
93
+ const nodeField = (schema) => Object.defineProperty(schema, NODE_FIELD, { value: true });
94
+ const NODE_FIELDS = {
95
+ id: nodeField(exports.bodyNodeIdSchema.optional()),
96
+ surfaces: nodeField(exports.bodyNodeSurfacesSchema.optional()),
97
+ };
98
+ const isNodeField = (schema) => {
99
+ let current = schema;
100
+ while (current && typeof current === 'object') {
101
+ if (Object.hasOwn(current, NODE_FIELD))
102
+ return true;
103
+ const { def } = current;
104
+ if (def?.type !== 'optional')
105
+ return false;
106
+ current = def.innerType;
107
+ }
108
+ return false;
109
+ };
110
+ const withNodeFields = (schema) => {
111
+ const reserved = Object.keys(NODE_FIELDS).find((field) => Object.hasOwn(schema.shape, field) && !isNodeField(schema.shape[field]));
112
+ if (reserved) {
113
+ throw new error_1.IsomerError(error_1.ISOMER_ERROR_CODES.RESERVED_NODE_FIELD, `definePrimitive: a primitive schema cannot declare \`${reserved}\`; every body node has it.`);
114
+ }
115
+ const extended = schema.extend(NODE_FIELDS);
116
+ return (schema.def.catchall === undefined ? extended.strict() : extended);
117
+ };
118
+ //# sourceMappingURL=primitive_module.js.map