@servicenow/sdk-build-plugins 4.2.0 → 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 (330) hide show
  1. package/dist/acl-plugin.js +9 -0
  2. package/dist/acl-plugin.js.map +1 -1
  3. package/dist/applicability-plugin.d.ts +2 -0
  4. package/dist/applicability-plugin.js +72 -0
  5. package/dist/applicability-plugin.js.map +1 -0
  6. package/dist/atf/test-plugin.js +5 -2
  7. package/dist/atf/test-plugin.js.map +1 -1
  8. package/dist/basic-syntax-plugin.js +7 -1
  9. package/dist/basic-syntax-plugin.js.map +1 -1
  10. package/dist/business-rule-plugin.js +1 -0
  11. package/dist/business-rule-plugin.js.map +1 -1
  12. package/dist/call-expression-plugin.js +1 -107
  13. package/dist/call-expression-plugin.js.map +1 -1
  14. package/dist/column-plugin.js +1 -1
  15. package/dist/column-plugin.js.map +1 -1
  16. package/dist/dashboard/dashboard-component-property-defaults.d.ts +152 -0
  17. package/dist/dashboard/dashboard-component-property-defaults.js +264 -0
  18. package/dist/dashboard/dashboard-component-property-defaults.js.map +1 -0
  19. package/dist/dashboard/dashboard-component-resolver.d.ts +13 -0
  20. package/dist/dashboard/dashboard-component-resolver.js +69 -0
  21. package/dist/dashboard/dashboard-component-resolver.js.map +1 -0
  22. package/dist/dashboard/dashboard-plugin.d.ts +12 -0
  23. package/dist/dashboard/dashboard-plugin.js +397 -0
  24. package/dist/dashboard/dashboard-plugin.js.map +1 -0
  25. package/dist/data-plugin.d.ts +3 -0
  26. package/dist/data-plugin.js +61 -113
  27. package/dist/data-plugin.js.map +1 -1
  28. package/dist/email-notification-plugin.d.ts +2 -0
  29. package/dist/email-notification-plugin.js +541 -0
  30. package/dist/email-notification-plugin.js.map +1 -0
  31. package/dist/flow/constants/flow-plugin-constants.d.ts +58 -0
  32. package/dist/flow/constants/flow-plugin-constants.js +70 -0
  33. package/dist/flow/constants/flow-plugin-constants.js.map +1 -0
  34. package/dist/flow/flow-logic/flow-logic-constants.d.ts +38 -0
  35. package/dist/flow/flow-logic/flow-logic-constants.js +118 -0
  36. package/dist/flow/flow-logic/flow-logic-constants.js.map +1 -0
  37. package/dist/flow/flow-logic/flow-logic-diagnostics.d.ts +19 -0
  38. package/dist/flow/flow-logic/flow-logic-diagnostics.js +503 -0
  39. package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -0
  40. package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +62 -0
  41. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +2092 -0
  42. package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -0
  43. package/dist/flow/flow-logic/flow-logic-plugin.d.ts +52 -0
  44. package/dist/flow/flow-logic/flow-logic-plugin.js +283 -0
  45. package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -0
  46. package/dist/flow/flow-logic/flow-logic-shapes.d.ts +104 -0
  47. package/dist/flow/flow-logic/flow-logic-shapes.js +201 -0
  48. package/dist/flow/flow-logic/flow-logic-shapes.js.map +1 -0
  49. package/dist/flow/plugins/approval-rules-plugin.d.ts +2 -0
  50. package/dist/flow/plugins/approval-rules-plugin.js +49 -0
  51. package/dist/flow/plugins/approval-rules-plugin.js.map +1 -0
  52. package/dist/flow/plugins/flow-action-definition-plugin.d.ts +2 -0
  53. package/dist/flow/plugins/flow-action-definition-plugin.js +286 -0
  54. package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -0
  55. package/dist/flow/plugins/flow-data-pill-plugin.d.ts +9 -0
  56. package/dist/flow/plugins/flow-data-pill-plugin.js +212 -0
  57. package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -0
  58. package/dist/flow/plugins/flow-definition-plugin.d.ts +2 -0
  59. package/dist/flow/plugins/flow-definition-plugin.js +1668 -0
  60. package/dist/flow/plugins/flow-definition-plugin.js.map +1 -0
  61. package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +26 -0
  62. package/dist/flow/plugins/flow-diagnostics-plugin.js +217 -0
  63. package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -0
  64. package/dist/flow/plugins/flow-instance-plugin.d.ts +12 -0
  65. package/dist/flow/plugins/flow-instance-plugin.js +930 -0
  66. package/dist/flow/plugins/flow-instance-plugin.js.map +1 -0
  67. package/dist/flow/plugins/flow-trigger-instance-plugin.d.ts +2 -0
  68. package/dist/flow/plugins/flow-trigger-instance-plugin.js +324 -0
  69. package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -0
  70. package/dist/flow/plugins/inline-script-plugin.d.ts +39 -0
  71. package/dist/flow/plugins/inline-script-plugin.js +80 -0
  72. package/dist/flow/plugins/inline-script-plugin.js.map +1 -0
  73. package/dist/flow/plugins/step-definition-plugin.d.ts +5 -0
  74. package/dist/flow/plugins/step-definition-plugin.js +71 -0
  75. package/dist/flow/plugins/step-definition-plugin.js.map +1 -0
  76. package/dist/flow/plugins/step-instance-plugin.d.ts +31 -0
  77. package/dist/flow/plugins/step-instance-plugin.js +339 -0
  78. package/dist/flow/plugins/step-instance-plugin.js.map +1 -0
  79. package/dist/flow/plugins/trigger-plugin.d.ts +2 -0
  80. package/dist/flow/plugins/trigger-plugin.js +96 -0
  81. package/dist/flow/plugins/trigger-plugin.js.map +1 -0
  82. package/dist/flow/plugins/wfa-datapill-plugin.d.ts +15 -0
  83. package/dist/flow/plugins/wfa-datapill-plugin.js +178 -0
  84. package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -0
  85. package/dist/flow/utils/approval-rules-processor.d.ts +13 -0
  86. package/dist/flow/utils/approval-rules-processor.js +267 -0
  87. package/dist/flow/utils/approval-rules-processor.js.map +1 -0
  88. package/dist/flow/utils/built-in-complex-objects.d.ts +19 -0
  89. package/dist/flow/utils/built-in-complex-objects.js +62 -0
  90. package/dist/flow/utils/built-in-complex-objects.js.map +1 -0
  91. package/dist/flow/utils/complex-object-resolver.d.ts +8 -0
  92. package/dist/flow/utils/complex-object-resolver.js +614 -0
  93. package/dist/flow/utils/complex-object-resolver.js.map +1 -0
  94. package/dist/flow/utils/complex-objects.d.ts +36 -0
  95. package/dist/flow/utils/complex-objects.js +481 -0
  96. package/dist/flow/utils/complex-objects.js.map +1 -0
  97. package/dist/flow/utils/data-pill-shapes.d.ts +58 -0
  98. package/dist/flow/utils/data-pill-shapes.js +135 -0
  99. package/dist/flow/utils/data-pill-shapes.js.map +1 -0
  100. package/dist/flow/utils/datapill-transformer.d.ts +110 -0
  101. package/dist/flow/utils/datapill-transformer.js +503 -0
  102. package/dist/flow/utils/datapill-transformer.js.map +1 -0
  103. package/dist/flow/utils/flow-constants.d.ts +65 -0
  104. package/dist/flow/utils/flow-constants.js +223 -0
  105. package/dist/flow/utils/flow-constants.js.map +1 -0
  106. package/dist/flow/utils/flow-io-to-record.d.ts +44 -0
  107. package/dist/flow/utils/flow-io-to-record.js +409 -0
  108. package/dist/flow/utils/flow-io-to-record.js.map +1 -0
  109. package/dist/flow/utils/flow-shapes.d.ts +161 -0
  110. package/dist/flow/utils/flow-shapes.js +255 -0
  111. package/dist/flow/utils/flow-shapes.js.map +1 -0
  112. package/dist/flow/utils/flow-to-xml.d.ts +16 -0
  113. package/dist/flow/utils/flow-to-xml.js +237 -0
  114. package/dist/flow/utils/flow-to-xml.js.map +1 -0
  115. package/dist/flow/utils/flow-variable-processor.d.ts +51 -0
  116. package/dist/flow/utils/flow-variable-processor.js +69 -0
  117. package/dist/flow/utils/flow-variable-processor.js.map +1 -0
  118. package/dist/flow/utils/label-cache-parser.d.ts +7 -0
  119. package/dist/flow/utils/label-cache-parser.js +24 -0
  120. package/dist/flow/utils/label-cache-parser.js.map +1 -0
  121. package/dist/flow/utils/label-cache-processor.d.ts +119 -0
  122. package/dist/flow/utils/label-cache-processor.js +719 -0
  123. package/dist/flow/utils/label-cache-processor.js.map +1 -0
  124. package/dist/flow/utils/pill-string-parser.d.ts +88 -0
  125. package/dist/flow/utils/pill-string-parser.js +306 -0
  126. package/dist/flow/utils/pill-string-parser.js.map +1 -0
  127. package/dist/flow/utils/schema-to-flow-object.d.ts +22 -0
  128. package/dist/flow/utils/schema-to-flow-object.js +318 -0
  129. package/dist/flow/utils/schema-to-flow-object.js.map +1 -0
  130. package/dist/flow/utils/utils.d.ts +117 -0
  131. package/dist/flow/utils/utils.js +345 -0
  132. package/dist/flow/utils/utils.js.map +1 -0
  133. package/dist/index.d.ts +20 -1
  134. package/dist/index.js +21 -1
  135. package/dist/index.js.map +1 -1
  136. package/dist/list-plugin.js +1 -1
  137. package/dist/list-plugin.js.map +1 -1
  138. package/dist/now-attach-plugin.d.ts +1 -0
  139. package/dist/now-attach-plugin.js +3 -0
  140. package/dist/now-attach-plugin.js.map +1 -1
  141. package/dist/record-plugin.d.ts +29 -0
  142. package/dist/record-plugin.js +66 -7
  143. package/dist/record-plugin.js.map +1 -1
  144. package/dist/repack/index.d.ts +2 -0
  145. package/dist/repack/index.js +8 -0
  146. package/dist/repack/index.js.map +1 -1
  147. package/dist/rest-api-plugin.js +54 -44
  148. package/dist/rest-api-plugin.js.map +1 -1
  149. package/dist/server-module-plugin/index.js +38 -4
  150. package/dist/server-module-plugin/index.js.map +1 -1
  151. package/dist/service-catalog/catalog-clientscript-plugin.d.ts +2 -0
  152. package/dist/service-catalog/catalog-clientscript-plugin.js +117 -0
  153. package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -0
  154. package/dist/service-catalog/catalog-item-plugin.d.ts +2 -0
  155. package/dist/service-catalog/catalog-item-plugin.js +115 -0
  156. package/dist/service-catalog/catalog-item-plugin.js.map +1 -0
  157. package/dist/service-catalog/catalog-ui-policy-plugin.d.ts +2 -0
  158. package/dist/service-catalog/catalog-ui-policy-plugin.js +266 -0
  159. package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -0
  160. package/dist/service-catalog/index.d.ts +5 -0
  161. package/dist/service-catalog/index.js +22 -0
  162. package/dist/service-catalog/index.js.map +1 -0
  163. package/dist/service-catalog/record-to-shape.d.ts +6 -0
  164. package/dist/service-catalog/record-to-shape.js +93 -0
  165. package/dist/service-catalog/record-to-shape.js.map +1 -0
  166. package/dist/service-catalog/sc-record-producer-plugin.d.ts +2 -0
  167. package/dist/service-catalog/sc-record-producer-plugin.js +139 -0
  168. package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -0
  169. package/dist/service-catalog/service-catalog-base.d.ts +311 -0
  170. package/dist/service-catalog/service-catalog-base.js +542 -0
  171. package/dist/service-catalog/service-catalog-base.js.map +1 -0
  172. package/dist/service-catalog/service-catalog-diagnostics.d.ts +45 -0
  173. package/dist/service-catalog/service-catalog-diagnostics.js +169 -0
  174. package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -0
  175. package/dist/service-catalog/shape-to-record.d.ts +7 -0
  176. package/dist/service-catalog/shape-to-record.js +232 -0
  177. package/dist/service-catalog/shape-to-record.js.map +1 -0
  178. package/dist/service-catalog/utils.d.ts +313 -0
  179. package/dist/service-catalog/utils.js +1144 -0
  180. package/dist/service-catalog/utils.js.map +1 -0
  181. package/dist/service-catalog/variable-helper.d.ts +43 -0
  182. package/dist/service-catalog/variable-helper.js +92 -0
  183. package/dist/service-catalog/variable-helper.js.map +1 -0
  184. package/dist/service-catalog/variable-set-plugin.d.ts +2 -0
  185. package/dist/service-catalog/variable-set-plugin.js +175 -0
  186. package/dist/service-catalog/variable-set-plugin.js.map +1 -0
  187. package/dist/service-catalog/variables-transform.d.ts +139 -0
  188. package/dist/service-catalog/variables-transform.js +403 -0
  189. package/dist/service-catalog/variables-transform.js.map +1 -0
  190. package/dist/sla/sla-validators.d.ts +61 -0
  191. package/dist/sla/sla-validators.js +224 -0
  192. package/dist/sla/sla-validators.js.map +1 -0
  193. package/dist/sla-plugin.d.ts +5 -0
  194. package/dist/sla-plugin.js +280 -0
  195. package/dist/sla-plugin.js.map +1 -0
  196. package/dist/table-plugin.js +16 -2
  197. package/dist/table-plugin.js.map +1 -1
  198. package/dist/ui-policy-plugin.js +5 -7
  199. package/dist/ui-policy-plugin.js.map +1 -1
  200. package/dist/utils.d.ts +10 -1
  201. package/dist/utils.js +16 -0
  202. package/dist/utils.js.map +1 -1
  203. package/dist/ux-list-menu-config-plugin.d.ts +2 -0
  204. package/dist/ux-list-menu-config-plugin.js +292 -0
  205. package/dist/ux-list-menu-config-plugin.js.map +1 -0
  206. package/dist/workspace-plugin/chrome-tab.d.ts +2 -0
  207. package/dist/workspace-plugin/chrome-tab.js +46 -0
  208. package/dist/workspace-plugin/chrome-tab.js.map +1 -0
  209. package/dist/workspace-plugin/constants.d.ts +52 -0
  210. package/dist/workspace-plugin/constants.js +56 -0
  211. package/dist/workspace-plugin/constants.js.map +1 -0
  212. package/dist/workspace-plugin/fluent-utils.d.ts +9 -0
  213. package/dist/workspace-plugin/fluent-utils.js +60 -0
  214. package/dist/workspace-plugin/fluent-utils.js.map +1 -0
  215. package/dist/workspace-plugin/page.d.ts +8 -0
  216. package/dist/workspace-plugin/page.js +108 -0
  217. package/dist/workspace-plugin/page.js.map +1 -0
  218. package/dist/workspace-plugin/screen.d.ts +1 -0
  219. package/dist/workspace-plugin/screen.js +38 -0
  220. package/dist/workspace-plugin/screen.js.map +1 -0
  221. package/dist/workspace-plugin/templates/index.d.ts +10 -0
  222. package/dist/workspace-plugin/templates/index.js +20 -0
  223. package/dist/workspace-plugin/templates/index.js.map +1 -0
  224. package/dist/workspace-plugin/templates/record-page-composition.d.ts +1 -0
  225. package/dist/workspace-plugin/templates/record-page-composition.js +4043 -0
  226. package/dist/workspace-plugin/templates/record-page-composition.js.map +1 -0
  227. package/dist/workspace-plugin/templates/record-page-data.d.ts +1 -0
  228. package/dist/workspace-plugin/templates/record-page-data.js +527 -0
  229. package/dist/workspace-plugin/templates/record-page-data.js.map +1 -0
  230. package/dist/workspace-plugin/templates/record-page-interalEventMappings.d.ts +1 -0
  231. package/dist/workspace-plugin/templates/record-page-interalEventMappings.js +39 -0
  232. package/dist/workspace-plugin/templates/record-page-interalEventMappings.js.map +1 -0
  233. package/dist/workspace-plugin/templates/record-page-layoutModel.d.ts +1 -0
  234. package/dist/workspace-plugin/templates/record-page-layoutModel.js +55 -0
  235. package/dist/workspace-plugin/templates/record-page-layoutModel.js.map +1 -0
  236. package/dist/workspace-plugin/templates/record-page-properties.d.ts +1 -0
  237. package/dist/workspace-plugin/templates/record-page-properties.js +135 -0
  238. package/dist/workspace-plugin/templates/record-page-properties.js.map +1 -0
  239. package/dist/workspace-plugin/templates/record-page.d.ts +3 -0
  240. package/dist/workspace-plugin/templates/record-page.js +8 -0
  241. package/dist/workspace-plugin/templates/record-page.js.map +1 -0
  242. package/dist/workspace-plugin.d.ts +2 -0
  243. package/dist/workspace-plugin.js +453 -0
  244. package/dist/workspace-plugin.js.map +1 -0
  245. package/package.json +10 -12
  246. package/src/acl-plugin.ts +14 -1
  247. package/src/applicability-plugin.ts +82 -0
  248. package/src/atf/test-plugin.ts +6 -3
  249. package/src/basic-syntax-plugin.ts +10 -1
  250. package/src/business-rule-plugin.ts +2 -1
  251. package/src/call-expression-plugin.ts +2 -130
  252. package/src/column-plugin.ts +1 -1
  253. package/src/dashboard/dashboard-component-property-defaults.ts +277 -0
  254. package/src/dashboard/dashboard-component-resolver.ts +69 -0
  255. package/src/dashboard/dashboard-plugin.ts +450 -0
  256. package/src/data-plugin.ts +67 -139
  257. package/src/email-notification-plugin.ts +850 -0
  258. package/src/flow/constants/flow-plugin-constants.ts +79 -0
  259. package/src/flow/flow-logic/flow-logic-constants.ts +120 -0
  260. package/src/flow/flow-logic/flow-logic-diagnostics.ts +591 -0
  261. package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +2550 -0
  262. package/src/flow/flow-logic/flow-logic-plugin.ts +337 -0
  263. package/src/flow/flow-logic/flow-logic-shapes.ts +215 -0
  264. package/src/flow/plugins/approval-rules-plugin.ts +48 -0
  265. package/src/flow/plugins/flow-action-definition-plugin.ts +295 -0
  266. package/src/flow/plugins/flow-data-pill-plugin.ts +258 -0
  267. package/src/flow/plugins/flow-definition-plugin.ts +2173 -0
  268. package/src/flow/plugins/flow-diagnostics-plugin.ts +280 -0
  269. package/src/flow/plugins/flow-instance-plugin.ts +1148 -0
  270. package/src/flow/plugins/flow-trigger-instance-plugin.ts +426 -0
  271. package/src/flow/plugins/inline-script-plugin.ts +83 -0
  272. package/src/flow/plugins/step-definition-plugin.ts +67 -0
  273. package/src/flow/plugins/step-instance-plugin.ts +431 -0
  274. package/src/flow/plugins/trigger-plugin.ts +95 -0
  275. package/src/flow/plugins/wfa-datapill-plugin.ts +213 -0
  276. package/src/flow/utils/approval-rules-processor.ts +298 -0
  277. package/src/flow/utils/built-in-complex-objects.ts +81 -0
  278. package/src/flow/utils/complex-object-resolver.ts +875 -0
  279. package/src/flow/utils/complex-objects.ts +656 -0
  280. package/src/flow/utils/data-pill-shapes.ts +165 -0
  281. package/src/flow/utils/datapill-transformer.ts +632 -0
  282. package/src/flow/utils/flow-constants.ts +276 -0
  283. package/src/flow/utils/flow-io-to-record.ts +533 -0
  284. package/src/flow/utils/flow-shapes.ts +296 -0
  285. package/src/flow/utils/flow-to-xml.ts +318 -0
  286. package/src/flow/utils/flow-variable-processor.ts +100 -0
  287. package/src/flow/utils/label-cache-parser.ts +37 -0
  288. package/src/flow/utils/label-cache-processor.ts +870 -0
  289. package/src/flow/utils/pill-string-parser.ts +375 -0
  290. package/src/flow/utils/schema-to-flow-object.ts +385 -0
  291. package/src/flow/utils/utils.ts +395 -0
  292. package/src/index.ts +21 -1
  293. package/src/list-plugin.ts +1 -1
  294. package/src/now-attach-plugin.ts +4 -0
  295. package/src/record-plugin.ts +76 -11
  296. package/src/repack/index.ts +14 -0
  297. package/src/rest-api-plugin.ts +62 -50
  298. package/src/server-module-plugin/index.ts +53 -17
  299. package/src/service-catalog/catalog-clientscript-plugin.ts +140 -0
  300. package/src/service-catalog/catalog-item-plugin.ts +162 -0
  301. package/src/service-catalog/catalog-ui-policy-plugin.ts +324 -0
  302. package/src/service-catalog/index.ts +5 -0
  303. package/src/service-catalog/record-to-shape.ts +109 -0
  304. package/src/service-catalog/sc-record-producer-plugin.ts +201 -0
  305. package/src/service-catalog/service-catalog-base.ts +600 -0
  306. package/src/service-catalog/service-catalog-diagnostics.ts +251 -0
  307. package/src/service-catalog/shape-to-record.ts +275 -0
  308. package/src/service-catalog/utils.ts +1362 -0
  309. package/src/service-catalog/variable-helper.ts +135 -0
  310. package/src/service-catalog/variable-set-plugin.ts +197 -0
  311. package/src/service-catalog/variables-transform.ts +438 -0
  312. package/src/sla/sla-validators.ts +331 -0
  313. package/src/sla-plugin.ts +358 -0
  314. package/src/table-plugin.ts +19 -2
  315. package/src/ui-policy-plugin.ts +5 -9
  316. package/src/utils.ts +24 -1
  317. package/src/ux-list-menu-config-plugin.ts +312 -0
  318. package/src/workspace-plugin/chrome-tab.ts +44 -0
  319. package/src/workspace-plugin/constants.ts +53 -0
  320. package/src/workspace-plugin/fluent-utils.ts +60 -0
  321. package/src/workspace-plugin/page.ts +139 -0
  322. package/src/workspace-plugin/screen.ts +34 -0
  323. package/src/workspace-plugin/templates/index.ts +17 -0
  324. package/src/workspace-plugin/templates/record-page-composition.ts +4051 -0
  325. package/src/workspace-plugin/templates/record-page-data.ts +523 -0
  326. package/src/workspace-plugin/templates/record-page-interalEventMappings.ts +35 -0
  327. package/src/workspace-plugin/templates/record-page-layoutModel.ts +51 -0
  328. package/src/workspace-plugin/templates/record-page-properties.ts +131 -0
  329. package/src/workspace-plugin/templates/record-page.ts +6 -0
  330. package/src/workspace-plugin.ts +574 -0
@@ -0,0 +1,426 @@
1
+ import {
2
+ CallExpressionShape,
3
+ DurationShape,
4
+ IdentifierShape,
5
+ ObjectShape,
6
+ Plugin,
7
+ StringShape,
8
+ TimeShape,
9
+ UnresolvedShape,
10
+ } from '@servicenow/sdk-build-core'
11
+ import { normalizeInputValue } from './flow-instance-plugin'
12
+ import { NowIdShape } from '../../now-id-plugin'
13
+ import { gunzipSync, gzipSync } from 'node:zlib'
14
+ import { COLUMN_API_TO_TYPE } from '../../column/column-helper'
15
+ import {
16
+ TRIGGER_INSTANCE_API_NAME,
17
+ TRIGGER_TYPE_KEY_NAME,
18
+ RUN_ON_EXTENDED,
19
+ TIME_DATA_TYPE_VALUE,
20
+ DURATION_DATA_TYPE_VALUE,
21
+ } from '../utils/flow-constants'
22
+ import { DAY_OF_WEEK_DISPLAY_MAP } from '../constants/flow-plugin-constants'
23
+ import { isArray } from 'lodash'
24
+
25
+ export const TriggerInstancePlugin = Plugin.create({
26
+ name: 'TriggerInstancePlugin',
27
+ records: {
28
+ sys_hub_trigger_instance_v2: {
29
+ toShape(record, { logger }) {
30
+ const gzStr = record.get('trigger_inputs').as(StringShape).getValue()
31
+ const inputsObj: globalThis.Record<string, unknown> = {}
32
+
33
+ try {
34
+ const arr = JSON.parse(gunzipSync(Buffer.from(gzStr, 'base64')).toString('utf8')) as Array<{
35
+ name: string
36
+ value: string
37
+ parameter: {
38
+ type: string
39
+ attributes: Record<string, unknown>
40
+ }
41
+ }>
42
+
43
+ for (const { name, value, parameter } of arr) {
44
+ const visibleAttr = parameter?.attributes?.['visible'] as string | undefined
45
+ const visibleInFdAttr = parameter?.attributes?.['visible_in_fd'] as string | undefined
46
+ const isHidden = visibleAttr === 'false' || visibleInFdAttr === 'false'
47
+ // Skip hidden fields during transformation
48
+ if (isHidden) {
49
+ continue
50
+ }
51
+ // Safely extract uiType, guarding against missing parameter or attributes
52
+ const uiType = (parameter?.attributes?.['uiType'] ?? parameter?.type) as string | undefined
53
+ if (name === RUN_ON_EXTENDED) {
54
+ inputsObj[name] = value // As this is a choice value, we don't need to normalize it. It should remain as a string. Keep it as 'true' or 'false'
55
+ } else {
56
+ inputsObj[name] = normalizeInputValue(value, uiType, record, logger)
57
+ }
58
+ }
59
+ } catch (err: unknown) {
60
+ logger.error(`Corrupt data in trigger instance ${err} in flow ${record.get('flow').getValue()}`)
61
+ throw new Error('Corrupt data in trigger instance')
62
+ }
63
+
64
+ //Check if it is a custom trigger - Custom triggers will have trigger_type attribute in the trigger inputs
65
+ if (inputsObj[TRIGGER_TYPE_KEY_NAME]) {
66
+ logger.warn('Customer trigger types are not supported')
67
+ return { success: false }
68
+ }
69
+
70
+ let triggerIdentifier: IdentifierShape | undefined
71
+ const triggerType = record.get('trigger_type')?.getValue()
72
+
73
+ // Map sys_hub_trigger_instance_v2.trigger_type values to the corresponding
74
+ // `*.now.ts` TriggerDefinition identifier exported from /automation
75
+
76
+ // This allows round-tripping of triggers beyond simple "record_create" events.
77
+ const triggerMap: Record<string, string> = {
78
+ // Record based triggers
79
+ record_create: 'trigger.record.created',
80
+ record_update: 'trigger.record.updated',
81
+ record_create_or_update: 'trigger.record.createdOrUpdated',
82
+
83
+ // SLA triggers
84
+ daily: 'trigger.scheduled.daily',
85
+ weekly: 'trigger.scheduled.weekly',
86
+ monthly: 'trigger.scheduled.monthly',
87
+ repeat: 'trigger.scheduled.repeat',
88
+ run_once: 'trigger.scheduled.runOnce',
89
+
90
+ // Application triggers
91
+ email: 'trigger.application.inboundEmail',
92
+ // service_catalog: 'trigger.application.serviceCatalog',
93
+ remote_table_query: 'trigger.application.remoteTableQuery',
94
+ sla_task: 'trigger.application.slaTask',
95
+ knowledge_management: 'trigger.application.knowledgeManagement',
96
+ }
97
+
98
+ const identifierName = triggerMap[triggerType as string]
99
+ if (identifierName) {
100
+ triggerIdentifier = new IdentifierShape({ source: record, name: identifierName })
101
+ } else {
102
+ logger.warn(`Unsupported trigger type = ${triggerType}, falling back to Record() API`)
103
+ return { success: false }
104
+ }
105
+
106
+ // New 3-argument pattern: wfa.trigger(triggerDefinition, { $id }, inputs)
107
+ return {
108
+ success: true,
109
+ value: new CallExpressionShape({
110
+ source: record,
111
+ callee: TRIGGER_INSTANCE_API_NAME,
112
+ args: [
113
+ // Arg 0: Trigger definition identifier
114
+ triggerIdentifier,
115
+ // Arg 1: Config object with $id and annotation
116
+ record.transform(({ $ }) => ({
117
+ $id: $.val(NowIdShape.from(record)),
118
+ annotation: $.from('comment').def(''),
119
+ })),
120
+ // Arg 2: Inputs object
121
+ new ObjectShape({ source: record, properties: inputsObj }),
122
+ ],
123
+ }),
124
+ }
125
+ },
126
+ },
127
+ },
128
+ shapes: [
129
+ {
130
+ shape: CallExpressionShape,
131
+ fileTypes: ['fluent'],
132
+ async toRecord(callExpression, { factory, diagnostics }) {
133
+ if (callExpression.getCallee() !== TRIGGER_INSTANCE_API_NAME) {
134
+ return { success: false }
135
+ }
136
+
137
+ // New 3-argument pattern: wfa.trigger(triggerDefinition, { $id }, inputs)
138
+ // Arg 0: Trigger definition (IdentifierShape or CallExpressionShape)
139
+ // Arg 1: Config object with $id
140
+ // Arg 2: Inputs object
141
+ const triggerShape = callExpression.getArgument(0)
142
+ const configObject = callExpression.getArgument(1)?.asObject()
143
+ const triggerInputs = callExpression.getArgument(2)?.asObject()
144
+
145
+ if (!configObject || !triggerInputs) {
146
+ diagnostics.error(
147
+ callExpression,
148
+ 'Trigger instance requires 3 arguments: triggerDefinition, config, and inputs'
149
+ )
150
+ return { success: false }
151
+ }
152
+
153
+ // Check if trigger definition is unresolved
154
+ if (triggerShape.is(UnresolvedShape)) {
155
+ diagnostics.error(
156
+ triggerShape,
157
+ 'Trigger definition could not be resolved. Make sure the trigger definition is imported and available.'
158
+ )
159
+ return {
160
+ success: false,
161
+ }
162
+ }
163
+
164
+ // Handle both IdentifierShape (e.g., trigger.record.created) and CallExpressionShape (inline definition)
165
+ let triggerDefinitionObject: ObjectShape
166
+ if (triggerShape.is(CallExpressionShape)) {
167
+ const triggerDefinition = triggerShape.as(CallExpressionShape)
168
+ triggerDefinitionObject = triggerDefinition.getArgument(0).asObject()
169
+ } else if (triggerShape.is(IdentifierShape)) {
170
+ // For IdentifierShape, we need to resolve it to get the trigger definition
171
+ const resolved = triggerShape.resolve()
172
+ if (resolved.is(CallExpressionShape)) {
173
+ triggerDefinitionObject = resolved.as(CallExpressionShape).getArgument(0).asObject()
174
+ } else {
175
+ diagnostics.error(triggerShape, 'Could not resolve trigger definition from identifier')
176
+ return { success: false }
177
+ }
178
+ } else {
179
+ diagnostics.error(triggerShape, 'Trigger definition must be a trigger identifier or definition')
180
+ return { success: false }
181
+ }
182
+
183
+ const gzippedInputs = createTriggerInputsForTriggerInstance({
184
+ triggerInstanceInputs: triggerInputs,
185
+ triggerDefinition: triggerDefinitionObject,
186
+ })
187
+
188
+ const triggerInstanceRecord = await factory.createRecord({
189
+ source: callExpression,
190
+ table: 'sys_hub_trigger_instance_v2',
191
+ explicitId: configObject.get('$id'),
192
+ properties: configObject.transform(({ $ }) => ({
193
+ name: $.val(triggerDefinitionObject.get('name').getValue()), // Created
194
+ trigger_definition: $.val(triggerDefinitionObject.get('$id').getValue()),
195
+ trigger_inputs: $.val(gzippedInputs), // Gzip string of inputs
196
+ trigger_outputs: $.val(''),
197
+ trigger_type: $.val(triggerDefinitionObject.get('type').getValue()),
198
+ comment: $.from('annotation').def(''), // Annotation field
199
+ // flow: //- This field will be populated in flow plugin
200
+ category: $.def(''),
201
+ })),
202
+ })
203
+
204
+ return {
205
+ success: true,
206
+ value: triggerInstanceRecord,
207
+ }
208
+ },
209
+ },
210
+ ],
211
+ })
212
+
213
+ type InputDefinitions = Record<string, CallExpressionShape>
214
+
215
+ /**
216
+ * Builds the `choiceList` array expected by the record JSON.
217
+ *
218
+ * @param choices An object whose keys are the choice values and whose
219
+ * values contain at least a `label` property.
220
+ * @param triggerDefId The $id of the trigger definition currently being processed.
221
+ */
222
+ function buildChoiceList(
223
+ choices: Record<string, { label?: string; [k: string]: unknown }> | undefined,
224
+ _triggerDefId: string
225
+ ) {
226
+ if (!choices) {
227
+ return []
228
+ }
229
+ return Object.entries(choices).map(([value, data]) => ({
230
+ fValue: value,
231
+ fLabel:
232
+ typeof data === 'object' && data && 'label' in data ? (data as { label?: string }).label : String(value),
233
+ fImage: '',
234
+ // fParameters: {
235
+ // name: `var__m_sys_hub_trigger_input_${triggerDefId}`,
236
+ // },
237
+ fSelected: false,
238
+ fUsed: false,
239
+ fMissing: false,
240
+ }))
241
+ }
242
+
243
+ /**
244
+ * Maps field types to their display value transformations.
245
+ * Add new entries here to support additional field transformations.
246
+ *
247
+ * @example
248
+ * // To add month transformation:
249
+ * // 'month': MONTH_DISPLAY_MAP
250
+ */
251
+ const FIELD_DISPLAY_MAPS: Record<string, Record<string, string>> = {
252
+ day_of_week: DAY_OF_WEEK_DISPLAY_MAP,
253
+ // Add more mappings here as needed
254
+ }
255
+
256
+ /**
257
+ * Transforms trigger input values to their display values.
258
+ * Only applies transformation if the field type is in the transformation map.
259
+ * Preserves original value type for fields that don't need transformation.
260
+ *
261
+ * @param fieldName - The name of the field
262
+ * @param value - The actual value (preserves original type)
263
+ * @param columnType - The column type (e.g., 'day_of_week', 'glide_time')
264
+ * @returns Object with original value and string displayValue
265
+ *
266
+ * @example
267
+ * // With transformation:
268
+ * transformTriggerInputValue('day_of_week', 1, 'day_of_week')
269
+ * // Returns: { value: 1, displayValue: 'Monday' }
270
+ *
271
+ * @example
272
+ * // Without transformation:
273
+ * transformTriggerInputValue('priority', 3, 'integer')
274
+ * // Returns: { value: 3, displayValue: '3' }
275
+ */
276
+ function transformTriggerInputValue(
277
+ fieldName: string,
278
+ value: unknown,
279
+ columnType: string,
280
+ triggerInstanceInputs: ObjectShape
281
+ ): { value: unknown; displayValue: string } {
282
+ // First, check if this field needs transformation
283
+ const displayMap = FIELD_DISPLAY_MAPS[columnType] || FIELD_DISPLAY_MAPS[fieldName]
284
+
285
+ if (!displayMap) {
286
+ const inputValueShape = triggerInstanceInputs.get(fieldName)
287
+ // Handle glide_time type by converting TimeShape to string
288
+ if (columnType === TIME_DATA_TYPE_VALUE && inputValueShape?.is(TimeShape)) {
289
+ value = inputValueShape.as(TimeShape).toString().getValue()
290
+ } else if (columnType === DURATION_DATA_TYPE_VALUE && inputValueShape?.is(DurationShape)) {
291
+ value = inputValueShape.as(DurationShape).toString().getValue()
292
+ }
293
+
294
+ return {
295
+ value: value ?? '',
296
+ displayValue: String(value ?? ''),
297
+ }
298
+ }
299
+
300
+ // Transformation is needed - convert to string for mapping lookup
301
+ const stringValue = String(value ?? '')
302
+ const displayValue = displayMap[stringValue]
303
+
304
+ return {
305
+ value: stringValue, // Keep as string since transformation was applied
306
+ displayValue: displayValue || stringValue, // Fallback if no mapping found
307
+ }
308
+ }
309
+
310
+ function createTriggerInputsForTriggerInstance({
311
+ triggerInstanceInputs,
312
+ triggerDefinition,
313
+ }: {
314
+ triggerInstanceInputs: ObjectShape
315
+ triggerDefinition: ObjectShape
316
+ }): string {
317
+ // Get trigger input definitions if they exist
318
+ const inputDefinitions = triggerDefinition.get('inputs').ifObject()?.properties()
319
+
320
+ // Return empty array if no valid inputs exist
321
+ if (!inputDefinitions || Object.keys(inputDefinitions).length === 0) {
322
+ return gzipSync(JSON.stringify([])).toString('base64')
323
+ }
324
+
325
+ // Get the set of provided input names
326
+ const providedInputNames = new Set(triggerInstanceInputs.keys())
327
+
328
+ // Transform input definitions into trigger inputs
329
+ const triggerInputs: TriggerInput[] = Object.entries(inputDefinitions as InputDefinitions).map(
330
+ ([name, inputCallExpr]) => {
331
+ const fieldProps = inputCallExpr.getArguments()[0]?.getValue() as FieldProperties | undefined
332
+
333
+ // Get user-provided value or fall back to default value from definition
334
+ let userValue = triggerInstanceInputs.get(name)?.getValue()
335
+
336
+ // If no value provided and a default exists, use the default
337
+ if (userValue === undefined && !providedInputNames.has(name) && fieldProps?.default !== undefined) {
338
+ userValue = fieldProps.default
339
+ }
340
+
341
+ if (isArray(userValue)) {
342
+ userValue = userValue.join(',') // Convert array to comma-separated string
343
+ }
344
+
345
+ // Apply default value if user didn't specify a value
346
+ if (userValue === undefined && fieldProps?.default !== undefined) {
347
+ userValue = fieldProps.default
348
+ }
349
+
350
+ const type =
351
+ inputCallExpr.getCallee() === 'GenericColumn'
352
+ ? (fieldProps?.columnType ?? '') // Use columnType for GenericColumn
353
+ : (COLUMN_API_TO_TYPE[inputCallExpr.getCallee()] ?? '')
354
+
355
+ // Transform value and displayValue using the utility function
356
+ const { value, displayValue } = transformTriggerInputValue(name, userValue, type, triggerInstanceInputs)
357
+
358
+ return {
359
+ triggerInstanceSysId: '',
360
+ label: fieldProps?.label ?? '',
361
+ internalType: type,
362
+ dependent: '',
363
+ choiceList: buildChoiceList(fieldProps?.choices, triggerDefinition.get('$id').asString().getValue()),
364
+ mandatory: fieldProps?.mandatory ?? false,
365
+ order: 100,
366
+ name,
367
+ value,
368
+ displayValue,
369
+ displayField: '',
370
+ scriptActive: false, // TODO: populate later
371
+ ...(type === 'glide_list' && { valueSysId: '' }),
372
+ children: [], // Check and remove later
373
+ parameter: {
374
+ type,
375
+ name,
376
+ label: fieldProps?.label ?? '',
377
+ ...(fieldProps?.attributes && typeof fieldProps.attributes === 'object'
378
+ ? { attributes: { ...fieldProps.attributes } }
379
+ : {}),
380
+ ...(fieldProps?.dependent_on
381
+ ? {
382
+ dependent_on: fieldProps.dependent_on,
383
+ use_dependent: true,
384
+ }
385
+ : {}),
386
+ ...(fieldProps?.reference
387
+ ? {
388
+ reference: fieldProps.reference,
389
+ reference_display: fieldProps.reference_display,
390
+ }
391
+ : {}),
392
+ },
393
+ } as TriggerInput
394
+ }
395
+ )
396
+ return gzipSync(JSON.stringify(triggerInputs)).toString('base64')
397
+ }
398
+
399
+ interface FieldProperties {
400
+ default?: unknown
401
+ label?: string
402
+ mandatory?: boolean
403
+ columnType?: string
404
+ choices?: Record<string, { label?: string; [key: string]: unknown }>
405
+ attributes?: Record<string, unknown>
406
+ dependent_on?: unknown
407
+ reference?: unknown
408
+ reference_display?: unknown
409
+ [key: string]: unknown
410
+ }
411
+
412
+ interface TriggerInput {
413
+ triggerInstanceSysId: string
414
+ label: string
415
+ internalType: string
416
+ dependent: string
417
+ choiceList: unknown[]
418
+ mandatory: boolean
419
+ order: number
420
+ name: string
421
+ value: unknown
422
+ displayValue: string
423
+ displayField: string
424
+ scriptActive: boolean
425
+ parameter: object
426
+ }
@@ -0,0 +1,83 @@
1
+ import { CallExpressionShape, Plugin, type Source } from '@servicenow/sdk-build-core'
2
+
3
+ /**
4
+ * Shape representing an inline script created via wfa.inlineScript('script content').
5
+ *
6
+ * This shape is used for Flow Designer inline scripts that are authored directly
7
+ * in Fluent code rather than in external files.
8
+ */
9
+ export class FDInlineScriptCallShape extends CallExpressionShape {
10
+ private readonly scriptContent: string
11
+
12
+ constructor({ source, scriptContent }: { source: Source; scriptContent: string }) {
13
+ super({ source, callee: 'wfa.inlineScript', args: [scriptContent] })
14
+ this.scriptContent = scriptContent
15
+ }
16
+
17
+ /**
18
+ * Gets the inline script content.
19
+ */
20
+ getScriptContent(): string {
21
+ return this.scriptContent
22
+ }
23
+
24
+ /**
25
+ * Returns the script content as the value.
26
+ * This is used during serialization to XML.
27
+ */
28
+ override getValue(): string {
29
+ return this.scriptContent
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Plugin to handle wfa.inlineScript() calls in Flow Designer.
35
+ *
36
+ * This plugin provides bi-directional conversion between Fluent and XML:
37
+ *
38
+ * **Fluent → XML (toSubclass):**
39
+ * - Detects `wfa.inlineScript('script')` calls in Fluent code
40
+ * - Converts to FDInlineScriptCallShape for XML serialization
41
+ * - Serialization handled by flow-instance-plugin via InlineScriptShape
42
+ *
43
+ * **XML → Fluent (in flow-instance-plugin):**
44
+ * - Detects `scriptActive: true` in XML
45
+ * - Creates FDInlineScriptCallShape via convertInlineScriptToInlineScriptCall()
46
+ * - Generates `wfa.inlineScript('script')` in Fluent code
47
+ */
48
+ export const InlineScriptPlugin = Plugin.create({
49
+ name: 'InlineScriptPlugin',
50
+ shapes: [
51
+ {
52
+ shape: CallExpressionShape,
53
+ fileTypes: ['fluent'],
54
+ toSubclass(callExpression, { diagnostics }) {
55
+ // Only handle wfa.inlineScript() calls
56
+ if (callExpression.getCallee() !== 'wfa.inlineScript') {
57
+ return { success: false }
58
+ }
59
+
60
+ // Validate the argument is a string
61
+ const arg = callExpression.getArgument(0)
62
+ if (!arg.isString()) {
63
+ diagnostics.error(arg, 'wfa.inlineScript() must have a string argument')
64
+ return { success: false }
65
+ }
66
+
67
+ // Extract script content and create specialized shape
68
+ const scriptContent = arg.getValue()
69
+
70
+ return {
71
+ success: true,
72
+ value: new FDInlineScriptCallShape({
73
+ source: callExpression,
74
+ scriptContent,
75
+ }),
76
+ }
77
+ },
78
+ },
79
+ // Note: No commit handlers needed for Flow Designer bi-directional workflow
80
+ // - Fluent → XML uses InlineScriptShape.toFlowDesignerJson() in flow-instance-plugin
81
+ // - XML → Fluent uses buildInlineScriptShapeFromXml() in flow-instance-plugin
82
+ ],
83
+ })
@@ -0,0 +1,67 @@
1
+ import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
2
+ import { buildVariableShapes } from '../utils/flow-io-to-record'
3
+ import { NowIdShape } from '../../now-id-plugin'
4
+ import { generateXML } from '../utils/flow-to-xml'
5
+ /**
6
+ * Plugin for processing StepDefinition calls
7
+ */
8
+ export const StepDefinitionPlugin = Plugin.create({
9
+ name: 'StepDefinitionPlugin',
10
+ records: {
11
+ sys_flow_step_definition: {
12
+ relationships: {
13
+ sys_flow_step_definition_input: {
14
+ via: 'model',
15
+ descendant: true,
16
+ relationships: {
17
+ sys_choice: {
18
+ via: {
19
+ name: 'name',
20
+ element: 'element',
21
+ },
22
+ descendant: true,
23
+ },
24
+ },
25
+ },
26
+ sys_flow_step_definition_output: {
27
+ via: 'model',
28
+ descendant: true,
29
+ },
30
+ },
31
+ toShape(record, { descendants }) {
32
+ const inputs = buildVariableShapes(descendants.query('sys_flow_step_definition_input'), descendants)
33
+ const outputs = buildVariableShapes(descendants.query('sys_flow_step_definition_output'), descendants)
34
+ return {
35
+ success: true,
36
+ value: new CallExpressionShape({
37
+ source: record,
38
+ callee: 'ActionStepDefinition',
39
+ args: [
40
+ record.transform(({ $ }) => {
41
+ return {
42
+ $id: $.val(NowIdShape.from(record)),
43
+ name: $.def(''),
44
+ shortDescription: $.from('short_description').def(''),
45
+ category: $.def(''),
46
+ inputs: $.val(inputs),
47
+ outputs: $.val(outputs),
48
+ allowExtendedInputs: $.toBoolean().def(true),
49
+ allowExtendedOutputs: $.toBoolean().def(true),
50
+ }
51
+ }),
52
+ ],
53
+ }),
54
+ }
55
+ },
56
+ toFile(record, { config, database }) {
57
+ return generateXML(record, { config, database })
58
+ },
59
+ },
60
+ sys_flow_step_definition_input: {
61
+ coalesce: ['model', 'element'],
62
+ },
63
+ sys_flow_step_definition_output: {
64
+ coalesce: ['model', 'element'],
65
+ },
66
+ },
67
+ })