@servicenow/sdk-build-plugins 4.4.1 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acl-plugin.js +54 -4
- package/dist/acl-plugin.js.map +1 -1
- package/dist/applicability-plugin.js +2 -0
- package/dist/applicability-plugin.js.map +1 -1
- package/dist/application-menu-plugin.js +2 -0
- package/dist/application-menu-plugin.js.map +1 -1
- package/dist/arrow-function-plugin.d.ts +6 -1
- package/dist/arrow-function-plugin.js +105 -12
- package/dist/arrow-function-plugin.js.map +1 -1
- package/dist/atf/test-plugin.js +2 -0
- package/dist/atf/test-plugin.js.map +1 -1
- package/dist/basic-syntax-plugin.js +20 -0
- package/dist/basic-syntax-plugin.js.map +1 -1
- package/dist/call-expression-plugin.js +1 -0
- package/dist/call-expression-plugin.js.map +1 -1
- package/dist/claims-plugin.js +1 -0
- package/dist/claims-plugin.js.map +1 -1
- package/dist/client-script-plugin.js +1 -0
- package/dist/client-script-plugin.js.map +1 -1
- package/dist/column-plugin.js +4 -7
- package/dist/column-plugin.js.map +1 -1
- package/dist/cross-scope-privilege-plugin.js +1 -0
- package/dist/cross-scope-privilege-plugin.js.map +1 -1
- package/dist/dashboard/dashboard-plugin.js +2 -0
- package/dist/dashboard/dashboard-plugin.js.map +1 -1
- package/dist/data-plugin.js +1 -0
- package/dist/data-plugin.js.map +1 -1
- package/dist/email-notification-plugin.js +9 -13
- package/dist/email-notification-plugin.js.map +1 -1
- package/dist/flow/constants/flow-plugin-constants.d.ts +1 -1
- package/dist/flow/constants/flow-plugin-constants.js +1 -1
- package/dist/flow/constants/flow-plugin-constants.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-diagnostics.js +5 -5
- package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +82 -2
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +48 -40
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-plugin.js +1 -0
- package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -1
- package/dist/flow/plugins/approval-rules-plugin.js +1 -0
- package/dist/flow/plugins/approval-rules-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-action-definition-plugin.js +1232 -55
- package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-data-pill-plugin.js +6 -2
- package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-definition-plugin.js +23 -44
- package/dist/flow/plugins/flow-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +2 -2
- package/dist/flow/plugins/flow-diagnostics-plugin.js +3 -2
- package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-instance-plugin.js +136 -34
- package/dist/flow/plugins/flow-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-trigger-instance-plugin.js +1 -0
- package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/inline-script-plugin.js +1 -0
- package/dist/flow/plugins/inline-script-plugin.js.map +1 -1
- package/dist/flow/plugins/step-definition-plugin.js +4 -2
- package/dist/flow/plugins/step-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/step-instance-plugin.d.ts +9 -1
- package/dist/flow/plugins/step-instance-plugin.js +649 -135
- package/dist/flow/plugins/step-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/trigger-plugin.js +2 -0
- package/dist/flow/plugins/trigger-plugin.js.map +1 -1
- package/dist/flow/plugins/wfa-datapill-plugin.js +21 -5
- package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -1
- package/dist/flow/post-install.d.ts +2 -0
- package/dist/flow/post-install.js +59 -0
- package/dist/flow/post-install.js.map +1 -0
- package/dist/flow/utils/complex-object-resolver.js +4 -1
- package/dist/flow/utils/complex-object-resolver.js.map +1 -1
- package/dist/flow/utils/complex-objects.js +5 -3
- package/dist/flow/utils/complex-objects.js.map +1 -1
- package/dist/flow/utils/flow-constants.d.ts +90 -2
- package/dist/flow/utils/flow-constants.js +430 -7
- 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 +37 -16
- package/dist/flow/utils/flow-io-to-record.js.map +1 -1
- package/dist/flow/utils/flow-shapes.js +4 -0
- package/dist/flow/utils/flow-shapes.js.map +1 -1
- package/dist/flow/utils/flow-to-xml.d.ts +3 -2
- package/dist/flow/utils/flow-to-xml.js +3 -4
- package/dist/flow/utils/flow-to-xml.js.map +1 -1
- package/dist/flow/utils/label-cache-parser.d.ts +9 -2
- package/dist/flow/utils/label-cache-parser.js +32 -4
- package/dist/flow/utils/label-cache-parser.js.map +1 -1
- package/dist/flow/utils/label-cache-processor.d.ts +5 -0
- package/dist/flow/utils/label-cache-processor.js +14 -2
- package/dist/flow/utils/label-cache-processor.js.map +1 -1
- package/dist/flow/utils/pill-shape-helpers.d.ts +15 -0
- package/dist/flow/utils/pill-shape-helpers.js +35 -0
- package/dist/flow/utils/pill-shape-helpers.js.map +1 -0
- package/dist/flow/utils/pill-string-parser.js +1 -0
- package/dist/flow/utils/pill-string-parser.js.map +1 -1
- package/dist/flow/utils/schema-to-flow-object.d.ts +6 -1
- package/dist/flow/utils/schema-to-flow-object.js +131 -15
- package/dist/flow/utils/schema-to-flow-object.js.map +1 -1
- package/dist/flow/utils/service-catalog.js +5 -1
- package/dist/flow/utils/service-catalog.js.map +1 -1
- package/dist/flow/utils/utils.d.ts +1 -0
- package/dist/flow/utils/utils.js +6 -1
- package/dist/flow/utils/utils.js.map +1 -1
- package/dist/form-plugin.d.ts +2 -0
- package/dist/form-plugin.js +1132 -0
- package/dist/form-plugin.js.map +1 -0
- package/dist/html-import-plugin.js +1 -0
- package/dist/html-import-plugin.js.map +1 -1
- package/dist/import-sets-plugin.js +2 -0
- package/dist/import-sets-plugin.js.map +1 -1
- package/dist/inbound-email-action-plugin.d.ts +10 -0
- package/dist/inbound-email-action-plugin.js +128 -0
- package/dist/inbound-email-action-plugin.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/instance-scan-plugin.d.ts +2 -0
- package/dist/instance-scan-plugin.js +293 -0
- package/dist/instance-scan-plugin.js.map +1 -0
- package/dist/json-plugin.js +1 -0
- package/dist/json-plugin.js.map +1 -1
- package/dist/list-plugin.js +1 -0
- package/dist/list-plugin.js.map +1 -1
- package/dist/now-attach-plugin.js +1 -0
- package/dist/now-attach-plugin.js.map +1 -1
- package/dist/now-config-plugin.js +659 -51
- package/dist/now-config-plugin.js.map +1 -1
- package/dist/now-id-plugin.js +1 -0
- package/dist/now-id-plugin.js.map +1 -1
- package/dist/now-include-plugin.js +1 -0
- package/dist/now-include-plugin.js.map +1 -1
- package/dist/now-ref-plugin.js +1 -0
- package/dist/now-ref-plugin.js.map +1 -1
- package/dist/now-unresolved-plugin.js +1 -0
- package/dist/now-unresolved-plugin.js.map +1 -1
- package/dist/package-json-plugin.js +1 -0
- package/dist/package-json-plugin.js.map +1 -1
- package/dist/property-plugin.js +3 -1
- package/dist/property-plugin.js.map +1 -1
- package/dist/record-plugin.d.ts +37 -0
- package/dist/record-plugin.js +47 -3
- package/dist/record-plugin.js.map +1 -1
- package/dist/repack/lint/Rules.d.ts +11 -2
- package/dist/repack/lint/Rules.js +160 -16
- package/dist/repack/lint/Rules.js.map +1 -1
- package/dist/repack/lint/index.d.ts +10 -5
- package/dist/repack/lint/index.js +76 -50
- package/dist/repack/lint/index.js.map +1 -1
- package/dist/rest-api-plugin.js +22 -1
- package/dist/rest-api-plugin.js.map +1 -1
- package/dist/role-plugin.js +1 -0
- package/dist/role-plugin.js.map +1 -1
- package/dist/schedule-script/index.d.ts +1 -0
- package/dist/schedule-script/index.js +18 -0
- package/dist/schedule-script/index.js.map +1 -0
- package/dist/schedule-script/scheduled-script-plugin.d.ts +2 -0
- package/dist/schedule-script/scheduled-script-plugin.js +556 -0
- package/dist/schedule-script/scheduled-script-plugin.js.map +1 -0
- package/dist/schedule-script/timeZoneConverter.d.ts +61 -0
- package/dist/schedule-script/timeZoneConverter.js +170 -0
- package/dist/schedule-script/timeZoneConverter.js.map +1 -0
- package/dist/script-action-plugin.js +2 -0
- package/dist/script-action-plugin.js.map +1 -1
- package/dist/script-include-plugin.js +2 -0
- package/dist/script-include-plugin.js.map +1 -1
- package/dist/server-module-plugin/index.js +13 -2
- package/dist/server-module-plugin/index.js.map +1 -1
- package/dist/service-catalog/catalog-clientscript-plugin.js +2 -0
- package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -1
- package/dist/service-catalog/catalog-item-plugin.js +2 -0
- package/dist/service-catalog/catalog-item-plugin.js.map +1 -1
- package/dist/service-catalog/catalog-ui-policy-plugin.js +2 -0
- package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -1
- package/dist/service-catalog/sc-record-producer-plugin.js +2 -0
- package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -1
- package/dist/service-catalog/service-catalog-base.d.ts +18 -18
- package/dist/service-catalog/service-catalog-base.js +22 -22
- package/dist/service-catalog/service-catalog-base.js.map +1 -1
- package/dist/service-catalog/service-catalog-diagnostics.d.ts +6 -0
- package/dist/service-catalog/service-catalog-diagnostics.js +20 -0
- package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -1
- package/dist/service-catalog/shape-to-record.js +7 -2
- package/dist/service-catalog/shape-to-record.js.map +1 -1
- package/dist/service-catalog/variable-set-plugin.js +2 -0
- package/dist/service-catalog/variable-set-plugin.js.map +1 -1
- package/dist/service-portal/angular-provider-plugin.js +2 -0
- package/dist/service-portal/angular-provider-plugin.js.map +1 -1
- package/dist/service-portal/dependency-plugin.js +5 -31
- package/dist/service-portal/dependency-plugin.js.map +1 -1
- package/dist/service-portal/header-footer-plugin.d.ts +2 -0
- package/dist/service-portal/header-footer-plugin.js +50 -0
- package/dist/service-portal/header-footer-plugin.js.map +1 -0
- package/dist/service-portal/menu-plugin.d.ts +2 -0
- package/dist/service-portal/menu-plugin.js +334 -0
- package/dist/service-portal/menu-plugin.js.map +1 -0
- package/dist/service-portal/page-plugin.d.ts +2 -0
- package/dist/service-portal/page-plugin.js +681 -0
- package/dist/service-portal/page-plugin.js.map +1 -0
- package/dist/service-portal/page-route-map-plugin.d.ts +2 -0
- package/dist/service-portal/page-route-map-plugin.js +114 -0
- package/dist/service-portal/page-route-map-plugin.js.map +1 -0
- package/dist/service-portal/portal-plugin.d.ts +2 -0
- package/dist/service-portal/portal-plugin.js +309 -0
- package/dist/service-portal/portal-plugin.js.map +1 -0
- package/dist/service-portal/theme-plugin.d.ts +2 -0
- package/dist/service-portal/theme-plugin.js +112 -0
- package/dist/service-portal/theme-plugin.js.map +1 -0
- package/dist/service-portal/utils.d.ts +46 -0
- package/dist/service-portal/utils.js +331 -0
- package/dist/service-portal/utils.js.map +1 -0
- package/dist/service-portal/widget-plugin.js +10 -182
- package/dist/service-portal/widget-plugin.js.map +1 -1
- package/dist/sla-plugin.js +2 -0
- package/dist/sla-plugin.js.map +1 -1
- package/dist/static-content-plugin.js +5 -0
- package/dist/static-content-plugin.js.map +1 -1
- package/dist/table-plugin.js +191 -26
- package/dist/table-plugin.js.map +1 -1
- package/dist/ui-action-plugin.js +3 -4
- package/dist/ui-action-plugin.js.map +1 -1
- package/dist/ui-page-plugin.js +101 -21
- package/dist/ui-page-plugin.js.map +1 -1
- package/dist/ui-policy-plugin.js +1 -0
- package/dist/ui-policy-plugin.js.map +1 -1
- package/dist/user-preference-plugin.js +2 -0
- package/dist/user-preference-plugin.js.map +1 -1
- package/dist/utils.d.ts +20 -2
- package/dist/utils.js +34 -3
- package/dist/utils.js.map +1 -1
- package/dist/ux-list-menu-config-plugin.js +2 -0
- package/dist/ux-list-menu-config-plugin.js.map +1 -1
- package/dist/view-plugin.js +9 -3
- package/dist/view-plugin.js.map +1 -1
- package/dist/workspace-plugin.js +41 -36
- package/dist/workspace-plugin.js.map +1 -1
- package/package.json +11 -11
- package/src/_types/eslint-community-eslint-utils.d.ts +15 -0
- package/src/acl-plugin.ts +97 -8
- package/src/applicability-plugin.ts +2 -0
- package/src/application-menu-plugin.ts +2 -0
- package/src/arrow-function-plugin.ts +128 -13
- package/src/atf/test-plugin.ts +2 -0
- package/src/basic-syntax-plugin.ts +21 -0
- package/src/call-expression-plugin.ts +1 -0
- package/src/claims-plugin.ts +1 -0
- package/src/client-script-plugin.ts +2 -1
- package/src/column-plugin.ts +4 -8
- package/src/cross-scope-privilege-plugin.ts +2 -1
- package/src/dashboard/dashboard-plugin.ts +2 -0
- package/src/data-plugin.ts +1 -0
- package/src/email-notification-plugin.ts +3 -23
- package/src/flow/constants/flow-plugin-constants.ts +1 -1
- package/src/flow/flow-logic/flow-logic-diagnostics.ts +5 -6
- package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +47 -45
- package/src/flow/flow-logic/flow-logic-plugin.ts +1 -0
- package/src/flow/plugins/approval-rules-plugin.ts +1 -0
- package/src/flow/plugins/flow-action-definition-plugin.ts +1584 -62
- package/src/flow/plugins/flow-data-pill-plugin.ts +6 -2
- package/src/flow/plugins/flow-definition-plugin.ts +22 -51
- package/src/flow/plugins/flow-diagnostics-plugin.ts +3 -2
- package/src/flow/plugins/flow-instance-plugin.ts +201 -36
- package/src/flow/plugins/flow-trigger-instance-plugin.ts +1 -0
- package/src/flow/plugins/inline-script-plugin.ts +1 -0
- package/src/flow/plugins/step-definition-plugin.ts +4 -2
- package/src/flow/plugins/step-instance-plugin.ts +772 -155
- package/src/flow/plugins/trigger-plugin.ts +2 -0
- package/src/flow/plugins/wfa-datapill-plugin.ts +26 -5
- package/src/flow/post-install.ts +93 -0
- package/src/flow/utils/complex-object-resolver.ts +4 -1
- package/src/flow/utils/complex-objects.ts +11 -3
- package/src/flow/utils/flow-constants.ts +451 -6
- package/src/flow/utils/flow-io-to-record.ts +43 -17
- package/src/flow/utils/flow-shapes.ts +4 -0
- package/src/flow/utils/flow-to-xml.ts +4 -4
- package/src/flow/utils/label-cache-parser.ts +33 -4
- package/src/flow/utils/label-cache-processor.ts +14 -2
- package/src/flow/utils/pill-shape-helpers.ts +42 -0
- package/src/flow/utils/pill-string-parser.ts +1 -0
- package/src/flow/utils/schema-to-flow-object.ts +183 -15
- package/src/flow/utils/service-catalog.ts +5 -2
- package/src/flow/utils/utils.ts +12 -1
- package/src/form-plugin.ts +1409 -0
- package/src/html-import-plugin.ts +1 -0
- package/src/import-sets-plugin.ts +2 -0
- package/src/inbound-email-action-plugin.ts +145 -0
- package/src/index.ts +13 -0
- package/src/instance-scan-plugin.ts +313 -0
- package/src/json-plugin.ts +1 -0
- package/src/list-plugin.ts +2 -1
- package/src/now-attach-plugin.ts +1 -0
- package/src/now-config-plugin.ts +833 -53
- package/src/now-id-plugin.ts +1 -0
- package/src/now-include-plugin.ts +1 -0
- package/src/now-ref-plugin.ts +1 -0
- package/src/now-unresolved-plugin.ts +1 -0
- package/src/package-json-plugin.ts +1 -0
- package/src/property-plugin.ts +6 -1
- package/src/record-plugin.ts +56 -6
- package/src/repack/lint/Rules.ts +171 -22
- package/src/repack/lint/index.ts +80 -56
- package/src/rest-api-plugin.ts +28 -2
- package/src/role-plugin.ts +2 -1
- package/src/schedule-script/index.ts +1 -0
- package/src/schedule-script/scheduled-script-plugin.ts +690 -0
- package/src/schedule-script/timeZoneConverter.ts +188 -0
- package/src/script-action-plugin.ts +2 -0
- package/src/script-include-plugin.ts +2 -0
- package/src/server-module-plugin/index.ts +14 -2
- package/src/service-catalog/catalog-clientscript-plugin.ts +2 -0
- package/src/service-catalog/catalog-item-plugin.ts +2 -0
- package/src/service-catalog/catalog-ui-policy-plugin.ts +2 -0
- package/src/service-catalog/sc-record-producer-plugin.ts +2 -0
- package/src/service-catalog/service-catalog-base.ts +22 -22
- package/src/service-catalog/service-catalog-diagnostics.ts +30 -0
- package/src/service-catalog/shape-to-record.ts +8 -2
- package/src/service-catalog/variable-set-plugin.ts +2 -0
- package/src/service-portal/angular-provider-plugin.ts +2 -0
- package/src/service-portal/dependency-plugin.ts +6 -53
- package/src/service-portal/header-footer-plugin.ts +57 -0
- package/src/service-portal/menu-plugin.ts +413 -0
- package/src/service-portal/page-plugin.ts +805 -0
- package/src/service-portal/page-route-map-plugin.ts +124 -0
- package/src/service-portal/portal-plugin.ts +342 -0
- package/src/service-portal/theme-plugin.ts +135 -0
- package/src/service-portal/utils.ts +470 -0
- package/src/service-portal/widget-plugin.ts +18 -224
- package/src/sla-plugin.ts +2 -0
- package/src/static-content-plugin.ts +4 -0
- package/src/table-plugin.ts +228 -37
- package/src/ui-action-plugin.ts +3 -8
- package/src/ui-page-plugin.ts +110 -21
- package/src/ui-policy-plugin.ts +2 -1
- package/src/user-preference-plugin.ts +2 -0
- package/src/utils.ts +42 -2
- package/src/ux-list-menu-config-plugin.ts +2 -0
- package/src/view-plugin.ts +11 -4
- package/src/workspace-plugin.ts +45 -43
- package/src/_types/eslint-plugin-es-x.d.ts +0 -17
|
@@ -91,10 +91,13 @@ export function determineRootIdentifierAndPath(
|
|
|
91
91
|
let pathStr = ''
|
|
92
92
|
|
|
93
93
|
switch (propertyNames[1]) {
|
|
94
|
-
case 'inputs':
|
|
95
|
-
|
|
94
|
+
case 'inputs': {
|
|
95
|
+
// Detect if inside Action() body → emit {{action.xxx}}, otherwise {{subflow.xxx}}
|
|
96
|
+
const actionAncestor = findAncestorByCalleeName(propertyAccessShape.getOriginalNode(), 'Action')
|
|
97
|
+
rootIdentifier = actionAncestor ? 'action' : 'subflow'
|
|
96
98
|
pathStr = propertyNames.slice(2).join('.')
|
|
97
99
|
break
|
|
100
|
+
}
|
|
98
101
|
case 'flowVariables':
|
|
99
102
|
// For params.flowVariables (schema reference), use 'flowVariables' as identifier with empty path
|
|
100
103
|
// For params.flowVariables.someVar (property access), use 'flow_variable' as identifier
|
|
@@ -156,6 +159,7 @@ function getForEachParameterName(identifierShape: IdentifierShape): string | nul
|
|
|
156
159
|
|
|
157
160
|
export const DataPillPlugin = Plugin.create({
|
|
158
161
|
name: 'DataPillPlugin',
|
|
162
|
+
docs: [],
|
|
159
163
|
shapes: [
|
|
160
164
|
{
|
|
161
165
|
shape: PropertyAccessShape,
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
type Diagnostics,
|
|
18
18
|
ts,
|
|
19
19
|
deleteMultipleDiff,
|
|
20
|
-
StringLiteralShape,
|
|
21
20
|
type Logger,
|
|
22
21
|
} from '@servicenow/sdk-build-core'
|
|
23
22
|
import { gzipSync } from 'node:zlib'
|
|
@@ -38,7 +37,7 @@ import {
|
|
|
38
37
|
uuidToSysId,
|
|
39
38
|
validateFlowVariableCall,
|
|
40
39
|
} from '../utils/utils'
|
|
41
|
-
import { getCallExpressionName } from '../../utils'
|
|
40
|
+
import { createSdkDocEntry, getCallExpressionName } from '../../utils'
|
|
42
41
|
import {
|
|
43
42
|
extractLabelCache,
|
|
44
43
|
createDefinitionMap,
|
|
@@ -55,6 +54,7 @@ import {
|
|
|
55
54
|
createPropertyAccessFromPath,
|
|
56
55
|
} from '../utils/pill-string-parser'
|
|
57
56
|
import { isDataPill } from '../utils/complex-object-resolver'
|
|
57
|
+
import { wrapWithDataPillCall, extractDataPillNames } from '../utils/pill-shape-helpers'
|
|
58
58
|
import { ArrayShape } from '@servicenow/sdk-build-core'
|
|
59
59
|
import { processFlowInputs, processFlowOutputs, processFlowVariables } from '../utils/flow-variable-processor'
|
|
60
60
|
import { buildUuidToIdentifierMap, processInstanceForDatapills, uuidToRecordMap } from '../utils/datapill-transformer'
|
|
@@ -211,7 +211,7 @@ import { ApprovalDueDateShape, ApprovalRulesShape } from '../utils/flow-shapes'
|
|
|
211
211
|
|
|
212
212
|
/**
|
|
213
213
|
* Traverse ancestors to find the topmost ArrowFunction and extract its parameter name
|
|
214
|
-
* This finds the ArrowFunction that's an argument to Flow/
|
|
214
|
+
* This finds the ArrowFunction that's an argument to Flow/Subflow, ignoring nested
|
|
215
215
|
* ArrowFunctions from control flow APIs like If, ElseIf, ForEach.
|
|
216
216
|
*
|
|
217
217
|
* @param shape - The shape to start traversing from
|
|
@@ -446,45 +446,6 @@ function processShapeForDatapills(
|
|
|
446
446
|
* @param dataType - The data type string (default: 'string')
|
|
447
447
|
* @returns CallExpressionShape wrapping the expression with wfa.dataPill()
|
|
448
448
|
*/
|
|
449
|
-
function wrapWithDataPillCall(
|
|
450
|
-
expression: PropertyAccessShape | IdentifierShape,
|
|
451
|
-
source: Record,
|
|
452
|
-
dataType = 'string'
|
|
453
|
-
): CallExpressionShape {
|
|
454
|
-
return new CallExpressionShape({
|
|
455
|
-
source,
|
|
456
|
-
callee: 'wfa.dataPill',
|
|
457
|
-
args: [expression, new StringLiteralShape({ source, literalText: dataType })],
|
|
458
|
-
})
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Extract all datapill names from a string value containing datapill patterns
|
|
463
|
-
* Handles both UUID-based pills ({{uuid.property}}) and semantic pills ({{prefix.path}})
|
|
464
|
-
*
|
|
465
|
-
* @param stringValue - String that may contain datapill patterns
|
|
466
|
-
* @returns Array of datapill names (e.g., ["trigger.table_name", "uuid.record.number"])
|
|
467
|
-
*/
|
|
468
|
-
function extractDataPillNames(stringValue: string): string[] {
|
|
469
|
-
const dataPillNames: string[] = []
|
|
470
|
-
|
|
471
|
-
// Match all datapill patterns: {{...}}
|
|
472
|
-
const pillPattern = /\{\{([^}]+)\}\}/g
|
|
473
|
-
const matches = Array.from(stringValue.matchAll(pillPattern))
|
|
474
|
-
|
|
475
|
-
for (const match of matches) {
|
|
476
|
-
if (match[1]) {
|
|
477
|
-
// Extract the content inside {{}} and split by | to get just the name part
|
|
478
|
-
// (some pills may have type info like {{pill.name|string}})
|
|
479
|
-
const pillContent = match[1].split('|')[0]
|
|
480
|
-
if (pillContent) {
|
|
481
|
-
dataPillNames.push(pillContent)
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
return dataPillNames
|
|
487
|
-
}
|
|
488
449
|
|
|
489
450
|
/**
|
|
490
451
|
* Wrap all PropertyAccessShape expressions in a TemplateExpressionShape with wfa.dataPill()
|
|
@@ -610,16 +571,22 @@ function extractAllPills(
|
|
|
610
571
|
const matchStart = match.index ?? 0
|
|
611
572
|
const matchEnd = matchStart + fullMatch.length
|
|
612
573
|
|
|
613
|
-
//
|
|
614
|
-
//
|
|
615
|
-
const
|
|
616
|
-
|
|
574
|
+
// Strip type annotation if present (e.g., "uuid.field|integer" -> "uuid.field").
|
|
575
|
+
// ServiceNow stores datapills with type annotations like {{pill.path|datatype}}.
|
|
576
|
+
const pipeIndex = content.indexOf('|')
|
|
577
|
+
const cleanContent = pipeIndex !== -1 ? content.substring(0, pipeIndex) : content
|
|
578
|
+
|
|
579
|
+
// Match UUID-based pills: both bare UUID (action/subflow outputs) and step[UUID] (action step outputs)
|
|
580
|
+
// Bare: {{uuid.property}} → e.g., action/subflow instance output
|
|
581
|
+
// Step: {{step[uuid].property}} → e.g., action step output
|
|
582
|
+
const uuidMatch = cleanContent.match(
|
|
583
|
+
/^(?:step\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]|([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}))\.([a-zA-Z_][a-zA-Z0-9_.]*[a-zA-Z0-9_])$/
|
|
617
584
|
)
|
|
618
585
|
|
|
619
586
|
if (uuidMatch) {
|
|
620
587
|
// This is a UUID-based pill
|
|
621
|
-
const uuid = uuidMatch[1]
|
|
622
|
-
const property = uuidMatch[
|
|
588
|
+
const uuid = uuidMatch[1] ?? uuidMatch[2]
|
|
589
|
+
const property = uuidMatch[3]
|
|
623
590
|
|
|
624
591
|
if (!uuid || !property) {
|
|
625
592
|
continue
|
|
@@ -628,7 +595,10 @@ function extractAllPills(
|
|
|
628
595
|
const identifier = uuidToIdentifierMap.get(uuid)
|
|
629
596
|
|
|
630
597
|
if (identifier) {
|
|
631
|
-
// PRESERVE EXISTING LOGIC: Apply forEach parameter handling
|
|
598
|
+
// PRESERVE EXISTING LOGIC: Apply forEach parameter handling.
|
|
599
|
+
// Note: With the consolidated regex, this is now called for step[UUID] pills too
|
|
600
|
+
// (previously only bare UUID pills hit this code). This is harmless since action
|
|
601
|
+
// step CIDs are never forEach parameters, so isForEachParam will always be false.
|
|
632
602
|
const isForEachParam = isForEachParameter(identifier, uuid)
|
|
633
603
|
let expression: PropertyAccessShape | IdentifierShape
|
|
634
604
|
|
|
@@ -1619,6 +1589,7 @@ function postProcessAssignSubflowOutputs(
|
|
|
1619
1589
|
|
|
1620
1590
|
export const FlowDefinitionPlugin = Plugin.create({
|
|
1621
1591
|
name: 'FlowDefinitionPlugin',
|
|
1592
|
+
docs: [createSdkDocEntry('Flow', ['sys_hub_flow'])],
|
|
1622
1593
|
records: {
|
|
1623
1594
|
sys_hub_flow: {
|
|
1624
1595
|
relationships: {
|
|
@@ -1680,8 +1651,8 @@ export const FlowDefinitionPlugin = Plugin.create({
|
|
|
1680
1651
|
getUpdateName(record) {
|
|
1681
1652
|
return { success: true, value: `${record.getTable()}_${record.getId().getValue()}` }
|
|
1682
1653
|
},
|
|
1683
|
-
toFile(record, { config, database }) {
|
|
1684
|
-
return generateXML(record, { config, database })
|
|
1654
|
+
toFile(record, { config, database, self }) {
|
|
1655
|
+
return generateXML(record, { config, database, plugin: self })
|
|
1685
1656
|
},
|
|
1686
1657
|
async diff(existing, incoming, descendants, context) {
|
|
1687
1658
|
return deleteMultipleDiff(existing, incoming, descendants, context)
|
|
@@ -90,11 +90,12 @@ function isInsideFlowContext(node: ts.Node): boolean {
|
|
|
90
90
|
* - wfa.flowLogic.goBackTo
|
|
91
91
|
* - wfa.flowLogic.tryCatch
|
|
92
92
|
* - wfa.flowLogic.doInParallel
|
|
93
|
-
* - FlowObject (must be within Flow/Subflow/
|
|
94
|
-
* - FlowArray (must be within Flow/Subflow/
|
|
93
|
+
* - FlowObject (must be within Flow/Subflow/Action/TriggerDefinition)
|
|
94
|
+
* - FlowArray (must be within Flow/Subflow/Action/TriggerDefinition)
|
|
95
95
|
*/
|
|
96
96
|
export const FlowDiagnosticsPlugin = Plugin.create({
|
|
97
97
|
name: 'FlowDiagnosticsPlugin',
|
|
98
|
+
docs: [],
|
|
98
99
|
shapes: [
|
|
99
100
|
{
|
|
100
101
|
shape: CallExpressionShape,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
findCatalogItemBySysId,
|
|
40
40
|
isCatalogAction,
|
|
41
41
|
} from '../utils/service-catalog'
|
|
42
|
-
import { getAttributeValue } from '../utils/schema-to-flow-object'
|
|
42
|
+
import { getAttributeValue, parseAttributesToObject } from '../utils/schema-to-flow-object'
|
|
43
43
|
import {
|
|
44
44
|
ActionSubflowInstanceShape,
|
|
45
45
|
ApprovalRulesShape,
|
|
@@ -64,6 +64,8 @@ import {
|
|
|
64
64
|
ACTION_TYPE_KEY_NAME,
|
|
65
65
|
CATALOG_VARIABLE_TABLE,
|
|
66
66
|
CATALOG_VARIABLE_SET_TABLE,
|
|
67
|
+
INLINE_SCRIPT_UNSUPPORTED_TYPES,
|
|
68
|
+
INLINE_SCRIPT_UNSUPPORTED_FIELDS,
|
|
67
69
|
} from '../utils/flow-constants'
|
|
68
70
|
|
|
69
71
|
import type { ApprovalDueDateType, ApprovalRulesType } from '@servicenow/sdk-core/runtime/flow'
|
|
@@ -164,10 +166,13 @@ export function normalizeInputValue(value: string, uiType?: string, source?: Sou
|
|
|
164
166
|
// Create a StringShape from the value and use ApprovalRulesShape.from() to parse it
|
|
165
167
|
return ApprovalRulesShape.from(source, Shape.from(source, value).asString())
|
|
166
168
|
} else if (uiType === APPROVAL_DUE_DATE_DATA_TYPE_VALUE) {
|
|
167
|
-
// Check if source is a Record before accessing action_type
|
|
169
|
+
// Check if source is a Record before accessing action_type or step_type.
|
|
170
|
+
// Flow context uses action_type; action definition context uses step_type.
|
|
168
171
|
if (source instanceof Record) {
|
|
169
172
|
const actionType = source.get(ACTION_TYPE_KEY_NAME)?.ifDefined()?.asString()?.getValue()
|
|
170
|
-
|
|
173
|
+
const stepType = source.get('step_type')?.ifDefined()?.asString()?.getValue()
|
|
174
|
+
const typeId = actionType ?? stepType
|
|
175
|
+
if (typeId && APPROVAL_DUE_DATE_INPUT_FIELD_ACTIONS.includes(typeId)) {
|
|
171
176
|
// Create a StringShape from the value and use ApprovalDueDateShape.from() to parse it
|
|
172
177
|
return ApprovalDueDateShape.from(source, Shape.from(source, value).asString())
|
|
173
178
|
}
|
|
@@ -275,10 +280,6 @@ function buildInstanceToShape({
|
|
|
275
280
|
}
|
|
276
281
|
|
|
277
282
|
const coreActionIdentifier = getCoreActionIdentifier(sysId)
|
|
278
|
-
if (callee === ACTION_INSTANCE_API_NAME && !coreActionIdentifier) {
|
|
279
|
-
logger.warn(`Custom actions are not supported, action = ${sysId}`)
|
|
280
|
-
return { success: false }
|
|
281
|
-
}
|
|
282
283
|
|
|
283
284
|
const action = database
|
|
284
285
|
.query('sys_hub_action_type_definition')
|
|
@@ -325,13 +326,12 @@ function buildInstanceToShape({
|
|
|
325
326
|
if (inputsShape === undefined) {
|
|
326
327
|
return { success: false as const }
|
|
327
328
|
}
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if (waitForCompletion) {
|
|
329
|
+
const waitForCompletionValue = record.get('wait_for_completion')?.getValue()
|
|
330
|
+
const isWaitForCompletionFalse = waitForCompletionValue === false || waitForCompletionValue === 'false'
|
|
331
|
+
if (isWaitForCompletionFalse) {
|
|
332
332
|
inputsShape = inputsShape
|
|
333
|
-
? inputsShape.merge({ waitForCompletion })
|
|
334
|
-
: Shape.from(record, { waitForCompletion }).asObject()
|
|
333
|
+
? inputsShape.merge({ waitForCompletion: false })
|
|
334
|
+
: Shape.from(record, { waitForCompletion: false }).asObject()
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
const configArg = new ObjectShape({
|
|
@@ -451,6 +451,7 @@ function validateCatalogVariableOutputReferences(
|
|
|
451
451
|
|
|
452
452
|
export const FlowInstancePlugin = Plugin.create({
|
|
453
453
|
name: 'FlowInstancePlugin',
|
|
454
|
+
docs: [],
|
|
454
455
|
records: {
|
|
455
456
|
sys_hub_action_instance_v2: {
|
|
456
457
|
toShape: buildInstanceToShape({
|
|
@@ -518,6 +519,7 @@ export const FlowInstancePlugin = Plugin.create({
|
|
|
518
519
|
source: callExpression,
|
|
519
520
|
transform,
|
|
520
521
|
logger,
|
|
522
|
+
diagnostics,
|
|
521
523
|
})
|
|
522
524
|
} else if (instanceType === SUBFLOW_INSTANCE_API_NAME) {
|
|
523
525
|
instanceRecord = await buildSubflowInstance({
|
|
@@ -529,6 +531,7 @@ export const FlowInstancePlugin = Plugin.create({
|
|
|
529
531
|
factory,
|
|
530
532
|
source: callExpression,
|
|
531
533
|
transform,
|
|
534
|
+
diagnostics,
|
|
532
535
|
})
|
|
533
536
|
}
|
|
534
537
|
|
|
@@ -708,6 +711,7 @@ async function buildActionInstance({
|
|
|
708
711
|
source,
|
|
709
712
|
transform,
|
|
710
713
|
logger,
|
|
714
|
+
diagnostics,
|
|
711
715
|
}: {
|
|
712
716
|
actionDef: Record | StringShape | undefined
|
|
713
717
|
inputs: ObjectShape
|
|
@@ -718,8 +722,12 @@ async function buildActionInstance({
|
|
|
718
722
|
source: Source
|
|
719
723
|
transform: Transform
|
|
720
724
|
logger: Logger
|
|
725
|
+
diagnostics: Diagnostics
|
|
721
726
|
}): Promise<Record | undefined> {
|
|
722
|
-
const values = actionDef
|
|
727
|
+
const values = actionDef
|
|
728
|
+
? await prepareActionInstanceValueJson(inputs, actionDef, transform, logger, diagnostics)
|
|
729
|
+
: undefined
|
|
730
|
+
|
|
723
731
|
const actionDefRecord = actionDef instanceof Record ? actionDef : undefined
|
|
724
732
|
const instanceProps = inputs.transform(({ $ }) => ({
|
|
725
733
|
active: $.val(true),
|
|
@@ -759,6 +767,7 @@ async function buildSubflowInstance({
|
|
|
759
767
|
uuid,
|
|
760
768
|
source,
|
|
761
769
|
transform,
|
|
770
|
+
diagnostics,
|
|
762
771
|
}: {
|
|
763
772
|
subflowDef: Record | StringShape | undefined
|
|
764
773
|
inputs: ObjectShape
|
|
@@ -768,8 +777,11 @@ async function buildSubflowInstance({
|
|
|
768
777
|
uuid: string | undefined
|
|
769
778
|
source: Source
|
|
770
779
|
transform: Transform
|
|
780
|
+
diagnostics: Diagnostics
|
|
771
781
|
}): Promise<Record | undefined> {
|
|
772
|
-
const values = subflowDef
|
|
782
|
+
const values = subflowDef
|
|
783
|
+
? await prepareSubflowInstanceValueJson(inputs, subflowDef, transform, diagnostics)
|
|
784
|
+
: undefined
|
|
773
785
|
|
|
774
786
|
const subflowDefRecord = subflowDef instanceof Record ? subflowDef : undefined
|
|
775
787
|
const instanceProps = inputs.transform(({ $ }) => ({
|
|
@@ -781,7 +793,7 @@ async function buildSubflowInstance({
|
|
|
781
793
|
generation_source: $.val(''),
|
|
782
794
|
subflow: $.val(subflowDefRecord?.getId()?.getValue() || subflowDef?.getValue() || ''),
|
|
783
795
|
subflow_inputs: $.val(values),
|
|
784
|
-
wait_for_completion: $.from('waitForCompletion').def(
|
|
796
|
+
wait_for_completion: $.from('waitForCompletion').def(true),
|
|
785
797
|
sys_class_name: $.val('sys_hub_sub_flow_instance_v2'),
|
|
786
798
|
parent_ui_id: $.def(''),
|
|
787
799
|
}))
|
|
@@ -867,7 +879,7 @@ function resolveComplexInput(
|
|
|
867
879
|
parentDef: Record,
|
|
868
880
|
inputTableName: string,
|
|
869
881
|
logger?: Logger
|
|
870
|
-
): { value: unknown; internalType: unknown } {
|
|
882
|
+
): { value: unknown; internalType: unknown; children?: unknown[] } {
|
|
871
883
|
return _resolveComplexInput(name, value, parentDef, inputTableName, undefined, logger)
|
|
872
884
|
}
|
|
873
885
|
|
|
@@ -943,14 +955,27 @@ function processInputValue(
|
|
|
943
955
|
}
|
|
944
956
|
|
|
945
957
|
/**
|
|
946
|
-
* Processes a definition input
|
|
958
|
+
* Processes a definition input not provided by the user.
|
|
947
959
|
* Handles hidden fields and default values by creating appropriate input objects.
|
|
948
960
|
*
|
|
961
|
+
* For hidden inputs, all attributes from the input definition are included in the
|
|
962
|
+
* parameter (e.g., `element_mapping_provider`, `uiType`) so that Flow Designer can
|
|
963
|
+
* properly handle them at runtime. For reference types, the reference table is also
|
|
964
|
+
* included. For complex object types (`FlowObject`/`FlowArray`), the complex object
|
|
965
|
+
* value is generated via `resolveComplexInput`.
|
|
966
|
+
*
|
|
949
967
|
* @param inputDef - The input definition record from the action/subflow definition
|
|
950
968
|
* @param inputName - The name of the input field
|
|
969
|
+
* @param actionDefRecord - The parent action definition record (needed for complex object resolution)
|
|
970
|
+
* @param logger - Logger instance
|
|
951
971
|
* @returns The processed input object if the field is hidden or has a default value, undefined otherwise
|
|
952
972
|
*/
|
|
953
|
-
function processDefaultOrHiddenInput(
|
|
973
|
+
function processDefaultOrHiddenInput(
|
|
974
|
+
inputDef: Record,
|
|
975
|
+
inputName: string,
|
|
976
|
+
actionDefRecord?: Record,
|
|
977
|
+
logger?: Logger
|
|
978
|
+
): unknown | undefined {
|
|
954
979
|
// Get attributes and check if hidden
|
|
955
980
|
const attributes = inputDef.get('attributes')?.ifString()?.getValue()
|
|
956
981
|
const visibleAttr = attributes ? getAttributeValue(attributes, 'visible') : undefined
|
|
@@ -962,16 +987,60 @@ function processDefaultOrHiddenInput(inputDef: Record, inputName: string): unkno
|
|
|
962
987
|
const hasDefaultValue = defaultValue !== undefined && defaultValue !== null && defaultValue !== ''
|
|
963
988
|
const internalType = inputDef.get('internal_type')?.asString()?.getValue() || 'string'
|
|
964
989
|
|
|
965
|
-
// For hidden fields or fields with default values, add them to result
|
|
990
|
+
// For hidden fields or fields with default values, add them to the result.
|
|
966
991
|
if (isHidden || hasDefaultValue) {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
992
|
+
let valueToUse: unknown = hasDefaultValue ? defaultValue : ''
|
|
993
|
+
|
|
994
|
+
// Parse all attributes from the input definition for the parameter.
|
|
995
|
+
const paramAttributes: globalThis.Record<string, unknown> = {}
|
|
996
|
+
if (attributes) {
|
|
997
|
+
const parsedAttributes = parseAttributesToObject(attributes)
|
|
998
|
+
for (const [key, value] of Object.entries(parsedAttributes)) {
|
|
999
|
+
if (value !== undefined) {
|
|
1000
|
+
paramAttributes[key] = value
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
971
1003
|
}
|
|
972
|
-
|
|
973
|
-
|
|
1004
|
+
|
|
1005
|
+
// Get the reference table for reference type inputs.
|
|
1006
|
+
const reference = inputDef.get('reference')?.ifString()?.getValue()
|
|
1007
|
+
|
|
1008
|
+
// For complex object types (`FlowObject`/`FlowArray`), resolve the value.
|
|
1009
|
+
const coType = paramAttributes['co_type_name'] as string | undefined
|
|
1010
|
+
const uiType = paramAttributes['uiType'] as string | undefined
|
|
1011
|
+
|
|
1012
|
+
if (actionDefRecord && coType && uiType) {
|
|
1013
|
+
const resolvedValue = resolveComplexInput(
|
|
1014
|
+
inputName,
|
|
1015
|
+
typeof valueToUse === 'object' && valueToUse !== null ? valueToUse : {},
|
|
1016
|
+
actionDefRecord,
|
|
1017
|
+
'sys_hub_action_input',
|
|
1018
|
+
logger
|
|
1019
|
+
)
|
|
1020
|
+
|
|
1021
|
+
if (resolvedValue.value !== undefined) {
|
|
1022
|
+
valueToUse = resolvedValue.value
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
const result: globalThis.Record<string, unknown> = {
|
|
1026
|
+
name: inputName,
|
|
1027
|
+
value: valueToUse,
|
|
1028
|
+
displayValue: valueToUse,
|
|
1029
|
+
scriptActive: false,
|
|
1030
|
+
parameter: {
|
|
1031
|
+
type: resolvedValue.internalType ?? internalType,
|
|
1032
|
+
...(Object.keys(paramAttributes).length > 0 && { attributes: paramAttributes }),
|
|
1033
|
+
...(reference && { reference }),
|
|
1034
|
+
},
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
if (resolvedValue.children && resolvedValue.children.length > 0) {
|
|
1038
|
+
result['children'] = resolvedValue.children
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
return result
|
|
974
1042
|
}
|
|
1043
|
+
|
|
975
1044
|
return {
|
|
976
1045
|
name: inputName,
|
|
977
1046
|
value: valueToUse,
|
|
@@ -980,12 +1049,68 @@ function processDefaultOrHiddenInput(inputDef: Record, inputName: string): unkno
|
|
|
980
1049
|
parameter: {
|
|
981
1050
|
type: internalType,
|
|
982
1051
|
...(Object.keys(paramAttributes).length > 0 && { attributes: paramAttributes }),
|
|
1052
|
+
...(reference && { reference }),
|
|
983
1053
|
},
|
|
984
1054
|
}
|
|
985
1055
|
}
|
|
986
1056
|
return undefined
|
|
987
1057
|
}
|
|
988
1058
|
|
|
1059
|
+
/**
|
|
1060
|
+
* Validates mandatory fields on raw shapes before datapill or inline script resolution. Only `StringShape`
|
|
1061
|
+
* values are validated for emptiness. Runtime-evaluated shapes (data pills, template expressions, inline
|
|
1062
|
+
* scripts, identifiers) are exempt because their values cannot be determined at build time.
|
|
1063
|
+
*
|
|
1064
|
+
* @param definition - The action or subflow definition record containing input definitions.
|
|
1065
|
+
* @param instanceInputs - The raw ObjectShape of user-provided input values before resolution.
|
|
1066
|
+
* @param diagnostics - Diagnostics instance for reporting validation errors.
|
|
1067
|
+
* @param inputTable - The table name for input definitions (e.g., 'sys_hub_action_input' or 'sys_hub_flow_input').
|
|
1068
|
+
* @param definitionName - Optional name of the action or subflow for more specific error messages.
|
|
1069
|
+
* @returns The filtered input definition records for reuse, or undefined if no definition.
|
|
1070
|
+
*/
|
|
1071
|
+
function validateMandatoryFields(
|
|
1072
|
+
definition: Record | undefined,
|
|
1073
|
+
instanceInputs: ObjectShape,
|
|
1074
|
+
diagnostics: Diagnostics,
|
|
1075
|
+
inputTable: string,
|
|
1076
|
+
definitionName?: string
|
|
1077
|
+
): Record[] | undefined {
|
|
1078
|
+
const inputDefinitions = definition
|
|
1079
|
+
? definition.flat().filter((record) => record.getTable() === inputTable)
|
|
1080
|
+
: undefined
|
|
1081
|
+
|
|
1082
|
+
if (inputDefinitions) {
|
|
1083
|
+
const rawEntries = new Map(instanceInputs.entries({ resolve: false }))
|
|
1084
|
+
|
|
1085
|
+
for (const inputDefinition of inputDefinitions) {
|
|
1086
|
+
const inputName = inputDefinition.get('element')?.asString()?.getValue() ?? ''
|
|
1087
|
+
if (!inputName) {
|
|
1088
|
+
continue
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
const isMandatory = inputDefinition.get('mandatory')?.ifBoolean()?.getValue() ?? false
|
|
1092
|
+
if (!isMandatory) {
|
|
1093
|
+
continue
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
const rawShape = rawEntries.get(inputName)
|
|
1097
|
+
if (!rawShape) {
|
|
1098
|
+
continue
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
if (rawShape.isString() && rawShape.isEmpty()) {
|
|
1102
|
+
const context = definitionName ? ` in action '${definitionName}'` : ''
|
|
1103
|
+
diagnostics.error(
|
|
1104
|
+
rawShape,
|
|
1105
|
+
`Mandatory field '${inputName}'${context} cannot be an empty string. Please provide a non-empty value.`
|
|
1106
|
+
)
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
return inputDefinitions
|
|
1112
|
+
}
|
|
1113
|
+
|
|
989
1114
|
/**
|
|
990
1115
|
* Resolve a catalog item record from a Shape (direct Record, TemplateExpressionShape, or IdentifierShape).
|
|
991
1116
|
*/
|
|
@@ -1162,7 +1287,8 @@ async function prepareActionInstanceValueJson(
|
|
|
1162
1287
|
instanceInputs: ObjectShape | undefined,
|
|
1163
1288
|
actionDef: Record | StringShape,
|
|
1164
1289
|
transform: Transform,
|
|
1165
|
-
logger: Logger
|
|
1290
|
+
logger: Logger,
|
|
1291
|
+
diagnostics: Diagnostics
|
|
1166
1292
|
) {
|
|
1167
1293
|
const actionDefRecord = actionDef.isRecord() ? actionDef.as(Record) : undefined
|
|
1168
1294
|
if (!instanceInputs) {
|
|
@@ -1170,13 +1296,25 @@ async function prepareActionInstanceValueJson(
|
|
|
1170
1296
|
}
|
|
1171
1297
|
const isActionDefString = actionDef instanceof StringShape
|
|
1172
1298
|
|
|
1299
|
+
// Resolve action name early for use in validation messages and special handling
|
|
1300
|
+
const actionSysId = actionDefRecord?.getId()?.getValue()
|
|
1301
|
+
const actionName = typeof actionSysId === 'string' ? CORE_ACTIONS_SYS_ID_NAME_MAP[actionSysId] : undefined
|
|
1302
|
+
|
|
1303
|
+
const definitionInputs = validateMandatoryFields(
|
|
1304
|
+
actionDefRecord,
|
|
1305
|
+
instanceInputs,
|
|
1306
|
+
diagnostics,
|
|
1307
|
+
'sys_hub_action_input',
|
|
1308
|
+
actionName
|
|
1309
|
+
)
|
|
1310
|
+
|
|
1173
1311
|
// Special handling for getCatalogVariables action
|
|
1174
1312
|
let overrideValues = new Map<string, string>()
|
|
1175
1313
|
let displayValues = new Map<string, string>()
|
|
1314
|
+
let unsupportedFieldsForAction: string[] | undefined
|
|
1176
1315
|
|
|
1177
1316
|
if (actionDefRecord) {
|
|
1178
|
-
|
|
1179
|
-
const actionName = typeof actionSysId === 'string' ? CORE_ACTIONS_SYS_ID_NAME_MAP[actionSysId] : undefined
|
|
1317
|
+
unsupportedFieldsForAction = actionName ? INLINE_SCRIPT_UNSUPPORTED_FIELDS[actionName] : undefined
|
|
1180
1318
|
|
|
1181
1319
|
// Check if this is the getCatalogVariables action or createCatalogTask action
|
|
1182
1320
|
if (actionName === 'getCatalogVariables' || actionName === 'createCatalogTask') {
|
|
@@ -1218,9 +1356,8 @@ async function prepareActionInstanceValueJson(
|
|
|
1218
1356
|
|
|
1219
1357
|
// When isActionDefString is true, there's no action definition in fluent
|
|
1220
1358
|
// We expect arbitrary inputs and should process all provided inputs directly
|
|
1221
|
-
if (actionDefRecord) {
|
|
1222
|
-
// When action definition record is present, process only definition inputs
|
|
1223
|
-
const definitionInputs = actionDefRecord.flat().filter((v) => v.getTable() === 'sys_hub_action_input')
|
|
1359
|
+
if (actionDefRecord && definitionInputs) {
|
|
1360
|
+
// When action definition record is present, process only the definition inputs.
|
|
1224
1361
|
const providedInputNames = new Set(objShape.keys())
|
|
1225
1362
|
|
|
1226
1363
|
for (const inputDef of definitionInputs) {
|
|
@@ -1230,6 +1367,26 @@ async function prepareActionInstanceValueJson(
|
|
|
1230
1367
|
}
|
|
1231
1368
|
// If input is provided in objShape(ie provided by user), process it
|
|
1232
1369
|
if (providedInputNames.has(inputName)) {
|
|
1370
|
+
const internalType = inputDef.get('internal_type')?.asString()?.getValue()
|
|
1371
|
+
const inputValue = objShape.get(inputName)
|
|
1372
|
+
if (
|
|
1373
|
+
isInlineScriptValue(inputValue?.getValue()) &&
|
|
1374
|
+
internalType &&
|
|
1375
|
+
INLINE_SCRIPT_UNSUPPORTED_TYPES.includes(internalType)
|
|
1376
|
+
) {
|
|
1377
|
+
diagnostics.error(
|
|
1378
|
+
inputValue,
|
|
1379
|
+
`wfa.inlineScript() is not supported for input '${inputName}' of type '${internalType}'. This type uses special parsing that is incompatible with dynamic script execution.`
|
|
1380
|
+
)
|
|
1381
|
+
continue
|
|
1382
|
+
}
|
|
1383
|
+
if (isInlineScriptValue(inputValue?.getValue()) && unsupportedFieldsForAction?.includes(inputName)) {
|
|
1384
|
+
diagnostics.error(
|
|
1385
|
+
inputValue,
|
|
1386
|
+
`wfa.inlineScript() is not supported for input '${inputName}'. This field references catalog metadata that must be resolved at design time for the Flow Designer UI.`
|
|
1387
|
+
)
|
|
1388
|
+
continue
|
|
1389
|
+
}
|
|
1233
1390
|
const processedValue = processInputValue(
|
|
1234
1391
|
inputName,
|
|
1235
1392
|
objShape,
|
|
@@ -1243,7 +1400,7 @@ async function prepareActionInstanceValueJson(
|
|
|
1243
1400
|
result.push(processedValue)
|
|
1244
1401
|
} else {
|
|
1245
1402
|
// Process default or hidden input
|
|
1246
|
-
const processedValue = processDefaultOrHiddenInput(inputDef, inputName)
|
|
1403
|
+
const processedValue = processDefaultOrHiddenInput(inputDef, inputName, actionDefRecord, logger)
|
|
1247
1404
|
if (processedValue) {
|
|
1248
1405
|
result.push(processedValue)
|
|
1249
1406
|
}
|
|
@@ -1262,8 +1419,15 @@ async function prepareActionInstanceValueJson(
|
|
|
1262
1419
|
async function prepareSubflowInstanceValueJson(
|
|
1263
1420
|
instanceInputs: ObjectShape,
|
|
1264
1421
|
subflowDef: Record | StringShape,
|
|
1265
|
-
transform: Transform
|
|
1422
|
+
transform: Transform,
|
|
1423
|
+
diagnostics: Diagnostics
|
|
1266
1424
|
) {
|
|
1425
|
+
const subflowDefRecord = subflowDef.isRecord() ? subflowDef.as(Record) : undefined
|
|
1426
|
+
const subflowName = subflowDefRecord?.get('name')?.ifString()?.getValue()
|
|
1427
|
+
|
|
1428
|
+
// Validate mandatory fields on raw shapes before any resolution.
|
|
1429
|
+
validateMandatoryFields(subflowDefRecord, instanceInputs, diagnostics, 'sys_hub_flow_input', subflowName)
|
|
1430
|
+
|
|
1267
1431
|
// Check for datapills and resolve them
|
|
1268
1432
|
const dataPillResults = await checkAndResolveDataPills(instanceInputs, transform)
|
|
1269
1433
|
|
|
@@ -1297,8 +1461,9 @@ async function prepareSubflowInstanceValueJson(
|
|
|
1297
1461
|
value: primitiveValue,
|
|
1298
1462
|
internalType: undefined,
|
|
1299
1463
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1464
|
+
|
|
1465
|
+
if (subflowDefRecord) {
|
|
1466
|
+
resolvedValue = resolveComplexInput(key, primitiveValue, subflowDefRecord, 'sys_hub_flow_input')
|
|
1302
1467
|
}
|
|
1303
1468
|
|
|
1304
1469
|
const result: globalThis.Record<string, unknown> = {
|
|
@@ -2,11 +2,13 @@ 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'
|
|
5
6
|
/**
|
|
6
7
|
* Plugin for processing StepDefinition calls
|
|
7
8
|
*/
|
|
8
9
|
export const StepDefinitionPlugin = Plugin.create({
|
|
9
10
|
name: 'StepDefinitionPlugin',
|
|
11
|
+
docs: [createSdkDocEntry('ActionStepDefinition', ['sys_flow_step_definition'])],
|
|
10
12
|
records: {
|
|
11
13
|
sys_flow_step_definition: {
|
|
12
14
|
relationships: {
|
|
@@ -53,8 +55,8 @@ export const StepDefinitionPlugin = Plugin.create({
|
|
|
53
55
|
}),
|
|
54
56
|
}
|
|
55
57
|
},
|
|
56
|
-
toFile(record, { config, database }) {
|
|
57
|
-
return generateXML(record, { config, database })
|
|
58
|
+
toFile(record, { config, database, self }) {
|
|
59
|
+
return generateXML(record, { config, database, plugin: self })
|
|
58
60
|
},
|
|
59
61
|
},
|
|
60
62
|
sys_flow_step_definition_input: {
|