@servicenow/sdk-build-plugins 4.4.1 → 4.6.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 (337) hide show
  1. package/dist/acl-plugin.js +54 -4
  2. package/dist/acl-plugin.js.map +1 -1
  3. package/dist/applicability-plugin.js +2 -0
  4. package/dist/applicability-plugin.js.map +1 -1
  5. package/dist/application-menu-plugin.js +2 -0
  6. package/dist/application-menu-plugin.js.map +1 -1
  7. package/dist/arrow-function-plugin.d.ts +6 -1
  8. package/dist/arrow-function-plugin.js +105 -12
  9. package/dist/arrow-function-plugin.js.map +1 -1
  10. package/dist/atf/test-plugin.js +2 -0
  11. package/dist/atf/test-plugin.js.map +1 -1
  12. package/dist/basic-syntax-plugin.js +20 -0
  13. package/dist/basic-syntax-plugin.js.map +1 -1
  14. package/dist/call-expression-plugin.js +1 -0
  15. package/dist/call-expression-plugin.js.map +1 -1
  16. package/dist/claims-plugin.js +1 -0
  17. package/dist/claims-plugin.js.map +1 -1
  18. package/dist/client-script-plugin.js +1 -0
  19. package/dist/client-script-plugin.js.map +1 -1
  20. package/dist/column-plugin.js +4 -7
  21. package/dist/column-plugin.js.map +1 -1
  22. package/dist/cross-scope-privilege-plugin.js +1 -0
  23. package/dist/cross-scope-privilege-plugin.js.map +1 -1
  24. package/dist/dashboard/dashboard-plugin.js +2 -0
  25. package/dist/dashboard/dashboard-plugin.js.map +1 -1
  26. package/dist/data-plugin.js +1 -0
  27. package/dist/data-plugin.js.map +1 -1
  28. package/dist/email-notification-plugin.js +9 -13
  29. package/dist/email-notification-plugin.js.map +1 -1
  30. package/dist/flow/constants/flow-plugin-constants.d.ts +1 -1
  31. package/dist/flow/constants/flow-plugin-constants.js +1 -1
  32. package/dist/flow/constants/flow-plugin-constants.js.map +1 -1
  33. package/dist/flow/flow-logic/flow-logic-diagnostics.js +5 -5
  34. package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -1
  35. package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +82 -2
  36. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +48 -40
  37. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -1
  38. package/dist/flow/flow-logic/flow-logic-plugin.js +1 -0
  39. package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -1
  40. package/dist/flow/plugins/approval-rules-plugin.js +1 -0
  41. package/dist/flow/plugins/approval-rules-plugin.js.map +1 -1
  42. package/dist/flow/plugins/flow-action-definition-plugin.js +1232 -55
  43. package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -1
  44. package/dist/flow/plugins/flow-data-pill-plugin.js +6 -2
  45. package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -1
  46. package/dist/flow/plugins/flow-definition-plugin.js +23 -44
  47. package/dist/flow/plugins/flow-definition-plugin.js.map +1 -1
  48. package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +2 -2
  49. package/dist/flow/plugins/flow-diagnostics-plugin.js +3 -2
  50. package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -1
  51. package/dist/flow/plugins/flow-instance-plugin.js +136 -34
  52. package/dist/flow/plugins/flow-instance-plugin.js.map +1 -1
  53. package/dist/flow/plugins/flow-trigger-instance-plugin.js +1 -0
  54. package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -1
  55. package/dist/flow/plugins/inline-script-plugin.js +1 -0
  56. package/dist/flow/plugins/inline-script-plugin.js.map +1 -1
  57. package/dist/flow/plugins/step-definition-plugin.js +4 -2
  58. package/dist/flow/plugins/step-definition-plugin.js.map +1 -1
  59. package/dist/flow/plugins/step-instance-plugin.d.ts +9 -1
  60. package/dist/flow/plugins/step-instance-plugin.js +649 -135
  61. package/dist/flow/plugins/step-instance-plugin.js.map +1 -1
  62. package/dist/flow/plugins/trigger-plugin.js +2 -0
  63. package/dist/flow/plugins/trigger-plugin.js.map +1 -1
  64. package/dist/flow/plugins/wfa-datapill-plugin.js +21 -5
  65. package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -1
  66. package/dist/flow/post-install.d.ts +2 -0
  67. package/dist/flow/post-install.js +59 -0
  68. package/dist/flow/post-install.js.map +1 -0
  69. package/dist/flow/utils/complex-object-resolver.js +4 -1
  70. package/dist/flow/utils/complex-object-resolver.js.map +1 -1
  71. package/dist/flow/utils/complex-objects.js +5 -3
  72. package/dist/flow/utils/complex-objects.js.map +1 -1
  73. package/dist/flow/utils/flow-constants.d.ts +90 -2
  74. package/dist/flow/utils/flow-constants.js +430 -7
  75. package/dist/flow/utils/flow-constants.js.map +1 -1
  76. package/dist/flow/utils/flow-io-to-record.d.ts +1 -1
  77. package/dist/flow/utils/flow-io-to-record.js +37 -16
  78. package/dist/flow/utils/flow-io-to-record.js.map +1 -1
  79. package/dist/flow/utils/flow-shapes.js +4 -0
  80. package/dist/flow/utils/flow-shapes.js.map +1 -1
  81. package/dist/flow/utils/flow-to-xml.d.ts +3 -2
  82. package/dist/flow/utils/flow-to-xml.js +3 -4
  83. package/dist/flow/utils/flow-to-xml.js.map +1 -1
  84. package/dist/flow/utils/label-cache-parser.d.ts +9 -2
  85. package/dist/flow/utils/label-cache-parser.js +32 -4
  86. package/dist/flow/utils/label-cache-parser.js.map +1 -1
  87. package/dist/flow/utils/label-cache-processor.d.ts +5 -0
  88. package/dist/flow/utils/label-cache-processor.js +14 -2
  89. package/dist/flow/utils/label-cache-processor.js.map +1 -1
  90. package/dist/flow/utils/pill-shape-helpers.d.ts +15 -0
  91. package/dist/flow/utils/pill-shape-helpers.js +35 -0
  92. package/dist/flow/utils/pill-shape-helpers.js.map +1 -0
  93. package/dist/flow/utils/pill-string-parser.js +1 -0
  94. package/dist/flow/utils/pill-string-parser.js.map +1 -1
  95. package/dist/flow/utils/schema-to-flow-object.d.ts +6 -1
  96. package/dist/flow/utils/schema-to-flow-object.js +131 -15
  97. package/dist/flow/utils/schema-to-flow-object.js.map +1 -1
  98. package/dist/flow/utils/service-catalog.js +5 -1
  99. package/dist/flow/utils/service-catalog.js.map +1 -1
  100. package/dist/flow/utils/utils.d.ts +1 -0
  101. package/dist/flow/utils/utils.js +6 -1
  102. package/dist/flow/utils/utils.js.map +1 -1
  103. package/dist/form-plugin.d.ts +2 -0
  104. package/dist/form-plugin.js +1132 -0
  105. package/dist/form-plugin.js.map +1 -0
  106. package/dist/html-import-plugin.js +1 -0
  107. package/dist/html-import-plugin.js.map +1 -1
  108. package/dist/import-sets-plugin.js +2 -0
  109. package/dist/import-sets-plugin.js.map +1 -1
  110. package/dist/inbound-email-action-plugin.d.ts +10 -0
  111. package/dist/inbound-email-action-plugin.js +128 -0
  112. package/dist/inbound-email-action-plugin.js.map +1 -0
  113. package/dist/index.d.ts +13 -0
  114. package/dist/index.js +17 -1
  115. package/dist/index.js.map +1 -1
  116. package/dist/instance-scan-plugin.d.ts +2 -0
  117. package/dist/instance-scan-plugin.js +293 -0
  118. package/dist/instance-scan-plugin.js.map +1 -0
  119. package/dist/json-plugin.js +1 -0
  120. package/dist/json-plugin.js.map +1 -1
  121. package/dist/list-plugin.js +1 -0
  122. package/dist/list-plugin.js.map +1 -1
  123. package/dist/now-attach-plugin.js +1 -0
  124. package/dist/now-attach-plugin.js.map +1 -1
  125. package/dist/now-config-plugin.js +659 -51
  126. package/dist/now-config-plugin.js.map +1 -1
  127. package/dist/now-id-plugin.js +1 -0
  128. package/dist/now-id-plugin.js.map +1 -1
  129. package/dist/now-include-plugin.js +1 -0
  130. package/dist/now-include-plugin.js.map +1 -1
  131. package/dist/now-ref-plugin.js +1 -0
  132. package/dist/now-ref-plugin.js.map +1 -1
  133. package/dist/now-unresolved-plugin.js +1 -0
  134. package/dist/now-unresolved-plugin.js.map +1 -1
  135. package/dist/package-json-plugin.js +1 -0
  136. package/dist/package-json-plugin.js.map +1 -1
  137. package/dist/property-plugin.js +3 -1
  138. package/dist/property-plugin.js.map +1 -1
  139. package/dist/record-plugin.d.ts +37 -0
  140. package/dist/record-plugin.js +47 -3
  141. package/dist/record-plugin.js.map +1 -1
  142. package/dist/repack/lint/Rules.d.ts +11 -2
  143. package/dist/repack/lint/Rules.js +160 -16
  144. package/dist/repack/lint/Rules.js.map +1 -1
  145. package/dist/repack/lint/index.d.ts +10 -5
  146. package/dist/repack/lint/index.js +76 -50
  147. package/dist/repack/lint/index.js.map +1 -1
  148. package/dist/rest-api-plugin.js +22 -1
  149. package/dist/rest-api-plugin.js.map +1 -1
  150. package/dist/role-plugin.js +1 -0
  151. package/dist/role-plugin.js.map +1 -1
  152. package/dist/schedule-script/index.d.ts +1 -0
  153. package/dist/schedule-script/index.js +18 -0
  154. package/dist/schedule-script/index.js.map +1 -0
  155. package/dist/schedule-script/scheduled-script-plugin.d.ts +2 -0
  156. package/dist/schedule-script/scheduled-script-plugin.js +556 -0
  157. package/dist/schedule-script/scheduled-script-plugin.js.map +1 -0
  158. package/dist/schedule-script/timeZoneConverter.d.ts +61 -0
  159. package/dist/schedule-script/timeZoneConverter.js +170 -0
  160. package/dist/schedule-script/timeZoneConverter.js.map +1 -0
  161. package/dist/script-action-plugin.js +2 -0
  162. package/dist/script-action-plugin.js.map +1 -1
  163. package/dist/script-include-plugin.js +2 -0
  164. package/dist/script-include-plugin.js.map +1 -1
  165. package/dist/server-module-plugin/index.js +13 -2
  166. package/dist/server-module-plugin/index.js.map +1 -1
  167. package/dist/service-catalog/catalog-clientscript-plugin.js +2 -0
  168. package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -1
  169. package/dist/service-catalog/catalog-item-plugin.js +2 -0
  170. package/dist/service-catalog/catalog-item-plugin.js.map +1 -1
  171. package/dist/service-catalog/catalog-ui-policy-plugin.js +2 -0
  172. package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -1
  173. package/dist/service-catalog/sc-record-producer-plugin.js +2 -0
  174. package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -1
  175. package/dist/service-catalog/service-catalog-base.d.ts +18 -18
  176. package/dist/service-catalog/service-catalog-base.js +22 -22
  177. package/dist/service-catalog/service-catalog-base.js.map +1 -1
  178. package/dist/service-catalog/service-catalog-diagnostics.d.ts +6 -0
  179. package/dist/service-catalog/service-catalog-diagnostics.js +20 -0
  180. package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -1
  181. package/dist/service-catalog/shape-to-record.js +7 -2
  182. package/dist/service-catalog/shape-to-record.js.map +1 -1
  183. package/dist/service-catalog/variable-set-plugin.js +2 -0
  184. package/dist/service-catalog/variable-set-plugin.js.map +1 -1
  185. package/dist/service-portal/angular-provider-plugin.js +2 -0
  186. package/dist/service-portal/angular-provider-plugin.js.map +1 -1
  187. package/dist/service-portal/dependency-plugin.js +5 -31
  188. package/dist/service-portal/dependency-plugin.js.map +1 -1
  189. package/dist/service-portal/header-footer-plugin.d.ts +2 -0
  190. package/dist/service-portal/header-footer-plugin.js +50 -0
  191. package/dist/service-portal/header-footer-plugin.js.map +1 -0
  192. package/dist/service-portal/menu-plugin.d.ts +2 -0
  193. package/dist/service-portal/menu-plugin.js +334 -0
  194. package/dist/service-portal/menu-plugin.js.map +1 -0
  195. package/dist/service-portal/page-plugin.d.ts +2 -0
  196. package/dist/service-portal/page-plugin.js +681 -0
  197. package/dist/service-portal/page-plugin.js.map +1 -0
  198. package/dist/service-portal/page-route-map-plugin.d.ts +2 -0
  199. package/dist/service-portal/page-route-map-plugin.js +114 -0
  200. package/dist/service-portal/page-route-map-plugin.js.map +1 -0
  201. package/dist/service-portal/portal-plugin.d.ts +2 -0
  202. package/dist/service-portal/portal-plugin.js +309 -0
  203. package/dist/service-portal/portal-plugin.js.map +1 -0
  204. package/dist/service-portal/theme-plugin.d.ts +2 -0
  205. package/dist/service-portal/theme-plugin.js +112 -0
  206. package/dist/service-portal/theme-plugin.js.map +1 -0
  207. package/dist/service-portal/utils.d.ts +46 -0
  208. package/dist/service-portal/utils.js +331 -0
  209. package/dist/service-portal/utils.js.map +1 -0
  210. package/dist/service-portal/widget-plugin.js +10 -182
  211. package/dist/service-portal/widget-plugin.js.map +1 -1
  212. package/dist/sla-plugin.js +2 -0
  213. package/dist/sla-plugin.js.map +1 -1
  214. package/dist/static-content-plugin.js +5 -0
  215. package/dist/static-content-plugin.js.map +1 -1
  216. package/dist/table-plugin.js +191 -26
  217. package/dist/table-plugin.js.map +1 -1
  218. package/dist/ui-action-plugin.js +3 -4
  219. package/dist/ui-action-plugin.js.map +1 -1
  220. package/dist/ui-page-plugin.js +101 -21
  221. package/dist/ui-page-plugin.js.map +1 -1
  222. package/dist/ui-policy-plugin.js +1 -0
  223. package/dist/ui-policy-plugin.js.map +1 -1
  224. package/dist/user-preference-plugin.js +2 -0
  225. package/dist/user-preference-plugin.js.map +1 -1
  226. package/dist/utils.d.ts +20 -2
  227. package/dist/utils.js +34 -3
  228. package/dist/utils.js.map +1 -1
  229. package/dist/ux-list-menu-config-plugin.js +2 -0
  230. package/dist/ux-list-menu-config-plugin.js.map +1 -1
  231. package/dist/view-plugin.js +9 -3
  232. package/dist/view-plugin.js.map +1 -1
  233. package/dist/workspace-plugin.js +41 -36
  234. package/dist/workspace-plugin.js.map +1 -1
  235. package/package.json +11 -11
  236. package/src/_types/eslint-community-eslint-utils.d.ts +15 -0
  237. package/src/acl-plugin.ts +97 -8
  238. package/src/applicability-plugin.ts +2 -0
  239. package/src/application-menu-plugin.ts +2 -0
  240. package/src/arrow-function-plugin.ts +128 -13
  241. package/src/atf/test-plugin.ts +2 -0
  242. package/src/basic-syntax-plugin.ts +21 -0
  243. package/src/call-expression-plugin.ts +1 -0
  244. package/src/claims-plugin.ts +1 -0
  245. package/src/client-script-plugin.ts +2 -1
  246. package/src/column-plugin.ts +4 -8
  247. package/src/cross-scope-privilege-plugin.ts +2 -1
  248. package/src/dashboard/dashboard-plugin.ts +2 -0
  249. package/src/data-plugin.ts +1 -0
  250. package/src/email-notification-plugin.ts +3 -23
  251. package/src/flow/constants/flow-plugin-constants.ts +1 -1
  252. package/src/flow/flow-logic/flow-logic-diagnostics.ts +5 -6
  253. package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +47 -45
  254. package/src/flow/flow-logic/flow-logic-plugin.ts +1 -0
  255. package/src/flow/plugins/approval-rules-plugin.ts +1 -0
  256. package/src/flow/plugins/flow-action-definition-plugin.ts +1584 -62
  257. package/src/flow/plugins/flow-data-pill-plugin.ts +6 -2
  258. package/src/flow/plugins/flow-definition-plugin.ts +22 -51
  259. package/src/flow/plugins/flow-diagnostics-plugin.ts +3 -2
  260. package/src/flow/plugins/flow-instance-plugin.ts +201 -36
  261. package/src/flow/plugins/flow-trigger-instance-plugin.ts +1 -0
  262. package/src/flow/plugins/inline-script-plugin.ts +1 -0
  263. package/src/flow/plugins/step-definition-plugin.ts +4 -2
  264. package/src/flow/plugins/step-instance-plugin.ts +772 -155
  265. package/src/flow/plugins/trigger-plugin.ts +2 -0
  266. package/src/flow/plugins/wfa-datapill-plugin.ts +26 -5
  267. package/src/flow/post-install.ts +93 -0
  268. package/src/flow/utils/complex-object-resolver.ts +4 -1
  269. package/src/flow/utils/complex-objects.ts +11 -3
  270. package/src/flow/utils/flow-constants.ts +451 -6
  271. package/src/flow/utils/flow-io-to-record.ts +43 -17
  272. package/src/flow/utils/flow-shapes.ts +4 -0
  273. package/src/flow/utils/flow-to-xml.ts +4 -4
  274. package/src/flow/utils/label-cache-parser.ts +33 -4
  275. package/src/flow/utils/label-cache-processor.ts +14 -2
  276. package/src/flow/utils/pill-shape-helpers.ts +42 -0
  277. package/src/flow/utils/pill-string-parser.ts +1 -0
  278. package/src/flow/utils/schema-to-flow-object.ts +183 -15
  279. package/src/flow/utils/service-catalog.ts +5 -2
  280. package/src/flow/utils/utils.ts +12 -1
  281. package/src/form-plugin.ts +1409 -0
  282. package/src/html-import-plugin.ts +1 -0
  283. package/src/import-sets-plugin.ts +2 -0
  284. package/src/inbound-email-action-plugin.ts +145 -0
  285. package/src/index.ts +13 -0
  286. package/src/instance-scan-plugin.ts +313 -0
  287. package/src/json-plugin.ts +1 -0
  288. package/src/list-plugin.ts +2 -1
  289. package/src/now-attach-plugin.ts +1 -0
  290. package/src/now-config-plugin.ts +833 -53
  291. package/src/now-id-plugin.ts +1 -0
  292. package/src/now-include-plugin.ts +1 -0
  293. package/src/now-ref-plugin.ts +1 -0
  294. package/src/now-unresolved-plugin.ts +1 -0
  295. package/src/package-json-plugin.ts +1 -0
  296. package/src/property-plugin.ts +6 -1
  297. package/src/record-plugin.ts +56 -6
  298. package/src/repack/lint/Rules.ts +171 -22
  299. package/src/repack/lint/index.ts +80 -56
  300. package/src/rest-api-plugin.ts +28 -2
  301. package/src/role-plugin.ts +2 -1
  302. package/src/schedule-script/index.ts +1 -0
  303. package/src/schedule-script/scheduled-script-plugin.ts +690 -0
  304. package/src/schedule-script/timeZoneConverter.ts +188 -0
  305. package/src/script-action-plugin.ts +2 -0
  306. package/src/script-include-plugin.ts +2 -0
  307. package/src/server-module-plugin/index.ts +14 -2
  308. package/src/service-catalog/catalog-clientscript-plugin.ts +2 -0
  309. package/src/service-catalog/catalog-item-plugin.ts +2 -0
  310. package/src/service-catalog/catalog-ui-policy-plugin.ts +2 -0
  311. package/src/service-catalog/sc-record-producer-plugin.ts +2 -0
  312. package/src/service-catalog/service-catalog-base.ts +22 -22
  313. package/src/service-catalog/service-catalog-diagnostics.ts +30 -0
  314. package/src/service-catalog/shape-to-record.ts +8 -2
  315. package/src/service-catalog/variable-set-plugin.ts +2 -0
  316. package/src/service-portal/angular-provider-plugin.ts +2 -0
  317. package/src/service-portal/dependency-plugin.ts +6 -53
  318. package/src/service-portal/header-footer-plugin.ts +57 -0
  319. package/src/service-portal/menu-plugin.ts +413 -0
  320. package/src/service-portal/page-plugin.ts +805 -0
  321. package/src/service-portal/page-route-map-plugin.ts +124 -0
  322. package/src/service-portal/portal-plugin.ts +342 -0
  323. package/src/service-portal/theme-plugin.ts +135 -0
  324. package/src/service-portal/utils.ts +470 -0
  325. package/src/service-portal/widget-plugin.ts +18 -224
  326. package/src/sla-plugin.ts +2 -0
  327. package/src/static-content-plugin.ts +4 -0
  328. package/src/table-plugin.ts +228 -37
  329. package/src/ui-action-plugin.ts +3 -8
  330. package/src/ui-page-plugin.ts +110 -21
  331. package/src/ui-policy-plugin.ts +2 -1
  332. package/src/user-preference-plugin.ts +2 -0
  333. package/src/utils.ts +42 -2
  334. package/src/ux-list-menu-config-plugin.ts +2 -0
  335. package/src/view-plugin.ts +11 -4
  336. package/src/workspace-plugin.ts +45 -43
  337. package/src/_types/eslint-plugin-es-x.d.ts +0 -17
@@ -2,14 +2,148 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StepInstancePlugin = exports.StepInstanceShape = void 0;
4
4
  const sdk_build_core_1 = require("@servicenow/sdk-build-core");
5
+ const now_id_plugin_1 = require("../../now-id-plugin");
5
6
  const utils_1 = require("../utils/utils");
6
7
  const column_helper_1 = require("../../column/column-helper");
7
8
  const flow_constants_1 = require("../utils/flow-constants");
9
+ const flow_instance_plugin_1 = require("./flow-instance-plugin");
10
+ const flow_shapes_1 = require("../utils/flow-shapes");
11
+ const utils_2 = require("../../utils");
12
+ const complex_objects_1 = require("../utils/complex-objects");
13
+ const data_pill_shapes_1 = require("../utils/data-pill-shapes");
14
+ const utils_3 = require("../utils/utils");
8
15
  // Error handling type mapping: string to number
9
16
  const ERROR_HANDLING_TYPE_MAP = {
10
17
  stop_the_action: 1,
11
18
  dont_stop_the_action: 2,
12
19
  };
20
+ /**
21
+ * Resolves a TemplateValue field shape to a datapill string (e.g., "{{action.desc|string}}").
22
+ * Handles two cases:
23
+ * 1. Already resolved PillShape — call getValue() directly
24
+ * 2. Unresolved wfa.dataPill() CallExpressionShape — extract pill info from arguments
25
+ * @param cidMap - Optional map of step variable name → CID for direct lookup (avoids AST walking)
26
+ * Returns undefined if the field is not a datapill.
27
+ */
28
+ function resolveFieldToPillString(fieldShape, cidMap) {
29
+ // Case 1: Already a PillShape (e.g., processed by the datapill plugin)
30
+ if (fieldShape instanceof data_pill_shapes_1.PillShape) {
31
+ return fieldShape.getValue();
32
+ }
33
+ // Case 2: Unresolved wfa.dataPill(expression, type) CallExpressionShape
34
+ if (fieldShape instanceof sdk_build_core_1.CallExpressionShape) {
35
+ const callee = fieldShape.getCallee();
36
+ if (callee !== 'wfa.dataPill') {
37
+ return undefined;
38
+ }
39
+ const typeArg = fieldShape.getArgument(1);
40
+ // Extract property path — try Shape API first, then AST node directly
41
+ const propertyNames = [];
42
+ const expressionArg = fieldShape.getArgument(0, false); // 0, false
43
+ if (expressionArg instanceof sdk_build_core_1.PropertyAccessShape) {
44
+ expressionArg.getElements().forEach((el) => {
45
+ if (el instanceof sdk_build_core_1.IdentifierShape) {
46
+ propertyNames.push(el.getName());
47
+ }
48
+ });
49
+ }
50
+ if (propertyNames.length < 2) {
51
+ return undefined;
52
+ }
53
+ let prefix = 'action';
54
+ let pathParts;
55
+ if (propertyNames[1] === 'inputs') {
56
+ // params.inputs.xxx → action pill
57
+ const originalNode = fieldShape.getOriginalNode?.();
58
+ if (originalNode) {
59
+ const actionAncestor = (0, utils_3.findAncestorByCalleeName)(originalNode, 'Action');
60
+ prefix = actionAncestor ? 'action' : 'subflow';
61
+ }
62
+ pathParts = propertyNames.slice(2);
63
+ }
64
+ else {
65
+ // Could be a step variable reference: create_record_step.record.short_description
66
+ // Resolve CID via cidMap lookup (O(1))
67
+ const varName = propertyNames[0];
68
+ const stepCid = varName ? cidMap?.get(varName) : undefined;
69
+ if (stepCid) {
70
+ prefix = `step[${stepCid}]`;
71
+ pathParts = propertyNames.slice(1);
72
+ }
73
+ else {
74
+ // Cannot resolve step CID — return undefined so the caller can handle the failure
75
+ return undefined;
76
+ }
77
+ }
78
+ const dataType = typeArg?.ifString()?.getValue();
79
+ const typeSuffix = dataType ? `|${dataType}` : '';
80
+ return `{{${prefix}.${pathParts.join('.')}${typeSuffix}}}`;
81
+ }
82
+ // Case 3: Already a resolved pill string
83
+ const val = fieldShape.getValue();
84
+ if (typeof val === 'string' && val.startsWith('{{') && val.endsWith('}}')) {
85
+ return val;
86
+ }
87
+ return undefined;
88
+ }
89
+ /**
90
+ * Extracts pill type annotations from a pill string and stores them in the pillTypeMap.
91
+ * Captures types from both step pills ({{step[CID].path|type}}) and action pills
92
+ * ({{action.path|type}}). The "|type" portion is captured before it gets stripped
93
+ * for the element_mapping value. The collected types are used later when building the label_cache.
94
+ */
95
+ const STEP_PILL_TYPE_REGEX = /\{\{step\[([^\]]+)\]\.([^|}]+)(?:\|([^}]+))?\}\}/g;
96
+ const ACTION_PILL_TYPE_REGEX = /\{\{action\.([^|}]+)(?:\|([^}]+))?\}\}/g;
97
+ function collectPillTypes(pillString, pillTypeMap) {
98
+ if (!pillTypeMap) {
99
+ return;
100
+ }
101
+ for (const match of pillString.matchAll(STEP_PILL_TYPE_REGEX)) {
102
+ const [, cid, pillPath, dataType] = match;
103
+ if (cid && pillPath && dataType) {
104
+ pillTypeMap.set(`${cid}::${pillPath}`, dataType);
105
+ }
106
+ }
107
+ for (const match of pillString.matchAll(ACTION_PILL_TYPE_REGEX)) {
108
+ const [, path, dataType] = match;
109
+ if (path && dataType) {
110
+ pillTypeMap.set(`action::${path}`, dataType);
111
+ }
112
+ }
113
+ }
114
+ /**
115
+ * Strips the |type suffix from a pill string.
116
+ * e.g., "{{action.desc|string}}" → "{{action.desc}}"
117
+ *
118
+ * Note: This is called on individual pill strings (from resolveFieldToPillString),
119
+ * never on concatenated multi-pill strings — so no `g` flag is needed.
120
+ */
121
+ function stripPillType(pill) {
122
+ return pill.replace(/\|[^}]+/, '');
123
+ }
124
+ /**
125
+ * Resolves a TemplateExpressionShape into a concatenated string, replacing
126
+ * datapill spans with their pill strings (type-stripped) and collecting pill types.
127
+ * Returns the resolved string and whether any pills were found.
128
+ */
129
+ function resolveTemplateExpression(templateShape, cidMap, pillTypeMap) {
130
+ let result = templateShape.getLiteralText();
131
+ let hasPills = false;
132
+ for (const span of templateShape.getSpans()) {
133
+ const expr = span.getExpression();
134
+ const pillStr = resolveFieldToPillString(expr, cidMap);
135
+ if (pillStr) {
136
+ collectPillTypes(pillStr, pillTypeMap);
137
+ result += stripPillType(pillStr);
138
+ hasPills = true;
139
+ }
140
+ else {
141
+ result += String(expr.getValue?.() ?? '');
142
+ }
143
+ result += span.getLiteralText();
144
+ }
145
+ return { result, hasPills };
146
+ }
13
147
  /**
14
148
  * StepInstanceShape represents a step instance within a custom action's body
15
149
  * This class handles the shape transformation for step instances
@@ -21,9 +155,13 @@ class StepInstanceShape extends sdk_build_core_1.CallExpressionShape {
21
155
  stepLabel;
22
156
  inputs;
23
157
  inputDefinitions;
158
+ /** Map of step variable name → CID, set by ActionDefinitionPlugin for step pill resolution in Action() bodies */
159
+ _cidMap;
160
+ /** Map of "CID::pillPath" → dataType, populated during toRecord for label_cache type propagation */
161
+ _pillTypeMap;
24
162
  constructor(args) {
25
163
  const { source, sysId, config, stepDefinitionSysId, stepLabel, inputs, inputDefinitions } = args;
26
- super({ source, callee: 'StepInstance', args: [sysId, config, stepDefinitionSysId] });
164
+ super({ source, callee: 'wfa.actionStep', args: [sysId, config, stepDefinitionSysId] });
27
165
  this.config = config;
28
166
  this.sysId = sysId;
29
167
  this.stepDefinitionSysId = stepDefinitionSysId;
@@ -49,10 +187,23 @@ class StepInstanceShape extends sdk_build_core_1.CallExpressionShape {
49
187
  getInputDefinitions() {
50
188
  return this.inputDefinitions;
51
189
  }
190
+ setCidMap(cidMap) {
191
+ this._cidMap = cidMap;
192
+ }
193
+ getCidMap() {
194
+ return this._cidMap;
195
+ }
196
+ setPillTypeMap(pillTypeMap) {
197
+ this._pillTypeMap = pillTypeMap;
198
+ }
199
+ getPillTypeMap() {
200
+ return this._pillTypeMap;
201
+ }
52
202
  }
53
203
  exports.StepInstanceShape = StepInstanceShape;
54
204
  exports.StepInstancePlugin = sdk_build_core_1.Plugin.create({
55
205
  name: 'StepInstancePlugin',
206
+ docs: [(0, utils_2.createSdkDocEntry)('wfa.actionStep', ['sys_hub_step_instance'])],
56
207
  shapes: [
57
208
  {
58
209
  shape: sdk_build_core_1.CallExpressionShape,
@@ -68,10 +219,8 @@ exports.StepInstancePlugin = sdk_build_core_1.Plugin.create({
68
219
  return { success: false };
69
220
  }
70
221
  const [stepDefinition, stepInstanceConfig, inputs] = args;
71
- // Validate first argument is a StepDefinition
72
- if (!(stepDefinition instanceof sdk_build_core_1.CallExpressionShape) ||
73
- stepDefinition.getCallee() !== 'ActionStepDefinition') {
74
- diagnostics.error(callExpression, 'Expected first argument to be a ActionStepDefinition');
222
+ if (!stepDefinition) {
223
+ diagnostics.error(callExpression, 'Missing step definition argument');
75
224
  return { success: false };
76
225
  }
77
226
  // Validate second argument is a valid ID
@@ -84,15 +233,55 @@ exports.StepInstancePlugin = sdk_build_core_1.Plugin.create({
84
233
  diagnostics.error(callExpression, 'Expected third argument to be an object');
85
234
  return { success: false };
86
235
  }
87
- const stepConfig = stepDefinition.getArgument(0).asObject();
236
+ let stepDefinitionSysId;
237
+ let stepLabel;
238
+ let inputDefinitions;
239
+ // First argument can be a string (built-in step name), IdentifierShape (actionStep.xxx),
240
+ // or ActionStepDefinition() call
241
+ const stepNameValue = stepDefinition.ifString()?.getValue();
242
+ if (stepNameValue) {
243
+ // Built-in step referenced by name string
244
+ stepDefinitionSysId = flow_constants_1.BUILT_IN_STEP_NAME_TO_SYSID[stepNameValue] ?? '';
245
+ stepLabel = stepNameValue;
246
+ if (!stepDefinitionSysId) {
247
+ diagnostics.error(callExpression, `Unknown built-in step type '${stepNameValue}'`);
248
+ return { success: false };
249
+ }
250
+ }
251
+ else if (stepDefinition instanceof sdk_build_core_1.IdentifierShape) {
252
+ // Built-in step referenced via actionStep.xxx identifier
253
+ const identifierName = stepDefinition.getName();
254
+ const prefix = `${flow_constants_1.BUILT_IN_STEP_PREFIX}.`;
255
+ const resolvedName = identifierName.startsWith(prefix)
256
+ ? identifierName.slice(prefix.length)
257
+ : identifierName;
258
+ stepDefinitionSysId = flow_constants_1.BUILT_IN_STEP_NAME_TO_SYSID[resolvedName] ?? '';
259
+ stepLabel = resolvedName;
260
+ if (!stepDefinitionSysId) {
261
+ diagnostics.error(callExpression, `Unknown built-in step type '${identifierName}'`);
262
+ return { success: false };
263
+ }
264
+ }
265
+ else if (stepDefinition instanceof sdk_build_core_1.CallExpressionShape &&
266
+ stepDefinition.getCallee() === 'ActionStepDefinition') {
267
+ // Custom step definition
268
+ const stepConfig = stepDefinition.getArgument(0).asObject();
269
+ stepDefinitionSysId = stepConfig.get('$id')?.getValue();
270
+ stepLabel = stepConfig.get('name')?.getValue();
271
+ inputDefinitions = stepConfig.get('inputs')?.ifObject()?.asObject();
272
+ }
273
+ else {
274
+ diagnostics.error(callExpression, 'Expected first argument to be a step type name string, actionStep.xxx identifier, or ActionStepDefinition');
275
+ return { success: false };
276
+ }
88
277
  const shapeArgs = {
89
278
  source: callExpression,
90
279
  sysId: stepInstanceConfig.get('$id')?.getValue(),
91
280
  config: stepInstanceConfig,
92
- stepDefinitionSysId: stepConfig.get('$id')?.getValue(),
93
- stepLabel: stepConfig.get('name')?.getValue(),
94
- inputDefinitions: stepConfig.get('inputs')?.asObject(),
281
+ stepDefinitionSysId,
282
+ stepLabel,
95
283
  inputs: inputs,
284
+ ...(inputDefinitions ? { inputDefinitions } : {}),
96
285
  };
97
286
  return {
98
287
  success: true,
@@ -103,10 +292,11 @@ exports.StepInstancePlugin = sdk_build_core_1.Plugin.create({
103
292
  {
104
293
  shape: StepInstanceShape,
105
294
  fileTypes: ['fluent'],
106
- async toRecord(callExpression, { factory }) {
295
+ async toRecord(callExpression, { factory, diagnostics }) {
107
296
  const stepInstanceRecord = await buildStepInstanceRecord({
108
297
  callExpression,
109
298
  factory,
299
+ diagnostics,
110
300
  values: callExpression.getInputs(),
111
301
  sysId: callExpression.getSysId(),
112
302
  stepDefinitionSysId: callExpression.getStepDefinitionSysId(),
@@ -124,6 +314,12 @@ exports.StepInstancePlugin = sdk_build_core_1.Plugin.create({
124
314
  sys_hub_step_ext_output: {
125
315
  coalesce: ['model', 'element'],
126
316
  },
317
+ sys_complex_object: {
318
+ coalesce: ['name'],
319
+ },
320
+ sys_element_mapping: {
321
+ coalesce: ['field', 'id'],
322
+ },
127
323
  sys_hub_step_instance: {
128
324
  relationships: {
129
325
  sys_variable_value: {
@@ -147,81 +343,128 @@ exports.StepInstancePlugin = sdk_build_core_1.Plugin.create({
147
343
  descendant: true,
148
344
  },
149
345
  },
150
- // toShape(record, { descendants, diagnostics }) {
151
- // // Get the step definition reference
152
- // const stepDefinitionRecords = descendants.query('sys_flow_step_definition')
153
- // if (stepDefinitionRecords.length === 0) {
154
- // diagnostics.error(record, 'Could not find step definition for step instance')
155
- // return { success: false }
156
- // }
157
- // const stepDefinition = stepDefinitionRecords[0]
158
- // if (!stepDefinition) {
159
- // diagnostics.error(record, 'Step definition is undefined')
160
- // return { success: false }
161
- // }
162
- // // Build the config object from sys_variable_value records
163
- // const variableValues = descendants.query('sys_variable_value')
164
- // const configObj: globalThis.Record<string, any> = {}
165
- // for (const varValue of variableValues) {
166
- // const variableSysId = varValue.get('variable')?.asString()?.getValue()
167
- // const value = varValue.get('value')?.asString()?.getValue()
168
- // // Find the matching input definition to get the element name
169
- // const inputRecords = descendants.query('sys_flow_step_definition_input', { sysId: variableSysId })
170
- // if (inputRecords.length > 0) {
171
- // const elementName = inputRecords[0]?.get('element')?.asString()?.getValue()
172
- // if (elementName) {
173
- // // Try to parse JSON values, otherwise use as string
174
- // try {
175
- // configObj[elementName] = JSON.parse(value || '')
176
- // } catch {
177
- // configObj[elementName] = value
178
- // }
179
- // }
180
- // }
181
- // }
182
- // // Add error_handling_type and label from the step instance record itself
183
- // const errorHandlingType = record.get('error_handling_type')?.asNumber()?.getValue()
184
- // if (errorHandlingType !== undefined && errorHandlingType !== 1) {
185
- // configObj['error_handling_type'] = errorHandlingType
186
- // }
187
- // const label = record.get('label')?.asString()?.getValue()
188
- // const stepName = stepDefinition.get('name')?.asString()?.getValue()
189
- // if (label && label !== stepName) {
190
- // configObj['label'] = label
191
- // }
192
- // // Create the StepDefinition CallExpressionShape reference
193
- // const stepDefinitionShape = new CallExpressionShape({
194
- // source: stepDefinition,
195
- // callee: 'StepDefinition',
196
- // args: [
197
- // stepDefinition.transform(({ $ }) => ({
198
- // $id: $.val(NowIdShape.from(stepDefinition)),
199
- // name: $,
200
- // })),
201
- // ],
202
- // })
203
- // // Create the config ObjectShape
204
- // const configProperties: globalThis.Record<string, any> = {}
205
- // for (const [key, value] of Object.entries(configObj)) {
206
- // configProperties[key] = value
207
- // }
208
- // const configShape = new ObjectShape({
209
- // source: record,
210
- // properties: configProperties,
211
- // })
212
- // return {
213
- // success: true,
214
- // value: new CallExpressionShape({
215
- // source: record,
216
- // callee: 'StepInstance',
217
- // args: [stepDefinitionShape, NowIdShape.from(record), configShape],
218
- // }),
219
- // }
220
- // },
346
+ toShape(record, { descendants, logger }) {
347
+ // Skip step instances that belong to an action definition
348
+ // those are handled by ActionDefinitionPlugin's toShape for Action() definitions
349
+ const actionRef = record.get('action')?.asString()?.getValue();
350
+ if (actionRef) {
351
+ return { success: false };
352
+ }
353
+ const stepDefinitionRecords = descendants.query('sys_flow_step_definition');
354
+ const variableValues = descendants.query('sys_variable_value');
355
+ const configObj = {};
356
+ let stepDefinitionShape;
357
+ let stepName;
358
+ if (stepDefinitionRecords.length > 0) {
359
+ // Custom step definition found in descendants
360
+ const stepDefinition = stepDefinitionRecords[0];
361
+ if (!stepDefinition) {
362
+ logger.warn('Step definition is undefined');
363
+ return { success: false };
364
+ }
365
+ stepName = stepDefinition.get('name')?.asString()?.getValue();
366
+ // Resolve variable values using input definition records from descendants
367
+ for (const varValue of variableValues) {
368
+ const variableSysId = varValue.get('variable')?.asString()?.getValue();
369
+ const value = varValue.get('value')?.asString()?.getValue();
370
+ const inputRecords = descendants.query('sys_flow_step_definition_input', {
371
+ sysId: variableSysId,
372
+ });
373
+ if (inputRecords.length > 0) {
374
+ const elementName = inputRecords[0]?.get('element')?.asString()?.getValue();
375
+ if (elementName) {
376
+ try {
377
+ configObj[elementName] = JSON.parse(value || '');
378
+ }
379
+ catch {
380
+ configObj[elementName] = value;
381
+ }
382
+ }
383
+ }
384
+ }
385
+ stepDefinitionShape = new sdk_build_core_1.CallExpressionShape({
386
+ source: stepDefinition,
387
+ callee: 'ActionStepDefinition',
388
+ args: [
389
+ stepDefinition.transform(({ $ }) => ({
390
+ $id: $.val(now_id_plugin_1.NowIdShape.from(stepDefinition)),
391
+ name: $,
392
+ })),
393
+ ],
394
+ });
395
+ }
396
+ else {
397
+ // OOB/built-in step definition — not in XML export
398
+ const stepTypeSysId = record.get('step_type')?.asString()?.getValue();
399
+ if (!stepTypeSysId) {
400
+ logger.warn(`Step instance ${record.getId().getValue()} has no step_type reference`);
401
+ return { success: false };
402
+ }
403
+ const builtInDef = flow_constants_1.BUILT_IN_STEP_DEFINITIONS[stepTypeSysId];
404
+ if (!builtInDef) {
405
+ logger.warn(`Unknown OOB step definition ${stepTypeSysId} for step instance ${record.getId().getValue()}`);
406
+ return { success: false };
407
+ }
408
+ stepName = builtInDef.name;
409
+ // Resolve variable values using the built-in definition's input/output mappings
410
+ for (const varValue of variableValues) {
411
+ const variableSysId = varValue.get('variable')?.asString()?.getValue();
412
+ const value = varValue.get('value')?.asString()?.getValue();
413
+ if (variableSysId) {
414
+ const entry = builtInDef.inputs[variableSysId] ?? builtInDef.outputs[variableSysId];
415
+ const elementName = entry ? (0, flow_constants_1.getVarEntryName)(entry) : undefined;
416
+ const uiType = entry ? (0, flow_constants_1.getVarEntryType)(entry) : undefined;
417
+ if (elementName && value != null) {
418
+ configObj[elementName] = uiType ? (0, flow_instance_plugin_1.normalizeInputValue)(value, uiType, record) : value;
419
+ }
420
+ }
421
+ }
422
+ // Built-in/OOB step: emit actionStep.xxx reference
423
+ const stepIdentifier = (0, utils_1.getBuiltInStepIdentifier)(stepTypeSysId);
424
+ stepDefinitionShape = stepIdentifier
425
+ ? new sdk_build_core_1.IdentifierShape({ source: record, name: stepIdentifier })
426
+ : builtInDef.name;
427
+ }
428
+ // Build step instance config (2nd arg): $id, label, error_handling_type
429
+ const configProperties = {
430
+ $id: now_id_plugin_1.NowIdShape.from(record),
431
+ };
432
+ const errorHandlingRaw = record.get('error_handling_type');
433
+ const errorHandlingType = errorHandlingRaw?.ifNumber()?.getValue() ?? Number(errorHandlingRaw?.ifString()?.getValue());
434
+ if (errorHandlingType && errorHandlingType !== 1 && !Number.isNaN(errorHandlingType)) {
435
+ configProperties['error_handling_type'] = errorHandlingType;
436
+ }
437
+ const label = record.get('label')?.asString()?.getValue();
438
+ if (label && label !== stepName) {
439
+ configProperties['label'] = label;
440
+ }
441
+ const stepInstanceConfig = new sdk_build_core_1.ObjectShape({
442
+ source: record,
443
+ properties: configProperties,
444
+ });
445
+ // Build inputs (3rd arg): resolved variable values only
446
+ const inputsShape = new sdk_build_core_1.ObjectShape({
447
+ source: record,
448
+ properties: { ...configObj },
449
+ });
450
+ return {
451
+ success: true,
452
+ value: new sdk_build_core_1.CallExpressionShape({
453
+ source: record,
454
+ callee: 'wfa.actionStep',
455
+ args: [stepDefinitionShape, stepInstanceConfig, inputsShape],
456
+ }),
457
+ };
458
+ },
221
459
  },
222
460
  },
223
461
  });
224
- async function buildStepInstanceRecord({ callExpression, factory, values, sysId, stepDefinitionSysId, stepLabel, inputs, }) {
462
+ async function buildStepInstanceRecord({ callExpression, factory, diagnostics, values, sysId, stepDefinitionSysId, stepLabel, inputs, }) {
463
+ // resolve: false — keep PillShapes and other ResolvableShapes intact (same reason as createVariableRecords).
464
+ // Using .getValue() on the parent ObjectShape would deeply resolve nested PillShapes into symbols.
465
+ const valuesArray = values.properties({ resolve: false });
466
+ const cidMap = callExpression.getCidMap();
467
+ const pillTypeMap = callExpression.getPillTypeMap();
225
468
  // Create step instance record
226
469
  const stepInstanceRecord = await factory.createRecord({
227
470
  source: callExpression,
@@ -231,7 +474,7 @@ async function buildStepInstanceRecord({ callExpression, factory, values, sysId,
231
474
  step_type: stepDefinitionSysId,
232
475
  order: 1,
233
476
  active: true,
234
- error_handling_type: ERROR_HANDLING_TYPE_MAP[values.get('errorHandlingType')?.getValue()] ?? 1,
477
+ error_handling_type: ERROR_HANDLING_TYPE_MAP[valuesArray['errorHandlingType']?.ifString()?.getValue() ?? ''] ?? 1,
235
478
  label: stepLabel,
236
479
  },
237
480
  });
@@ -240,19 +483,21 @@ async function buildStepInstanceRecord({ callExpression, factory, values, sysId,
240
483
  });
241
484
  const stepInstanceSysId = updatedStepInstanceRecord.getId().getValue();
242
485
  // Create sys_variable_value records for each input value
243
- const variableValueRecords = await createVariableRecords(values, inputs, factory, callExpression, stepInstanceSysId);
486
+ const stepDataRecords = await createVariableRecords(valuesArray, inputs, factory, callExpression, stepInstanceSysId, stepDefinitionSysId, cidMap);
244
487
  const extendedInputRecords = [];
245
488
  const extendedOutputRecords = [];
246
489
  const extendedVariableValueRecords = [];
247
- const valuesArray = values.properties();
248
- // biome-ignore lint/suspicious/noExplicitAny: Dynamic input variable config
249
- const inputVariables = valuesArray['inputVariables']?.getValue();
250
- if (inputVariables) {
251
- for (const [name, config] of Object.entries(inputVariables)) {
252
- const label = config.label;
253
- const mandatory = config.mandatory;
254
- const defaultValue = config.defaultValue ?? '';
255
- const value = config.value;
490
+ const inputVariablesShape = valuesArray['inputVariables'];
491
+ if (inputVariablesShape) {
492
+ const inputVarObj = inputVariablesShape.asObject();
493
+ const inputVarProps = inputVarObj.properties({ resolve: false });
494
+ const extInputTableName = `var__m_sys_hub_step_ext_input_${stepInstanceSysId}`;
495
+ for (const [name, configShapeRaw] of Object.entries(inputVarProps)) {
496
+ const configObj = configShapeRaw.asObject();
497
+ const configProps = configObj.properties({ resolve: false });
498
+ const label = (configProps['label']?.ifString?.()?.getValue() ?? name);
499
+ const defaultValue = (configProps['defaultValue']?.ifString?.()?.getValue() ?? '');
500
+ const valueShape = configProps['value'];
256
501
  const extInputRecord = await factory.createRecord({
257
502
  source: callExpression,
258
503
  table: 'sys_hub_step_ext_input',
@@ -261,69 +506,336 @@ async function buildStepInstanceRecord({ callExpression, factory, values, sysId,
261
506
  model: stepInstanceSysId,
262
507
  model_id: stepInstanceSysId,
263
508
  model_table: 'sys_hub_step_instance',
264
- name: `var__m_sys_hub_step_ext_input_${stepInstanceSysId}`,
509
+ name: extInputTableName,
265
510
  element: name,
266
511
  label: label,
267
- mandatory: mandatory,
268
512
  default_value: defaultValue,
513
+ attributes: (0, flow_constants_1.buildExtVarAttributes)('string'),
514
+ internal_type: 'string',
269
515
  },
270
516
  });
271
517
  extendedInputRecords.push(extInputRecord);
272
- extendedVariableValueRecords.push(await factory.createRecord({
273
- source: callExpression,
274
- table: 'sys_variable_value',
275
- properties: {
276
- document: 'sys_hub_step_instance',
277
- document_key: stepInstanceSysId,
278
- order: 100,
279
- value: value,
280
- variable: extInputRecord.getId().getValue(),
281
- },
282
- }));
518
+ if (!valueShape) {
519
+ // No value provided — still create a sys_variable_value record with empty value
520
+ // so the platform recognizes the ext input variable exists
521
+ extendedVariableValueRecords.push(await factory.createRecord({
522
+ source: callExpression,
523
+ table: 'sys_variable_value',
524
+ properties: {
525
+ document: 'sys_hub_step_instance',
526
+ document_key: stepInstanceSysId,
527
+ order: 100,
528
+ value: '',
529
+ variable: extInputRecord.getId().getValue(),
530
+ },
531
+ }));
532
+ }
533
+ else {
534
+ // Check if value is a datapill — if so, create sys_element_mapping instead of sys_variable_value
535
+ const pillString = resolveFieldToPillString(valueShape, cidMap);
536
+ if (pillString) {
537
+ collectPillTypes(pillString, pillTypeMap);
538
+ extendedVariableValueRecords.push(await factory.createRecord({
539
+ source: callExpression,
540
+ table: 'sys_element_mapping',
541
+ properties: {
542
+ field: name,
543
+ id: stepInstanceSysId,
544
+ table: extInputTableName,
545
+ value: stripPillType(pillString),
546
+ },
547
+ }));
548
+ }
549
+ else if (valueShape.is(sdk_build_core_1.TemplateExpressionShape)) {
550
+ const { result, hasPills } = resolveTemplateExpression(valueShape, cidMap, pillTypeMap);
551
+ if (hasPills) {
552
+ extendedVariableValueRecords.push(await factory.createRecord({
553
+ source: callExpression,
554
+ table: 'sys_element_mapping',
555
+ properties: {
556
+ field: name,
557
+ id: stepInstanceSysId,
558
+ table: extInputTableName,
559
+ value: result,
560
+ },
561
+ }));
562
+ }
563
+ else {
564
+ extendedVariableValueRecords.push(await factory.createRecord({
565
+ source: callExpression,
566
+ table: 'sys_variable_value',
567
+ properties: {
568
+ document: 'sys_hub_step_instance',
569
+ document_key: stepInstanceSysId,
570
+ order: 100,
571
+ value: result,
572
+ variable: extInputRecord.getId().getValue(),
573
+ },
574
+ }));
575
+ }
576
+ }
577
+ else {
578
+ // Simple value → store in sys_variable_value
579
+ const rawVal = valueShape.ifString()?.getValue() ?? valueShape.getValue?.();
580
+ const resolvedValue = typeof rawVal === 'symbol' ? '' : (rawVal ?? '');
581
+ extendedVariableValueRecords.push(await factory.createRecord({
582
+ source: callExpression,
583
+ table: 'sys_variable_value',
584
+ properties: {
585
+ document: 'sys_hub_step_instance',
586
+ document_key: stepInstanceSysId,
587
+ order: 100,
588
+ value: resolvedValue,
589
+ variable: extInputRecord.getId().getValue(),
590
+ },
591
+ }));
592
+ }
593
+ }
283
594
  }
284
595
  }
285
596
  const outputVariables = valuesArray['outputVariables'];
597
+ const complexObjectRecords = [];
286
598
  if (outputVariables) {
287
599
  const outputItemShape = outputVariables.asObject();
288
- const outputProperties = outputItemShape.properties();
600
+ const outputProperties = outputItemShape.properties({ resolve: false });
289
601
  for (const [columnName, columnCallExpr] of Object.entries(outputProperties)) {
290
602
  const callExpr = columnCallExpr.as(sdk_build_core_1.CallExpressionShape);
291
- const columnType = callExpr.getCallee(); // e.g., 'StringColumn', 'IntegerColumn'
603
+ const columnType = callExpr.getCallee(); // e.g., 'StringColumn', 'IntegerColumn', 'FlowObject', 'FlowArray'
292
604
  const columnConfig = callExpr.getArgument(0)?.asObject();
293
605
  const columnLabel = columnConfig?.get('label')?.getValue();
294
606
  const mandatory = columnConfig?.get('mandatory')?.getValue();
295
- const internalType = column_helper_1.COLUMN_API_TO_TYPE[columnType] || 'string';
296
- const extOutputRecord = await factory.createRecord({
297
- source: callExpression,
298
- table: 'sys_hub_step_ext_output',
299
- properties: {
300
- active: true,
301
- model: stepInstanceSysId,
302
- model_id: stepInstanceSysId,
303
- model_table: 'sys_hub_step_instance',
304
- name: `var__m_sys_hub_step_ext_output_${stepInstanceSysId}`,
305
- element: columnName,
306
- label: columnLabel || columnName,
307
- internal_type: internalType,
308
- mandatory: mandatory,
309
- },
310
- });
311
- extendedOutputRecords.push(extOutputRecord);
607
+ // Handle FlowObject and FlowArray complex objects
608
+ if (columnType === flow_constants_1.FLOW_OBJECT_API_NAME || columnType === flow_constants_1.FLOW_ARRAY_API_NAME) {
609
+ const coTypeName = columnConfig?.get('co_type_name')?.ifString()?.getValue();
610
+ const varSysId = `${stepInstanceSysId}_${columnName}`;
611
+ const complexObjectId = coTypeName || `FD${varSysId}`;
612
+ const isArray = columnType === flow_constants_1.FLOW_ARRAY_API_NAME;
613
+ // Generate schema for complex object
614
+ const schemaObj = (0, complex_objects_1.generateSchemaFromObject)(columnConfig, complexObjectId, columnName, stepInstanceSysId, 0, isArray, diagnostics, false);
615
+ // Create sys_complex_object record
616
+ const explicitId = columnConfig?.get('$id')?.ifString()?.getValue();
617
+ const complexRecord = await factory.createRecord({
618
+ source: callExpression,
619
+ table: 'sys_complex_object',
620
+ properties: {
621
+ name: complexObjectId,
622
+ namespace: 'FlowDesigner',
623
+ type: isArray ? 'complex_object_collection' : 'complex_object_schema',
624
+ serialized_content: JSON.stringify(schemaObj),
625
+ ...(explicitId ? { sys_id: explicitId } : {}),
626
+ },
627
+ });
628
+ complexObjectRecords.push(complexRecord);
629
+ // Get complex object attributes
630
+ const systemAttributes = (0, complex_objects_1.getComplexObjectAttributes)(schemaObj, complexObjectId, isArray);
631
+ const attributesStr = (0, complex_objects_1.formatComplexObjectAttributes)(systemAttributes);
632
+ // Create ext_output record with complex object type
633
+ const extOutputRecord = await factory.createRecord({
634
+ source: callExpression,
635
+ table: 'sys_hub_step_ext_output',
636
+ properties: {
637
+ active: true,
638
+ model: stepInstanceSysId,
639
+ model_id: stepInstanceSysId,
640
+ model_table: 'sys_hub_step_instance',
641
+ name: `var__m_sys_hub_step_ext_output_${stepInstanceSysId}`,
642
+ element: columnName,
643
+ label: columnLabel || columnName,
644
+ internal_type: 'string',
645
+ max_length: 65000,
646
+ mandatory: mandatory,
647
+ attributes: attributesStr,
648
+ },
649
+ });
650
+ extendedOutputRecords.push(extOutputRecord);
651
+ }
652
+ else {
653
+ // Handle regular column types (StringColumn, IntegerColumn, etc.)
654
+ const internalType = column_helper_1.COLUMN_API_TO_TYPE[columnType] || 'string';
655
+ const maxLength = columnConfig?.get('maxLength')?.ifNumber()?.getValue();
656
+ const hint = columnConfig?.get('hint')?.ifString()?.getValue();
657
+ const defaultValue = columnConfig?.get('default')?.ifString()?.getValue();
658
+ const extOutputRecord = await factory.createRecord({
659
+ source: callExpression,
660
+ table: 'sys_hub_step_ext_output',
661
+ properties: {
662
+ active: true,
663
+ model: stepInstanceSysId,
664
+ model_id: stepInstanceSysId,
665
+ model_table: 'sys_hub_step_instance',
666
+ name: `var__m_sys_hub_step_ext_output_${stepInstanceSysId}`,
667
+ element: columnName,
668
+ label: columnLabel || columnName,
669
+ internal_type: internalType,
670
+ mandatory: mandatory,
671
+ ...(maxLength != null ? { max_length: maxLength } : {}),
672
+ ...(hint ? { hint } : {}),
673
+ ...(defaultValue ? { default_value: defaultValue } : {}),
674
+ attributes: (0, flow_constants_1.buildExtVarAttributes)(internalType),
675
+ },
676
+ });
677
+ extendedOutputRecords.push(extOutputRecord);
678
+ }
312
679
  }
313
680
  }
314
- return updatedStepInstanceRecord.with(...variableValueRecords, ...extendedInputRecords, ...extendedVariableValueRecords, ...extendedOutputRecords);
681
+ return updatedStepInstanceRecord.with(...stepDataRecords, ...extendedInputRecords, ...extendedVariableValueRecords, ...extendedOutputRecords, ...complexObjectRecords);
315
682
  }
316
- async function createVariableRecords(values, inputs, factory, callExpression, stepInstanceSysId) {
317
- const properties = values.properties();
683
+ async function createVariableRecords(valuesProperties, inputs, factory, callExpression, stepInstanceSysId, stepDefinitionSysId, cidMap) {
318
684
  // Filter out inputVariables, outputVariables and errorHandlingType as they are handled separately
319
- const filteredEntries = Object.entries(properties).filter(([key]) => key !== 'inputVariables' && key !== 'outputVariables' && key !== 'errorHandlingType');
320
- return await Promise.all(filteredEntries.map(([key, valueShape]) => {
685
+ const filteredEntries = Object.entries(valuesProperties).filter(([key]) => key !== 'inputVariables' && key !== 'outputVariables' && key !== 'errorHandlingType');
686
+ // Build reverse lookup (elementName → varSysId) from BUILT_IN_STEP_DEFINITIONS
687
+ const builtInDef = flow_constants_1.BUILT_IN_STEP_DEFINITIONS[stepDefinitionSysId];
688
+ const elementToVarSysId = {};
689
+ if (builtInDef) {
690
+ for (const [varSysId, entry] of Object.entries(builtInDef.inputs)) {
691
+ elementToVarSysId[(0, flow_constants_1.getVarEntryName)(entry)] = varSysId;
692
+ }
693
+ for (const [varSysId, entry] of Object.entries(builtInDef.outputs)) {
694
+ elementToVarSysId[(0, flow_constants_1.getVarEntryName)(entry)] = varSysId;
695
+ }
696
+ }
697
+ const pillTypeMap = callExpression.getPillTypeMap();
698
+ const allRecords = [];
699
+ await Promise.all(filteredEntries.map(async ([key, valueShape]) => {
700
+ // Try resolving from inputDefinitions shape first, then fall back to built-in map
701
+ let variableSysId = '';
321
702
  const input = inputs?.get(key);
322
- const variableSysId = input instanceof sdk_build_core_1.CallExpressionShape
323
- ? input.getArgument(0).asObject().get('sysId')?.getValue()
324
- : '';
325
- const actualValue = valueShape.getValue?.() ?? valueShape.toString();
326
- return factory.createRecord({
703
+ if (input instanceof sdk_build_core_1.CallExpressionShape) {
704
+ variableSysId = input.getArgument(0).asObject().get('sysId')?.getValue() ?? '';
705
+ }
706
+ if (!variableSysId) {
707
+ variableSysId = elementToVarSysId[key] ?? '';
708
+ }
709
+ // ApprovalDueDateShape: store JSON in sys_element_mapping.value (ServiceNow reads from there)
710
+ // and create sys_variable_value with empty value
711
+ if (valueShape.is(flow_shapes_1.ApprovalDueDateShape)) {
712
+ const jsonValue = valueShape.toString().getValue();
713
+ const [elementMappingRecord, variableValueRecord] = await Promise.all([
714
+ factory.createRecord({
715
+ source: callExpression,
716
+ table: 'sys_element_mapping',
717
+ properties: {
718
+ field: key,
719
+ id: stepInstanceSysId,
720
+ table: `var__m_sys_flow_step_definition_input_${stepDefinitionSysId}`,
721
+ value: jsonValue,
722
+ },
723
+ }),
724
+ factory.createRecord({
725
+ source: callExpression,
726
+ table: 'sys_variable_value',
727
+ properties: {
728
+ document: 'sys_hub_step_instance',
729
+ document_key: stepInstanceSysId,
730
+ order: 100,
731
+ // value intentionally empty: ServiceNow reads due_date JSON from sys_element_mapping, not here
732
+ value: '',
733
+ variable: variableSysId,
734
+ },
735
+ }),
736
+ ]);
737
+ allRecords.push(elementMappingRecord, variableValueRecord);
738
+ return;
739
+ }
740
+ // Handle TemplateValueShape specially - serialize to ServiceNow format.
741
+ // When TemplateValue contains datapills, the platform stores the entire encoded string
742
+ // (with pills inline) in a single sys_element_mapping record with field=<parent input name>.
743
+ let actualValue;
744
+ if (valueShape.is(sdk_build_core_1.TemplateValueShape)) {
745
+ const templateObj = valueShape.getTemplateValue();
746
+ const entries = [];
747
+ let hasPills = false;
748
+ for (const [field, fieldShape] of templateObj.entries({ resolve: false })) {
749
+ const pillString = resolveFieldToPillString(fieldShape, cidMap);
750
+ if (pillString) {
751
+ collectPillTypes(pillString, pillTypeMap);
752
+ entries.push(`${field}=${stripPillType(pillString)}`);
753
+ hasPills = true;
754
+ }
755
+ else if (fieldShape.is(sdk_build_core_1.TemplateExpressionShape)) {
756
+ const resolved = resolveTemplateExpression(fieldShape, cidMap, pillTypeMap);
757
+ if (resolved.hasPills) {
758
+ hasPills = true;
759
+ }
760
+ const escapedValue = resolved.result.replace(/\^/g, '^^');
761
+ entries.push(`${field}=${escapedValue}`);
762
+ }
763
+ else {
764
+ const resolved = fieldShape.getValue();
765
+ const escapedValue = String(resolved).replace(/\^/g, '^^');
766
+ entries.push(`${field}=${escapedValue}`);
767
+ }
768
+ }
769
+ const encodedValue = entries.join('^');
770
+ if (hasPills) {
771
+ // TemplateValue with datapills → single sys_element_mapping record
772
+ // No sys_variable_value for this field — platform reads from element_mapping only
773
+ allRecords.push(await factory.createRecord({
774
+ source: callExpression,
775
+ table: 'sys_element_mapping',
776
+ properties: {
777
+ field: key,
778
+ id: stepInstanceSysId,
779
+ table: `var__m_sys_flow_step_definition_input_${stepDefinitionSysId}`,
780
+ value: encodedValue,
781
+ },
782
+ }));
783
+ return;
784
+ }
785
+ // No datapills — standard encoded string in sys_variable_value
786
+ actualValue = encodedValue ? `${encodedValue}^EQ` : '';
787
+ }
788
+ else if (valueShape.is(sdk_build_core_1.DurationShape)) {
789
+ // DurationShape.getValue() returns a symbol, so use toString() instead
790
+ actualValue = valueShape.toString().getValue();
791
+ }
792
+ else if (valueShape.is(flow_shapes_1.ApprovalRulesShape)) {
793
+ // ApprovalRulesShape.getValue() returns a JSON object, not a string.
794
+ // Previously fell through to the generic getValue() path which stored a raw [object Object].
795
+ // toString() correctly serializes it to the JSON string ServiceNow expects.
796
+ actualValue = valueShape.toString().getValue();
797
+ }
798
+ else if (valueShape.is(sdk_build_core_1.TemplateExpressionShape)) {
799
+ const { result, hasPills } = resolveTemplateExpression(valueShape, cidMap, pillTypeMap);
800
+ if (hasPills) {
801
+ allRecords.push(await factory.createRecord({
802
+ source: callExpression,
803
+ table: 'sys_element_mapping',
804
+ properties: {
805
+ field: key,
806
+ id: stepInstanceSysId,
807
+ table: `var__m_sys_flow_step_definition_input_${stepDefinitionSysId}`,
808
+ value: result,
809
+ },
810
+ }));
811
+ return;
812
+ }
813
+ actualValue = result;
814
+ }
815
+ else {
816
+ // Check if it's a wfa.dataPill() CallExpressionShape (step output reference)
817
+ // that needs to be resolved to a pill string for sys_element_mapping
818
+ const pillString = resolveFieldToPillString(valueShape, cidMap);
819
+ if (pillString) {
820
+ collectPillTypes(pillString, pillTypeMap);
821
+ allRecords.push(await factory.createRecord({
822
+ source: callExpression,
823
+ table: 'sys_element_mapping',
824
+ properties: {
825
+ field: key,
826
+ id: stepInstanceSysId,
827
+ table: `var__m_sys_flow_step_definition_input_${stepDefinitionSysId}`,
828
+ value: stripPillType(pillString),
829
+ },
830
+ }));
831
+ return;
832
+ }
833
+ const rawValue = valueShape.getValue?.();
834
+ // Guard against symbol values (e.g., DurationShape, unresolved shapes with { resolve: false })
835
+ // since factory.createRecord cannot serialize symbols. Fall back to empty string.
836
+ actualValue = typeof rawValue === 'symbol' ? '' : (rawValue ?? '');
837
+ }
838
+ const record = await factory.createRecord({
327
839
  source: callExpression,
328
840
  table: 'sys_variable_value',
329
841
  properties: {
@@ -334,6 +846,8 @@ async function createVariableRecords(values, inputs, factory, callExpression, st
334
846
  variable: variableSysId,
335
847
  },
336
848
  });
849
+ allRecords.push(record);
337
850
  }));
851
+ return allRecords;
338
852
  }
339
853
  //# sourceMappingURL=step-instance-plugin.js.map