@servicenow/sdk-build-plugins 4.2.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acl-plugin.js +11 -0
- package/dist/acl-plugin.js.map +1 -1
- package/dist/applicability-plugin.d.ts +2 -0
- package/dist/applicability-plugin.js +72 -0
- package/dist/applicability-plugin.js.map +1 -0
- package/dist/atf/test-plugin.js +5 -2
- package/dist/atf/test-plugin.js.map +1 -1
- package/dist/basic-syntax-plugin.js +7 -1
- package/dist/basic-syntax-plugin.js.map +1 -1
- package/dist/business-rule-plugin.js +1 -0
- package/dist/business-rule-plugin.js.map +1 -1
- package/dist/call-expression-plugin.js +1 -107
- package/dist/call-expression-plugin.js.map +1 -1
- package/dist/column/column-to-record.d.ts +10 -3
- package/dist/column/column-to-record.js +44 -7
- package/dist/column/column-to-record.js.map +1 -1
- package/dist/column-plugin.d.ts +3 -1
- package/dist/column-plugin.js +12 -12
- package/dist/column-plugin.js.map +1 -1
- package/dist/dashboard/dashboard-component-property-defaults.d.ts +152 -0
- package/dist/dashboard/dashboard-component-property-defaults.js +264 -0
- package/dist/dashboard/dashboard-component-property-defaults.js.map +1 -0
- package/dist/dashboard/dashboard-component-resolver.d.ts +13 -0
- package/dist/dashboard/dashboard-component-resolver.js +69 -0
- package/dist/dashboard/dashboard-component-resolver.js.map +1 -0
- package/dist/dashboard/dashboard-plugin.d.ts +12 -0
- package/dist/dashboard/dashboard-plugin.js +397 -0
- package/dist/dashboard/dashboard-plugin.js.map +1 -0
- package/dist/data-plugin.d.ts +3 -0
- package/dist/data-plugin.js +61 -113
- package/dist/data-plugin.js.map +1 -1
- package/dist/email-notification-plugin.d.ts +2 -0
- package/dist/email-notification-plugin.js +541 -0
- package/dist/email-notification-plugin.js.map +1 -0
- package/dist/flow/constants/flow-plugin-constants.d.ts +58 -0
- package/dist/flow/constants/flow-plugin-constants.js +70 -0
- package/dist/flow/constants/flow-plugin-constants.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-constants.d.ts +38 -0
- package/dist/flow/flow-logic/flow-logic-constants.js +118 -0
- package/dist/flow/flow-logic/flow-logic-constants.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-diagnostics.d.ts +19 -0
- package/dist/flow/flow-logic/flow-logic-diagnostics.js +503 -0
- package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +62 -0
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +2092 -0
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-plugin.d.ts +52 -0
- package/dist/flow/flow-logic/flow-logic-plugin.js +283 -0
- package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-shapes.d.ts +104 -0
- package/dist/flow/flow-logic/flow-logic-shapes.js +201 -0
- package/dist/flow/flow-logic/flow-logic-shapes.js.map +1 -0
- package/dist/flow/plugins/approval-rules-plugin.d.ts +2 -0
- package/dist/flow/plugins/approval-rules-plugin.js +49 -0
- package/dist/flow/plugins/approval-rules-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-action-definition-plugin.d.ts +2 -0
- package/dist/flow/plugins/flow-action-definition-plugin.js +286 -0
- package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-data-pill-plugin.d.ts +9 -0
- package/dist/flow/plugins/flow-data-pill-plugin.js +212 -0
- package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-definition-plugin.d.ts +2 -0
- package/dist/flow/plugins/flow-definition-plugin.js +1668 -0
- package/dist/flow/plugins/flow-definition-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +26 -0
- package/dist/flow/plugins/flow-diagnostics-plugin.js +217 -0
- package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-instance-plugin.d.ts +12 -0
- package/dist/flow/plugins/flow-instance-plugin.js +1205 -0
- package/dist/flow/plugins/flow-instance-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-trigger-instance-plugin.d.ts +2 -0
- package/dist/flow/plugins/flow-trigger-instance-plugin.js +338 -0
- package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -0
- package/dist/flow/plugins/inline-script-plugin.d.ts +39 -0
- package/dist/flow/plugins/inline-script-plugin.js +80 -0
- package/dist/flow/plugins/inline-script-plugin.js.map +1 -0
- package/dist/flow/plugins/step-definition-plugin.d.ts +5 -0
- package/dist/flow/plugins/step-definition-plugin.js +71 -0
- package/dist/flow/plugins/step-definition-plugin.js.map +1 -0
- package/dist/flow/plugins/step-instance-plugin.d.ts +31 -0
- package/dist/flow/plugins/step-instance-plugin.js +339 -0
- package/dist/flow/plugins/step-instance-plugin.js.map +1 -0
- package/dist/flow/plugins/trigger-plugin.d.ts +2 -0
- package/dist/flow/plugins/trigger-plugin.js +96 -0
- package/dist/flow/plugins/trigger-plugin.js.map +1 -0
- package/dist/flow/plugins/wfa-datapill-plugin.d.ts +15 -0
- package/dist/flow/plugins/wfa-datapill-plugin.js +178 -0
- package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -0
- package/dist/flow/utils/approval-rules-processor.d.ts +13 -0
- package/dist/flow/utils/approval-rules-processor.js +267 -0
- package/dist/flow/utils/approval-rules-processor.js.map +1 -0
- package/dist/flow/utils/built-in-complex-objects.d.ts +19 -0
- package/dist/flow/utils/built-in-complex-objects.js +62 -0
- package/dist/flow/utils/built-in-complex-objects.js.map +1 -0
- package/dist/flow/utils/complex-object-resolver.d.ts +8 -0
- package/dist/flow/utils/complex-object-resolver.js +614 -0
- package/dist/flow/utils/complex-object-resolver.js.map +1 -0
- package/dist/flow/utils/complex-objects.d.ts +36 -0
- package/dist/flow/utils/complex-objects.js +481 -0
- package/dist/flow/utils/complex-objects.js.map +1 -0
- package/dist/flow/utils/data-pill-shapes.d.ts +58 -0
- package/dist/flow/utils/data-pill-shapes.js +135 -0
- package/dist/flow/utils/data-pill-shapes.js.map +1 -0
- package/dist/flow/utils/datapill-transformer.d.ts +110 -0
- package/dist/flow/utils/datapill-transformer.js +503 -0
- package/dist/flow/utils/datapill-transformer.js.map +1 -0
- package/dist/flow/utils/flow-constants.d.ts +72 -0
- package/dist/flow/utils/flow-constants.js +230 -0
- package/dist/flow/utils/flow-constants.js.map +1 -0
- package/dist/flow/utils/flow-io-to-record.d.ts +44 -0
- package/dist/flow/utils/flow-io-to-record.js +409 -0
- package/dist/flow/utils/flow-io-to-record.js.map +1 -0
- package/dist/flow/utils/flow-shapes.d.ts +161 -0
- package/dist/flow/utils/flow-shapes.js +255 -0
- package/dist/flow/utils/flow-shapes.js.map +1 -0
- package/dist/flow/utils/flow-to-xml.d.ts +16 -0
- package/dist/flow/utils/flow-to-xml.js +237 -0
- package/dist/flow/utils/flow-to-xml.js.map +1 -0
- package/dist/flow/utils/flow-variable-processor.d.ts +51 -0
- package/dist/flow/utils/flow-variable-processor.js +69 -0
- package/dist/flow/utils/flow-variable-processor.js.map +1 -0
- package/dist/flow/utils/label-cache-parser.d.ts +7 -0
- package/dist/flow/utils/label-cache-parser.js +24 -0
- package/dist/flow/utils/label-cache-parser.js.map +1 -0
- package/dist/flow/utils/label-cache-processor.d.ts +119 -0
- package/dist/flow/utils/label-cache-processor.js +719 -0
- package/dist/flow/utils/label-cache-processor.js.map +1 -0
- package/dist/flow/utils/pill-string-parser.d.ts +88 -0
- package/dist/flow/utils/pill-string-parser.js +306 -0
- package/dist/flow/utils/pill-string-parser.js.map +1 -0
- package/dist/flow/utils/schema-to-flow-object.d.ts +22 -0
- package/dist/flow/utils/schema-to-flow-object.js +318 -0
- package/dist/flow/utils/schema-to-flow-object.js.map +1 -0
- package/dist/flow/utils/service-catalog.d.ts +47 -0
- package/dist/flow/utils/service-catalog.js +137 -0
- package/dist/flow/utils/service-catalog.js.map +1 -0
- package/dist/flow/utils/utils.d.ts +117 -0
- package/dist/flow/utils/utils.js +345 -0
- package/dist/flow/utils/utils.js.map +1 -0
- package/dist/index.d.ts +20 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/list-plugin.js +1 -1
- package/dist/list-plugin.js.map +1 -1
- package/dist/now-attach-plugin.d.ts +1 -0
- package/dist/now-attach-plugin.js +10 -10
- package/dist/now-attach-plugin.js.map +1 -1
- package/dist/now-ref-plugin.js +1 -1
- package/dist/now-ref-plugin.js.map +1 -1
- package/dist/record-plugin.d.ts +29 -0
- package/dist/record-plugin.js +66 -7
- package/dist/record-plugin.js.map +1 -1
- package/dist/repack/index.d.ts +2 -0
- package/dist/repack/index.js +8 -0
- package/dist/repack/index.js.map +1 -1
- package/dist/rest-api-plugin.js +54 -44
- package/dist/rest-api-plugin.js.map +1 -1
- package/dist/server-module-plugin/index.d.ts +10 -0
- package/dist/server-module-plugin/index.js +83 -59
- package/dist/server-module-plugin/index.js.map +1 -1
- package/dist/service-catalog/catalog-clientscript-plugin.d.ts +2 -0
- package/dist/service-catalog/catalog-clientscript-plugin.js +117 -0
- package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -0
- package/dist/service-catalog/catalog-item-plugin.d.ts +2 -0
- package/dist/service-catalog/catalog-item-plugin.js +115 -0
- package/dist/service-catalog/catalog-item-plugin.js.map +1 -0
- package/dist/service-catalog/catalog-ui-policy-plugin.d.ts +2 -0
- package/dist/service-catalog/catalog-ui-policy-plugin.js +266 -0
- package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -0
- package/dist/service-catalog/index.d.ts +5 -0
- package/dist/service-catalog/index.js +22 -0
- package/dist/service-catalog/index.js.map +1 -0
- package/dist/service-catalog/record-to-shape.d.ts +6 -0
- package/dist/service-catalog/record-to-shape.js +93 -0
- package/dist/service-catalog/record-to-shape.js.map +1 -0
- package/dist/service-catalog/sc-record-producer-plugin.d.ts +2 -0
- package/dist/service-catalog/sc-record-producer-plugin.js +140 -0
- package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -0
- package/dist/service-catalog/service-catalog-base.d.ts +311 -0
- package/dist/service-catalog/service-catalog-base.js +542 -0
- package/dist/service-catalog/service-catalog-base.js.map +1 -0
- package/dist/service-catalog/service-catalog-diagnostics.d.ts +45 -0
- package/dist/service-catalog/service-catalog-diagnostics.js +172 -0
- package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -0
- package/dist/service-catalog/shape-to-record.d.ts +8 -0
- package/dist/service-catalog/shape-to-record.js +235 -0
- package/dist/service-catalog/shape-to-record.js.map +1 -0
- package/dist/service-catalog/utils.d.ts +323 -0
- package/dist/service-catalog/utils.js +1216 -0
- package/dist/service-catalog/utils.js.map +1 -0
- package/dist/service-catalog/variable-helper.d.ts +43 -0
- package/dist/service-catalog/variable-helper.js +92 -0
- package/dist/service-catalog/variable-helper.js.map +1 -0
- package/dist/service-catalog/variable-set-plugin.d.ts +2 -0
- package/dist/service-catalog/variable-set-plugin.js +175 -0
- package/dist/service-catalog/variable-set-plugin.js.map +1 -0
- package/dist/service-catalog/variables-transform.d.ts +139 -0
- package/dist/service-catalog/variables-transform.js +403 -0
- package/dist/service-catalog/variables-transform.js.map +1 -0
- package/dist/sla/sla-validators.d.ts +61 -0
- package/dist/sla/sla-validators.js +224 -0
- package/dist/sla/sla-validators.js.map +1 -0
- package/dist/sla-plugin.d.ts +5 -0
- package/dist/sla-plugin.js +280 -0
- package/dist/sla-plugin.js.map +1 -0
- package/dist/static-content-plugin.js +25 -2
- package/dist/static-content-plugin.js.map +1 -1
- package/dist/table-plugin.js +32 -15
- package/dist/table-plugin.js.map +1 -1
- package/dist/ui-page-plugin.js +832 -19
- package/dist/ui-page-plugin.js.map +1 -1
- package/dist/ui-policy-plugin.js +5 -7
- package/dist/ui-policy-plugin.js.map +1 -1
- package/dist/utils.d.ts +10 -1
- package/dist/utils.js +16 -0
- package/dist/utils.js.map +1 -1
- package/dist/ux-list-menu-config-plugin.d.ts +2 -0
- package/dist/ux-list-menu-config-plugin.js +292 -0
- package/dist/ux-list-menu-config-plugin.js.map +1 -0
- package/dist/workspace-plugin/chrome-tab.d.ts +2 -0
- package/dist/workspace-plugin/chrome-tab.js +46 -0
- package/dist/workspace-plugin/chrome-tab.js.map +1 -0
- package/dist/workspace-plugin/constants.d.ts +52 -0
- package/dist/workspace-plugin/constants.js +56 -0
- package/dist/workspace-plugin/constants.js.map +1 -0
- package/dist/workspace-plugin/fluent-utils.d.ts +9 -0
- package/dist/workspace-plugin/fluent-utils.js +60 -0
- package/dist/workspace-plugin/fluent-utils.js.map +1 -0
- package/dist/workspace-plugin/page.d.ts +8 -0
- package/dist/workspace-plugin/page.js +108 -0
- package/dist/workspace-plugin/page.js.map +1 -0
- package/dist/workspace-plugin/screen.d.ts +1 -0
- package/dist/workspace-plugin/screen.js +38 -0
- package/dist/workspace-plugin/screen.js.map +1 -0
- package/dist/workspace-plugin/templates/index.d.ts +10 -0
- package/dist/workspace-plugin/templates/index.js +20 -0
- package/dist/workspace-plugin/templates/index.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-composition.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-composition.js +4043 -0
- package/dist/workspace-plugin/templates/record-page-composition.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-data.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-data.js +527 -0
- package/dist/workspace-plugin/templates/record-page-data.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-interalEventMappings.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-interalEventMappings.js +39 -0
- package/dist/workspace-plugin/templates/record-page-interalEventMappings.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-layoutModel.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-layoutModel.js +55 -0
- package/dist/workspace-plugin/templates/record-page-layoutModel.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-properties.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-properties.js +135 -0
- package/dist/workspace-plugin/templates/record-page-properties.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page.d.ts +3 -0
- package/dist/workspace-plugin/templates/record-page.js +8 -0
- package/dist/workspace-plugin/templates/record-page.js.map +1 -0
- package/dist/workspace-plugin.d.ts +2 -0
- package/dist/workspace-plugin.js +453 -0
- package/dist/workspace-plugin.js.map +1 -0
- package/package.json +10 -12
- package/src/acl-plugin.ts +16 -1
- package/src/applicability-plugin.ts +82 -0
- package/src/atf/test-plugin.ts +6 -3
- package/src/basic-syntax-plugin.ts +10 -1
- package/src/business-rule-plugin.ts +2 -1
- package/src/call-expression-plugin.ts +2 -130
- package/src/column/column-to-record.ts +54 -8
- package/src/column-plugin.ts +29 -13
- package/src/dashboard/dashboard-component-property-defaults.ts +277 -0
- package/src/dashboard/dashboard-component-resolver.ts +69 -0
- package/src/dashboard/dashboard-plugin.ts +450 -0
- package/src/data-plugin.ts +67 -139
- package/src/email-notification-plugin.ts +850 -0
- package/src/flow/constants/flow-plugin-constants.ts +79 -0
- package/src/flow/flow-logic/flow-logic-constants.ts +120 -0
- package/src/flow/flow-logic/flow-logic-diagnostics.ts +591 -0
- package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +2550 -0
- package/src/flow/flow-logic/flow-logic-plugin.ts +337 -0
- package/src/flow/flow-logic/flow-logic-shapes.ts +215 -0
- package/src/flow/plugins/approval-rules-plugin.ts +48 -0
- package/src/flow/plugins/flow-action-definition-plugin.ts +295 -0
- package/src/flow/plugins/flow-data-pill-plugin.ts +258 -0
- package/src/flow/plugins/flow-definition-plugin.ts +2173 -0
- package/src/flow/plugins/flow-diagnostics-plugin.ts +280 -0
- package/src/flow/plugins/flow-instance-plugin.ts +1499 -0
- package/src/flow/plugins/flow-trigger-instance-plugin.ts +444 -0
- package/src/flow/plugins/inline-script-plugin.ts +83 -0
- package/src/flow/plugins/step-definition-plugin.ts +67 -0
- package/src/flow/plugins/step-instance-plugin.ts +431 -0
- package/src/flow/plugins/trigger-plugin.ts +95 -0
- package/src/flow/plugins/wfa-datapill-plugin.ts +213 -0
- package/src/flow/utils/approval-rules-processor.ts +298 -0
- package/src/flow/utils/built-in-complex-objects.ts +81 -0
- package/src/flow/utils/complex-object-resolver.ts +875 -0
- package/src/flow/utils/complex-objects.ts +656 -0
- package/src/flow/utils/data-pill-shapes.ts +165 -0
- package/src/flow/utils/datapill-transformer.ts +632 -0
- package/src/flow/utils/flow-constants.ts +285 -0
- package/src/flow/utils/flow-io-to-record.ts +533 -0
- package/src/flow/utils/flow-shapes.ts +296 -0
- package/src/flow/utils/flow-to-xml.ts +318 -0
- package/src/flow/utils/flow-variable-processor.ts +100 -0
- package/src/flow/utils/label-cache-parser.ts +37 -0
- package/src/flow/utils/label-cache-processor.ts +870 -0
- package/src/flow/utils/pill-string-parser.ts +375 -0
- package/src/flow/utils/schema-to-flow-object.ts +385 -0
- package/src/flow/utils/service-catalog.ts +174 -0
- package/src/flow/utils/utils.ts +395 -0
- package/src/index.ts +20 -1
- package/src/list-plugin.ts +1 -1
- package/src/now-attach-plugin.ts +14 -11
- package/src/now-ref-plugin.ts +1 -1
- package/src/record-plugin.ts +76 -11
- package/src/repack/index.ts +14 -0
- package/src/rest-api-plugin.ts +62 -50
- package/src/server-module-plugin/index.ts +112 -86
- package/src/service-catalog/catalog-clientscript-plugin.ts +140 -0
- package/src/service-catalog/catalog-item-plugin.ts +162 -0
- package/src/service-catalog/catalog-ui-policy-plugin.ts +324 -0
- package/src/service-catalog/index.ts +5 -0
- package/src/service-catalog/record-to-shape.ts +109 -0
- package/src/service-catalog/sc-record-producer-plugin.ts +201 -0
- package/src/service-catalog/service-catalog-base.ts +600 -0
- package/src/service-catalog/service-catalog-diagnostics.ts +254 -0
- package/src/service-catalog/shape-to-record.ts +279 -0
- package/src/service-catalog/utils.ts +1455 -0
- package/src/service-catalog/variable-helper.ts +135 -0
- package/src/service-catalog/variable-set-plugin.ts +197 -0
- package/src/service-catalog/variables-transform.ts +438 -0
- package/src/sla/sla-validators.ts +331 -0
- package/src/sla-plugin.ts +358 -0
- package/src/static-content-plugin.ts +25 -2
- package/src/table-plugin.ts +49 -16
- package/src/ui-page-plugin.ts +1063 -20
- package/src/ui-policy-plugin.ts +5 -9
- package/src/utils.ts +24 -1
- package/src/ux-list-menu-config-plugin.ts +312 -0
- package/src/workspace-plugin/chrome-tab.ts +44 -0
- package/src/workspace-plugin/constants.ts +53 -0
- package/src/workspace-plugin/fluent-utils.ts +60 -0
- package/src/workspace-plugin/page.ts +139 -0
- package/src/workspace-plugin/screen.ts +34 -0
- package/src/workspace-plugin/templates/index.ts +17 -0
- package/src/workspace-plugin/templates/record-page-composition.ts +4051 -0
- package/src/workspace-plugin/templates/record-page-data.ts +523 -0
- package/src/workspace-plugin/templates/record-page-interalEventMappings.ts +35 -0
- package/src/workspace-plugin/templates/record-page-layoutModel.ts +51 -0
- package/src/workspace-plugin/templates/record-page-properties.ts +131 -0
- package/src/workspace-plugin/templates/record-page.ts +6 -0
- package/src/workspace-plugin.ts +574 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { type Result, Plugin, type Shape, ts } from '@servicenow/sdk-build-core'
|
|
2
|
+
import { getCallExpressionName } from '../../utils'
|
|
3
|
+
import { findAncestorByCalleeName } from '../utils/utils'
|
|
4
|
+
import { DataPillPlugin } from './flow-data-pill-plugin'
|
|
5
|
+
import { BasicSyntaxPlugin } from '../../basic-syntax-plugin'
|
|
6
|
+
import { ForEachItemShape, PillShape } from '../utils/data-pill-shapes'
|
|
7
|
+
import { FLOW_LOGIC } from '../flow-logic/flow-logic-constants'
|
|
8
|
+
|
|
9
|
+
const DATAPILL_CALLEE = 'wfa.dataPill'
|
|
10
|
+
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// HELPER FUNCTIONS
|
|
13
|
+
// ============================================================================
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Checks if a node is the items argument (first argument) of wfa.flowLogic.forEach()
|
|
17
|
+
*
|
|
18
|
+
* Verifies the following conditions:
|
|
19
|
+
* 1. The immediate parent is a CallExpression
|
|
20
|
+
* 2. The parent's callee is 'wfa.flowLogic.forEach'
|
|
21
|
+
* 3. The node is the first argument of that forEach call
|
|
22
|
+
*
|
|
23
|
+
* @param node - The node to check
|
|
24
|
+
* @returns true if the node is the items argument of forEach, false otherwise
|
|
25
|
+
*/
|
|
26
|
+
function isForEachItemsArgument(node: ts.Node): boolean {
|
|
27
|
+
const parentCall = node.getParentIfKind(ts.SyntaxKind.CallExpression)
|
|
28
|
+
return (
|
|
29
|
+
parentCall !== undefined &&
|
|
30
|
+
getCallExpressionName(parentCall) === FLOW_LOGIC.FOR_EACH &&
|
|
31
|
+
parentCall.getArguments()[0] === node
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Extracts metadata from the TypeScript type of a data pill expression.
|
|
37
|
+
* This includes parent table name, column name, and reference table.
|
|
38
|
+
*
|
|
39
|
+
* For example, for params.trigger.current.company:
|
|
40
|
+
* - parentTableName: "user_criteria" (from the record type)
|
|
41
|
+
* - columnName: "company" (the property being accessed)
|
|
42
|
+
* - reference: "core_company" (from the column's referenceTable property)
|
|
43
|
+
*/
|
|
44
|
+
function extractMetadataFromType(node: ts.Node): {
|
|
45
|
+
parentTableName: string | null
|
|
46
|
+
columnName: string | null
|
|
47
|
+
reference: string | null
|
|
48
|
+
} {
|
|
49
|
+
let parentTableName: string | null = null
|
|
50
|
+
let columnName: string | null = null
|
|
51
|
+
let reference: string | null = null
|
|
52
|
+
|
|
53
|
+
// For property access like params.trigger.current.company or outOfStockAssets.Records
|
|
54
|
+
if (ts.Node.isPropertyAccessExpression(node)) {
|
|
55
|
+
// Get the property name (e.g., "company" or "Records")
|
|
56
|
+
columnName = node.getName()
|
|
57
|
+
|
|
58
|
+
// Get the parent expression (e.g., params.trigger.current or outOfStockAssets)
|
|
59
|
+
const parentExpr = node.getExpression()
|
|
60
|
+
const parentType = parentExpr.getType()
|
|
61
|
+
const parentTypeText = parentType.getText()
|
|
62
|
+
|
|
63
|
+
// Pattern A: Check for OutputsWithDependentTable<..., "table_name"> from action outputs
|
|
64
|
+
// e.g., OutputsWithDependentTable<{...}, "alm_hardware"> & {...}
|
|
65
|
+
// The type text contains nested brackets, so we look for the pattern: }, "table_name"> &
|
|
66
|
+
if (parentTypeText.includes('OutputsWithDependentTable')) {
|
|
67
|
+
const outputsDependentMatch = parentTypeText.match(/},\s*["']([^"']+)["']\s*>\s*&/)
|
|
68
|
+
if (outputsDependentMatch?.[1]) {
|
|
69
|
+
reference = outputsDependentMatch[1]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Try to extract the table name from TableAwareRecordRecursive or similar types
|
|
74
|
+
if (!reference) {
|
|
75
|
+
const tableMatch = parentTypeText.match(/TableAwareRecord(?:Recursive|WithFallback)?<["']([^"']+)["']/)
|
|
76
|
+
if (tableMatch?.[1]) {
|
|
77
|
+
parentTableName = tableMatch[1]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Get the type of the property being accessed
|
|
82
|
+
const propertyType = node.getType()
|
|
83
|
+
const propertyTypeText = propertyType.getText()
|
|
84
|
+
|
|
85
|
+
// Try to extract referenceTable from the property type
|
|
86
|
+
// Pattern 1: Check if the property type is itself a TableAwareRecordRecursive type
|
|
87
|
+
// e.g., TableAwareRecordRecursive<"core_company", 2>
|
|
88
|
+
if (!reference) {
|
|
89
|
+
const tableTypeMatch = propertyTypeText.match(
|
|
90
|
+
/TableAwareRecord(?:Recursive|WithFallback)?<["']([^"']+)["']/
|
|
91
|
+
)
|
|
92
|
+
if (tableTypeMatch?.[1]) {
|
|
93
|
+
reference = tableTypeMatch[1]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return { parentTableName, columnName, reference }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ============================================================================
|
|
102
|
+
// PLUGIN DEFINITION
|
|
103
|
+
// ============================================================================
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* WfaDataPillPlugin - Handles wfa.dataPill() CallExpressions
|
|
107
|
+
*
|
|
108
|
+
* This plugin processes datapill wrapper calls and converts them to PillShape.
|
|
109
|
+
*
|
|
110
|
+
* Usage:
|
|
111
|
+
* wfa.dataPill(params.trigger.current.active, 'boolean')
|
|
112
|
+
* wfa.dataPill(params.flowVariables.userName, 'string')
|
|
113
|
+
* wfa.dataPill(actionInstance.output, 'reference')
|
|
114
|
+
*
|
|
115
|
+
* The first argument is the PropertyAccessExpression to the data source.
|
|
116
|
+
* The second argument is the data type string.
|
|
117
|
+
*/
|
|
118
|
+
export const WfaDataPillPlugin = Plugin.create({
|
|
119
|
+
name: 'WfaDataPillPlugin',
|
|
120
|
+
nodes: [
|
|
121
|
+
{
|
|
122
|
+
node: 'CallExpression',
|
|
123
|
+
fileTypes: ['fluent'],
|
|
124
|
+
async toShape(node, { diagnostics, transform }): Promise<Result<Shape>> {
|
|
125
|
+
const callee = getCallExpressionName(node)
|
|
126
|
+
|
|
127
|
+
// Only handle wfa.dataPill() calls
|
|
128
|
+
if (callee !== DATAPILL_CALLEE) {
|
|
129
|
+
return { success: false }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Validate wfa.dataPill is inside a Flow or Subflow call expression
|
|
133
|
+
const ancestorFlowOrSubflow = findAncestorByCalleeName(node, 'Flow', 'Subflow')
|
|
134
|
+
if (!ancestorFlowOrSubflow) {
|
|
135
|
+
diagnostics.error(node, 'wfa.dataPill() cannot be used outside of a Flow or Subflow context.')
|
|
136
|
+
return { success: false }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// TODO: This is not working, Even though the debug point is hitting this but not printing the error for some reason, need to fix from core team.
|
|
140
|
+
// This will be gone once the toSubclass node -> toShape is refactored to toSubclass() with story ref. STRY62776143
|
|
141
|
+
const ancestorDuration = findAncestorByCalleeName(node, 'Duration')
|
|
142
|
+
if (ancestorDuration) {
|
|
143
|
+
diagnostics.error(node, 'wfa.dataPill() cannot be used inside a Duration().')
|
|
144
|
+
return { success: false }
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const args = node.getArguments()
|
|
148
|
+
|
|
149
|
+
let expressionArg = args[0]
|
|
150
|
+
const typeArg = args[1]
|
|
151
|
+
|
|
152
|
+
if (!expressionArg) {
|
|
153
|
+
diagnostics.error(node, 'wfa.dataPill: missing required expression argument')
|
|
154
|
+
return { success: false }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Check if this pill is used in forEach items argument (computed once, reused throughout)
|
|
158
|
+
const isForEachItems = isForEachItemsArgument(node)
|
|
159
|
+
|
|
160
|
+
// Check for type assertions (as any, as string, etc.) in forEach items argument ONLY
|
|
161
|
+
if (ts.Node.isAsExpression(expressionArg)) {
|
|
162
|
+
if (isForEachItems) {
|
|
163
|
+
diagnostics.error(
|
|
164
|
+
expressionArg,
|
|
165
|
+
'wfa.dataPill: Type assertions (e.g., "as any") are not allowed in forEach items argument.'
|
|
166
|
+
)
|
|
167
|
+
return { success: false }
|
|
168
|
+
}
|
|
169
|
+
// For non-forEach uses, unwrap the type assertion to get the underlying expression
|
|
170
|
+
expressionArg = expressionArg.getExpression()
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Validate first argument is a property access expression or identifier
|
|
174
|
+
if (
|
|
175
|
+
!ts.Node.isPropertyAccessExpression(expressionArg) &&
|
|
176
|
+
!ts.Node.isIdentifier(expressionArg) // In ForEach scneario we get identifier like "item"
|
|
177
|
+
) {
|
|
178
|
+
diagnostics.error(
|
|
179
|
+
expressionArg,
|
|
180
|
+
'wfa.dataPill: first argument must be a property access expression (e.g., params.trigger.current.active)'
|
|
181
|
+
)
|
|
182
|
+
return { success: false }
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Convert the expression argument to a shape first
|
|
186
|
+
const shapeResult = await transform.toShape(expressionArg, BasicSyntaxPlugin, DataPillPlugin)
|
|
187
|
+
if (shapeResult.success) {
|
|
188
|
+
if (shapeResult.value instanceof PillShape || shapeResult.value instanceof ForEachItemShape) {
|
|
189
|
+
shapeResult.value.setType((typeArg as ts.StringLiteral).getLiteralValue())
|
|
190
|
+
|
|
191
|
+
// Only extract and set metadata if this pill is the items argument of forEach
|
|
192
|
+
if (isForEachItems) {
|
|
193
|
+
const metadata = extractMetadataFromType(expressionArg)
|
|
194
|
+
if (metadata.parentTableName) {
|
|
195
|
+
shapeResult.value.setParentTableName(metadata.parentTableName)
|
|
196
|
+
}
|
|
197
|
+
if (metadata.columnName) {
|
|
198
|
+
shapeResult.value.setColumnName(metadata.columnName)
|
|
199
|
+
}
|
|
200
|
+
if (metadata.reference) {
|
|
201
|
+
shapeResult.value.setReference(metadata.reference)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return { success: true, value: shapeResult.value }
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
diagnostics.error(expressionArg, 'wfa.dataPill: failed to resolve expression or type')
|
|
208
|
+
return { success: false }
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
shapes: [],
|
|
213
|
+
})
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions to convert between JSON and string formats for Approval Rules
|
|
3
|
+
*/
|
|
4
|
+
import { APPROVAL_ACTION_TYPE_APPROVE_VALUE, APPROVAL_ACTION_TYPES } from './flow-constants'
|
|
5
|
+
import type {
|
|
6
|
+
ApprovalConditionRuleType,
|
|
7
|
+
ApprovalRuleActionType,
|
|
8
|
+
ApprovalRuleConditionType,
|
|
9
|
+
ApprovalRuleSetType,
|
|
10
|
+
ApprovalRulesType,
|
|
11
|
+
} from '@servicenow/sdk-core/runtime/flow'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Converts Approval Rules JSON to string representation
|
|
15
|
+
* @param {Object} approvalRules - Approval rules JSON containing ruleSets and conditionType attributes
|
|
16
|
+
* @returns {string} String representation of the Approval Rules
|
|
17
|
+
*/
|
|
18
|
+
export function approvalRulesJsonToString(approvalRules: ApprovalRulesType): string {
|
|
19
|
+
const { ruleSets = [] } = approvalRules
|
|
20
|
+
return ruleSetsJsonToString(ruleSets)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Converts a Rule Sets JSON to its string representation
|
|
25
|
+
* @param {Array} ruleSets - Array of Rule Set objects
|
|
26
|
+
* @returns {string} String representation of the Rule Sets
|
|
27
|
+
*/
|
|
28
|
+
function ruleSetsJsonToString(ruleSets: Array<ApprovalRuleSetType>): string {
|
|
29
|
+
if (!ruleSets || !Array.isArray(ruleSets) || ruleSets.length === 0) {
|
|
30
|
+
return APPROVAL_ACTION_TYPE_APPROVE_VALUE
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//Iterate through the RuleSets and convert each RuleSet JSON to string
|
|
34
|
+
return ruleSets
|
|
35
|
+
.map((ruleSet) => ruleSetJsonToString(ruleSet))
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
.join('Or') //Rule Sets are connected with 'Or' condition
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Converts a Rule Set JSON to its string representation
|
|
41
|
+
* @param {Object} ruleSet - Rule Set object containg action and rules
|
|
42
|
+
* @returns {string} String representation of the Rule Set
|
|
43
|
+
*/
|
|
44
|
+
function ruleSetJsonToString(ruleSet: ApprovalRuleSetType): string {
|
|
45
|
+
const { action, rules = [] } = ruleSet
|
|
46
|
+
|
|
47
|
+
//Check if action type is valid
|
|
48
|
+
if (!action || !APPROVAL_ACTION_TYPES.includes(action)) {
|
|
49
|
+
return ''
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//Check if rules are valid
|
|
53
|
+
if (!rules || !Array.isArray(rules) || rules.length === 0) {
|
|
54
|
+
return action
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//Iterate over the rules and convert each rule json (contains list of conditions) to string
|
|
58
|
+
const rulesString = rules
|
|
59
|
+
.map((rule) => ruleJSONToString(rule))
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.join('&') //Rules are connected with & (AND)
|
|
62
|
+
|
|
63
|
+
return `${action}${rulesString}`
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Converts a Rule (contains list of conditions) JSON to its string representation
|
|
67
|
+
* @param {Array} rule - Array of Rule condition objects
|
|
68
|
+
* @returns {string} String representation of the Rule conditions
|
|
69
|
+
*/
|
|
70
|
+
function ruleJSONToString(rule: Array<ApprovalRuleConditionType>): string {
|
|
71
|
+
if (!rule || !Array.isArray(rule) || rule.length === 0) {
|
|
72
|
+
return ''
|
|
73
|
+
}
|
|
74
|
+
//Iterate through the rule conditions and convert each rule condition to string
|
|
75
|
+
const ruleString = rule
|
|
76
|
+
.map((ruleCondition) => ruleConditionJSONToString(ruleCondition))
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join('|') //Rule conditions are connected with | (OR)
|
|
79
|
+
return ruleString
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function ruleConditionJSONToString(ruleCondition: ApprovalRuleConditionType): string {
|
|
83
|
+
if (!ruleCondition || Object.keys(ruleCondition).length === 0) {
|
|
84
|
+
return ''
|
|
85
|
+
}
|
|
86
|
+
let result = ''
|
|
87
|
+
|
|
88
|
+
// Handle Count and Percent
|
|
89
|
+
if (ruleCondition.ruleType === 'Count' && ruleCondition.count !== undefined) {
|
|
90
|
+
result = `${ruleCondition.count}#`
|
|
91
|
+
} else if (ruleCondition.ruleType === 'Percent' && ruleCondition.percent !== undefined) {
|
|
92
|
+
result = `${ruleCondition.percent}%`
|
|
93
|
+
} else {
|
|
94
|
+
// Add rule type
|
|
95
|
+
result = ruleCondition.ruleType
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Handle manual flag
|
|
99
|
+
if (ruleCondition.manual) {
|
|
100
|
+
result += 'M'
|
|
101
|
+
return result
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Add users if present
|
|
105
|
+
if (ruleCondition.users && ruleCondition.users.length > 0) {
|
|
106
|
+
result += `U[${ruleCondition.users
|
|
107
|
+
.map((user) => {
|
|
108
|
+
const trimmed = String(user).trim()
|
|
109
|
+
// Check if user is already a data pill format (e.g., {{trigger.current.manager.city|string}})
|
|
110
|
+
const match = trimmed.match(/^\{\{(.*)\}\}$/)
|
|
111
|
+
if (match) {
|
|
112
|
+
return trimmed
|
|
113
|
+
}
|
|
114
|
+
return `{{static.${user}}}`
|
|
115
|
+
})
|
|
116
|
+
.join(',')}]`
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Add groups if present
|
|
120
|
+
if (ruleCondition.groups && ruleCondition.groups.length > 0) {
|
|
121
|
+
result += `G[${ruleCondition.groups
|
|
122
|
+
.map((group) => {
|
|
123
|
+
const trimmed = String(group).trim()
|
|
124
|
+
// Check if group is already a data pill format (e.g., {{trigger.current.group_ref|string}})
|
|
125
|
+
const match = trimmed.match(/^\{\{(.*)\}\}$/)
|
|
126
|
+
if (match) {
|
|
127
|
+
return trimmed
|
|
128
|
+
}
|
|
129
|
+
return `{{static.${group}}}`
|
|
130
|
+
})
|
|
131
|
+
.join(',')}]`
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return result
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Converts Approval Rules string to JSON representation
|
|
139
|
+
* @param {string} ruleSetsString - String representation of the Approval Rules
|
|
140
|
+
* @returns {Object} Approval rules JSON containing ruleSets and conditionType attributes
|
|
141
|
+
*/
|
|
142
|
+
export function approvalRulesStringToJson(ruleSetsString: string): ApprovalRulesType {
|
|
143
|
+
const EMPTY_RULE_SETS_JSON: ApprovalRulesType = {
|
|
144
|
+
conditionType: 'OR',
|
|
145
|
+
ruleSets: [],
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!ruleSetsString || ruleSetsString.length === 0) {
|
|
149
|
+
return EMPTY_RULE_SETS_JSON
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 1. Split by 'Or' to get individual Rule Sets
|
|
153
|
+
// 2. Iterate through the Rule Sets and convert each Rule Set string to JSON
|
|
154
|
+
const ruleSetsJson = ruleSetsString.split('Or').map((ruleSetString) => ruleSetStringToJson(ruleSetString))
|
|
155
|
+
return {
|
|
156
|
+
...EMPTY_RULE_SETS_JSON,
|
|
157
|
+
ruleSets: ruleSetsJson,
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Converts a Rule Set string to its JSON representation
|
|
162
|
+
* @param {string} ruleSetString - Rule Set string
|
|
163
|
+
* @returns {Array} JSON representation of the Rule Set
|
|
164
|
+
*/
|
|
165
|
+
function ruleSetStringToJson(ruleSetString: string): ApprovalRuleSetType {
|
|
166
|
+
const EMPTY_RULE_SET_JSON: ApprovalRuleSetType = {
|
|
167
|
+
action: 'Approves',
|
|
168
|
+
conditionType: 'AND',
|
|
169
|
+
rules: [],
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!ruleSetString || ruleSetString.length === 0) {
|
|
173
|
+
return EMPTY_RULE_SET_JSON
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Extract action (Approves, Rejects, ApprovesRejects)
|
|
177
|
+
const actionRegex = /^(ApprovesRejects|Approves|Rejects)/
|
|
178
|
+
const actionMatch = ruleSetString.match(actionRegex)
|
|
179
|
+
if (!actionMatch) {
|
|
180
|
+
return EMPTY_RULE_SET_JSON
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const action = actionMatch[0] as ApprovalRuleActionType
|
|
184
|
+
|
|
185
|
+
// If the string is just the action name, return an empty rule set
|
|
186
|
+
if (ruleSetString === action) {
|
|
187
|
+
return { ...EMPTY_RULE_SET_JSON, action }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Remove action from the Rule Set string and extract the rules string
|
|
191
|
+
const rulesString = ruleSetString.substring(action.length)
|
|
192
|
+
|
|
193
|
+
// Split rules by & to get individual rules within the Rule Set
|
|
194
|
+
const rulesRegex = /[&]/g
|
|
195
|
+
|
|
196
|
+
//Iterate through the rules and convert each rule string to JSON
|
|
197
|
+
const rulesJson = rulesString
|
|
198
|
+
.split(rulesRegex)
|
|
199
|
+
.map((ruleString) => ruleStringToJson(ruleString))
|
|
200
|
+
.filter(Boolean)
|
|
201
|
+
|
|
202
|
+
return { ...EMPTY_RULE_SET_JSON, action, rules: rulesJson }
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Converts a Rule string to its JSON representation
|
|
207
|
+
* @param {string} ruleString - Rule string
|
|
208
|
+
* @returns {Array} JSON representation of the Rule
|
|
209
|
+
*/
|
|
210
|
+
function ruleStringToJson(ruleString: string): Array<ApprovalRuleConditionType> {
|
|
211
|
+
if (!ruleString || ruleString.length === 0) {
|
|
212
|
+
return []
|
|
213
|
+
}
|
|
214
|
+
const ruleConditionsRegex = /[|]/g
|
|
215
|
+
const ruleConditionStrings: string[] = []
|
|
216
|
+
|
|
217
|
+
ruleString.split(ruleConditionsRegex).forEach((ruleConditionString) => {
|
|
218
|
+
ruleConditionStrings.push(ruleConditionString)
|
|
219
|
+
})
|
|
220
|
+
return ruleConditionStrings
|
|
221
|
+
.map((ruleConditionString) => ruleConditionStringToJson(ruleConditionString))
|
|
222
|
+
.filter((ruleConditionJson): ruleConditionJson is ApprovalRuleConditionType => ruleConditionJson !== undefined)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Converts a Rule Condition string to its JSON representation
|
|
227
|
+
* @param {string} ruleConditionString - Rule Condition string
|
|
228
|
+
* @returns {Object} JSON representation of the Rule Condition
|
|
229
|
+
*/
|
|
230
|
+
function ruleConditionStringToJson(ruleConditionString: string): ApprovalRuleConditionType | undefined {
|
|
231
|
+
if (!ruleConditionString || ruleConditionString.length === 0) {
|
|
232
|
+
return undefined
|
|
233
|
+
}
|
|
234
|
+
const ruleConditionJson: ApprovalRuleConditionType = {
|
|
235
|
+
ruleType: 'Any',
|
|
236
|
+
users: [],
|
|
237
|
+
groups: [],
|
|
238
|
+
manual: false,
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Check if manual
|
|
242
|
+
const hasManual = ruleConditionString.includes('M')
|
|
243
|
+
if (hasManual) {
|
|
244
|
+
ruleConditionJson.manual = true
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Check for Count or Percent
|
|
248
|
+
const countMatch = ruleConditionString.match(/(\d+)#/)
|
|
249
|
+
const percentMatch = ruleConditionString.match(/(\d+)%/)
|
|
250
|
+
|
|
251
|
+
if (countMatch?.[1]) {
|
|
252
|
+
ruleConditionJson.ruleType = 'Count'
|
|
253
|
+
ruleConditionJson['count'] = parseInt(countMatch[1], 10)
|
|
254
|
+
} else if (percentMatch?.[1]) {
|
|
255
|
+
ruleConditionJson.ruleType = 'Percent'
|
|
256
|
+
ruleConditionJson['percent'] = parseInt(percentMatch[1], 10)
|
|
257
|
+
} else {
|
|
258
|
+
// Extract rule type (Any, All, Res)
|
|
259
|
+
const ruleTypeMatch = ruleConditionString.match(/(Any|All|Res)/)
|
|
260
|
+
if (ruleTypeMatch) {
|
|
261
|
+
ruleConditionJson.ruleType = ruleTypeMatch[0] as ApprovalConditionRuleType
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
ruleConditionJson.users = getUsersJson(ruleConditionString)
|
|
265
|
+
ruleConditionJson.groups = getGroupsJson(ruleConditionString)
|
|
266
|
+
|
|
267
|
+
return ruleConditionJson
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function getUsersJson(ruleConditionString: string) {
|
|
271
|
+
if (ruleConditionString && ruleConditionString.length > 0) {
|
|
272
|
+
// Extract users
|
|
273
|
+
const usersMatch = ruleConditionString.match(/U\[(.*?)\]/)
|
|
274
|
+
if (usersMatch?.[1]) {
|
|
275
|
+
const usersString = usersMatch[1]
|
|
276
|
+
return usersString
|
|
277
|
+
.split(',')
|
|
278
|
+
.map((user) => user.replace(/{{static\.(.*?)}}/, '$1').trim())
|
|
279
|
+
.filter(Boolean)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return []
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function getGroupsJson(ruleConditionString: string) {
|
|
286
|
+
if (ruleConditionString && ruleConditionString.length > 0) {
|
|
287
|
+
// Extract groups
|
|
288
|
+
const groupsMatch = ruleConditionString.match(/G\[(.*?)\]/)
|
|
289
|
+
if (groupsMatch?.[1]) {
|
|
290
|
+
const groupsString = groupsMatch[1]
|
|
291
|
+
return groupsString
|
|
292
|
+
.split(',')
|
|
293
|
+
.map((group) => group.replace(/{{static\.(.*?)}}/, '$1').trim())
|
|
294
|
+
.filter(Boolean)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return []
|
|
298
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in complex objects that are available globally in Flow Designer.
|
|
3
|
+
* These are referenced by flows but may not be present in the user's project metadata.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
interface BuiltInComplexObject {
|
|
7
|
+
$id: string
|
|
8
|
+
table: 'sys_complex_object'
|
|
9
|
+
data: {
|
|
10
|
+
name: string
|
|
11
|
+
namespace: string
|
|
12
|
+
scope_name?: string
|
|
13
|
+
serialized_content: string
|
|
14
|
+
sys_domain: string
|
|
15
|
+
sys_policy?: string
|
|
16
|
+
type: string
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const FDChangeDetails: BuiltInComplexObject = {
|
|
21
|
+
$id: '239e04950f023300ecf0cc52ff767e0c',
|
|
22
|
+
table: 'sys_complex_object',
|
|
23
|
+
data: {
|
|
24
|
+
name: 'FDChangeDetails',
|
|
25
|
+
namespace: 'FlowDesigner',
|
|
26
|
+
scope_name: 'global',
|
|
27
|
+
serialized_content:
|
|
28
|
+
'{"FlowDesigner:FDChangeDetails":{"previous_display_value":"String","previous_display_value.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Previous Display Value\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"4\\",\\"max_length\\":\\"0\\"}"},"previous_value":"String","previous_value.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Previous Value\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"2\\",\\"max_length\\":\\"0\\"}"},"current_display_value":"String","current_display_value.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Current Display Value\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"5\\",\\"max_length\\":\\"0\\"}"},"current_value":"String","current_value.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Current Value\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"3\\",\\"max_length\\":\\"0\\"}"},"field_name":"String","field_name.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Field Name\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"1\\",\\"max_length\\":\\"0\\"}"}},"FlowDesigner:FDChangeDetails.$type_facets":{"SimpleMapFacet":"{\\"read_only_complex_object\\":\\"true\\",\\"pwd2droppable\\":\\"true\\",\\"default_value\\":\\"\\",\\"label\\":\\"Changed Fields\\",\\"mandatory\\":\\"false\\",\\"child_name\\":\\"FDChangeDetails\\",\\"uiTypeLabel\\":\\"Array.Object\\",\\"co_type_name\\":\\"FDCollection\\",\\"child_label\\":\\"FDChangeDetails\\",\\"child_type_label\\":\\"Object\\",\\"element_mapping_provider\\":\\"com.glide.flow_design.action.data.FlowDesignVariableMapper\\",\\"read_only\\":\\"false\\",\\"hint\\":null,\\"uiType\\":\\"array.object\\",\\"child_type\\":\\"object\\",\\"order\\":\\"1\\",\\"max_length\\":\\"8000\\"}"}}',
|
|
29
|
+
sys_domain: 'global',
|
|
30
|
+
type: 'complex_object_schema',
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const FDSTEPSTATUS: BuiltInComplexObject = {
|
|
35
|
+
$id: '73720df26f312010bf408271145b3600',
|
|
36
|
+
table: 'sys_complex_object',
|
|
37
|
+
data: {
|
|
38
|
+
name: 'FDSTEPSTATUS',
|
|
39
|
+
namespace: 'FlowDesigner',
|
|
40
|
+
scope_name: 'global',
|
|
41
|
+
serialized_content:
|
|
42
|
+
'{"FlowDesigner:FDSTEPSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"Integer\\",\\"read_only\\":\\"false\\",\\"hint\\":null,\\"uiType\\":\\"integer\\",\\"default_value\\":\\"\\",\\"label\\":\\"Code\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"1\\",\\"max_length\\":\\"40\\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":null,\\"uiType\\":\\"string\\",\\"default_value\\":null,\\"label\\":\\"Message\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"2\\",\\"max_length\\":\\"4000\\"}"}},"FlowDesigner:FDSTEPSTATUS.$type_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"Object\\",\\"co_type_name\\":\\"FDSTEPSTATUS\\",\\"read_only\\":\\"false\\",\\"hint\\":null,\\"uiType\\":\\"object\\",\\"default_value\\":\\"\\",\\"label\\":\\"Step Status\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"1\\",\\"max_length\\":\\"0\\"}"}}',
|
|
43
|
+
sys_domain: 'global',
|
|
44
|
+
type: 'complex_object_schema',
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const FDACTIONSTATUS: BuiltInComplexObject = {
|
|
49
|
+
$id: 'b91cc65087022010226ca1bb36cb0be4',
|
|
50
|
+
table: 'sys_complex_object',
|
|
51
|
+
data: {
|
|
52
|
+
name: 'FDACTIONSTATUS',
|
|
53
|
+
namespace: 'FlowDesigner',
|
|
54
|
+
serialized_content:
|
|
55
|
+
'{"FlowDesigner:FDACTIONSTATUS":{"code":"Integer","code.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"Integer\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"integer\\",\\"default_value\\":\\"\\",\\"label\\":\\"Code\\",\\"action_error_output\\":\\"true\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"1\\",\\"max_length\\":\\"40\\"}"},"message":"String","message.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Message\\",\\"action_error_output\\":\\"true\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"2\\",\\"max_length\\":\\"4000\\"}"}},"FlowDesigner:FDACTIONSTATUS.$type_facets":{"SimpleMapFacet":"{\\"default_value\\":\\"\\",\\"label\\":\\"Action Status\\",\\"action_error_output\\":\\"true\\",\\"mandatory\\":\\"false\\",\\"uiUniqueId\\":\\"4adfb7bc-9d67-498d-88d0-8d6c3d584fed\\",\\"uiTypeLabel\\":\\"Object\\",\\"co_type_name\\":\\"FDACTIONSTATUS\\",\\"element_mapping_provider\\":\\"com.glide.flow_design.action.data.FlowDesignVariableMapper\\",\\"read_only\\":\\"false\\",\\"hint\\":null,\\"uiType\\":\\"object\\",\\"order\\":\\"1\\",\\"max_length\\":\\"65000\\"}"}}',
|
|
56
|
+
sys_domain: 'global',
|
|
57
|
+
sys_policy: 'read',
|
|
58
|
+
type: 'complex_object_schema',
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const FDCollection: BuiltInComplexObject = {
|
|
63
|
+
$id: 'f4f014150f023300ecf0cc52ff767eed',
|
|
64
|
+
table: 'sys_complex_object',
|
|
65
|
+
data: {
|
|
66
|
+
name: 'FDCollection',
|
|
67
|
+
namespace: 'FlowDesigner',
|
|
68
|
+
scope_name: 'global',
|
|
69
|
+
serialized_content:
|
|
70
|
+
'{"FlowDesigner:FDCollection":{"$COCollectionField":[{"FDChangeDetails":{"previous_display_value":"String","previous_display_value.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Previous Display Value\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"4\\",\\"max_length\\":\\"0\\"}"},"previous_value":"String","previous_value.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Previous Value\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"2\\",\\"max_length\\":\\"0\\"}"},"current_display_value":"String","current_display_value.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Current Display Value\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"5\\",\\"max_length\\":\\"0\\"}"},"current_value":"String","current_value.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Current Value\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"3\\",\\"max_length\\":\\"0\\"}"},"field_name":"String","field_name.$field_facets":{"SimpleMapFacet":"{\\"uiTypeLabel\\":\\"String\\",\\"read_only\\":\\"false\\",\\"hint\\":\\"\\",\\"uiType\\":\\"string\\",\\"default_value\\":\\"\\",\\"label\\":\\"Field Name\\",\\"mandatory\\":\\"false\\",\\"order\\":\\"1\\",\\"max_length\\":\\"0\\"}"}}}],"$COCollectionField.$type_facets":{"SimpleMapFacet":"{\\"pwd2droppable\\":\\"true\\",\\"default_value\\":\\"\\",\\"label\\":\\"Changed Fields\\",\\"mandatory\\":\\"false\\",\\"child_name\\":\\"FDChangeDetails\\",\\"uiTypeLabel\\":\\"Array.Object\\",\\"co_type_name\\":\\"FDCollection\\",\\"child_label\\":\\"FDChangeDetails\\",\\"child_type_label\\":\\"Object\\",\\"element_mapping_provider\\":\\"com.glide.flow_design.action.data.FlowDesignVariableMapper\\",\\"read_only\\":\\"false\\",\\"hint\\":null,\\"uiType\\":\\"array.object\\",\\"child_type\\":\\"object\\",\\"order\\":\\"1\\",\\"max_length\\":\\"8000\\"}"},"$COCollectionField.$field_facets":{"SimpleMapFacet":"{\\"up-shift-collection-level\\":\\"true\\"}"}},"FlowDesigner:FDCollection.$type_facets":{"SimpleMapFacet":"{\\"pwd2droppable\\":\\"true\\",\\"default_value\\":\\"\\",\\"label\\":\\"Changed Fields\\",\\"mandatory\\":\\"false\\",\\"child_name\\":\\"FDChangeDetails\\",\\"uiTypeLabel\\":\\"Array.Object\\",\\"co_type_name\\":\\"FDCollection\\",\\"child_label\\":\\"FDChangeDetails\\",\\"child_type_label\\":\\"Object\\",\\"element_mapping_provider\\":\\"com.glide.flow_design.action.data.FlowDesignVariableMapper\\",\\"read_only\\":\\"false\\",\\"hint\\":null,\\"uiType\\":\\"array.object\\",\\"child_type\\":\\"object\\",\\"order\\":\\"1\\",\\"max_length\\":\\"8000\\"}"}}',
|
|
71
|
+
sys_domain: 'global',
|
|
72
|
+
type: 'complex_object_collection',
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const builtInComplexObjects: Record<string, BuiltInComplexObject> = {
|
|
77
|
+
FDChangeDetails,
|
|
78
|
+
FDSTEPSTATUS,
|
|
79
|
+
FDACTIONSTATUS,
|
|
80
|
+
FDCollection,
|
|
81
|
+
}
|