@flanksource/clicky-ui 0.3.19 → 0.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/dist/components/ErrorWrapper.cjs +1 -1
  2. package/dist/components/ErrorWrapper.cjs.map +1 -1
  3. package/dist/components/ErrorWrapper.js +1 -1
  4. package/dist/components/ErrorWrapper.js.map +1 -1
  5. package/dist/components/UnitStepControls.cjs +55 -0
  6. package/dist/components/UnitStepControls.cjs.map +1 -0
  7. package/dist/components/UnitStepControls.d.ts +10 -0
  8. package/dist/components/UnitStepControls.d.ts.map +1 -0
  9. package/dist/components/UnitStepControls.js +55 -0
  10. package/dist/components/UnitStepControls.js.map +1 -0
  11. package/dist/components/json-schema-form-accordion-array.cjs +5 -73
  12. package/dist/components/json-schema-form-accordion-array.cjs.map +1 -1
  13. package/dist/components/json-schema-form-accordion-array.d.ts.map +1 -1
  14. package/dist/components/json-schema-form-accordion-array.js +3 -71
  15. package/dist/components/json-schema-form-accordion-array.js.map +1 -1
  16. package/dist/components/json-schema-form-array.cjs +6 -1
  17. package/dist/components/json-schema-form-array.cjs.map +1 -1
  18. package/dist/components/json-schema-form-array.d.ts.map +1 -1
  19. package/dist/components/json-schema-form-array.js +6 -1
  20. package/dist/components/json-schema-form-array.js.map +1 -1
  21. package/dist/components/json-schema-form-cards-array.cjs +96 -0
  22. package/dist/components/json-schema-form-cards-array.cjs.map +1 -0
  23. package/dist/components/json-schema-form-cards-array.d.ts +7 -0
  24. package/dist/components/json-schema-form-cards-array.d.ts.map +1 -0
  25. package/dist/components/json-schema-form-cards-array.js +96 -0
  26. package/dist/components/json-schema-form-cards-array.js.map +1 -0
  27. package/dist/components/json-schema-form-item-row.cjs +81 -0
  28. package/dist/components/json-schema-form-item-row.cjs.map +1 -0
  29. package/dist/components/json-schema-form-item-row.d.ts +19 -0
  30. package/dist/components/json-schema-form-item-row.d.ts.map +1 -0
  31. package/dist/components/json-schema-form-item-row.js +81 -0
  32. package/dist/components/json-schema-form-item-row.js.map +1 -0
  33. package/dist/components/json-schema-form-render.cjs +2 -2
  34. package/dist/components/json-schema-form-render.cjs.map +1 -1
  35. package/dist/components/json-schema-form-render.d.ts.map +1 -1
  36. package/dist/components/json-schema-form-render.js +2 -2
  37. package/dist/components/json-schema-form-render.js.map +1 -1
  38. package/dist/components/json-schema-form-resolve.cjs +1 -1
  39. package/dist/components/json-schema-form-resolve.cjs.map +1 -1
  40. package/dist/components/json-schema-form-resolve.js +1 -1
  41. package/dist/components/json-schema-form-resolve.js.map +1 -1
  42. package/dist/components/json-schema-form-tone.cjs +12 -0
  43. package/dist/components/json-schema-form-tone.cjs.map +1 -1
  44. package/dist/components/json-schema-form-tone.js +12 -0
  45. package/dist/components/json-schema-form-tone.js.map +1 -1
  46. package/dist/components/json-schema-form-types.d.ts +1 -1
  47. package/dist/components/json-schema-form-types.d.ts.map +1 -1
  48. package/dist/components/unit-form-extension.cjs +126 -0
  49. package/dist/components/unit-form-extension.cjs.map +1 -0
  50. package/dist/components/unit-form-extension.d.ts +8 -0
  51. package/dist/components/unit-form-extension.d.ts.map +1 -0
  52. package/dist/components/unit-form-extension.js +126 -0
  53. package/dist/components/unit-form-extension.js.map +1 -0
  54. package/dist/components.cjs +4 -0
  55. package/dist/components.cjs.map +1 -1
  56. package/dist/components.d.ts +1 -0
  57. package/dist/components.d.ts.map +1 -1
  58. package/dist/components.js +4 -0
  59. package/dist/components.js.map +1 -1
  60. package/dist/data/diagnostics/ErrorDetails.cjs +61 -8
  61. package/dist/data/diagnostics/ErrorDetails.cjs.map +1 -1
  62. package/dist/data/diagnostics/ErrorDetails.d.ts.map +1 -1
  63. package/dist/data/diagnostics/ErrorDetails.js +61 -8
  64. package/dist/data/diagnostics/ErrorDetails.js.map +1 -1
  65. package/dist/data/diagnostics/error-diagnostics.cjs +10 -4
  66. package/dist/data/diagnostics/error-diagnostics.cjs.map +1 -1
  67. package/dist/data/diagnostics/error-diagnostics.d.ts.map +1 -1
  68. package/dist/data/diagnostics/error-diagnostics.js +10 -4
  69. package/dist/data/diagnostics/error-diagnostics.js.map +1 -1
  70. package/dist/data/query-browser/QueryBrowser.cjs +12 -6
  71. package/dist/data/query-browser/QueryBrowser.cjs.map +1 -1
  72. package/dist/data/query-browser/QueryBrowser.d.ts.map +1 -1
  73. package/dist/data/query-browser/QueryBrowser.js +12 -6
  74. package/dist/data/query-browser/QueryBrowser.js.map +1 -1
  75. package/dist/data/query-browser/QueryBrowser.types.cjs +2 -1
  76. package/dist/data/query-browser/QueryBrowser.types.cjs.map +1 -1
  77. package/dist/data/query-browser/QueryBrowser.types.d.ts +16 -14
  78. package/dist/data/query-browser/QueryBrowser.types.d.ts.map +1 -1
  79. package/dist/data/query-browser/QueryBrowser.types.js +2 -1
  80. package/dist/data/query-browser/QueryBrowser.types.js.map +1 -1
  81. package/dist/data/version-info.cjs +3 -3
  82. package/dist/data/version-info.js +3 -3
  83. package/dist/index.cjs +4 -0
  84. package/dist/index.cjs.map +1 -1
  85. package/dist/index.js +4 -0
  86. package/dist/index.js.map +1 -1
  87. package/dist/lib/string.cjs +8 -0
  88. package/dist/lib/string.cjs.map +1 -1
  89. package/dist/lib/string.d.ts +1 -0
  90. package/dist/lib/string.d.ts.map +1 -1
  91. package/dist/lib/string.js +8 -0
  92. package/dist/lib/string.js.map +1 -1
  93. package/dist/profiles/catalogTree.cjs +133 -0
  94. package/dist/profiles/catalogTree.cjs.map +1 -0
  95. package/dist/profiles/catalogTree.d.ts +11 -0
  96. package/dist/profiles/catalogTree.d.ts.map +1 -0
  97. package/dist/profiles/catalogTree.js +133 -0
  98. package/dist/profiles/catalogTree.js.map +1 -0
  99. package/dist/profiles/connectionBrowserModel.cjs +185 -0
  100. package/dist/profiles/connectionBrowserModel.cjs.map +1 -0
  101. package/dist/profiles/connectionBrowserModel.d.ts +169 -0
  102. package/dist/profiles/connectionBrowserModel.d.ts.map +1 -0
  103. package/dist/profiles/connectionBrowserModel.js +185 -0
  104. package/dist/profiles/connectionBrowserModel.js.map +1 -0
  105. package/dist/profiles/connectionQueryWorkspace.cjs +185 -0
  106. package/dist/profiles/connectionQueryWorkspace.cjs.map +1 -0
  107. package/dist/profiles/connectionQueryWorkspace.d.ts +63 -0
  108. package/dist/profiles/connectionQueryWorkspace.d.ts.map +1 -0
  109. package/dist/profiles/connectionQueryWorkspace.js +185 -0
  110. package/dist/profiles/connectionQueryWorkspace.js.map +1 -0
  111. package/dist/profiles/connectionQueryWorkspaceModel.cjs +28 -0
  112. package/dist/profiles/connectionQueryWorkspaceModel.cjs.map +1 -0
  113. package/dist/profiles/connectionQueryWorkspaceModel.d.ts +38 -0
  114. package/dist/profiles/connectionQueryWorkspaceModel.d.ts.map +1 -0
  115. package/dist/profiles/connectionQueryWorkspaceModel.js +28 -0
  116. package/dist/profiles/connectionQueryWorkspaceModel.js.map +1 -0
  117. package/dist/profiles/esFieldValues.cjs +64 -0
  118. package/dist/profiles/esFieldValues.cjs.map +1 -0
  119. package/dist/profiles/esFieldValues.d.ts +48 -0
  120. package/dist/profiles/esFieldValues.d.ts.map +1 -0
  121. package/dist/profiles/esFieldValues.js +64 -0
  122. package/dist/profiles/esFieldValues.js.map +1 -0
  123. package/dist/profiles/esParamMappingModel.cjs +301 -0
  124. package/dist/profiles/esParamMappingModel.cjs.map +1 -0
  125. package/dist/profiles/esParamMappingModel.d.ts +37 -0
  126. package/dist/profiles/esParamMappingModel.d.ts.map +1 -0
  127. package/dist/profiles/esParamMappingModel.js +301 -0
  128. package/dist/profiles/esParamMappingModel.js.map +1 -0
  129. package/dist/profiles/esParamMappingPill.cjs +24 -0
  130. package/dist/profiles/esParamMappingPill.cjs.map +1 -0
  131. package/dist/profiles/esParamMappingPill.d.ts +13 -0
  132. package/dist/profiles/esParamMappingPill.d.ts.map +1 -0
  133. package/dist/profiles/esParamMappingPill.js +24 -0
  134. package/dist/profiles/esParamMappingPill.js.map +1 -0
  135. package/dist/profiles/esParamOperandExtension.cjs +75 -0
  136. package/dist/profiles/esParamOperandExtension.cjs.map +1 -0
  137. package/dist/profiles/esParamOperandExtension.d.ts +11 -0
  138. package/dist/profiles/esParamOperandExtension.d.ts.map +1 -0
  139. package/dist/profiles/esParamOperandExtension.js +75 -0
  140. package/dist/profiles/esParamOperandExtension.js.map +1 -0
  141. package/dist/profiles/esQueryBuilder.cjs +205 -0
  142. package/dist/profiles/esQueryBuilder.cjs.map +1 -0
  143. package/dist/profiles/esQueryBuilder.d.ts +35 -0
  144. package/dist/profiles/esQueryBuilder.d.ts.map +1 -0
  145. package/dist/profiles/esQueryBuilder.js +205 -0
  146. package/dist/profiles/esQueryBuilder.js.map +1 -0
  147. package/dist/profiles/esQueryBuilderExtension.cjs +23 -0
  148. package/dist/profiles/esQueryBuilderExtension.cjs.map +1 -0
  149. package/dist/profiles/esQueryBuilderExtension.d.ts +5 -0
  150. package/dist/profiles/esQueryBuilderExtension.d.ts.map +1 -0
  151. package/dist/profiles/esQueryBuilderExtension.js +23 -0
  152. package/dist/profiles/esQueryBuilderExtension.js.map +1 -0
  153. package/dist/profiles/esQueryBuilderForm.cjs +26 -0
  154. package/dist/profiles/esQueryBuilderForm.cjs.map +1 -0
  155. package/dist/profiles/esQueryBuilderForm.d.ts +18 -0
  156. package/dist/profiles/esQueryBuilderForm.d.ts.map +1 -0
  157. package/dist/profiles/esQueryBuilderForm.js +26 -0
  158. package/dist/profiles/esQueryBuilderForm.js.map +1 -0
  159. package/dist/profiles/esQueryBuilderModel.cjs +131 -0
  160. package/dist/profiles/esQueryBuilderModel.cjs.map +1 -0
  161. package/dist/profiles/esQueryBuilderModel.d.ts +108 -0
  162. package/dist/profiles/esQueryBuilderModel.d.ts.map +1 -0
  163. package/dist/profiles/esQueryBuilderModel.js +131 -0
  164. package/dist/profiles/esQueryBuilderModel.js.map +1 -0
  165. package/dist/profiles/esQueryClauseGroup.cjs +144 -0
  166. package/dist/profiles/esQueryClauseGroup.cjs.map +1 -0
  167. package/dist/profiles/esQueryClauseGroup.d.ts +10 -0
  168. package/dist/profiles/esQueryClauseGroup.d.ts.map +1 -0
  169. package/dist/profiles/esQueryClauseGroup.js +144 -0
  170. package/dist/profiles/esQueryClauseGroup.js.map +1 -0
  171. package/dist/profiles/esQueryCompile.cjs +47 -0
  172. package/dist/profiles/esQueryCompile.cjs.map +1 -0
  173. package/dist/profiles/esQueryCompile.d.ts +39 -0
  174. package/dist/profiles/esQueryCompile.d.ts.map +1 -0
  175. package/dist/profiles/esQueryCompile.js +47 -0
  176. package/dist/profiles/esQueryCompile.js.map +1 -0
  177. package/dist/profiles/esQueryConditionRow.cjs +168 -0
  178. package/dist/profiles/esQueryConditionRow.cjs.map +1 -0
  179. package/dist/profiles/esQueryConditionRow.d.ts +37 -0
  180. package/dist/profiles/esQueryConditionRow.d.ts.map +1 -0
  181. package/dist/profiles/esQueryConditionRow.js +168 -0
  182. package/dist/profiles/esQueryConditionRow.js.map +1 -0
  183. package/dist/profiles/esQueryGroupModel.cjs +12 -0
  184. package/dist/profiles/esQueryGroupModel.cjs.map +1 -0
  185. package/dist/profiles/esQueryGroupModel.d.ts +9 -0
  186. package/dist/profiles/esQueryGroupModel.d.ts.map +1 -0
  187. package/dist/profiles/esQueryGroupModel.js +12 -0
  188. package/dist/profiles/esQueryGroupModel.js.map +1 -0
  189. package/dist/profiles/esQueryOccur.cjs +16 -0
  190. package/dist/profiles/esQueryOccur.cjs.map +1 -0
  191. package/dist/profiles/esQueryOccur.d.ts +11 -0
  192. package/dist/profiles/esQueryOccur.d.ts.map +1 -0
  193. package/dist/profiles/esQueryOccur.js +16 -0
  194. package/dist/profiles/esQueryOccur.js.map +1 -0
  195. package/dist/profiles/esQueryOperandEditors.cjs +279 -0
  196. package/dist/profiles/esQueryOperandEditors.cjs.map +1 -0
  197. package/dist/profiles/esQueryOperandEditors.d.ts +24 -0
  198. package/dist/profiles/esQueryOperandEditors.d.ts.map +1 -0
  199. package/dist/profiles/esQueryOperandEditors.js +279 -0
  200. package/dist/profiles/esQueryOperandEditors.js.map +1 -0
  201. package/dist/profiles/esQueryOperandModel.cjs +28 -0
  202. package/dist/profiles/esQueryOperandModel.cjs.map +1 -0
  203. package/dist/profiles/esQueryOperandModel.d.ts +17 -0
  204. package/dist/profiles/esQueryOperandModel.d.ts.map +1 -0
  205. package/dist/profiles/esQueryOperandModel.js +28 -0
  206. package/dist/profiles/esQueryOperandModel.js.map +1 -0
  207. package/dist/profiles/esQueryOperators.cjs +165 -0
  208. package/dist/profiles/esQueryOperators.cjs.map +1 -0
  209. package/dist/profiles/esQueryOperators.d.ts +83 -0
  210. package/dist/profiles/esQueryOperators.d.ts.map +1 -0
  211. package/dist/profiles/esQueryOperators.js +165 -0
  212. package/dist/profiles/esQueryOperators.js.map +1 -0
  213. package/dist/profiles/esQueryOutputEditor.cjs +138 -0
  214. package/dist/profiles/esQueryOutputEditor.cjs.map +1 -0
  215. package/dist/profiles/esQueryOutputEditor.d.ts +7 -0
  216. package/dist/profiles/esQueryOutputEditor.d.ts.map +1 -0
  217. package/dist/profiles/esQueryOutputEditor.js +138 -0
  218. package/dist/profiles/esQueryOutputEditor.js.map +1 -0
  219. package/dist/profiles/esQueryOutputModel.cjs +16 -0
  220. package/dist/profiles/esQueryOutputModel.cjs.map +1 -0
  221. package/dist/profiles/esQueryOutputModel.d.ts +14 -0
  222. package/dist/profiles/esQueryOutputModel.d.ts.map +1 -0
  223. package/dist/profiles/esQueryOutputModel.js +16 -0
  224. package/dist/profiles/esQueryOutputModel.js.map +1 -0
  225. package/dist/profiles/esQueryPreview.cjs +30 -0
  226. package/dist/profiles/esQueryPreview.cjs.map +1 -0
  227. package/dist/profiles/esQueryPreview.d.ts +6 -0
  228. package/dist/profiles/esQueryPreview.d.ts.map +1 -0
  229. package/dist/profiles/esQueryPreview.js +30 -0
  230. package/dist/profiles/esQueryPreview.js.map +1 -0
  231. package/dist/profiles/esQuerySortEditor.cjs +143 -0
  232. package/dist/profiles/esQuerySortEditor.cjs.map +1 -0
  233. package/dist/profiles/esQuerySortEditor.d.ts +9 -0
  234. package/dist/profiles/esQuerySortEditor.d.ts.map +1 -0
  235. package/dist/profiles/esQuerySortEditor.js +143 -0
  236. package/dist/profiles/esQuerySortEditor.js.map +1 -0
  237. package/dist/profiles/esQuerySortModel.cjs +13 -0
  238. package/dist/profiles/esQuerySortModel.cjs.map +1 -0
  239. package/dist/profiles/esQuerySortModel.d.ts +4 -0
  240. package/dist/profiles/esQuerySortModel.d.ts.map +1 -0
  241. package/dist/profiles/esQuerySortModel.js +13 -0
  242. package/dist/profiles/esQuerySortModel.js.map +1 -0
  243. package/dist/profiles/esValueCombobox.cjs +86 -0
  244. package/dist/profiles/esValueCombobox.cjs.map +1 -0
  245. package/dist/profiles/esValueCombobox.d.ts +15 -0
  246. package/dist/profiles/esValueCombobox.d.ts.map +1 -0
  247. package/dist/profiles/esValueCombobox.js +86 -0
  248. package/dist/profiles/esValueCombobox.js.map +1 -0
  249. package/dist/profiles/jsonPathSample.cjs +75 -0
  250. package/dist/profiles/jsonPathSample.cjs.map +1 -0
  251. package/dist/profiles/jsonPathSample.d.ts +27 -0
  252. package/dist/profiles/jsonPathSample.d.ts.map +1 -0
  253. package/dist/profiles/jsonPathSample.js +75 -0
  254. package/dist/profiles/jsonPathSample.js.map +1 -0
  255. package/dist/profiles/jsonPathSampleRow.cjs +14 -0
  256. package/dist/profiles/jsonPathSampleRow.cjs.map +1 -0
  257. package/dist/profiles/jsonPathSampleRow.d.ts +6 -0
  258. package/dist/profiles/jsonPathSampleRow.d.ts.map +1 -0
  259. package/dist/profiles/jsonPathSampleRow.js +14 -0
  260. package/dist/profiles/jsonPathSampleRow.js.map +1 -0
  261. package/dist/profiles/profileApi.cjs +37 -0
  262. package/dist/profiles/profileApi.cjs.map +1 -0
  263. package/dist/profiles/profileApi.d.ts +32 -0
  264. package/dist/profiles/profileApi.d.ts.map +1 -0
  265. package/dist/profiles/profileApi.js +37 -0
  266. package/dist/profiles/profileApi.js.map +1 -0
  267. package/dist/profiles/profileBuilder.cjs +65 -0
  268. package/dist/profiles/profileBuilder.cjs.map +1 -0
  269. package/dist/profiles/profileBuilder.d.ts +11 -0
  270. package/dist/profiles/profileBuilder.d.ts.map +1 -0
  271. package/dist/profiles/profileBuilder.js +65 -0
  272. package/dist/profiles/profileBuilder.js.map +1 -0
  273. package/dist/profiles/profileBuilderExtension.cjs +25 -0
  274. package/dist/profiles/profileBuilderExtension.cjs.map +1 -0
  275. package/dist/profiles/profileBuilderExtension.d.ts +5 -0
  276. package/dist/profiles/profileBuilderExtension.d.ts.map +1 -0
  277. package/dist/profiles/profileBuilderExtension.js +25 -0
  278. package/dist/profiles/profileBuilderExtension.js.map +1 -0
  279. package/dist/profiles/profileBuilderWorkspace.cjs +368 -0
  280. package/dist/profiles/profileBuilderWorkspace.cjs.map +1 -0
  281. package/dist/profiles/profileBuilderWorkspace.d.ts +21 -0
  282. package/dist/profiles/profileBuilderWorkspace.d.ts.map +1 -0
  283. package/dist/profiles/profileBuilderWorkspace.js +368 -0
  284. package/dist/profiles/profileBuilderWorkspace.js.map +1 -0
  285. package/dist/profiles/profileColumnModel.cjs +23 -0
  286. package/dist/profiles/profileColumnModel.cjs.map +1 -0
  287. package/dist/profiles/profileColumnModel.d.ts +8 -0
  288. package/dist/profiles/profileColumnModel.d.ts.map +1 -0
  289. package/dist/profiles/profileColumnModel.js +23 -0
  290. package/dist/profiles/profileColumnModel.js.map +1 -0
  291. package/dist/profiles/profileColumnPicker.cjs +68 -0
  292. package/dist/profiles/profileColumnPicker.cjs.map +1 -0
  293. package/dist/profiles/profileColumnPicker.d.ts +11 -0
  294. package/dist/profiles/profileColumnPicker.d.ts.map +1 -0
  295. package/dist/profiles/profileColumnPicker.js +68 -0
  296. package/dist/profiles/profileColumnPicker.js.map +1 -0
  297. package/dist/profiles/profileEditor.cjs +386 -0
  298. package/dist/profiles/profileEditor.cjs.map +1 -0
  299. package/dist/profiles/profileEditor.d.ts +19 -0
  300. package/dist/profiles/profileEditor.d.ts.map +1 -0
  301. package/dist/profiles/profileEditor.js +386 -0
  302. package/dist/profiles/profileEditor.js.map +1 -0
  303. package/dist/profiles/profileEditorModel.cjs +181 -0
  304. package/dist/profiles/profileEditorModel.cjs.map +1 -0
  305. package/dist/profiles/profileEditorModel.d.ts +74 -0
  306. package/dist/profiles/profileEditorModel.d.ts.map +1 -0
  307. package/dist/profiles/profileEditorModel.js +181 -0
  308. package/dist/profiles/profileEditorModel.js.map +1 -0
  309. package/dist/profiles/profileEditorPreview.cjs +38 -0
  310. package/dist/profiles/profileEditorPreview.cjs.map +1 -0
  311. package/dist/profiles/profileEditorPreview.d.ts +12 -0
  312. package/dist/profiles/profileEditorPreview.d.ts.map +1 -0
  313. package/dist/profiles/profileEditorPreview.js +38 -0
  314. package/dist/profiles/profileEditorPreview.js.map +1 -0
  315. package/dist/profiles/profileEditorRail.cjs +46 -0
  316. package/dist/profiles/profileEditorRail.cjs.map +1 -0
  317. package/dist/profiles/profileEditorRail.d.ts +8 -0
  318. package/dist/profiles/profileEditorRail.d.ts.map +1 -0
  319. package/dist/profiles/profileEditorRail.js +46 -0
  320. package/dist/profiles/profileEditorRail.js.map +1 -0
  321. package/dist/profiles/profileEditorRaw.cjs +118 -0
  322. package/dist/profiles/profileEditorRaw.cjs.map +1 -0
  323. package/dist/profiles/profileEditorRaw.d.ts +7 -0
  324. package/dist/profiles/profileEditorRaw.d.ts.map +1 -0
  325. package/dist/profiles/profileEditorRaw.js +118 -0
  326. package/dist/profiles/profileEditorRaw.js.map +1 -0
  327. package/dist/profiles/profileEditorRoutes.cjs +7 -0
  328. package/dist/profiles/profileEditorRoutes.cjs.map +1 -0
  329. package/dist/profiles/profileEditorRoutes.d.ts +2 -0
  330. package/dist/profiles/profileEditorRoutes.d.ts.map +1 -0
  331. package/dist/profiles/profileEditorRoutes.js +7 -0
  332. package/dist/profiles/profileEditorRoutes.js.map +1 -0
  333. package/dist/profiles/profileEditorSections.cjs +213 -0
  334. package/dist/profiles/profileEditorSections.cjs.map +1 -0
  335. package/dist/profiles/profileEditorSections.d.ts +23 -0
  336. package/dist/profiles/profileEditorSections.d.ts.map +1 -0
  337. package/dist/profiles/profileEditorSections.js +213 -0
  338. package/dist/profiles/profileEditorSections.js.map +1 -0
  339. package/dist/profiles/profileFieldEditor.cjs +200 -0
  340. package/dist/profiles/profileFieldEditor.cjs.map +1 -0
  341. package/dist/profiles/profileFieldEditor.d.ts +34 -0
  342. package/dist/profiles/profileFieldEditor.d.ts.map +1 -0
  343. package/dist/profiles/profileFieldEditor.js +200 -0
  344. package/dist/profiles/profileFieldEditor.js.map +1 -0
  345. package/dist/profiles/profileFieldGrid.cjs +250 -0
  346. package/dist/profiles/profileFieldGrid.cjs.map +1 -0
  347. package/dist/profiles/profileFieldGrid.d.ts +20 -0
  348. package/dist/profiles/profileFieldGrid.d.ts.map +1 -0
  349. package/dist/profiles/profileFieldGrid.js +250 -0
  350. package/dist/profiles/profileFieldGrid.js.map +1 -0
  351. package/dist/profiles/profileFieldManager.cjs +103 -0
  352. package/dist/profiles/profileFieldManager.cjs.map +1 -0
  353. package/dist/profiles/profileFieldManager.d.ts +9 -0
  354. package/dist/profiles/profileFieldManager.d.ts.map +1 -0
  355. package/dist/profiles/profileFieldManager.js +103 -0
  356. package/dist/profiles/profileFieldManager.js.map +1 -0
  357. package/dist/profiles/profileFieldState.cjs +136 -0
  358. package/dist/profiles/profileFieldState.cjs.map +1 -0
  359. package/dist/profiles/profileFieldState.d.ts +41 -0
  360. package/dist/profiles/profileFieldState.d.ts.map +1 -0
  361. package/dist/profiles/profileFieldState.js +136 -0
  362. package/dist/profiles/profileFieldState.js.map +1 -0
  363. package/dist/profiles/profileFieldTypes.cjs +17 -0
  364. package/dist/profiles/profileFieldTypes.cjs.map +1 -0
  365. package/dist/profiles/profileFieldTypes.d.ts +8 -0
  366. package/dist/profiles/profileFieldTypes.d.ts.map +1 -0
  367. package/dist/profiles/profileFieldTypes.js +17 -0
  368. package/dist/profiles/profileFieldTypes.js.map +1 -0
  369. package/dist/profiles/profileParamModel.cjs +78 -0
  370. package/dist/profiles/profileParamModel.cjs.map +1 -0
  371. package/dist/profiles/profileParamModel.d.ts +3 -0
  372. package/dist/profiles/profileParamModel.d.ts.map +1 -0
  373. package/dist/profiles/profileParamModel.js +78 -0
  374. package/dist/profiles/profileParamModel.js.map +1 -0
  375. package/dist/profiles/profileSamplePayload.cjs +15 -0
  376. package/dist/profiles/profileSamplePayload.cjs.map +1 -0
  377. package/dist/profiles/profileSamplePayload.d.ts +13 -0
  378. package/dist/profiles/profileSamplePayload.d.ts.map +1 -0
  379. package/dist/profiles/profileSamplePayload.js +15 -0
  380. package/dist/profiles/profileSamplePayload.js.map +1 -0
  381. package/dist/profiles/profileWizard.cjs +257 -0
  382. package/dist/profiles/profileWizard.cjs.map +1 -0
  383. package/dist/profiles/profileWizard.d.ts +12 -0
  384. package/dist/profiles/profileWizard.d.ts.map +1 -0
  385. package/dist/profiles/profileWizard.js +257 -0
  386. package/dist/profiles/profileWizard.js.map +1 -0
  387. package/dist/profiles/profileWizardHelp.cjs +10 -0
  388. package/dist/profiles/profileWizardHelp.cjs.map +1 -0
  389. package/dist/profiles/profileWizardHelp.d.ts +13 -0
  390. package/dist/profiles/profileWizardHelp.d.ts.map +1 -0
  391. package/dist/profiles/profileWizardHelp.js +10 -0
  392. package/dist/profiles/profileWizardHelp.js.map +1 -0
  393. package/dist/profiles/profileWizardModel.cjs +198 -0
  394. package/dist/profiles/profileWizardModel.cjs.map +1 -0
  395. package/dist/profiles/profileWizardModel.d.ts +255 -0
  396. package/dist/profiles/profileWizardModel.d.ts.map +1 -0
  397. package/dist/profiles/profileWizardModel.js +198 -0
  398. package/dist/profiles/profileWizardModel.js.map +1 -0
  399. package/dist/profiles/profileWizardQueryStep.cjs +215 -0
  400. package/dist/profiles/profileWizardQueryStep.cjs.map +1 -0
  401. package/dist/profiles/profileWizardQueryStep.d.ts +18 -0
  402. package/dist/profiles/profileWizardQueryStep.d.ts.map +1 -0
  403. package/dist/profiles/profileWizardQueryStep.js +215 -0
  404. package/dist/profiles/profileWizardQueryStep.js.map +1 -0
  405. package/dist/profiles/profileWizardSteps.cjs +214 -0
  406. package/dist/profiles/profileWizardSteps.cjs.map +1 -0
  407. package/dist/profiles/profileWizardSteps.d.ts +35 -0
  408. package/dist/profiles/profileWizardSteps.d.ts.map +1 -0
  409. package/dist/profiles/profileWizardSteps.js +214 -0
  410. package/dist/profiles/profileWizardSteps.js.map +1 -0
  411. package/dist/profiles/profileYaml.cjs +19 -0
  412. package/dist/profiles/profileYaml.cjs.map +1 -0
  413. package/dist/profiles/profileYaml.d.ts +4 -0
  414. package/dist/profiles/profileYaml.d.ts.map +1 -0
  415. package/dist/profiles/profileYaml.js +19 -0
  416. package/dist/profiles/profileYaml.js.map +1 -0
  417. package/dist/profiles/prometheusResults.cjs +60 -0
  418. package/dist/profiles/prometheusResults.cjs.map +1 -0
  419. package/dist/profiles/prometheusResults.d.ts +7 -0
  420. package/dist/profiles/prometheusResults.d.ts.map +1 -0
  421. package/dist/profiles/prometheusResults.js +60 -0
  422. package/dist/profiles/prometheusResults.js.map +1 -0
  423. package/dist/profiles/queryRowLimits.cjs +82 -0
  424. package/dist/profiles/queryRowLimits.cjs.map +1 -0
  425. package/dist/profiles/queryRowLimits.d.ts +9 -0
  426. package/dist/profiles/queryRowLimits.d.ts.map +1 -0
  427. package/dist/profiles/queryRowLimits.js +82 -0
  428. package/dist/profiles/queryRowLimits.js.map +1 -0
  429. package/dist/profiles/queryRowLimitsModel.cjs +10 -0
  430. package/dist/profiles/queryRowLimitsModel.cjs.map +1 -0
  431. package/dist/profiles/queryRowLimitsModel.d.ts +9 -0
  432. package/dist/profiles/queryRowLimitsModel.d.ts.map +1 -0
  433. package/dist/profiles/queryRowLimitsModel.js +10 -0
  434. package/dist/profiles/queryRowLimitsModel.js.map +1 -0
  435. package/dist/profiles/queryTargetPicker.cjs +42 -0
  436. package/dist/profiles/queryTargetPicker.cjs.map +1 -0
  437. package/dist/profiles/queryTargetPicker.d.ts +8 -0
  438. package/dist/profiles/queryTargetPicker.d.ts.map +1 -0
  439. package/dist/profiles/queryTargetPicker.js +42 -0
  440. package/dist/profiles/queryTargetPicker.js.map +1 -0
  441. package/dist/profiles/testSchema.d.ts +3 -0
  442. package/dist/profiles/testSchema.d.ts.map +1 -0
  443. package/dist/profiles.cjs +223 -0
  444. package/dist/profiles.cjs.map +1 -0
  445. package/dist/profiles.d.ts +68 -0
  446. package/dist/profiles.d.ts.map +1 -0
  447. package/dist/profiles.js +223 -0
  448. package/dist/profiles.js.map +1 -0
  449. package/dist/styles.css +1 -1
  450. package/package.json +6 -1
@@ -0,0 +1,301 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const esQueryBuilderModel = require("./esQueryBuilderModel.cjs");
4
+ const esQueryOperandModel = require("./esQueryOperandModel.cjs");
5
+ const profileWizardModel = require("./profileWizardModel.cjs");
6
+ function paramMappings(search, name) {
7
+ const found = [];
8
+ const walk = (condition, path) => {
9
+ var _a;
10
+ if (!condition) return;
11
+ for (const operand of operands) {
12
+ const value = condition[operand];
13
+ const values = Array.isArray(value) ? value : [value];
14
+ if (condition.field && values.some((entry) => esQueryBuilderModel.isParamValue(entry) && entry.param === name)) {
15
+ found.push({ path, field: condition.field, operand });
16
+ }
17
+ }
18
+ (_a = condition.conditions) == null ? void 0 : _a.forEach(
19
+ (child, index) => walk(child, [...path, index])
20
+ );
21
+ };
22
+ walk(search == null ? void 0 : search.query, []);
23
+ return found;
24
+ }
25
+ function addParamMapping({
26
+ search,
27
+ params,
28
+ name,
29
+ field
30
+ }) {
31
+ const param = namedParam(params, name);
32
+ if (param.role === "limit" || param.role === "offset") {
33
+ throw new Error(
34
+ `${param.role} parameter ${name} cannot map to a query field`
35
+ );
36
+ }
37
+ if (param.role === "time-from" || param.role === "time-to") {
38
+ return { search: { ...search, timeField: field }, params };
39
+ }
40
+ const withoutPrevious = param.type === "list" ? stripParamReferences(search, name) : search;
41
+ const condition = {
42
+ op: param.type === "list" ? "terms" : "term",
43
+ occur: "filter",
44
+ field,
45
+ value: { param: name },
46
+ ...!param.required ? { optional: true } : {}
47
+ };
48
+ return {
49
+ search: appendCondition(withoutPrevious, condition),
50
+ params: syncNativeField(
51
+ params,
52
+ name,
53
+ param.type === "list" ? field : void 0
54
+ )
55
+ };
56
+ }
57
+ function bindParamOperand({
58
+ search,
59
+ params,
60
+ path,
61
+ operand,
62
+ name
63
+ }) {
64
+ const param = namedParam(params, name);
65
+ if (param.role && param.role !== "filter") {
66
+ throw new Error(
67
+ `${param.role} parameter ${name} cannot bind a query operand`
68
+ );
69
+ }
70
+ const condition = search.query && esQueryBuilderModel.conditionAt(search.query, path);
71
+ if (!(condition == null ? void 0 : condition.field))
72
+ throw new Error(`condition for parameter ${name} has no field`);
73
+ const value = { param: name };
74
+ const patch = operand === "values" ? esQueryOperandModel.conditionOperandPatch({ arity: "multiple", values: [value] }) : operand === "value" ? esQueryOperandModel.conditionOperandPatch({ arity: "single", value }) : esQueryOperandModel.conditionOperandPatch({ arity: "range", bound: operand, value });
75
+ const query = esQueryBuilderModel.updateAt(
76
+ search.query,
77
+ path,
78
+ (current) => profileWizardModel.applyPatch(current, patch)
79
+ );
80
+ const bound = { ...search, query };
81
+ return {
82
+ search: param.type === "list" ? stripParamReferences(bound, name, path) : bound,
83
+ params: syncNativeField(
84
+ params,
85
+ name,
86
+ param.type === "list" ? condition.field : void 0
87
+ )
88
+ };
89
+ }
90
+ function removeParamMapping({
91
+ search,
92
+ params,
93
+ name,
94
+ path
95
+ }) {
96
+ const param = namedParam(params, name);
97
+ if (param.role === "time-from" || param.role === "time-to") {
98
+ const next = { ...search };
99
+ delete next.timeField;
100
+ return { search: next, params };
101
+ }
102
+ if (!path) {
103
+ if (param.type !== "list")
104
+ throw new Error(`parameter ${name} has no field mapping to remove`);
105
+ return { search, params: syncNativeField(params, name, void 0) };
106
+ }
107
+ const query = search.query ? editAt(
108
+ search.query,
109
+ path,
110
+ (condition) => removeReference(condition, name)
111
+ ) : void 0;
112
+ return {
113
+ search: { ...search, query: query ?? esQueryBuilderModel.emptyGroup() },
114
+ params: syncNativeField(params, name, void 0)
115
+ };
116
+ }
117
+ function reconcileParamMappings({
118
+ search,
119
+ previous,
120
+ next
121
+ }) {
122
+ let reconciled = search;
123
+ const previousNames = new Set(
124
+ previous.map((param) => param.name).filter(Boolean)
125
+ );
126
+ const nextNames = new Set(next.map((param) => param.name).filter(Boolean));
127
+ const renamed = /* @__PURE__ */ new Set();
128
+ if (previous.length === next.length) {
129
+ previous.forEach((param, index) => {
130
+ var _a;
131
+ const oldName = param.name;
132
+ const newName = (_a = next[index]) == null ? void 0 : _a.name;
133
+ if (oldName && newName && oldName !== newName && !nextNames.has(oldName) && !previousNames.has(newName)) {
134
+ reconciled = renameParamReferences(reconciled, oldName, newName);
135
+ renamed.add(oldName);
136
+ }
137
+ });
138
+ }
139
+ for (const param of previous) {
140
+ if (param.name && !renamed.has(param.name) && !nextNames.has(param.name)) {
141
+ reconciled = stripParamReferences(reconciled, param.name);
142
+ }
143
+ }
144
+ return {
145
+ search: reconciled,
146
+ params: syncAllNativeFields(reconciled, next, search)
147
+ };
148
+ }
149
+ function reconcileSearchParamMappings({
150
+ previousSearch,
151
+ nextSearch,
152
+ params
153
+ }) {
154
+ return {
155
+ search: nextSearch,
156
+ params: syncAllNativeFields(nextSearch, params, previousSearch)
157
+ };
158
+ }
159
+ const operands = ["value", "values", "gt", "gte", "lt", "lte"];
160
+ function namedParam(params, name) {
161
+ const param = params.find((candidate) => candidate.name === name);
162
+ if (!param) throw new Error(`parameter ${name} does not exist`);
163
+ return param;
164
+ }
165
+ function appendCondition(search, condition) {
166
+ if (!search.query || search.query.op === "match_all") {
167
+ return { ...search, query: { ...esQueryBuilderModel.emptyGroup(), conditions: [condition] } };
168
+ }
169
+ if (search.query.op === "bool") {
170
+ return {
171
+ ...search,
172
+ query: {
173
+ ...search.query,
174
+ conditions: [...search.query.conditions ?? [], condition]
175
+ }
176
+ };
177
+ }
178
+ return {
179
+ ...search,
180
+ query: { ...esQueryBuilderModel.emptyGroup(), conditions: [search.query, condition] }
181
+ };
182
+ }
183
+ function stripParamReferences(search, name, keepPath) {
184
+ const query = stripCondition(search.query, name, [], keepPath);
185
+ return { ...search, query: query ?? esQueryBuilderModel.emptyGroup() };
186
+ }
187
+ function stripCondition(condition, name, path, keepPath) {
188
+ var _a;
189
+ if (!condition) return void 0;
190
+ if (keepPath && samePath(path, keepPath)) return condition;
191
+ if (condition.when === name) return void 0;
192
+ let next = removeReference(condition, name);
193
+ if (!next) return void 0;
194
+ if (next.conditions) {
195
+ const conditions = next.conditions.flatMap((child, index) => {
196
+ const stripped = stripCondition(child, name, [...path, index], keepPath);
197
+ return stripped ? [stripped] : [];
198
+ });
199
+ next = { ...next, conditions };
200
+ if (conditions.length === 0 && (((_a = condition.conditions) == null ? void 0 : _a.length) ?? 0) > 0)
201
+ return void 0;
202
+ }
203
+ return next;
204
+ }
205
+ function removeReference(condition, name) {
206
+ let removed = false;
207
+ const next = { ...condition };
208
+ for (const operand of operands) {
209
+ const value = condition[operand];
210
+ if (operand === "values") {
211
+ const values = (condition.values ?? []).filter((entry) => {
212
+ const matches = esQueryBuilderModel.isParamValue(entry) && entry.param === name;
213
+ removed || (removed = matches);
214
+ return !matches;
215
+ });
216
+ if (values.length) next.values = values;
217
+ else delete next.values;
218
+ } else if (esQueryBuilderModel.isParamValue(value) && value.param === name) {
219
+ delete next[operand];
220
+ removed = true;
221
+ }
222
+ }
223
+ return removed && !hasOperand(next) ? void 0 : next;
224
+ }
225
+ function hasOperand(condition) {
226
+ var _a, _b;
227
+ return condition.value !== void 0 || Boolean((_a = condition.values) == null ? void 0 : _a.length) || condition.gt !== void 0 || condition.gte !== void 0 || condition.lt !== void 0 || condition.lte !== void 0 || Boolean((_b = condition.conditions) == null ? void 0 : _b.length);
228
+ }
229
+ function editAt(condition, path, edit) {
230
+ if (path.length === 0) return edit(condition);
231
+ const [target, ...rest] = path;
232
+ const children = condition.conditions ?? [];
233
+ const child = target === void 0 ? void 0 : children[target];
234
+ if (!child) throw new Error(`condition path ${path.join(".")} does not exist`);
235
+ const edited = editAt(child, rest, edit);
236
+ return {
237
+ ...condition,
238
+ conditions: children.flatMap(
239
+ (child2, index) => index !== target ? [child2] : edited ? [edited] : []
240
+ )
241
+ };
242
+ }
243
+ function renameParamReferences(search, oldName, newName) {
244
+ const rename = (condition) => {
245
+ const next = { ...condition };
246
+ for (const operand of operands) {
247
+ const value = condition[operand];
248
+ if (operand === "values") {
249
+ if (condition.values) {
250
+ next.values = condition.values.map(
251
+ (entry) => renamedValue(entry, oldName, newName)
252
+ );
253
+ }
254
+ } else {
255
+ next[operand] = renamedValue(value, oldName, newName);
256
+ }
257
+ }
258
+ if (condition.when === oldName) next.when = newName;
259
+ if (condition.conditions)
260
+ next.conditions = condition.conditions.map(rename);
261
+ return next;
262
+ };
263
+ if (!search.query) return { ...search };
264
+ return { ...search, query: rename(search.query) };
265
+ }
266
+ function renamedValue(value, oldName, newName) {
267
+ return esQueryBuilderModel.isParamValue(value) && value.param === oldName ? { param: newName } : value;
268
+ }
269
+ function syncNativeField(params, name, field) {
270
+ const param = namedParam(params, name);
271
+ if (param.type !== "list") return params;
272
+ return params.map((candidate) => {
273
+ if (candidate.name !== name) return candidate;
274
+ const next = { ...candidate, ...field ? { field } : {} };
275
+ if (!field) delete next.field;
276
+ return next;
277
+ });
278
+ }
279
+ function syncAllNativeFields(search, params, previousSearch) {
280
+ return params.map((param) => {
281
+ if (param.type !== "list" || !param.name) return param;
282
+ const mapping = paramMappings(search, param.name)[0];
283
+ const wasMapped = paramMappings(previousSearch, param.name).length > 0;
284
+ if (!mapping && !wasMapped) return param;
285
+ const field = mapping == null ? void 0 : mapping.field;
286
+ if (field === param.field) return param;
287
+ const next = { ...param, ...field ? { field } : {} };
288
+ if (!field) delete next.field;
289
+ return next;
290
+ });
291
+ }
292
+ function samePath(left, right) {
293
+ return left.length === right.length && left.every((value, index) => value === right[index]);
294
+ }
295
+ exports.addParamMapping = addParamMapping;
296
+ exports.bindParamOperand = bindParamOperand;
297
+ exports.paramMappings = paramMappings;
298
+ exports.reconcileParamMappings = reconcileParamMappings;
299
+ exports.reconcileSearchParamMappings = reconcileSearchParamMappings;
300
+ exports.removeParamMapping = removeParamMapping;
301
+ //# sourceMappingURL=esParamMappingModel.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esParamMappingModel.cjs","sources":["../../src/profiles/esParamMappingModel.ts"],"sourcesContent":["import type {\n ConditionPath,\n EsCondition,\n EsSearch,\n EsValue,\n} from \"./esQueryBuilderModel\";\nimport {\n conditionAt,\n emptyGroup,\n isParamValue,\n updateAt,\n} from \"./esQueryBuilderModel\";\nimport { conditionOperandPatch } from \"./esQueryOperandModel\";\nimport { applyPatch, type ParamDraft } from \"./profileWizardModel\";\n\nexport type ParamOperand = \"value\" | \"values\" | \"gt\" | \"gte\" | \"lt\" | \"lte\";\n\nexport type ParamMapping = {\n path: ConditionPath;\n field: string;\n operand: ParamOperand;\n};\n\nexport type ParamMappingEdit = {\n search: EsSearch;\n params: ParamDraft[];\n};\n\nexport function paramMappings(\n search: EsSearch | undefined,\n name: string,\n): ParamMapping[] {\n const found: ParamMapping[] = [];\n const walk = (condition: EsCondition | undefined, path: ConditionPath) => {\n if (!condition) return;\n for (const operand of operands) {\n const value = condition[operand];\n const values = Array.isArray(value) ? value : [value];\n if (\n condition.field &&\n values.some((entry) => isParamValue(entry) && entry.param === name)\n ) {\n found.push({ path, field: condition.field, operand });\n }\n }\n condition.conditions?.forEach((child, index) =>\n walk(child, [...path, index]),\n );\n };\n walk(search?.query, []);\n return found;\n}\n\nexport function addParamMapping({\n search,\n params,\n name,\n field,\n}: ParamMappingEdit & { name: string; field: string }): ParamMappingEdit {\n const param = namedParam(params, name);\n if (param.role === \"limit\" || param.role === \"offset\") {\n throw new Error(\n `${param.role} parameter ${name} cannot map to a query field`,\n );\n }\n if (param.role === \"time-from\" || param.role === \"time-to\") {\n return { search: { ...search, timeField: field }, params };\n }\n const withoutPrevious =\n param.type === \"list\" ? stripParamReferences(search, name) : search;\n const condition: EsCondition = {\n op: param.type === \"list\" ? \"terms\" : \"term\",\n occur: \"filter\",\n field,\n value: { param: name },\n ...(!param.required ? { optional: true } : {}),\n };\n return {\n search: appendCondition(withoutPrevious, condition),\n params: syncNativeField(\n params,\n name,\n param.type === \"list\" ? field : undefined,\n ),\n };\n}\n\nexport function bindParamOperand({\n search,\n params,\n path,\n operand,\n name,\n}: ParamMappingEdit & {\n path: ConditionPath;\n operand: ParamOperand;\n name: string;\n}): ParamMappingEdit {\n const param = namedParam(params, name);\n if (param.role && param.role !== \"filter\") {\n throw new Error(\n `${param.role} parameter ${name} cannot bind a query operand`,\n );\n }\n const condition = search.query && conditionAt(search.query, path);\n if (!condition?.field)\n throw new Error(`condition for parameter ${name} has no field`);\n const value = { param: name };\n const patch =\n operand === \"values\"\n ? conditionOperandPatch({ arity: \"multiple\", values: [value] })\n : operand === \"value\"\n ? conditionOperandPatch({ arity: \"single\", value })\n : conditionOperandPatch({ arity: \"range\", bound: operand, value });\n const query = updateAt(search.query as EsCondition, path, (current) =>\n applyPatch(current, patch),\n );\n const bound = { ...search, query };\n return {\n search:\n param.type === \"list\" ? stripParamReferences(bound, name, path) : bound,\n params: syncNativeField(\n params,\n name,\n param.type === \"list\" ? condition.field : undefined,\n ),\n };\n}\n\nexport function removeParamMapping({\n search,\n params,\n name,\n path,\n}: ParamMappingEdit & {\n name: string;\n path?: ConditionPath;\n}): ParamMappingEdit {\n const param = namedParam(params, name);\n if (param.role === \"time-from\" || param.role === \"time-to\") {\n const next = { ...search };\n delete next.timeField;\n return { search: next, params };\n }\n if (!path) {\n if (param.type !== \"list\")\n throw new Error(`parameter ${name} has no field mapping to remove`);\n return { search, params: syncNativeField(params, name, undefined) };\n }\n const query = search.query\n ? editAt(search.query, path, (condition) =>\n removeReference(condition, name),\n )\n : undefined;\n return {\n search: { ...search, query: query ?? emptyGroup() },\n params: syncNativeField(params, name, undefined),\n };\n}\n\nexport function reconcileParamMappings({\n search,\n previous,\n next,\n}: {\n search: EsSearch;\n previous: ParamDraft[];\n next: ParamDraft[];\n}): ParamMappingEdit {\n let reconciled = search;\n const previousNames = new Set(\n previous.map((param) => param.name).filter(Boolean),\n );\n const nextNames = new Set(next.map((param) => param.name).filter(Boolean));\n const renamed = new Set<string>();\n if (previous.length === next.length) {\n previous.forEach((param, index) => {\n const oldName = param.name;\n const newName = next[index]?.name;\n if (\n oldName &&\n newName &&\n oldName !== newName &&\n !nextNames.has(oldName) &&\n !previousNames.has(newName)\n ) {\n reconciled = renameParamReferences(reconciled, oldName, newName);\n renamed.add(oldName);\n }\n });\n }\n for (const param of previous) {\n if (param.name && !renamed.has(param.name) && !nextNames.has(param.name)) {\n reconciled = stripParamReferences(reconciled, param.name);\n }\n }\n return {\n search: reconciled,\n params: syncAllNativeFields(reconciled, next, search),\n };\n}\n\nexport function reconcileSearchParamMappings({\n previousSearch,\n nextSearch,\n params,\n}: {\n previousSearch: EsSearch;\n nextSearch: EsSearch;\n params: ParamDraft[];\n}): ParamMappingEdit {\n return {\n search: nextSearch,\n params: syncAllNativeFields(nextSearch, params, previousSearch),\n };\n}\n\nconst operands: ParamOperand[] = [\"value\", \"values\", \"gt\", \"gte\", \"lt\", \"lte\"];\n\nfunction namedParam(params: ParamDraft[], name: string): ParamDraft {\n const param = params.find((candidate) => candidate.name === name);\n if (!param) throw new Error(`parameter ${name} does not exist`);\n return param;\n}\n\nfunction appendCondition(search: EsSearch, condition: EsCondition): EsSearch {\n if (!search.query || search.query.op === \"match_all\") {\n return { ...search, query: { ...emptyGroup(), conditions: [condition] } };\n }\n if (search.query.op === \"bool\") {\n return {\n ...search,\n query: {\n ...search.query,\n conditions: [...(search.query.conditions ?? []), condition],\n },\n };\n }\n return {\n ...search,\n query: { ...emptyGroup(), conditions: [search.query, condition] },\n };\n}\n\nfunction stripParamReferences(\n search: EsSearch,\n name: string,\n keepPath?: ConditionPath,\n): EsSearch {\n const query = stripCondition(search.query, name, [], keepPath);\n return { ...search, query: query ?? emptyGroup() };\n}\n\nfunction stripCondition(\n condition: EsCondition | undefined,\n name: string,\n path: ConditionPath,\n keepPath?: ConditionPath,\n): EsCondition | undefined {\n if (!condition) return undefined;\n if (keepPath && samePath(path, keepPath)) return condition;\n if (condition.when === name) return undefined;\n let next = removeReference(condition, name);\n if (!next) return undefined;\n if (next.conditions) {\n const conditions = next.conditions.flatMap((child, index) => {\n const stripped = stripCondition(child, name, [...path, index], keepPath);\n return stripped ? [stripped] : [];\n });\n next = { ...next, conditions };\n if (conditions.length === 0 && (condition.conditions?.length ?? 0) > 0)\n return undefined;\n }\n return next;\n}\n\nfunction removeReference(\n condition: EsCondition,\n name: string,\n): EsCondition | undefined {\n let removed = false;\n const next = { ...condition };\n for (const operand of operands) {\n const value = condition[operand];\n if (operand === \"values\") {\n const values = (condition.values ?? []).filter((entry) => {\n const matches = isParamValue(entry) && entry.param === name;\n removed ||= matches;\n return !matches;\n });\n // Deleted rather than set to undefined: the search is serialized, and a\n // present `values: undefined` is a key the backend has to interpret.\n if (values.length) next.values = values;\n else delete next.values;\n } else if (isParamValue(value) && value.param === name) {\n delete next[operand];\n removed = true;\n }\n }\n return removed && !hasOperand(next) ? undefined : next;\n}\n\nfunction hasOperand(condition: EsCondition): boolean {\n return (\n condition.value !== undefined ||\n Boolean(condition.values?.length) ||\n condition.gt !== undefined ||\n condition.gte !== undefined ||\n condition.lt !== undefined ||\n condition.lte !== undefined ||\n Boolean(condition.conditions?.length)\n );\n}\n\nfunction editAt(\n condition: EsCondition,\n path: ConditionPath,\n edit: (condition: EsCondition) => EsCondition | undefined,\n): EsCondition | undefined {\n if (path.length === 0) return edit(condition);\n const [target, ...rest] = path;\n const children = condition.conditions ?? [];\n const child = target === undefined ? undefined : children[target];\n if (!child) throw new Error(`condition path ${path.join(\".\")} does not exist`);\n const edited = editAt(child, rest, edit);\n return {\n ...condition,\n conditions: children.flatMap((child, index) =>\n index !== target ? [child] : edited ? [edited] : [],\n ),\n };\n}\n\nfunction renameParamReferences(\n search: EsSearch,\n oldName: string,\n newName: string,\n): EsSearch {\n const rename = (condition: EsCondition): EsCondition => {\n const next = { ...condition };\n for (const operand of operands) {\n const value = condition[operand];\n if (operand === \"values\") {\n if (condition.values) {\n next.values = condition.values.map((entry) =>\n renamedValue(entry, oldName, newName),\n );\n }\n } else {\n next[operand] = renamedValue(value, oldName, newName) as never;\n }\n }\n if (condition.when === oldName) next.when = newName;\n if (condition.conditions)\n next.conditions = condition.conditions.map(rename);\n return next;\n };\n if (!search.query) return { ...search };\n return { ...search, query: rename(search.query) };\n}\n\nfunction renamedValue(\n value: EsValue,\n oldName: string,\n newName: string,\n): EsValue {\n return isParamValue(value) && value.param === oldName\n ? { param: newName }\n : value;\n}\n\nfunction syncNativeField(\n params: ParamDraft[],\n name: string,\n field: string | undefined,\n): ParamDraft[] {\n const param = namedParam(params, name);\n if (param.type !== \"list\") return params;\n return params.map((candidate) => {\n if (candidate.name !== name) return candidate;\n const next: ParamDraft = { ...candidate, ...(field ? { field } : {}) };\n if (!field) delete next.field;\n return next;\n });\n}\n\nfunction syncAllNativeFields(\n search: EsSearch,\n params: ParamDraft[],\n previousSearch: EsSearch,\n): ParamDraft[] {\n return params.map((param) => {\n if (param.type !== \"list\" || !param.name) return param;\n const mapping = paramMappings(search, param.name)[0];\n const wasMapped = paramMappings(previousSearch, param.name).length > 0;\n if (!mapping && !wasMapped) return param;\n const field = mapping?.field;\n if (field === param.field) return param;\n const next: ParamDraft = { ...param, ...(field ? { field } : {}) };\n if (!field) delete next.field;\n return next;\n });\n}\n\nfunction samePath(left: ConditionPath, right: ConditionPath): boolean {\n return (\n left.length === right.length &&\n left.every((value, index) => value === right[index])\n );\n}\n"],"names":["isParamValue","conditionAt","conditionOperandPatch","updateAt","applyPatch","emptyGroup","child"],"mappings":";;;;;AA4BO,SAAS,cACd,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U,MAAM,KAAK,CAAC;AAEvD;;;;;;;"}
@@ -0,0 +1,37 @@
1
+ import { ConditionPath, EsSearch } from './esQueryBuilderModel';
2
+ import { ParamDraft } from './profileWizardModel';
3
+ export type ParamOperand = "value" | "values" | "gt" | "gte" | "lt" | "lte";
4
+ export type ParamMapping = {
5
+ path: ConditionPath;
6
+ field: string;
7
+ operand: ParamOperand;
8
+ };
9
+ export type ParamMappingEdit = {
10
+ search: EsSearch;
11
+ params: ParamDraft[];
12
+ };
13
+ export declare function paramMappings(search: EsSearch | undefined, name: string): ParamMapping[];
14
+ export declare function addParamMapping({ search, params, name, field, }: ParamMappingEdit & {
15
+ name: string;
16
+ field: string;
17
+ }): ParamMappingEdit;
18
+ export declare function bindParamOperand({ search, params, path, operand, name, }: ParamMappingEdit & {
19
+ path: ConditionPath;
20
+ operand: ParamOperand;
21
+ name: string;
22
+ }): ParamMappingEdit;
23
+ export declare function removeParamMapping({ search, params, name, path, }: ParamMappingEdit & {
24
+ name: string;
25
+ path?: ConditionPath;
26
+ }): ParamMappingEdit;
27
+ export declare function reconcileParamMappings({ search, previous, next, }: {
28
+ search: EsSearch;
29
+ previous: ParamDraft[];
30
+ next: ParamDraft[];
31
+ }): ParamMappingEdit;
32
+ export declare function reconcileSearchParamMappings({ previousSearch, nextSearch, params, }: {
33
+ previousSearch: EsSearch;
34
+ nextSearch: EsSearch;
35
+ params: ParamDraft[];
36
+ }): ParamMappingEdit;
37
+ //# sourceMappingURL=esParamMappingModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esParamMappingModel.d.ts","sourceRoot":"","sources":["../../src/profiles/esParamMappingModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,QAAQ,EAET,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,GAAG,K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AC3C,cAAc,EACd,UAAU,EACV,MAAM,GACP,EAAE;IACD,cAAc,EAAE,QAAQ,CAAC;IACzB,UAAU,EAAE,QAAQ,CAAC;IACrB,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB,GAAG,gBAAgB,CAKnB"}
@@ -0,0 +1,301 @@
1
+ import { conditionAt, updateAt, emptyGroup, isParamValue } from "./esQueryBuilderModel.js";
2
+ import { conditionOperandPatch } from "./esQueryOperandModel.js";
3
+ import { applyPatch } from "./profileWizardModel.js";
4
+ function paramMappings(search, name) {
5
+ const found = [];
6
+ const walk = (condition, path) => {
7
+ var _a;
8
+ if (!condition) return;
9
+ for (const operand of operands) {
10
+ const value = condition[operand];
11
+ const values = Array.isArray(value) ? value : [value];
12
+ if (condition.field && values.some((entry) => isParamValue(entry) && entry.param === name)) {
13
+ found.push({ path, field: condition.field, operand });
14
+ }
15
+ }
16
+ (_a = condition.conditions) == null ? void 0 : _a.forEach(
17
+ (child, index) => walk(child, [...path, index])
18
+ );
19
+ };
20
+ walk(search == null ? void 0 : search.query, []);
21
+ return found;
22
+ }
23
+ function addParamMapping({
24
+ search,
25
+ params,
26
+ name,
27
+ field
28
+ }) {
29
+ const param = namedParam(params, name);
30
+ if (param.role === "limit" || param.role === "offset") {
31
+ throw new Error(
32
+ `${param.role} parameter ${name} cannot map to a query field`
33
+ );
34
+ }
35
+ if (param.role === "time-from" || param.role === "time-to") {
36
+ return { search: { ...search, timeField: field }, params };
37
+ }
38
+ const withoutPrevious = param.type === "list" ? stripParamReferences(search, name) : search;
39
+ const condition = {
40
+ op: param.type === "list" ? "terms" : "term",
41
+ occur: "filter",
42
+ field,
43
+ value: { param: name },
44
+ ...!param.required ? { optional: true } : {}
45
+ };
46
+ return {
47
+ search: appendCondition(withoutPrevious, condition),
48
+ params: syncNativeField(
49
+ params,
50
+ name,
51
+ param.type === "list" ? field : void 0
52
+ )
53
+ };
54
+ }
55
+ function bindParamOperand({
56
+ search,
57
+ params,
58
+ path,
59
+ operand,
60
+ name
61
+ }) {
62
+ const param = namedParam(params, name);
63
+ if (param.role && param.role !== "filter") {
64
+ throw new Error(
65
+ `${param.role} parameter ${name} cannot bind a query operand`
66
+ );
67
+ }
68
+ const condition = search.query && conditionAt(search.query, path);
69
+ if (!(condition == null ? void 0 : condition.field))
70
+ throw new Error(`condition for parameter ${name} has no field`);
71
+ const value = { param: name };
72
+ const patch = operand === "values" ? conditionOperandPatch({ arity: "multiple", values: [value] }) : operand === "value" ? conditionOperandPatch({ arity: "single", value }) : conditionOperandPatch({ arity: "range", bound: operand, value });
73
+ const query = updateAt(
74
+ search.query,
75
+ path,
76
+ (current) => applyPatch(current, patch)
77
+ );
78
+ const bound = { ...search, query };
79
+ return {
80
+ search: param.type === "list" ? stripParamReferences(bound, name, path) : bound,
81
+ params: syncNativeField(
82
+ params,
83
+ name,
84
+ param.type === "list" ? condition.field : void 0
85
+ )
86
+ };
87
+ }
88
+ function removeParamMapping({
89
+ search,
90
+ params,
91
+ name,
92
+ path
93
+ }) {
94
+ const param = namedParam(params, name);
95
+ if (param.role === "time-from" || param.role === "time-to") {
96
+ const next = { ...search };
97
+ delete next.timeField;
98
+ return { search: next, params };
99
+ }
100
+ if (!path) {
101
+ if (param.type !== "list")
102
+ throw new Error(`parameter ${name} has no field mapping to remove`);
103
+ return { search, params: syncNativeField(params, name, void 0) };
104
+ }
105
+ const query = search.query ? editAt(
106
+ search.query,
107
+ path,
108
+ (condition) => removeReference(condition, name)
109
+ ) : void 0;
110
+ return {
111
+ search: { ...search, query: query ?? emptyGroup() },
112
+ params: syncNativeField(params, name, void 0)
113
+ };
114
+ }
115
+ function reconcileParamMappings({
116
+ search,
117
+ previous,
118
+ next
119
+ }) {
120
+ let reconciled = search;
121
+ const previousNames = new Set(
122
+ previous.map((param) => param.name).filter(Boolean)
123
+ );
124
+ const nextNames = new Set(next.map((param) => param.name).filter(Boolean));
125
+ const renamed = /* @__PURE__ */ new Set();
126
+ if (previous.length === next.length) {
127
+ previous.forEach((param, index) => {
128
+ var _a;
129
+ const oldName = param.name;
130
+ const newName = (_a = next[index]) == null ? void 0 : _a.name;
131
+ if (oldName && newName && oldName !== newName && !nextNames.has(oldName) && !previousNames.has(newName)) {
132
+ reconciled = renameParamReferences(reconciled, oldName, newName);
133
+ renamed.add(oldName);
134
+ }
135
+ });
136
+ }
137
+ for (const param of previous) {
138
+ if (param.name && !renamed.has(param.name) && !nextNames.has(param.name)) {
139
+ reconciled = stripParamReferences(reconciled, param.name);
140
+ }
141
+ }
142
+ return {
143
+ search: reconciled,
144
+ params: syncAllNativeFields(reconciled, next, search)
145
+ };
146
+ }
147
+ function reconcileSearchParamMappings({
148
+ previousSearch,
149
+ nextSearch,
150
+ params
151
+ }) {
152
+ return {
153
+ search: nextSearch,
154
+ params: syncAllNativeFields(nextSearch, params, previousSearch)
155
+ };
156
+ }
157
+ const operands = ["value", "values", "gt", "gte", "lt", "lte"];
158
+ function namedParam(params, name) {
159
+ const param = params.find((candidate) => candidate.name === name);
160
+ if (!param) throw new Error(`parameter ${name} does not exist`);
161
+ return param;
162
+ }
163
+ function appendCondition(search, condition) {
164
+ if (!search.query || search.query.op === "match_all") {
165
+ return { ...search, query: { ...emptyGroup(), conditions: [condition] } };
166
+ }
167
+ if (search.query.op === "bool") {
168
+ return {
169
+ ...search,
170
+ query: {
171
+ ...search.query,
172
+ conditions: [...search.query.conditions ?? [], condition]
173
+ }
174
+ };
175
+ }
176
+ return {
177
+ ...search,
178
+ query: { ...emptyGroup(), conditions: [search.query, condition] }
179
+ };
180
+ }
181
+ function stripParamReferences(search, name, keepPath) {
182
+ const query = stripCondition(search.query, name, [], keepPath);
183
+ return { ...search, query: query ?? emptyGroup() };
184
+ }
185
+ function stripCondition(condition, name, path, keepPath) {
186
+ var _a;
187
+ if (!condition) return void 0;
188
+ if (keepPath && samePath(path, keepPath)) return condition;
189
+ if (condition.when === name) return void 0;
190
+ let next = removeReference(condition, name);
191
+ if (!next) return void 0;
192
+ if (next.conditions) {
193
+ const conditions = next.conditions.flatMap((child, index) => {
194
+ const stripped = stripCondition(child, name, [...path, index], keepPath);
195
+ return stripped ? [stripped] : [];
196
+ });
197
+ next = { ...next, conditions };
198
+ if (conditions.length === 0 && (((_a = condition.conditions) == null ? void 0 : _a.length) ?? 0) > 0)
199
+ return void 0;
200
+ }
201
+ return next;
202
+ }
203
+ function removeReference(condition, name) {
204
+ let removed = false;
205
+ const next = { ...condition };
206
+ for (const operand of operands) {
207
+ const value = condition[operand];
208
+ if (operand === "values") {
209
+ const values = (condition.values ?? []).filter((entry) => {
210
+ const matches = isParamValue(entry) && entry.param === name;
211
+ removed || (removed = matches);
212
+ return !matches;
213
+ });
214
+ if (values.length) next.values = values;
215
+ else delete next.values;
216
+ } else if (isParamValue(value) && value.param === name) {
217
+ delete next[operand];
218
+ removed = true;
219
+ }
220
+ }
221
+ return removed && !hasOperand(next) ? void 0 : next;
222
+ }
223
+ function hasOperand(condition) {
224
+ var _a, _b;
225
+ return condition.value !== void 0 || Boolean((_a = condition.values) == null ? void 0 : _a.length) || condition.gt !== void 0 || condition.gte !== void 0 || condition.lt !== void 0 || condition.lte !== void 0 || Boolean((_b = condition.conditions) == null ? void 0 : _b.length);
226
+ }
227
+ function editAt(condition, path, edit) {
228
+ if (path.length === 0) return edit(condition);
229
+ const [target, ...rest] = path;
230
+ const children = condition.conditions ?? [];
231
+ const child = target === void 0 ? void 0 : children[target];
232
+ if (!child) throw new Error(`condition path ${path.join(".")} does not exist`);
233
+ const edited = editAt(child, rest, edit);
234
+ return {
235
+ ...condition,
236
+ conditions: children.flatMap(
237
+ (child2, index) => index !== target ? [child2] : edited ? [edited] : []
238
+ )
239
+ };
240
+ }
241
+ function renameParamReferences(search, oldName, newName) {
242
+ const rename = (condition) => {
243
+ const next = { ...condition };
244
+ for (const operand of operands) {
245
+ const value = condition[operand];
246
+ if (operand === "values") {
247
+ if (condition.values) {
248
+ next.values = condition.values.map(
249
+ (entry) => renamedValue(entry, oldName, newName)
250
+ );
251
+ }
252
+ } else {
253
+ next[operand] = renamedValue(value, oldName, newName);
254
+ }
255
+ }
256
+ if (condition.when === oldName) next.when = newName;
257
+ if (condition.conditions)
258
+ next.conditions = condition.conditions.map(rename);
259
+ return next;
260
+ };
261
+ if (!search.query) return { ...search };
262
+ return { ...search, query: rename(search.query) };
263
+ }
264
+ function renamedValue(value, oldName, newName) {
265
+ return isParamValue(value) && value.param === oldName ? { param: newName } : value;
266
+ }
267
+ function syncNativeField(params, name, field) {
268
+ const param = namedParam(params, name);
269
+ if (param.type !== "list") return params;
270
+ return params.map((candidate) => {
271
+ if (candidate.name !== name) return candidate;
272
+ const next = { ...candidate, ...field ? { field } : {} };
273
+ if (!field) delete next.field;
274
+ return next;
275
+ });
276
+ }
277
+ function syncAllNativeFields(search, params, previousSearch) {
278
+ return params.map((param) => {
279
+ if (param.type !== "list" || !param.name) return param;
280
+ const mapping = paramMappings(search, param.name)[0];
281
+ const wasMapped = paramMappings(previousSearch, param.name).length > 0;
282
+ if (!mapping && !wasMapped) return param;
283
+ const field = mapping == null ? void 0 : mapping.field;
284
+ if (field === param.field) return param;
285
+ const next = { ...param, ...field ? { field } : {} };
286
+ if (!field) delete next.field;
287
+ return next;
288
+ });
289
+ }
290
+ function samePath(left, right) {
291
+ return left.length === right.length && left.every((value, index) => value === right[index]);
292
+ }
293
+ export {
294
+ addParamMapping,
295
+ bindParamOperand,
296
+ paramMappings,
297
+ reconcileParamMappings,
298
+ reconcileSearchParamMappings,
299
+ removeParamMapping
300
+ };
301
+ //# sourceMappingURL=esParamMappingModel.js.map