@persona/design-system 0.10.0 → 0.10.2

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 (267) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/AdvancedFilterRuleRow.d.mts +2 -2
  3. package/dist/AdvancedFilterRulesPopover.d.mts +2 -2
  4. package/dist/ArrayValueControl.d.mts +1 -1
  5. package/dist/BooleanValueControl.d.mts +1 -1
  6. package/dist/{Calendar-DAfQCLOJ.d.mts → Calendar-CkjYG7Mj.d.mts} +1 -1
  7. package/dist/Calendar.d.mts +1 -1
  8. package/dist/{CheckboxGroupField-BYB4OBlW.d.mts → CheckboxGroupField-BrPGNIyD.d.mts} +2 -2
  9. package/dist/CheckboxGroupField.d.mts +1 -1
  10. package/dist/ChoicesValueControl.d.mts +1 -1
  11. package/dist/{Combobox-CcFJo68g.mjs → Combobox-BXHCfVpE.mjs} +2 -2
  12. package/dist/{Combobox-CcFJo68g.mjs.map → Combobox-BXHCfVpE.mjs.map} +1 -1
  13. package/dist/{Combobox-DH5ycYlG.d.mts → Combobox-D0dMN5eY.d.mts} +3 -3
  14. package/dist/Combobox.d.mts +2 -2
  15. package/dist/{ComboboxBase-BQQSKUBU.d.mts → ComboboxBase-BlNi9OnF.d.mts} +2 -2
  16. package/dist/ComboboxBase.d.mts +1 -1
  17. package/dist/{ComboboxMultiSelect-Da3Gv1k5.d.mts → ComboboxMultiSelect-DbTYO-Yz.d.mts} +2 -2
  18. package/dist/ComboboxMultiSelect.d.mts +1 -1
  19. package/dist/{ComboboxSingleSelect-BUDovONU.d.mts → ComboboxSingleSelect-Cd6VYdwr.d.mts} +3 -3
  20. package/dist/ComboboxSingleSelect.d.mts +1 -1
  21. package/dist/{CompactBar-D12R7Nm2.d.mts → CompactBar-CfrrZ69k.d.mts} +1 -1
  22. package/dist/CompactBar.d.mts +1 -1
  23. package/dist/{ConfigFormGroup-CidT_cE9.mjs → ConfigFormGroup-BE3yR_VU.mjs} +1 -1
  24. package/dist/{ConfigFormGroup-CidT_cE9.mjs.map → ConfigFormGroup-BE3yR_VU.mjs.map} +1 -1
  25. package/dist/{DataTable-fZ7SNbIH.d.mts → DataTable-BdKUCgcZ.d.mts} +7 -5
  26. package/dist/{DataTable-95ZxiPlV.mjs → DataTable-F9R-aQCg.mjs} +8 -8
  27. package/dist/DataTable-F9R-aQCg.mjs.map +1 -0
  28. package/dist/DataTable.d.mts +1 -1
  29. package/dist/{DateField-DLz13Ksl.d.mts → DateField-CwSq77Ri.d.mts} +1 -1
  30. package/dist/DateField.d.mts +1 -1
  31. package/dist/{DatePicker-D0cvVbzq.mjs → DatePicker-CkNQjfCN.mjs} +2 -2
  32. package/dist/{DatePicker-D0cvVbzq.mjs.map → DatePicker-CkNQjfCN.mjs.map} +1 -1
  33. package/dist/{DatePicker-DYVWmbrb.d.mts → DatePicker-DRhY_0st.d.mts} +1 -1
  34. package/dist/DatePicker.d.mts +1 -1
  35. package/dist/{DateRangePicker-Be8TYtjz.d.mts → DateRangePicker-CLuBLF1q.d.mts} +2 -2
  36. package/dist/DateRangePicker.d.mts +1 -1
  37. package/dist/DateRangeValueControl.d.mts +2 -2
  38. package/dist/DateValueControl.d.mts +1 -1
  39. package/dist/DropdownButton.d.mts +1 -1
  40. package/dist/{DropdownMenu-DAa2kNrt.d.mts → DropdownMenu-nxFNS1kH.d.mts} +2 -2
  41. package/dist/DropdownMenu.d.mts +1 -1
  42. package/dist/{FieldRegistry-d5tGpSch.d.mts → FieldRegistry-B5E-GN91.d.mts} +2 -2
  43. package/dist/FieldRegistry.d.mts +1 -1
  44. package/dist/{FilterBar-Bh18VyOK.d.mts → FilterBar-BQWpTi2b.d.mts} +4 -4
  45. package/dist/FilterBar.d.mts +1 -1
  46. package/dist/FilterPickerMenu.d.mts +2 -2
  47. package/dist/FilterPill.d.mts +1 -1
  48. package/dist/FilterPopover.d.mts +1 -1
  49. package/dist/FloatValueControl.d.mts +1 -1
  50. package/dist/{FormField-cSG93kuo.mjs → FormField-D0y1uRV5.mjs} +9 -9
  51. package/dist/{FormField-cSG93kuo.mjs.map → FormField-D0y1uRV5.mjs.map} +1 -1
  52. package/dist/HighlightedText.d.mts +1 -1
  53. package/dist/{HoverCopyableField-D-BubaRd.mjs → HoverCopyableField-DkOosH8z.mjs} +2 -2
  54. package/dist/{HoverCopyableField-D-BubaRd.mjs.map → HoverCopyableField-DkOosH8z.mjs.map} +1 -1
  55. package/dist/ImageThumbnail.d.mts +43 -0
  56. package/dist/IndexTableLayout.d.mts +3 -3
  57. package/dist/InlineCombobox.d.mts +1 -1
  58. package/dist/InlineInput.d.mts +1 -1
  59. package/dist/IntegerValueControl.d.mts +1 -1
  60. package/dist/{Link-Cf__H8gD.mjs → Link-BSuXrvTu.mjs} +1 -1
  61. package/dist/{Link-Cf__H8gD.mjs.map → Link-BSuXrvTu.mjs.map} +1 -1
  62. package/dist/{ListBox-C80J7DCG.mjs → ListBox-BLoJVezh.mjs} +2 -2
  63. package/dist/{ListBox-C80J7DCG.mjs.map → ListBox-BLoJVezh.mjs.map} +1 -1
  64. package/dist/{ListBox-Bj5c626-.d.mts → ListBox-CXFI-0nG.d.mts} +2 -2
  65. package/dist/ListBox.d.mts +1 -1
  66. package/dist/{ListBoxField-DsJRabgE.d.mts → ListBoxField-BCOrph2k.d.mts} +4 -4
  67. package/dist/ListBoxField.d.mts +1 -1
  68. package/dist/{LogicRow-CcpD-Kk3.d.mts → LogicRow-8oYRkwz5.d.mts} +2 -2
  69. package/dist/LogicRow.d.mts +1 -1
  70. package/dist/{Menu-C0FU9WEF.d.mts → Menu-DHnQZ5yN.d.mts} +2 -2
  71. package/dist/Menu.d.mts +1 -1
  72. package/dist/{Modal-kjUptzg1.mjs → Modal-IJdbLORi.mjs} +1 -1
  73. package/dist/{Modal-kjUptzg1.mjs.map → Modal-IJdbLORi.mjs.map} +1 -1
  74. package/dist/{Pagination-DtK-jbEY.mjs → Pagination-C5ANr9M0.mjs} +2 -2
  75. package/dist/{Pagination-DtK-jbEY.mjs.map → Pagination-C5ANr9M0.mjs.map} +1 -1
  76. package/dist/{Pii-DueIK287.mjs → Pii-G16_b7Yk.mjs} +1 -1
  77. package/dist/{Pii-DueIK287.mjs.map → Pii-G16_b7Yk.mjs.map} +1 -1
  78. package/dist/{PillShell-CXROf8gO.d.mts → PillShell-DqglbFHe.d.mts} +2 -2
  79. package/dist/PillShell.d.mts +1 -1
  80. package/dist/{Popover-BcII7usF.mjs → Popover-532iYFek.mjs} +1 -1
  81. package/dist/{Popover-BcII7usF.mjs.map → Popover-532iYFek.mjs.map} +1 -1
  82. package/dist/{Radio-DDT_l8rd.mjs → Radio-BstZg3DI.mjs} +1 -1
  83. package/dist/{Radio-DDT_l8rd.mjs.map → Radio-BstZg3DI.mjs.map} +1 -1
  84. package/dist/{RadioGroup-CmD8NFCL.mjs → RadioGroup-erKerwSt.mjs} +2 -2
  85. package/dist/{RadioGroup-CmD8NFCL.mjs.map → RadioGroup-erKerwSt.mjs.map} +1 -1
  86. package/dist/{RangeCalendar-cZSYjuOZ.d.mts → RangeCalendar-CK5ArbIQ.d.mts} +2 -2
  87. package/dist/RangeCalendar.d.mts +1 -1
  88. package/dist/RangeCalendarPresets.d.mts +1 -1
  89. package/dist/RuleEditorFields.d.mts +2 -2
  90. package/dist/RulesPill.d.mts +1 -1
  91. package/dist/{SegmentedControl-CcKPfxBR.mjs → SegmentedControl-DQjIO6iX.mjs} +1 -1
  92. package/dist/{SegmentedControl-CcKPfxBR.mjs.map → SegmentedControl-DQjIO6iX.mjs.map} +1 -1
  93. package/dist/{Select-sBEBrNgo.d.mts → Select-CSbamhJO.d.mts} +2 -2
  94. package/dist/{Select-BJ9ACmRD.mjs → Select-hnXfPywt.mjs} +1 -1
  95. package/dist/{Select-BJ9ACmRD.mjs.map → Select-hnXfPywt.mjs.map} +1 -1
  96. package/dist/Select.d.mts +1 -1
  97. package/dist/SelectionCard.d.mts +51 -0
  98. package/dist/SelectionCardGroup.d.mts +37 -0
  99. package/dist/SmartTextInput.d.mts +22 -5
  100. package/dist/SmartTextInputField.d.mts +2 -2
  101. package/dist/SmartTextInputFunctionDialog.d.mts +2 -2
  102. package/dist/SmartTextInputListbox.d.mts +2 -2
  103. package/dist/SmartTextInputPopover.d.mts +1 -1
  104. package/dist/{Spinner-uVZyOh1T.mjs → Spinner-AnIk8d9M.mjs} +1 -1
  105. package/dist/{Spinner-uVZyOh1T.mjs.map → Spinner-AnIk8d9M.mjs.map} +1 -1
  106. package/dist/StringValueControl.d.mts +1 -1
  107. package/dist/{Table--o4ZLRbb.mjs → Table-CmuWqmVN.mjs} +2 -2
  108. package/dist/{Table--o4ZLRbb.mjs.map → Table-CmuWqmVN.mjs.map} +1 -1
  109. package/dist/{TableBox-3qunC9Nl.mjs → TableBox-BRJunn09.mjs} +4 -4
  110. package/dist/{TableBox-3qunC9Nl.mjs.map → TableBox-BRJunn09.mjs.map} +1 -1
  111. package/dist/TableBox.d.mts +1 -1
  112. package/dist/{TableBoxCell-BRECnVTs.d.mts → TableBoxCell-Cag3ZYRs.d.mts} +4 -4
  113. package/dist/TableBoxCell.d.mts +1 -1
  114. package/dist/{TableBoxField-Lm_tn73M.d.mts → TableBoxField-C3Cg6Lv5.d.mts} +5 -5
  115. package/dist/TableBoxField.d.mts +1 -1
  116. package/dist/{TableBoxRow-BS8Dc-zw.d.mts → TableBoxRow-y5ay5lMt.d.mts} +2 -2
  117. package/dist/TableBoxRow.d.mts +1 -1
  118. package/dist/{TableBoxRowActions-oLMb8XcM.d.mts → TableBoxRowActions-CDdVjAPQ.d.mts} +2 -2
  119. package/dist/TableBoxRowActions.d.mts +1 -1
  120. package/dist/{TableControls-DxSFqRwJ.mjs → TableControls-C5fNNdmT.mjs} +1359 -1308
  121. package/dist/TableControls-C5fNNdmT.mjs.map +1 -0
  122. package/dist/{TableControls-UfObf-ZN.d.mts → TableControls-DCtTiWk6.d.mts} +10 -5
  123. package/dist/TableControls.d.mts +2 -2
  124. package/dist/{TableControlsContext-Bhtb0cMs.d.mts → TableControlsContext-CzJCMrSe.d.mts} +2 -2
  125. package/dist/TableControlsContext.d.mts +1 -1
  126. package/dist/{TableViewConfigurationDropdown-BDXe2Q1Y.d.mts → TableViewConfigurationDropdown-BvOlDkJy.d.mts} +2 -2
  127. package/dist/TableViewConfigurationDropdown.d.mts +1 -1
  128. package/dist/{TextArea-CFf0Lspu.mjs → TextArea-CaIEBz8d.mjs} +1 -1
  129. package/dist/{TextArea-CFf0Lspu.mjs.map → TextArea-CaIEBz8d.mjs.map} +1 -1
  130. package/dist/{Toggle-BLdemkh_.mjs → Toggle-BsqSNYok.mjs} +1 -1
  131. package/dist/{Toggle-BLdemkh_.mjs.map → Toggle-BsqSNYok.mjs.map} +1 -1
  132. package/dist/{chainTypes-BbFZn8a9.d.mts → chainTypes-Cjp0zZ4E.d.mts} +3 -3
  133. package/dist/{clientFilterUtils-c5xzvoBj.d.mts → clientFilterUtils-BqDn44aM.d.mts} +2 -2
  134. package/dist/clientFilterUtils.d.mts +1 -1
  135. package/dist/{codec-DIp7dhcN.d.mts → codec-KAvQRjTW.d.mts} +2 -2
  136. package/dist/codec.d.mts +1 -1
  137. package/dist/components/Combobox/index.d.mts +2 -2
  138. package/dist/components/Combobox/index.mjs +1 -1
  139. package/dist/components/ConfigFormGroup/index.mjs +1 -1
  140. package/dist/components/DataTable/TableControls/index.d.mts +21 -21
  141. package/dist/components/DataTable/TableControls/index.mjs +1 -1
  142. package/dist/components/DataTable/index.d.mts +5 -5
  143. package/dist/components/DataTable/index.mjs +1 -1
  144. package/dist/components/DataTable/types.d.mts +1 -1
  145. package/dist/components/DatePicker/index.d.mts +5 -5
  146. package/dist/components/DatePicker/index.mjs +1 -1
  147. package/dist/components/DropdownMenu/index.d.mts +1 -1
  148. package/dist/components/FormField/index.d.mts +4 -4
  149. package/dist/components/FormField/index.mjs +1 -1
  150. package/dist/components/HoverCopyableField/index.mjs +1 -1
  151. package/dist/components/ImageTile/index.mjs +82 -52
  152. package/dist/components/ImageTile/index.mjs.map +1 -1
  153. package/dist/components/Link/index.mjs +1 -1
  154. package/dist/components/ListBox/index.d.mts +3 -3
  155. package/dist/components/ListBox/index.mjs +1 -1
  156. package/dist/components/Menu/index.d.mts +1 -1
  157. package/dist/components/Modal/index.mjs +1 -1
  158. package/dist/components/Pagination/index.mjs +1 -1
  159. package/dist/components/Pii/index.mjs +1 -1
  160. package/dist/components/Popover/index.mjs +1 -1
  161. package/dist/components/Radio/index.mjs +1 -1
  162. package/dist/components/RadioGroup/index.mjs +1 -1
  163. package/dist/components/SegmentedControl/index.mjs +1 -1
  164. package/dist/components/Select/index.d.mts +1 -1
  165. package/dist/components/Select/index.mjs +1 -1
  166. package/dist/components/SelectionCard/index.d.mts +3 -0
  167. package/dist/components/SelectionCard/index.mjs +264 -0
  168. package/dist/components/SelectionCard/index.mjs.map +1 -0
  169. package/dist/components/SmartTextInput/index.d.mts +2 -2
  170. package/dist/components/SmartTextInput/index.mjs +12 -3
  171. package/dist/components/SmartTextInput/index.mjs.map +1 -1
  172. package/dist/components/Spinner/index.mjs +1 -1
  173. package/dist/components/Table/index.mjs +1 -1
  174. package/dist/components/TableBox/index.d.mts +1 -1
  175. package/dist/components/TableBox/index.mjs +1 -1
  176. package/dist/components/TextArea/index.mjs +1 -1
  177. package/dist/components/Toggle/index.mjs +1 -1
  178. package/dist/components/VersionHistory/index.mjs +3 -3
  179. package/dist/compound-expression.d.mts +1 -1
  180. package/dist/{date-range-rule-value-D01nn054.d.mts → date-range-rule-value-Dk6pZHnD.d.mts} +2 -2
  181. package/dist/date-range-rule-value.d.mts +1 -1
  182. package/dist/{date-rule-intent-B4hQ_APa.d.mts → date-rule-intent-C5C8HB1v.d.mts} +3 -3
  183. package/dist/date-rule-intent.d.mts +1 -1
  184. package/dist/display.d.mts +1 -1
  185. package/dist/fieldPickerOptions.d.mts +2 -2
  186. package/dist/{filter-size-context-Dj7Idc8j.d.mts → filter-size-context-5xQ3ycnC.d.mts} +2 -2
  187. package/dist/filter-size-context.d.mts +1 -1
  188. package/dist/{filters-DDrsgRYy.d.mts → filters-jG9Y3UKb.d.mts} +2 -2
  189. package/dist/filters.d.mts +1 -1
  190. package/dist/{helpers-D8_2I4ZX.d.mts → helpers-DCIto6aY.d.mts} +2 -2
  191. package/dist/helpers.d.mts +1 -1
  192. package/dist/{index-DsjvDLF8.d.mts → index-C3uFHTo0.d.mts} +3 -3
  193. package/dist/{index-DkXly4xw.d.mts → index-DTAcGzW4.d.mts} +2 -2
  194. package/dist/index3.d.mts +3 -3
  195. package/dist/index4.d.mts +1 -1
  196. package/dist/index5.d.mts +14 -14
  197. package/dist/{inputFields-DyOZHse2.d.mts → inputFields-mUsms2tO.d.mts} +4 -4
  198. package/dist/inputFields.d.mts +1 -1
  199. package/dist/{jsonSchema-COo0XQLA.d.mts → jsonSchema-DmOA0Lnu.d.mts} +2 -2
  200. package/dist/lib/PDSProvider.d.mts +8 -0
  201. package/dist/lib/PDSProvider.mjs +15 -11
  202. package/dist/lib/PDSProvider.mjs.map +1 -1
  203. package/dist/lib/chainTypes.d.mts +1 -1
  204. package/dist/lib/colorMode.d.mts +30 -0
  205. package/dist/lib/colorMode.mjs +71 -0
  206. package/dist/lib/colorMode.mjs.map +1 -0
  207. package/dist/lib/customFunctionSchema.d.mts +1 -1
  208. package/dist/lib/date-filter/index.d.mts +2 -2
  209. package/dist/lib/jsonSchema.d.mts +1 -1
  210. package/dist/lib/jsonSchema.mjs.map +1 -1
  211. package/dist/lib/jsonSchemaType.d.mts +1 -1
  212. package/dist/lib/methodChain.d.mts +1 -1
  213. package/dist/lib/objectSchemaTypes.d.mts +1 -1
  214. package/dist/lib/platformObject.d.mts +1 -1
  215. package/dist/lib/schemaOptions.d.mts +2 -2
  216. package/dist/lib/schemaOptions.mjs +20 -2
  217. package/dist/lib/schemaOptions.mjs.map +1 -1
  218. package/dist/lib/useChain.d.mts +1 -1
  219. package/dist/{listbox-options-D-DyLUdi.d.mts → listbox-options-DCmqWWgy.d.mts} +3 -3
  220. package/dist/listbox-options.d.mts +1 -1
  221. package/dist/{methodChain-BAUFBbR9.d.mts → methodChain-DaDvXsHF.d.mts} +2 -2
  222. package/dist/{operators-DjQXVNVI.d.mts → operators-Seez5p9U.d.mts} +2 -2
  223. package/dist/operators.d.mts +1 -1
  224. package/dist/patterns/IndexTableLayout/index.mjs +1 -1
  225. package/dist/patterns/LayoutLoadingShimmer/index.mjs +1 -1
  226. package/dist/patterns/WizardModal/index.mjs +1 -1
  227. package/dist/relative-date-label.d.mts +1 -1
  228. package/dist/{schemaOptions-D536qhSd.d.mts → schemaOptions-BQgLOgtD.d.mts} +8 -3
  229. package/dist/{types-DHTFd-5t.d.mts → types-39QvBZuZ.d.mts} +1 -1
  230. package/dist/{types-Dx8PgO8a.d.mts → types-CrRWZ0Ia.d.mts} +4 -4
  231. package/dist/{types-DFU6M0OL.d.mts → types-DWU0Dmy9.d.mts} +3 -3
  232. package/dist/{types-CjQzH0MM.d.mts → types-DxJyE_U8.d.mts} +2 -2
  233. package/dist/{types-BMpEizJP.d.mts → types-EodOhsjw.d.mts} +2 -2
  234. package/dist/{types-BhHdS6QP.d.mts → types-SOkNtcBq.d.mts} +2 -2
  235. package/dist/types3.d.mts +1 -1
  236. package/dist/types4.d.mts +2 -2
  237. package/dist/types5.d.mts +2 -2
  238. package/dist/types6.d.mts +1 -1
  239. package/dist/types7.d.mts +1 -1
  240. package/dist/{url-state-D1muieS7.d.mts → url-state-CwaRVyXR.d.mts} +2 -2
  241. package/dist/url-state.d.mts +1 -1
  242. package/dist/{useChain-D5LvupTW.d.mts → useChain-DXkKKe-J.d.mts} +4 -4
  243. package/dist/useChainAtCursor.d.mts +4 -4
  244. package/dist/useCodeChainFunctionPanel.d.mts +1 -1
  245. package/dist/useColumnConfiguration.d.mts +2 -2
  246. package/dist/useComboboxFooterAction.d.mts +1 -1
  247. package/dist/{useFilterStateV2-MH3zbQFr.d.mts → useFilterStateV2-Bzo27PR-.d.mts} +3 -3
  248. package/dist/useFilterStateV2.d.mts +1 -1
  249. package/dist/{useTableColumns-rLskKJhd.d.mts → useTableColumns-DSXRInPb.d.mts} +2 -2
  250. package/dist/useTableColumns.d.mts +1 -1
  251. package/dist/useTruncation.d.mts +1 -1
  252. package/dist/utils.d.mts +1 -1
  253. package/dist/utils4.d.mts +2 -2
  254. package/dist/{validation-Csi2SJxm.d.mts → validation-D6NPueNk.d.mts} +3 -3
  255. package/dist/validation.d.mts +1 -1
  256. package/dist/validation2.d.mts +3 -3
  257. package/dist/{value-control-resolver-BoBFvQ_0.d.mts → value-control-resolver-C-UrXVlB.d.mts} +2 -2
  258. package/dist/value-control-resolver.d.mts +1 -1
  259. package/llms.txt +9 -1
  260. package/package.json +5 -1
  261. package/skills/ui-authoring/COMPONENTS.md +2 -1
  262. package/skills/ui-authoring/PATTERNS.md +5 -1
  263. package/skills/ui-authoring/TOKENS.md +10 -0
  264. package/dist/DataTable-95ZxiPlV.mjs.map +0 -1
  265. package/dist/TableControls-DxSFqRwJ.mjs.map +0 -1
  266. /package/dist/{index-BYd3Btr1.d.mts → index-DztUdPP_.d.mts} +0 -0
  267. /package/dist/{index-IJ_PXwxI2.d.mts → index-uMNhmxEh.d.mts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"jsonSchema.mjs","names":[],"sources":["../../lib/jsonSchema.ts"],"sourcesContent":["import { startCase } from 'lodash-es';\n\nimport type {\n FunctionConvertedTypeSchema,\n FunctionGenericParameterSchema,\n FunctionJsonSchema,\n FunctionParameterJsonSchema,\n FunctionReturnTypeJsonSchema,\n ObjectSchemaMap,\n} from './objectSchemaTypes';\n/**\n * Consumers with a known set of platform object keys can narrow `objectKey`\n * via declaration merging:\n *\n * declare module '@persona/design-system/lib/jsonSchema' {\n * interface JsonSchemaObjectKeyRegistry { objectKey: MyObjectKeyEnum }\n * }\n */\nexport interface JsonSchemaObjectKeyRegistry {}\n\nexport type JsonSchemaObjectKey = JsonSchemaObjectKeyRegistry extends {\n objectKey: infer K extends string;\n}\n ? K\n : string;\n\n/**\n * Field types are consumer-defined. Register them by mapping each field type to the JSON type it\n * serializes as (`null` when it has no fixed JSON type); PDS derives the full `fieldType` set and\n * each JSON schema interface's allowed `fieldType`s from the map:\n *\n * const FIELD_TYPE_JSON_TYPES = {\n * [MyFieldType.File]: 'object',\n * [MyFieldType.Alias]: null,\n * } as const satisfies Record<MyFieldType, `${JsonSchemaTypes}` | null>;\n *\n * declare module '@persona/design-system/lib/jsonSchema' {\n * interface JsonSchemaFieldTypeRegistry { fieldTypes: typeof FIELD_TYPE_JSON_TYPES }\n * }\n *\n * See the \"Lib/JSON Schema\" docs page for the full guide.\n */\nexport interface JsonSchemaFieldTypeRegistry {}\n\nexport type JsonSchemaFieldType = JsonSchemaFieldTypeRegistry extends { fieldTypes: infer M }\n ? keyof M & string\n : string;\n\ntype FieldTypeKind = `${Exclude<JsonSchemaTypes, JsonSchemaTypes.Null>}`;\n\ntype FieldTypeFor<K extends FieldTypeKind> = JsonSchemaFieldTypeRegistry extends {\n fieldTypes: infer M;\n}\n ? { [P in keyof M]: M[P] extends K ? P : never }[keyof M] & string\n : string;\n\n/** A field type this module gives runtime meaning to, as the consumer's type spells it. */\ntype KnownFieldType<V extends string> = string extends JsonSchemaFieldType\n ? V\n : Extract<JsonSchemaFieldType, V>;\n\nexport enum JsonSchemaTypes {\n Array = 'array',\n Boolean = 'boolean',\n Integer = 'integer',\n Number = 'number',\n Object = 'object',\n String = 'string',\n Null = 'null',\n}\n\nexport enum JsonSchemaCustomTypes {\n Date = 'date',\n Datetime = 'datetime',\n Enum = 'enum',\n File = 'file',\n MultiEnum = 'multi-enum',\n GroupedEnum = 'grouped-enum',\n Relation = 'relation',\n MaskedString = 'secret',\n Unknown = 'unknown',\n}\n\nexport type JsonSchemaAllTypes = JsonSchemaTypes | JsonSchemaCustomTypes;\nexport const JsonSchemaAllTypes = {\n ...JsonSchemaTypes,\n ...JsonSchemaCustomTypes,\n};\n\nexport const JsonSchemaStringifiableTypes = [\n JsonSchemaTypes.Boolean,\n JsonSchemaTypes.Integer,\n JsonSchemaTypes.Number,\n JsonSchemaTypes.String,\n JsonSchemaCustomTypes.Date,\n JsonSchemaCustomTypes.Enum,\n];\n\nexport type JsonSchemaBasicTypes =\n | JsonSchemaTypes.Boolean\n | JsonSchemaTypes.Integer\n | JsonSchemaTypes.Number\n | JsonSchemaTypes.String;\n\nexport interface JsonSchemaBase {\n title?: string;\n description?: string;\n examples?: (string | number)[];\n oneOf?: JsonSchema[];\n $ref?: string;\n $id?: string;\n id?: string; // custom\n // TODO: This likely should be a `JsonSchema` not an object containing only `type` but currently\n // only simple objects with a `type` property are expected.\n // Setting the correct type causes too-deep type recursion errors elsewhere.\n serializedSchema?: { type: JsonSchemaTypes } | null; // custom;\n default?: unknown;\n readOnly?: boolean;\n}\n\nexport interface JsonSchemaArray<ItemSchema = JsonSchema> extends JsonSchemaBase {\n type: JsonSchemaTypes.Array;\n items: ItemSchema;\n uniqueItems?: boolean;\n fieldType?: FieldTypeFor<'array'>; // custom\n default?: unknown[];\n supportedFunctions?: string[];\n}\n\nexport interface JsonSchemaBoolean extends JsonSchemaBase {\n type: JsonSchemaTypes.Boolean;\n fieldType?: FieldTypeFor<'boolean'>; // custom\n default?: boolean;\n}\n\nexport interface JsonSchemaInteger extends JsonSchemaBase {\n type: JsonSchemaTypes.Integer;\n enum?: number[];\n minimum?: number;\n maximum?: number;\n fieldType?: FieldTypeFor<'integer'>; // custom\n default?: number;\n}\n\nexport interface JsonSchemaNumber extends JsonSchemaBase {\n type: JsonSchemaTypes.Number;\n enum?: number[];\n minimum?: number;\n maximum?: number;\n fieldType?: FieldTypeFor<'number'>; // custom\n default?: number;\n}\n\nexport interface JsonSchemaNull extends JsonSchemaBase {\n type: JsonSchemaTypes.Null;\n default?: null;\n}\n\nexport interface JsonSchemaObject<PropertySchema = JsonSchema> extends JsonSchemaBase {\n type: JsonSchemaTypes.Object;\n properties: Record<string, PropertySchema>;\n required?: string[];\n // custom\n objectKey?: JsonSchemaObjectKey;\n // custom\n fieldType?: FieldTypeFor<'object'>;\n // custom\n isVariable?: boolean;\n // custom: picker subtitle for a chain root; generated root `description`s\n // otherwise just repeat the label and are hidden\n rootDescription?: string;\n additionalProperties?: boolean;\n baseSupportedFunctions?: string[];\n}\n\nexport const EMPTY_JSON_SCHEMA_OBJECT: JsonSchemaObject = {\n type: JsonSchemaTypes.Object,\n properties: {},\n};\n\nexport interface JsonSchemaString extends JsonSchemaBase {\n type: JsonSchemaTypes.String;\n enum?: string[];\n oneOf?: JsonSchemaConst[];\n const?: string;\n format?: string;\n group?: string; // custom\n labels?: string[]; // custom\n maxLength?: number | null;\n fieldType?: FieldTypeFor<'string'>; // custom\n default?: string;\n}\n\nexport interface JsonSchemaAnyOf extends JsonSchemaBase {\n anyOf: JsonSchema[];\n}\n\nexport interface JsonSchemaConst extends JsonSchemaBase {\n const: string;\n}\n\nexport interface JsonSchemaRef extends JsonSchemaBase {\n $ref: string;\n // custom\n objectKey?: JsonSchemaObjectKey;\n}\n\nexport type JsonSchemaEmpty = Record<string, never>;\n\nexport type JsonSchemaBasic =\n | JsonSchemaBoolean\n | JsonSchemaInteger\n | JsonSchemaNumber\n | JsonSchemaString;\n\n// This is an explicit type for json schemas that only use the standard types.\n// e.g. All subschemas will have a `type` attribute.\n// This is useful for when you know you won't be dealing with any uncommon schemas like anyOf.\nexport type JsonSchemaCore =\n | JsonSchemaArray<JsonSchemaCore>\n | JsonSchemaBoolean\n | JsonSchemaInteger\n | JsonSchemaNumber\n | JsonSchemaObject<JsonSchemaCore>\n | JsonSchemaString;\n\nexport type JsonSchema =\n | JsonSchemaArray\n | JsonSchemaBoolean\n | JsonSchemaInteger\n | JsonSchemaNumber\n | JsonSchemaObject\n | JsonSchemaString\n | JsonSchemaAnyOf\n | JsonSchemaConst\n | JsonSchemaRef\n | JsonSchemaBase;\n\nexport const isJsonSchemaObject = (schema: JsonSchema): schema is JsonSchemaObject => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Object;\n};\n\nexport const isJsonSchemaArray = (schema: JsonSchema): schema is JsonSchemaArray => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Array;\n};\n\n/** Returns true for non-primitive schemas (object, array, or $ref to a platform object). */\nexport const isNonPrimitiveSchema = (schema: JsonSchema): boolean =>\n isJsonSchemaObject(schema) || isJsonSchemaArray(schema) || isJsonSchemaRef(schema);\n\nexport const isFileType = (\n fieldType: JsonSchemaFieldType | undefined,\n): fieldType is KnownFieldType<'file'> => fieldType === 'file';\n\nexport const isJsonType = (\n fieldType: JsonSchemaFieldType | undefined,\n): fieldType is KnownFieldType<'json'> => fieldType === 'json';\n\nexport const isFileField = (schema: JsonSchema): boolean =>\n 'fieldType' in schema && isFileType(schema.fieldType);\n\nexport const isArrayWithFileItems = (schema: JsonSchema): boolean =>\n isJsonSchemaArray(schema) &&\n !!schema.items &&\n typeof schema.items === 'object' &&\n 'fieldType' in schema.items &&\n isFileType(schema.items.fieldType);\n\n/** ImageGallery accepts file schemas or arrays of file items. */\nexport const isFileSchema = (schema: JsonSchema): boolean =>\n isFileField(schema) || isArrayWithFileItems(schema);\n\nexport const isJsonSchemaRef = (schema: JsonSchema): schema is JsonSchemaRef => {\n return '$ref' in schema;\n};\n\nexport const isJsonSchemaPlatformObject = (schema: JsonSchema): schema is JsonSchemaRef => {\n return isJsonSchemaRef(schema) && 'objectKey' in schema;\n};\n\nexport const isJsonSchemaString = (schema: JsonSchema): schema is JsonSchemaString => {\n return 'type' in schema && schema.type === JsonSchemaTypes.String;\n};\n\nexport const isJsonSchemaDate = (schema: JsonSchema): schema is JsonSchemaString => {\n return (\n 'type' in schema &&\n schema.type === JsonSchemaTypes.String &&\n 'format' in schema &&\n schema.format === 'date'\n );\n};\n\nexport const isJsonSchemaDateTime = (schema: JsonSchema): schema is JsonSchemaString => {\n return (\n 'type' in schema &&\n schema.type === JsonSchemaTypes.String &&\n 'format' in schema &&\n schema.format === 'date-time'\n );\n};\n\nexport const isJsonSchemaSecret = (schema: JsonSchema): schema is JsonSchemaString => {\n return (\n 'type' in schema &&\n schema.type === JsonSchemaTypes.String &&\n 'format' in schema &&\n schema.format === 'secret'\n );\n};\n\nexport const isOneOfSchema = (\n schema: JsonSchema,\n): schema is JsonSchemaBase & { oneOf: JsonSchemaConst[] } => {\n return 'oneOf' in schema && schema.oneOf != null && Array.isArray(schema.oneOf);\n};\n\nexport const isOneOfStringSchema = (\n schema: JsonSchema,\n): schema is JsonSchemaString & { oneOf: JsonSchemaConst[] } => {\n return (\n isJsonSchemaString(schema) &&\n 'oneOf' in schema &&\n schema.oneOf != null &&\n Array.isArray(schema.oneOf)\n );\n};\n\nexport const isFunctionSchema = (schema: JsonSchema): schema is FunctionJsonSchema => {\n return schema && 'function' in schema && !!schema.function;\n};\n\nexport const genericArrayItemSchema = (\n object: JsonSchema,\n schema: FunctionParameterJsonSchema | FunctionReturnTypeJsonSchema,\n): JsonSchema | null => {\n if (!('genericType' in schema) || schema.genericType !== 'array_item_schema') {\n return null;\n }\n const array = withNameableType(object);\n return array != null && isJsonSchemaArray(array) && isSubschema(array.items) ? array.items : null;\n};\n\nexport const isPrecedingSchema = (\n schema: FunctionParameterJsonSchema | FunctionReturnTypeJsonSchema,\n) => {\n return 'genericType' in schema && schema.genericType === 'preceding_schema';\n};\n\nexport const isGenericParameterSchema = (\n schema: FunctionParameterJsonSchema | FunctionReturnTypeJsonSchema,\n): schema is FunctionGenericParameterSchema => {\n return (\n 'genericType' in schema && schema.genericType === 'parameter_schema' && 'position' in schema\n );\n};\n\nexport const isConvertedTypeSchema = (\n schema: FunctionParameterJsonSchema | FunctionReturnTypeJsonSchema,\n): schema is FunctionConvertedTypeSchema => {\n return (\n 'genericType' in schema && schema.genericType === 'converted_type' && 'schemaByValue' in schema\n );\n};\n\nexport const isJsonSchemaChoices = (schema: JsonSchema): schema is JsonSchemaString => {\n return 'type' in schema && schema.type === JsonSchemaTypes.String && 'enum' in schema;\n};\n\nexport const isJsonSchemaInteger = (schema: JsonSchema): schema is JsonSchemaInteger => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Integer;\n};\n\nexport const isJsonSchemaNumber = (schema: JsonSchema): schema is JsonSchemaNumber => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Number;\n};\n\nexport const isJsonSchemaBoolean = (schema: JsonSchema): schema is JsonSchemaBoolean => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Boolean;\n};\n\nexport const functionParametersFromJsonSchema = (\n functionSchema: JsonSchema,\n currentSchema: JsonSchema,\n): JsonSchema[] => {\n if (!isFunctionSchema(functionSchema)) {\n return [];\n }\n\n const paramTypes = functionSchema.properties.parameterTypes;\n const orderedParams: JsonSchema[] = [];\n Object.entries(paramTypes.properties).forEach(([title, paramObject]) => {\n orderedParams[paramObject.position] = {\n title,\n ...(genericArrayItemSchema(currentSchema, paramObject) ?? paramObject),\n };\n });\n return orderedParams;\n};\n\nexport const getArrayItemType = (schema: JsonSchema): JsonSchemaTypes | null => {\n if (!isJsonSchemaArray(schema) || !('type' in schema.items) || schema.items.type == null) {\n return null;\n }\n\n const itemType = schema.items.type;\n\n switch (itemType) {\n case JsonSchemaTypes.Boolean:\n case JsonSchemaTypes.Integer:\n case JsonSchemaTypes.Number:\n case JsonSchemaTypes.Object:\n case JsonSchemaTypes.String:\n return itemType;\n case JsonSchemaTypes.Array:\n // Nested arrays are not supported for simple array item types\n return null;\n default:\n return null;\n }\n};\n\n/**\n * Display labels for field-backed schemas, whose JSON type alone is too coarse to identify them:\n * every file and relation field serializes as `object`, so only `fieldType` distinguishes a document\n * from a selfie from a plain hash. Shared by both the array-item and object branches below so a type\n * can't be labelled two ways depending on whether it is wrapped in an array.\n *\n * Values follow `FIELD_SCHEMA_TYPE_DISPLAY` in `front-end/lib/fields` so the same field reads the same in the\n * field-schema editor and in these pickers. They are duplicated rather than imported because\n * `front-end/lib/fields` imports this module, and this label map is deliberately dependency-free.\n *\n * These are names, so they are intentionally finer-grained than `getDataTypeFromJsonSchema`, which\n * resolves the same schemas to a rendering strategy: it has no relation case (base `Field::Relation`\n * lands on `DataType.Hash`) and folds NFC into `DataType.GovernmentId`. A label wants to be as\n * specific as the schema allows; a DataType wants to be as specific as the renderer supports.\n *\n * The base `Field::Relation` appears when a producer erases the concrete subtype; \"Relation\" is\n * vague but still truer than the bare JSON type.\n */\nconst FIELD_TYPE_LABELS: Partial<Record<string, string>> = {\n 'Field::Relation::Document::Generic': 'Document',\n file: 'File',\n 'Field::Relation::Document::GovernmentId': 'Government ID',\n 'Field::Relation::Document::GovernmentIdNfc': 'Government ID NFC',\n hash: 'Hash',\n json: 'JSON',\n 'platform-file': 'Platform File',\n 'Field::Relation': 'Relation',\n 'Field::Relation::Selfie': 'Selfie',\n};\n\n/**\n * Names the field types that are all `type: 'string'` in JSON Schema and are told apart only by a\n * marker, so an item inside an array reads the same as it would on its own. Returns null for a\n * plain string, leaving the caller to fall back to the JSON type.\n */\nconst stringSubtypeLabel = (schema: JsonSchema): string | null => {\n if (!isJsonSchemaString(schema)) {\n return null;\n }\n if (schema.fieldType === 'choices') {\n return 'Choices';\n }\n // The backend platform-object schema sends both markers for an email address; a schema built\n // from a field schema on the client sends `format` alone.\n if (schema.fieldType === 'email-address' || schema.format === 'email') {\n return 'Email Address';\n }\n if (schema.format === 'date-time') {\n return 'Datetime';\n }\n if (schema.format === 'date') {\n return 'Date';\n }\n if (schema.format === 'secret') {\n return 'Secret';\n }\n return null;\n};\n\n/**\n * An `items` slot holds a boolean in JSON Schema 2020-12, and anything at all in a hand-written\n * schema, so a label rule can only treat it as a schema once it is an object.\n */\nconst isSubschema = (items: unknown): items is JsonSchema =>\n items != null && typeof items === 'object';\n\n/**\n * Restates a `type` union as the single type it names, so a caller can apply one label rule to a\n * nullable schema and its non-nullable form alike. Returns null when the type names nothing a label\n * can use: no `type` at all, or a union wider than nullable.\n */\nconst withNameableType = (\n schema: JsonSchema | FunctionJsonSchema,\n): (JsonSchema & { type: JsonSchemaTypes }) | null => {\n if (!('type' in schema)) {\n return null;\n }\n const type = schema.type as JsonSchemaTypes | JsonSchemaTypes[];\n const nameable = typeof type === 'string' ? type : getNonNullableType(schema);\n if (nameable == null) {\n return null;\n }\n const named = { ...schema, type: nameable };\n return named as JsonSchema & { type: JsonSchemaTypes };\n};\n\nexport const humanizeSchemaType = ({\n schema,\n parentSchema = {},\n}: {\n schema: JsonSchema | FunctionJsonSchema;\n parentSchema?: JsonSchema;\n}): string => {\n if ('function' in schema && schema.function) {\n return 'Function';\n }\n\n const format = (typeName: string, { asArray = false }: { asArray?: boolean } = {}): string => {\n return startCase(typeName.split('/')[0]) + (asArray ? '[]' : '');\n };\n\n // Unlike a `type`, an `objectKey` is never narrowed before it gets here, and a customer-authored\n // schema can hold anything in it.\n const formatObjectKey = (objectKey: unknown, options: { asArray?: boolean } = {}): string =>\n typeof objectKey === 'string' ? format(objectKey, options) : 'Unsupported';\n\n if ('genericType' in schema && schema.genericType === 'array_item_schema') {\n const parent = withNameableType(parentSchema);\n\n if (parent != null && isJsonSchemaArray(parent) && isSubschema(parent.items)) {\n if ('objectKey' in parent.items && parent.items.objectKey) {\n return formatObjectKey(parent.items.objectKey);\n }\n\n if ('type' in parent.items) {\n // The option here is the item itself, so an item type that names nothing leaves no outer\n // type to fall back on.\n const items = withNameableType(parent.items);\n return items == null ? 'Unsupported' : (stringSubtypeLabel(items) ?? format(items.type));\n }\n }\n }\n\n if (isJsonSchemaRef(schema) && schema.objectKey) {\n return formatObjectKey(schema.objectKey);\n }\n\n if (!('type' in schema)) {\n return '';\n }\n\n // Resolved before any rule reads the type, so a nullable schema is labelled the same way whether\n // it stands alone or sits in an array.\n const named = withNameableType(schema);\n if (named == null) {\n // TODO(PLO-345): return one label per non-null type for multi-non-null schemas.\n return 'Unsupported';\n }\n\n if (isJsonSchemaArray(named)) {\n if (named.fieldType === 'multi-choices') {\n return 'Multi Choices';\n }\n\n if (isSubschema(named.items)) {\n if ('objectKey' in named.items && named.items.objectKey) {\n return formatObjectKey(named.items.objectKey, { asArray: true });\n }\n\n // An item schema with no nameable type leaves the array reading as its own `Array` type,\n // which is still true of the value.\n const items = withNameableType(named.items);\n if (items != null) {\n // Object items are named by their `fieldType`; ones without a recognized marker read as\n // `Hash[]` rather than `Object[]`, since a bare `object` says nothing useful to a reader.\n if (isJsonSchemaObject(items)) {\n const itemLabel = items.fieldType && FIELD_TYPE_LABELS[items.fieldType];\n return `${itemLabel ?? 'Hash'}[]`;\n }\n\n const itemLabel = stringSubtypeLabel(items);\n if (itemLabel) {\n return `${itemLabel}[]`;\n }\n\n return format(items.type, { asArray: true });\n }\n }\n }\n\n if (isJsonSchemaString(named)) {\n if ('objectKey' in named && named.objectKey != null) {\n return formatObjectKey(named.objectKey);\n }\n const label = stringSubtypeLabel(named);\n if (label) {\n return label;\n }\n }\n\n if (isJsonSchemaObject(named)) {\n if (named.objectKey) {\n return formatObjectKey(named.objectKey);\n }\n\n // An untagged object has no field type to name it, so it falls through to its JSON type.\n const label = named.fieldType && FIELD_TYPE_LABELS[named.fieldType];\n if (label) {\n return label;\n }\n }\n\n return format(named.type);\n};\n\nexport const getNonNullableType = (\n schema: JsonSchema | FunctionJsonSchema | null | undefined,\n): JsonSchemaTypes | null => {\n if (!schema || !('type' in schema)) {\n return null;\n }\n const type = schema.type as JsonSchemaTypes | JsonSchemaTypes[];\n if (!Array.isArray(type)) {\n return null;\n }\n if (type.length !== 2 || !type.includes(JsonSchemaTypes.Null)) {\n return null;\n }\n // Only the cast above makes a member a `JsonSchemaTypes`; a hand-written schema can put anything\n // in the union, and callers splat this into a `type` their own callers then read as a name.\n const nonNullable = type.find((t) => t !== JsonSchemaTypes.Null);\n return typeof nonNullable === 'string' ? nonNullable : null;\n};\n\n/**\n * Unwraps an exactly-nullable platform-object union — a `oneOf` of one `$ref`\n * member and one `null` member — to its `$ref` member. Any other shape\n * (arbitrary unions, multiple refs, inline members) returns null so it is\n * never treated as a single receiver type.\n */\nexport const getNonNullableRefSchema = (\n schema: JsonSchema | null | undefined,\n): JsonSchemaRef | null => {\n if (!schema || !('oneOf' in schema) || !Array.isArray(schema.oneOf)) {\n return null;\n }\n if ('type' in schema || schema.oneOf.length !== 2) {\n return null;\n }\n const nullMembers: JsonSchema[] = schema.oneOf.filter(\n (member) => 'type' in member && (member.type as JsonSchemaTypes) === JsonSchemaTypes.Null,\n );\n if (nullMembers.length !== 1) {\n return null;\n }\n const refMember = schema.oneOf.find((member) => !nullMembers.includes(member));\n return refMember && isJsonSchemaRef(refMember) ? refMember : null;\n};\n\nexport const isSchemaTypeAllowed = (\n schema: JsonSchema | FunctionJsonSchema | null | undefined,\n allowedTypes: readonly string[],\n): boolean => {\n if (!schema) {\n return false;\n }\n const nonNullable = getNonNullableType(schema);\n if (nonNullable) {\n return allowedTypes.includes(nonNullable);\n }\n if ('type' in schema && !Array.isArray(schema.type) && allowedTypes.includes(schema.type)) {\n return true;\n }\n if ('format' in schema && typeof schema.format === 'string') {\n return allowedTypes.includes(schema.format);\n }\n return false;\n};\n\nexport const extendSchema = (\n schemaMap: ObjectSchemaMap,\n schemaToAdd: Partial<Record<keyof typeof schemaMap, Record<string, JsonSchema>>>,\n): ObjectSchemaMap => {\n return Object.fromEntries(\n Object.entries(schemaMap).map(([key, schema]) => {\n return [\n key,\n {\n ...schema,\n properties: {\n ...schema?.properties,\n ...schemaToAdd[key],\n },\n },\n ];\n }),\n );\n};\n"],"mappings":";;AA6DA,IAAY,kBAAL,yBAAA,iBAAA;AACL,iBAAA,WAAA;AACA,iBAAA,aAAA;AACA,iBAAA,aAAA;AACA,iBAAA,YAAA;AACA,iBAAA,YAAA;AACA,iBAAA,YAAA;AACA,iBAAA,UAAA;;KACD;AAED,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,UAAA;AACA,uBAAA,cAAA;AACA,uBAAA,UAAA;AACA,uBAAA,UAAA;AACA,uBAAA,eAAA;AACA,uBAAA,iBAAA;AACA,uBAAA,cAAA;AACA,uBAAA,kBAAA;AACA,uBAAA,aAAA;;KAC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,OAAO;AAE7C,QAAO;;AAGT,MAAa,gBACX,WACA,gBACoB;AACpB,QAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,KAAK,CAAC,KAAK,YAAY;AAC/C,SAAO,CACL,KACA;GACE,GAAG;GACH,YAAY;IACV,GAAG,QAAQ;IACX,GAAG,YAAY;IAChB;GACF,CACF;GACD,CACH"}
1
+ {"version":3,"file":"jsonSchema.mjs","names":[],"sources":["../../lib/jsonSchema.ts"],"sourcesContent":["import { startCase } from 'lodash-es';\n\nimport type {\n FunctionConvertedTypeSchema,\n FunctionGenericParameterSchema,\n FunctionJsonSchema,\n FunctionParameterJsonSchema,\n FunctionReturnTypeJsonSchema,\n ObjectSchemaMap,\n} from './objectSchemaTypes';\n/**\n * Consumers with a known set of platform object keys can narrow `objectKey`\n * via declaration merging:\n *\n * declare module '@persona/design-system/lib/jsonSchema' {\n * interface JsonSchemaObjectKeyRegistry { objectKey: MyObjectKeyEnum }\n * }\n */\nexport interface JsonSchemaObjectKeyRegistry {}\n\nexport type JsonSchemaObjectKey = JsonSchemaObjectKeyRegistry extends {\n objectKey: infer K extends string;\n}\n ? K\n : string;\n\n/**\n * Field types are consumer-defined. Register them by mapping each field type to the JSON type it\n * serializes as (`null` when it has no fixed JSON type); PDS derives the full `fieldType` set and\n * each JSON schema interface's allowed `fieldType`s from the map:\n *\n * const FIELD_TYPE_JSON_TYPES = {\n * [MyFieldType.File]: 'object',\n * [MyFieldType.Alias]: null,\n * } as const satisfies Record<MyFieldType, `${JsonSchemaTypes}` | null>;\n *\n * declare module '@persona/design-system/lib/jsonSchema' {\n * interface JsonSchemaFieldTypeRegistry { fieldTypes: typeof FIELD_TYPE_JSON_TYPES }\n * }\n *\n * See the \"Lib/JSON Schema\" docs page for the full guide.\n */\nexport interface JsonSchemaFieldTypeRegistry {}\n\nexport type JsonSchemaFieldType = JsonSchemaFieldTypeRegistry extends { fieldTypes: infer M }\n ? keyof M & string\n : string;\n\ntype FieldTypeKind = `${Exclude<JsonSchemaTypes, JsonSchemaTypes.Null>}`;\n\ntype FieldTypeFor<K extends FieldTypeKind> = JsonSchemaFieldTypeRegistry extends {\n fieldTypes: infer M;\n}\n ? { [P in keyof M]: M[P] extends K ? P : never }[keyof M] & string\n : string;\n\n/** A field type this module gives runtime meaning to, as the consumer's type spells it. */\ntype KnownFieldType<V extends string> = string extends JsonSchemaFieldType\n ? V\n : Extract<JsonSchemaFieldType, V>;\n\nexport enum JsonSchemaTypes {\n Array = 'array',\n Boolean = 'boolean',\n Integer = 'integer',\n Number = 'number',\n Object = 'object',\n String = 'string',\n Null = 'null',\n}\n\nexport enum JsonSchemaCustomTypes {\n Date = 'date',\n Datetime = 'datetime',\n Enum = 'enum',\n File = 'file',\n MultiEnum = 'multi-enum',\n GroupedEnum = 'grouped-enum',\n Relation = 'relation',\n MaskedString = 'secret',\n Unknown = 'unknown',\n}\n\nexport type JsonSchemaAllTypes = JsonSchemaTypes | JsonSchemaCustomTypes;\nexport const JsonSchemaAllTypes = {\n ...JsonSchemaTypes,\n ...JsonSchemaCustomTypes,\n};\n\nexport const JsonSchemaStringifiableTypes = [\n JsonSchemaTypes.Boolean,\n JsonSchemaTypes.Integer,\n JsonSchemaTypes.Number,\n JsonSchemaTypes.String,\n JsonSchemaCustomTypes.Date,\n JsonSchemaCustomTypes.Enum,\n];\n\nexport type JsonSchemaBasicTypes =\n | JsonSchemaTypes.Boolean\n | JsonSchemaTypes.Integer\n | JsonSchemaTypes.Number\n | JsonSchemaTypes.String;\n\nexport interface JsonSchemaBase {\n title?: string;\n description?: string;\n examples?: (string | number)[];\n oneOf?: JsonSchema[];\n $ref?: string;\n $id?: string;\n id?: string; // custom\n // TODO: This likely should be a `JsonSchema` not an object containing only `type` but currently\n // only simple objects with a `type` property are expected.\n // Setting the correct type causes too-deep type recursion errors elsewhere.\n serializedSchema?: { type: JsonSchemaTypes } | null; // custom;\n default?: unknown;\n readOnly?: boolean;\n}\n\nexport interface JsonSchemaArray<ItemSchema = JsonSchema> extends JsonSchemaBase {\n type: JsonSchemaTypes.Array;\n items: ItemSchema;\n uniqueItems?: boolean;\n fieldType?: FieldTypeFor<'array'>; // custom\n default?: unknown[];\n supportedFunctions?: string[];\n}\n\nexport interface JsonSchemaBoolean extends JsonSchemaBase {\n type: JsonSchemaTypes.Boolean;\n fieldType?: FieldTypeFor<'boolean'>; // custom\n default?: boolean;\n}\n\nexport interface JsonSchemaInteger extends JsonSchemaBase {\n type: JsonSchemaTypes.Integer;\n enum?: number[];\n minimum?: number;\n maximum?: number;\n fieldType?: FieldTypeFor<'integer'>; // custom\n default?: number;\n}\n\nexport interface JsonSchemaNumber extends JsonSchemaBase {\n type: JsonSchemaTypes.Number;\n enum?: number[];\n minimum?: number;\n maximum?: number;\n fieldType?: FieldTypeFor<'number'>; // custom\n default?: number;\n}\n\nexport interface JsonSchemaNull extends JsonSchemaBase {\n type: JsonSchemaTypes.Null;\n default?: null;\n}\n\nexport interface JsonSchemaObject<PropertySchema = JsonSchema> extends JsonSchemaBase {\n type: JsonSchemaTypes.Object;\n properties: Record<string, PropertySchema>;\n required?: string[];\n // custom\n objectKey?: JsonSchemaObjectKey;\n // custom\n fieldType?: FieldTypeFor<'object'>;\n // custom\n isVariable?: boolean;\n // custom: picker subtitle for a chain root; generated root `description`s\n // otherwise just repeat the label and are hidden\n rootDescription?: string;\n // `true` admits keys missing from `properties` with an unknown type; a schema types them.\n additionalProperties?: boolean | JsonSchema;\n baseSupportedFunctions?: string[];\n}\n\nexport const EMPTY_JSON_SCHEMA_OBJECT: JsonSchemaObject = {\n type: JsonSchemaTypes.Object,\n properties: {},\n};\n\nexport interface JsonSchemaString extends JsonSchemaBase {\n type: JsonSchemaTypes.String;\n enum?: string[];\n oneOf?: JsonSchemaConst[];\n const?: string;\n format?: string;\n group?: string; // custom\n labels?: string[]; // custom\n maxLength?: number | null;\n fieldType?: FieldTypeFor<'string'>; // custom\n default?: string;\n}\n\nexport interface JsonSchemaAnyOf extends JsonSchemaBase {\n anyOf: JsonSchema[];\n}\n\nexport interface JsonSchemaConst extends JsonSchemaBase {\n const: string;\n}\n\nexport interface JsonSchemaRef extends JsonSchemaBase {\n $ref: string;\n // custom\n objectKey?: JsonSchemaObjectKey;\n}\n\nexport type JsonSchemaEmpty = Record<string, never>;\n\nexport type JsonSchemaBasic =\n | JsonSchemaBoolean\n | JsonSchemaInteger\n | JsonSchemaNumber\n | JsonSchemaString;\n\n// This is an explicit type for json schemas that only use the standard types.\n// e.g. All subschemas will have a `type` attribute.\n// This is useful for when you know you won't be dealing with any uncommon schemas like anyOf.\nexport type JsonSchemaCore =\n | JsonSchemaArray<JsonSchemaCore>\n | JsonSchemaBoolean\n | JsonSchemaInteger\n | JsonSchemaNumber\n | JsonSchemaObject<JsonSchemaCore>\n | JsonSchemaString;\n\nexport type JsonSchema =\n | JsonSchemaArray\n | JsonSchemaBoolean\n | JsonSchemaInteger\n | JsonSchemaNumber\n | JsonSchemaObject\n | JsonSchemaString\n | JsonSchemaAnyOf\n | JsonSchemaConst\n | JsonSchemaRef\n | JsonSchemaBase;\n\nexport const isJsonSchemaObject = (schema: JsonSchema): schema is JsonSchemaObject => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Object;\n};\n\nexport const isJsonSchemaArray = (schema: JsonSchema): schema is JsonSchemaArray => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Array;\n};\n\n/** Returns true for non-primitive schemas (object, array, or $ref to a platform object). */\nexport const isNonPrimitiveSchema = (schema: JsonSchema): boolean =>\n isJsonSchemaObject(schema) || isJsonSchemaArray(schema) || isJsonSchemaRef(schema);\n\nexport const isFileType = (\n fieldType: JsonSchemaFieldType | undefined,\n): fieldType is KnownFieldType<'file'> => fieldType === 'file';\n\nexport const isJsonType = (\n fieldType: JsonSchemaFieldType | undefined,\n): fieldType is KnownFieldType<'json'> => fieldType === 'json';\n\nexport const isFileField = (schema: JsonSchema): boolean =>\n 'fieldType' in schema && isFileType(schema.fieldType);\n\nexport const isArrayWithFileItems = (schema: JsonSchema): boolean =>\n isJsonSchemaArray(schema) &&\n !!schema.items &&\n typeof schema.items === 'object' &&\n 'fieldType' in schema.items &&\n isFileType(schema.items.fieldType);\n\n/** ImageGallery accepts file schemas or arrays of file items. */\nexport const isFileSchema = (schema: JsonSchema): boolean =>\n isFileField(schema) || isArrayWithFileItems(schema);\n\nexport const isJsonSchemaRef = (schema: JsonSchema): schema is JsonSchemaRef => {\n return '$ref' in schema;\n};\n\nexport const isJsonSchemaPlatformObject = (schema: JsonSchema): schema is JsonSchemaRef => {\n return isJsonSchemaRef(schema) && 'objectKey' in schema;\n};\n\nexport const isJsonSchemaString = (schema: JsonSchema): schema is JsonSchemaString => {\n return 'type' in schema && schema.type === JsonSchemaTypes.String;\n};\n\nexport const isJsonSchemaDate = (schema: JsonSchema): schema is JsonSchemaString => {\n return (\n 'type' in schema &&\n schema.type === JsonSchemaTypes.String &&\n 'format' in schema &&\n schema.format === 'date'\n );\n};\n\nexport const isJsonSchemaDateTime = (schema: JsonSchema): schema is JsonSchemaString => {\n return (\n 'type' in schema &&\n schema.type === JsonSchemaTypes.String &&\n 'format' in schema &&\n schema.format === 'date-time'\n );\n};\n\nexport const isJsonSchemaSecret = (schema: JsonSchema): schema is JsonSchemaString => {\n return (\n 'type' in schema &&\n schema.type === JsonSchemaTypes.String &&\n 'format' in schema &&\n schema.format === 'secret'\n );\n};\n\nexport const isOneOfSchema = (\n schema: JsonSchema,\n): schema is JsonSchemaBase & { oneOf: JsonSchemaConst[] } => {\n return 'oneOf' in schema && schema.oneOf != null && Array.isArray(schema.oneOf);\n};\n\nexport const isOneOfStringSchema = (\n schema: JsonSchema,\n): schema is JsonSchemaString & { oneOf: JsonSchemaConst[] } => {\n return (\n isJsonSchemaString(schema) &&\n 'oneOf' in schema &&\n schema.oneOf != null &&\n Array.isArray(schema.oneOf)\n );\n};\n\nexport const isFunctionSchema = (schema: JsonSchema): schema is FunctionJsonSchema => {\n return schema && 'function' in schema && !!schema.function;\n};\n\nexport const genericArrayItemSchema = (\n object: JsonSchema,\n schema: FunctionParameterJsonSchema | FunctionReturnTypeJsonSchema,\n): JsonSchema | null => {\n if (!('genericType' in schema) || schema.genericType !== 'array_item_schema') {\n return null;\n }\n const array = withNameableType(object);\n return array != null && isJsonSchemaArray(array) && isSubschema(array.items) ? array.items : null;\n};\n\nexport const isPrecedingSchema = (\n schema: FunctionParameterJsonSchema | FunctionReturnTypeJsonSchema,\n) => {\n return 'genericType' in schema && schema.genericType === 'preceding_schema';\n};\n\nexport const isGenericParameterSchema = (\n schema: FunctionParameterJsonSchema | FunctionReturnTypeJsonSchema,\n): schema is FunctionGenericParameterSchema => {\n return (\n 'genericType' in schema && schema.genericType === 'parameter_schema' && 'position' in schema\n );\n};\n\nexport const isConvertedTypeSchema = (\n schema: FunctionParameterJsonSchema | FunctionReturnTypeJsonSchema,\n): schema is FunctionConvertedTypeSchema => {\n return (\n 'genericType' in schema && schema.genericType === 'converted_type' && 'schemaByValue' in schema\n );\n};\n\nexport const isJsonSchemaChoices = (schema: JsonSchema): schema is JsonSchemaString => {\n return 'type' in schema && schema.type === JsonSchemaTypes.String && 'enum' in schema;\n};\n\nexport const isJsonSchemaInteger = (schema: JsonSchema): schema is JsonSchemaInteger => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Integer;\n};\n\nexport const isJsonSchemaNumber = (schema: JsonSchema): schema is JsonSchemaNumber => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Number;\n};\n\nexport const isJsonSchemaBoolean = (schema: JsonSchema): schema is JsonSchemaBoolean => {\n return 'type' in schema && schema.type === JsonSchemaTypes.Boolean;\n};\n\nexport const functionParametersFromJsonSchema = (\n functionSchema: JsonSchema,\n currentSchema: JsonSchema,\n): JsonSchema[] => {\n if (!isFunctionSchema(functionSchema)) {\n return [];\n }\n\n const paramTypes = functionSchema.properties.parameterTypes;\n const orderedParams: JsonSchema[] = [];\n Object.entries(paramTypes.properties).forEach(([title, paramObject]) => {\n orderedParams[paramObject.position] = {\n title,\n ...(genericArrayItemSchema(currentSchema, paramObject) ?? paramObject),\n };\n });\n return orderedParams;\n};\n\nexport const getArrayItemType = (schema: JsonSchema): JsonSchemaTypes | null => {\n if (!isJsonSchemaArray(schema) || !('type' in schema.items) || schema.items.type == null) {\n return null;\n }\n\n const itemType = schema.items.type;\n\n switch (itemType) {\n case JsonSchemaTypes.Boolean:\n case JsonSchemaTypes.Integer:\n case JsonSchemaTypes.Number:\n case JsonSchemaTypes.Object:\n case JsonSchemaTypes.String:\n return itemType;\n case JsonSchemaTypes.Array:\n // Nested arrays are not supported for simple array item types\n return null;\n default:\n return null;\n }\n};\n\n/**\n * Display labels for field-backed schemas, whose JSON type alone is too coarse to identify them:\n * every file and relation field serializes as `object`, so only `fieldType` distinguishes a document\n * from a selfie from a plain hash. Shared by both the array-item and object branches below so a type\n * can't be labelled two ways depending on whether it is wrapped in an array.\n *\n * Values follow `FIELD_SCHEMA_TYPE_DISPLAY` in `front-end/lib/fields` so the same field reads the same in the\n * field-schema editor and in these pickers. They are duplicated rather than imported because\n * `front-end/lib/fields` imports this module, and this label map is deliberately dependency-free.\n *\n * These are names, so they are intentionally finer-grained than `getDataTypeFromJsonSchema`, which\n * resolves the same schemas to a rendering strategy: it has no relation case (base `Field::Relation`\n * lands on `DataType.Hash`) and folds NFC into `DataType.GovernmentId`. A label wants to be as\n * specific as the schema allows; a DataType wants to be as specific as the renderer supports.\n *\n * The base `Field::Relation` appears when a producer erases the concrete subtype; \"Relation\" is\n * vague but still truer than the bare JSON type.\n */\nconst FIELD_TYPE_LABELS: Partial<Record<string, string>> = {\n 'Field::Relation::Document::Generic': 'Document',\n file: 'File',\n 'Field::Relation::Document::GovernmentId': 'Government ID',\n 'Field::Relation::Document::GovernmentIdNfc': 'Government ID NFC',\n hash: 'Hash',\n json: 'JSON',\n 'platform-file': 'Platform File',\n 'Field::Relation': 'Relation',\n 'Field::Relation::Selfie': 'Selfie',\n};\n\n/**\n * Names the field types that are all `type: 'string'` in JSON Schema and are told apart only by a\n * marker, so an item inside an array reads the same as it would on its own. Returns null for a\n * plain string, leaving the caller to fall back to the JSON type.\n */\nconst stringSubtypeLabel = (schema: JsonSchema): string | null => {\n if (!isJsonSchemaString(schema)) {\n return null;\n }\n if (schema.fieldType === 'choices') {\n return 'Choices';\n }\n // The backend platform-object schema sends both markers for an email address; a schema built\n // from a field schema on the client sends `format` alone.\n if (schema.fieldType === 'email-address' || schema.format === 'email') {\n return 'Email Address';\n }\n if (schema.format === 'date-time') {\n return 'Datetime';\n }\n if (schema.format === 'date') {\n return 'Date';\n }\n if (schema.format === 'secret') {\n return 'Secret';\n }\n return null;\n};\n\n/**\n * An `items` slot holds a boolean in JSON Schema 2020-12, and anything at all in a hand-written\n * schema, so a label rule can only treat it as a schema once it is an object.\n */\nconst isSubschema = (items: unknown): items is JsonSchema =>\n items != null && typeof items === 'object';\n\n/**\n * Restates a `type` union as the single type it names, so a caller can apply one label rule to a\n * nullable schema and its non-nullable form alike. Returns null when the type names nothing a label\n * can use: no `type` at all, or a union wider than nullable.\n */\nconst withNameableType = (\n schema: JsonSchema | FunctionJsonSchema,\n): (JsonSchema & { type: JsonSchemaTypes }) | null => {\n if (!('type' in schema)) {\n return null;\n }\n const type = schema.type as JsonSchemaTypes | JsonSchemaTypes[];\n const nameable = typeof type === 'string' ? type : getNonNullableType(schema);\n if (nameable == null) {\n return null;\n }\n const named = { ...schema, type: nameable };\n return named as JsonSchema & { type: JsonSchemaTypes };\n};\n\nexport const humanizeSchemaType = ({\n schema,\n parentSchema = {},\n}: {\n schema: JsonSchema | FunctionJsonSchema;\n parentSchema?: JsonSchema;\n}): string => {\n if ('function' in schema && schema.function) {\n return 'Function';\n }\n\n const format = (typeName: string, { asArray = false }: { asArray?: boolean } = {}): string => {\n return startCase(typeName.split('/')[0]) + (asArray ? '[]' : '');\n };\n\n // Unlike a `type`, an `objectKey` is never narrowed before it gets here, and a customer-authored\n // schema can hold anything in it.\n const formatObjectKey = (objectKey: unknown, options: { asArray?: boolean } = {}): string =>\n typeof objectKey === 'string' ? format(objectKey, options) : 'Unsupported';\n\n if ('genericType' in schema && schema.genericType === 'array_item_schema') {\n const parent = withNameableType(parentSchema);\n\n if (parent != null && isJsonSchemaArray(parent) && isSubschema(parent.items)) {\n if ('objectKey' in parent.items && parent.items.objectKey) {\n return formatObjectKey(parent.items.objectKey);\n }\n\n if ('type' in parent.items) {\n // The option here is the item itself, so an item type that names nothing leaves no outer\n // type to fall back on.\n const items = withNameableType(parent.items);\n return items == null ? 'Unsupported' : (stringSubtypeLabel(items) ?? format(items.type));\n }\n }\n }\n\n if (isJsonSchemaRef(schema) && schema.objectKey) {\n return formatObjectKey(schema.objectKey);\n }\n\n if (!('type' in schema)) {\n return '';\n }\n\n // Resolved before any rule reads the type, so a nullable schema is labelled the same way whether\n // it stands alone or sits in an array.\n const named = withNameableType(schema);\n if (named == null) {\n // TODO(PLO-345): return one label per non-null type for multi-non-null schemas.\n return 'Unsupported';\n }\n\n if (isJsonSchemaArray(named)) {\n if (named.fieldType === 'multi-choices') {\n return 'Multi Choices';\n }\n\n if (isSubschema(named.items)) {\n if ('objectKey' in named.items && named.items.objectKey) {\n return formatObjectKey(named.items.objectKey, { asArray: true });\n }\n\n // An item schema with no nameable type leaves the array reading as its own `Array` type,\n // which is still true of the value.\n const items = withNameableType(named.items);\n if (items != null) {\n // Object items are named by their `fieldType`; ones without a recognized marker read as\n // `Hash[]` rather than `Object[]`, since a bare `object` says nothing useful to a reader.\n if (isJsonSchemaObject(items)) {\n const itemLabel = items.fieldType && FIELD_TYPE_LABELS[items.fieldType];\n return `${itemLabel ?? 'Hash'}[]`;\n }\n\n const itemLabel = stringSubtypeLabel(items);\n if (itemLabel) {\n return `${itemLabel}[]`;\n }\n\n return format(items.type, { asArray: true });\n }\n }\n }\n\n if (isJsonSchemaString(named)) {\n if ('objectKey' in named && named.objectKey != null) {\n return formatObjectKey(named.objectKey);\n }\n const label = stringSubtypeLabel(named);\n if (label) {\n return label;\n }\n }\n\n if (isJsonSchemaObject(named)) {\n if (named.objectKey) {\n return formatObjectKey(named.objectKey);\n }\n\n // An untagged object has no field type to name it, so it falls through to its JSON type.\n const label = named.fieldType && FIELD_TYPE_LABELS[named.fieldType];\n if (label) {\n return label;\n }\n }\n\n return format(named.type);\n};\n\nexport const getNonNullableType = (\n schema: JsonSchema | FunctionJsonSchema | null | undefined,\n): JsonSchemaTypes | null => {\n if (!schema || !('type' in schema)) {\n return null;\n }\n const type = schema.type as JsonSchemaTypes | JsonSchemaTypes[];\n if (!Array.isArray(type)) {\n return null;\n }\n if (type.length !== 2 || !type.includes(JsonSchemaTypes.Null)) {\n return null;\n }\n // Only the cast above makes a member a `JsonSchemaTypes`; a hand-written schema can put anything\n // in the union, and callers splat this into a `type` their own callers then read as a name.\n const nonNullable = type.find((t) => t !== JsonSchemaTypes.Null);\n return typeof nonNullable === 'string' ? nonNullable : null;\n};\n\n/**\n * Unwraps an exactly-nullable platform-object union — a `oneOf` of one `$ref`\n * member and one `null` member — to its `$ref` member. Any other shape\n * (arbitrary unions, multiple refs, inline members) returns null so it is\n * never treated as a single receiver type.\n */\nexport const getNonNullableRefSchema = (\n schema: JsonSchema | null | undefined,\n): JsonSchemaRef | null => {\n if (!schema || !('oneOf' in schema) || !Array.isArray(schema.oneOf)) {\n return null;\n }\n if ('type' in schema || schema.oneOf.length !== 2) {\n return null;\n }\n const nullMembers: JsonSchema[] = schema.oneOf.filter(\n (member) => 'type' in member && (member.type as JsonSchemaTypes) === JsonSchemaTypes.Null,\n );\n if (nullMembers.length !== 1) {\n return null;\n }\n const refMember = schema.oneOf.find((member) => !nullMembers.includes(member));\n return refMember && isJsonSchemaRef(refMember) ? refMember : null;\n};\n\nexport const isSchemaTypeAllowed = (\n schema: JsonSchema | FunctionJsonSchema | null | undefined,\n allowedTypes: readonly string[],\n): boolean => {\n if (!schema) {\n return false;\n }\n const nonNullable = getNonNullableType(schema);\n if (nonNullable) {\n return allowedTypes.includes(nonNullable);\n }\n if ('type' in schema && !Array.isArray(schema.type) && allowedTypes.includes(schema.type)) {\n return true;\n }\n if ('format' in schema && typeof schema.format === 'string') {\n return allowedTypes.includes(schema.format);\n }\n return false;\n};\n\nexport const extendSchema = (\n schemaMap: ObjectSchemaMap,\n schemaToAdd: Partial<Record<keyof typeof schemaMap, Record<string, JsonSchema>>>,\n): ObjectSchemaMap => {\n return Object.fromEntries(\n Object.entries(schemaMap).map(([key, schema]) => {\n return [\n key,\n {\n ...schema,\n properties: {\n ...schema?.properties,\n ...schemaToAdd[key],\n },\n },\n ];\n }),\n );\n};\n"],"mappings":";;AA6DA,IAAY,kBAAL,yBAAA,iBAAA;AACL,iBAAA,WAAA;AACA,iBAAA,aAAA;AACA,iBAAA,aAAA;AACA,iBAAA,YAAA;AACA,iBAAA,YAAA;AACA,iBAAA,YAAA;AACA,iBAAA,UAAA;;KACD;AAED,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,UAAA;AACA,uBAAA,cAAA;AACA,uBAAA,UAAA;AACA,uBAAA,UAAA;AACA,uBAAA,eAAA;AACA,uBAAA,iBAAA;AACA,uBAAA,cAAA;AACA,uBAAA,kBAAA;AACA,uBAAA,aAAA;;KACD;AAGD,MAAa,qBAAqB;CAChC,GAAG;CACH,GAAG;CACJ;AAED,MAAa,+BAA+B;;;;;;;CAO3C;AAgFD,MAAa,2BAA6C;CACxD,MAAA;CACA,YAAY,EAAE;CACf;AA4DD,MAAa,sBAAsB,WAAmD;AACpF,QAAO,UAAU,UAAU,OAAO,SAAA;;AAGpC,MAAa,qBAAqB,WAAkD;AAClF,QAAO,UAAU,UAAU,OAAO,SAAA;;;AAIpC,MAAa,wBAAwB,WACnC,mBAAmB,OAAO,IAAI,kBAAkB,OAAO,IAAI,gBAAgB,OAAO;AAEpF,MAAa,cACX,cACwC,cAAc;AAExD,MAAa,cACX,cACwC,cAAc;AAExD,MAAa,eAAe,WAC1B,eAAe,UAAU,WAAW,OAAO,UAAU;AAEvD,MAAa,wBAAwB,WAC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AChE,QAAO,OAAO,gBAAgB,WAAW,cAAc;;;;;;;;AASzD,MAAa,2BACX,WACyB;AACzB,KAAI,CAAC,UAAU,EAAE,WAAW,WAAW,CAAC,MAAM,QAAQ,OAAO,MAAM,CACjE,QAAO;AAET,KAAI,UAAU,UAAU,OAAO,MAAM,WAAW,EAC9C,QAAO;CAET,MAAM,cAA4B,OAAO,MAAM,QAC5C,WAAW,UAAU,UAAW,OAAO,SAAA,OACzC;AACD,KAAI,YAAY,WAAW,EACzB,QAAO;CAET,MAAM,YAAY,OAAO,MAAM,MAAM,WAAW,CAAC,YAAY,SAAS,OAAO,CAAC;AAC9E,QAAO,aAAa,gBAAgB,UAAU,GAAG,YAAY;;AAG/D,MAAa,uBACX,QACA,iBACY;AACZ,KAAI,CAAC,OACH,QAAO;CAET,MAAM,cAAc,mBAAmB,OAAO;AAC9C,KAAI,YACF,QAAO,aAAa,SAAS,YAAY;AAE3C,KAAI,UAAU,UAAU,CAAC,MAAM,QAAQ,OAAO,KAAK,IAAI,aAAa,SAAS,OAAO,KAAK,CACvF,QAAO;AAET,KAAI,YAAY,UAAU,OAAO,OAAO,WAAW,SACjD,QAAO,aAAa,SAAS,OAAO,OAAO;AAE7C,QAAO;;AAGT,MAAa,gBACX,WACA,gBACoB;AACpB,QAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,KAAK,CAAC,KAAK,YAAY;AAC/C,SAAO,CACL,KACA;GACE,GAAG;GACH,YAAY;IACV,GAAG,QAAQ;IACX,GAAG,YAAY;IAChB;GACF,CACF;GACD,CACH"}
@@ -1,4 +1,4 @@
1
- import { T as JsonSchemaTypes, f as JsonSchemaCustomTypes, n as JsonSchema } from "../jsonSchema-COo0XQLA.mjs";
1
+ import { T as JsonSchemaTypes, f as JsonSchemaCustomTypes, n as JsonSchema } from "../jsonSchema-DmOA0Lnu.mjs";
2
2
 
3
3
  //#region lib/jsonSchemaType.d.ts
4
4
  declare const getJsonSchemaType: (schema: JsonSchema | null) => JsonSchemaTypes | JsonSchemaCustomTypes;
@@ -1,3 +1,3 @@
1
- import { C as tryParseMethodChain, S as removeFunctionNode, _ as methodChainToString, a as getFunctionParams, b as pathContainsFunctionNode, c as isCustomFunctionNode, d as isIdentifierNode, f as isStringNode, g as methodChainRootName, h as methodChainNodeToJsonSchema, i as containsFunctionNode, l as isEmpty, m as methodChainCache, n as MethodChainNodeTypes, o as getSyntaxError, p as isValid, r as appendedMethodChain, s as isArrayNode, t as EMPTY_METHOD_CHAIN, u as isFunctionNode, v as parseMethodChain, x as pathIsNormative, y as parseWithPartialOption } from "../methodChain-BAUFBbR9.mjs";
1
+ import { C as tryParseMethodChain, S as removeFunctionNode, _ as methodChainToString, a as getFunctionParams, b as pathContainsFunctionNode, c as isCustomFunctionNode, d as isIdentifierNode, f as isStringNode, g as methodChainRootName, h as methodChainNodeToJsonSchema, i as containsFunctionNode, l as isEmpty, m as methodChainCache, n as MethodChainNodeTypes, o as getSyntaxError, p as isValid, r as appendedMethodChain, s as isArrayNode, t as EMPTY_METHOD_CHAIN, u as isFunctionNode, v as parseMethodChain, x as pathIsNormative, y as parseWithPartialOption } from "../methodChain-DaDvXsHF.mjs";
2
2
  import { a as FunctionParamType, c as NumberNode, i as FunctionNode, l as StringNode, n as Chain, o as IdentifierNode, r as CustomFunctionNode, s as MethodChainNode, t as ArrayNode } from "../methodChainTypes-a7kHYhs7.mjs";
3
3
  export { ArrayNode, Chain, CustomFunctionNode, EMPTY_METHOD_CHAIN, FunctionNode, FunctionParamType, IdentifierNode, MethodChainNode, MethodChainNodeTypes, NumberNode, StringNode, appendedMethodChain, containsFunctionNode, getFunctionParams, getSyntaxError, isArrayNode, isCustomFunctionNode, isEmpty, isFunctionNode, isIdentifierNode, isStringNode, isValid, methodChainCache, methodChainNodeToJsonSchema, methodChainRootName, methodChainToString, parseMethodChain, parseWithPartialOption, pathContainsFunctionNode, pathIsNormative, removeFunctionNode, tryParseMethodChain };
@@ -1,2 +1,2 @@
1
- import { at as FunctionConvertedTypeSchema, ct as FunctionParameterJsonSchema, dt as ObjectSchemaMap, it as CollectionMetaJsonSchema, lt as FunctionReturnTypeJsonSchema, ot as FunctionGenericParameterSchema, st as FunctionJsonSchema, ut as GenericType } from "../jsonSchema-COo0XQLA.mjs";
1
+ import { at as FunctionConvertedTypeSchema, ct as FunctionParameterJsonSchema, dt as ObjectSchemaMap, it as CollectionMetaJsonSchema, lt as FunctionReturnTypeJsonSchema, ot as FunctionGenericParameterSchema, st as FunctionJsonSchema, ut as GenericType } from "../jsonSchema-DmOA0Lnu.mjs";
2
2
  export { CollectionMetaJsonSchema, FunctionConvertedTypeSchema, FunctionGenericParameterSchema, FunctionJsonSchema, FunctionParameterJsonSchema, FunctionReturnTypeJsonSchema, GenericType, ObjectSchemaMap };
@@ -1,4 +1,4 @@
1
- import { S as JsonSchemaRef, b as JsonSchemaObjectKey, d as JsonSchemaCore, dt as ObjectSchemaMap, n as JsonSchema, u as JsonSchemaConst, y as JsonSchemaObject } from "../jsonSchema-COo0XQLA.mjs";
1
+ import { S as JsonSchemaRef, b as JsonSchemaObjectKey, d as JsonSchemaCore, dt as ObjectSchemaMap, n as JsonSchema, u as JsonSchemaConst, y as JsonSchemaObject } from "../jsonSchema-DmOA0Lnu.mjs";
2
2
 
3
3
  //#region lib/platformObject.d.ts
4
4
  interface PlatformObjectJsonSchema extends JsonSchemaObject {
@@ -1,2 +1,2 @@
1
- import { a as getFunctionSchemaForNode, c as getSchemaForFieldPath, d as hasRequiredPropertyShape, f as isTypeMatch, g as validatePath, h as splitAtNearestParentObject, i as formatDisplayValue, l as getSchemaForVariablePath, m as nextLinkSchema, n as OptionFilters, o as getOptionForValue, p as isValidOption, r as extractPlatformObjectKey, s as getSchemaByPath, t as Option, u as getSchemaOptions } from "../schemaOptions-D536qhSd.mjs";
2
- export { Option, OptionFilters, extractPlatformObjectKey, formatDisplayValue, getFunctionSchemaForNode, getOptionForValue, getSchemaByPath, getSchemaForFieldPath, getSchemaForVariablePath, getSchemaOptions, hasRequiredPropertyShape, isTypeMatch, isValidOption, nextLinkSchema, splitAtNearestParentObject, validatePath };
1
+ import { _ as validatePath, a as formatDisplayValue, c as getSchemaByPath, d as getSchemaOptions, f as hasRequiredPropertyShape, g as splitAtNearestParentObject, h as nextLinkSchema, i as extractPlatformObjectKey, l as getSchemaForFieldPath, m as isValidOption, n as OptionFilters, o as getFunctionSchemaForNode, p as isTypeMatch, r as UNTYPED_ADDITIONAL_PROPERTY_SCHEMA, s as getOptionForValue, t as Option, u as getSchemaForVariablePath } from "../schemaOptions-BQgLOgtD.mjs";
2
+ export { Option, OptionFilters, UNTYPED_ADDITIONAL_PROPERTY_SCHEMA, extractPlatformObjectKey, formatDisplayValue, getFunctionSchemaForNode, getOptionForValue, getSchemaByPath, getSchemaForFieldPath, getSchemaForVariablePath, getSchemaOptions, hasRequiredPropertyShape, isTypeMatch, isValidOption, nextLinkSchema, splitAtNearestParentObject, validatePath };
@@ -146,6 +146,24 @@ const parseMethodChainForJSS = (path) => {
146
146
  if (partial.length > 0) return appendedMethodChain(methodChain, partial);
147
147
  return methodChain;
148
148
  };
149
+ /**
150
+ * The schema resolved for a key admitted by `additionalProperties: true`: valid, with an unknown
151
+ * type. Compared by identity (e.g. by the SmartTextInput validator), so do not copy it.
152
+ */
153
+ const UNTYPED_ADDITIONAL_PROPERTY_SCHEMA = Object.freeze({});
154
+ /**
155
+ * Resolves an identifier that is not a declared property of `currentSchema` through the object's
156
+ * `additionalProperties`: its schema when one is given, `UNTYPED_ADDITIONAL_PROPERTY_SCHEMA` when
157
+ * it is `true`, and null when extra keys are not allowed.
158
+ */
159
+ const additionalPropertySchema = (currentSchema, link, platformObjectJsonSchema) => {
160
+ if (currentSchema == null || !isIdentifierNode(link)) return null;
161
+ const resolved = isJsonSchemaRef(currentSchema) ? resolveJssRef(currentSchema, platformObjectJsonSchema) : currentSchema;
162
+ if (!isJsonSchemaObject(resolved) || resolved.properties?.[link.name] != null) return null;
163
+ const { additionalProperties } = resolved;
164
+ if (additionalProperties === true) return UNTYPED_ADDITIONAL_PROPERTY_SCHEMA;
165
+ return typeof additionalProperties === "object" && additionalProperties != null ? additionalProperties : null;
166
+ };
149
167
  const getSchemaForFieldPath = ({ path, initialSchema, platformObjectJsonSchema = {}, primitiveUtilities = {} }) => {
150
168
  if (!initialSchema || !("type" in initialSchema) && !("$ref" in initialSchema)) return {
151
169
  schema: null,
@@ -167,7 +185,7 @@ const getSchemaForFieldPath = ({ path, initialSchema, platformObjectJsonSchema =
167
185
  nextLink: link,
168
186
  platformObjectJsonSchema,
169
187
  primitiveUtilities
170
- });
188
+ }) ?? additionalPropertySchema(currentSchema, link, platformObjectJsonSchema);
171
189
  }, schema);
172
190
  return {
173
191
  schema: result,
@@ -476,6 +494,6 @@ const splitAtNearestParentObject = (chain, currentSchema, platformSchemaMap, pri
476
494
  }];
477
495
  };
478
496
  //#endregion
479
- export { extractPlatformObjectKey, formatDisplayValue, getFunctionSchemaForNode, getOptionForValue, getSchemaByPath, getSchemaForFieldPath, getSchemaForVariablePath, getSchemaOptions, hasRequiredPropertyShape, isTypeMatch, isValidOption, nextLinkSchema, splitAtNearestParentObject, validatePath };
497
+ export { UNTYPED_ADDITIONAL_PROPERTY_SCHEMA, extractPlatformObjectKey, formatDisplayValue, getFunctionSchemaForNode, getOptionForValue, getSchemaByPath, getSchemaForFieldPath, getSchemaForVariablePath, getSchemaOptions, hasRequiredPropertyShape, isTypeMatch, isValidOption, nextLinkSchema, splitAtNearestParentObject, validatePath };
480
498
 
481
499
  //# sourceMappingURL=schemaOptions.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemaOptions.mjs","names":[],"sources":["../../lib/schemaOptions.ts"],"sourcesContent":["import { compact, flatten, last, sortBy, trim } from 'lodash-es';\n\nimport { assertNever } from './assertNever';\nimport {\n JsonSchemaAllTypes,\n type JsonSchemaCustomTypes,\n JsonSchemaStringifiableTypes,\n EMPTY_JSON_SCHEMA_OBJECT,\n getNonNullableRefSchema,\n genericArrayItemSchema,\n getNonNullableType,\n isConvertedTypeSchema,\n isFileType,\n isFunctionSchema,\n isGenericParameterSchema,\n isJsonSchemaArray,\n isJsonSchemaDate,\n isJsonSchemaDateTime,\n isJsonSchemaObject,\n isJsonSchemaRef,\n isJsonSchemaString,\n isJsonType,\n isPrecedingSchema,\n type JsonSchema,\n type JsonSchemaArray,\n type JsonSchemaBasicTypes,\n type JsonSchemaObject,\n JsonSchemaTypes,\n type JsonSchemaObjectKey,\n} from './jsonSchema';\nimport { getJsonSchemaType } from './jsonSchemaType';\nimport {\n appendedMethodChain,\n type Chain,\n EMPTY_METHOD_CHAIN,\n isIdentifierNode,\n isFunctionNode,\n isStringNode,\n isValid,\n type MethodChainNode,\n MethodChainNodeTypes,\n methodChainToString,\n parseMethodChain,\n parseWithPartialOption,\n type StringNode,\n} from './methodChain';\nimport type { FunctionJsonSchema, ObjectSchemaMap } from './objectSchemaTypes';\nimport {\n getPlatformObjectTypeFromJsonSchema,\n getSchemaId,\n MERGED_SCHEMA_ID,\n PrimitiveSchemaId,\n resolveJssRef,\n} from './platformObject';\n\ntype VariableSchemaObject = {\n value: string;\n schema?: JsonSchema | null;\n isVariable?: boolean;\n};\n\nconst fullNodeName = (node: MethodChainNode): string =>\n `${node.type === MethodChainNodeTypes.CustomFunction ? '@' : ''}${node.name}`;\n\nexport type Option = {\n label: string;\n value: string;\n property: string;\n schema: JsonSchema | FunctionJsonSchema;\n methodChain: Chain | null;\n utility?: boolean;\n workflowObjectKey?: string;\n isVariable?: boolean;\n};\n\nconst SCHEMA_PATH_PATTERN = /\\/schema\\/([a-z][a-z0-9-_]*)/i;\n\n/**\n * Extracts the top-level platform-object key from a schema's `$ref`/`$id`/\n * `objectKey`/`objectType.const` markers. Collapses subtypes to their root\n * (`/schema/verification/document/merged` -> `verification`) because callers\n * compare against top-level `ApiModel` values.\n */\nexport const extractPlatformObjectKey = (\n schema: JsonSchema | null | undefined,\n platformObjectJsonSchema: ObjectSchemaMap = {},\n): string | null => {\n if (!schema) {\n return null;\n }\n if (isJsonSchemaRef(schema)) {\n const refMatch = schema.$ref?.match(SCHEMA_PATH_PATTERN);\n if (refMatch) {\n return refMatch[1];\n }\n return extractPlatformObjectKey(\n resolveJssRef(schema, platformObjectJsonSchema),\n platformObjectJsonSchema,\n );\n }\n if ('$id' in schema && typeof schema.$id === 'string') {\n const idMatch = schema.$id.match(SCHEMA_PATH_PATTERN);\n if (idMatch) {\n return idMatch[1];\n }\n }\n // Serialized PLOB columns carry `objectKey` on a scalar schema (no `$ref`), so\n // read it regardless of `type`, collapsing subtypes to root like the `$ref` branch.\n if ('objectKey' in schema && typeof schema.objectKey === 'string') {\n return schema.objectKey.split('/')[0];\n }\n return getPlatformObjectTypeFromJsonSchema(schema);\n};\n\ntype PossibleType = JsonSchemaTypes | JsonSchemaCustomTypes | JsonSchemaObjectKey;\ntype PossibleArrayType = JsonSchemaBasicTypes | JsonSchemaTypes.Object | JsonSchemaObjectKey;\n\nconst isMatchingType = (\n schema: JsonSchema,\n allowedTypes: PossibleType[],\n allowedArrayTypes: PossibleArrayType[],\n) => {\n if (allowedTypes.length === 0) {\n return true;\n }\n const jsonSchemaType = getJsonSchemaType(schema);\n // If strings are allowed and the field is string-able, let it through.\n if (\n allowedTypes.some((schemaType) => schemaType === JsonSchemaTypes.String) &&\n JsonSchemaStringifiableTypes.some((schemaType) => schemaType === jsonSchemaType)\n ) {\n return true;\n } else if (jsonSchemaType === JsonSchemaAllTypes.Array) {\n const itemsSchema = 'items' in schema ? schema.items : null;\n if (\n !allowedTypes.includes(JsonSchemaAllTypes.Array) ||\n // Don't recurse on array, otherwise we risk matching on objects within the array\n (allowedArrayTypes?.length &&\n !allowedArrayTypes.some((schemaType) => schemaType === getJsonSchemaType(itemsSchema)))\n ) {\n return false;\n }\n } else if (\n jsonSchemaType !== JsonSchemaAllTypes.Object &&\n !allowedTypes.some((schemaType) => schemaType === jsonSchemaType)\n ) {\n return false;\n }\n return true;\n};\n\n// isValidOptionHelper returns true if the schema provided is (in order of precedence)\n// 1) not a disallowed by name\n// AND 2) not a disallowed type\n// AND 3) allowed field by name (either explicitly or implicitly)\n// at each level (we recurse down for object types), we check that the fields at the level fit the above 1,2 and 3\n//\n// 1) is straight forward. if a field is named as disallowed it has the most precedence\n// 2) the field is disallowed by type if the allowedTypes are specified AND\n// - if the field is an array, then\n// - arrays are in allowedTypes\n// - AND (its `items` type is in `allowedArrayTypes` OR `allowedArrayTypes` is empty)\n// - if the field is an object, we do nothing since the recursion is handled at the `isValidOptionHelper` level\n// - else, the field type appears in allowedTypes\n// 3) we can be allowed by name\n// - explicitly, which means the field is named explicitly as an allowedFieldPath (this has precedence)\n// - implicitly, which means that there are no fields explicitly named in allowedFieldPath\n// - an object field can be allowed implicitly if it has at least one valid children\nconst isValidOptionHelper = (\n schema: JsonSchema,\n allowedFieldPaths: Set<string>,\n disallowedFieldPaths: Set<string>,\n allowedTypes: PossibleType[],\n allowedArrayTypes: PossibleArrayType[],\n path: string[],\n platformObjectJsonSchema: ObjectSchemaMap,\n traversedSchemaIds = new Set(),\n): boolean => {\n const resolvedSchema = isJsonSchemaRef(schema)\n ? resolveJssRef(schema, platformObjectJsonSchema)\n : schema;\n\n if (resolvedSchema.$id) {\n if (traversedSchemaIds.has(resolvedSchema.$id)) {\n // We've already traversed this schema ID, which there were no\n // valid types found for it, so return false to avoid infinite loops\n return false;\n } else {\n // If we haven't traversed this schema ID yet, add it to the set\n // This allows us to avoid infinite loops when resolving references\n // in recursive schemas\n traversedSchemaIds.add(resolvedSchema.$id);\n }\n }\n const dotPath = path.join('.');\n if (disallowedFieldPaths.has(dotPath)) {\n return false;\n }\n if (!isMatchingType(resolvedSchema, allowedTypes, allowedArrayTypes)) {\n return false;\n }\n if (allowedFieldPaths.has(dotPath)) {\n return true;\n }\n // if we are here it means\n // - our type is valid\n // - we are not disallowed\n // - we are not explicitly allowed\n // if we are here, we are only valid if\n // - we are an object and at least one of our properties are valid\n // OR, we are not an object and allowedFieldPaths is empty\n const jsonSchemaType = getJsonSchemaType(resolvedSchema);\n if (jsonSchemaType === JsonSchemaTypes.Object) {\n // A schemaless JSON field is an opaque leaf, so it has no child to qualify it as an option.\n if ('fieldType' in resolvedSchema && isJsonType(resolvedSchema.fieldType)) {\n return allowedFieldPaths.size === 0;\n }\n return (\n 'properties' in resolvedSchema &&\n resolvedSchema.properties != null &&\n Object.entries(resolvedSchema.properties).some(([prop, propSchema]) =>\n isValidOptionHelper(\n propSchema,\n allowedFieldPaths,\n disallowedFieldPaths,\n allowedTypes,\n allowedArrayTypes,\n [...path, prop],\n platformObjectJsonSchema,\n traversedSchemaIds,\n ),\n )\n );\n }\n return allowedFieldPaths.size === 0;\n};\n\nexport const isValidOption = (\n schema: JsonSchema,\n allowedFieldPaths: string[],\n disallowedFieldPaths: string[],\n allowedTypes: PossibleType[],\n allowedArrayTypes: PossibleArrayType[],\n path: string[] = [],\n platformObjectJsonSchema: ObjectSchemaMap,\n): boolean => {\n const allowedFieldPathsSet =\n allowedFieldPaths == null ? new Set<string>() : new Set<string>(allowedFieldPaths);\n const disallowedFieldPathsSet =\n disallowedFieldPaths == null ? new Set<string>() : new Set<string>(disallowedFieldPaths);\n if (\n allowedFieldPathsSet.size === 0 &&\n disallowedFieldPathsSet.size === 0 &&\n allowedTypes.length === 0 &&\n allowedArrayTypes.length === 0\n ) {\n return true;\n }\n return isValidOptionHelper(\n schema,\n allowedFieldPathsSet,\n disallowedFieldPathsSet,\n allowedTypes ?? [],\n allowedArrayTypes ?? [],\n path,\n platformObjectJsonSchema,\n );\n};\n\nconst buildSchemaOptionsFor = (rootSchema: JsonSchemaObject, baseChain: Chain | null) =>\n Object.entries(rootSchema?.properties ?? {}).map(([property, propSchema]) => {\n const appended = appendedMethodChain(baseChain ?? EMPTY_METHOD_CHAIN, property);\n return {\n label: methodChainToString(appended),\n value: methodChainToString(appended),\n property,\n schema: propSchema,\n methodChain: appended,\n workflowObjectKey: 'objectKey' in propSchema ? propSchema.objectKey : undefined,\n isVariable: 'isVariable' in propSchema ? propSchema.isVariable : false,\n };\n });\n\nconst getSupportedArrayFunctions = (\n schema: JsonSchema,\n arrayPrimitive: JsonSchemaObject,\n): string[] => {\n if (isJsonSchemaArray(schema) && schema['supportedFunctions']) {\n return schema['supportedFunctions'];\n }\n return arrayPrimitive['baseSupportedFunctions'] ?? [];\n};\n\nexport const getSchemaOptions = ({\n option,\n optionFilters,\n platformObjectJsonSchema,\n primitiveUtilities,\n digPrimitives = false,\n}: {\n option: Pick<Option, 'schema' | 'methodChain'>;\n optionFilters?: OptionFilters;\n platformObjectJsonSchema: ObjectSchemaMap;\n primitiveUtilities: ObjectSchemaMap;\n digPrimitives?: boolean;\n}): Option[] => {\n const { schema, methodChain } = option;\n const nullableRefSchema = getNonNullableRefSchema(schema);\n const baseSchema = nullableRefSchema ?? schema;\n const refResolved = isJsonSchemaRef(baseSchema)\n ? resolveJssRef(baseSchema, platformObjectJsonSchema)\n : baseSchema;\n const nonNullable = refResolved && getNonNullableType(refResolved);\n const resolvedSchema = nonNullable\n ? ({ ...refResolved, type: nonNullable } as JsonSchema)\n : refResolved;\n const schemaType = getJsonSchemaType(resolvedSchema);\n\n const schemaOptions = (() => {\n switch (schemaType) {\n case JsonSchemaAllTypes.Object:\n return buildSchemaOptionsFor(resolvedSchema as JsonSchemaObject, methodChain);\n case JsonSchemaAllTypes.Array:\n case JsonSchemaAllTypes.MultiEnum: {\n if (!digPrimitives) {\n return [];\n }\n const arrayPrimitive = primitiveUtilities[PrimitiveSchemaId.Array];\n if (!arrayPrimitive) {\n return [];\n }\n const allOptions = buildSchemaOptionsFor(arrayPrimitive, methodChain);\n const supported = getSupportedArrayFunctions(resolvedSchema, arrayPrimitive);\n return allOptions.filter((opt) => supported.includes(opt.property));\n }\n case JsonSchemaAllTypes.String:\n return digPrimitives\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.String], methodChain)\n : [];\n case JsonSchemaAllTypes.Enum: {\n if (digPrimitives && isJsonSchemaString(resolvedSchema)) {\n return buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.String], methodChain);\n }\n return [];\n }\n case JsonSchemaAllTypes.File:\n return digPrimitives\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.File], methodChain)\n : [];\n // Integer/Number share a single /schema/number bucket — see the collapse\n // in `getPrimitiveSchemaId` and the backend `JSON_TYPE_TO_SCHEMA_ID`. The\n // default mock primitives don't ship utilities for these, so the lookup\n // returns CCFs only (the only properties merged in by `useChain`).\n case JsonSchemaAllTypes.Integer:\n case JsonSchemaAllTypes.Number:\n return digPrimitives && primitiveUtilities[PrimitiveSchemaId.Number]\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.Number], methodChain)\n : [];\n case JsonSchemaAllTypes.Boolean:\n return digPrimitives && primitiveUtilities[PrimitiveSchemaId.Boolean]\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.Boolean], methodChain)\n : [];\n // Date and Datetime are distinct buckets, mirroring the backend\n // `PlatformPrimitive::Date` / `PlatformPrimitive::Datetime` split. A\n // calendar-only Date receiver shouldn't surface CCFs authored against\n // timezone-bearing Datetimes (or vice versa).\n case JsonSchemaAllTypes.Date:\n return digPrimitives && primitiveUtilities[PrimitiveSchemaId.Date]\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.Date], methodChain)\n : [];\n case JsonSchemaAllTypes.Datetime:\n return digPrimitives && primitiveUtilities[PrimitiveSchemaId.Datetime]\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.Datetime], methodChain)\n : [];\n case JsonSchemaAllTypes.GroupedEnum:\n case JsonSchemaAllTypes.Null:\n case JsonSchemaAllTypes.Relation:\n case JsonSchemaAllTypes.MaskedString:\n case JsonSchemaAllTypes.Unknown:\n return [];\n default:\n assertNever(schemaType);\n }\n })();\n\n // After a possibly-null value, offer a CCF only when its receiver schema\n // accepts null. Non-CCF members stay for nullable `type` arrays but not\n // for a nullable `$ref | null` union, whose member paths `nextLinkSchema`\n // cannot resolve.\n const possiblyNull = nullableRefSchema != null || nonNullable != null;\n const nullSafeOptions = possiblyNull\n ? schemaOptions.filter((opt) => {\n if (isFunctionSchema(opt.schema) && opt.schema.codeChainFunctionToken != null) {\n return opt.schema.acceptsNullReceiver === true;\n }\n return nullableRefSchema == null;\n })\n : schemaOptions;\n\n const containsFilters = optionFilters && !!flatten(compact(Object.values(optionFilters))).length;\n const finalOptions = containsFilters\n ? filterForAllowedSchemaOptions(nullSafeOptions, optionFilters, platformObjectJsonSchema)\n : nullSafeOptions;\n return sortBy(finalOptions, (opt: Option) => opt.property.replace(/^@/, '')) as Option[];\n};\n\nexport const formatDisplayValue = (value: any) => {\n return typeof value === 'string' ? value : trim(JSON.stringify(value, null, 1), '\"');\n};\n\n/**\n * Resolves the schema at a dotted path (e.g. \"account.birthDate\").\n * Tries direct key lookup first, then traverses into nested object .properties by path part.\n * Normalizes kebab/snake at each level for key lookup.\n */\nexport function getSchemaByPath(\n properties: Record<string, JsonSchema> | null | undefined,\n path: string,\n): JsonSchema | undefined {\n if (!properties || !path) {\n return undefined;\n }\n\n const lookup = (props: Record<string, JsonSchema>, key: string): JsonSchema | undefined =>\n props[key] ?? props[key.replace(/_/g, '-')] ?? props[key.replace(/-/g, '_')];\n\n const byFullPath = lookup(properties, path);\n if (byFullPath != null) {\n return byFullPath;\n }\n\n const i = path.indexOf('.');\n if (i === -1) {\n return undefined;\n }\n const nestedKey = path.slice(0, i);\n const rest = path.slice(i + 1);\n const next = lookup(properties, nestedKey);\n if (next == null || !isJsonSchemaObject(next) || !next.properties) {\n return undefined;\n }\n return getSchemaByPath(next.properties, rest);\n}\n\nconst parseMethodChainForJSS = (path: string): Chain | null => {\n const { methodChain, partial, valid } = parseWithPartialOption(path);\n if (!valid) {\n return null;\n }\n\n if (partial.length > 0) {\n return appendedMethodChain(methodChain, partial);\n }\n\n return methodChain;\n};\n\nexport const getSchemaForFieldPath = ({\n path,\n initialSchema,\n platformObjectJsonSchema = {},\n primitiveUtilities = {},\n}: {\n path: string;\n initialSchema: JsonSchema;\n platformObjectJsonSchema?: ObjectSchemaMap;\n primitiveUtilities?: ObjectSchemaMap;\n}): {\n schema: JsonSchema | null;\n propertyName: string | null;\n} => {\n if (!initialSchema || (!('type' in initialSchema) && !('$ref' in initialSchema))) {\n return { schema: null, propertyName: null };\n }\n\n const schema: JsonSchema = isJsonSchemaRef(initialSchema)\n ? resolveJssRef(initialSchema, platformObjectJsonSchema)\n : initialSchema;\n\n if (path === '' || !isValid(path)) {\n return { schema: null, propertyName: null };\n }\n const methodChain = parseMethodChain(path);\n if (!methodChain) {\n return { schema: null, propertyName: null };\n }\n const result = methodChain.links.reduce<JsonSchema | null>((currentSchema, link) => {\n return nextLinkSchema({\n currentSchema,\n nextLink: link,\n platformObjectJsonSchema,\n primitiveUtilities,\n });\n }, schema);\n\n const propertyName = result ? last(methodChain.links)?.name || null : null;\n return { schema: result, propertyName };\n};\n\n/**\n * Get the schema for a variable path from usableObjects.\n */\nexport const getSchemaForVariablePath = ({\n path,\n usableObjects,\n}: {\n path: string;\n usableObjects: VariableSchemaObject[];\n}): {\n schema: JsonSchema | null;\n propertyName: string | null;\n} => {\n // just variables\n const syntheticSchema: JsonSchemaObject = {\n type: JsonSchemaTypes.Object,\n properties: Object.fromEntries(\n usableObjects\n .filter((obj) => obj.schema != null && obj.isVariable === true)\n .map((obj) => [obj.value, obj.schema!]),\n ),\n };\n\n return getSchemaForFieldPath({\n path,\n initialSchema: syntheticSchema,\n });\n};\n\nconst getPrimitiveSchemaId = (schema: JsonSchema): string | null => {\n if (!('type' in schema)) {\n return null;\n }\n // File type has special naming: 'file' -> '/schema/field/file'\n // because the backend uses Field::File.name.underscore = 'field/file'\n // File fields have type: 'object' with fieldType: 'file'\n if (isJsonSchemaObject(schema) && isFileType(schema.fieldType)) {\n return PrimitiveSchemaId.File;\n }\n // Date and Datetime are encoded as `{type: 'string', format: 'date'|'date-time'}`.\n // Check before the generic string branch so date receivers don't bucket as String.\n if (isJsonSchemaDate(schema)) {\n return PrimitiveSchemaId.Date;\n }\n if (isJsonSchemaDateTime(schema)) {\n return PrimitiveSchemaId.Datetime;\n }\n const type = Array.isArray(schema.type) ? getNonNullableType(schema) : schema.type;\n if (!type) {\n return null;\n }\n // Integer and Number share one CCF bucket — mirrors the backend collapse\n // in JSON_TYPE_TO_SCHEMA_ID. A CCF authored against a Number receiver\n // fires for both .length-style integers and float-typed values.\n if (type === JsonSchemaTypes.Integer || type === JsonSchemaTypes.Number) {\n return PrimitiveSchemaId.Number;\n }\n if (type === JsonSchemaTypes.Boolean) {\n return PrimitiveSchemaId.Boolean;\n }\n return getSchemaId(type);\n};\n\nexport const nextLinkSchema = ({\n currentSchema,\n nextLink,\n platformObjectJsonSchema,\n primitiveUtilities,\n}: {\n currentSchema: JsonSchema | null;\n nextLink: MethodChainNode;\n platformObjectJsonSchema: ObjectSchemaMap;\n primitiveUtilities: ObjectSchemaMap;\n}): JsonSchema | null => {\n if (!currentSchema) {\n return null;\n }\n // Runtime dispatches a typed null only to a CCF whose receiver schema\n // accepts null, so a nullable value resolves only through such CCFs.\n if (nextLink.type === MethodChainNodeTypes.CustomFunction) {\n const unwrapped = getNonNullableRefSchema(currentSchema);\n const nonNullType = unwrapped ? null : getNonNullableType(currentSchema);\n const receiver =\n unwrapped ?? (nonNullType ? ({ ...currentSchema, type: nonNullType } as JsonSchema) : null);\n if (receiver) {\n const fn = getFunctionSchemaForNode({\n parentSchema: currentSchema,\n functionName: fullNodeName(nextLink),\n isCustomFunction: true,\n platformObjectJsonSchema,\n primitiveUtilities,\n });\n if (fn?.acceptsNullReceiver !== true) {\n return null;\n }\n currentSchema = receiver;\n }\n }\n if (isJsonSchemaRef(currentSchema)) {\n currentSchema = resolveJssRef(currentSchema, platformObjectJsonSchema);\n } else if (isJsonSchemaArray(currentSchema) && isJsonSchemaRef(currentSchema.items)) {\n currentSchema = {\n ...currentSchema,\n items: {\n ...resolveJssRef(currentSchema.items, platformObjectJsonSchema),\n },\n };\n }\n if (!('type' in currentSchema)) {\n return null;\n }\n\n const schemaId = getPrimitiveSchemaId(currentSchema);\n if (schemaId && schemaId in primitiveUtilities) {\n const utilityReturnType = getPrimitiveUtilitiesReturnSchema(\n currentSchema,\n nextLink,\n primitiveUtilities[schemaId],\n );\n if (utilityReturnType) {\n return utilityReturnType;\n }\n }\n if ('properties' in currentSchema) {\n const propertySchema = currentSchema.properties[fullNodeName(nextLink)];\n if (propertySchema && isFunctionSchema(propertySchema)) {\n return propertySchema.properties.returnType;\n }\n return propertySchema ?? null;\n }\n return null;\n};\n\n/**\n * Returns the FunctionJsonSchema for `functionName` within `parentSchema`, checking both\n * primitive utilities (e.g. array/string methods) and direct object properties.\n * Returns null if not found or not a function schema.\n */\nexport const getFunctionSchemaForNode = ({\n parentSchema,\n functionName,\n isCustomFunction,\n platformObjectJsonSchema,\n primitiveUtilities,\n}: {\n parentSchema: JsonSchema;\n functionName: string;\n isCustomFunction: boolean;\n platformObjectJsonSchema: ObjectSchemaMap;\n primitiveUtilities: ObjectSchemaMap;\n}): FunctionJsonSchema | null => {\n if (isCustomFunction) {\n parentSchema = getNonNullableRefSchema(parentSchema) ?? parentSchema;\n }\n if (isJsonSchemaRef(parentSchema)) {\n parentSchema = resolveJssRef(parentSchema, platformObjectJsonSchema);\n }\n\n const schemaId = getPrimitiveSchemaId(parentSchema);\n if (schemaId && schemaId in primitiveUtilities) {\n const utilitySchema = primitiveUtilities[schemaId].properties[functionName];\n if (utilitySchema && isFunctionSchema(utilitySchema)) {\n return utilitySchema;\n }\n }\n\n if (isJsonSchemaObject(parentSchema) && functionName in parentSchema.properties) {\n const propSchema = parentSchema.properties[functionName];\n if (isFunctionSchema(propSchema)) {\n return propSchema;\n }\n }\n\n return null;\n};\n\n// When the result is an array of platform objects (identified by objectKey on items),\n// inject a $ref so the schema structure matches has_many associations.\n// This ensures consistent operator options in conditionals.\nconst injectRefForPlatformObjectArray = (schema: JsonSchema | null): JsonSchema | null => {\n if (\n schema &&\n isJsonSchemaArray(schema) &&\n isJsonSchemaObject(schema.items) &&\n 'objectKey' in schema.items &&\n schema.items.objectKey\n ) {\n const schemaId = getSchemaId(schema.items.objectKey, MERGED_SCHEMA_ID);\n return {\n ...schema,\n items: {\n ...schema.items,\n $ref: schemaId,\n },\n };\n }\n return schema;\n};\n\nconst getPrimitiveUtilitiesReturnSchema = (\n object: JsonSchema,\n node: MethodChainNode,\n schema: JsonSchemaObject<JsonSchema | FunctionJsonSchema>,\n): JsonSchema | null => {\n const name = fullNodeName(node);\n if (!(name in schema.properties)) {\n return null;\n }\n\n const utilitySchema = schema.properties[name];\n\n const returnSchema = isFunctionSchema(utilitySchema)\n ? utilitySchema.properties.returnType\n : utilitySchema;\n\n const itemSchema = genericArrayItemSchema(object, returnSchema);\n if (itemSchema) {\n return itemSchema;\n }\n\n if (isPrecedingSchema(returnSchema)) {\n return object;\n }\n\n if (\n isConvertedTypeSchema(returnSchema) &&\n isFunctionNode(node) &&\n node.params[returnSchema.position] &&\n isStringNode(node.params[returnSchema.position])\n ) {\n const stringNode = node.params[returnSchema.position] as StringNode;\n return returnSchema.schemaByValue[stringNode.value] ?? EMPTY_JSON_SCHEMA_OBJECT;\n }\n\n if (\n isGenericParameterSchema(returnSchema) &&\n isFunctionNode(node) &&\n node.params[returnSchema.position] &&\n isStringNode(node.params[returnSchema.position])\n ) {\n const stringNode = node.params[returnSchema.position] as StringNode;\n const objectSchema = isJsonSchemaArray(object) ? object.items : object;\n if (isJsonSchemaObject(objectSchema)) {\n const path = stringNode.value.split('.');\n const resultSchema = path.reduce<JsonSchema | null>((schema, key) => {\n if (schema == null || !isJsonSchemaObject(schema) || !schema.properties[key]) {\n return null;\n }\n return schema.properties[key];\n }, objectSchema);\n\n return injectRefForPlatformObjectArray(resultSchema);\n }\n }\n\n return 'genericType' in returnSchema ? EMPTY_JSON_SCHEMA_OBJECT : returnSchema;\n};\n\n/**\n * @param path\n * @param allowedFieldPaths - can be a complete path to a base type field\n * (e.g. 'data.some.string_field'), or a partial path to an object ('data')\n * @param fieldPathsAreStrictMatch - true if we only want to match exact paths in allowedFieldPaths and disallowedFieldPaths\n */\nconst isAllowedPath = (path: string, allowedFieldPaths: string[]) => {\n return allowedFieldPaths.some((fieldPath) => {\n const valueIsPartialMatch = fieldPath.startsWith(path);\n const valueIsNestedProp = path.startsWith(`${fieldPath}.`);\n return valueIsPartialMatch || valueIsNestedProp;\n });\n};\n\n/**\n * @param path\n * @param disallowedFieldPaths - can be a complete path to a base type field\n * (e.g. 'data.some.string_field'), or a partial path to an object ('data')\n */\nconst isDisallowedPath = (path: string, disallowedFieldPaths: string[]) => {\n return disallowedFieldPaths.some((fieldPath) => {\n const valueIsMatch = fieldPath === path;\n const valueIsNestedProp = path.startsWith(`${fieldPath}.`);\n return valueIsMatch || valueIsNestedProp;\n });\n};\n\nexport const isTypeMatch = ({\n fieldJsonSchema,\n types,\n platformObjectJsonSchema = {},\n arrayTypes,\n traversedSchemaIds = new Set(),\n}: {\n fieldJsonSchema: JsonSchema;\n types: PossibleType[];\n platformObjectJsonSchema: ObjectSchemaMap;\n arrayTypes?: PossibleArrayType[];\n traversedSchemaIds?: Set<string>;\n}): boolean => {\n const resolvedSchema = isJsonSchemaRef(fieldJsonSchema)\n ? resolveJssRef(fieldJsonSchema, platformObjectJsonSchema)\n : fieldJsonSchema;\n\n if (resolvedSchema.$id) {\n if (traversedSchemaIds.has(resolvedSchema.$id)) {\n // We've already traversed this schema ID, which there were no\n // valid types found for it, so return false to avoid infinite loops\n return false;\n } else {\n // If we haven't traversed this schema ID yet, add it to the set\n // This allows us to avoid infinite loops when resolving references\n // in recursive schemas\n traversedSchemaIds.add(resolvedSchema.$id);\n }\n }\n\n const fieldJsonSchemaType = getJsonSchemaType(resolvedSchema);\n switch (fieldJsonSchemaType) {\n case JsonSchemaAllTypes.Object: {\n const objectSchema = resolvedSchema as JsonSchemaObject;\n // For generic JsonSchemaObjectKey such as 'report' or 'verification', we match on subtypes\n // like 'business-watchlist' as well; otherwise, generics don't show anything\n const isObjectKeyOfType = (type: JsonSchemaObjectKey) =>\n objectSchema.objectKey &&\n types.includes(type) &&\n objectSchema.objectKey.split('/')[0] === type;\n\n if (\n types.includes(JsonSchemaTypes.Object) ||\n (objectSchema.objectKey && types.includes(objectSchema.objectKey)) ||\n isObjectKeyOfType('report') ||\n isObjectKeyOfType('verification')\n ) {\n return true;\n }\n\n return Object.values(objectSchema.properties || {}).some((propJsonSchema) =>\n isTypeMatch({\n fieldJsonSchema: propJsonSchema,\n types,\n platformObjectJsonSchema,\n arrayTypes,\n traversedSchemaIds: traversedSchemaIds,\n }),\n );\n }\n case JsonSchemaAllTypes.Array: {\n const arraySchema = resolvedSchema as JsonSchemaArray;\n const itemSchema = isJsonSchemaRef(arraySchema.items)\n ? resolveJssRef(arraySchema.items, platformObjectJsonSchema)\n : arraySchema.items;\n return (\n types.includes(JsonSchemaAllTypes.Array) &&\n // Don't recurse on array, otherwise we risk matching on objects within the array\n !!arrayTypes &&\n arrayTypes.some(\n (schemaType) =>\n schemaType === getJsonSchemaType(itemSchema) ||\n (isJsonSchemaObject(itemSchema) && schemaType === itemSchema.objectKey),\n )\n );\n }\n case JsonSchemaAllTypes.String:\n case JsonSchemaAllTypes.Number:\n case JsonSchemaAllTypes.Boolean:\n case JsonSchemaAllTypes.Integer:\n case JsonSchemaAllTypes.Date:\n case JsonSchemaAllTypes.Datetime:\n case JsonSchemaAllTypes.Enum:\n case JsonSchemaAllTypes.MultiEnum:\n case JsonSchemaAllTypes.GroupedEnum:\n case JsonSchemaAllTypes.Unknown: {\n return types.some((schemaType) => schemaType === fieldJsonSchemaType);\n }\n default:\n return false;\n }\n};\n\nexport interface OptionFilters {\n allowedArrayTypes?: PossibleArrayType[];\n allowedFieldPaths?: string[];\n allowedTypes?: PossibleType[];\n disallowedFieldPaths?: string[];\n fieldPathsAreStrictMatch?: boolean;\n requiredPropertyShape?: string[]; // Array of property names that must exist in the schema\n}\n\nexport const hasRequiredPropertyShape = (\n schema: JsonSchema,\n requiredPropertyShape: string[],\n platformObjectJsonSchema: ObjectSchemaMap = {},\n checkRecursively: boolean = true,\n): boolean => {\n if (!requiredPropertyShape?.length) {\n return true;\n }\n\n const resolvedSchema = isJsonSchemaRef(schema)\n ? resolveJssRef(schema, platformObjectJsonSchema)\n : schema;\n\n if (\n resolvedSchema &&\n 'type' in resolvedSchema &&\n resolvedSchema.type === JsonSchemaTypes.Object &&\n 'properties' in resolvedSchema &&\n resolvedSchema.properties\n ) {\n const schemaProperties = resolvedSchema.properties as Record<string, JsonSchema>;\n const hasAllProperties = requiredPropertyShape.every(\n (propName) => propName in schemaProperties,\n );\n\n if (hasAllProperties) {\n return true;\n }\n\n if (checkRecursively) {\n return Object.values(schemaProperties).some((propSchema) =>\n hasRequiredPropertyShape(\n propSchema,\n requiredPropertyShape,\n platformObjectJsonSchema,\n checkRecursively,\n ),\n );\n }\n }\n return false;\n};\n\nconst filterForAllowedSchemaOptions = (\n options: Option[] = [],\n {\n allowedArrayTypes,\n allowedFieldPaths,\n allowedTypes,\n disallowedFieldPaths,\n fieldPathsAreStrictMatch,\n requiredPropertyShape,\n }: OptionFilters,\n platformObjectJsonSchema: ObjectSchemaMap = {},\n) => {\n let filteredOptions = options;\n\n if (fieldPathsAreStrictMatch) {\n if (allowedFieldPaths?.length || disallowedFieldPaths?.length || allowedTypes?.length) {\n filteredOptions = filteredOptions.filter((option) =>\n isValidOption(\n option.schema,\n allowedFieldPaths ?? [],\n disallowedFieldPaths ?? [],\n allowedTypes ?? [],\n allowedArrayTypes ?? [],\n option.value.split('.'),\n platformObjectJsonSchema,\n ),\n );\n }\n } else {\n if (allowedFieldPaths?.length) {\n filteredOptions = filteredOptions.filter((option) =>\n isAllowedPath(option.value, allowedFieldPaths),\n );\n }\n if (disallowedFieldPaths?.length) {\n filteredOptions = filteredOptions.filter(\n (option) => !isDisallowedPath(option.value, disallowedFieldPaths),\n );\n }\n if (allowedTypes?.length) {\n filteredOptions = filteredOptions.filter((option) =>\n isTypeMatch({\n fieldJsonSchema: option.schema,\n types: allowedTypes,\n platformObjectJsonSchema,\n arrayTypes: allowedArrayTypes,\n }),\n );\n }\n }\n\n // Add a recursive function to check if schema or any nested schema has the required properties\n if (requiredPropertyShape?.length) {\n filteredOptions = filteredOptions.filter((option) =>\n hasRequiredPropertyShape(option.schema, requiredPropertyShape, platformObjectJsonSchema),\n );\n }\n\n return filteredOptions;\n};\n\nexport const getOptionForValue = ({\n value,\n jsonSchema,\n schemaForFieldPath,\n}: {\n value: string;\n jsonSchema: JsonSchema;\n schemaForFieldPath: (\n path: string,\n initialSchema: JsonSchema,\n ) => { schema: JsonSchema | null; propertyName: string | null };\n}): Option | null => {\n const { schema, propertyName } = schemaForFieldPath(value, jsonSchema);\n if (!schema || !propertyName) {\n return null;\n }\n\n const methodChain = parseMethodChainForJSS(value);\n return {\n label: methodChain ? methodChainToString(methodChain) : value,\n value: methodChain ? methodChainToString(methodChain) : value,\n property: propertyName,\n schema,\n methodChain,\n };\n};\n\nexport const validatePath = ({\n path,\n jsonSchema,\n platformObjectJsonSchema = {},\n primitiveUtilities = {},\n optionFilters,\n}: {\n path: string;\n jsonSchema: JsonSchema;\n platformObjectJsonSchema: ObjectSchemaMap;\n primitiveUtilities: ObjectSchemaMap;\n optionFilters?: OptionFilters;\n}) => {\n const schemaOptions = getSchemaOptions({\n option: { schema: jsonSchema, methodChain: parseMethodChainForJSS('') },\n optionFilters,\n platformObjectJsonSchema,\n primitiveUtilities,\n });\n const { methodChain, partial } = parseWithPartialOption(path);\n\n const matchedSchemaOptions = methodChain.links.reduce<Option[]>((currentSchema, link) => {\n if (currentSchema.length === 0) {\n return [];\n }\n const optionMatch = currentSchema.find((option) => option.property === link.name);\n if (optionMatch) {\n return getSchemaOptions({\n option: optionMatch,\n optionFilters,\n platformObjectJsonSchema,\n primitiveUtilities,\n });\n }\n return [];\n }, schemaOptions);\n\n const optionsWithPartiallyMatchedFinalLink = matchedSchemaOptions.filter((option) =>\n option.property.includes(partial),\n );\n return {\n valid: optionsWithPartiallyMatchedFinalLink.length > 0,\n schemaOptions: optionsWithPartiallyMatchedFinalLink,\n partial,\n };\n};\n\n/**\n * Given a method chain that corresponds to the passed schema, find the right-most indentifier that\n * is a platform object and split the method chain on that identifier, with the platform object on\n * the left side.\n *\n * This function is used to optimize a method chain into two parts, left side for server resolution\n * and right side for client resolution.\n *\n * For example:\n * current_case.fields.field_a -> ['current_case', 'fields.field_a']\n * current_case.inquiries.first.id -> ['current_case.inquiries.first', 'id']\n * current_case.account.fields.field_b -> ['current_case.account', 'fields.field_b']\n */\nexport const splitAtNearestParentObject = (\n chain: Chain,\n currentSchema: JsonSchemaObject,\n platformSchemaMap: ObjectSchemaMap,\n primitiveUtilities: ObjectSchemaMap,\n): [leftChain: Chain, rightChain: Chain] => {\n // Create a list of schemas that match each link in the method chain.\n // The list is reversed such that the first schema matches the last link of the method chain\n // for the next step.\n const leafUpLinkSchemas: (JsonSchema | null)[] = [currentSchema];\n for (const link of chain.links) {\n const nextSchema = nextLinkSchema({\n currentSchema: leafUpLinkSchemas[0],\n nextLink: link,\n platformObjectJsonSchema: platformSchemaMap,\n primitiveUtilities,\n });\n leafUpLinkSchemas.unshift(nextSchema);\n }\n\n // List of links that correspond to the left and right sides of the split.\n // As we walk the schema from leaf to root, we move links to the right side.\n const leafUpLeftLinks = [...chain.links].reverse();\n const leafUpRightLinks: typeof leafUpLeftLinks = [];\n\n for (const [i, linkSchema] of leafUpLinkSchemas.entries()) {\n if (!linkSchema) {\n // When the schema is unknown, check if the current link is an identifier accessing a\n // property on an unresolvable platform object ref. If any remaining schema in the\n // ancestor chain is a $ref (or array of $refs), we're within a platform object whose\n // schema couldn't be resolved — push the identifier to the client (right) side.\n if (isIdentifierNode(leafUpLeftLinks[0])) {\n const nearestPlatformAncestor = leafUpLinkSchemas\n .slice(i + 1)\n .find(\n (s) => s && (isJsonSchemaRef(s) || (isJsonSchemaArray(s) && isJsonSchemaRef(s.items))),\n );\n if (nearestPlatformAncestor) {\n leafUpRightLinks.push(leafUpLeftLinks.shift()!);\n continue;\n }\n }\n // If we are missing schema, break out asap to keep links on the left.\n break;\n } else if ('$id' in linkSchema || isJsonSchemaRef(linkSchema)) {\n break;\n } else if (isJsonSchemaArray(linkSchema)) {\n if ('$id' in linkSchema.items || isJsonSchemaRef(linkSchema.items)) {\n break;\n }\n // Array-returning functions (filter, sort, etc.) on platform object arrays\n // must be resolved server-side even when the items ref cannot be resolved.\n if (isFunctionNode(leafUpLeftLinks[0])) {\n break;\n }\n } else if (isFunctionNode(leafUpLeftLinks[0])) {\n break;\n } else if (isIdentifierNode(leafUpLeftLinks[0])) {\n const nextSchema = leafUpLinkSchemas[i + 1];\n // If the preceding schema has a primitive schema ID in the utilities, the identifier\n // was resolved via primitive utilities (e.g. 'trim' on a string, 'count' on an array).\n // The server handles these inline, so keep the whole chain server-side.\n if (nextSchema) {\n const primitiveId = getPrimitiveSchemaId(nextSchema);\n if (primitiveId && primitiveId in primitiveUtilities) {\n break;\n }\n }\n // Real special case here. If:\n // - The current link is an identifier\n // - The next schema is an array\n // = break out, because we don't want to load the whole array into the client\n if (nextSchema && isJsonSchemaArray(nextSchema)) {\n break;\n }\n }\n\n leafUpRightLinks.push(leafUpLeftLinks.shift()!);\n }\n\n const leftChain: Chain = {\n type: MethodChainNodeTypes.Chain,\n links: leafUpLeftLinks.reverse(),\n };\n const rightChain: Chain = {\n type: MethodChainNodeTypes.Chain,\n links: leafUpRightLinks.reverse(),\n };\n return [leftChain, rightChain];\n};\n"],"mappings":";;;;;;AA6DA,MAAM,gBAAgB,SACpB,GAAG,KAAK,SAAS,qBAAqB,iBAAiB,MAAM,KAAK,KAAK;AAazE,MAAM,sBAAsB;;;;;;;AAQ5B,MAAa,4BACX,QACA,2BAA4C,EAAE,KAC5B;AAClB,KAAI,CAAC,OACH,QAAO;AAET,KAAI,gBAAgB,OAAO,EAAE;EAC3B,MAAM,WA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EAAE,MAAM,EAE7D,EAAE;AAC3B,sBAAiB,KAAK,gBAAgB,OAAO,CAAE;AAC/C;;;AAIJ;aACS,SAAS,cAAc,gBAAgB,WAAW,CAC3D;WACS,kBAAkB,WAAW,EAAE;AACxC,OAAI,SAAS,WAAW,SAAS,gBAAgB,WAAW,MAAM,CAChE;AAIF,OAAI,eAAe,gBAAgB,GAAG,CACpC;aAEO,eAAe,gBAAgB,GAAG,CAC3C;WACS,iBAAiB,gBAAgB,GAAG,EAAE;GAC/C,MAAM,aAAa,kBAAkB,IAAI;AAIzC,OAAI,YAAY;IACd,MAAM,cAAc,qBAAqB,WAAW;AACpD,QAAI,eAAe,eAAe,mBAChC;;AAOJ,OAAI,cAAc,kBAAkB,WAAW,CAC7C;;AAIJ,mBAAiB,KAAK,gBAAgB,OAAO,CAAE;;AAWjD,QAAO,CAAC;EAPN,MAAM,qBAAqB;EAC3B,OAAO,gBAAgB,SAAS;EAMjB,EAAE;EAHjB,MAAM,qBAAqB;EAC3B,OAAO,iBAAiB,SAAS;EAEN,CAAC"}
1
+ {"version":3,"file":"schemaOptions.mjs","names":[],"sources":["../../lib/schemaOptions.ts"],"sourcesContent":["import { compact, flatten, last, sortBy, trim } from 'lodash-es';\n\nimport { assertNever } from './assertNever';\nimport {\n JsonSchemaAllTypes,\n type JsonSchemaCustomTypes,\n JsonSchemaStringifiableTypes,\n EMPTY_JSON_SCHEMA_OBJECT,\n getNonNullableRefSchema,\n genericArrayItemSchema,\n getNonNullableType,\n isConvertedTypeSchema,\n isFileType,\n isFunctionSchema,\n isGenericParameterSchema,\n isJsonSchemaArray,\n isJsonSchemaDate,\n isJsonSchemaDateTime,\n isJsonSchemaObject,\n isJsonSchemaRef,\n isJsonSchemaString,\n isJsonType,\n isPrecedingSchema,\n type JsonSchema,\n type JsonSchemaArray,\n type JsonSchemaBasicTypes,\n type JsonSchemaObject,\n JsonSchemaTypes,\n type JsonSchemaObjectKey,\n} from './jsonSchema';\nimport { getJsonSchemaType } from './jsonSchemaType';\nimport {\n appendedMethodChain,\n type Chain,\n EMPTY_METHOD_CHAIN,\n isIdentifierNode,\n isFunctionNode,\n isStringNode,\n isValid,\n type MethodChainNode,\n MethodChainNodeTypes,\n methodChainToString,\n parseMethodChain,\n parseWithPartialOption,\n type StringNode,\n} from './methodChain';\nimport type { FunctionJsonSchema, ObjectSchemaMap } from './objectSchemaTypes';\nimport {\n getPlatformObjectTypeFromJsonSchema,\n getSchemaId,\n MERGED_SCHEMA_ID,\n PrimitiveSchemaId,\n resolveJssRef,\n} from './platformObject';\n\ntype VariableSchemaObject = {\n value: string;\n schema?: JsonSchema | null;\n isVariable?: boolean;\n};\n\nconst fullNodeName = (node: MethodChainNode): string =>\n `${node.type === MethodChainNodeTypes.CustomFunction ? '@' : ''}${node.name}`;\n\nexport type Option = {\n label: string;\n value: string;\n property: string;\n schema: JsonSchema | FunctionJsonSchema;\n methodChain: Chain | null;\n utility?: boolean;\n workflowObjectKey?: string;\n isVariable?: boolean;\n};\n\nconst SCHEMA_PATH_PATTERN = /\\/schema\\/([a-z][a-z0-9-_]*)/i;\n\n/**\n * Extracts the top-level platform-object key from a schema's `$ref`/`$id`/\n * `objectKey`/`objectType.const` markers. Collapses subtypes to their root\n * (`/schema/verification/document/merged` -> `verification`) because callers\n * compare against top-level `ApiModel` values.\n */\nexport const extractPlatformObjectKey = (\n schema: JsonSchema | null | undefined,\n platformObjectJsonSchema: ObjectSchemaMap = {},\n): string | null => {\n if (!schema) {\n return null;\n }\n if (isJsonSchemaRef(schema)) {\n const refMatch = schema.$ref?.match(SCHEMA_PATH_PATTERN);\n if (refMatch) {\n return refMatch[1];\n }\n return extractPlatformObjectKey(\n resolveJssRef(schema, platformObjectJsonSchema),\n platformObjectJsonSchema,\n );\n }\n if ('$id' in schema && typeof schema.$id === 'string') {\n const idMatch = schema.$id.match(SCHEMA_PATH_PATTERN);\n if (idMatch) {\n return idMatch[1];\n }\n }\n // Serialized PLOB columns carry `objectKey` on a scalar schema (no `$ref`), so\n // read it regardless of `type`, collapsing subtypes to root like the `$ref` branch.\n if ('objectKey' in schema && typeof schema.objectKey === 'string') {\n return schema.objectKey.split('/')[0];\n }\n return getPlatformObjectTypeFromJsonSchema(schema);\n};\n\ntype PossibleType = JsonSchemaTypes | JsonSchemaCustomTypes | JsonSchemaObjectKey;\ntype PossibleArrayType = JsonSchemaBasicTypes | JsonSchemaTypes.Object | JsonSchemaObjectKey;\n\nconst isMatchingType = (\n schema: JsonSchema,\n allowedTypes: PossibleType[],\n allowedArrayTypes: PossibleArrayType[],\n) => {\n if (allowedTypes.length === 0) {\n return true;\n }\n const jsonSchemaType = getJsonSchemaType(schema);\n // If strings are allowed and the field is string-able, let it through.\n if (\n allowedTypes.some((schemaType) => schemaType === JsonSchemaTypes.String) &&\n JsonSchemaStringifiableTypes.some((schemaType) => schemaType === jsonSchemaType)\n ) {\n return true;\n } else if (jsonSchemaType === JsonSchemaAllTypes.Array) {\n const itemsSchema = 'items' in schema ? schema.items : null;\n if (\n !allowedTypes.includes(JsonSchemaAllTypes.Array) ||\n // Don't recurse on array, otherwise we risk matching on objects within the array\n (allowedArrayTypes?.length &&\n !allowedArrayTypes.some((schemaType) => schemaType === getJsonSchemaType(itemsSchema)))\n ) {\n return false;\n }\n } else if (\n jsonSchemaType !== JsonSchemaAllTypes.Object &&\n !allowedTypes.some((schemaType) => schemaType === jsonSchemaType)\n ) {\n return false;\n }\n return true;\n};\n\n// isValidOptionHelper returns true if the schema provided is (in order of precedence)\n// 1) not a disallowed by name\n// AND 2) not a disallowed type\n// AND 3) allowed field by name (either explicitly or implicitly)\n// at each level (we recurse down for object types), we check that the fields at the level fit the above 1,2 and 3\n//\n// 1) is straight forward. if a field is named as disallowed it has the most precedence\n// 2) the field is disallowed by type if the allowedTypes are specified AND\n// - if the field is an array, then\n// - arrays are in allowedTypes\n// - AND (its `items` type is in `allowedArrayTypes` OR `allowedArrayTypes` is empty)\n// - if the field is an object, we do nothing since the recursion is handled at the `isValidOptionHelper` level\n// - else, the field type appears in allowedTypes\n// 3) we can be allowed by name\n// - explicitly, which means the field is named explicitly as an allowedFieldPath (this has precedence)\n// - implicitly, which means that there are no fields explicitly named in allowedFieldPath\n// - an object field can be allowed implicitly if it has at least one valid children\nconst isValidOptionHelper = (\n schema: JsonSchema,\n allowedFieldPaths: Set<string>,\n disallowedFieldPaths: Set<string>,\n allowedTypes: PossibleType[],\n allowedArrayTypes: PossibleArrayType[],\n path: string[],\n platformObjectJsonSchema: ObjectSchemaMap,\n traversedSchemaIds = new Set(),\n): boolean => {\n const resolvedSchema = isJsonSchemaRef(schema)\n ? resolveJssRef(schema, platformObjectJsonSchema)\n : schema;\n\n if (resolvedSchema.$id) {\n if (traversedSchemaIds.has(resolvedSchema.$id)) {\n // We've already traversed this schema ID, which there were no\n // valid types found for it, so return false to avoid infinite loops\n return false;\n } else {\n // If we haven't traversed this schema ID yet, add it to the set\n // This allows us to avoid infinite loops when resolving references\n // in recursive schemas\n traversedSchemaIds.add(resolvedSchema.$id);\n }\n }\n const dotPath = path.join('.');\n if (disallowedFieldPaths.has(dotPath)) {\n return false;\n }\n if (!isMatchingType(resolvedSchema, allowedTypes, allowedArrayTypes)) {\n return false;\n }\n if (allowedFieldPaths.has(dotPath)) {\n return true;\n }\n // if we are here it means\n // - our type is valid\n // - we are not disallowed\n // - we are not explicitly allowed\n // if we are here, we are only valid if\n // - we are an object and at least one of our properties are valid\n // OR, we are not an object and allowedFieldPaths is empty\n const jsonSchemaType = getJsonSchemaType(resolvedSchema);\n if (jsonSchemaType === JsonSchemaTypes.Object) {\n // A schemaless JSON field is an opaque leaf, so it has no child to qualify it as an option.\n if ('fieldType' in resolvedSchema && isJsonType(resolvedSchema.fieldType)) {\n return allowedFieldPaths.size === 0;\n }\n return (\n 'properties' in resolvedSchema &&\n resolvedSchema.properties != null &&\n Object.entries(resolvedSchema.properties).some(([prop, propSchema]) =>\n isValidOptionHelper(\n propSchema,\n allowedFieldPaths,\n disallowedFieldPaths,\n allowedTypes,\n allowedArrayTypes,\n [...path, prop],\n platformObjectJsonSchema,\n traversedSchemaIds,\n ),\n )\n );\n }\n return allowedFieldPaths.size === 0;\n};\n\nexport const isValidOption = (\n schema: JsonSchema,\n allowedFieldPaths: string[],\n disallowedFieldPaths: string[],\n allowedTypes: PossibleType[],\n allowedArrayTypes: PossibleArrayType[],\n path: string[] = [],\n platformObjectJsonSchema: ObjectSchemaMap,\n): boolean => {\n const allowedFieldPathsSet =\n allowedFieldPaths == null ? new Set<string>() : new Set<string>(allowedFieldPaths);\n const disallowedFieldPathsSet =\n disallowedFieldPaths == null ? new Set<string>() : new Set<string>(disallowedFieldPaths);\n if (\n allowedFieldPathsSet.size === 0 &&\n disallowedFieldPathsSet.size === 0 &&\n allowedTypes.length === 0 &&\n allowedArrayTypes.length === 0\n ) {\n return true;\n }\n return isValidOptionHelper(\n schema,\n allowedFieldPathsSet,\n disallowedFieldPathsSet,\n allowedTypes ?? [],\n allowedArrayTypes ?? [],\n path,\n platformObjectJsonSchema,\n );\n};\n\nconst buildSchemaOptionsFor = (rootSchema: JsonSchemaObject, baseChain: Chain | null) =>\n Object.entries(rootSchema?.properties ?? {}).map(([property, propSchema]) => {\n const appended = appendedMethodChain(baseChain ?? EMPTY_METHOD_CHAIN, property);\n return {\n label: methodChainToString(appended),\n value: methodChainToString(appended),\n property,\n schema: propSchema,\n methodChain: appended,\n workflowObjectKey: 'objectKey' in propSchema ? propSchema.objectKey : undefined,\n isVariable: 'isVariable' in propSchema ? propSchema.isVariable : false,\n };\n });\n\nconst getSupportedArrayFunctions = (\n schema: JsonSchema,\n arrayPrimitive: JsonSchemaObject,\n): string[] => {\n if (isJsonSchemaArray(schema) && schema['supportedFunctions']) {\n return schema['supportedFunctions'];\n }\n return arrayPrimitive['baseSupportedFunctions'] ?? [];\n};\n\nexport const getSchemaOptions = ({\n option,\n optionFilters,\n platformObjectJsonSchema,\n primitiveUtilities,\n digPrimitives = false,\n}: {\n option: Pick<Option, 'schema' | 'methodChain'>;\n optionFilters?: OptionFilters;\n platformObjectJsonSchema: ObjectSchemaMap;\n primitiveUtilities: ObjectSchemaMap;\n digPrimitives?: boolean;\n}): Option[] => {\n const { schema, methodChain } = option;\n const nullableRefSchema = getNonNullableRefSchema(schema);\n const baseSchema = nullableRefSchema ?? schema;\n const refResolved = isJsonSchemaRef(baseSchema)\n ? resolveJssRef(baseSchema, platformObjectJsonSchema)\n : baseSchema;\n const nonNullable = refResolved && getNonNullableType(refResolved);\n const resolvedSchema = nonNullable\n ? ({ ...refResolved, type: nonNullable } as JsonSchema)\n : refResolved;\n const schemaType = getJsonSchemaType(resolvedSchema);\n\n const schemaOptions = (() => {\n switch (schemaType) {\n case JsonSchemaAllTypes.Object:\n return buildSchemaOptionsFor(resolvedSchema as JsonSchemaObject, methodChain);\n case JsonSchemaAllTypes.Array:\n case JsonSchemaAllTypes.MultiEnum: {\n if (!digPrimitives) {\n return [];\n }\n const arrayPrimitive = primitiveUtilities[PrimitiveSchemaId.Array];\n if (!arrayPrimitive) {\n return [];\n }\n const allOptions = buildSchemaOptionsFor(arrayPrimitive, methodChain);\n const supported = getSupportedArrayFunctions(resolvedSchema, arrayPrimitive);\n return allOptions.filter((opt) => supported.includes(opt.property));\n }\n case JsonSchemaAllTypes.String:\n return digPrimitives\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.String], methodChain)\n : [];\n case JsonSchemaAllTypes.Enum: {\n if (digPrimitives && isJsonSchemaString(resolvedSchema)) {\n return buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.String], methodChain);\n }\n return [];\n }\n case JsonSchemaAllTypes.File:\n return digPrimitives\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.File], methodChain)\n : [];\n // Integer/Number share a single /schema/number bucket — see the collapse\n // in `getPrimitiveSchemaId` and the backend `JSON_TYPE_TO_SCHEMA_ID`. The\n // default mock primitives don't ship utilities for these, so the lookup\n // returns CCFs only (the only properties merged in by `useChain`).\n case JsonSchemaAllTypes.Integer:\n case JsonSchemaAllTypes.Number:\n return digPrimitives && primitiveUtilities[PrimitiveSchemaId.Number]\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.Number], methodChain)\n : [];\n case JsonSchemaAllTypes.Boolean:\n return digPrimitives && primitiveUtilities[PrimitiveSchemaId.Boolean]\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.Boolean], methodChain)\n : [];\n // Date and Datetime are distinct buckets, mirroring the backend\n // `PlatformPrimitive::Date` / `PlatformPrimitive::Datetime` split. A\n // calendar-only Date receiver shouldn't surface CCFs authored against\n // timezone-bearing Datetimes (or vice versa).\n case JsonSchemaAllTypes.Date:\n return digPrimitives && primitiveUtilities[PrimitiveSchemaId.Date]\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.Date], methodChain)\n : [];\n case JsonSchemaAllTypes.Datetime:\n return digPrimitives && primitiveUtilities[PrimitiveSchemaId.Datetime]\n ? buildSchemaOptionsFor(primitiveUtilities[PrimitiveSchemaId.Datetime], methodChain)\n : [];\n case JsonSchemaAllTypes.GroupedEnum:\n case JsonSchemaAllTypes.Null:\n case JsonSchemaAllTypes.Relation:\n case JsonSchemaAllTypes.MaskedString:\n case JsonSchemaAllTypes.Unknown:\n return [];\n default:\n assertNever(schemaType);\n }\n })();\n\n // After a possibly-null value, offer a CCF only when its receiver schema\n // accepts null. Non-CCF members stay for nullable `type` arrays but not\n // for a nullable `$ref | null` union, whose member paths `nextLinkSchema`\n // cannot resolve.\n const possiblyNull = nullableRefSchema != null || nonNullable != null;\n const nullSafeOptions = possiblyNull\n ? schemaOptions.filter((opt) => {\n if (isFunctionSchema(opt.schema) && opt.schema.codeChainFunctionToken != null) {\n return opt.schema.acceptsNullReceiver === true;\n }\n return nullableRefSchema == null;\n })\n : schemaOptions;\n\n const containsFilters = optionFilters && !!flatten(compact(Object.values(optionFilters))).length;\n const finalOptions = containsFilters\n ? filterForAllowedSchemaOptions(nullSafeOptions, optionFilters, platformObjectJsonSchema)\n : nullSafeOptions;\n return sortBy(finalOptions, (opt: Option) => opt.property.replace(/^@/, '')) as Option[];\n};\n\nexport const formatDisplayValue = (value: any) => {\n return typeof value === 'string' ? value : trim(JSON.stringify(value, null, 1), '\"');\n};\n\n/**\n * Resolves the schema at a dotted path (e.g. \"account.birthDate\").\n * Tries direct key lookup first, then traverses into nested object .properties by path part.\n * Normalizes kebab/snake at each level for key lookup.\n */\nexport function getSchemaByPath(\n properties: Record<string, JsonSchema> | null | undefined,\n path: string,\n): JsonSchema | undefined {\n if (!properties || !path) {\n return undefined;\n }\n\n const lookup = (props: Record<string, JsonSchema>, key: string): JsonSchema | undefined =>\n props[key] ?? props[key.replace(/_/g, '-')] ?? props[key.replace(/-/g, '_')];\n\n const byFullPath = lookup(properties, path);\n if (byFullPath != null) {\n return byFullPath;\n }\n\n const i = path.indexOf('.');\n if (i === -1) {\n return undefined;\n }\n const nestedKey = path.slice(0, i);\n const rest = path.slice(i + 1);\n const next = lookup(properties, nestedKey);\n if (next == null || !isJsonSchemaObject(next) || !next.properties) {\n return undefined;\n }\n return getSchemaByPath(next.properties, rest);\n}\n\nconst parseMethodChainForJSS = (path: string): Chain | null => {\n const { methodChain, partial, valid } = parseWithPartialOption(path);\n if (!valid) {\n return null;\n }\n\n if (partial.length > 0) {\n return appendedMethodChain(methodChain, partial);\n }\n\n return methodChain;\n};\n\n/**\n * The schema resolved for a key admitted by `additionalProperties: true`: valid, with an unknown\n * type. Compared by identity (e.g. by the SmartTextInput validator), so do not copy it.\n */\nexport const UNTYPED_ADDITIONAL_PROPERTY_SCHEMA: JsonSchema = Object.freeze({});\n\n/**\n * Resolves an identifier that is not a declared property of `currentSchema` through the object's\n * `additionalProperties`: its schema when one is given, `UNTYPED_ADDITIONAL_PROPERTY_SCHEMA` when\n * it is `true`, and null when extra keys are not allowed.\n */\nconst additionalPropertySchema = (\n currentSchema: JsonSchema | null,\n link: MethodChainNode,\n platformObjectJsonSchema: ObjectSchemaMap,\n): JsonSchema | null => {\n if (currentSchema == null || !isIdentifierNode(link)) {\n return null;\n }\n const resolved = isJsonSchemaRef(currentSchema)\n ? resolveJssRef(currentSchema, platformObjectJsonSchema)\n : currentSchema;\n if (!isJsonSchemaObject(resolved) || resolved.properties?.[link.name] != null) {\n return null;\n }\n const { additionalProperties } = resolved;\n if (additionalProperties === true) {\n return UNTYPED_ADDITIONAL_PROPERTY_SCHEMA;\n }\n return typeof additionalProperties === 'object' && additionalProperties != null\n ? additionalProperties\n : null;\n};\n\nexport const getSchemaForFieldPath = ({\n path,\n initialSchema,\n platformObjectJsonSchema = {},\n primitiveUtilities = {},\n}: {\n path: string;\n initialSchema: JsonSchema;\n platformObjectJsonSchema?: ObjectSchemaMap;\n primitiveUtilities?: ObjectSchemaMap;\n}): {\n schema: JsonSchema | null;\n propertyName: string | null;\n} => {\n if (!initialSchema || (!('type' in initialSchema) && !('$ref' in initialSchema))) {\n return { schema: null, propertyName: null };\n }\n\n const schema: JsonSchema = isJsonSchemaRef(initialSchema)\n ? resolveJssRef(initialSchema, platformObjectJsonSchema)\n : initialSchema;\n\n if (path === '' || !isValid(path)) {\n return { schema: null, propertyName: null };\n }\n const methodChain = parseMethodChain(path);\n if (!methodChain) {\n return { schema: null, propertyName: null };\n }\n const result = methodChain.links.reduce<JsonSchema | null>((currentSchema, link) => {\n return (\n nextLinkSchema({\n currentSchema,\n nextLink: link,\n platformObjectJsonSchema,\n primitiveUtilities,\n }) ?? additionalPropertySchema(currentSchema, link, platformObjectJsonSchema)\n );\n }, schema);\n\n const propertyName = result ? last(methodChain.links)?.name || null : null;\n return { schema: result, propertyName };\n};\n\n/**\n * Get the schema for a variable path from usableObjects.\n */\nexport const getSchemaForVariablePath = ({\n path,\n usableObjects,\n}: {\n path: string;\n usableObjects: VariableSchemaObject[];\n}): {\n schema: JsonSchema | null;\n propertyName: string | null;\n} => {\n // just variables\n const syntheticSchema: JsonSchemaObject = {\n type: JsonSchemaTypes.Object,\n properties: Object.fromEntries(\n usableObjects\n .filter((obj) => obj.schema != null && obj.isVariable === true)\n .map((obj) => [obj.value, obj.schema!]),\n ),\n };\n\n return getSchemaForFieldPath({\n path,\n initialSchema: syntheticSchema,\n });\n};\n\nconst getPrimitiveSchemaId = (schema: JsonSchema): string | null => {\n if (!('type' in schema)) {\n return null;\n }\n // File type has special naming: 'file' -> '/schema/field/file'\n // because the backend uses Field::File.name.underscore = 'field/file'\n // File fields have type: 'object' with fieldType: 'file'\n if (isJsonSchemaObject(schema) && isFileType(schema.fieldType)) {\n return PrimitiveSchemaId.File;\n }\n // Date and Datetime are encoded as `{type: 'string', format: 'date'|'date-time'}`.\n // Check before the generic string branch so date receivers don't bucket as String.\n if (isJsonSchemaDate(schema)) {\n return PrimitiveSchemaId.Date;\n }\n if (isJsonSchemaDateTime(schema)) {\n return PrimitiveSchemaId.Datetime;\n }\n const type = Array.isArray(schema.type) ? getNonNullableType(schema) : schema.type;\n if (!type) {\n return null;\n }\n // Integer and Number share one CCF bucket — mirrors the backend collapse\n // in JSON_TYPE_TO_SCHEMA_ID. A CCF authored against a Number receiver\n // fires for both .length-style integers and float-typed values.\n if (type === JsonSchemaTypes.Integer || type === JsonSchemaTypes.Number) {\n return PrimitiveSchemaId.Number;\n }\n if (type === JsonSchemaTypes.Boolean) {\n return PrimitiveSchemaId.Boolean;\n }\n return getSchemaId(type);\n};\n\nexport const nextLinkSchema = ({\n currentSchema,\n nextLink,\n platformObjectJsonSchema,\n primitiveUtilities,\n}: {\n currentSchema: JsonSchema | null;\n nextLink: MethodChainNode;\n platformObjectJsonSchema: ObjectSchemaMap;\n primitiveUtilities: ObjectSchemaMap;\n}): JsonSchema | null => {\n if (!currentSchema) {\n return null;\n }\n // Runtime dispatches a typed null only to a CCF whose receiver schema\n // accepts null, so a nullable value resolves only through such CCFs.\n if (nextLink.type === MethodChainNodeTypes.CustomFunction) {\n const unwrapped = getNonNullableRefSchema(currentSchema);\n const nonNullType = unwrapped ? null : getNonNullableType(currentSchema);\n const receiver =\n unwrapped ?? (nonNullType ? ({ ...currentSchema, type: nonNullType } as JsonSchema) : null);\n if (receiver) {\n const fn = getFunctionSchemaForNode({\n parentSchema: currentSchema,\n functionName: fullNodeName(nextLink),\n isCustomFunction: true,\n platformObjectJsonSchema,\n primitiveUtilities,\n });\n if (fn?.acceptsNullReceiver !== true) {\n return null;\n }\n currentSchema = receiver;\n }\n }\n if (isJsonSchemaRef(currentSchema)) {\n currentSchema = resolveJssRef(currentSchema, platformObjectJsonSchema);\n } else if (isJsonSchemaArray(currentSchema) && isJsonSchemaRef(currentSchema.items)) {\n currentSchema = {\n ...currentSchema,\n items: {\n ...resolveJssRef(currentSchema.items, platformObjectJsonSchema),\n },\n };\n }\n if (!('type' in currentSchema)) {\n return null;\n }\n\n const schemaId = getPrimitiveSchemaId(currentSchema);\n if (schemaId && schemaId in primitiveUtilities) {\n const utilityReturnType = getPrimitiveUtilitiesReturnSchema(\n currentSchema,\n nextLink,\n primitiveUtilities[schemaId],\n );\n if (utilityReturnType) {\n return utilityReturnType;\n }\n }\n if ('properties' in currentSchema) {\n const propertySchema = currentSchema.properties[fullNodeName(nextLink)];\n if (propertySchema && isFunctionSchema(propertySchema)) {\n return propertySchema.properties.returnType;\n }\n return propertySchema ?? null;\n }\n return null;\n};\n\n/**\n * Returns the FunctionJsonSchema for `functionName` within `parentSchema`, checking both\n * primitive utilities (e.g. array/string methods) and direct object properties.\n * Returns null if not found or not a function schema.\n */\nexport const getFunctionSchemaForNode = ({\n parentSchema,\n functionName,\n isCustomFunction,\n platformObjectJsonSchema,\n primitiveUtilities,\n}: {\n parentSchema: JsonSchema;\n functionName: string;\n isCustomFunction: boolean;\n platformObjectJsonSchema: ObjectSchemaMap;\n primitiveUtilities: ObjectSchemaMap;\n}): FunctionJsonSchema | null => {\n if (isCustomFunction) {\n parentSchema = getNonNullableRefSchema(parentSchema) ?? parentSchema;\n }\n if (isJsonSchemaRef(parentSchema)) {\n parentSchema = resolveJssRef(parentSchema, platformObjectJsonSchema);\n }\n\n const schemaId = getPrimitiveSchemaId(parentSchema);\n if (schemaId && schemaId in primitiveUtilities) {\n const utilitySchema = primitiveUtilities[schemaId].properties[functionName];\n if (utilitySchema && isFunctionSchema(utilitySchema)) {\n return utilitySchema;\n }\n }\n\n if (isJsonSchemaObject(parentSchema) && functionName in parentSchema.properties) {\n const propSchema = parentSchema.properties[functionName];\n if (isFunctionSchema(propSchema)) {\n return propSchema;\n }\n }\n\n return null;\n};\n\n// When the result is an array of platform objects (identified by objectKey on items),\n// inject a $ref so the schema structure matches has_many associations.\n// This ensures consistent operator options in conditionals.\nconst injectRefForPlatformObjectArray = (schema: JsonSchema | null): JsonSchema | null => {\n if (\n schema &&\n isJsonSchemaArray(schema) &&\n isJsonSchemaObject(schema.items) &&\n 'objectKey' in schema.items &&\n schema.items.objectKey\n ) {\n const schemaId = getSchemaId(schema.items.objectKey, MERGED_SCHEMA_ID);\n return {\n ...schema,\n items: {\n ...schema.items,\n $ref: schemaId,\n },\n };\n }\n return schema;\n};\n\nconst getPrimitiveUtilitiesReturnSchema = (\n object: JsonSchema,\n node: MethodChainNode,\n schema: JsonSchemaObject<JsonSchema | FunctionJsonSchema>,\n): JsonSchema | null => {\n const name = fullNodeName(node);\n if (!(name in schema.properties)) {\n return null;\n }\n\n const utilitySchema = schema.properties[name];\n\n const returnSchema = isFunctionSchema(utilitySchema)\n ? utilitySchema.properties.returnType\n : utilitySchema;\n\n const itemSchema = genericArrayItemSchema(object, returnSchema);\n if (itemSchema) {\n return itemSchema;\n }\n\n if (isPrecedingSchema(returnSchema)) {\n return object;\n }\n\n if (\n isConvertedTypeSchema(returnSchema) &&\n isFunctionNode(node) &&\n node.params[returnSchema.position] &&\n isStringNode(node.params[returnSchema.position])\n ) {\n const stringNode = node.params[returnSchema.position] as StringNode;\n return returnSchema.schemaByValue[stringNode.value] ?? EMPTY_JSON_SCHEMA_OBJECT;\n }\n\n if (\n isGenericParameterSchema(returnSchema) &&\n isFunctionNode(node) &&\n node.params[returnSchema.position] &&\n isStringNode(node.params[returnSchema.position])\n ) {\n const stringNode = node.params[returnSchema.position] as StringNode;\n const objectSchema = isJsonSchemaArray(object) ? object.items : object;\n if (isJsonSchemaObject(objectSchema)) {\n const path = stringNode.value.split('.');\n const resultSchema = path.reduce<JsonSchema | null>((schema, key) => {\n if (schema == null || !isJsonSchemaObject(schema) || !schema.properties[key]) {\n return null;\n }\n return schema.properties[key];\n }, objectSchema);\n\n return injectRefForPlatformObjectArray(resultSchema);\n }\n }\n\n return 'genericType' in returnSchema ? EMPTY_JSON_SCHEMA_OBJECT : returnSchema;\n};\n\n/**\n * @param path\n * @param allowedFieldPaths - can be a complete path to a base type field\n * (e.g. 'data.some.string_field'), or a partial path to an object ('data')\n * @param fieldPathsAreStrictMatch - true if we only want to match exact paths in allowedFieldPaths and disallowedFieldPaths\n */\nconst isAllowedPath = (path: string, allowedFieldPaths: string[]) => {\n return allowedFieldPaths.some((fieldPath) => {\n const valueIsPartialMatch = fieldPath.startsWith(path);\n const valueIsNestedProp = path.startsWith(`${fieldPath}.`);\n return valueIsPartialMatch || valueIsNestedProp;\n });\n};\n\n/**\n * @param path\n * @param disallowedFieldPaths - can be a complete path to a base type field\n * (e.g. 'data.some.string_field'), or a partial path to an object ('data')\n */\nconst isDisallowedPath = (path: string, disallowedFieldPaths: string[]) => {\n return disallowedFieldPaths.some((fieldPath) => {\n const valueIsMatch = fieldPath === path;\n const valueIsNestedProp = path.startsWith(`${fieldPath}.`);\n return valueIsMatch || valueIsNestedProp;\n });\n};\n\nexport const isTypeMatch = ({\n fieldJsonSchema,\n types,\n platformObjectJsonSchema = {},\n arrayTypes,\n traversedSchemaIds = new Set(),\n}: {\n fieldJsonSchema: JsonSchema;\n types: PossibleType[];\n platformObjectJsonSchema: ObjectSchemaMap;\n arrayTypes?: PossibleArrayType[];\n traversedSchemaIds?: Set<string>;\n}): boolean => {\n const resolvedSchema = isJsonSchemaRef(fieldJsonSchema)\n ? resolveJssRef(fieldJsonSchema, platformObjectJsonSchema)\n : fieldJsonSchema;\n\n if (resolvedSchema.$id) {\n if (traversedSchemaIds.has(resolvedSchema.$id)) {\n // We've already traversed this schema ID, which there were no\n // valid types found for it, so return false to avoid infinite loops\n return false;\n } else {\n // If we haven't traversed this schema ID yet, add it to the set\n // This allows us to avoid infinite loops when resolving references\n // in recursive schemas\n traversedSchemaIds.add(resolvedSchema.$id);\n }\n }\n\n const fieldJsonSchemaType = getJsonSchemaType(resolvedSchema);\n switch (fieldJsonSchemaType) {\n case JsonSchemaAllTypes.Object: {\n const objectSchema = resolvedSchema as JsonSchemaObject;\n // For generic JsonSchemaObjectKey such as 'report' or 'verification', we match on subtypes\n // like 'business-watchlist' as well; otherwise, generics don't show anything\n const isObjectKeyOfType = (type: JsonSchemaObjectKey) =>\n objectSchema.objectKey &&\n types.includes(type) &&\n objectSchema.objectKey.split('/')[0] === type;\n\n if (\n types.includes(JsonSchemaTypes.Object) ||\n (objectSchema.objectKey && types.includes(objectSchema.objectKey)) ||\n isObjectKeyOfType('report') ||\n isObjectKeyOfType('verification')\n ) {\n return true;\n }\n\n return Object.values(objectSchema.properties || {}).some((propJsonSchema) =>\n isTypeMatch({\n fieldJsonSchema: propJsonSchema,\n types,\n platformObjectJsonSchema,\n arrayTypes,\n traversedSchemaIds: traversedSchemaIds,\n }),\n );\n }\n case JsonSchemaAllTypes.Array: {\n const arraySchema = resolvedSchema as JsonSchemaArray;\n const itemSchema = isJsonSchemaRef(arraySchema.items)\n ? resolveJssRef(arraySchema.items, platformObjectJsonSchema)\n : arraySchema.items;\n return (\n types.includes(JsonSchemaAllTypes.Array) &&\n // Don't recurse on array, otherwise we risk matching on objects within the array\n !!arrayTypes &&\n arrayTypes.some(\n (schemaType) =>\n schemaType === getJsonSchemaType(itemSchema) ||\n (isJsonSchemaObject(itemSchema) && schemaType === itemSchema.objectKey),\n )\n );\n }\n case JsonSchemaAllTypes.String:\n case JsonSchemaAllTypes.Number:\n case JsonSchemaAllTypes.Boolean:\n case JsonSchemaAllTypes.Integer:\n case JsonSchemaAllTypes.Date:\n case JsonSchemaAllTypes.Datetime:\n case JsonSchemaAllTypes.Enum:\n case JsonSchemaAllTypes.MultiEnum:\n case JsonSchemaAllTypes.GroupedEnum:\n case JsonSchemaAllTypes.Unknown: {\n return types.some((schemaType) => schemaType === fieldJsonSchemaType);\n }\n default:\n return false;\n }\n};\n\nexport interface OptionFilters {\n allowedArrayTypes?: PossibleArrayType[];\n allowedFieldPaths?: string[];\n allowedTypes?: PossibleType[];\n disallowedFieldPaths?: string[];\n fieldPathsAreStrictMatch?: boolean;\n requiredPropertyShape?: string[]; // Array of property names that must exist in the schema\n}\n\nexport const hasRequiredPropertyShape = (\n schema: JsonSchema,\n requiredPropertyShape: string[],\n platformObjectJsonSchema: ObjectSchemaMap = {},\n checkRecursively: boolean = true,\n): boolean => {\n if (!requiredPropertyShape?.length) {\n return true;\n }\n\n const resolvedSchema = isJsonSchemaRef(schema)\n ? resolveJssRef(schema, platformObjectJsonSchema)\n : schema;\n\n if (\n resolvedSchema &&\n 'type' in resolvedSchema &&\n resolvedSchema.type === JsonSchemaTypes.Object &&\n 'properties' in resolvedSchema &&\n resolvedSchema.properties\n ) {\n const schemaProperties = resolvedSchema.properties as Record<string, JsonSchema>;\n const hasAllProperties = requiredPropertyShape.every(\n (propName) => propName in schemaProperties,\n );\n\n if (hasAllProperties) {\n return true;\n }\n\n if (checkRecursively) {\n return Object.values(schemaProperties).some((propSchema) =>\n hasRequiredPropertyShape(\n propSchema,\n requiredPropertyShape,\n platformObjectJsonSchema,\n checkRecursively,\n ),\n );\n }\n }\n return false;\n};\n\nconst filterForAllowedSchemaOptions = (\n options: Option[] = [],\n {\n allowedArrayTypes,\n allowedFieldPaths,\n allowedTypes,\n disallowedFieldPaths,\n fieldPathsAreStrictMatch,\n requiredPropertyShape,\n }: OptionFilters,\n platformObjectJsonSchema: ObjectSchemaMap = {},\n) => {\n let filteredOptions = options;\n\n if (fieldPathsAreStrictMatch) {\n if (allowedFieldPaths?.length || disallowedFieldPaths?.length || allowedTypes?.length) {\n filteredOptions = filteredOptions.filter((option) =>\n isValidOption(\n option.schema,\n allowedFieldPaths ?? [],\n disallowedFieldPaths ?? [],\n allowedTypes ?? [],\n allowedArrayTypes ?? [],\n option.value.split('.'),\n platformObjectJsonSchema,\n ),\n );\n }\n } else {\n if (allowedFieldPaths?.length) {\n filteredOptions = filteredOptions.filter((option) =>\n isAllowedPath(option.value, allowedFieldPaths),\n );\n }\n if (disallowedFieldPaths?.length) {\n filteredOptions = filteredOptions.filter(\n (option) => !isDisallowedPath(option.value, disallowedFieldPaths),\n );\n }\n if (allowedTypes?.length) {\n filteredOptions = filteredOptions.filter((option) =>\n isTypeMatch({\n fieldJsonSchema: option.schema,\n types: allowedTypes,\n platformObjectJsonSchema,\n arrayTypes: allowedArrayTypes,\n }),\n );\n }\n }\n\n // Add a recursive function to check if schema or any nested schema has the required properties\n if (requiredPropertyShape?.length) {\n filteredOptions = filteredOptions.filter((option) =>\n hasRequiredPropertyShape(option.schema, requiredPropertyShape, platformObjectJsonSchema),\n );\n }\n\n return filteredOptions;\n};\n\nexport const getOptionForValue = ({\n value,\n jsonSchema,\n schemaForFieldPath,\n}: {\n value: string;\n jsonSchema: JsonSchema;\n schemaForFieldPath: (\n path: string,\n initialSchema: JsonSchema,\n ) => { schema: JsonSchema | null; propertyName: string | null };\n}): Option | null => {\n const { schema, propertyName } = schemaForFieldPath(value, jsonSchema);\n if (!schema || !propertyName) {\n return null;\n }\n\n const methodChain = parseMethodChainForJSS(value);\n return {\n label: methodChain ? methodChainToString(methodChain) : value,\n value: methodChain ? methodChainToString(methodChain) : value,\n property: propertyName,\n schema,\n methodChain,\n };\n};\n\nexport const validatePath = ({\n path,\n jsonSchema,\n platformObjectJsonSchema = {},\n primitiveUtilities = {},\n optionFilters,\n}: {\n path: string;\n jsonSchema: JsonSchema;\n platformObjectJsonSchema: ObjectSchemaMap;\n primitiveUtilities: ObjectSchemaMap;\n optionFilters?: OptionFilters;\n}) => {\n const schemaOptions = getSchemaOptions({\n option: { schema: jsonSchema, methodChain: parseMethodChainForJSS('') },\n optionFilters,\n platformObjectJsonSchema,\n primitiveUtilities,\n });\n const { methodChain, partial } = parseWithPartialOption(path);\n\n const matchedSchemaOptions = methodChain.links.reduce<Option[]>((currentSchema, link) => {\n if (currentSchema.length === 0) {\n return [];\n }\n const optionMatch = currentSchema.find((option) => option.property === link.name);\n if (optionMatch) {\n return getSchemaOptions({\n option: optionMatch,\n optionFilters,\n platformObjectJsonSchema,\n primitiveUtilities,\n });\n }\n return [];\n }, schemaOptions);\n\n const optionsWithPartiallyMatchedFinalLink = matchedSchemaOptions.filter((option) =>\n option.property.includes(partial),\n );\n return {\n valid: optionsWithPartiallyMatchedFinalLink.length > 0,\n schemaOptions: optionsWithPartiallyMatchedFinalLink,\n partial,\n };\n};\n\n/**\n * Given a method chain that corresponds to the passed schema, find the right-most indentifier that\n * is a platform object and split the method chain on that identifier, with the platform object on\n * the left side.\n *\n * This function is used to optimize a method chain into two parts, left side for server resolution\n * and right side for client resolution.\n *\n * For example:\n * current_case.fields.field_a -> ['current_case', 'fields.field_a']\n * current_case.inquiries.first.id -> ['current_case.inquiries.first', 'id']\n * current_case.account.fields.field_b -> ['current_case.account', 'fields.field_b']\n */\nexport const splitAtNearestParentObject = (\n chain: Chain,\n currentSchema: JsonSchemaObject,\n platformSchemaMap: ObjectSchemaMap,\n primitiveUtilities: ObjectSchemaMap,\n): [leftChain: Chain, rightChain: Chain] => {\n // Create a list of schemas that match each link in the method chain.\n // The list is reversed such that the first schema matches the last link of the method chain\n // for the next step.\n const leafUpLinkSchemas: (JsonSchema | null)[] = [currentSchema];\n for (const link of chain.links) {\n const nextSchema = nextLinkSchema({\n currentSchema: leafUpLinkSchemas[0],\n nextLink: link,\n platformObjectJsonSchema: platformSchemaMap,\n primitiveUtilities,\n });\n leafUpLinkSchemas.unshift(nextSchema);\n }\n\n // List of links that correspond to the left and right sides of the split.\n // As we walk the schema from leaf to root, we move links to the right side.\n const leafUpLeftLinks = [...chain.links].reverse();\n const leafUpRightLinks: typeof leafUpLeftLinks = [];\n\n for (const [i, linkSchema] of leafUpLinkSchemas.entries()) {\n if (!linkSchema) {\n // When the schema is unknown, check if the current link is an identifier accessing a\n // property on an unresolvable platform object ref. If any remaining schema in the\n // ancestor chain is a $ref (or array of $refs), we're within a platform object whose\n // schema couldn't be resolved — push the identifier to the client (right) side.\n if (isIdentifierNode(leafUpLeftLinks[0])) {\n const nearestPlatformAncestor = leafUpLinkSchemas\n .slice(i + 1)\n .find(\n (s) => s && (isJsonSchemaRef(s) || (isJsonSchemaArray(s) && isJsonSchemaRef(s.items))),\n );\n if (nearestPlatformAncestor) {\n leafUpRightLinks.push(leafUpLeftLinks.shift()!);\n continue;\n }\n }\n // If we are missing schema, break out asap to keep links on the left.\n break;\n } else if ('$id' in linkSchema || isJsonSchemaRef(linkSchema)) {\n break;\n } else if (isJsonSchemaArray(linkSchema)) {\n if ('$id' in linkSchema.items || isJsonSchemaRef(linkSchema.items)) {\n break;\n }\n // Array-returning functions (filter, sort, etc.) on platform object arrays\n // must be resolved server-side even when the items ref cannot be resolved.\n if (isFunctionNode(leafUpLeftLinks[0])) {\n break;\n }\n } else if (isFunctionNode(leafUpLeftLinks[0])) {\n break;\n } else if (isIdentifierNode(leafUpLeftLinks[0])) {\n const nextSchema = leafUpLinkSchemas[i + 1];\n // If the preceding schema has a primitive schema ID in the utilities, the identifier\n // was resolved via primitive utilities (e.g. 'trim' on a string, 'count' on an array).\n // The server handles these inline, so keep the whole chain server-side.\n if (nextSchema) {\n const primitiveId = getPrimitiveSchemaId(nextSchema);\n if (primitiveId && primitiveId in primitiveUtilities) {\n break;\n }\n }\n // Real special case here. If:\n // - The current link is an identifier\n // - The next schema is an array\n // = break out, because we don't want to load the whole array into the client\n if (nextSchema && isJsonSchemaArray(nextSchema)) {\n break;\n }\n }\n\n leafUpRightLinks.push(leafUpLeftLinks.shift()!);\n }\n\n const leftChain: Chain = {\n type: MethodChainNodeTypes.Chain,\n links: leafUpLeftLinks.reverse(),\n };\n const rightChain: Chain = {\n type: MethodChainNodeTypes.Chain,\n links: leafUpRightLinks.reverse(),\n };\n return [leftChain, rightChain];\n};\n"],"mappings":";;;;;;AA6DA,MAAM,gBAAgB,SACpB,GAAG,KAAK,SAAS,qBAAqB,iBAAiB,MAAM,KAAK,KAAK;AAazE,MAAM,sBAAsB;;;;;;;AAQ5B,MAAa,4BACX,QACA,2BAA4C,EAAE,KAC5B;AAClB,KAAI,CAAC,OACH,QAAO;AAET,KAAI,gBAAgB,OAAO,EAAE;EAC3B,MAAM,WAAW,OAAO,MAAM,MAAM,oBAAoB;AACxD,MAAI,SACF,QAAO,SAAS;AAElB,SAAO,yBACL,cAAc,QAAQ,yBAAyB,EAC/C,yBACD;;AAEH,KAAI,SAAS,UAAU,OAAO,OAAO,QAAQ,UAAU;EACrD,MAAM,UAAU,OAAO,IAAI,MAAM,oBAAoB;AACrD,MAAI,QACF,QAAO,QAAQ;;AAKnB,KAAI,eAAe,UAAU,OAAO,OAAO,cAAc,SACvD,QAAO,OAAO,UAAU,MAAM,IAAI,CAAC;AAErC,QAAO,oCAAoC,OAAO;;AAMpD,MAAM,kBACJ,QACA,cACA,sBACG;AACH,KAAI,aAAa,WAAW,EAC1B,QAAO;CAET,MAAM,iBAAiB,kBAAkB,OAAO;AAEhD,KACE,aAAa,MAAM,eAAe,eAAA,SAAsC,IACxE,6BAA6B,MAAM,eAAe,eAAe,eAAe,CAEhF,QAAO;UACE,mBAAmB,mBAAmB,OAAO;EACtD,MAAM,cAAc,WAAW,SAAS,OAAO,QAAQ;AACvD,MACE,CAAC,aAAa,SAAS,mBAAmB,MAAM,IAE/C,mBAAmB,UAClB,CAAC,kBAAkB,MAAM,eAAe,eAAe,kBAAkB,YAAY,CAAC,CAExF,QAAO;YAGT,mBAAmB,mBAAmB,UACtC,CAAC,aAAa,MAAM,eAAe,eAAe,eAAe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c,qBAAqB,WAAW;AACpD,QAAI,eAAe,eAAe,mBAChC;;AAOJ,OAAI,cAAc,kBAAkB,WAAW,CAC7C;;AAIJ,mBAAiB,KAAK,gBAAgB,OAAO,CAAE;;AAWjD,QAAO,CAAC;EAPN,MAAM,qBAAqB;EAC3B,OAAO,gBAAgB,SAAS;EAMjB,EAAE;EAHjB,MAAM,qBAAqB;EAC3B,OAAO,iBAAiB,SAAS;EAEN,CAAC"}
@@ -1,2 +1,2 @@
1
- import { n as useChain, r as useChainSchema, t as chainRootsFromSchemaProperties } from "../useChain-D5LvupTW.mjs";
1
+ import { n as useChain, r as useChainSchema, t as chainRootsFromSchemaProperties } from "../useChain-DXkKKe-J.mjs";
2
2
  export { chainRootsFromSchemaProperties, useChain as default, useChainSchema };
@@ -1,5 +1,5 @@
1
- import { n as PossibleChainSchema } from "./chainTypes-BbFZn8a9.mjs";
2
- import { a as Mode, u as ValueType } from "./types-DFU6M0OL.mjs";
1
+ import { n as PossibleChainSchema } from "./chainTypes-Cjp0zZ4E.mjs";
2
+ import { a as Mode, u as ValueType } from "./types-DWU0Dmy9.mjs";
3
3
 
4
4
  //#region components/SmartTextInput/listbox-options.d.ts
5
5
  type MethodChainOption = {
@@ -35,4 +35,4 @@ declare const getContextMenuOptions: (valueIsEmpty: boolean, allowedValueType: V
35
35
  declare const getMethodChainOptions: (options: PossibleChainSchema[]) => MethodChainOption[];
36
36
  //#endregion
37
37
  export { SmartTextInputOption as a, isContextMenuOption as c, MethodChainOption as i, isMethodChainOption as l, ContextMenuOption as n, getContextMenuOptions as o, EXIT_METHOD_CHAIN_VALUE_TYPE_OPTION as r, getMethodChainOptions as s, ContextMenuExamples as t };
38
- //# sourceMappingURL=listbox-options-D-DyLUdi.d.mts.map
38
+ //# sourceMappingURL=listbox-options-DCmqWWgy.d.mts.map
@@ -1,2 +1,2 @@
1
- import { a as SmartTextInputOption, c as isContextMenuOption, i as MethodChainOption, l as isMethodChainOption, n as ContextMenuOption, o as getContextMenuOptions, r as EXIT_METHOD_CHAIN_VALUE_TYPE_OPTION, s as getMethodChainOptions, t as ContextMenuExamples } from "./listbox-options-D-DyLUdi.mjs";
1
+ import { a as SmartTextInputOption, c as isContextMenuOption, i as MethodChainOption, l as isMethodChainOption, n as ContextMenuOption, o as getContextMenuOptions, r as EXIT_METHOD_CHAIN_VALUE_TYPE_OPTION, s as getMethodChainOptions, t as ContextMenuExamples } from "./listbox-options-DCmqWWgy.mjs";
2
2
  export { ContextMenuExamples, ContextMenuOption, EXIT_METHOD_CHAIN_VALUE_TYPE_OPTION, MethodChainOption, SmartTextInputOption, getContextMenuOptions, getMethodChainOptions, isContextMenuOption, isMethodChainOption };
@@ -1,5 +1,5 @@
1
1
  import { u as ASTNodeType } from "./types-Kmnood9Y.mjs";
2
- import { n as JsonSchema } from "./jsonSchema-COo0XQLA.mjs";
2
+ import { n as JsonSchema } from "./jsonSchema-DmOA0Lnu.mjs";
3
3
  import { a as FunctionParamType, c as NumberNode, i as FunctionNode, l as StringNode, n as Chain, o as IdentifierNode, r as CustomFunctionNode, s as MethodChainNode, t as ArrayNode } from "./methodChainTypes-a7kHYhs7.mjs";
4
4
 
5
5
  //#region components/SmartTextInput/parser/method-chain/parser.d.ts
@@ -63,4 +63,4 @@ declare const getSyntaxError: () => typeof SyntaxError;
63
63
  declare const methodChainNodeToJsonSchema: (node: StringNode | NumberNode | ArrayNode) => JsonSchema | null;
64
64
  //#endregion
65
65
  export { tryParseMethodChain as C, removeFunctionNode as S, methodChainToString as _, getFunctionParams as a, pathContainsFunctionNode as b, isCustomFunctionNode as c, isIdentifierNode as d, isStringNode as f, methodChainRootName as g, methodChainNodeToJsonSchema as h, containsFunctionNode as i, isEmpty as l, methodChainCache as m, MethodChainNodeTypes as n, getSyntaxError as o, isValid as p, appendedMethodChain as r, isArrayNode as s, EMPTY_METHOD_CHAIN as t, isFunctionNode as u, parseMethodChain as v, pathIsNormative as x, parseWithPartialOption as y };
66
- //# sourceMappingURL=methodChain-BAUFBbR9.d.mts.map
66
+ //# sourceMappingURL=methodChain-DaDvXsHF.d.mts.map
@@ -1,4 +1,4 @@
1
- import { a as FilterConditionOperator, c as FilterFieldType, d as FilterRuleValue, l as FilterOperator, o as FilterField, r as DateRangeFilterValue, u as FilterRule } from "./types-BMpEizJP.mjs";
1
+ import { a as FilterConditionOperator, c as FilterFieldType, d as FilterRuleValue, l as FilterOperator, o as FilterField, r as DateRangeFilterValue, u as FilterRule } from "./types-EodOhsjw.mjs";
2
2
  import { i as CommonStrings } from "./strings-FWNWdSn1.mjs";
3
3
  //#region components/DataTable/TableControls/FiltersV2/operators.d.ts
4
4
  type OperatorLabelKey = 'operatorIs' | 'operatorIsNot' | 'operatorContains' | 'operatorDoesNotContain' | 'operatorIsEmpty' | 'operatorIsNotEmpty' | 'operatorIsTrue' | 'operatorIsFalse' | 'operatorBefore' | 'operatorAfter' | 'operatorBetween' | 'operatorIsAnyOf' | 'operatorIsNoneOf' | 'operatorGreaterThan' | 'operatorGreaterThanOrEqual' | 'operatorLessThan' | 'operatorLessThanOrEqual' | 'operatorIsEqualTo' | 'operatorIsGreaterThan' | 'operatorIsLessThan';
@@ -109,4 +109,4 @@ declare function emptyValueForRule(field: Pick<FilterField, 'type' | 'condition'
109
109
  declare function reconcileValueForOperator(field: Pick<FilterField, 'type' | 'condition'>, nextOperator: FilterOperator, previousOperator: FilterOperator, value: FilterRuleValue): FilterRuleValue;
110
110
  //#endregion
111
111
  export { isNumericComparisonOperator as _, emptyValueForRule as a, reconcileValueForOperator as b, getDefaultOperatorForType as c, getOperatorsForType as d, hasCompleteConditionValue as f, isNumericComparison as g, isMinutePrecisionDate as h, emptyValueForFieldType as i, getOperatorLabel as l, isCompleteNumericComparisonValue as m, NumericComparisonOperator as n, fieldHasMultipleOperators as o, isCompleteDateRange as p, carriesDateRange as r, getConditionOperator as s, NUMERIC_COMPARISON_OPERATORS as t, getOperatorsForField as u, isRangeOperator as v, withValue as x, isValuelessOperator as y };
112
- //# sourceMappingURL=operators-DjQXVNVI.d.mts.map
112
+ //# sourceMappingURL=operators-Seez5p9U.d.mts.map
@@ -1,2 +1,2 @@
1
- import { _ as isNumericComparisonOperator, a as emptyValueForRule, b as reconcileValueForOperator, c as getDefaultOperatorForType, d as getOperatorsForType, f as hasCompleteConditionValue, g as isNumericComparison, h as isMinutePrecisionDate, i as emptyValueForFieldType, l as getOperatorLabel, m as isCompleteNumericComparisonValue, n as NumericComparisonOperator, o as fieldHasMultipleOperators, p as isCompleteDateRange, r as carriesDateRange, s as getConditionOperator, t as NUMERIC_COMPARISON_OPERATORS, u as getOperatorsForField, v as isRangeOperator, x as withValue, y as isValuelessOperator } from "./operators-DjQXVNVI.mjs";
1
+ import { _ as isNumericComparisonOperator, a as emptyValueForRule, b as reconcileValueForOperator, c as getDefaultOperatorForType, d as getOperatorsForType, f as hasCompleteConditionValue, g as isNumericComparison, h as isMinutePrecisionDate, i as emptyValueForFieldType, l as getOperatorLabel, m as isCompleteNumericComparisonValue, n as NumericComparisonOperator, o as fieldHasMultipleOperators, p as isCompleteDateRange, r as carriesDateRange, s as getConditionOperator, t as NUMERIC_COMPARISON_OPERATORS, u as getOperatorsForField, v as isRangeOperator, x as withValue, y as isValuelessOperator } from "./operators-Seez5p9U.mjs";
2
2
  export { NUMERIC_COMPARISON_OPERATORS, NumericComparisonOperator, carriesDateRange, emptyValueForFieldType, emptyValueForRule, fieldHasMultipleOperators, getConditionOperator, getDefaultOperatorForType, getOperatorLabel, getOperatorsForField, getOperatorsForType, hasCompleteConditionValue, isCompleteDateRange, isCompleteNumericComparisonValue, isMinutePrecisionDate, isNumericComparison, isNumericComparisonOperator, isRangeOperator, isValuelessOperator, reconcileValueForOperator, withValue };
@@ -1,5 +1,5 @@
1
1
  import { t as Card_default } from "../../Card-BXNxWX5C.mjs";
2
- import { t as DataTable } from "../../DataTable-95ZxiPlV.mjs";
2
+ import { t as DataTable } from "../../DataTable-F9R-aQCg.mjs";
3
3
  import { t as PageHeader } from "../../PageHeader-DJF7nxgN.mjs";
4
4
  import { a as Section, i as Container } from "../../PageLayout-fXJW7daI.mjs";
5
5
  import { useMemo } from "react";
@@ -2,7 +2,7 @@ import { a as styled } from "../../styledComponentsInterop-NxwFjeA4.mjs";
2
2
  import { n as Stack, t as HStack } from "../../Stack-BkC7FCdF.mjs";
3
3
  import { t as LoadingShimmer } from "../../LoadingShimmer-Bqjdut7i.mjs";
4
4
  import { t as Card_default } from "../../CardV2-Dp4eHSE-.mjs";
5
- import { h as Table, m as TableHeaderCell, n as TableBody, p as TableRow, r as TableHead, s as TableCell } from "../../Table--o4ZLRbb.mjs";
5
+ import { h as Table, m as TableHeaderCell, n as TableBody, p as TableRow, r as TableHead, s as TableCell } from "../../Table-CmuWqmVN.mjs";
6
6
  import { n as PageHeaderContainer } from "../../PageHeader-DJF7nxgN.mjs";
7
7
  import { Color, Spacing } from "@persona/design-tokens";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -2,7 +2,7 @@ import { a as styled } from "../../styledComponentsInterop-NxwFjeA4.mjs";
2
2
  import { semanticColor } from "../../lib/semanticColor.mjs";
3
3
  import { t as HStack } from "../../Stack-BkC7FCdF.mjs";
4
4
  import { n as Button } from "../../IconButton-HWx5Hlmi.mjs";
5
- import { i as Modal_default } from "../../Modal-kjUptzg1.mjs";
5
+ import { i as Modal_default } from "../../Modal-IJdbLORi.mjs";
6
6
  import { t as ProgressIndicator } from "../../ProgressIndicator-CM37EU1B.mjs";
7
7
  import { Color, Spacing } from "@persona/design-tokens";
8
8
  import { useState } from "react";