@servicenow/sdk-build-plugins 4.1.1 → 4.3.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 (388) hide show
  1. package/dist/acl-plugin.js +22 -4
  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/application-menu-plugin.js +1 -0
  7. package/dist/application-menu-plugin.js.map +1 -1
  8. package/dist/atf/step-configs.d.ts +13 -12
  9. package/dist/atf/step-configs.js.map +1 -1
  10. package/dist/atf/test-plugin.d.ts +1 -1
  11. package/dist/atf/test-plugin.js +13 -7
  12. package/dist/atf/test-plugin.js.map +1 -1
  13. package/dist/basic-syntax-plugin.js +58 -14
  14. package/dist/basic-syntax-plugin.js.map +1 -1
  15. package/dist/business-rule-plugin.js +1 -0
  16. package/dist/business-rule-plugin.js.map +1 -1
  17. package/dist/call-expression-plugin.js +1 -107
  18. package/dist/call-expression-plugin.js.map +1 -1
  19. package/dist/claims-plugin.js +1 -1
  20. package/dist/claims-plugin.js.map +1 -1
  21. package/dist/client-script-plugin.js +5 -17
  22. package/dist/client-script-plugin.js.map +1 -1
  23. package/dist/column/column-helper.d.ts +1 -1
  24. package/dist/column/column-helper.js +46 -2
  25. package/dist/column/column-helper.js.map +1 -1
  26. package/dist/column/column-to-record.js +6 -4
  27. package/dist/column/column-to-record.js.map +1 -1
  28. package/dist/column-plugin.js +107 -28
  29. package/dist/column-plugin.js.map +1 -1
  30. package/dist/dashboard/dashboard-component-property-defaults.d.ts +152 -0
  31. package/dist/dashboard/dashboard-component-property-defaults.js +264 -0
  32. package/dist/dashboard/dashboard-component-property-defaults.js.map +1 -0
  33. package/dist/dashboard/dashboard-component-resolver.d.ts +13 -0
  34. package/dist/dashboard/dashboard-component-resolver.js +69 -0
  35. package/dist/dashboard/dashboard-component-resolver.js.map +1 -0
  36. package/dist/dashboard/dashboard-plugin.d.ts +12 -0
  37. package/dist/dashboard/dashboard-plugin.js +397 -0
  38. package/dist/dashboard/dashboard-plugin.js.map +1 -0
  39. package/dist/data-plugin.d.ts +6 -0
  40. package/dist/data-plugin.js +156 -0
  41. package/dist/data-plugin.js.map +1 -0
  42. package/dist/email-notification-plugin.d.ts +2 -0
  43. package/dist/email-notification-plugin.js +541 -0
  44. package/dist/email-notification-plugin.js.map +1 -0
  45. package/dist/flow/constants/flow-plugin-constants.d.ts +58 -0
  46. package/dist/flow/constants/flow-plugin-constants.js +70 -0
  47. package/dist/flow/constants/flow-plugin-constants.js.map +1 -0
  48. package/dist/flow/flow-logic/flow-logic-constants.d.ts +38 -0
  49. package/dist/flow/flow-logic/flow-logic-constants.js +118 -0
  50. package/dist/flow/flow-logic/flow-logic-constants.js.map +1 -0
  51. package/dist/flow/flow-logic/flow-logic-diagnostics.d.ts +19 -0
  52. package/dist/flow/flow-logic/flow-logic-diagnostics.js +503 -0
  53. package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -0
  54. package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +62 -0
  55. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +2092 -0
  56. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -0
  57. package/dist/flow/flow-logic/flow-logic-plugin.d.ts +52 -0
  58. package/dist/flow/flow-logic/flow-logic-plugin.js +283 -0
  59. package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -0
  60. package/dist/flow/flow-logic/flow-logic-shapes.d.ts +104 -0
  61. package/dist/flow/flow-logic/flow-logic-shapes.js +201 -0
  62. package/dist/flow/flow-logic/flow-logic-shapes.js.map +1 -0
  63. package/dist/flow/plugins/approval-rules-plugin.d.ts +2 -0
  64. package/dist/flow/plugins/approval-rules-plugin.js +49 -0
  65. package/dist/flow/plugins/approval-rules-plugin.js.map +1 -0
  66. package/dist/flow/plugins/flow-action-definition-plugin.d.ts +2 -0
  67. package/dist/flow/plugins/flow-action-definition-plugin.js +286 -0
  68. package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -0
  69. package/dist/flow/plugins/flow-data-pill-plugin.d.ts +9 -0
  70. package/dist/flow/plugins/flow-data-pill-plugin.js +212 -0
  71. package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -0
  72. package/dist/flow/plugins/flow-definition-plugin.d.ts +2 -0
  73. package/dist/flow/plugins/flow-definition-plugin.js +1668 -0
  74. package/dist/flow/plugins/flow-definition-plugin.js.map +1 -0
  75. package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +26 -0
  76. package/dist/flow/plugins/flow-diagnostics-plugin.js +217 -0
  77. package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -0
  78. package/dist/flow/plugins/flow-instance-plugin.d.ts +12 -0
  79. package/dist/flow/plugins/flow-instance-plugin.js +930 -0
  80. package/dist/flow/plugins/flow-instance-plugin.js.map +1 -0
  81. package/dist/flow/plugins/flow-trigger-instance-plugin.d.ts +2 -0
  82. package/dist/flow/plugins/flow-trigger-instance-plugin.js +324 -0
  83. package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -0
  84. package/dist/flow/plugins/inline-script-plugin.d.ts +39 -0
  85. package/dist/flow/plugins/inline-script-plugin.js +80 -0
  86. package/dist/flow/plugins/inline-script-plugin.js.map +1 -0
  87. package/dist/flow/plugins/step-definition-plugin.d.ts +5 -0
  88. package/dist/flow/plugins/step-definition-plugin.js +71 -0
  89. package/dist/flow/plugins/step-definition-plugin.js.map +1 -0
  90. package/dist/flow/plugins/step-instance-plugin.d.ts +31 -0
  91. package/dist/flow/plugins/step-instance-plugin.js +339 -0
  92. package/dist/flow/plugins/step-instance-plugin.js.map +1 -0
  93. package/dist/flow/plugins/trigger-plugin.d.ts +2 -0
  94. package/dist/flow/plugins/trigger-plugin.js +96 -0
  95. package/dist/flow/plugins/trigger-plugin.js.map +1 -0
  96. package/dist/flow/plugins/wfa-datapill-plugin.d.ts +15 -0
  97. package/dist/flow/plugins/wfa-datapill-plugin.js +178 -0
  98. package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -0
  99. package/dist/flow/utils/approval-rules-processor.d.ts +13 -0
  100. package/dist/flow/utils/approval-rules-processor.js +267 -0
  101. package/dist/flow/utils/approval-rules-processor.js.map +1 -0
  102. package/dist/flow/utils/built-in-complex-objects.d.ts +19 -0
  103. package/dist/flow/utils/built-in-complex-objects.js +62 -0
  104. package/dist/flow/utils/built-in-complex-objects.js.map +1 -0
  105. package/dist/flow/utils/complex-object-resolver.d.ts +8 -0
  106. package/dist/flow/utils/complex-object-resolver.js +614 -0
  107. package/dist/flow/utils/complex-object-resolver.js.map +1 -0
  108. package/dist/flow/utils/complex-objects.d.ts +36 -0
  109. package/dist/flow/utils/complex-objects.js +481 -0
  110. package/dist/flow/utils/complex-objects.js.map +1 -0
  111. package/dist/flow/utils/data-pill-shapes.d.ts +58 -0
  112. package/dist/flow/utils/data-pill-shapes.js +135 -0
  113. package/dist/flow/utils/data-pill-shapes.js.map +1 -0
  114. package/dist/flow/utils/datapill-transformer.d.ts +110 -0
  115. package/dist/flow/utils/datapill-transformer.js +503 -0
  116. package/dist/flow/utils/datapill-transformer.js.map +1 -0
  117. package/dist/flow/utils/flow-constants.d.ts +65 -0
  118. package/dist/flow/utils/flow-constants.js +223 -0
  119. package/dist/flow/utils/flow-constants.js.map +1 -0
  120. package/dist/flow/utils/flow-io-to-record.d.ts +44 -0
  121. package/dist/flow/utils/flow-io-to-record.js +409 -0
  122. package/dist/flow/utils/flow-io-to-record.js.map +1 -0
  123. package/dist/flow/utils/flow-shapes.d.ts +161 -0
  124. package/dist/flow/utils/flow-shapes.js +255 -0
  125. package/dist/flow/utils/flow-shapes.js.map +1 -0
  126. package/dist/flow/utils/flow-to-xml.d.ts +16 -0
  127. package/dist/flow/utils/flow-to-xml.js +237 -0
  128. package/dist/flow/utils/flow-to-xml.js.map +1 -0
  129. package/dist/flow/utils/flow-variable-processor.d.ts +51 -0
  130. package/dist/flow/utils/flow-variable-processor.js +69 -0
  131. package/dist/flow/utils/flow-variable-processor.js.map +1 -0
  132. package/dist/flow/utils/label-cache-parser.d.ts +7 -0
  133. package/dist/flow/utils/label-cache-parser.js +24 -0
  134. package/dist/flow/utils/label-cache-parser.js.map +1 -0
  135. package/dist/flow/utils/label-cache-processor.d.ts +119 -0
  136. package/dist/flow/utils/label-cache-processor.js +719 -0
  137. package/dist/flow/utils/label-cache-processor.js.map +1 -0
  138. package/dist/flow/utils/pill-string-parser.d.ts +88 -0
  139. package/dist/flow/utils/pill-string-parser.js +306 -0
  140. package/dist/flow/utils/pill-string-parser.js.map +1 -0
  141. package/dist/flow/utils/schema-to-flow-object.d.ts +22 -0
  142. package/dist/flow/utils/schema-to-flow-object.js +318 -0
  143. package/dist/flow/utils/schema-to-flow-object.js.map +1 -0
  144. package/dist/flow/utils/utils.d.ts +117 -0
  145. package/dist/flow/utils/utils.js +345 -0
  146. package/dist/flow/utils/utils.js.map +1 -0
  147. package/dist/import-sets-plugin.d.ts +2 -0
  148. package/dist/import-sets-plugin.js +412 -0
  149. package/dist/import-sets-plugin.js.map +1 -0
  150. package/dist/index.d.ts +24 -1
  151. package/dist/index.js +25 -1
  152. package/dist/index.js.map +1 -1
  153. package/dist/json-plugin.d.ts +4 -4
  154. package/dist/json-plugin.js +21 -7
  155. package/dist/json-plugin.js.map +1 -1
  156. package/dist/list-plugin.js +83 -1
  157. package/dist/list-plugin.js.map +1 -1
  158. package/dist/now-attach-plugin.d.ts +36 -0
  159. package/dist/now-attach-plugin.js +320 -0
  160. package/dist/now-attach-plugin.js.map +1 -0
  161. package/dist/now-config-plugin.js +3 -0
  162. package/dist/now-config-plugin.js.map +1 -1
  163. package/dist/now-include-plugin.js +7 -1
  164. package/dist/now-include-plugin.js.map +1 -1
  165. package/dist/package-json-plugin.js +2 -2
  166. package/dist/package-json-plugin.js.map +1 -1
  167. package/dist/record-plugin.d.ts +35 -0
  168. package/dist/record-plugin.js +109 -23
  169. package/dist/record-plugin.js.map +1 -1
  170. package/dist/repack/index.d.ts +2 -0
  171. package/dist/repack/index.js +8 -0
  172. package/dist/repack/index.js.map +1 -1
  173. package/dist/repack/lint/Rules.js.map +1 -1
  174. package/dist/rest-api-plugin.js +81 -74
  175. package/dist/rest-api-plugin.js.map +1 -1
  176. package/dist/role-plugin.js +1 -0
  177. package/dist/role-plugin.js.map +1 -1
  178. package/dist/server-module-plugin/index.js +53 -6
  179. package/dist/server-module-plugin/index.js.map +1 -1
  180. package/dist/service-catalog/catalog-clientscript-plugin.d.ts +2 -0
  181. package/dist/service-catalog/catalog-clientscript-plugin.js +117 -0
  182. package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -0
  183. package/dist/service-catalog/catalog-item-plugin.d.ts +2 -0
  184. package/dist/service-catalog/catalog-item-plugin.js +115 -0
  185. package/dist/service-catalog/catalog-item-plugin.js.map +1 -0
  186. package/dist/service-catalog/catalog-ui-policy-plugin.d.ts +2 -0
  187. package/dist/service-catalog/catalog-ui-policy-plugin.js +266 -0
  188. package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -0
  189. package/dist/service-catalog/index.d.ts +5 -0
  190. package/dist/service-catalog/index.js +22 -0
  191. package/dist/service-catalog/index.js.map +1 -0
  192. package/dist/service-catalog/record-to-shape.d.ts +6 -0
  193. package/dist/service-catalog/record-to-shape.js +93 -0
  194. package/dist/service-catalog/record-to-shape.js.map +1 -0
  195. package/dist/service-catalog/sc-record-producer-plugin.d.ts +2 -0
  196. package/dist/service-catalog/sc-record-producer-plugin.js +139 -0
  197. package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -0
  198. package/dist/service-catalog/service-catalog-base.d.ts +311 -0
  199. package/dist/service-catalog/service-catalog-base.js +542 -0
  200. package/dist/service-catalog/service-catalog-base.js.map +1 -0
  201. package/dist/service-catalog/service-catalog-diagnostics.d.ts +45 -0
  202. package/dist/service-catalog/service-catalog-diagnostics.js +169 -0
  203. package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -0
  204. package/dist/service-catalog/shape-to-record.d.ts +7 -0
  205. package/dist/service-catalog/shape-to-record.js +232 -0
  206. package/dist/service-catalog/shape-to-record.js.map +1 -0
  207. package/dist/service-catalog/utils.d.ts +313 -0
  208. package/dist/service-catalog/utils.js +1144 -0
  209. package/dist/service-catalog/utils.js.map +1 -0
  210. package/dist/service-catalog/variable-helper.d.ts +43 -0
  211. package/dist/service-catalog/variable-helper.js +92 -0
  212. package/dist/service-catalog/variable-helper.js.map +1 -0
  213. package/dist/service-catalog/variable-set-plugin.d.ts +2 -0
  214. package/dist/service-catalog/variable-set-plugin.js +175 -0
  215. package/dist/service-catalog/variable-set-plugin.js.map +1 -0
  216. package/dist/service-catalog/variables-transform.d.ts +139 -0
  217. package/dist/service-catalog/variables-transform.js +403 -0
  218. package/dist/service-catalog/variables-transform.js.map +1 -0
  219. package/dist/service-portal/widget-plugin.js +4 -1
  220. package/dist/service-portal/widget-plugin.js.map +1 -1
  221. package/dist/sla/sla-validators.d.ts +61 -0
  222. package/dist/sla/sla-validators.js +224 -0
  223. package/dist/sla/sla-validators.js.map +1 -0
  224. package/dist/sla-plugin.d.ts +5 -0
  225. package/dist/sla-plugin.js +280 -0
  226. package/dist/sla-plugin.js.map +1 -0
  227. package/dist/static-content-plugin.d.ts +1 -0
  228. package/dist/static-content-plugin.js +4 -3
  229. package/dist/static-content-plugin.js.map +1 -1
  230. package/dist/table-plugin.js +49 -4
  231. package/dist/table-plugin.js.map +1 -1
  232. package/dist/ui-page-plugin.js +2 -1
  233. package/dist/ui-page-plugin.js.map +1 -1
  234. package/dist/ui-policy-plugin.d.ts +2 -0
  235. package/dist/ui-policy-plugin.js +405 -0
  236. package/dist/ui-policy-plugin.js.map +1 -0
  237. package/dist/utils.d.ts +19 -1
  238. package/dist/utils.js +40 -0
  239. package/dist/utils.js.map +1 -1
  240. package/dist/ux-list-menu-config-plugin.d.ts +2 -0
  241. package/dist/ux-list-menu-config-plugin.js +292 -0
  242. package/dist/ux-list-menu-config-plugin.js.map +1 -0
  243. package/dist/view-plugin.js +1 -1
  244. package/dist/view-plugin.js.map +1 -1
  245. package/dist/workspace-plugin/chrome-tab.d.ts +2 -0
  246. package/dist/workspace-plugin/chrome-tab.js +46 -0
  247. package/dist/workspace-plugin/chrome-tab.js.map +1 -0
  248. package/dist/workspace-plugin/constants.d.ts +52 -0
  249. package/dist/workspace-plugin/constants.js +56 -0
  250. package/dist/workspace-plugin/constants.js.map +1 -0
  251. package/dist/workspace-plugin/fluent-utils.d.ts +9 -0
  252. package/dist/workspace-plugin/fluent-utils.js +60 -0
  253. package/dist/workspace-plugin/fluent-utils.js.map +1 -0
  254. package/dist/workspace-plugin/page.d.ts +8 -0
  255. package/dist/workspace-plugin/page.js +108 -0
  256. package/dist/workspace-plugin/page.js.map +1 -0
  257. package/dist/workspace-plugin/screen.d.ts +1 -0
  258. package/dist/workspace-plugin/screen.js +38 -0
  259. package/dist/workspace-plugin/screen.js.map +1 -0
  260. package/dist/workspace-plugin/templates/index.d.ts +10 -0
  261. package/dist/workspace-plugin/templates/index.js +20 -0
  262. package/dist/workspace-plugin/templates/index.js.map +1 -0
  263. package/dist/workspace-plugin/templates/record-page-composition.d.ts +1 -0
  264. package/dist/workspace-plugin/templates/record-page-composition.js +4043 -0
  265. package/dist/workspace-plugin/templates/record-page-composition.js.map +1 -0
  266. package/dist/workspace-plugin/templates/record-page-data.d.ts +1 -0
  267. package/dist/workspace-plugin/templates/record-page-data.js +527 -0
  268. package/dist/workspace-plugin/templates/record-page-data.js.map +1 -0
  269. package/dist/workspace-plugin/templates/record-page-interalEventMappings.d.ts +1 -0
  270. package/dist/workspace-plugin/templates/record-page-interalEventMappings.js +39 -0
  271. package/dist/workspace-plugin/templates/record-page-interalEventMappings.js.map +1 -0
  272. package/dist/workspace-plugin/templates/record-page-layoutModel.d.ts +1 -0
  273. package/dist/workspace-plugin/templates/record-page-layoutModel.js +55 -0
  274. package/dist/workspace-plugin/templates/record-page-layoutModel.js.map +1 -0
  275. package/dist/workspace-plugin/templates/record-page-properties.d.ts +1 -0
  276. package/dist/workspace-plugin/templates/record-page-properties.js +135 -0
  277. package/dist/workspace-plugin/templates/record-page-properties.js.map +1 -0
  278. package/dist/workspace-plugin/templates/record-page.d.ts +3 -0
  279. package/dist/workspace-plugin/templates/record-page.js +8 -0
  280. package/dist/workspace-plugin/templates/record-page.js.map +1 -0
  281. package/dist/workspace-plugin.d.ts +2 -0
  282. package/dist/workspace-plugin.js +453 -0
  283. package/dist/workspace-plugin.js.map +1 -0
  284. package/package.json +10 -12
  285. package/src/_types/eslint-plugin-es-x.d.ts +17 -0
  286. package/src/_types/md5.js.d.ts +8 -0
  287. package/src/acl-plugin.ts +33 -10
  288. package/src/applicability-plugin.ts +82 -0
  289. package/src/application-menu-plugin.ts +1 -0
  290. package/src/atf/step-configs.ts +14 -12
  291. package/src/atf/test-plugin.ts +46 -24
  292. package/src/basic-syntax-plugin.ts +71 -14
  293. package/src/business-rule-plugin.ts +9 -5
  294. package/src/call-expression-plugin.ts +2 -130
  295. package/src/claims-plugin.ts +1 -1
  296. package/src/client-script-plugin.ts +8 -22
  297. package/src/column/column-helper.ts +65 -3
  298. package/src/column/column-to-record.ts +6 -4
  299. package/src/column-plugin.ts +142 -40
  300. package/src/dashboard/dashboard-component-property-defaults.ts +277 -0
  301. package/src/dashboard/dashboard-component-resolver.ts +69 -0
  302. package/src/dashboard/dashboard-plugin.ts +450 -0
  303. package/src/data-plugin.ts +194 -0
  304. package/src/email-notification-plugin.ts +850 -0
  305. package/src/flow/constants/flow-plugin-constants.ts +79 -0
  306. package/src/flow/flow-logic/flow-logic-constants.ts +120 -0
  307. package/src/flow/flow-logic/flow-logic-diagnostics.ts +591 -0
  308. package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +2550 -0
  309. package/src/flow/flow-logic/flow-logic-plugin.ts +337 -0
  310. package/src/flow/flow-logic/flow-logic-shapes.ts +215 -0
  311. package/src/flow/plugins/approval-rules-plugin.ts +48 -0
  312. package/src/flow/plugins/flow-action-definition-plugin.ts +295 -0
  313. package/src/flow/plugins/flow-data-pill-plugin.ts +258 -0
  314. package/src/flow/plugins/flow-definition-plugin.ts +2173 -0
  315. package/src/flow/plugins/flow-diagnostics-plugin.ts +280 -0
  316. package/src/flow/plugins/flow-instance-plugin.ts +1148 -0
  317. package/src/flow/plugins/flow-trigger-instance-plugin.ts +426 -0
  318. package/src/flow/plugins/inline-script-plugin.ts +83 -0
  319. package/src/flow/plugins/step-definition-plugin.ts +67 -0
  320. package/src/flow/plugins/step-instance-plugin.ts +431 -0
  321. package/src/flow/plugins/trigger-plugin.ts +95 -0
  322. package/src/flow/plugins/wfa-datapill-plugin.ts +213 -0
  323. package/src/flow/utils/approval-rules-processor.ts +298 -0
  324. package/src/flow/utils/built-in-complex-objects.ts +81 -0
  325. package/src/flow/utils/complex-object-resolver.ts +875 -0
  326. package/src/flow/utils/complex-objects.ts +656 -0
  327. package/src/flow/utils/data-pill-shapes.ts +165 -0
  328. package/src/flow/utils/datapill-transformer.ts +632 -0
  329. package/src/flow/utils/flow-constants.ts +276 -0
  330. package/src/flow/utils/flow-io-to-record.ts +533 -0
  331. package/src/flow/utils/flow-shapes.ts +296 -0
  332. package/src/flow/utils/flow-to-xml.ts +318 -0
  333. package/src/flow/utils/flow-variable-processor.ts +100 -0
  334. package/src/flow/utils/label-cache-parser.ts +37 -0
  335. package/src/flow/utils/label-cache-processor.ts +870 -0
  336. package/src/flow/utils/pill-string-parser.ts +375 -0
  337. package/src/flow/utils/schema-to-flow-object.ts +385 -0
  338. package/src/flow/utils/utils.ts +395 -0
  339. package/src/import-sets-plugin.ts +542 -0
  340. package/src/index.ts +25 -1
  341. package/src/json-plugin.ts +31 -12
  342. package/src/list-plugin.ts +91 -1
  343. package/src/now-attach-plugin.ts +403 -0
  344. package/src/now-config-plugin.ts +6 -2
  345. package/src/now-include-plugin.ts +8 -1
  346. package/src/package-json-plugin.ts +3 -3
  347. package/src/record-plugin.ts +126 -30
  348. package/src/repack/index.ts +14 -0
  349. package/src/repack/lint/Rules.ts +1 -10
  350. package/src/rest-api-plugin.ts +106 -100
  351. package/src/role-plugin.ts +1 -0
  352. package/src/server-module-plugin/index.ts +74 -22
  353. package/src/service-catalog/catalog-clientscript-plugin.ts +140 -0
  354. package/src/service-catalog/catalog-item-plugin.ts +162 -0
  355. package/src/service-catalog/catalog-ui-policy-plugin.ts +324 -0
  356. package/src/service-catalog/index.ts +5 -0
  357. package/src/service-catalog/record-to-shape.ts +109 -0
  358. package/src/service-catalog/sc-record-producer-plugin.ts +201 -0
  359. package/src/service-catalog/service-catalog-base.ts +600 -0
  360. package/src/service-catalog/service-catalog-diagnostics.ts +251 -0
  361. package/src/service-catalog/shape-to-record.ts +275 -0
  362. package/src/service-catalog/utils.ts +1362 -0
  363. package/src/service-catalog/variable-helper.ts +135 -0
  364. package/src/service-catalog/variable-set-plugin.ts +197 -0
  365. package/src/service-catalog/variables-transform.ts +438 -0
  366. package/src/service-portal/widget-plugin.ts +4 -1
  367. package/src/sla/sla-validators.ts +331 -0
  368. package/src/sla-plugin.ts +358 -0
  369. package/src/static-content-plugin.ts +2 -2
  370. package/src/table-plugin.ts +66 -9
  371. package/src/ui-page-plugin.ts +2 -1
  372. package/src/ui-policy-plugin.ts +505 -0
  373. package/src/utils.ts +50 -1
  374. package/src/ux-list-menu-config-plugin.ts +312 -0
  375. package/src/view-plugin.ts +1 -1
  376. package/src/workspace-plugin/chrome-tab.ts +44 -0
  377. package/src/workspace-plugin/constants.ts +53 -0
  378. package/src/workspace-plugin/fluent-utils.ts +60 -0
  379. package/src/workspace-plugin/page.ts +139 -0
  380. package/src/workspace-plugin/screen.ts +34 -0
  381. package/src/workspace-plugin/templates/index.ts +17 -0
  382. package/src/workspace-plugin/templates/record-page-composition.ts +4051 -0
  383. package/src/workspace-plugin/templates/record-page-data.ts +523 -0
  384. package/src/workspace-plugin/templates/record-page-interalEventMappings.ts +35 -0
  385. package/src/workspace-plugin/templates/record-page-layoutModel.ts +51 -0
  386. package/src/workspace-plugin/templates/record-page-properties.ts +131 -0
  387. package/src/workspace-plugin/templates/record-page.ts +6 -0
  388. package/src/workspace-plugin.ts +574 -0
@@ -0,0 +1,930 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowInstancePlugin = void 0;
4
+ exports.normalizeInputValue = normalizeInputValue;
5
+ const sdk_build_core_1 = require("@servicenow/sdk-build-core");
6
+ const now_id_plugin_1 = require("../../now-id-plugin");
7
+ const node_zlib_1 = require("node:zlib");
8
+ const complex_object_resolver_1 = require("../utils/complex-object-resolver");
9
+ const utils_1 = require("../utils/utils");
10
+ const schema_to_flow_object_1 = require("../utils/schema-to-flow-object");
11
+ const flow_shapes_1 = require("../utils/flow-shapes");
12
+ const inline_script_plugin_1 = require("./inline-script-plugin");
13
+ const flow_constants_1 = require("../utils/flow-constants");
14
+ /**
15
+ * Helper function to check if a field is hidden based on visible or visible_in_fd attributes
16
+ * @param attributes The attributes string from the field definition
17
+ * @returns true if the field has visible='false' or visible_in_fd='false'
18
+ */
19
+ function isHiddenField(attributes) {
20
+ if (!attributes) {
21
+ return false;
22
+ }
23
+ const visibleAttr = (0, schema_to_flow_object_1.getAttributeValue)(attributes, 'visible');
24
+ const visibleInFdAttr = (0, schema_to_flow_object_1.getAttributeValue)(attributes, 'visible_in_fd');
25
+ return visibleAttr === 'false' || visibleInFdAttr === 'false';
26
+ }
27
+ /**
28
+ * Parses a complex object format where values are nested under $cv.$v
29
+ * @param obj The complex object to parse
30
+ * @returns A simplified object with direct values
31
+ */
32
+ function parseComplexObjectValues(obj) {
33
+ /**
34
+ * Recursively parse a value that may contain Flow Designer complex-object wrappers.
35
+ * Handles:
36
+ * • Primitive values – returned as-is
37
+ * • Objects with `$cv` – unwrap to `$cv.$v`
38
+ * • Objects with `$COCollectionField` – treat as an array and recurse
39
+ * • Arrays – recurse over each element
40
+ * • Plain objects – recurse over each property
41
+ */
42
+ const parseValue = (val) => {
43
+ if (val === null || val === undefined) {
44
+ return val;
45
+ }
46
+ // Arrays – recurse element-wise
47
+ if (Array.isArray(val)) {
48
+ return val.map(parseValue);
49
+ }
50
+ // Objects
51
+ if (typeof val === 'object') {
52
+ const obj = val;
53
+ // Direct complex-value wrapper
54
+ if ('$cv' in obj) {
55
+ const cv = obj['$cv'];
56
+ return parseValue(cv?.['$v']);
57
+ }
58
+ // Flow Designer collection array wrapper
59
+ if ('$COCollectionField' in obj) {
60
+ return parseValue(obj['$COCollectionField']);
61
+ }
62
+ // Plain object – recurse on each property
63
+ const out = {};
64
+ for (const [k, v] of Object.entries(val)) {
65
+ out[k] = parseValue(v);
66
+ }
67
+ return out;
68
+ }
69
+ // Primitive
70
+ return val;
71
+ };
72
+ return parseValue(obj);
73
+ }
74
+ /**
75
+ * Normalize raw input value based on uiType.
76
+ * - Attempts to JSON.parse strings.
77
+ * - Resolves FlowDesigner complexObject structures via parseComplexObjectValues.
78
+ * - For array uiTypes, ensures the result is an array (falling back to raw).
79
+ * - For glide_time, parses the time string and returns a TimeShape object.
80
+ * - For glide_duration, parses the duration string and returns a DurationShape object.
81
+ * - For template_value, parses the time string and returns a TemplateValueShape object.
82
+ */
83
+ function normalizeInputValue(value, uiType, source, logger) {
84
+ // Handle glide_time type specially - parse the time string and return TimeShape
85
+ if (source) {
86
+ try {
87
+ if (uiType === flow_constants_1.TIME_DATA_TYPE_VALUE) {
88
+ // Create a StringShape from the value and use TimeShape.from() to parse it.
89
+ // Uses UTC timezone value to show in fluent flow to be in sync with Flow designer UI
90
+ return sdk_build_core_1.TimeShape.from(source, sdk_build_core_1.Shape.from(source, value).asString(), flow_constants_1.UTC_TIMEZONE_VALUE);
91
+ }
92
+ else if (uiType === flow_constants_1.DURATION_DATA_TYPE_VALUE) {
93
+ // Create a StringShape from the value and use DurationShape.from() to parse it
94
+ return sdk_build_core_1.DurationShape.from(source, sdk_build_core_1.Shape.from(source, value).asString());
95
+ }
96
+ else if (uiType === flow_constants_1.TEMPLATE_DATA_TYPE_VALUE) {
97
+ // Create a StringShape from the value and use TemplateValueShape.from() to parse it
98
+ return sdk_build_core_1.TemplateValueShape.from(source, sdk_build_core_1.Shape.from(source, value).asString());
99
+ }
100
+ else if (uiType === flow_constants_1.APPROVAL_RULES_DATA_TYPE_VALUE) {
101
+ // Create a StringShape from the value and use ApprovalRulesShape.from() to parse it
102
+ return flow_shapes_1.ApprovalRulesShape.from(source, sdk_build_core_1.Shape.from(source, value).asString());
103
+ }
104
+ else if (uiType === flow_constants_1.APPROVAL_DUE_DATE_DATA_TYPE_VALUE) {
105
+ // Check if source is a Record before accessing action_type
106
+ if (source instanceof sdk_build_core_1.Record) {
107
+ const actionType = source.get(flow_constants_1.ACTION_TYPE_KEY_NAME)?.ifDefined()?.asString()?.getValue();
108
+ if (flow_constants_1.APPROVAL_DUE_DATE_INPUT_FIELD_ACTIONS.includes(actionType)) {
109
+ // Create a StringShape from the value and use ApprovalDueDateShape.from() to parse it
110
+ return flow_shapes_1.ApprovalDueDateShape.from(source, sdk_build_core_1.Shape.from(source, value).asString());
111
+ }
112
+ }
113
+ }
114
+ }
115
+ catch (e) {
116
+ // If parsing fails, fall through to normal handling
117
+ logger?.error(`Failed to parse value ${value} for ${uiType} in record ${source}: ${e instanceof Error ? e.message : e}`);
118
+ return value;
119
+ }
120
+ }
121
+ let parsed = value;
122
+ try {
123
+ if (uiType !== 'string') {
124
+ parsed = JSON.parse(value);
125
+ }
126
+ }
127
+ catch {
128
+ // handle internal string types
129
+ if (uiType === 'glide_list') {
130
+ // comma separated sys_ids – return [] if empty
131
+ return value && value.trim() !== '' ? value.split(',') : [];
132
+ }
133
+ return value; // any string literal value (other than a valid stringified JSON)
134
+ }
135
+ if (parsed && typeof parsed === 'object' && 'complexObject' in parsed) {
136
+ return parseComplexObjectValues(parsed.complexObject);
137
+ }
138
+ if (uiType?.startsWith('array')) {
139
+ return Array.isArray(parsed) ? parsed : value;
140
+ }
141
+ /**
142
+ * Handle internal non-string types for primitive data types
143
+ * Ex. Instances store boolean values as '1' or '0' instead of true or false. But we show it as true/false in UI/fluent
144
+ */
145
+ if (uiType === 'boolean') {
146
+ parsed = Boolean(parsed); // 1 or true = true, 0 or false = false
147
+ }
148
+ return parsed;
149
+ }
150
+ function buildInstanceToShape({ defColumn, // e.g. "action_type" | "subflow"
151
+ inputsTableName, // e.g. "sys_hub_action_input" | "sys_hub_flow_input"
152
+ zippedColumn, // e.g. "values" | "subflow_inputs"
153
+ callee, // "wfa.action" | "wfa.subflow"
154
+ }) {
155
+ return function toShape(record, { database, logger }) {
156
+ // Resolve the instance definition - either from the source shape or from the database record
157
+ const source = record.getSource();
158
+ const instanceDef = source instanceof flow_shapes_1.ActionSubflowInstanceShape
159
+ ? source.getInstanceDefinition()
160
+ : record.get(defColumn)?.ifDefined()?.asString();
161
+ const definitionInputs = instanceDef instanceof sdk_build_core_1.Record
162
+ ? instanceDef.flat().filter((v) => v.getTable() === inputsTableName)
163
+ : undefined;
164
+ const zippedInputs = record.get(zippedColumn)?.ifString()?.getValue() ?? '';
165
+ // ── Identifier discovery ────────────────────────────────────────────────
166
+ let identifierShapeOrSysId = instanceDef;
167
+ if (instanceDef instanceof sdk_build_core_1.Record) {
168
+ // check for core actions in existing fluent code, if so below condition will keep the existing identifier.
169
+ // Otherwise action.core.log will be replaced with the log.
170
+ const sysId = instanceDef.getId().getValue();
171
+ const coreActionIdentifier = (0, utils_1.getCoreActionIdentifier)(sysId);
172
+ if (coreActionIdentifier) {
173
+ identifierShapeOrSysId = new sdk_build_core_1.IdentifierShape({
174
+ source: record,
175
+ name: coreActionIdentifier,
176
+ });
177
+ }
178
+ else {
179
+ const original = instanceDef.getOriginalSource();
180
+ if (sdk_build_core_1.ts.Node.isNode(original)) {
181
+ const varDecl = original.getFirstAncestorByKind(sdk_build_core_1.ts.SyntaxKind.VariableDeclaration);
182
+ const idNode = varDecl?.getNameNode();
183
+ if (idNode) {
184
+ identifierShapeOrSysId = new sdk_build_core_1.IdentifierShape({
185
+ source: idNode,
186
+ name: idNode.getText(),
187
+ });
188
+ }
189
+ }
190
+ }
191
+ }
192
+ else {
193
+ // When definition is not a Record, try to resolve from database by sys_id
194
+ if (defColumn === flow_constants_1.ACTION_DEF_COLUMN_NAME) {
195
+ const sysId = instanceDef?.ifString()?.getValue();
196
+ if (!sysId) {
197
+ return { success: false };
198
+ }
199
+ const coreActionIdentifier = (0, utils_1.getCoreActionIdentifier)(sysId);
200
+ if (callee === flow_constants_1.ACTION_INSTANCE_API_NAME && !coreActionIdentifier) {
201
+ logger.warn(`Custom actions are not supported, action = ${sysId}`);
202
+ return { success: false };
203
+ }
204
+ const action = database
205
+ .query('sys_hub_action_type_definition')
206
+ .find((v) => v.getId().getValue() === sysId);
207
+ const actionSource = action?.getSource();
208
+ if (actionSource instanceof sdk_build_core_1.CallExpressionShape) {
209
+ const identifierName = (0, utils_1.getIdentifierFromShape)(actionSource);
210
+ if (identifierName) {
211
+ identifierShapeOrSysId = new sdk_build_core_1.IdentifierShape({
212
+ source: actionSource.getOriginalSource(),
213
+ name: identifierName,
214
+ });
215
+ }
216
+ }
217
+ else if (coreActionIdentifier) {
218
+ //Special case handling for core actions
219
+ identifierShapeOrSysId = new sdk_build_core_1.IdentifierShape({ source: record, name: coreActionIdentifier });
220
+ }
221
+ }
222
+ else if (defColumn === 'subflow') {
223
+ const sysId = instanceDef?.getValue();
224
+ const subflow = database.query('sys_hub_flow').find((v) => v.getId().getValue() === sysId);
225
+ const actionSource = subflow?.getSource();
226
+ if (actionSource instanceof sdk_build_core_1.CallExpressionShape) {
227
+ const identifierName = (0, utils_1.getIdentifierFromShape)(actionSource);
228
+ if (identifierName) {
229
+ identifierShapeOrSysId = new sdk_build_core_1.IdentifierShape({
230
+ source: actionSource.getOriginalSource(),
231
+ name: identifierName,
232
+ });
233
+ }
234
+ }
235
+ }
236
+ }
237
+ let inputsShape = buildInputsShapeFromZipped({
238
+ zippedInputs,
239
+ definitionInputs,
240
+ record,
241
+ logger,
242
+ });
243
+ if (inputsShape === undefined) {
244
+ return { success: false };
245
+ }
246
+ const waitForCompletion = record.get('wait_for_completion')?.getValue() === true ||
247
+ record.get('wait_for_completion')?.getValue() === 'true';
248
+ if (waitForCompletion) {
249
+ inputsShape = inputsShape
250
+ ? inputsShape.merge({ waitForCompletion })
251
+ : sdk_build_core_1.Shape.from(record, { waitForCompletion }).asObject();
252
+ }
253
+ const configArg = new sdk_build_core_1.ObjectShape({
254
+ source: record,
255
+ properties: record.transform(({ $ }) => ({
256
+ $id: $.val(now_id_plugin_1.NowIdShape.from(record)),
257
+ annotation: $.from('comment').def(''),
258
+ uuid: $.from('ui_id').def(''),
259
+ })),
260
+ });
261
+ // Create the CallExpressionShape for the action/subflow instance
262
+ const callExpression = new sdk_build_core_1.CallExpressionShape({
263
+ source: record,
264
+ callee,
265
+ args: [identifierShapeOrSysId, configArg, inputsShape],
266
+ });
267
+ // Generate variable name from existing source or fallback to callee + ID
268
+ const order = record.get('order')?.getValue();
269
+ let identifierPrefix = '';
270
+ if (callee.toLowerCase() === flow_constants_1.ACTION_INSTANCE_API_NAME) {
271
+ identifierPrefix = 'action';
272
+ }
273
+ else if (callee.toLowerCase() === flow_constants_1.SUBFLOW_INSTANCE_API_NAME) {
274
+ identifierPrefix = 'subflow';
275
+ }
276
+ // Use getDirectVariableIdentifier to only check direct parent VariableDeclaration
277
+ // This prevents actions inside Subflows from inheriting the parent Subflow's variable name
278
+ const variableName = (0, utils_1.getDirectVariableIdentifier)(record.getOriginalSource()) ?? `${identifierPrefix}Instance_${order}`; // _${instanceId.slice(0, 8)}`
279
+ // Wrap in VariableStatementShape with isExported: false
280
+ return {
281
+ success: true,
282
+ value: new sdk_build_core_1.VariableStatementShape({
283
+ source: record,
284
+ variableName,
285
+ initializer: callExpression,
286
+ isExported: false,
287
+ }),
288
+ };
289
+ };
290
+ }
291
+ exports.FlowInstancePlugin = sdk_build_core_1.Plugin.create({
292
+ name: 'FlowInstancePlugin',
293
+ records: {
294
+ sys_hub_action_instance_v2: {
295
+ toShape: buildInstanceToShape({
296
+ defColumn: flow_constants_1.ACTION_DEF_COLUMN_NAME,
297
+ inputsTableName: 'sys_hub_action_input',
298
+ zippedColumn: 'values',
299
+ callee: flow_constants_1.ACTION_INSTANCE_API_NAME,
300
+ }),
301
+ },
302
+ sys_hub_sub_flow_instance_v2: {
303
+ toShape: buildInstanceToShape({
304
+ defColumn: 'subflow',
305
+ inputsTableName: 'sys_hub_flow_input',
306
+ zippedColumn: 'subflow_inputs',
307
+ callee: flow_constants_1.SUBFLOW_INSTANCE_API_NAME,
308
+ }),
309
+ },
310
+ },
311
+ shapes: [
312
+ {
313
+ // Look for FDInstanceShape and return instance records as needed for Flow plugin
314
+ shape: flow_shapes_1.ActionSubflowInstanceShape,
315
+ fileTypes: ['fluent'],
316
+ async toRecord(callExpression, { factory, transform, diagnostics, logger }) {
317
+ const instanceType = callExpression.getInstanceType();
318
+ // Shortcut for unsupported instance types
319
+ if (instanceType !== flow_constants_1.ACTION_INSTANCE_API_NAME && instanceType !== flow_constants_1.SUBFLOW_INSTANCE_API_NAME) {
320
+ return { success: false };
321
+ }
322
+ const instanceParentDef = callExpression.getInstanceDefinition();
323
+ const instanceSysId = callExpression.getSysId();
324
+ const instanceInputs = callExpression.getInstanceProps();
325
+ const instanceAnnotation = callExpression.getAnnotation()?.getValue();
326
+ const instanceUUID = callExpression.getInstanceUUID()?.getValue();
327
+ if (!instanceInputs || !instanceSysId || !instanceParentDef) {
328
+ diagnostics.error(callExpression, `Failed to extract inputs, sysId, or definition from ${instanceType}`);
329
+ return { success: false };
330
+ }
331
+ let instanceRecord;
332
+ if (instanceType === flow_constants_1.ACTION_INSTANCE_API_NAME) {
333
+ instanceRecord = await buildActionInstance({
334
+ actionDef: instanceParentDef,
335
+ inputs: instanceInputs,
336
+ sysId: instanceSysId,
337
+ annotation: instanceAnnotation,
338
+ uuid: instanceUUID,
339
+ factory,
340
+ source: callExpression,
341
+ transform,
342
+ logger,
343
+ });
344
+ }
345
+ else if (instanceType === flow_constants_1.SUBFLOW_INSTANCE_API_NAME) {
346
+ instanceRecord = await buildSubflowInstance({
347
+ subflowDef: instanceParentDef,
348
+ inputs: instanceInputs,
349
+ sysId: instanceSysId,
350
+ annotation: instanceAnnotation,
351
+ uuid: instanceUUID,
352
+ factory,
353
+ source: callExpression,
354
+ transform,
355
+ });
356
+ }
357
+ return instanceRecord ? { success: true, value: instanceRecord } : { success: false };
358
+ },
359
+ },
360
+ ],
361
+ });
362
+ // -------------------------
363
+ // Shared helpers
364
+ // -------------------------
365
+ /**
366
+ * Builds an FDInlineScriptCallShape from XML inline script data.
367
+ *
368
+ * **Inline Script Detection:**
369
+ * Detects inputs with `scriptActive: true` and extracts the script content from
370
+ * the `script[fieldName].script` property. Creates an FDInlineScriptCallShape that represents
371
+ * `wfa.inlineScript('script content')` in Fluent code.
372
+ *
373
+ * @param fieldName - The name of the input field
374
+ * @param scriptActive - Whether this field contains an active script
375
+ * @param script - The script object containing script content keyed by field name
376
+ * @param source - The source Record for creating the shape
377
+ * @returns FDInlineScriptCallShape if this is an inline script, undefined otherwise
378
+ */
379
+ function buildInlineScriptShapeFromXml(fieldName, scriptActive, script, source) {
380
+ if (scriptActive === true && script && script[fieldName]?.script) {
381
+ const scriptContent = script[fieldName].script;
382
+ return new inline_script_plugin_1.FDInlineScriptCallShape({
383
+ source,
384
+ scriptContent,
385
+ });
386
+ }
387
+ return undefined;
388
+ }
389
+ /**
390
+ * Build an ObjectShape representing instance inputs from a base64-zipped JSON payload.
391
+ * This is used by both subflow and action instances.
392
+ * Supports bi-directional conversion for inline scripts (XML ↔ Fluent).
393
+ */
394
+ function buildInputsShapeFromZipped({ zippedInputs, definitionInputs, record, logger, }) {
395
+ if (!zippedInputs) {
396
+ return undefined;
397
+ }
398
+ const props = {};
399
+ try {
400
+ const unzipped = (0, node_zlib_1.gunzipSync)(Buffer.from(zippedInputs, 'base64')).toString();
401
+ const values = JSON.parse(unzipped);
402
+ for (const { name, value, scriptActive, script, parameter } of values) {
403
+ const attributes = definitionInputs
404
+ ?.find((v) => v.get('element').asString()?.getValue() === name)
405
+ ?.get('attributes')
406
+ ?.ifString()
407
+ ?.getValue();
408
+ const uiType = attributes ? (0, schema_to_flow_object_1.getAttributeValue)(attributes, 'uiType') : undefined;
409
+ // Skip hidden fields during transformation
410
+ // Convert parameter.attributes object to string format (key=value,key=value)
411
+ const paramAttributesStr = parameter?.attributes
412
+ ? Object.entries(parameter.attributes)
413
+ .map(([key, value]) => `${key}=${value}`)
414
+ .join(',')
415
+ : undefined;
416
+ if (isHiddenField(attributes) || isHiddenField(paramAttributesStr)) {
417
+ continue;
418
+ }
419
+ try {
420
+ if (flow_constants_1.UNSUPPORTED_DATA_TYPES.includes(parameter?.type)) {
421
+ logger.warn(`input ${name} has unsupported data type ${parameter?.type}`);
422
+ return undefined;
423
+ }
424
+ // Check if this is an inline script and convert to wfa.inlineScript() format
425
+ const inlineScriptShape = buildInlineScriptShapeFromXml(name, scriptActive, script, record);
426
+ if (inlineScriptShape) {
427
+ props[name] = inlineScriptShape;
428
+ }
429
+ else {
430
+ // Use displayValue for proper type conversion (e.g., boolean: '1' → true)
431
+ props[name] = normalizeInputValue(value, uiType ?? parameter.type, record, logger);
432
+ }
433
+ }
434
+ catch (e) {
435
+ const recordInfo = `${record.getTable()}.${record.getId().getValue()}`;
436
+ logger.warn(`Failed to parse value for ${name} in record ${recordInfo}: ${e instanceof Error ? e.message : e}`);
437
+ props[name] = value;
438
+ }
439
+ }
440
+ return new sdk_build_core_1.ObjectShape({ source: record, properties: props });
441
+ }
442
+ catch (error) {
443
+ logger.error(`Malformed/unsupported input payload in subflow_inputs: ${error}`);
444
+ return undefined;
445
+ }
446
+ }
447
+ // -------------------------
448
+ // Helper builders
449
+ // -------------------------
450
+ async function buildActionInstance({ actionDef, inputs, sysId, annotation, uuid, factory, source, transform, logger, }) {
451
+ const values = actionDef ? await prepareActionInstanceValueJson(inputs, actionDef, transform, logger) : undefined;
452
+ const actionDefRecord = actionDef instanceof sdk_build_core_1.Record ? actionDef : undefined;
453
+ const instanceProps = inputs.transform(({ $ }) => ({
454
+ active: $.val(true),
455
+ // if actionDef is not a Record (sysId fallback cases), actionDef?.getValue() should get get the string value (sysId) as is
456
+ action_type: $.val(actionDefRecord?.getId()?.getValue() || actionDef?.getValue() || ''),
457
+ action_type_parent: $.val(actionDefRecord?.getId()?.getValue() || actionDef?.getValue() || ''),
458
+ comment: $.val(annotation || actionDefRecord?.get('comment')?.getValue() || ''),
459
+ display_text: $.val(''),
460
+ generation_source: $.val(''),
461
+ sys_class_name: $.val('sys_hub_action_instance_v2'),
462
+ updation_source: $.val(''),
463
+ values: $.val(values),
464
+ parent_ui_id: $.val(''),
465
+ }));
466
+ if (!instanceProps) {
467
+ return undefined;
468
+ }
469
+ const record = await factory.createRecord({
470
+ source,
471
+ explicitId: sysId,
472
+ table: 'sys_hub_action_instance_v2',
473
+ properties: instanceProps,
474
+ });
475
+ // UUID can come from either instance uuid property (for fd ui authored actions) or generated from sysid (for fluent authored actions).
476
+ const instanceUUID = uuid ? uuid : (0, utils_1.sysIdToUuid)(record.getId().getValue());
477
+ return record.merge({ ui_id: instanceUUID });
478
+ }
479
+ async function buildSubflowInstance({ subflowDef, inputs, sysId, annotation, factory, uuid, source, transform, }) {
480
+ const values = subflowDef ? await prepareSubflowInstanceValueJson(inputs, subflowDef, transform) : undefined;
481
+ const subflowDefRecord = subflowDef instanceof sdk_build_core_1.Record ? subflowDef : undefined;
482
+ const instanceProps = inputs.transform(({ $ }) => ({
483
+ order: $.val(1),
484
+ flow: $.val(''),
485
+ attributes: $.val(''),
486
+ comment: $.val(annotation || subflowDefRecord?.get('comment')?.getValue() || ''),
487
+ display_text: $.val(''),
488
+ generation_source: $.val(''),
489
+ subflow: $.val(subflowDefRecord?.getId()?.getValue() || subflowDef?.getValue() || ''),
490
+ subflow_inputs: $.val(values),
491
+ wait_for_completion: $.from('waitForCompletion').def(false),
492
+ sys_class_name: $.val('sys_hub_sub_flow_instance_v2'),
493
+ parent_ui_id: $.def(''),
494
+ }));
495
+ if (!instanceProps) {
496
+ return undefined;
497
+ }
498
+ const record = await factory.createRecord({
499
+ source,
500
+ explicitId: sysId,
501
+ table: 'sys_hub_sub_flow_instance_v2',
502
+ properties: instanceProps,
503
+ });
504
+ // UUID can come from either instance uuid property (for fd ui authored subflows) or generated from sysid (for fluent authored subflows).
505
+ const instanceUUID = uuid ? uuid : (0, utils_1.sysIdToUuid)(record.getId().getValue());
506
+ return record.merge({ ui_id: instanceUUID });
507
+ }
508
+ /**
509
+ * Checks for inline script patterns in the input properties and resolves them
510
+ * to their appropriate format (either script format or primitive value).
511
+ *
512
+ * Supports inline scripts via wfa.inlineScript('script') (detected as CallExpressionShape/FDInlineScriptCallShape).
513
+ *
514
+ * Architecture note:
515
+ * This function detects inline scripts based on context - only template literals and Now.include()
516
+ * calls used as Action/Subflow inputs are treated as inline scripts. This avoids incorrectly
517
+ * converting template literals used elsewhere in the codebase (logging, formatting, etc.).
518
+ *
519
+ * Similar to data pills processing, this function:
520
+ * - Uses .entries({ resolve: false }) to preserve shape types
521
+ * - Checks if each shape is a TemplateExpressionShape or Now.include() call
522
+ * - Returns special serialization format for inline scripts
523
+ * - Falls back to regular getValue() for non-script shapes
524
+ *
525
+ * @param instanceInputs - The ObjectShape containing input properties
526
+ * @param transform - Transform context for shape conversion
527
+ * @returns Array of [name, value] tuples where inline scripts are serialized appropriately
528
+ */
529
+ async function checkAndResolveInlineScripts(instanceInputs, _transform) {
530
+ const entries = instanceInputs.entries({ resolve: false });
531
+ const results = [];
532
+ for (const [key, shape] of entries) {
533
+ // Handle wfa.inlineScript() calls - they should already be FDInlineScriptCallShape after plugin processing
534
+ if (shape instanceof inline_script_plugin_1.FDInlineScriptCallShape) {
535
+ const scriptContent = shape.getValue();
536
+ if (typeof scriptContent === 'string') {
537
+ // Wrap the script content in a TemplateExpressionShape
538
+ const templateShape = new sdk_build_core_1.TemplateExpressionShape({
539
+ source: shape,
540
+ literalText: scriptContent,
541
+ });
542
+ // Create InlineScriptShape for Flow Designer serialization
543
+ const inlineScript = new flow_shapes_1.InlineScriptShape({
544
+ source: templateShape,
545
+ scriptContent,
546
+ });
547
+ const scriptValue = inlineScript.toFlowDesignerJson(key);
548
+ results.push([key, scriptValue]);
549
+ }
550
+ }
551
+ }
552
+ return results;
553
+ }
554
+ /**
555
+ * Resolves complex object input values for subflow/action instance preparation.
556
+ * @param name - Input field name
557
+ * @param value - Raw input value
558
+ * @param parentDef - Record containing input and complex object definitions
559
+ * @param inputTableName - Table name to look up input definitions (e.g. 'sys_hub_flow_input' or 'sys_hub_action_input')
560
+ */
561
+ // Deprecated: kept for backward-compat but delegates to shared resolver
562
+ function resolveComplexInput(name, value, parentDef, inputTableName, logger) {
563
+ return (0, complex_object_resolver_1.resolveComplexInput)(name, value, parentDef, inputTableName, undefined, logger);
564
+ }
565
+ /**
566
+ * Checks if a given value is a serialized inline script object.
567
+ * This is used to identify inputs that have already been processed into the final
568
+ * Flow Designer JSON format for scripts.
569
+ *
570
+ * @param value - The value to check.
571
+ * @returns `true` if the value is a script object, `false` otherwise.
572
+ */
573
+ function isInlineScriptValue(value) {
574
+ return typeof value === 'object' && value !== null && value.scriptActive === true;
575
+ }
576
+ /**
577
+ * Processes an input value from objShape and returns the appropriate result object.
578
+ * Handles inline scripts by returning them as-is, or creates a standard input object.
579
+ *
580
+ * @param inputName - The name of the input field
581
+ * @param objShape - The ObjectShape containing all input values
582
+ * @param options - Optional processing options
583
+ * @param options.type - The parameter type to use (defaults to 'string' if not provided)
584
+ * @param options.actionDefRecord - Action definition record for complex input resolution
585
+ * @param options.inputTableName - Table name for input definitions (e.g., 'sys_hub_action_input')
586
+ * @returns The processed input object
587
+ */
588
+ function processInputValue(inputName, objShape, options) {
589
+ const value = objShape.get(inputName);
590
+ const primitiveValue = value.getValue();
591
+ // If it's an inline script object, return it as-is
592
+ if (isInlineScriptValue(primitiveValue)) {
593
+ return primitiveValue;
594
+ }
595
+ let finalValue = primitiveValue;
596
+ let finalType = options?.type ?? 'string';
597
+ // If action definition is provided, resolve complex input
598
+ if (options?.actionDefRecord && options?.inputTableName) {
599
+ const resolvedValue = resolveComplexInput(inputName, primitiveValue, options.actionDefRecord, options.inputTableName, options?.logger);
600
+ finalValue = resolvedValue.value;
601
+ finalType = resolvedValue.internalType;
602
+ }
603
+ // Return standard input object
604
+ return {
605
+ name: inputName,
606
+ value: finalValue,
607
+ displayValue: finalValue,
608
+ scriptActive: false,
609
+ parameter: {
610
+ type: finalType,
611
+ },
612
+ };
613
+ }
614
+ /**
615
+ * Processes a definition input that was not provided by the user.
616
+ * Handles hidden fields and default values by creating appropriate input objects.
617
+ *
618
+ * @param inputDef - The input definition record from the action/subflow definition
619
+ * @param inputName - The name of the input field
620
+ * @returns The processed input object if the field is hidden or has a default value, undefined otherwise
621
+ */
622
+ function processDefaultOrHiddenInput(inputDef, inputName) {
623
+ // Get attributes and check if hidden
624
+ const attributes = inputDef.get('attributes')?.ifString()?.getValue();
625
+ const visibleAttr = attributes ? (0, schema_to_flow_object_1.getAttributeValue)(attributes, 'visible') : undefined;
626
+ const visibleInFdAttr = attributes ? (0, schema_to_flow_object_1.getAttributeValue)(attributes, 'visible_in_fd') : undefined;
627
+ const isHidden = visibleAttr === 'false' || visibleInFdAttr === 'false';
628
+ // Get default value and internal type
629
+ const defaultValue = inputDef.get('default_value')?.getValue();
630
+ const hasDefaultValue = defaultValue !== undefined && defaultValue !== null && defaultValue !== '';
631
+ const internalType = inputDef.get('internal_type')?.asString()?.getValue() || 'string';
632
+ // For hidden fields or fields with default values, add them to result
633
+ if (isHidden || hasDefaultValue) {
634
+ const valueToUse = hasDefaultValue ? defaultValue : '';
635
+ const paramAttributes = {};
636
+ if (visibleAttr === 'false') {
637
+ paramAttributes.visible = false;
638
+ }
639
+ if (visibleInFdAttr === 'false') {
640
+ paramAttributes.visible_in_fd = false;
641
+ }
642
+ return {
643
+ name: inputName,
644
+ value: valueToUse,
645
+ displayValue: valueToUse,
646
+ scriptActive: false,
647
+ parameter: {
648
+ type: internalType,
649
+ ...(Object.keys(paramAttributes).length > 0 && { attributes: paramAttributes }),
650
+ },
651
+ };
652
+ }
653
+ return undefined;
654
+ }
655
+ async function prepareActionInstanceValueJson(instanceInputs, actionDef, transform, logger) {
656
+ const actionDefRecord = actionDef.isRecord() ? actionDef.as(sdk_build_core_1.Record) : undefined;
657
+ if (!instanceInputs) {
658
+ return [];
659
+ }
660
+ const isActionDefString = actionDef instanceof sdk_build_core_1.StringShape;
661
+ // Check for datapills and resolve them
662
+ const dataPillResults = await checkAndResolveDataPills(instanceInputs, transform);
663
+ // Check for inline script tags and resolve them (only returns scripts)
664
+ const inlineScriptResults = await checkAndResolveInlineScripts(instanceInputs, transform);
665
+ const inlineScriptMap = new Map(inlineScriptResults);
666
+ // Merge: use inline scripts where they exist, otherwise use datapill results
667
+ // Note: Inline script can be applied to only top level properties; No need to handle nested objects
668
+ const mergedResults = dataPillResults.map(([key, value]) => {
669
+ return inlineScriptMap.has(key) ? [key, inlineScriptMap.get(key)] : [key, value];
670
+ });
671
+ const objShape = new sdk_build_core_1.ObjectShape({
672
+ source: instanceInputs.getSource(),
673
+ properties: Object.fromEntries(mergedResults),
674
+ });
675
+ const result = [];
676
+ // When isActionDefString is true, there's no action definition in fluent
677
+ // We expect arbitrary inputs and should process all provided inputs directly
678
+ if (actionDefRecord) {
679
+ // When action definition record is present, process only definition inputs
680
+ const definitionInputs = actionDefRecord.flat().filter((v) => v.getTable() === 'sys_hub_action_input');
681
+ const providedInputNames = new Set(objShape.keys());
682
+ for (const inputDef of definitionInputs) {
683
+ const inputName = inputDef.get('element')?.asString()?.getValue();
684
+ if (!inputName) {
685
+ continue;
686
+ }
687
+ // If input is provided in objShape(ie provided by user), process it
688
+ if (providedInputNames.has(inputName)) {
689
+ const processedValue = processInputValue(inputName, objShape, {
690
+ actionDefRecord,
691
+ inputTableName: 'sys_hub_action_input',
692
+ logger,
693
+ });
694
+ result.push(processedValue);
695
+ }
696
+ else {
697
+ // Process default or hidden input
698
+ const processedValue = processDefaultOrHiddenInput(inputDef, inputName);
699
+ if (processedValue) {
700
+ result.push(processedValue);
701
+ }
702
+ }
703
+ }
704
+ }
705
+ else if (isActionDefString) {
706
+ for (const inputName of objShape.keys()) {
707
+ const processedValue = processInputValue(inputName, objShape, { type: 'string' });
708
+ result.push(processedValue);
709
+ }
710
+ }
711
+ return result;
712
+ }
713
+ async function prepareSubflowInstanceValueJson(instanceInputs, subflowDef, transform) {
714
+ // Check for datapills and resolve them
715
+ const dataPillResults = await checkAndResolveDataPills(instanceInputs, transform);
716
+ // Check for inline script tags and resolve them (only returns scripts)
717
+ const inlineScriptResults = await checkAndResolveInlineScripts(instanceInputs, transform);
718
+ const inlineScriptMap = new Map(inlineScriptResults);
719
+ // Merge: use inline scripts where they exist, otherwise use datapill results
720
+ const mergedResults = dataPillResults.map(([key, value]) => {
721
+ return inlineScriptMap.has(key) ? [key, inlineScriptMap.get(key)] : [key, value];
722
+ });
723
+ const objShape = new sdk_build_core_1.ObjectShape({
724
+ source: instanceInputs.getSource(),
725
+ properties: Object.fromEntries(mergedResults),
726
+ });
727
+ return objShape
728
+ .keys()
729
+ .filter((key) => key !== 'waitForCompletion')
730
+ .map((key) => {
731
+ const value = objShape.get(key);
732
+ const primitiveValue = value.getValue();
733
+ // If checkAndResolveInlineScripts already returned a script object, return it as-is
734
+ if (isInlineScriptValue(primitiveValue)) {
735
+ return primitiveValue;
736
+ }
737
+ let resolvedValue = {
738
+ value: primitiveValue,
739
+ internalType: undefined,
740
+ };
741
+ if (subflowDef.isRecord()) {
742
+ resolvedValue = resolveComplexInput(key, primitiveValue, subflowDef.as(sdk_build_core_1.Record), 'sys_hub_flow_input');
743
+ }
744
+ const result = {
745
+ name: key,
746
+ value: resolvedValue.value,
747
+ displayValue: resolvedValue.value,
748
+ parameter: {
749
+ type: resolvedValue.internalType,
750
+ }, // populate later if needed
751
+ };
752
+ // Add children array if present (for FlowObject with datapills)
753
+ if (resolvedValue.children && resolvedValue.children.length > 0) {
754
+ result['children'] = resolvedValue.children;
755
+ }
756
+ return result;
757
+ });
758
+ }
759
+ /**
760
+ * Type guard to check if a shape is a data pill shape that needs resolution.
761
+ * Data pill shapes include PropertyAccessShape, TemplateExpressionShape, and IdentifierShape.
762
+ * @param shape - The shape to check
763
+ * @returns true if the shape is a data pill shape, false otherwise
764
+ */
765
+ function isDataPillShape(shape) {
766
+ return (shape instanceof sdk_build_core_1.PropertyAccessShape ||
767
+ shape instanceof sdk_build_core_1.TemplateExpressionShape ||
768
+ shape instanceof sdk_build_core_1.IdentifierShape);
769
+ }
770
+ /**
771
+ * Recursively resolves data pills in nested object structures.
772
+ * Handles objects with nested data pills and constructs the resolved object back.
773
+ * Special shapes like TemplateValueShape and ApprovalRulesShape are also processed recursively
774
+ * since they can contain data pills in their nested structures.
775
+ * @param shape - The ObjectShape to process
776
+ * @param transform - The transform instance
777
+ * @returns Resolved object with all nested data pills resolved
778
+ */
779
+ async function resolveObjectShapeRecursively(shape, transform) {
780
+ const entries = shape.entries({ resolve: false });
781
+ const resolvedObject = {};
782
+ for (const [key, valueShape] of entries) {
783
+ if (isDataPillShape(valueShape)) {
784
+ // Resolve data pill shapes
785
+ resolvedObject[key] = await (0, utils_1.resolveDataPillShape)(valueShape, transform);
786
+ }
787
+ else if (valueShape.isObject()) {
788
+ // Recursively resolve all ObjectShapes including special types
789
+ // TemplateValueShape and ApprovalRulesShape can contain data pills in their nested structures
790
+ // DurationShape only contains primitive numbers, but handling it recursively is harmless
791
+ resolvedObject[key] = await resolveObjectShapeRecursively(valueShape.asObject(), transform);
792
+ }
793
+ else if (valueShape.isArray()) {
794
+ // Handle array: recursively resolve each element
795
+ const arrayShape = valueShape.asArray();
796
+ const elements = arrayShape.getElements(false);
797
+ const resolvedArray = [];
798
+ for (const element of elements) {
799
+ if (isDataPillShape(element)) {
800
+ resolvedArray.push(await (0, utils_1.resolveDataPillShape)(element, transform));
801
+ }
802
+ else if (element.isObject()) {
803
+ resolvedArray.push(await resolveObjectShapeRecursively(element.asObject(), transform));
804
+ }
805
+ else if (element.isArray()) {
806
+ // Recursively handle nested arrays by creating a temporary ObjectShape wrapper
807
+ const tempShape = new sdk_build_core_1.ObjectShape({
808
+ source: element.getSource(),
809
+ properties: { temp: element },
810
+ });
811
+ const resolved = await resolveObjectShapeRecursively(tempShape, transform);
812
+ resolvedArray.push(resolved.temp);
813
+ }
814
+ else {
815
+ resolvedArray.push(element.getValue());
816
+ }
817
+ }
818
+ resolvedObject[key] = resolvedArray;
819
+ }
820
+ else {
821
+ // For all other shapes (primitives), get the value directly
822
+ resolvedObject[key] = valueShape.getValue();
823
+ }
824
+ }
825
+ return resolvedObject;
826
+ }
827
+ /**
828
+ * Wraps special shape types (ApprovalRulesShape, TemplateValueShape, DurationShape) with their string representations.
829
+ * @param shape - The original shape
830
+ * @param resolvedValue - The resolved value
831
+ * @param source - The source for creating new shapes
832
+ * @returns The appropriately wrapped value or the original resolved value
833
+ */
834
+ function wrapSpecialShape(shape, resolvedValue, source) {
835
+ if (shape.is(flow_shapes_1.ApprovalRulesShape)) {
836
+ return new flow_shapes_1.ApprovalRulesShape({
837
+ source,
838
+ value: resolvedValue,
839
+ }).toString();
840
+ }
841
+ else if (shape.is(sdk_build_core_1.TemplateValueShape)) {
842
+ return new sdk_build_core_1.TemplateValueShape({
843
+ source,
844
+ value: resolvedValue,
845
+ }).toString();
846
+ }
847
+ else if (shape.is(sdk_build_core_1.DurationShape)) {
848
+ return new sdk_build_core_1.DurationShape({
849
+ source,
850
+ value: resolvedValue,
851
+ }).toString();
852
+ }
853
+ else if (shape.is(flow_shapes_1.ApprovalDueDateShape)) {
854
+ return new flow_shapes_1.ApprovalDueDateShape({
855
+ source,
856
+ value: resolvedValue,
857
+ }).toString();
858
+ }
859
+ return resolvedValue;
860
+ }
861
+ /**
862
+ * Checks for datapills and resolves them in instance inputs.
863
+ * Similar to resolveObjectShapeRecursively but returns key-value pairs and handles special shapes.
864
+ * @param instanceInputs - The instance inputs object shape
865
+ * @param transform - The transform instance
866
+ * @returns Array of [key, value] pairs with resolved datapills
867
+ */
868
+ async function checkAndResolveDataPills(instanceInputs, transform) {
869
+ const entries = instanceInputs.entries({ resolve: false });
870
+ const results = [];
871
+ for (const [key, shape] of entries) {
872
+ if (shape && isDataPillShape(shape)) {
873
+ const resolvedValue = await (0, utils_1.resolveDataPillShape)(shape, transform);
874
+ results.push([key, resolvedValue]);
875
+ }
876
+ else if (shape.is(sdk_build_core_1.DurationShape)) {
877
+ // Handle DurationShape specially - convert to string representation
878
+ // DurationShape.getValue() returns a symbol, so we need to get the duration value differently
879
+ const durationShape = shape.as(sdk_build_core_1.DurationShape);
880
+ const durationValue = durationShape.getDuration();
881
+ const wrappedValue = wrapSpecialShape(shape, durationValue, instanceInputs.getSource());
882
+ results.push([key, wrappedValue]);
883
+ }
884
+ else if (shape.isObject() || shape.is(sdk_build_core_1.TemplateValueShape)) {
885
+ const objShape = shape.is(sdk_build_core_1.TemplateValueShape) ? shape.getTemplateValue() : shape.asObject();
886
+ // Recursively resolve object shapes
887
+ const resolvedValue = await resolveObjectShapeRecursively(objShape, transform);
888
+ // Preserve special shapes like TemplateValue by passing the original shape
889
+ const wrappedValue = wrapSpecialShape(shape, resolvedValue, instanceInputs.getSource());
890
+ results.push([key, wrappedValue]);
891
+ }
892
+ else if (shape.isArray()) {
893
+ // Resolve arrays using the shared recursive logic
894
+ const resolvedArray = await resolveArrayElements(shape.asArray(), transform);
895
+ results.push([key, resolvedArray]);
896
+ }
897
+ else {
898
+ results.push([key, shape.getValue()]);
899
+ }
900
+ }
901
+ return results;
902
+ }
903
+ /**
904
+ * Resolves all elements in an array shape, handling datapills, objects, and nested arrays.
905
+ * Shared logic extracted from both resolveObjectShapeRecursively and checkAndResolveDataPills.
906
+ * @param arrayShape - The array shape to resolve
907
+ * @param transform - The transform instance
908
+ * @returns Resolved array with all datapills resolved
909
+ */
910
+ async function resolveArrayElements(arrayShape, transform) {
911
+ const elements = arrayShape.asArray().getElements(false);
912
+ const resolvedArray = [];
913
+ for (const element of elements) {
914
+ if (isDataPillShape(element)) {
915
+ resolvedArray.push(await (0, utils_1.resolveDataPillShape)(element, transform));
916
+ }
917
+ else if (element.isObject()) {
918
+ resolvedArray.push(await resolveObjectShapeRecursively(element.asObject(), transform));
919
+ }
920
+ else if (element.isArray()) {
921
+ // Recursively handle nested arrays
922
+ resolvedArray.push(await resolveArrayElements(element, transform));
923
+ }
924
+ else {
925
+ resolvedArray.push(element.getValue());
926
+ }
927
+ }
928
+ return resolvedArray;
929
+ }
930
+ //# sourceMappingURL=flow-instance-plugin.js.map