@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,632 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CallExpressionShape,
|
|
3
|
+
type IdentifierShape,
|
|
4
|
+
type Record,
|
|
5
|
+
Shape,
|
|
6
|
+
VariableStatementShape,
|
|
7
|
+
ObjectShape,
|
|
8
|
+
type Diagnostics,
|
|
9
|
+
type Logger,
|
|
10
|
+
} from '@servicenow/sdk-build-core'
|
|
11
|
+
import { ArrowFunctionShape } from '../../arrow-function-plugin'
|
|
12
|
+
import { FLOW_LOGIC, FLOW_LOGIC_PREFIX } from '../flow-logic/flow-logic-constants'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Result of datapill transformation
|
|
16
|
+
*/
|
|
17
|
+
export interface DatapillTransformResult {
|
|
18
|
+
shape: Shape
|
|
19
|
+
propsChanged: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Information about a flow instance shape for processing
|
|
24
|
+
*/
|
|
25
|
+
export interface FlowInstanceShapeInfo {
|
|
26
|
+
callExpression: CallExpressionShape
|
|
27
|
+
variableStatement: VariableStatementShape | CallExpressionShape
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Flow logic types that have outputs and can be assigned to a variable
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* TODO: Extend this list as more flow logics with outputs are added also try to create map to identify arguments dynamically
|
|
35
|
+
* e.g., flow logic like waitForADuration has config at arg 0 and outputs, while others may have different positions
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
const FLOW_LOGIC_WITH_OUTPUTS = [FLOW_LOGIC.WAIT_FOR_A_DURATION]
|
|
39
|
+
|
|
40
|
+
// Module-level map to store UUID-to-Record mapping for forEach detection
|
|
41
|
+
// This is populated by buildUuidToIdentifierMap and used by isForEachParameter
|
|
42
|
+
export const uuidToRecordMap = new Map<string, Record>()
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Build a map of UUID to variable identifiers from instance records and shapes
|
|
46
|
+
* This map is used to transform UUID-based datapills into property access expressions
|
|
47
|
+
* Uses ui_id from records (not $id from config) because datapills reference ui_id
|
|
48
|
+
*
|
|
49
|
+
* @param recordToShapeMap - Map of instance records to their corresponding shapes
|
|
50
|
+
* @returns Map of UUID strings (ui_id) to IdentifierShapes
|
|
51
|
+
*/
|
|
52
|
+
export function buildUuidToIdentifierMap(recordToShapeMap: Map<Record, Shape>): Map<string, IdentifierShape> {
|
|
53
|
+
const uuidToIdentifierMap = new Map<string, IdentifierShape>()
|
|
54
|
+
|
|
55
|
+
// Clear and rebuild the module-level UUID-to-Record map
|
|
56
|
+
uuidToRecordMap.clear()
|
|
57
|
+
|
|
58
|
+
for (const [record, instanceShape] of recordToShapeMap.entries()) {
|
|
59
|
+
// Extract ui_id from the record (this is what datapills reference)
|
|
60
|
+
const uiId = record.get('ui_id')?.getValue() as string | undefined
|
|
61
|
+
|
|
62
|
+
if (!uiId) {
|
|
63
|
+
continue
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Handle VariableStatementShape (actions/subflows with variable assignments)
|
|
67
|
+
if (instanceShape instanceof VariableStatementShape) {
|
|
68
|
+
const variableStatement = instanceShape.as(VariableStatementShape)
|
|
69
|
+
const variableName = variableStatement.getVariableName()
|
|
70
|
+
const callExpression = variableStatement.getInitializer().as(CallExpressionShape)
|
|
71
|
+
|
|
72
|
+
const callee = callExpression.getCallee()
|
|
73
|
+
|
|
74
|
+
// For flow logic with outputs (e.g., waitForADuration), config is at position 0
|
|
75
|
+
// For actions/subflows, config is at position 1
|
|
76
|
+
const isFlowLogicWithOutputs = FLOW_LOGIC_WITH_OUTPUTS.includes(callee as FLOW_LOGIC)
|
|
77
|
+
const configArgIndex = isFlowLogicWithOutputs ? 0 : 1
|
|
78
|
+
const configArg = callExpression.getArgument(configArgIndex)?.asObject()
|
|
79
|
+
|
|
80
|
+
if (configArg) {
|
|
81
|
+
const uuid = configArg.get('uuid')?.ifString()?.getValue()
|
|
82
|
+
if (uuid && variableName) {
|
|
83
|
+
uuidToIdentifierMap.set(uuid, variableName)
|
|
84
|
+
uuidToRecordMap.set(uuid, record)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Handle CallExpressionShape (flow logic like forEach)
|
|
89
|
+
else if (instanceShape instanceof CallExpressionShape) {
|
|
90
|
+
const callExpression = instanceShape.as(CallExpressionShape)
|
|
91
|
+
const callee = callExpression.getCallee()
|
|
92
|
+
|
|
93
|
+
if (callee === 'wfa.flowLogic.forEach') {
|
|
94
|
+
// Get the arrow function body (3rd argument for forEach)
|
|
95
|
+
// NOTE: For nested forEach, parameter names are order-based (item_0, item_1, item_2, etc.)
|
|
96
|
+
// This allows distinguishing which parent forEach an 'item' reference belongs to
|
|
97
|
+
// Example:
|
|
98
|
+
// forEach at order 0: (item_0) => { ... }
|
|
99
|
+
// forEach at order 1: (item_1) => { ... }
|
|
100
|
+
// In XML, datapills are stored as {{forEachUUID.item.field}}
|
|
101
|
+
// which gets transformed to item_0.field, item_1.field, etc. based on the UUID mapping
|
|
102
|
+
const bodyArg = callExpression.getArgument(2)
|
|
103
|
+
if (bodyArg?.if(ArrowFunctionShape)) {
|
|
104
|
+
const arrowFunc = bodyArg.as(ArrowFunctionShape)
|
|
105
|
+
const params = arrowFunc.getParameters()
|
|
106
|
+
// getParameters() returns IdentifierShape[] - use directly
|
|
107
|
+
if (params && params.length > 0) {
|
|
108
|
+
const paramIdentifier = params[0]
|
|
109
|
+
if (paramIdentifier) {
|
|
110
|
+
uuidToIdentifierMap.set(uiId, paramIdentifier)
|
|
111
|
+
uuidToRecordMap.set(uiId, record)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return uuidToIdentifierMap
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Extract CallExpression and VariableStatement from an instance shape
|
|
124
|
+
* Handles both VariableStatementShape (for Action/Subflow) and bare CallExpressionShape (for flow logic)
|
|
125
|
+
*
|
|
126
|
+
* @param instanceShape - The shape to extract from
|
|
127
|
+
* @returns Object containing callExpression and variableStatement
|
|
128
|
+
*/
|
|
129
|
+
export function extractInstanceShapeInfo(instanceShape: Shape): FlowInstanceShapeInfo {
|
|
130
|
+
let callExpression: CallExpressionShape
|
|
131
|
+
let variableStatement: VariableStatementShape | CallExpressionShape
|
|
132
|
+
|
|
133
|
+
if (instanceShape instanceof VariableStatementShape) {
|
|
134
|
+
callExpression = instanceShape.getInitializer().as(CallExpressionShape)
|
|
135
|
+
variableStatement = instanceShape
|
|
136
|
+
} else {
|
|
137
|
+
callExpression = instanceShape.as(CallExpressionShape)
|
|
138
|
+
variableStatement = callExpression
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return { callExpression, variableStatement }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Rebuild a CallExpressionShape with transformed properties
|
|
146
|
+
* Creates a new CallExpression with the transformed props and cleaned config
|
|
147
|
+
*
|
|
148
|
+
* @param originalCallExpression - The original CallExpression
|
|
149
|
+
* @param transformedProps - The transformed properties object
|
|
150
|
+
* @param configShape - The config shape (possibly cleaned)
|
|
151
|
+
* @param record - The source record for shape creation
|
|
152
|
+
* @returns New CallExpressionShape with transformed properties
|
|
153
|
+
*/
|
|
154
|
+
export function rebuildCallExpressionWithDatapills(
|
|
155
|
+
originalCallExpression: CallExpressionShape,
|
|
156
|
+
transformedProps: { [key: string]: Shape },
|
|
157
|
+
configShape: Shape,
|
|
158
|
+
record: Record
|
|
159
|
+
): CallExpressionShape {
|
|
160
|
+
const originalActionDef = originalCallExpression.getArgument(0, false)
|
|
161
|
+
const newPropsArg = Shape.from(record, transformedProps)
|
|
162
|
+
|
|
163
|
+
return new CallExpressionShape({
|
|
164
|
+
source: originalCallExpression.getSource(),
|
|
165
|
+
callee: originalCallExpression.getCallee(),
|
|
166
|
+
args: [originalActionDef, configShape, newPropsArg],
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Rebuild an instance shape (VariableStatement or CallExpression) with transformed datapills
|
|
172
|
+
*
|
|
173
|
+
* @param instanceShape - The original instance shape
|
|
174
|
+
* @param newCallExpression - The new CallExpression with transformed properties
|
|
175
|
+
* @param instanceShapeInfo - Information extracted from the instance shape
|
|
176
|
+
* @returns Rebuilt VariableStatementShape or the new CallExpression
|
|
177
|
+
*/
|
|
178
|
+
export function rebuildInstanceWithDatapills(
|
|
179
|
+
instanceShape: Shape,
|
|
180
|
+
newCallExpression: CallExpressionShape,
|
|
181
|
+
instanceShapeInfo: FlowInstanceShapeInfo
|
|
182
|
+
): Shape {
|
|
183
|
+
const { variableStatement } = instanceShapeInfo
|
|
184
|
+
|
|
185
|
+
if (instanceShape instanceof VariableStatementShape) {
|
|
186
|
+
return new VariableStatementShape({
|
|
187
|
+
source: variableStatement.getSource(),
|
|
188
|
+
variableName:
|
|
189
|
+
variableStatement instanceof VariableStatementShape
|
|
190
|
+
? variableStatement.getVariableName()
|
|
191
|
+
: 'dummyVariable_removeLater', // For flow logic that returns outputs
|
|
192
|
+
initializer: newCallExpression,
|
|
193
|
+
isExported: false,
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Return the CallExpression directly for non-variable statements (flow logic)
|
|
198
|
+
return newCallExpression
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Check if a callee string represents a flow logic call
|
|
203
|
+
* @param callee - The callee string (e.g., 'wfa.flowLogic.if', 'wfa.action')
|
|
204
|
+
* @returns true if the callee is a flow logic call
|
|
205
|
+
*/
|
|
206
|
+
export function isFlowLogicCallee(callee: string): boolean {
|
|
207
|
+
return callee.startsWith(FLOW_LOGIC_PREFIX)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Check if a flow logic type has a body (arrow function)
|
|
212
|
+
* @param callee - The flow logic callee (e.g., 'wfa.flowLogic.if')
|
|
213
|
+
* @returns true if the flow logic has a body
|
|
214
|
+
*/
|
|
215
|
+
export function flowLogicHasBody(callee: string): boolean {
|
|
216
|
+
// Flow logic with bodies: if, elseIf, else, forEach, tryCatch, doInParallel
|
|
217
|
+
// Flow logic without bodies: goBackTo, waitForADuration, exitLoop, endFlow, skipIteration
|
|
218
|
+
return [
|
|
219
|
+
FLOW_LOGIC.IF,
|
|
220
|
+
FLOW_LOGIC.ELSEIF,
|
|
221
|
+
FLOW_LOGIC.ELSE,
|
|
222
|
+
FLOW_LOGIC.FOR_EACH,
|
|
223
|
+
FLOW_LOGIC.TRY_CATCH,
|
|
224
|
+
FLOW_LOGIC.DO_IN_PARALLEL,
|
|
225
|
+
].includes(callee as FLOW_LOGIC)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Extract arrow function bodies from a flow logic call expression
|
|
230
|
+
* Different flow logic types have bodies in different positions:
|
|
231
|
+
* - If/ElseIf/Else: Single body at argument 1
|
|
232
|
+
* - ForEach: Body at argument 2 (arg 0 is items, arg 1 is config)
|
|
233
|
+
* - TryCatch: Object with 'try' and 'catch' properties containing arrow functions
|
|
234
|
+
* - DoInParallel: Variadic functions starting from argument 1
|
|
235
|
+
*
|
|
236
|
+
* @param callExpression - The flow logic call expression
|
|
237
|
+
* @param callee - The flow logic callee
|
|
238
|
+
* @returns Array of arrow function shapes
|
|
239
|
+
*/
|
|
240
|
+
export function extractFlowLogicBodies(callExpression: CallExpressionShape, callee: string): ArrowFunctionShape[] {
|
|
241
|
+
const bodies: ArrowFunctionShape[] = []
|
|
242
|
+
|
|
243
|
+
if (callee === FLOW_LOGIC.TRY_CATCH) {
|
|
244
|
+
// TryCatch: { try: () => {...}, catch: () => {...} }
|
|
245
|
+
const handlers = callExpression.getArgument(1)?.asObject()
|
|
246
|
+
if (handlers) {
|
|
247
|
+
const tryHandler = handlers.get('try')
|
|
248
|
+
const catchHandler = handlers.get('catch')
|
|
249
|
+
if (tryHandler?.if(ArrowFunctionShape)) {
|
|
250
|
+
bodies.push(tryHandler.as(ArrowFunctionShape))
|
|
251
|
+
}
|
|
252
|
+
if (catchHandler?.if(ArrowFunctionShape)) {
|
|
253
|
+
bodies.push(catchHandler.as(ArrowFunctionShape))
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
} else if (callee === FLOW_LOGIC.DO_IN_PARALLEL) {
|
|
257
|
+
// DoInParallel: config, fn1, fn2, fn3, ...
|
|
258
|
+
const allArgs = callExpression.getArguments()
|
|
259
|
+
for (let i = 1; i < allArgs.length; i++) {
|
|
260
|
+
const arg = callExpression.getArgument(i)
|
|
261
|
+
if (arg?.if(ArrowFunctionShape)) {
|
|
262
|
+
bodies.push(arg.as(ArrowFunctionShape))
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
} else if (callee === FLOW_LOGIC.FOR_EACH) {
|
|
266
|
+
// ForEach: items, config, body
|
|
267
|
+
const bodyArg = callExpression.getArgument(2)
|
|
268
|
+
if (bodyArg?.if(ArrowFunctionShape)) {
|
|
269
|
+
bodies.push(bodyArg.as(ArrowFunctionShape))
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
// If/ElseIf/Else: config, body
|
|
273
|
+
const bodyArg = callExpression.getArgument(1)
|
|
274
|
+
if (bodyArg?.if(ArrowFunctionShape)) {
|
|
275
|
+
bodies.push(bodyArg.as(ArrowFunctionShape))
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return bodies
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Rebuild a flow logic call expression with transformed config and bodies
|
|
284
|
+
* @param callExpression - Original call expression
|
|
285
|
+
* @param transformedConfig - Transformed config object
|
|
286
|
+
* @param transformedBodies - Transformed arrow function bodies
|
|
287
|
+
* @param callee - The flow logic callee
|
|
288
|
+
* @param record - The source record
|
|
289
|
+
* @returns Rebuilt CallExpressionShape
|
|
290
|
+
*/
|
|
291
|
+
export function rebuildFlowLogicWithDatapills(
|
|
292
|
+
callExpression: CallExpressionShape,
|
|
293
|
+
transformedConfig: ObjectShape,
|
|
294
|
+
transformedBodies: ArrowFunctionShape[],
|
|
295
|
+
callee: string,
|
|
296
|
+
record: Record,
|
|
297
|
+
transformedItemsArg?: Shape
|
|
298
|
+
): CallExpressionShape {
|
|
299
|
+
if (callee === FLOW_LOGIC.TRY_CATCH) {
|
|
300
|
+
// TryCatch: config, { try: fn1, catch: fn2 }
|
|
301
|
+
const handlersObj = Shape.from(record, {
|
|
302
|
+
try: transformedBodies[0],
|
|
303
|
+
catch: transformedBodies[1],
|
|
304
|
+
})
|
|
305
|
+
return new CallExpressionShape({
|
|
306
|
+
source: callExpression.getSource(),
|
|
307
|
+
callee: callExpression.getCallee(),
|
|
308
|
+
args: [transformedConfig, handlersObj],
|
|
309
|
+
})
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (callee === 'wfa.flowLogic.doInParallel') {
|
|
313
|
+
// DoInParallel: config, fn1, fn2, ...
|
|
314
|
+
return new CallExpressionShape({
|
|
315
|
+
source: callExpression.getSource(),
|
|
316
|
+
callee: callExpression.getCallee(),
|
|
317
|
+
args: [transformedConfig, ...transformedBodies],
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (callee === 'wfa.flowLogic.forEach') {
|
|
322
|
+
// ForEach: items, config, body
|
|
323
|
+
// Use transformed items if available, otherwise use original
|
|
324
|
+
const itemsArg = transformedItemsArg || callExpression.getArgument(0, false)
|
|
325
|
+
return new CallExpressionShape({
|
|
326
|
+
source: callExpression.getSource(),
|
|
327
|
+
callee: callExpression.getCallee(),
|
|
328
|
+
args: [itemsArg, transformedConfig, transformedBodies[0]],
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// If/ElseIf/Else: config, body
|
|
333
|
+
return new CallExpressionShape({
|
|
334
|
+
source: callExpression.getSource(),
|
|
335
|
+
callee: callExpression.getCallee(),
|
|
336
|
+
args: [transformedConfig, transformedBodies[0]],
|
|
337
|
+
})
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Type for config cleanup callback function
|
|
342
|
+
* Used to clean up Action/Subflow configs after transformation
|
|
343
|
+
*/
|
|
344
|
+
export type ConfigCleanupCallback = (configShape: Shape, instanceSource: Shape) => Shape
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Recursively process an instance shape (Action, Subflow, or Flow Logic) to transform datapills
|
|
348
|
+
* This is the main entry point for datapill transformation that handles all instance types
|
|
349
|
+
*
|
|
350
|
+
* @param instanceShape - The instance shape to process (VariableStatementShape or CallExpressionShape)
|
|
351
|
+
* @param uuidToIdentifierMap - Map of UUID to variable identifiers for UUID-based datapills
|
|
352
|
+
* @param record - The source record for shape creation
|
|
353
|
+
* @param diagnostics - Diagnostics for error reporting
|
|
354
|
+
* @param paramName - Parameter name for semantic datapills (e.g., 'params')
|
|
355
|
+
* @param processShapeForDatapills - Recursive helper to process nested structures (objects/arrays)
|
|
356
|
+
* @param cleanupConfig - Optional callback to clean up Action/Subflow configs
|
|
357
|
+
* @returns DatapillTransformResult with transformed shape and change tracking
|
|
358
|
+
*/
|
|
359
|
+
export function processInstanceForDatapills(
|
|
360
|
+
instanceShape: Shape,
|
|
361
|
+
uuidToIdentifierMap: Map<string, IdentifierShape>,
|
|
362
|
+
record: Record,
|
|
363
|
+
diagnostics: Diagnostics,
|
|
364
|
+
paramName: string,
|
|
365
|
+
logger: Logger,
|
|
366
|
+
processShapeForDatapills: (
|
|
367
|
+
value: Shape,
|
|
368
|
+
uuidToIdentifierMap: Map<string, IdentifierShape>,
|
|
369
|
+
source: Record,
|
|
370
|
+
diagnostics: Diagnostics,
|
|
371
|
+
logger: Logger,
|
|
372
|
+
parameterName?: string
|
|
373
|
+
) => DatapillTransformResult,
|
|
374
|
+
cleanupConfig?: ConfigCleanupCallback
|
|
375
|
+
): DatapillTransformResult {
|
|
376
|
+
// Step 1: Extract call expression and variable statement
|
|
377
|
+
const { callExpression, variableStatement } = extractInstanceShapeInfo(instanceShape)
|
|
378
|
+
const callee = callExpression.getCallee()
|
|
379
|
+
const isFlowLogic = isFlowLogicCallee(callee)
|
|
380
|
+
|
|
381
|
+
// Step 2: Determine which properties to transform based on instance type
|
|
382
|
+
let propsArg: Shape | undefined
|
|
383
|
+
let configArgIndex: number
|
|
384
|
+
|
|
385
|
+
if (isFlowLogic) {
|
|
386
|
+
// For SetFlowVariables and AssignSubflowOutputs, transform the values object (3rd argument)
|
|
387
|
+
// For ForEach, transform the config (2nd argument)
|
|
388
|
+
// For other flow logic, transform the config (1st argument)
|
|
389
|
+
if (callee === FLOW_LOGIC.SET_FLOW_VARIABLES || callee === FLOW_LOGIC.ASSIGN_SUBFLOW_OUTPUTS) {
|
|
390
|
+
configArgIndex = 2
|
|
391
|
+
propsArg = callExpression.getArgument(2)
|
|
392
|
+
} else if (callee === FLOW_LOGIC.FOR_EACH) {
|
|
393
|
+
configArgIndex = 1
|
|
394
|
+
propsArg = callExpression.getArgument(1)
|
|
395
|
+
} else {
|
|
396
|
+
configArgIndex = 0
|
|
397
|
+
propsArg = callExpression.getArgument(0)
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
// For Action/Subflow, we transform the inputs (3rd argument)
|
|
401
|
+
configArgIndex = 2
|
|
402
|
+
propsArg = callExpression.getArgument(configArgIndex)
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
let overallChanged = false
|
|
406
|
+
|
|
407
|
+
if (!propsArg.isDefined()) {
|
|
408
|
+
return { shape: instanceShape, propsChanged: false }
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Step 3: Transform schema argument for SetFlowVariables and AssignSubflowOutputs
|
|
412
|
+
// The schema argument (arg 1) contains PropertyAccessShape with placeholder identifier (_params)
|
|
413
|
+
// that needs to be resolved to the actual parameter name
|
|
414
|
+
let transformedSchemaArg: Shape | undefined
|
|
415
|
+
if (callee === FLOW_LOGIC.SET_FLOW_VARIABLES || callee === FLOW_LOGIC.ASSIGN_SUBFLOW_OUTPUTS) {
|
|
416
|
+
const schemaArg = callExpression.getArgument(1)
|
|
417
|
+
if (schemaArg) {
|
|
418
|
+
const schemaResult = processShapeForDatapills(
|
|
419
|
+
schemaArg,
|
|
420
|
+
uuidToIdentifierMap,
|
|
421
|
+
record,
|
|
422
|
+
diagnostics,
|
|
423
|
+
logger,
|
|
424
|
+
paramName
|
|
425
|
+
)
|
|
426
|
+
transformedSchemaArg = schemaResult.shape
|
|
427
|
+
if (schemaResult.propsChanged) {
|
|
428
|
+
overallChanged = true
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Step 3.5: Transform items argument for ForEach
|
|
434
|
+
// The items argument (arg 0) contains data pill strings like "{{trigger.array_field}}"
|
|
435
|
+
// that need to be converted to PropertyAccessShape with the correct parameter name
|
|
436
|
+
let transformedItemsArg: Shape | undefined
|
|
437
|
+
if (callee === FLOW_LOGIC.FOR_EACH) {
|
|
438
|
+
const itemsArg = callExpression.getArgument(0)
|
|
439
|
+
if (itemsArg) {
|
|
440
|
+
const itemsResult = processShapeForDatapills(
|
|
441
|
+
itemsArg,
|
|
442
|
+
uuidToIdentifierMap,
|
|
443
|
+
record,
|
|
444
|
+
diagnostics,
|
|
445
|
+
logger,
|
|
446
|
+
paramName
|
|
447
|
+
)
|
|
448
|
+
transformedItemsArg = itemsResult.shape
|
|
449
|
+
if (itemsResult.propsChanged) {
|
|
450
|
+
overallChanged = true
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// Note: goBackTo step ID should remain as UUID string for XML serialization
|
|
456
|
+
// It will be resolved to an identifier during the flow-logic-plugin-helpers.ts transformation
|
|
457
|
+
|
|
458
|
+
// Step 4: Transform properties in config/inputs/values
|
|
459
|
+
let transformedConfig: ObjectShape | undefined
|
|
460
|
+
if (propsArg.isObject()) {
|
|
461
|
+
const propsObj = propsArg.asObject()
|
|
462
|
+
const propsEntries = propsObj.entries()
|
|
463
|
+
const transformedProps: { [key: string]: Shape } = {}
|
|
464
|
+
let propsChanged = false
|
|
465
|
+
|
|
466
|
+
for (const [key, value] of propsEntries) {
|
|
467
|
+
const result = processShapeForDatapills(value, uuidToIdentifierMap, record, diagnostics, logger, paramName)
|
|
468
|
+
transformedProps[key] = result.shape
|
|
469
|
+
|
|
470
|
+
if (result.propsChanged) {
|
|
471
|
+
propsChanged = true
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (propsChanged) {
|
|
476
|
+
transformedConfig = new ObjectShape({
|
|
477
|
+
source: propsArg.getSource(),
|
|
478
|
+
properties: transformedProps,
|
|
479
|
+
})
|
|
480
|
+
overallChanged = true
|
|
481
|
+
} else {
|
|
482
|
+
transformedConfig = propsObj
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Check if config cleanup would make changes (before overallChanged check)
|
|
486
|
+
// This ensures we don't early-return when cleanup is needed
|
|
487
|
+
if (cleanupConfig) {
|
|
488
|
+
// For Action/Subflow instances, check config (argument 1)
|
|
489
|
+
if (!isFlowLogic) {
|
|
490
|
+
const originalConfig = callExpression.getArgument(1)
|
|
491
|
+
if (originalConfig) {
|
|
492
|
+
const cleanedConfig = cleanupConfig(originalConfig, instanceShape)
|
|
493
|
+
if (cleanedConfig !== originalConfig) {
|
|
494
|
+
overallChanged = true
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// For flow logic with outputs (e.g., WaitForADuration), check config (argument 0)
|
|
500
|
+
const isFlowLogicWithOutputs = FLOW_LOGIC_WITH_OUTPUTS.includes(callee as FLOW_LOGIC)
|
|
501
|
+
if (isFlowLogicWithOutputs && transformedConfig) {
|
|
502
|
+
const cleanedConfig = cleanupConfig(transformedConfig, callExpression)
|
|
503
|
+
if (cleanedConfig !== transformedConfig) {
|
|
504
|
+
overallChanged = true
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Step 4: Handle flow logic with bodies (recursive processing of child instances)
|
|
511
|
+
const transformedBodies: ArrowFunctionShape[] = []
|
|
512
|
+
if (isFlowLogic && flowLogicHasBody(callee)) {
|
|
513
|
+
const bodies = extractFlowLogicBodies(callExpression, callee)
|
|
514
|
+
|
|
515
|
+
for (const body of bodies) {
|
|
516
|
+
const childInstances = body.getStatements()
|
|
517
|
+
const transformedChildren: Shape[] = []
|
|
518
|
+
let anyChildChanged = false
|
|
519
|
+
|
|
520
|
+
// Recursively process each child instance
|
|
521
|
+
for (const childInstance of childInstances) {
|
|
522
|
+
const childResult = processInstanceForDatapills(
|
|
523
|
+
childInstance,
|
|
524
|
+
uuidToIdentifierMap,
|
|
525
|
+
record,
|
|
526
|
+
diagnostics,
|
|
527
|
+
paramName,
|
|
528
|
+
logger,
|
|
529
|
+
processShapeForDatapills,
|
|
530
|
+
cleanupConfig
|
|
531
|
+
)
|
|
532
|
+
transformedChildren.push(childResult.shape)
|
|
533
|
+
|
|
534
|
+
if (childResult.propsChanged) {
|
|
535
|
+
anyChildChanged = true
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// Rebuild body if children changed
|
|
540
|
+
const transformedBody = anyChildChanged
|
|
541
|
+
? new ArrowFunctionShape({
|
|
542
|
+
source: body.getSource(),
|
|
543
|
+
parameters: body.getParameters(),
|
|
544
|
+
statements: transformedChildren,
|
|
545
|
+
})
|
|
546
|
+
: body
|
|
547
|
+
|
|
548
|
+
transformedBodies.push(transformedBody)
|
|
549
|
+
|
|
550
|
+
if (anyChildChanged) {
|
|
551
|
+
overallChanged = true
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// Step 5: Rebuild instance if anything changed
|
|
557
|
+
if (!overallChanged) {
|
|
558
|
+
return {
|
|
559
|
+
shape: instanceShape,
|
|
560
|
+
propsChanged: false,
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// Rebuild the call expression
|
|
565
|
+
let newCallExpression: CallExpressionShape
|
|
566
|
+
|
|
567
|
+
if (isFlowLogic && transformedBodies.length > 0 && transformedConfig) {
|
|
568
|
+
// Rebuild flow logic with transformed config and bodies
|
|
569
|
+
newCallExpression = rebuildFlowLogicWithDatapills(
|
|
570
|
+
callExpression,
|
|
571
|
+
transformedConfig,
|
|
572
|
+
transformedBodies,
|
|
573
|
+
callee,
|
|
574
|
+
record,
|
|
575
|
+
transformedItemsArg // Pass transformed items for ForEach
|
|
576
|
+
)
|
|
577
|
+
} else {
|
|
578
|
+
// Rebuild Action/Subflow or flow logic without body
|
|
579
|
+
const originalActionDef = callExpression.getArgument(0, false)
|
|
580
|
+
let originalConfig = callExpression.getArgument(1)
|
|
581
|
+
|
|
582
|
+
// Apply config cleanup for Action/Subflow instances
|
|
583
|
+
if (!isFlowLogic && cleanupConfig && originalConfig) {
|
|
584
|
+
originalConfig = cleanupConfig(originalConfig, instanceShape)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const isFlowLogicWithOutputs = FLOW_LOGIC_WITH_OUTPUTS.includes(callee as FLOW_LOGIC)
|
|
588
|
+
if (isFlowLogicWithOutputs && cleanupConfig && transformedConfig) {
|
|
589
|
+
transformedConfig = cleanupConfig(transformedConfig, callExpression).asObject()
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const newArgs: Shape[] = []
|
|
593
|
+
|
|
594
|
+
if (configArgIndex === 2) {
|
|
595
|
+
// Action/Subflow OR SetFlowVariables/AssignSubflowOutputs: definition/config, schema/config, inputs/values
|
|
596
|
+
newArgs.push(originalActionDef)
|
|
597
|
+
// For SetFlowVariables/AssignSubflowOutputs, use transformed schema arg if available
|
|
598
|
+
if (transformedSchemaArg) {
|
|
599
|
+
newArgs.push(transformedSchemaArg)
|
|
600
|
+
} else if (originalConfig) {
|
|
601
|
+
newArgs.push(originalConfig)
|
|
602
|
+
}
|
|
603
|
+
newArgs.push(Shape.from(record, transformedConfig))
|
|
604
|
+
} else if (configArgIndex === 1 && transformedConfig) {
|
|
605
|
+
// ForEach: items, config
|
|
606
|
+
// Use transformed items if available, otherwise use original
|
|
607
|
+
const itemsArg = transformedItemsArg || callExpression.getArgument(0, false)
|
|
608
|
+
newArgs.push(itemsArg)
|
|
609
|
+
newArgs.push(transformedConfig)
|
|
610
|
+
} else if (configArgIndex === 0 && transformedConfig) {
|
|
611
|
+
// Flow logic without body: just config
|
|
612
|
+
newArgs.push(transformedConfig)
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
newCallExpression = new CallExpressionShape({
|
|
616
|
+
source: callExpression.getSource(),
|
|
617
|
+
callee: callExpression.getCallee(),
|
|
618
|
+
args: newArgs,
|
|
619
|
+
})
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// Rebuild instance (VariableStatement or CallExpression)
|
|
623
|
+
const rebuiltInstance = rebuildInstanceWithDatapills(instanceShape, newCallExpression, {
|
|
624
|
+
callExpression,
|
|
625
|
+
variableStatement,
|
|
626
|
+
})
|
|
627
|
+
|
|
628
|
+
return {
|
|
629
|
+
shape: rebuiltInstance,
|
|
630
|
+
propsChanged: true,
|
|
631
|
+
}
|
|
632
|
+
}
|