@servicenow/sdk-build-plugins 4.2.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/dist/acl-plugin.js +11 -0
  2. package/dist/acl-plugin.js.map +1 -1
  3. package/dist/applicability-plugin.d.ts +2 -0
  4. package/dist/applicability-plugin.js +72 -0
  5. package/dist/applicability-plugin.js.map +1 -0
  6. package/dist/atf/test-plugin.js +5 -2
  7. package/dist/atf/test-plugin.js.map +1 -1
  8. package/dist/basic-syntax-plugin.js +7 -1
  9. package/dist/basic-syntax-plugin.js.map +1 -1
  10. package/dist/business-rule-plugin.js +1 -0
  11. package/dist/business-rule-plugin.js.map +1 -1
  12. package/dist/call-expression-plugin.js +1 -107
  13. package/dist/call-expression-plugin.js.map +1 -1
  14. package/dist/column/column-to-record.d.ts +10 -3
  15. package/dist/column/column-to-record.js +44 -7
  16. package/dist/column/column-to-record.js.map +1 -1
  17. package/dist/column-plugin.d.ts +3 -1
  18. package/dist/column-plugin.js +12 -12
  19. package/dist/column-plugin.js.map +1 -1
  20. package/dist/dashboard/dashboard-component-property-defaults.d.ts +152 -0
  21. package/dist/dashboard/dashboard-component-property-defaults.js +264 -0
  22. package/dist/dashboard/dashboard-component-property-defaults.js.map +1 -0
  23. package/dist/dashboard/dashboard-component-resolver.d.ts +13 -0
  24. package/dist/dashboard/dashboard-component-resolver.js +69 -0
  25. package/dist/dashboard/dashboard-component-resolver.js.map +1 -0
  26. package/dist/dashboard/dashboard-plugin.d.ts +12 -0
  27. package/dist/dashboard/dashboard-plugin.js +397 -0
  28. package/dist/dashboard/dashboard-plugin.js.map +1 -0
  29. package/dist/data-plugin.d.ts +3 -0
  30. package/dist/data-plugin.js +61 -113
  31. package/dist/data-plugin.js.map +1 -1
  32. package/dist/email-notification-plugin.d.ts +2 -0
  33. package/dist/email-notification-plugin.js +541 -0
  34. package/dist/email-notification-plugin.js.map +1 -0
  35. package/dist/flow/constants/flow-plugin-constants.d.ts +58 -0
  36. package/dist/flow/constants/flow-plugin-constants.js +70 -0
  37. package/dist/flow/constants/flow-plugin-constants.js.map +1 -0
  38. package/dist/flow/flow-logic/flow-logic-constants.d.ts +38 -0
  39. package/dist/flow/flow-logic/flow-logic-constants.js +118 -0
  40. package/dist/flow/flow-logic/flow-logic-constants.js.map +1 -0
  41. package/dist/flow/flow-logic/flow-logic-diagnostics.d.ts +19 -0
  42. package/dist/flow/flow-logic/flow-logic-diagnostics.js +503 -0
  43. package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -0
  44. package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +62 -0
  45. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +2092 -0
  46. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -0
  47. package/dist/flow/flow-logic/flow-logic-plugin.d.ts +52 -0
  48. package/dist/flow/flow-logic/flow-logic-plugin.js +283 -0
  49. package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -0
  50. package/dist/flow/flow-logic/flow-logic-shapes.d.ts +104 -0
  51. package/dist/flow/flow-logic/flow-logic-shapes.js +201 -0
  52. package/dist/flow/flow-logic/flow-logic-shapes.js.map +1 -0
  53. package/dist/flow/plugins/approval-rules-plugin.d.ts +2 -0
  54. package/dist/flow/plugins/approval-rules-plugin.js +49 -0
  55. package/dist/flow/plugins/approval-rules-plugin.js.map +1 -0
  56. package/dist/flow/plugins/flow-action-definition-plugin.d.ts +2 -0
  57. package/dist/flow/plugins/flow-action-definition-plugin.js +286 -0
  58. package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -0
  59. package/dist/flow/plugins/flow-data-pill-plugin.d.ts +9 -0
  60. package/dist/flow/plugins/flow-data-pill-plugin.js +212 -0
  61. package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -0
  62. package/dist/flow/plugins/flow-definition-plugin.d.ts +2 -0
  63. package/dist/flow/plugins/flow-definition-plugin.js +1668 -0
  64. package/dist/flow/plugins/flow-definition-plugin.js.map +1 -0
  65. package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +26 -0
  66. package/dist/flow/plugins/flow-diagnostics-plugin.js +217 -0
  67. package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -0
  68. package/dist/flow/plugins/flow-instance-plugin.d.ts +12 -0
  69. package/dist/flow/plugins/flow-instance-plugin.js +1205 -0
  70. package/dist/flow/plugins/flow-instance-plugin.js.map +1 -0
  71. package/dist/flow/plugins/flow-trigger-instance-plugin.d.ts +2 -0
  72. package/dist/flow/plugins/flow-trigger-instance-plugin.js +338 -0
  73. package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -0
  74. package/dist/flow/plugins/inline-script-plugin.d.ts +39 -0
  75. package/dist/flow/plugins/inline-script-plugin.js +80 -0
  76. package/dist/flow/plugins/inline-script-plugin.js.map +1 -0
  77. package/dist/flow/plugins/step-definition-plugin.d.ts +5 -0
  78. package/dist/flow/plugins/step-definition-plugin.js +71 -0
  79. package/dist/flow/plugins/step-definition-plugin.js.map +1 -0
  80. package/dist/flow/plugins/step-instance-plugin.d.ts +31 -0
  81. package/dist/flow/plugins/step-instance-plugin.js +339 -0
  82. package/dist/flow/plugins/step-instance-plugin.js.map +1 -0
  83. package/dist/flow/plugins/trigger-plugin.d.ts +2 -0
  84. package/dist/flow/plugins/trigger-plugin.js +96 -0
  85. package/dist/flow/plugins/trigger-plugin.js.map +1 -0
  86. package/dist/flow/plugins/wfa-datapill-plugin.d.ts +15 -0
  87. package/dist/flow/plugins/wfa-datapill-plugin.js +178 -0
  88. package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -0
  89. package/dist/flow/utils/approval-rules-processor.d.ts +13 -0
  90. package/dist/flow/utils/approval-rules-processor.js +267 -0
  91. package/dist/flow/utils/approval-rules-processor.js.map +1 -0
  92. package/dist/flow/utils/built-in-complex-objects.d.ts +19 -0
  93. package/dist/flow/utils/built-in-complex-objects.js +62 -0
  94. package/dist/flow/utils/built-in-complex-objects.js.map +1 -0
  95. package/dist/flow/utils/complex-object-resolver.d.ts +8 -0
  96. package/dist/flow/utils/complex-object-resolver.js +614 -0
  97. package/dist/flow/utils/complex-object-resolver.js.map +1 -0
  98. package/dist/flow/utils/complex-objects.d.ts +36 -0
  99. package/dist/flow/utils/complex-objects.js +481 -0
  100. package/dist/flow/utils/complex-objects.js.map +1 -0
  101. package/dist/flow/utils/data-pill-shapes.d.ts +58 -0
  102. package/dist/flow/utils/data-pill-shapes.js +135 -0
  103. package/dist/flow/utils/data-pill-shapes.js.map +1 -0
  104. package/dist/flow/utils/datapill-transformer.d.ts +110 -0
  105. package/dist/flow/utils/datapill-transformer.js +503 -0
  106. package/dist/flow/utils/datapill-transformer.js.map +1 -0
  107. package/dist/flow/utils/flow-constants.d.ts +72 -0
  108. package/dist/flow/utils/flow-constants.js +230 -0
  109. package/dist/flow/utils/flow-constants.js.map +1 -0
  110. package/dist/flow/utils/flow-io-to-record.d.ts +44 -0
  111. package/dist/flow/utils/flow-io-to-record.js +409 -0
  112. package/dist/flow/utils/flow-io-to-record.js.map +1 -0
  113. package/dist/flow/utils/flow-shapes.d.ts +161 -0
  114. package/dist/flow/utils/flow-shapes.js +255 -0
  115. package/dist/flow/utils/flow-shapes.js.map +1 -0
  116. package/dist/flow/utils/flow-to-xml.d.ts +16 -0
  117. package/dist/flow/utils/flow-to-xml.js +237 -0
  118. package/dist/flow/utils/flow-to-xml.js.map +1 -0
  119. package/dist/flow/utils/flow-variable-processor.d.ts +51 -0
  120. package/dist/flow/utils/flow-variable-processor.js +69 -0
  121. package/dist/flow/utils/flow-variable-processor.js.map +1 -0
  122. package/dist/flow/utils/label-cache-parser.d.ts +7 -0
  123. package/dist/flow/utils/label-cache-parser.js +24 -0
  124. package/dist/flow/utils/label-cache-parser.js.map +1 -0
  125. package/dist/flow/utils/label-cache-processor.d.ts +119 -0
  126. package/dist/flow/utils/label-cache-processor.js +719 -0
  127. package/dist/flow/utils/label-cache-processor.js.map +1 -0
  128. package/dist/flow/utils/pill-string-parser.d.ts +88 -0
  129. package/dist/flow/utils/pill-string-parser.js +306 -0
  130. package/dist/flow/utils/pill-string-parser.js.map +1 -0
  131. package/dist/flow/utils/schema-to-flow-object.d.ts +22 -0
  132. package/dist/flow/utils/schema-to-flow-object.js +318 -0
  133. package/dist/flow/utils/schema-to-flow-object.js.map +1 -0
  134. package/dist/flow/utils/service-catalog.d.ts +47 -0
  135. package/dist/flow/utils/service-catalog.js +137 -0
  136. package/dist/flow/utils/service-catalog.js.map +1 -0
  137. package/dist/flow/utils/utils.d.ts +117 -0
  138. package/dist/flow/utils/utils.js +345 -0
  139. package/dist/flow/utils/utils.js.map +1 -0
  140. package/dist/index.d.ts +20 -1
  141. package/dist/index.js +21 -1
  142. package/dist/index.js.map +1 -1
  143. package/dist/list-plugin.js +1 -1
  144. package/dist/list-plugin.js.map +1 -1
  145. package/dist/now-attach-plugin.d.ts +1 -0
  146. package/dist/now-attach-plugin.js +10 -10
  147. package/dist/now-attach-plugin.js.map +1 -1
  148. package/dist/now-ref-plugin.js +1 -1
  149. package/dist/now-ref-plugin.js.map +1 -1
  150. package/dist/record-plugin.d.ts +29 -0
  151. package/dist/record-plugin.js +66 -7
  152. package/dist/record-plugin.js.map +1 -1
  153. package/dist/repack/index.d.ts +2 -0
  154. package/dist/repack/index.js +8 -0
  155. package/dist/repack/index.js.map +1 -1
  156. package/dist/rest-api-plugin.js +54 -44
  157. package/dist/rest-api-plugin.js.map +1 -1
  158. package/dist/server-module-plugin/index.d.ts +10 -0
  159. package/dist/server-module-plugin/index.js +83 -59
  160. package/dist/server-module-plugin/index.js.map +1 -1
  161. package/dist/service-catalog/catalog-clientscript-plugin.d.ts +2 -0
  162. package/dist/service-catalog/catalog-clientscript-plugin.js +117 -0
  163. package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -0
  164. package/dist/service-catalog/catalog-item-plugin.d.ts +2 -0
  165. package/dist/service-catalog/catalog-item-plugin.js +115 -0
  166. package/dist/service-catalog/catalog-item-plugin.js.map +1 -0
  167. package/dist/service-catalog/catalog-ui-policy-plugin.d.ts +2 -0
  168. package/dist/service-catalog/catalog-ui-policy-plugin.js +266 -0
  169. package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -0
  170. package/dist/service-catalog/index.d.ts +5 -0
  171. package/dist/service-catalog/index.js +22 -0
  172. package/dist/service-catalog/index.js.map +1 -0
  173. package/dist/service-catalog/record-to-shape.d.ts +6 -0
  174. package/dist/service-catalog/record-to-shape.js +93 -0
  175. package/dist/service-catalog/record-to-shape.js.map +1 -0
  176. package/dist/service-catalog/sc-record-producer-plugin.d.ts +2 -0
  177. package/dist/service-catalog/sc-record-producer-plugin.js +140 -0
  178. package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -0
  179. package/dist/service-catalog/service-catalog-base.d.ts +311 -0
  180. package/dist/service-catalog/service-catalog-base.js +542 -0
  181. package/dist/service-catalog/service-catalog-base.js.map +1 -0
  182. package/dist/service-catalog/service-catalog-diagnostics.d.ts +45 -0
  183. package/dist/service-catalog/service-catalog-diagnostics.js +172 -0
  184. package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -0
  185. package/dist/service-catalog/shape-to-record.d.ts +8 -0
  186. package/dist/service-catalog/shape-to-record.js +235 -0
  187. package/dist/service-catalog/shape-to-record.js.map +1 -0
  188. package/dist/service-catalog/utils.d.ts +323 -0
  189. package/dist/service-catalog/utils.js +1216 -0
  190. package/dist/service-catalog/utils.js.map +1 -0
  191. package/dist/service-catalog/variable-helper.d.ts +43 -0
  192. package/dist/service-catalog/variable-helper.js +92 -0
  193. package/dist/service-catalog/variable-helper.js.map +1 -0
  194. package/dist/service-catalog/variable-set-plugin.d.ts +2 -0
  195. package/dist/service-catalog/variable-set-plugin.js +175 -0
  196. package/dist/service-catalog/variable-set-plugin.js.map +1 -0
  197. package/dist/service-catalog/variables-transform.d.ts +139 -0
  198. package/dist/service-catalog/variables-transform.js +403 -0
  199. package/dist/service-catalog/variables-transform.js.map +1 -0
  200. package/dist/sla/sla-validators.d.ts +61 -0
  201. package/dist/sla/sla-validators.js +224 -0
  202. package/dist/sla/sla-validators.js.map +1 -0
  203. package/dist/sla-plugin.d.ts +5 -0
  204. package/dist/sla-plugin.js +280 -0
  205. package/dist/sla-plugin.js.map +1 -0
  206. package/dist/static-content-plugin.js +25 -2
  207. package/dist/static-content-plugin.js.map +1 -1
  208. package/dist/table-plugin.js +32 -15
  209. package/dist/table-plugin.js.map +1 -1
  210. package/dist/ui-page-plugin.js +832 -19
  211. package/dist/ui-page-plugin.js.map +1 -1
  212. package/dist/ui-policy-plugin.js +5 -7
  213. package/dist/ui-policy-plugin.js.map +1 -1
  214. package/dist/utils.d.ts +10 -1
  215. package/dist/utils.js +16 -0
  216. package/dist/utils.js.map +1 -1
  217. package/dist/ux-list-menu-config-plugin.d.ts +2 -0
  218. package/dist/ux-list-menu-config-plugin.js +292 -0
  219. package/dist/ux-list-menu-config-plugin.js.map +1 -0
  220. package/dist/workspace-plugin/chrome-tab.d.ts +2 -0
  221. package/dist/workspace-plugin/chrome-tab.js +46 -0
  222. package/dist/workspace-plugin/chrome-tab.js.map +1 -0
  223. package/dist/workspace-plugin/constants.d.ts +52 -0
  224. package/dist/workspace-plugin/constants.js +56 -0
  225. package/dist/workspace-plugin/constants.js.map +1 -0
  226. package/dist/workspace-plugin/fluent-utils.d.ts +9 -0
  227. package/dist/workspace-plugin/fluent-utils.js +60 -0
  228. package/dist/workspace-plugin/fluent-utils.js.map +1 -0
  229. package/dist/workspace-plugin/page.d.ts +8 -0
  230. package/dist/workspace-plugin/page.js +108 -0
  231. package/dist/workspace-plugin/page.js.map +1 -0
  232. package/dist/workspace-plugin/screen.d.ts +1 -0
  233. package/dist/workspace-plugin/screen.js +38 -0
  234. package/dist/workspace-plugin/screen.js.map +1 -0
  235. package/dist/workspace-plugin/templates/index.d.ts +10 -0
  236. package/dist/workspace-plugin/templates/index.js +20 -0
  237. package/dist/workspace-plugin/templates/index.js.map +1 -0
  238. package/dist/workspace-plugin/templates/record-page-composition.d.ts +1 -0
  239. package/dist/workspace-plugin/templates/record-page-composition.js +4043 -0
  240. package/dist/workspace-plugin/templates/record-page-composition.js.map +1 -0
  241. package/dist/workspace-plugin/templates/record-page-data.d.ts +1 -0
  242. package/dist/workspace-plugin/templates/record-page-data.js +527 -0
  243. package/dist/workspace-plugin/templates/record-page-data.js.map +1 -0
  244. package/dist/workspace-plugin/templates/record-page-interalEventMappings.d.ts +1 -0
  245. package/dist/workspace-plugin/templates/record-page-interalEventMappings.js +39 -0
  246. package/dist/workspace-plugin/templates/record-page-interalEventMappings.js.map +1 -0
  247. package/dist/workspace-plugin/templates/record-page-layoutModel.d.ts +1 -0
  248. package/dist/workspace-plugin/templates/record-page-layoutModel.js +55 -0
  249. package/dist/workspace-plugin/templates/record-page-layoutModel.js.map +1 -0
  250. package/dist/workspace-plugin/templates/record-page-properties.d.ts +1 -0
  251. package/dist/workspace-plugin/templates/record-page-properties.js +135 -0
  252. package/dist/workspace-plugin/templates/record-page-properties.js.map +1 -0
  253. package/dist/workspace-plugin/templates/record-page.d.ts +3 -0
  254. package/dist/workspace-plugin/templates/record-page.js +8 -0
  255. package/dist/workspace-plugin/templates/record-page.js.map +1 -0
  256. package/dist/workspace-plugin.d.ts +2 -0
  257. package/dist/workspace-plugin.js +453 -0
  258. package/dist/workspace-plugin.js.map +1 -0
  259. package/package.json +10 -12
  260. package/src/acl-plugin.ts +16 -1
  261. package/src/applicability-plugin.ts +82 -0
  262. package/src/atf/test-plugin.ts +6 -3
  263. package/src/basic-syntax-plugin.ts +10 -1
  264. package/src/business-rule-plugin.ts +2 -1
  265. package/src/call-expression-plugin.ts +2 -130
  266. package/src/column/column-to-record.ts +54 -8
  267. package/src/column-plugin.ts +29 -13
  268. package/src/dashboard/dashboard-component-property-defaults.ts +277 -0
  269. package/src/dashboard/dashboard-component-resolver.ts +69 -0
  270. package/src/dashboard/dashboard-plugin.ts +450 -0
  271. package/src/data-plugin.ts +67 -139
  272. package/src/email-notification-plugin.ts +850 -0
  273. package/src/flow/constants/flow-plugin-constants.ts +79 -0
  274. package/src/flow/flow-logic/flow-logic-constants.ts +120 -0
  275. package/src/flow/flow-logic/flow-logic-diagnostics.ts +591 -0
  276. package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +2550 -0
  277. package/src/flow/flow-logic/flow-logic-plugin.ts +337 -0
  278. package/src/flow/flow-logic/flow-logic-shapes.ts +215 -0
  279. package/src/flow/plugins/approval-rules-plugin.ts +48 -0
  280. package/src/flow/plugins/flow-action-definition-plugin.ts +295 -0
  281. package/src/flow/plugins/flow-data-pill-plugin.ts +258 -0
  282. package/src/flow/plugins/flow-definition-plugin.ts +2173 -0
  283. package/src/flow/plugins/flow-diagnostics-plugin.ts +280 -0
  284. package/src/flow/plugins/flow-instance-plugin.ts +1499 -0
  285. package/src/flow/plugins/flow-trigger-instance-plugin.ts +444 -0
  286. package/src/flow/plugins/inline-script-plugin.ts +83 -0
  287. package/src/flow/plugins/step-definition-plugin.ts +67 -0
  288. package/src/flow/plugins/step-instance-plugin.ts +431 -0
  289. package/src/flow/plugins/trigger-plugin.ts +95 -0
  290. package/src/flow/plugins/wfa-datapill-plugin.ts +213 -0
  291. package/src/flow/utils/approval-rules-processor.ts +298 -0
  292. package/src/flow/utils/built-in-complex-objects.ts +81 -0
  293. package/src/flow/utils/complex-object-resolver.ts +875 -0
  294. package/src/flow/utils/complex-objects.ts +656 -0
  295. package/src/flow/utils/data-pill-shapes.ts +165 -0
  296. package/src/flow/utils/datapill-transformer.ts +632 -0
  297. package/src/flow/utils/flow-constants.ts +285 -0
  298. package/src/flow/utils/flow-io-to-record.ts +533 -0
  299. package/src/flow/utils/flow-shapes.ts +296 -0
  300. package/src/flow/utils/flow-to-xml.ts +318 -0
  301. package/src/flow/utils/flow-variable-processor.ts +100 -0
  302. package/src/flow/utils/label-cache-parser.ts +37 -0
  303. package/src/flow/utils/label-cache-processor.ts +870 -0
  304. package/src/flow/utils/pill-string-parser.ts +375 -0
  305. package/src/flow/utils/schema-to-flow-object.ts +385 -0
  306. package/src/flow/utils/service-catalog.ts +174 -0
  307. package/src/flow/utils/utils.ts +395 -0
  308. package/src/index.ts +20 -1
  309. package/src/list-plugin.ts +1 -1
  310. package/src/now-attach-plugin.ts +14 -11
  311. package/src/now-ref-plugin.ts +1 -1
  312. package/src/record-plugin.ts +76 -11
  313. package/src/repack/index.ts +14 -0
  314. package/src/rest-api-plugin.ts +62 -50
  315. package/src/server-module-plugin/index.ts +112 -86
  316. package/src/service-catalog/catalog-clientscript-plugin.ts +140 -0
  317. package/src/service-catalog/catalog-item-plugin.ts +162 -0
  318. package/src/service-catalog/catalog-ui-policy-plugin.ts +324 -0
  319. package/src/service-catalog/index.ts +5 -0
  320. package/src/service-catalog/record-to-shape.ts +109 -0
  321. package/src/service-catalog/sc-record-producer-plugin.ts +201 -0
  322. package/src/service-catalog/service-catalog-base.ts +600 -0
  323. package/src/service-catalog/service-catalog-diagnostics.ts +254 -0
  324. package/src/service-catalog/shape-to-record.ts +279 -0
  325. package/src/service-catalog/utils.ts +1455 -0
  326. package/src/service-catalog/variable-helper.ts +135 -0
  327. package/src/service-catalog/variable-set-plugin.ts +197 -0
  328. package/src/service-catalog/variables-transform.ts +438 -0
  329. package/src/sla/sla-validators.ts +331 -0
  330. package/src/sla-plugin.ts +358 -0
  331. package/src/static-content-plugin.ts +25 -2
  332. package/src/table-plugin.ts +49 -16
  333. package/src/ui-page-plugin.ts +1063 -20
  334. package/src/ui-policy-plugin.ts +5 -9
  335. package/src/utils.ts +24 -1
  336. package/src/ux-list-menu-config-plugin.ts +312 -0
  337. package/src/workspace-plugin/chrome-tab.ts +44 -0
  338. package/src/workspace-plugin/constants.ts +53 -0
  339. package/src/workspace-plugin/fluent-utils.ts +60 -0
  340. package/src/workspace-plugin/page.ts +139 -0
  341. package/src/workspace-plugin/screen.ts +34 -0
  342. package/src/workspace-plugin/templates/index.ts +17 -0
  343. package/src/workspace-plugin/templates/record-page-composition.ts +4051 -0
  344. package/src/workspace-plugin/templates/record-page-data.ts +523 -0
  345. package/src/workspace-plugin/templates/record-page-interalEventMappings.ts +35 -0
  346. package/src/workspace-plugin/templates/record-page-layoutModel.ts +51 -0
  347. package/src/workspace-plugin/templates/record-page-properties.ts +131 -0
  348. package/src/workspace-plugin/templates/record-page.ts +6 -0
  349. package/src/workspace-plugin.ts +574 -0
@@ -0,0 +1,719 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractTriggerInputs = extractTriggerInputs;
4
+ exports.extractTriggerOutputs = extractTriggerOutputs;
5
+ exports.createDefinitionMap = createDefinitionMap;
6
+ exports.extractLabelsFromComplexObject = extractLabelsFromComplexObject;
7
+ exports.extractForEachMetadata = extractForEachMetadata;
8
+ exports.updateForEachMetadata = updateForEachMetadata;
9
+ exports.extractDataPillsFromValuesArray = extractDataPillsFromValuesArray;
10
+ exports.resolveDataPillMetadata = resolveDataPillMetadata;
11
+ exports.extractLabelCache = extractLabelCache;
12
+ exports.buildDataPillAttributes = buildDataPillAttributes;
13
+ const schema_to_flow_object_1 = require("./schema-to-flow-object");
14
+ const sdk_build_core_1 = require("@servicenow/sdk-build-core");
15
+ const column_helper_1 = require("../../column/column-helper");
16
+ const flow_logic_constants_1 = require("../flow-logic/flow-logic-constants");
17
+ const pill_string_parser_1 = require("./pill-string-parser");
18
+ const complex_object_resolver_1 = require("./complex-object-resolver");
19
+ /**
20
+ * Label Cache and Data Pill Metadata Utilities
21
+ *
22
+ * This module contains all utilities for:
23
+ * - Processing label cache for flow definitions
24
+ * - Extracting data pill metadata from instances
25
+ * - Resolving labels from complex objects
26
+ * - Generating initial data pill metadata for instances
27
+ */
28
+ // ============================================================================
29
+ // Helper Functions
30
+ // ============================================================================
31
+ /**
32
+ * Maps trigger name prefixes (from data pill names) to their display labels
33
+ * This mapping is derived from the actual trigger definitions and their labels
34
+ */
35
+ /**
36
+ * Regex pattern to strip |dataType suffix from datapill expressions
37
+ * Matches: {{pillName|dataType}} and captures pillName to replace with {{pillName}}
38
+ */
39
+ const STRIP_DATATYPE_FROM_PILL_REGEX = /\{\{([^|}]+)\|[^}]+\}\}/g;
40
+ const TRIGGER_NAME_TO_LABEL_MAP = {
41
+ Created: 'Trigger - Record Created',
42
+ Updated: 'Trigger - Record Updated',
43
+ 'Created or Updated': 'Trigger - Record Created or Updated',
44
+ Daily: 'Trigger - Run Daily',
45
+ Monthly: 'Trigger - Run Monthly',
46
+ Repeat: 'Trigger - Run Repeat',
47
+ 'Run Once': 'Trigger - Run Once',
48
+ Weekly: 'Trigger - Run Weekly',
49
+ 'Inbound Email': 'Trigger - Inbound Email',
50
+ 'Service Catalog': 'Trigger - Service Catalog',
51
+ 'Knowledge Management': 'Trigger - Knowledge Management',
52
+ 'Remote Table Query': 'Trigger - Remote Table Query',
53
+ 'SLA Task': 'Trigger - SLA Task',
54
+ };
55
+ // ============================================================================
56
+ // Trigger Output and Input Extraction
57
+ // ============================================================================
58
+ /**
59
+ * Helper function to extract trigger inputs from trigger instance shape
60
+ * Returns a map of input name to value for use in label cache processing
61
+ */
62
+ function extractTriggerInputs(triggerInstanceShape) {
63
+ const triggerInputsMap = new Map();
64
+ if (!triggerInstanceShape) {
65
+ return triggerInputsMap;
66
+ }
67
+ // Extract trigger inputs from argument(2)
68
+ const triggerInputsObj = triggerInstanceShape.getArgument(2)?.as(sdk_build_core_1.ObjectShape);
69
+ if (triggerInputsObj) {
70
+ for (const [inputName, inputValue] of triggerInputsObj.entries()) {
71
+ if (!inputValue) {
72
+ continue;
73
+ }
74
+ // Extract the actual value from different shape types
75
+ const value = inputValue.getValue();
76
+ triggerInputsMap.set(inputName, value);
77
+ }
78
+ }
79
+ return triggerInputsMap;
80
+ }
81
+ /**
82
+ * Helper function to extract trigger output definitions from trigger instance shape
83
+ * Returns a map of output name to { label, type } for use in label cache processing
84
+ */
85
+ function extractTriggerOutputs(triggerInstanceShape) {
86
+ const triggerOutputShapeMap = new Map();
87
+ if (!triggerInstanceShape || triggerInstanceShape instanceof sdk_build_core_1.UndefinedShape) {
88
+ return triggerOutputShapeMap;
89
+ }
90
+ const triggerDefArg = triggerInstanceShape.getArgument(0);
91
+ if (!(triggerDefArg instanceof sdk_build_core_1.CallExpressionShape)) {
92
+ return triggerOutputShapeMap;
93
+ }
94
+ const triggerConfigArg = triggerDefArg.getArgument(0);
95
+ if (!(triggerConfigArg instanceof sdk_build_core_1.ObjectShape)) {
96
+ return triggerOutputShapeMap;
97
+ }
98
+ const outputsObj = triggerConfigArg.get('outputs');
99
+ if (!(outputsObj instanceof sdk_build_core_1.ObjectShape)) {
100
+ return triggerOutputShapeMap;
101
+ }
102
+ // Iterate through all output properties and extract column metadata
103
+ for (const [outputName, outputValue] of outputsObj.entries()) {
104
+ if (!outputValue) {
105
+ continue;
106
+ }
107
+ const outputDefCE = outputValue.as(sdk_build_core_1.CallExpressionShape);
108
+ const callee = outputDefCE.getCallee();
109
+ if (!callee) {
110
+ continue;
111
+ }
112
+ // Extract column type name (optimized: lastIndexOf instead of split)
113
+ const lastDotIndex = callee.lastIndexOf('.');
114
+ const columnApiName = lastDotIndex >= 0 ? callee.substring(lastDotIndex + 1) : callee;
115
+ // Map to internal type
116
+ const internalType = column_helper_1.COLUMN_API_TO_TYPE[columnApiName] || columnApiName;
117
+ if (!internalType) {
118
+ continue;
119
+ }
120
+ // Extract label from argument object
121
+ const outputDefArg = outputDefCE.getArgument(0);
122
+ const label = outputDefArg ? outputDefArg.as(sdk_build_core_1.ObjectShape).get('label')?.getValue() : undefined;
123
+ triggerOutputShapeMap.set(outputName, {
124
+ label: label ? String(label) : outputName,
125
+ type: internalType,
126
+ });
127
+ }
128
+ return triggerOutputShapeMap;
129
+ }
130
+ /**
131
+ * Creates a lookup map from records by element name.
132
+ * Used to build maps of flow variables, subflow inputs, etc.
133
+ *
134
+ * @param records - Array of records to filter and map
135
+ * @param tableName - Table name to filter by
136
+ * @returns Map of element names to records
137
+ */
138
+ function createDefinitionMap(records, tableName) {
139
+ const map = new Map();
140
+ records
141
+ .filter((rec) => rec.getTable() === tableName)
142
+ .forEach((record) => {
143
+ const element = record.get('element')?.asString()?.getValue();
144
+ if (element) {
145
+ map.set(element, record);
146
+ }
147
+ });
148
+ return map;
149
+ }
150
+ // ============================================================================
151
+ // Complex Object Label Extraction
152
+ // ============================================================================
153
+ /**
154
+ * Extracts labels from complex object schema and determines field types.
155
+ * Traverses nested complex object structures to build label paths.
156
+ */
157
+ function extractLabelsFromComplexObject(segments, coRecord, labelParts) {
158
+ const serializedContent = coRecord.get('serialized_content')?.ifString()?.getValue();
159
+ if (!serializedContent) {
160
+ return null;
161
+ }
162
+ const schema = JSON.parse(serializedContent);
163
+ const rootKey = Object.keys(schema).find((k) => k.startsWith('FlowDesigner:'));
164
+ if (!rootKey) {
165
+ return null;
166
+ }
167
+ let currentSchema = schema[rootKey];
168
+ let extractedType = null;
169
+ // If accessing root object itself (segments.length === 2), extract type from root .$type_facets
170
+ if (segments.length === 2) {
171
+ const rootTypeFacets = schema[`${rootKey}.$type_facets`]?.SimpleMapFacet;
172
+ if (rootTypeFacets) {
173
+ const rootFacetData = JSON.parse(rootTypeFacets);
174
+ if (rootFacetData.uiType) {
175
+ extractedType = rootFacetData.uiType;
176
+ }
177
+ }
178
+ return extractedType;
179
+ }
180
+ for (let i = 2; i < segments.length; i++) {
181
+ const fieldName = segments[i];
182
+ if (!fieldName) {
183
+ continue;
184
+ }
185
+ const facetKey = `${fieldName}.$field_facets`;
186
+ const facet = currentSchema[facetKey]?.SimpleMapFacet;
187
+ if (!facet) {
188
+ throw new Error(`Missing field facets for '${fieldName}' in complex object schema. ` +
189
+ `Path: ${segments.join('.')}. This indicates the schema is incomplete or the field doesn't exist.`);
190
+ }
191
+ const facetData = JSON.parse(facet);
192
+ labelParts.push(facetData.label || fieldName);
193
+ if (i === segments.length - 1 && facetData.uiType) {
194
+ extractedType = facetData.uiType;
195
+ }
196
+ if (currentSchema[fieldName] &&
197
+ typeof currentSchema[fieldName] === 'object' &&
198
+ !Array.isArray(currentSchema[fieldName])) {
199
+ currentSchema = currentSchema[fieldName];
200
+ }
201
+ }
202
+ return extractedType;
203
+ }
204
+ /**
205
+ * Parses a data pill string and extracts the prefix and path.
206
+ * Supports all data pill formats: {{prefix.path}}
207
+ *
208
+ * @param pillString - The data pill string (e.g., "{{flow_variable.varName}}", "{{trigger.current.sys_id}}")
209
+ * @returns Object with prefix and path, or null if not a valid pill
210
+ *
211
+ * @example
212
+ * parseDataPill("{{flow_variable.varName}}") // { prefix: 'flow_variable', path: 'varName' }
213
+ * parseDataPill("{{trigger.current.sys_id}}") // { prefix: 'trigger', path: 'current.sys_id' }
214
+ * parseDataPill("{{subflow.output}}") // { prefix: 'subflow', path: 'output' }
215
+ */
216
+ function parseDataPill(pillString) {
217
+ // Use the existing parseSinglePill utility from pill-string-parser
218
+ const parsed = (0, pill_string_parser_1.parseSinglePill)(pillString, false);
219
+ if (!parsed) {
220
+ return null;
221
+ }
222
+ return {
223
+ prefix: parsed.prefix,
224
+ path: parsed.path,
225
+ };
226
+ }
227
+ /**
228
+ * Extracts table name from a flow variable definition record.
229
+ * Handles both ReferenceColumn (reference_table) and FlowArray (childName) types.
230
+ *
231
+ * @param flowVar - The flow variable definition record
232
+ * @returns Table name or null if not found
233
+ */
234
+ function extractTableNameFromFlowVariable(flowVar) {
235
+ // Try to get table name from reference_table field (for simple reference columns)
236
+ const refTable = flowVar.get('reference_table')?.getValue();
237
+ if (refTable) {
238
+ return refTable;
239
+ }
240
+ // For FlowArray, extract child type from source shape
241
+ const sourceShape = flowVar.getSource();
242
+ if (sourceShape instanceof sdk_build_core_1.CallExpressionShape) {
243
+ const firstArg = sourceShape.getArgument(0);
244
+ if (firstArg instanceof sdk_build_core_1.ObjectShape) {
245
+ return firstArg.get('childName')?.getValue() || null;
246
+ }
247
+ }
248
+ return null;
249
+ }
250
+ /**
251
+ * Extracts forEach metadata from a flow logic instance record.
252
+ * This includes the step number and table name (if available) for forEach loops.
253
+ *
254
+ * @param rec - The flow logic instance record
255
+ * @param order - The step order number
256
+ * @param flowVarDefMap - Map of flow variable names to their definition records
257
+ * @returns Object with stepNumber and tableName
258
+ */
259
+ function extractForEachMetadata(rec, order, flowVarDefMap) {
260
+ const valuesJson = rec.get('values')?.getValue();
261
+ let tableName = null;
262
+ // Early return if no values or inputs array
263
+ if (!valuesJson ||
264
+ typeof valuesJson !== 'object' ||
265
+ !('inputs' in valuesJson) ||
266
+ !Array.isArray(valuesJson.inputs)) {
267
+ return { stepNumber: order, tableName };
268
+ }
269
+ // Find the 'items' input in the forEach values
270
+ const itemsInput = valuesJson.inputs.find((inp) => inp?.name === 'items');
271
+ if (!itemsInput?.value || typeof itemsInput.value !== 'string') {
272
+ return { stepNumber: order, tableName };
273
+ }
274
+ // Parse the data pill to extract prefix and path
275
+ const parsed = parseDataPill(itemsInput.value);
276
+ if (!parsed) {
277
+ return { stepNumber: order, tableName };
278
+ }
279
+ // Handle flow_variable pills specifically (can extract table name from flow variable definitions)
280
+ if (parsed.prefix === 'flow_variable') {
281
+ // TODO: Fix this: below parsed.path comes as "flow_variable|dataTypes".
282
+ const varName = parsed.path.split('|')[0] || '';
283
+ const flowVar = flowVarDefMap.get(varName);
284
+ if (flowVar) {
285
+ tableName = extractTableNameFromFlowVariable(flowVar);
286
+ }
287
+ }
288
+ return { stepNumber: order, tableName };
289
+ }
290
+ /**
291
+ * Updates the forEach metadata map if the record is a forEach instance.
292
+ * Extracts metadata (step number and table name) and adds it to the map.
293
+ *
294
+ * @param rec - The flow logic instance record to check
295
+ * @param order - The step order number
296
+ * @param flowVarDefMap - Map of flow variable names to their definition records
297
+ * @param forEachMetadataMap - Map containing forEach metadata
298
+ * @returns Updated forEachMetadataMap with new forEach metadata if found
299
+ */
300
+ function updateForEachMetadata(rec, order, flowVarDefMap, forEachMetadataMap) {
301
+ const logicDefId = rec.get('logic_definition')?.getValue();
302
+ if (logicDefId === flow_logic_constants_1.FLOW_LOGIC_SYS_ID_MAP[flow_logic_constants_1.FLOW_LOGIC.FOR_EACH]) {
303
+ const uiId = rec.get('ui_id')?.getValue();
304
+ if (uiId) {
305
+ const metadata = extractForEachMetadata(rec, order, flowVarDefMap);
306
+ if (metadata) {
307
+ forEachMetadataMap.set(uiId, metadata);
308
+ }
309
+ }
310
+ }
311
+ return forEachMetadataMap;
312
+ }
313
+ /**
314
+ * Helper function to extract data pills from a string value and update the label cache.
315
+ * Shared logic used by both extractDataPillsFromChildren and extractDataPillsFromValuesArray.
316
+ * @param value - The string value potentially containing data pills
317
+ * @param fieldName - The name of the field containing this value
318
+ * @param stepUuid - UUID of the step where these data pills are used
319
+ * @param labelCacheMap - Existing label cache map to update (modified in place)
320
+ */
321
+ function extractPillsFromValue(value, fieldName, stepUuid, labelCacheMap) {
322
+ if (typeof value !== 'string' || !value.includes('{{')) {
323
+ return;
324
+ }
325
+ const matches = value.matchAll(pill_string_parser_1.PILL_REGEX);
326
+ for (const match of matches) {
327
+ const pillString = match[0]; // e.g., "{{trigger.table_name|string}}" or "{{trigger.current.company|glide_list|meta:user_criteria:company:core_company}}"
328
+ const pillContent = pillString.slice(2, -2); // Remove {{ and }}
329
+ const parts = pillContent.split('|');
330
+ const dataPillName = parts[0];
331
+ const dataPillType = parts[1];
332
+ const metaPart = parts[2]; // e.g., "meta:user_criteria:company:core_company"
333
+ if (!dataPillName) {
334
+ continue;
335
+ }
336
+ // Parse metadata if present
337
+ let metadata;
338
+ if (metaPart && metaPart.startsWith('meta:')) {
339
+ const metaValues = metaPart.substring(5).split(':'); // Remove "meta:" prefix and split
340
+ const parentTableName = metaValues[0]?.trim() || undefined;
341
+ const columnName = metaValues[1]?.trim() || undefined;
342
+ const reference = metaValues[2]?.trim() || undefined;
343
+ // Only create metadata object if at least one field has a non-empty value
344
+ if (parentTableName || columnName || reference) {
345
+ metadata = {};
346
+ // Only add properties with actual non-empty values
347
+ if (parentTableName && parentTableName.length > 0) {
348
+ metadata.parentTableName = parentTableName;
349
+ }
350
+ if (columnName && columnName.length > 0) {
351
+ metadata.columnName = columnName;
352
+ }
353
+ if (reference && reference.length > 0) {
354
+ metadata.reference = reference;
355
+ }
356
+ }
357
+ }
358
+ updateLabelCacheForPill(dataPillName, dataPillType, stepUuid, fieldName, labelCacheMap, metadata);
359
+ }
360
+ }
361
+ /**
362
+ * Updates the label cache map with data pill usage information.
363
+ * Shared logic for tracking pill usage across different step instances.
364
+ * @param pillName - The data pill name (e.g., "trigger.table_name")
365
+ * @param pillType - The data pill type (e.g., "string")
366
+ * @param stepUuid - UUID of the step where this pill is used
367
+ * @param fieldName - The field name where this pill is used
368
+ * @param labelCacheMap - Existing label cache map to update (modified in place)
369
+ * @param metadata - Optional metadata containing parentTableName, columnName, and reference
370
+ */
371
+ function updateLabelCacheForPill(pillName, pillType, stepUuid, fieldName, labelCacheMap, metadata) {
372
+ if (labelCacheMap.has(pillName)) {
373
+ const existingPill = labelCacheMap.get(pillName);
374
+ // Update type if we have a better type (non-undefined) and existing is undefined
375
+ if (pillType && !existingPill.type) {
376
+ existingPill.type = pillType;
377
+ existingPill.base_type = pillType;
378
+ }
379
+ // Update usedInstances - add this step's UUID and field name
380
+ if (existingPill.usedInstances[stepUuid]) {
381
+ // Step UUID already exists, add field name if not already present
382
+ if (!existingPill.usedInstances[stepUuid].includes(fieldName)) {
383
+ existingPill.usedInstances[stepUuid].push(fieldName);
384
+ }
385
+ }
386
+ else {
387
+ // New step UUID, create new entry
388
+ existingPill.usedInstances[stepUuid] = [fieldName];
389
+ }
390
+ // Update metadata fields if provided and not already set
391
+ if (metadata) {
392
+ if (metadata.parentTableName && metadata.parentTableName.length > 0 && !existingPill.parent_table_name) {
393
+ existingPill.parent_table_name = metadata.parentTableName;
394
+ }
395
+ if (metadata.columnName && metadata.columnName.length > 0 && !existingPill.column_name) {
396
+ existingPill.column_name = metadata.columnName;
397
+ }
398
+ if (metadata.reference && metadata.reference.length > 0 && !existingPill.reference) {
399
+ existingPill.reference = metadata.reference;
400
+ }
401
+ }
402
+ }
403
+ else {
404
+ // New data pill, create entry
405
+ const pillEntry = {
406
+ name: pillName,
407
+ label: '', // Will be populated later by resolveDataPillMetadata
408
+ type: pillType,
409
+ base_type: pillType,
410
+ usedInstances: {
411
+ [stepUuid]: [fieldName],
412
+ },
413
+ attributes: {},
414
+ };
415
+ // Add metadata fields only if they have non-empty values
416
+ if (metadata) {
417
+ if (metadata.parentTableName && metadata.parentTableName.length > 0) {
418
+ pillEntry.parent_table_name = metadata.parentTableName;
419
+ }
420
+ if (metadata.columnName && metadata.columnName.length > 0) {
421
+ pillEntry.column_name = metadata.columnName;
422
+ }
423
+ if (metadata.reference && metadata.reference.length > 0) {
424
+ pillEntry.reference = metadata.reference;
425
+ }
426
+ }
427
+ labelCacheMap.set(pillName, pillEntry);
428
+ }
429
+ }
430
+ /**
431
+ * Recursively extracts data pills from children array (used for FlowObject fields)
432
+ * @param children - Array of child field objects
433
+ * @param stepUuid - UUID of the step where these data pills are used
434
+ * @param labelCacheMap - Existing label cache map to update (modified in place)
435
+ */
436
+ function extractDataPillsFromChildren(children, stepUuid, labelCacheMap) {
437
+ for (const child of children) {
438
+ if (!child) {
439
+ continue;
440
+ }
441
+ // Add type annotation to datapill strings based on parameter.type before extraction
442
+ // This ensures the label cache can extract and store the correct type
443
+ if ((0, complex_object_resolver_1.isDataPill)(child.value)) {
444
+ const paramType = child.parameter?.type;
445
+ if (paramType && paramType !== 'string' && paramType !== 'glide_date_time') {
446
+ // Add type annotation: {{path}} -> {{path|type}}
447
+ const pillContent = child.value.slice(2, -2); // Remove {{ and }}
448
+ // Check if it already has a type annotation
449
+ if (!pillContent.includes('|')) {
450
+ child.value = `{{${pillContent}|${paramType}}}`;
451
+ }
452
+ }
453
+ }
454
+ // Extract datapills from this child's value using shared logic
455
+ extractPillsFromValue(child.value, child.name, stepUuid, labelCacheMap);
456
+ // Strip |dataType from pills in-place
457
+ if (typeof child.value === 'string') {
458
+ child.value = child.value.replace(STRIP_DATATYPE_FROM_PILL_REGEX, '{{$1}}');
459
+ }
460
+ // Recursively process nested children (for nested FlowObjects)
461
+ if (child.children && Array.isArray(child.children) && child.children.length > 0) {
462
+ extractDataPillsFromChildren(child.children, stepUuid, labelCacheMap);
463
+ }
464
+ }
465
+ }
466
+ /**
467
+ * Extracts data pills from a values structure and tracks their usage.
468
+ * Data pills are in the format {{dataPillName}} within string values.
469
+ *
470
+ * Handles three different table types:
471
+ * - sys_hub_action_instance_v2: Array of objects with name/value pairs
472
+ * - sys_hub_flow_logic_instance_v2: Object with keys (inputs, outputsToAssign, etc.) containing arrays
473
+ * - sys_hub_sub_flow_instance_v2: Handled as needed
474
+ *
475
+ * @param valuesData - Values data (array or object depending on table type)
476
+ * @param stepUuid - UUID of the step where these data pills are used
477
+ * @param labelCacheMap - Existing label cache map to update (modified in place)
478
+ * @param tableName - The table name to determine data structure
479
+ * @returns Updated label cache map with data pill usage tracked
480
+ */
481
+ function extractDataPillsFromValuesArray(valuesData, stepUuid, labelCacheMap
482
+ // tableName?: string
483
+ ) {
484
+ if (!valuesData) {
485
+ return labelCacheMap;
486
+ }
487
+ // Handle sys_hub_action_instance_v2: Array of objects
488
+ if (Array.isArray(valuesData)) {
489
+ for (const input of valuesData) {
490
+ const inputName = input.name;
491
+ const inputValue = input.value;
492
+ // Handle children array for FlowObject fields with datapills
493
+ if (input.children && Array.isArray(input.children) && input.children.length > 0) {
494
+ // For FlowObjects with children, extract from children only (not parent value)
495
+ extractDataPillsFromChildren(input.children, stepUuid, labelCacheMap);
496
+ }
497
+ else {
498
+ // For regular fields without children, extract from the value using shared logic
499
+ extractPillsFromValue(inputValue, inputName, stepUuid, labelCacheMap);
500
+ }
501
+ // Strip |dataType from pills in-place
502
+ if (typeof input.value === 'string') {
503
+ input.value = input.value.replace(STRIP_DATATYPE_FROM_PILL_REGEX, '{{$1}}');
504
+ input.displayValue = input.displayValue.replace(STRIP_DATATYPE_FROM_PILL_REGEX, '{{$1}}');
505
+ }
506
+ }
507
+ }
508
+ // Handle sys_hub_flow_logic_instance_v2: Object with keys containing arrays
509
+ else if (typeof valuesData === 'object') {
510
+ // Iterate over all keys (inputs, outputsToAssign, variables, etc.)
511
+ for (const [key, arrayValue] of Object.entries(valuesData)) {
512
+ if (Array.isArray(arrayValue)) {
513
+ // Process each item in the array
514
+ for (const item of arrayValue) {
515
+ if (item && typeof item === 'object') {
516
+ const itemName = item.name || key;
517
+ const itemValue = item.value;
518
+ // Handle children array for FlowObject fields with datapills
519
+ if (item.children && Array.isArray(item.children) && item.children.length > 0) {
520
+ // For FlowObjects with children, extract from children only (not parent value)
521
+ extractDataPillsFromChildren(item.children, stepUuid, labelCacheMap);
522
+ }
523
+ else {
524
+ // For regular fields without children, extract from the value using shared logic
525
+ extractPillsFromValue(itemValue, itemName, stepUuid, labelCacheMap);
526
+ }
527
+ // Strip |dataType from pills in-place
528
+ if (typeof item.value === 'string') {
529
+ item.value = item.value.replace(STRIP_DATATYPE_FROM_PILL_REGEX, '{{$1}}');
530
+ item.displayValue = item.displayValue.replace(STRIP_DATATYPE_FROM_PILL_REGEX, '{{$1}}');
531
+ }
532
+ }
533
+ }
534
+ }
535
+ }
536
+ }
537
+ return labelCacheMap;
538
+ }
539
+ /**
540
+ * Resolves data pill metadata including label parts, variable definition, and type information.
541
+ * Handles flow variables, subflow inputs, trigger pills, and forEach item pills.
542
+ */
543
+ function resolveDataPillMetadata(segments, flowVarDefMap, subflowInputDefMap, relatedRecords, triggerData, forEachMetadataMap
544
+ // parentUiId?: string
545
+ ) {
546
+ const labelParts = [];
547
+ let varDef;
548
+ let extractedType = null;
549
+ const [prefix, varName] = segments;
550
+ const getLabel = (record) => record?.get('label')?.ifString()?.asString()?.getValue();
551
+ // Handle forEach item pills (format: "uuid.item.fieldName" or "uuid.item")
552
+ // Check if prefix is a UUID (forEach instance ui_id)
553
+ if (prefix && (0, pill_string_parser_1.isUuidPrefix)(prefix) && varName === 'item' && forEachMetadataMap) {
554
+ const forEachMetadata = forEachMetadataMap.get(prefix);
555
+ if (forEachMetadata) {
556
+ // Build label: "2 - For Each➛Problem Record➛Number"
557
+ labelParts.push(`${forEachMetadata.stepNumber} - For Each - `);
558
+ // Add table name or generic "Record"
559
+ if (forEachMetadata.tableName) {
560
+ labelParts.push(`${forEachMetadata.tableName} Record`);
561
+ }
562
+ else {
563
+ labelParts.push('item');
564
+ }
565
+ // Add remaining field segments with capitalized names
566
+ if (segments.length > 2) {
567
+ const fieldSegments = segments.slice(2).map((segment) => segment
568
+ .split('_')
569
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
570
+ .join(' '));
571
+ labelParts.push(...fieldSegments);
572
+ }
573
+ }
574
+ }
575
+ // Handle trigger data pills (format: "Created_1.table_name" or "Inbound Email_1.body_text")
576
+ else if (prefix?.endsWith('_1') && varName && triggerData) {
577
+ const triggerOutput = triggerData.outputs.get(varName);
578
+ const triggerName = prefix.slice(0, -2); // Remove "_1" suffix
579
+ const firstLabelPart = TRIGGER_NAME_TO_LABEL_MAP[triggerName] || `Trigger - ${triggerName}`;
580
+ labelParts.push(firstLabelPart);
581
+ const tableName = triggerData.inputs.get('table');
582
+ if (varName === 'current') {
583
+ labelParts.push(`${tableName} Record`);
584
+ const formattedSegments = segments.slice(2).map((segment) => segment
585
+ .split('_')
586
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
587
+ .join(' '));
588
+ labelParts.push(...formattedSegments);
589
+ }
590
+ else if (triggerOutput) {
591
+ // Map trigger name to its display label, or construct default if not in map
592
+ labelParts.push(varName === 'table_name' && tableName ? `${tableName} Table` : triggerOutput.label);
593
+ extractedType = triggerOutput.type;
594
+ }
595
+ }
596
+ else if (prefix === 'flow_variable' && varName) {
597
+ varDef = flowVarDefMap.get(varName);
598
+ labelParts.push('Flow Variables');
599
+ const defLabel = getLabel(varDef);
600
+ if (defLabel) {
601
+ labelParts.push(defLabel);
602
+ }
603
+ if (varDef) {
604
+ const attributesStr = varDef.get('attributes')?.ifString()?.getValue() ?? '';
605
+ // const attributes = parseAttributesToObject(attributesStr)
606
+ const coTypeName = (0, schema_to_flow_object_1.getAttributeValue)(attributesStr, 'co_type_name');
607
+ if (coTypeName) {
608
+ const coRecord = relatedRecords.find((rec) => rec.getTable() === 'sys_complex_object' &&
609
+ rec.get('name')?.asString()?.getValue() === coTypeName);
610
+ if (coRecord) {
611
+ extractedType = extractLabelsFromComplexObject(segments, coRecord, labelParts);
612
+ }
613
+ }
614
+ }
615
+ }
616
+ else if (prefix === 'subflow' && varName) {
617
+ varDef = subflowInputDefMap.get(varName);
618
+ labelParts.push('Input');
619
+ const defLabel = getLabel(varDef);
620
+ if (defLabel) {
621
+ labelParts.push(defLabel);
622
+ }
623
+ if (varDef) {
624
+ const attributesStr = varDef.get('attributes')?.ifString()?.getValue() ?? '';
625
+ const attributes = (0, schema_to_flow_object_1.parseAttributesToObject)(attributesStr);
626
+ const coTypeName = attributes.co_type_name;
627
+ if (coTypeName) {
628
+ const coRecord = relatedRecords.find((rec) => rec.getTable() === 'sys_complex_object' &&
629
+ rec.get('name')?.asString()?.getValue() === coTypeName);
630
+ if (coRecord) {
631
+ extractedType = extractLabelsFromComplexObject(segments, coRecord, labelParts);
632
+ }
633
+ }
634
+ }
635
+ }
636
+ else {
637
+ // Handle other data pill types (trigger, inputs, outputs, etc.)
638
+ // Add all path segments which will be joined with ➛ in processDataPill
639
+ labelParts.push(...segments);
640
+ }
641
+ return { labelParts, varDef, extractedType };
642
+ }
643
+ /**
644
+ * Processes a single data pill and enriches it with label, type, and reference metadata
645
+ */
646
+ function processDataPill(varMeta, flowVarDefMap, subflowInputDefMap, relatedRecords, triggerData, forEachMetadataMap) {
647
+ const varKey = varMeta.name;
648
+ // Now the datapill structure is {{datapill.path|datatype}}, hence we need to split below
649
+ const segments = varKey.split('.');
650
+ const { labelParts, varDef, extractedType } = resolveDataPillMetadata(segments, flowVarDefMap, subflowInputDefMap, relatedRecords, triggerData, forEachMetadataMap);
651
+ if (labelParts.length > 0) {
652
+ varMeta.label = labelParts.join('➛');
653
+ }
654
+ if (extractedType) {
655
+ varMeta.type = extractedType;
656
+ varMeta.base_type = extractedType;
657
+ }
658
+ // Note: parent_table_name, column_name, and reference are already set
659
+ // by updateLabelCacheForPill when parsing the pill string metadata
660
+ if (varDef && !varMeta.type) {
661
+ const internalType = varDef.get('internal_type')?.ifString()?.asString()?.getValue() || varMeta.column_type;
662
+ varMeta.type = internalType;
663
+ varMeta.base_type = internalType;
664
+ }
665
+ if (varDef) {
666
+ varMeta.reference_table = varDef.get('reference_table')?.ifString()?.asString()?.getValue() || null;
667
+ varMeta.reference_display = varDef.get('reference_display')?.ifString()?.asString()?.getValue() || null;
668
+ }
669
+ }
670
+ /**
671
+ * Extracts and aggregates label cache data from instance record attributes.
672
+ * Returns a new map with enriched data pill metadata.
673
+ */
674
+ function extractLabelCache(flowVarDefMap, subflowInputDefMap, relatedRecords, existingLabelCacheMap, triggerData, forEachMetadataMap) {
675
+ const labelCacheMap = new Map(existingLabelCacheMap);
676
+ for (const key of labelCacheMap.keys()) {
677
+ const varMeta = labelCacheMap.get(key);
678
+ if (!varMeta.label) {
679
+ processDataPill(varMeta, flowVarDefMap, subflowInputDefMap, relatedRecords, triggerData, forEachMetadataMap);
680
+ }
681
+ }
682
+ return labelCacheMap;
683
+ }
684
+ // ============================================================================
685
+ // Instance Data Pill Metadata Generation
686
+ // ============================================================================
687
+ /**
688
+ * Builds data pill metadata attributes for instance records.
689
+ * Used by action and subflow instances to track data pill usage.
690
+ *
691
+ * This metadata is stored in the instance's attributes field and later enriched in
692
+ * the flow definition's label_cache with proper labels, types, and references.
693
+ *
694
+ * @param dataPillMetadata - Map of data pill metadata collected during instance processing
695
+ * @param instanceUiId - The UUID of the instance
696
+ * @returns Array of data pill metadata attributes ready for instance record
697
+ */
698
+ function buildDataPillAttributes(dataPillMetadata, instanceUiId) {
699
+ const dataPillAttributes = [];
700
+ for (const [, pillInfo] of dataPillMetadata.entries()) {
701
+ dataPillAttributes.push({
702
+ name: pillInfo.dataPillPath,
703
+ label: '', // Will be enriched by processDataPill in extractLabelCacheFromAttributes
704
+ reference: null,
705
+ reference_display: null,
706
+ type: 'string',
707
+ base_type: 'string',
708
+ parent_table_name: null,
709
+ column_name: null,
710
+ choices: [],
711
+ usedInstances: {
712
+ [instanceUiId]: [pillInfo.inputFieldName],
713
+ },
714
+ attributes: {},
715
+ });
716
+ }
717
+ return dataPillAttributes;
718
+ }
719
+ //# sourceMappingURL=label-cache-processor.js.map