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