@servicenow/sdk-build-plugins 4.6.1 → 4.7.1
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 +0 -3
- package/dist/acl-plugin.js.map +1 -1
- package/dist/applicability-plugin.js +0 -2
- package/dist/applicability-plugin.js.map +1 -1
- package/dist/application-menu-plugin.js +0 -2
- package/dist/application-menu-plugin.js.map +1 -1
- package/dist/arrow-function-plugin.js +0 -1
- package/dist/arrow-function-plugin.js.map +1 -1
- package/dist/atf/test-plugin.js +0 -2
- package/dist/atf/test-plugin.js.map +1 -1
- package/dist/basic-syntax-plugin.js +0 -1
- package/dist/basic-syntax-plugin.js.map +1 -1
- package/dist/business-rule-plugin.js +0 -1
- package/dist/business-rule-plugin.js.map +1 -1
- package/dist/call-expression-plugin.js +0 -1
- package/dist/call-expression-plugin.js.map +1 -1
- package/dist/claims-plugin.js +0 -1
- package/dist/claims-plugin.js.map +1 -1
- package/dist/client-script-plugin.js +0 -1
- package/dist/client-script-plugin.js.map +1 -1
- package/dist/column-plugin.js +24 -7
- package/dist/column-plugin.js.map +1 -1
- package/dist/cross-scope-privilege-plugin.js +0 -1
- package/dist/cross-scope-privilege-plugin.js.map +1 -1
- package/dist/dashboard/dashboard-plugin.js +0 -2
- package/dist/dashboard/dashboard-plugin.js.map +1 -1
- package/dist/data-plugin.js +0 -1
- package/dist/data-plugin.js.map +1 -1
- package/dist/data-policy-plugin.d.ts +2 -0
- package/dist/data-policy-plugin.js +276 -0
- package/dist/data-policy-plugin.js.map +1 -0
- package/dist/email-notification-plugin.js +2 -3
- package/dist/email-notification-plugin.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-constants.d.ts +2 -0
- package/dist/flow/flow-logic/flow-logic-constants.js +6 -1
- package/dist/flow/flow-logic/flow-logic-constants.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-diagnostics.js +192 -56
- package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +2 -1
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +44 -5
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-plugin.js +279 -29
- package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-shapes.d.ts +15 -0
- package/dist/flow/flow-logic/flow-logic-shapes.js +25 -1
- package/dist/flow/flow-logic/flow-logic-shapes.js.map +1 -1
- package/dist/flow/plugins/approval-rules-plugin.js +0 -1
- package/dist/flow/plugins/approval-rules-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-action-definition-plugin.js +804 -205
- package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-data-pill-plugin.js +3 -5
- package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-definition-plugin.js +84 -17
- package/dist/flow/plugins/flow-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-diagnostics-plugin.js +65 -3
- package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-instance-plugin.js +13 -5
- package/dist/flow/plugins/flow-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-trigger-instance-plugin.js +0 -1
- package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/inline-script-plugin.js +0 -1
- package/dist/flow/plugins/inline-script-plugin.js.map +1 -1
- package/dist/flow/plugins/step-definition-plugin.js +0 -2
- package/dist/flow/plugins/step-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/step-instance-plugin.js +216 -77
- package/dist/flow/plugins/step-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/trigger-plugin.js +0 -2
- package/dist/flow/plugins/trigger-plugin.js.map +1 -1
- package/dist/flow/plugins/wfa-datapill-plugin.js +0 -1
- package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -1
- package/dist/flow/utils/datapill-transformer.js +9 -5
- package/dist/flow/utils/datapill-transformer.js.map +1 -1
- package/dist/flow/utils/flow-constants.d.ts +12 -0
- package/dist/flow/utils/flow-constants.js +17 -3
- package/dist/flow/utils/flow-constants.js.map +1 -1
- package/dist/flow/utils/flow-io-to-record.d.ts +1 -1
- package/dist/flow/utils/flow-io-to-record.js +21 -13
- package/dist/flow/utils/flow-io-to-record.js.map +1 -1
- package/dist/flow/utils/flow-pill-utils.d.ts +26 -0
- package/dist/flow/utils/flow-pill-utils.js +50 -0
- package/dist/flow/utils/flow-pill-utils.js.map +1 -0
- package/dist/flow/utils/flow-stage-processor.d.ts +138 -0
- package/dist/flow/utils/flow-stage-processor.js +665 -0
- package/dist/flow/utils/flow-stage-processor.js.map +1 -0
- package/dist/flow/utils/pill-string-parser.js +28 -43
- package/dist/flow/utils/pill-string-parser.js.map +1 -1
- package/dist/flow/utils/utils.d.ts +11 -6
- package/dist/flow/utils/utils.js +37 -28
- package/dist/flow/utils/utils.js.map +1 -1
- package/dist/form-plugin.js +4 -14
- package/dist/form-plugin.js.map +1 -1
- package/dist/html-import-plugin.js +0 -1
- package/dist/html-import-plugin.js.map +1 -1
- package/dist/import-sets-plugin.js +0 -2
- package/dist/import-sets-plugin.js.map +1 -1
- package/dist/inbound-email-action-plugin.js +0 -1
- package/dist/inbound-email-action-plugin.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/instance-scan-plugin.js +0 -7
- package/dist/instance-scan-plugin.js.map +1 -1
- package/dist/json-plugin.js +0 -1
- package/dist/json-plugin.js.map +1 -1
- package/dist/list-plugin.js +4 -1
- package/dist/list-plugin.js.map +1 -1
- package/dist/now-attach-plugin.js +0 -1
- package/dist/now-attach-plugin.js.map +1 -1
- package/dist/now-config-plugin.js +0 -1
- package/dist/now-config-plugin.js.map +1 -1
- package/dist/now-id-plugin.js +0 -1
- package/dist/now-id-plugin.js.map +1 -1
- package/dist/now-include-plugin.js +0 -1
- package/dist/now-include-plugin.js.map +1 -1
- package/dist/now-ref-plugin.js +0 -1
- package/dist/now-ref-plugin.js.map +1 -1
- package/dist/now-unresolved-plugin.js +0 -1
- package/dist/now-unresolved-plugin.js.map +1 -1
- package/dist/package-json-plugin.js +3 -2
- package/dist/package-json-plugin.js.map +1 -1
- package/dist/property-plugin.js +0 -2
- package/dist/property-plugin.js.map +1 -1
- package/dist/record-plugin.d.ts +2 -0
- package/dist/record-plugin.js +2 -2
- package/dist/record-plugin.js.map +1 -1
- package/dist/repack/lint/Rules.d.ts +1 -2
- package/dist/rest-api-plugin.js +6 -5
- package/dist/rest-api-plugin.js.map +1 -1
- package/dist/role-plugin.js +0 -1
- package/dist/role-plugin.js.map +1 -1
- package/dist/schedule-script/scheduled-script-plugin.js +5 -4
- package/dist/schedule-script/scheduled-script-plugin.js.map +1 -1
- package/dist/script-action-plugin.js +0 -2
- package/dist/script-action-plugin.js.map +1 -1
- package/dist/script-include-plugin.js +0 -4
- package/dist/script-include-plugin.js.map +1 -1
- package/dist/server-module-plugin/index.js +2 -3
- package/dist/server-module-plugin/index.js.map +1 -1
- package/dist/service-catalog/catalog-clientscript-plugin.js +0 -2
- package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -1
- package/dist/service-catalog/catalog-item-plugin.js +0 -2
- package/dist/service-catalog/catalog-item-plugin.js.map +1 -1
- package/dist/service-catalog/catalog-ui-policy-plugin.js +0 -2
- package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -1
- package/dist/service-catalog/sc-record-producer-plugin.js +0 -2
- package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -1
- package/dist/service-catalog/variable-set-plugin.js +0 -2
- package/dist/service-catalog/variable-set-plugin.js.map +1 -1
- package/dist/service-portal/angular-provider-plugin.js +0 -2
- package/dist/service-portal/angular-provider-plugin.js.map +1 -1
- package/dist/service-portal/dependency-plugin.js +3 -5
- package/dist/service-portal/dependency-plugin.js.map +1 -1
- package/dist/service-portal/header-footer-plugin.js +3 -5
- package/dist/service-portal/header-footer-plugin.js.map +1 -1
- package/dist/service-portal/menu-plugin.js +0 -1
- package/dist/service-portal/menu-plugin.js.map +1 -1
- package/dist/service-portal/page-plugin.js +0 -1
- package/dist/service-portal/page-plugin.js.map +1 -1
- package/dist/service-portal/page-route-map-plugin.js +0 -1
- package/dist/service-portal/page-route-map-plugin.js.map +1 -1
- package/dist/service-portal/portal-plugin.js +0 -2
- package/dist/service-portal/portal-plugin.js.map +1 -1
- package/dist/service-portal/theme-plugin.js +0 -2
- package/dist/service-portal/theme-plugin.js.map +1 -1
- package/dist/service-portal/widget-plugin.js +3 -5
- package/dist/service-portal/widget-plugin.js.map +1 -1
- package/dist/sla-plugin.js +0 -2
- package/dist/sla-plugin.js.map +1 -1
- package/dist/static-content-plugin.js +32 -3
- package/dist/static-content-plugin.js.map +1 -1
- package/dist/table-plugin.js +102 -11
- package/dist/table-plugin.js.map +1 -1
- package/dist/ui-action-plugin.js +26 -17
- package/dist/ui-action-plugin.js.map +1 -1
- package/dist/ui-page-plugin.js +159 -17
- package/dist/ui-page-plugin.js.map +1 -1
- package/dist/ui-policy-plugin.js +0 -1
- package/dist/ui-policy-plugin.js.map +1 -1
- package/dist/user-preference-plugin.js +0 -2
- package/dist/user-preference-plugin.js.map +1 -1
- package/dist/utils.d.ts +1 -9
- package/dist/utils.js +0 -14
- package/dist/utils.js.map +1 -1
- package/dist/ux-list-menu-config-plugin.js +0 -2
- package/dist/ux-list-menu-config-plugin.js.map +1 -1
- package/dist/view-plugin.js +0 -1
- package/dist/view-plugin.js.map +1 -1
- package/dist/workspace-plugin.js +0 -2
- package/dist/workspace-plugin.js.map +1 -1
- package/package.json +6 -6
- package/src/acl-plugin.ts +1 -4
- package/src/applicability-plugin.ts +0 -2
- package/src/application-menu-plugin.ts +0 -2
- package/src/arrow-function-plugin.ts +0 -1
- package/src/atf/test-plugin.ts +0 -2
- package/src/basic-syntax-plugin.ts +0 -1
- package/src/business-rule-plugin.ts +1 -2
- package/src/call-expression-plugin.ts +0 -1
- package/src/claims-plugin.ts +0 -1
- package/src/client-script-plugin.ts +1 -2
- package/src/column-plugin.ts +29 -9
- package/src/cross-scope-privilege-plugin.ts +1 -2
- package/src/dashboard/dashboard-plugin.ts +0 -2
- package/src/data-plugin.ts +0 -1
- package/src/data-policy-plugin.ts +333 -0
- package/src/email-notification-plugin.ts +8 -4
- package/src/flow/flow-logic/flow-logic-constants.ts +6 -0
- package/src/flow/flow-logic/flow-logic-diagnostics.ts +236 -58
- package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +59 -6
- package/src/flow/flow-logic/flow-logic-plugin.ts +368 -38
- package/src/flow/flow-logic/flow-logic-shapes.ts +25 -0
- package/src/flow/plugins/approval-rules-plugin.ts +0 -1
- package/src/flow/plugins/flow-action-definition-plugin.ts +940 -208
- package/src/flow/plugins/flow-data-pill-plugin.ts +3 -5
- package/src/flow/plugins/flow-definition-plugin.ts +159 -26
- package/src/flow/plugins/flow-diagnostics-plugin.ts +89 -3
- package/src/flow/plugins/flow-instance-plugin.ts +26 -12
- package/src/flow/plugins/flow-trigger-instance-plugin.ts +0 -1
- package/src/flow/plugins/inline-script-plugin.ts +0 -1
- package/src/flow/plugins/step-definition-plugin.ts +0 -2
- package/src/flow/plugins/step-instance-plugin.ts +259 -65
- package/src/flow/plugins/trigger-plugin.ts +0 -2
- package/src/flow/plugins/wfa-datapill-plugin.ts +0 -1
- package/src/flow/utils/datapill-transformer.ts +13 -5
- package/src/flow/utils/flow-constants.ts +19 -1
- package/src/flow/utils/flow-io-to-record.ts +29 -19
- package/src/flow/utils/flow-pill-utils.ts +48 -0
- package/src/flow/utils/flow-stage-processor.ts +831 -0
- package/src/flow/utils/pill-string-parser.ts +29 -47
- package/src/flow/utils/utils.ts +39 -35
- package/src/form-plugin.ts +5 -15
- package/src/html-import-plugin.ts +0 -1
- package/src/import-sets-plugin.ts +0 -2
- package/src/inbound-email-action-plugin.ts +1 -2
- package/src/index.ts +7 -1
- package/src/instance-scan-plugin.ts +0 -7
- package/src/json-plugin.ts +0 -1
- package/src/list-plugin.ts +6 -2
- package/src/now-attach-plugin.ts +0 -1
- package/src/now-config-plugin.ts +0 -1
- package/src/now-id-plugin.ts +0 -1
- package/src/now-include-plugin.ts +0 -1
- package/src/now-ref-plugin.ts +0 -1
- package/src/now-unresolved-plugin.ts +0 -1
- package/src/package-json-plugin.ts +8 -3
- package/src/property-plugin.ts +0 -2
- package/src/record-plugin.ts +3 -3
- package/src/repack/lint/Rules.ts +1 -1
- package/src/rest-api-plugin.ts +7 -6
- package/src/role-plugin.ts +1 -2
- package/src/schedule-script/scheduled-script-plugin.ts +11 -5
- package/src/script-action-plugin.ts +0 -2
- package/src/script-include-plugin.ts +0 -4
- package/src/server-module-plugin/index.ts +2 -3
- package/src/service-catalog/catalog-clientscript-plugin.ts +0 -2
- package/src/service-catalog/catalog-item-plugin.ts +0 -2
- package/src/service-catalog/catalog-ui-policy-plugin.ts +0 -2
- package/src/service-catalog/sc-record-producer-plugin.ts +0 -2
- package/src/service-catalog/variable-set-plugin.ts +0 -2
- package/src/service-portal/angular-provider-plugin.ts +0 -2
- package/src/service-portal/dependency-plugin.ts +0 -2
- package/src/service-portal/header-footer-plugin.ts +0 -2
- package/src/service-portal/menu-plugin.ts +1 -2
- package/src/service-portal/page-plugin.ts +1 -2
- package/src/service-portal/page-route-map-plugin.ts +1 -2
- package/src/service-portal/portal-plugin.ts +0 -2
- package/src/service-portal/theme-plugin.ts +0 -2
- package/src/service-portal/widget-plugin.ts +0 -2
- package/src/sla-plugin.ts +0 -2
- package/src/static-content-plugin.ts +37 -4
- package/src/table-plugin.ts +118 -16
- package/src/ui-action-plugin.ts +30 -17
- package/src/ui-page-plugin.ts +188 -20
- package/src/ui-policy-plugin.ts +1 -2
- package/src/user-preference-plugin.ts +0 -2
- package/src/utils.ts +0 -15
- package/src/ux-list-menu-config-plugin.ts +0 -2
- package/src/view-plugin.ts +0 -1
- package/src/workspace-plugin.ts +0 -2
|
@@ -159,7 +159,6 @@ function getForEachParameterName(identifierShape: IdentifierShape): string | nul
|
|
|
159
159
|
|
|
160
160
|
export const DataPillPlugin = Plugin.create({
|
|
161
161
|
name: 'DataPillPlugin',
|
|
162
|
-
docs: [],
|
|
163
162
|
shapes: [
|
|
164
163
|
{
|
|
165
164
|
shape: PropertyAccessShape,
|
|
@@ -207,12 +206,11 @@ export const DataPillPlugin = Plugin.create({
|
|
|
207
206
|
const expr = span.getExpression()
|
|
208
207
|
const literalText = span.getLiteralText()
|
|
209
208
|
|
|
210
|
-
const
|
|
209
|
+
const pillShape = expr.is([PropertyAccessShape, IdentifierShape])
|
|
211
210
|
? await transform.toSubclass(expr, DataPillPlugin) // In case of PropertyAccessShape call the toSubclass() again, which calls above handler
|
|
212
|
-
:
|
|
211
|
+
: undefined
|
|
213
212
|
|
|
214
|
-
if (
|
|
215
|
-
const pillShape = pillShapeResult.value
|
|
213
|
+
if (pillShape) {
|
|
216
214
|
if (pillShape instanceof PillShape) {
|
|
217
215
|
// do not call getValue() for trigger, as this will be handled in flow-instance-plugin
|
|
218
216
|
if (pillShape.getRootIdentifier() === 'trigger') {
|
|
@@ -24,9 +24,34 @@ import { gzipSync } from 'node:zlib'
|
|
|
24
24
|
import { ArrowFunctionShape } from '../../arrow-function-plugin'
|
|
25
25
|
import { NowIdShape } from '../../now-id-plugin'
|
|
26
26
|
import { buildVariableShapes, complexObjectMatchesIoRecord } from '../utils/flow-io-to-record'
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
FLOW_API_NAME,
|
|
29
|
+
STAGE_API_NAME,
|
|
30
|
+
slugifyString,
|
|
31
|
+
SUBFLOW_API_NAME,
|
|
32
|
+
SUBFLOW_INSTANCE_API_NAME,
|
|
33
|
+
TRIGGER_INSTANCE_API_NAME,
|
|
34
|
+
} from '../utils/flow-constants'
|
|
35
|
+
import {
|
|
36
|
+
buildStageInsertionMap,
|
|
37
|
+
buildStageShapes,
|
|
38
|
+
collectSubflowDefName,
|
|
39
|
+
createStageCallShape,
|
|
40
|
+
createSubflowStageRecords,
|
|
41
|
+
extractStageKey,
|
|
42
|
+
finalizeStageRecords,
|
|
43
|
+
insertNestedStageShapes,
|
|
44
|
+
processHeaderStages,
|
|
45
|
+
resolveNestedStagesInline,
|
|
46
|
+
resolveNestedStagesForTryCatch,
|
|
47
|
+
} from '../utils/flow-stage-processor'
|
|
28
48
|
import { generateXML } from '../utils/flow-to-xml'
|
|
29
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
DO_IN_PARALLEL_BLOCK_SYS_ID,
|
|
51
|
+
FLOW_LOGIC,
|
|
52
|
+
FlowLogicSysId,
|
|
53
|
+
TRY_CATCH_CATCH_SYS_ID,
|
|
54
|
+
} from '../flow-logic/flow-logic-constants'
|
|
30
55
|
import { TriggerInstancePlugin } from './flow-trigger-instance-plugin'
|
|
31
56
|
import { FlowLogicPlugin } from '../flow-logic/flow-logic-plugin'
|
|
32
57
|
import { FlowInstancePlugin } from './flow-instance-plugin'
|
|
@@ -37,7 +62,7 @@ import {
|
|
|
37
62
|
uuidToSysId,
|
|
38
63
|
validateFlowVariableCall,
|
|
39
64
|
} from '../utils/utils'
|
|
40
|
-
import {
|
|
65
|
+
import { getCallExpressionName } from '../../utils'
|
|
41
66
|
import {
|
|
42
67
|
extractLabelCache,
|
|
43
68
|
createDefinitionMap,
|
|
@@ -1589,7 +1614,6 @@ function postProcessAssignSubflowOutputs(
|
|
|
1589
1614
|
|
|
1590
1615
|
export const FlowDefinitionPlugin = Plugin.create({
|
|
1591
1616
|
name: 'FlowDefinitionPlugin',
|
|
1592
|
-
docs: [createSdkDocEntry('Flow', ['sys_hub_flow'])],
|
|
1593
1617
|
records: {
|
|
1594
1618
|
sys_hub_flow: {
|
|
1595
1619
|
relationships: {
|
|
@@ -1681,6 +1705,11 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
1681
1705
|
|
|
1682
1706
|
const flowVariables = buildVariableShapes(descendants.query('sys_hub_flow_variable'), descendants)
|
|
1683
1707
|
|
|
1708
|
+
// Build stage shapes from sys_hub_flow_stage records
|
|
1709
|
+
const stageRecords = descendants.query('sys_hub_flow_stage', { flow: record.getId().getValue() })
|
|
1710
|
+
const stages = buildStageShapes(stageRecords)
|
|
1711
|
+
const stageInsertionMap = buildStageInsertionMap(stageRecords)
|
|
1712
|
+
|
|
1684
1713
|
//Check if flow has unsupported descendants are present
|
|
1685
1714
|
if (checkForUnsupportedFlowDescendants(descendants, record, logger)) {
|
|
1686
1715
|
return { success: false }
|
|
@@ -1742,37 +1771,64 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
1742
1771
|
// Use recordToShapeMap to access ui_id from records (datapills reference ui_id, not $id)
|
|
1743
1772
|
const uuidToIdentifierMap = buildUuidToIdentifierMap(recordToShapeMap)
|
|
1744
1773
|
|
|
1745
|
-
// For the flow body, only use top-level instances (those without parent_ui_id)
|
|
1774
|
+
// For the flow body, only use top-level instances (those without parent_ui_id). Also exclude Catch
|
|
1775
|
+
// records — they are subsumed into their paired Try's `wfa.flowLogic.tryCatch(...)` shape via
|
|
1776
|
+
// `connected_to`, and emitting them separately would produce a duplicate top-level statement.
|
|
1746
1777
|
const topLevelInstances = allInstances
|
|
1747
1778
|
.filter(
|
|
1748
1779
|
(instance) =>
|
|
1749
|
-
!instance.get('parent_ui_id').isDefined() ||
|
|
1780
|
+
(!instance.get('parent_ui_id').isDefined() ||
|
|
1781
|
+
instance.get('parent_ui_id').getValue() === '') &&
|
|
1782
|
+
!(
|
|
1783
|
+
instance.getTable() === 'sys_hub_flow_logic_instance_v2' &&
|
|
1784
|
+
instance.get('logic_definition').asString().getValue() === TRY_CATCH_CATCH_SYS_ID
|
|
1785
|
+
)
|
|
1750
1786
|
)
|
|
1751
1787
|
.sort((a, b) => order(a) - order(b))
|
|
1752
1788
|
|
|
1753
|
-
|
|
1789
|
+
// Build instance shapes (without stages) first to resolve paramName
|
|
1790
|
+
const rawInstanceShapes: Array<{ shape: Shape; record: Record }> = []
|
|
1754
1791
|
for (const instance of topLevelInstances) {
|
|
1755
1792
|
const shape = recordToShapeMap.get(instance)
|
|
1756
1793
|
if (!shape) {
|
|
1757
1794
|
logger.error(`Failed to find shape for instance ${instance.getId().getValue()}`)
|
|
1758
1795
|
return { success: false }
|
|
1759
1796
|
}
|
|
1797
|
+
rawInstanceShapes.push({ shape, record: instance })
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
// Extract parameter name from the topmost ArrowFunction
|
|
1801
|
+
// This allows us to use the actual parameter name instead of hardcoding "_params"
|
|
1802
|
+
let paramName = DEFAULT_PARAM_NAME // Default fallback
|
|
1803
|
+
const firstRealShape = rawInstanceShapes[0]?.shape
|
|
1804
|
+
if (firstRealShape) {
|
|
1805
|
+
paramName = getArrowFunctionParamName(firstRealShape) || DEFAULT_PARAM_NAME
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
// Insert top-level wfa.stage() calls before matching instances
|
|
1809
|
+
const instanceShapes: Shape[] = []
|
|
1810
|
+
for (const { shape, record: inst } of rawInstanceShapes) {
|
|
1811
|
+
const instanceOrder = order(inst)
|
|
1812
|
+
const stageKeys = stageInsertionMap.get(instanceOrder)
|
|
1813
|
+
if (stageKeys && stageKeys.length > 0) {
|
|
1814
|
+
for (const key of stageKeys) {
|
|
1815
|
+
instanceShapes.push(createStageCallShape(key, paramName, record))
|
|
1816
|
+
}
|
|
1817
|
+
stageInsertionMap.delete(instanceOrder)
|
|
1818
|
+
}
|
|
1760
1819
|
instanceShapes.push(shape)
|
|
1761
1820
|
}
|
|
1762
1821
|
|
|
1822
|
+
// Insert nested wfa.stage() calls inside flow logic bodies (if/elseIf/else)
|
|
1823
|
+
if (stageInsertionMap.size > 0) {
|
|
1824
|
+
insertNestedStageShapes(instanceShapes, stageInsertionMap, paramName, order)
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1763
1827
|
// Transform datapill expressions in instance props
|
|
1764
1828
|
// This section handles TWO types of datapills:
|
|
1765
1829
|
// 1. UUID-based pills: {{uuid.property}} → references to previous action/subflow instances (e.g., {{f56a03c1-18f6-4f7b-9c61-0d4ff472b334.name}} → actionInstance_1.name)
|
|
1766
1830
|
// 2. Semantic pills: {{trigger.property}}, {{flow_variable.name}} → references to flow parameters (e.g., {{trigger.table_name}} → params.trigger.table_name)
|
|
1767
1831
|
|
|
1768
|
-
// Extract parameter name from the topmost ArrowFunction
|
|
1769
|
-
// This allows us to use the actual parameter name instead of hardcoding "params"
|
|
1770
|
-
let paramName = DEFAULT_PARAM_NAME // Default fallback
|
|
1771
|
-
const firstInstance = instanceShapes[0]
|
|
1772
|
-
if (firstInstance) {
|
|
1773
|
-
paramName = getArrowFunctionParamName(firstInstance) || DEFAULT_PARAM_NAME
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
1832
|
// Process all instances (Action, Subflow, and Flow Logic) recursively
|
|
1777
1833
|
// This handles datapill transformation for all instance types and their nested children
|
|
1778
1834
|
instanceShapes.forEach((instanceShape: Shape, index) => {
|
|
@@ -1807,7 +1863,7 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
1807
1863
|
$id: $.val(NowIdShape.from(record)),
|
|
1808
1864
|
name: $,
|
|
1809
1865
|
description: $.def(EMPTY_STRING),
|
|
1810
|
-
|
|
1866
|
+
protectionPolicy: $.from('sys_policy').def(EMPTY_STRING),
|
|
1811
1867
|
runAs: $.from('run_as').def(RUN_AS_DEFAULT),
|
|
1812
1868
|
runWithRoles: $.from('run_with_roles')
|
|
1813
1869
|
.map((r) => {
|
|
@@ -1831,6 +1887,7 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
1831
1887
|
}
|
|
1832
1888
|
: {}),
|
|
1833
1889
|
flowVariables: $.val(flowVariables).def({}),
|
|
1890
|
+
...(Object.keys(stages).length > 0 ? { stages: $.val(stages) } : {}),
|
|
1834
1891
|
})),
|
|
1835
1892
|
...(isFlow ? [triggerShape, flowBody] : [flowBody]),
|
|
1836
1893
|
],
|
|
@@ -1924,12 +1981,11 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
1924
1981
|
explicitId: flowConfiguration.get('$id'),
|
|
1925
1982
|
properties: flowConfiguration.transform(({ $ }) => ({
|
|
1926
1983
|
name: $,
|
|
1927
|
-
internal_name: $.from('name').map((n) => slugifyString(n.getValue())),
|
|
1928
1984
|
annotation: $.def(EMPTY_STRING),
|
|
1929
1985
|
description: $.def(EMPTY_STRING),
|
|
1930
1986
|
access: $.def(ACCESS_DEFAULT),
|
|
1931
1987
|
category: $.def(EMPTY_STRING),
|
|
1932
|
-
sys_policy: $.from('
|
|
1988
|
+
sys_policy: $.from('protectionPolicy').def(EMPTY_STRING),
|
|
1933
1989
|
run_as: $.from('runAs').def(RUN_AS_DEFAULT),
|
|
1934
1990
|
generation_source: $.def(GENERATION_SOURCE),
|
|
1935
1991
|
show_draft_actions: $.def(BOOLEAN_FALSE_STRING),
|
|
@@ -1955,6 +2011,10 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
1955
2011
|
)
|
|
1956
2012
|
}
|
|
1957
2013
|
|
|
2014
|
+
// Phase 1 — create sys_hub_flow_stage records for each declared stage.
|
|
2015
|
+
// component_indexes is not set here; computed after the body loop.
|
|
2016
|
+
const headerStageRecords = await processHeaderStages(flowConfiguration, flowDefinitionRecord, factory)
|
|
2017
|
+
|
|
1958
2018
|
// ------------------------------------------------------------
|
|
1959
2019
|
// Handle FlowVariables() argument (flow-level variables)
|
|
1960
2020
|
// Each variable becomes a separate sys_hub_flow_variable record
|
|
@@ -2033,6 +2093,9 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
2033
2093
|
let forEachMetadataMap = new Map<string, { stepNumber: number; tableName: string | null }>()
|
|
2034
2094
|
|
|
2035
2095
|
let order = 1
|
|
2096
|
+
const pendingStages: Array<{ startActionIndex: number; key: string }> = []
|
|
2097
|
+
const subflowDefNames = new Map<string, string>()
|
|
2098
|
+
|
|
2036
2099
|
for (const [, v] of (allInstances ?? []).entries()) {
|
|
2037
2100
|
// Validate trigger placement: triggers must be the second argument to Flow(), not in the body
|
|
2038
2101
|
const callExpr = v instanceof VariableStatementShape ? v.getInitializer() : v
|
|
@@ -2043,10 +2106,66 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
2043
2106
|
)
|
|
2044
2107
|
continue
|
|
2045
2108
|
}
|
|
2109
|
+
|
|
2110
|
+
// Top-level wfa.stage() — record component_index and skip
|
|
2111
|
+
if (callExpr instanceof CallExpressionShape && callExpr.getCallee() === STAGE_API_NAME) {
|
|
2112
|
+
const stageKey = extractStageKey(callExpr)
|
|
2113
|
+
if (!stageKey) {
|
|
2114
|
+
diagnostics.error(
|
|
2115
|
+
callExpr,
|
|
2116
|
+
'wfa.stage() argument must be a stage reference like params.stages.<key>.'
|
|
2117
|
+
)
|
|
2118
|
+
} else if (!headerStageRecords.has(stageKey)) {
|
|
2119
|
+
diagnostics.error(
|
|
2120
|
+
callExpr,
|
|
2121
|
+
`wfa.stage() references stage '${stageKey}' which is not declared in the stages config.`
|
|
2122
|
+
)
|
|
2123
|
+
} else {
|
|
2124
|
+
pendingStages.push({ startActionIndex: order - 1, key: stageKey })
|
|
2125
|
+
}
|
|
2126
|
+
continue
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2046
2129
|
const instanceRecord = await getRecordFromFlowInstaceShape(v, transform)
|
|
2047
2130
|
|
|
2048
2131
|
if (instanceRecord) {
|
|
2049
|
-
instanceRecord.flat()
|
|
2132
|
+
const flatRecs = instanceRecord.flat()
|
|
2133
|
+
|
|
2134
|
+
// Resolve nested stages and collect subflow def names inline
|
|
2135
|
+
if (callExpr instanceof CallExpressionShape) {
|
|
2136
|
+
const callee = callExpr.getCallee()
|
|
2137
|
+
if (
|
|
2138
|
+
callee === FLOW_LOGIC.IF ||
|
|
2139
|
+
callee === FLOW_LOGIC.ELSEIF ||
|
|
2140
|
+
callee === FLOW_LOGIC.ELSE
|
|
2141
|
+
) {
|
|
2142
|
+
resolveNestedStagesInline(
|
|
2143
|
+
callExpr,
|
|
2144
|
+
flatRecs,
|
|
2145
|
+
order,
|
|
2146
|
+
headerStageRecords,
|
|
2147
|
+
pendingStages,
|
|
2148
|
+
subflowDefNames,
|
|
2149
|
+
diagnostics
|
|
2150
|
+
)
|
|
2151
|
+
}
|
|
2152
|
+
if (callee === FLOW_LOGIC.TRY_CATCH) {
|
|
2153
|
+
resolveNestedStagesForTryCatch(
|
|
2154
|
+
callExpr,
|
|
2155
|
+
flatRecs,
|
|
2156
|
+
order,
|
|
2157
|
+
headerStageRecords,
|
|
2158
|
+
pendingStages,
|
|
2159
|
+
subflowDefNames,
|
|
2160
|
+
diagnostics
|
|
2161
|
+
)
|
|
2162
|
+
}
|
|
2163
|
+
if (callee === SUBFLOW_INSTANCE_API_NAME) {
|
|
2164
|
+
collectSubflowDefName(callExpr, subflowDefNames)
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
flatRecs.forEach((rec) => {
|
|
2050
2169
|
// For subflow instances, values will be in subflow_inputs, for other instances (action/flow logic) it will be in values
|
|
2051
2170
|
const inputsKey =
|
|
2052
2171
|
rec.getTable() === 'sys_hub_sub_flow_instance_v2' ? 'subflow_inputs' : 'values'
|
|
@@ -2109,13 +2228,13 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
2109
2228
|
forEachMetadataMap
|
|
2110
2229
|
)
|
|
2111
2230
|
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2231
|
+
const mergedRec = rec.merge({
|
|
2232
|
+
flow: flowDefinitionRecord.getId().getValue(),
|
|
2233
|
+
order: finalOrder,
|
|
2234
|
+
[inputsKey]: gzipSync(JSON.stringify(valuesJSON)).toString('base64'),
|
|
2235
|
+
})
|
|
2236
|
+
relatedRecords.push(mergedRec)
|
|
2237
|
+
|
|
2119
2238
|
order++
|
|
2120
2239
|
})
|
|
2121
2240
|
} else {
|
|
@@ -2126,6 +2245,20 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
2126
2245
|
}
|
|
2127
2246
|
}
|
|
2128
2247
|
|
|
2248
|
+
// Finalise all stage records
|
|
2249
|
+
const finalisedStages = finalizeStageRecords(pendingStages, headerStageRecords)
|
|
2250
|
+
relatedRecords.push(...finalisedStages)
|
|
2251
|
+
|
|
2252
|
+
relatedRecords.push(
|
|
2253
|
+
...(await createSubflowStageRecords(
|
|
2254
|
+
relatedRecords,
|
|
2255
|
+
finalisedStages.length,
|
|
2256
|
+
flowDefinitionRecord,
|
|
2257
|
+
factory,
|
|
2258
|
+
subflowDefNames
|
|
2259
|
+
))
|
|
2260
|
+
)
|
|
2261
|
+
|
|
2129
2262
|
const labelCacheData = Array.from(labelCacheMap.values())
|
|
2130
2263
|
const flowDefWithMetadata =
|
|
2131
2264
|
labelCacheData.length > 0
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
TemplateExpressionShape,
|
|
17
17
|
PropertyAccessShape,
|
|
18
18
|
IdentifierShape,
|
|
19
|
+
DATA_HELPER_NAMES,
|
|
19
20
|
type Shape,
|
|
20
21
|
} from '@servicenow/sdk-build-core'
|
|
21
22
|
import { isDataPillShape } from '../flow-logic/flow-logic-plugin-helpers'
|
|
@@ -45,13 +46,18 @@ import {
|
|
|
45
46
|
TRIGGER_INSTANCE_API_NAME,
|
|
46
47
|
ACTION_DEFINITION_API_NAME,
|
|
47
48
|
TRIGGER_DEFINITION_API_NAME,
|
|
49
|
+
STAGE_API_NAME,
|
|
50
|
+
FLOW_STAGE_CALLEE,
|
|
48
51
|
} from '../utils/flow-constants'
|
|
49
52
|
|
|
53
|
+
import { FLOW_LOGIC } from '../flow-logic/flow-logic-constants'
|
|
54
|
+
import { createFlowLogicInstanceShape } from '../flow-logic/flow-logic-shapes'
|
|
55
|
+
|
|
50
56
|
// sendEmail action sys_id for validation
|
|
51
57
|
const SEND_EMAIL_ACTION_SYS_ID = 'c1806bf4a70323008299b39f087901cb'
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
// Branching constructs where a trailing wfa.stage() is invalid
|
|
60
|
+
const BRANCHING_CONSTRUCTS: string[] = [FLOW_LOGIC.IF, FLOW_LOGIC.ELSEIF, FLOW_LOGIC.ELSE, FLOW_LOGIC.TRY_CATCH]
|
|
55
61
|
|
|
56
62
|
/**
|
|
57
63
|
* Helper function to check if a node is inside a Flow or Subflow body
|
|
@@ -95,7 +101,6 @@ function isInsideFlowContext(node: ts.Node): boolean {
|
|
|
95
101
|
*/
|
|
96
102
|
export const FlowDiagnosticsPlugin = Plugin.create({
|
|
97
103
|
name: 'FlowDiagnosticsPlugin',
|
|
98
|
-
docs: [],
|
|
99
104
|
shapes: [
|
|
100
105
|
{
|
|
101
106
|
shape: CallExpressionShape,
|
|
@@ -277,5 +282,86 @@ export const FlowDiagnosticsPlugin = Plugin.create({
|
|
|
277
282
|
return { success: false }
|
|
278
283
|
},
|
|
279
284
|
},
|
|
285
|
+
{
|
|
286
|
+
shape: CallExpressionShape,
|
|
287
|
+
fileTypes: ['fluent'],
|
|
288
|
+
toSubclass(expr, { diagnostics }) {
|
|
289
|
+
if (expr.getCallee() !== STAGE_API_NAME) {
|
|
290
|
+
return { success: false }
|
|
291
|
+
}
|
|
292
|
+
const node = expr.getOriginalNode()
|
|
293
|
+
|
|
294
|
+
const parentForEach = findAncestorByCalleeName(node, FLOW_LOGIC.FOR_EACH)
|
|
295
|
+
if (parentForEach) {
|
|
296
|
+
diagnostics.error(
|
|
297
|
+
expr,
|
|
298
|
+
'wfa.stage() cannot be used inside a forEach block. Move stage markers to the top level of the flow body.'
|
|
299
|
+
)
|
|
300
|
+
}
|
|
301
|
+
const parentDoInParallel = findAncestorByCalleeName(node, FLOW_LOGIC.DO_IN_PARALLEL)
|
|
302
|
+
if (parentDoInParallel) {
|
|
303
|
+
diagnostics.error(
|
|
304
|
+
expr,
|
|
305
|
+
'wfa.stage() cannot be used inside a doInParallel block. Move stage markers to the top level of the flow body.'
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Stage must not be the last statement in a branching logic block or the flow body.
|
|
310
|
+
// A stage that trails with nothing after it has no effect.
|
|
311
|
+
if (!parentForEach && !parentDoInParallel) {
|
|
312
|
+
const stmtNode = node.getParent()
|
|
313
|
+
if (stmtNode) {
|
|
314
|
+
const isLastStatement = !stmtNode
|
|
315
|
+
.getNextSiblings()
|
|
316
|
+
.some((n: ts.Node) => !ts.Node.isCommentStatement(n))
|
|
317
|
+
if (isLastStatement) {
|
|
318
|
+
const containingArrowFn = stmtNode.getFirstAncestorByKind(ts.SyntaxKind.ArrowFunction)
|
|
319
|
+
if (containingArrowFn) {
|
|
320
|
+
const parentCallExpr = containingArrowFn.getFirstAncestorByKind(
|
|
321
|
+
ts.SyntaxKind.CallExpression
|
|
322
|
+
)
|
|
323
|
+
if (parentCallExpr) {
|
|
324
|
+
const callName = getCallExpressionName(parentCallExpr)
|
|
325
|
+
if (BRANCHING_CONSTRUCTS.includes(callName)) {
|
|
326
|
+
diagnostics.error(
|
|
327
|
+
expr,
|
|
328
|
+
'wfa.stage() cannot be the last statement in a branching logic block (if/elseIf/else/tryCatch). A stage must be followed by at least one action or flow logic step.'
|
|
329
|
+
)
|
|
330
|
+
} else if (callName === FLOW_API_NAME || callName === SUBFLOW_API_NAME) {
|
|
331
|
+
diagnostics.error(
|
|
332
|
+
expr,
|
|
333
|
+
'wfa.stage() cannot be the last statement in the flow body. A stage must be followed by at least one action or flow logic step.'
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return { success: false }
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
shape: CallExpressionShape,
|
|
347
|
+
fileTypes: ['fluent'],
|
|
348
|
+
toSubclass(expr, { diagnostics }) {
|
|
349
|
+
if (expr.getCallee() !== FLOW_STAGE_CALLEE) {
|
|
350
|
+
return { success: false }
|
|
351
|
+
}
|
|
352
|
+
const durationShape = expr.getArgument(0).asObject().get('duration', false)
|
|
353
|
+
const isDefined = !durationShape.if(UndefinedShape)
|
|
354
|
+
const isDurationCall =
|
|
355
|
+
durationShape.if(CallExpressionShape) &&
|
|
356
|
+
durationShape.as(CallExpressionShape).getCallee() === DATA_HELPER_NAMES.DURATION
|
|
357
|
+
if (isDefined && !isDurationCall) {
|
|
358
|
+
diagnostics.error(
|
|
359
|
+
durationShape,
|
|
360
|
+
"FlowStage 'duration' must use the Duration() helper, e.g. Duration({ hours: 4 }). Plain objects are not supported."
|
|
361
|
+
)
|
|
362
|
+
}
|
|
363
|
+
return { success: false }
|
|
364
|
+
},
|
|
365
|
+
},
|
|
280
366
|
],
|
|
281
367
|
})
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
getDirectVariableIdentifier,
|
|
31
31
|
getIdentifierFromRecord,
|
|
32
32
|
getIdentifierFromShape,
|
|
33
|
+
getOrderSuffix,
|
|
33
34
|
resolveDataPillShape,
|
|
34
35
|
sysIdToUuid,
|
|
35
36
|
} from '../utils/utils'
|
|
@@ -42,8 +43,8 @@ import {
|
|
|
42
43
|
import { getAttributeValue, parseAttributesToObject } from '../utils/schema-to-flow-object'
|
|
43
44
|
import {
|
|
44
45
|
ActionSubflowInstanceShape,
|
|
45
|
-
ApprovalRulesShape,
|
|
46
46
|
ApprovalDueDateShape,
|
|
47
|
+
ApprovalRulesShape,
|
|
47
48
|
InlineScriptShape,
|
|
48
49
|
} from '../utils/flow-shapes'
|
|
49
50
|
import { FDInlineScriptCallShape } from './inline-script-plugin'
|
|
@@ -51,21 +52,22 @@ import { FDInlineScriptCallShape } from './inline-script-plugin'
|
|
|
51
52
|
import {
|
|
52
53
|
ACTION_DEF_COLUMN_NAME,
|
|
53
54
|
ACTION_INSTANCE_API_NAME,
|
|
54
|
-
|
|
55
|
+
ACTION_TYPE_KEY_NAME,
|
|
55
56
|
APPROVAL_DUE_DATE_DATA_TYPE_VALUE,
|
|
57
|
+
APPROVAL_DUE_DATE_INPUT_FIELD_ACTIONS,
|
|
58
|
+
APPROVAL_RULES_DATA_TYPE_VALUE,
|
|
59
|
+
CATALOG_VARIABLE_SET_TABLE,
|
|
60
|
+
CATALOG_VARIABLE_TABLE,
|
|
56
61
|
CORE_ACTIONS_SYS_ID_NAME_MAP,
|
|
57
62
|
DURATION_DATA_TYPE_VALUE,
|
|
63
|
+
INLINE_SCRIPT_UNSUPPORTED_FIELDS,
|
|
64
|
+
INLINE_SCRIPT_UNSUPPORTED_TYPES,
|
|
58
65
|
SUBFLOW_INSTANCE_API_NAME,
|
|
59
66
|
TEMPLATE_DATA_TYPE_VALUE,
|
|
60
67
|
TIME_DATA_TYPE_VALUE,
|
|
61
68
|
UNSUPPORTED_DATA_TYPES,
|
|
62
69
|
UTC_TIMEZONE_VALUE,
|
|
63
|
-
|
|
64
|
-
ACTION_TYPE_KEY_NAME,
|
|
65
|
-
CATALOG_VARIABLE_TABLE,
|
|
66
|
-
CATALOG_VARIABLE_SET_TABLE,
|
|
67
|
-
INLINE_SCRIPT_UNSUPPORTED_TYPES,
|
|
68
|
-
INLINE_SCRIPT_UNSUPPORTED_FIELDS,
|
|
70
|
+
ELEMENT_MAPPING_FIELD_ALIASES,
|
|
69
71
|
} from '../utils/flow-constants'
|
|
70
72
|
|
|
71
73
|
import type { ApprovalDueDateType, ApprovalRulesType } from '@servicenow/sdk-core/runtime/flow'
|
|
@@ -350,8 +352,11 @@ function buildInstanceToShape({
|
|
|
350
352
|
args: [identifierShapeOrSysId, configArg, inputsShape],
|
|
351
353
|
})
|
|
352
354
|
|
|
353
|
-
// Generate variable name from existing source or fallback to callee + ID
|
|
354
|
-
|
|
355
|
+
// Generate a variable name from an existing source or fallback to callee + ID.
|
|
356
|
+
// Actions inside a DoInParallel branch use composite orders like `2➛3`; strip the separator so the identifier
|
|
357
|
+
// stays valid JS.
|
|
358
|
+
const order = getOrderSuffix((record.get('order')?.getValue() as string | undefined) ?? '')
|
|
359
|
+
|
|
355
360
|
let identifierPrefix = ''
|
|
356
361
|
if (callee.toLowerCase() === ACTION_INSTANCE_API_NAME) {
|
|
357
362
|
identifierPrefix = 'action'
|
|
@@ -451,7 +456,6 @@ function validateCatalogVariableOutputReferences(
|
|
|
451
456
|
|
|
452
457
|
export const FlowInstancePlugin = Plugin.create({
|
|
453
458
|
name: 'FlowInstancePlugin',
|
|
454
|
-
docs: [],
|
|
455
459
|
records: {
|
|
456
460
|
sys_hub_action_instance_v2: {
|
|
457
461
|
toShape: buildInstanceToShape({
|
|
@@ -488,6 +492,9 @@ export const FlowInstancePlugin = Plugin.create({
|
|
|
488
492
|
const instanceInputs = callExpression.getInstanceProps()
|
|
489
493
|
const instanceAnnotation = callExpression.getAnnotation()?.getValue()
|
|
490
494
|
const instanceUUID = callExpression.getInstanceUUID()?.getValue()
|
|
495
|
+
const instanceConfigObj = callExpression.getArgument(1).as(ObjectShape)
|
|
496
|
+
const instanceShowSubflowStage =
|
|
497
|
+
instanceConfigObj.get('showSubflowStage').ifBoolean()?.getValue() ?? false
|
|
491
498
|
|
|
492
499
|
if (!instanceInputs || !instanceSysId || !instanceParentDef) {
|
|
493
500
|
diagnostics.error(
|
|
@@ -528,6 +535,7 @@ export const FlowInstancePlugin = Plugin.create({
|
|
|
528
535
|
sysId: instanceSysId,
|
|
529
536
|
annotation: instanceAnnotation,
|
|
530
537
|
uuid: instanceUUID,
|
|
538
|
+
showSubflowStage: instanceShowSubflowStage,
|
|
531
539
|
factory,
|
|
532
540
|
source: callExpression,
|
|
533
541
|
transform,
|
|
@@ -628,7 +636,10 @@ function buildInputsShapeFromZipped({
|
|
|
628
636
|
}
|
|
629
637
|
}
|
|
630
638
|
|
|
631
|
-
for (const { name, value, scriptActive, script, parameter } of values) {
|
|
639
|
+
for (const { name: rawName, value, scriptActive, script, parameter } of values) {
|
|
640
|
+
// Translate platform-internal field names (e.g. __snc_dont_fail_on_error)
|
|
641
|
+
// to their Fluent API names (e.g. dont_fail_flow_on_error)
|
|
642
|
+
const name = ELEMENT_MAPPING_FIELD_ALIASES[rawName] ?? rawName
|
|
632
643
|
const attributes = definitionInputs
|
|
633
644
|
?.find((v) => v.get('element').asString()?.getValue() === name)
|
|
634
645
|
?.get('attributes')
|
|
@@ -765,6 +776,7 @@ async function buildSubflowInstance({
|
|
|
765
776
|
annotation,
|
|
766
777
|
factory,
|
|
767
778
|
uuid,
|
|
779
|
+
showSubflowStage,
|
|
768
780
|
source,
|
|
769
781
|
transform,
|
|
770
782
|
diagnostics,
|
|
@@ -775,6 +787,7 @@ async function buildSubflowInstance({
|
|
|
775
787
|
annotation: string | undefined
|
|
776
788
|
factory: Factory
|
|
777
789
|
uuid: string | undefined
|
|
790
|
+
showSubflowStage: boolean
|
|
778
791
|
source: Source
|
|
779
792
|
transform: Transform
|
|
780
793
|
diagnostics: Diagnostics
|
|
@@ -794,6 +807,7 @@ async function buildSubflowInstance({
|
|
|
794
807
|
subflow: $.val(subflowDefRecord?.getId()?.getValue() || subflowDef?.getValue() || ''),
|
|
795
808
|
subflow_inputs: $.val(values),
|
|
796
809
|
wait_for_completion: $.from('waitForCompletion').def(true),
|
|
810
|
+
show_stages: $.val(showSubflowStage),
|
|
797
811
|
sys_class_name: $.val('sys_hub_sub_flow_instance_v2'),
|
|
798
812
|
parent_ui_id: $.def(''),
|
|
799
813
|
}))
|
|
@@ -2,13 +2,11 @@ import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
|
|
|
2
2
|
import { buildVariableShapes } from '../utils/flow-io-to-record'
|
|
3
3
|
import { NowIdShape } from '../../now-id-plugin'
|
|
4
4
|
import { generateXML } from '../utils/flow-to-xml'
|
|
5
|
-
import { createSdkDocEntry } from '../../utils'
|
|
6
5
|
/**
|
|
7
6
|
* Plugin for processing StepDefinition calls
|
|
8
7
|
*/
|
|
9
8
|
export const StepDefinitionPlugin = Plugin.create({
|
|
10
9
|
name: 'StepDefinitionPlugin',
|
|
11
|
-
docs: [createSdkDocEntry('ActionStepDefinition', ['sys_flow_step_definition'])],
|
|
12
10
|
records: {
|
|
13
11
|
sys_flow_step_definition: {
|
|
14
12
|
relationships: {
|