@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,254 @@
|
|
|
1
|
+
import type { Diagnostics, ObjectShape } from '@servicenow/sdk-build-core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validates that at most one of executionPlan, flow, or workflow is defined.
|
|
5
|
+
* These fields are mutually exclusive in the FulfillmentProcess type.
|
|
6
|
+
* Returns true if valid, false if a diagnostic was emitted.
|
|
7
|
+
*/
|
|
8
|
+
export function validateFulfillmentProcessExclusivity(arg: ObjectShape, diagnostics: Diagnostics): boolean {
|
|
9
|
+
const fields = ['executionPlan', 'flow', 'workflow'] as const
|
|
10
|
+
const defined = fields.filter((f) => {
|
|
11
|
+
const val = arg.get(f)
|
|
12
|
+
return val.isDefined() && (!!val.ifRecordId() || !val.ifString()?.isEmpty())
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
if (defined.length > 1) {
|
|
16
|
+
diagnostics.error(
|
|
17
|
+
arg,
|
|
18
|
+
`Only one of executionPlan, flow, or workflow can be specified. Found: ${defined.join(', ')}. Remove the extra fields so that only one fulfillment method is configured.`
|
|
19
|
+
)
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Validates that categories are only provided when catalogs are also provided.
|
|
27
|
+
* Returns true if valid, false if a diagnostic was emitted.
|
|
28
|
+
*/
|
|
29
|
+
export function validateCategoriesRequireCatalogs(arg: ObjectShape, diagnostics: Diagnostics): boolean {
|
|
30
|
+
const hasCategories =
|
|
31
|
+
arg.get('categories').isDefined() && (arg.get('categories').ifArray()?.getElements()?.length ?? 0) > 0
|
|
32
|
+
const hasCatalogs =
|
|
33
|
+
arg.get('catalogs').isDefined() && (arg.get('catalogs').ifArray()?.getElements()?.length ?? 0) > 0
|
|
34
|
+
|
|
35
|
+
if (hasCategories && !hasCatalogs) {
|
|
36
|
+
diagnostics.error(
|
|
37
|
+
arg.get('categories'),
|
|
38
|
+
`'categories' requires 'catalogs' to also be specified. Categories can only be selected after the Catalogs field is populated.`
|
|
39
|
+
)
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
return true
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Validates that catalogItem and variableSet are not both provided.
|
|
47
|
+
* When appliesTo is 'set', variableSet should be provided; when 'item', catalogItem should be provided.
|
|
48
|
+
* Returns true if valid, false if a diagnostic was emitted.
|
|
49
|
+
*/
|
|
50
|
+
export function validateCatalogItemVariableSetExclusivity(
|
|
51
|
+
arg: ObjectShape,
|
|
52
|
+
diagnostics: Diagnostics,
|
|
53
|
+
context: string
|
|
54
|
+
): boolean {
|
|
55
|
+
const hasCatalogItem = arg.get('catalogItem').isDefined() && !arg.get('catalogItem').ifString()?.isEmpty()
|
|
56
|
+
const hasVariableSet = arg.get('variableSet').isDefined() && !arg.get('variableSet').ifString()?.isEmpty()
|
|
57
|
+
|
|
58
|
+
if (hasCatalogItem && hasVariableSet) {
|
|
59
|
+
diagnostics.error(
|
|
60
|
+
arg,
|
|
61
|
+
`${context}: 'catalogItem' and 'variableSet' are mutually exclusive. Specify only one. When appliesTo is 'set', use variableSet; when 'item', use catalogItem.`
|
|
62
|
+
)
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const appliesTo = arg.get('appliesTo')?.ifString()?.getValue()
|
|
67
|
+
if (appliesTo === 'set' && hasCatalogItem) {
|
|
68
|
+
diagnostics.error(
|
|
69
|
+
arg.get('catalogItem'),
|
|
70
|
+
`${context}: 'catalogItem' should not be specified when appliesTo is 'set'. Use 'variableSet' instead.`
|
|
71
|
+
)
|
|
72
|
+
return false
|
|
73
|
+
}
|
|
74
|
+
if (appliesTo === 'item' && hasVariableSet) {
|
|
75
|
+
diagnostics.error(
|
|
76
|
+
arg.get('variableSet'),
|
|
77
|
+
`${context}: 'variableSet' should not be specified when appliesTo is 'item'. Use 'catalogItem' instead.`
|
|
78
|
+
)
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return true
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Validates that variableMessage is provided when variableMessageType is set in a UI policy action.
|
|
87
|
+
* Returns true if valid, false if a diagnostic was emitted.
|
|
88
|
+
*/
|
|
89
|
+
export function validateUiPolicyActionMessage(actionObj: ObjectShape, diagnostics: Diagnostics): boolean {
|
|
90
|
+
const hasMessageType =
|
|
91
|
+
actionObj.get('variableMessageType').isDefined() && !actionObj.get('variableMessageType').ifString()?.isEmpty()
|
|
92
|
+
const hasMessage =
|
|
93
|
+
actionObj.get('variableMessage').isDefined() && !actionObj.get('variableMessage').ifString()?.isEmpty()
|
|
94
|
+
|
|
95
|
+
if (hasMessageType && !hasMessage) {
|
|
96
|
+
diagnostics.error(
|
|
97
|
+
actionObj.get('variableMessageType'),
|
|
98
|
+
`'variableMessage' is required when 'variableMessageType' is specified. Provide a message to display on the field.`
|
|
99
|
+
)
|
|
100
|
+
return false
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (hasMessage && !hasMessageType) {
|
|
104
|
+
diagnostics.error(
|
|
105
|
+
actionObj.get('variableMessage'),
|
|
106
|
+
`'variableMessageType' is required when 'variableMessage' is specified. Provide a message type (info, warning, or error).`
|
|
107
|
+
)
|
|
108
|
+
return false
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return true
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Validates that 'field' is provided when 'mapToField' is true in a variable config.
|
|
116
|
+
* Returns true if valid, false if a diagnostic was emitted.
|
|
117
|
+
*/
|
|
118
|
+
export function validateMapToFieldRequiresField(config: ObjectShape, diagnostics: Diagnostics): boolean {
|
|
119
|
+
const mapToField = config.get('mapToField')
|
|
120
|
+
const isMapToFieldTrue = mapToField.isDefined() && mapToField.ifBoolean()?.getValue() === true
|
|
121
|
+
const hasField = config.get('field').isDefined() && !config.get('field').ifString()?.isEmpty()
|
|
122
|
+
|
|
123
|
+
if (isMapToFieldTrue && !hasField) {
|
|
124
|
+
diagnostics.error(mapToField, `'field' is required when 'mapToField' is true. Specify the field to map to.`)
|
|
125
|
+
return false
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return true
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Validates that mandatory is not true when hidden or readOnly is true, and vice versa.
|
|
133
|
+
* Returns true if valid, false if a diagnostic was emitted.
|
|
134
|
+
*/
|
|
135
|
+
export function validateMandatoryReadOnlyHidden(config: ObjectShape, diagnostics: Diagnostics): boolean {
|
|
136
|
+
const isMandatory = config.get('mandatory').isDefined() && config.get('mandatory').ifBoolean()?.getValue() === true
|
|
137
|
+
const isReadOnly = config.get('readOnly').isDefined() && config.get('readOnly').ifBoolean()?.getValue() === true
|
|
138
|
+
const isHidden = config.get('hidden').isDefined() && config.get('hidden').ifBoolean()?.getValue() === true
|
|
139
|
+
|
|
140
|
+
if (isMandatory && isReadOnly) {
|
|
141
|
+
diagnostics.error(
|
|
142
|
+
config.get('mandatory'),
|
|
143
|
+
`'mandatory' cannot be true when 'readOnly' is true. A field cannot be both required and read-only.`
|
|
144
|
+
)
|
|
145
|
+
return false
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (isMandatory && isHidden) {
|
|
149
|
+
diagnostics.error(
|
|
150
|
+
config.get('mandatory'),
|
|
151
|
+
`'mandatory' cannot be true when 'hidden' is true. A field cannot be both required and hidden.`
|
|
152
|
+
)
|
|
153
|
+
return false
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return true
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Validates lookup variable configuration: table-based and choice-based properties are mutually exclusive,
|
|
161
|
+
* and price fields are not allowed when uniqueValuesOnly is true.
|
|
162
|
+
* Returns true if valid, false if a diagnostic was emitted.
|
|
163
|
+
*/
|
|
164
|
+
export function validateLookupSourceExclusivity(config: ObjectShape, diagnostics: Diagnostics): boolean {
|
|
165
|
+
const lookupSource = config.get('lookupSource')
|
|
166
|
+
const lookupSourceValue = lookupSource?.ifString()?.getValue()
|
|
167
|
+
const hasLookupSource = lookupSource.isDefined() && !lookupSource.ifString()?.isEmpty()
|
|
168
|
+
const hasLookupFromTable =
|
|
169
|
+
config.get('lookupFromTable').isDefined() && !config.get('lookupFromTable').ifString()?.isEmpty()
|
|
170
|
+
const hasLookupValueField =
|
|
171
|
+
config.get('lookupValueField').isDefined() && !config.get('lookupValueField').ifString()?.isEmpty()
|
|
172
|
+
|
|
173
|
+
const isChoicesSource = hasLookupSource && lookupSourceValue === 'choices'
|
|
174
|
+
|
|
175
|
+
if (isChoicesSource) {
|
|
176
|
+
if (hasLookupFromTable) {
|
|
177
|
+
diagnostics.error(
|
|
178
|
+
config.get('lookupFromTable'),
|
|
179
|
+
`'lookupFromTable' should not be specified when 'lookupSource' is 'choices'.`
|
|
180
|
+
)
|
|
181
|
+
return false
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (hasLookupValueField) {
|
|
185
|
+
diagnostics.error(
|
|
186
|
+
config.get('lookupValueField'),
|
|
187
|
+
`'lookupValueField' should not be specified when 'lookupSource' is 'choices'.`
|
|
188
|
+
)
|
|
189
|
+
return false
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return true
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const requiredNode = lookupSource.isDefined() ? lookupSource : config
|
|
196
|
+
|
|
197
|
+
if (!hasLookupFromTable) {
|
|
198
|
+
diagnostics.error(requiredNode, `'lookupFromTable' is required when 'lookupSource' is not 'choices'.`)
|
|
199
|
+
return false
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!hasLookupValueField) {
|
|
203
|
+
diagnostics.error(requiredNode, `'lookupValueField' is required when 'lookupSource' is not 'choices'.`)
|
|
204
|
+
return false
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return true
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Validates reference qualifier fields are mutually exclusive and consistent with useReferenceQualifier.
|
|
212
|
+
* referenceQualCondition, dynamicRefQual, and referenceQual are mutually exclusive.
|
|
213
|
+
* Returns true if valid, false if a diagnostic was emitted.
|
|
214
|
+
*/
|
|
215
|
+
export function validateReferenceQualifierExclusivity(
|
|
216
|
+
config: ObjectShape,
|
|
217
|
+
diagnostics: Diagnostics,
|
|
218
|
+
context: string
|
|
219
|
+
): boolean {
|
|
220
|
+
const hasRefQualCondition =
|
|
221
|
+
config.get('referenceQualCondition').isDefined() && !config.get('referenceQualCondition').ifString()?.isEmpty()
|
|
222
|
+
const hasDynamicRefQual =
|
|
223
|
+
config.get('dynamicRefQual').isDefined() && !config.get('dynamicRefQual').ifString()?.isEmpty()
|
|
224
|
+
const hasRefQual = config.get('referenceQual').isDefined() && !config.get('referenceQual').ifString()?.isEmpty()
|
|
225
|
+
|
|
226
|
+
const useRefQualShape = config.get('useReferenceQualifier')
|
|
227
|
+
const useRefQual = useRefQualShape?.ifString()?.getValue()
|
|
228
|
+
|
|
229
|
+
if ((useRefQual === 'simple' || useRefQualShape.ifString()?.isEmpty()) && !hasRefQualCondition) {
|
|
230
|
+
diagnostics.error(
|
|
231
|
+
useRefQualShape,
|
|
232
|
+
`${context}: 'referenceQualCondition' is required when 'useReferenceQualifier' is 'simple'.`
|
|
233
|
+
)
|
|
234
|
+
return false
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (useRefQual === 'dynamic' && !hasDynamicRefQual) {
|
|
238
|
+
diagnostics.error(
|
|
239
|
+
useRefQualShape,
|
|
240
|
+
`${context}: 'dynamicRefQual' is required when 'useReferenceQualifier' is 'dynamic'.`
|
|
241
|
+
)
|
|
242
|
+
return false
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (useRefQual === 'advanced' && !hasRefQual) {
|
|
246
|
+
diagnostics.error(
|
|
247
|
+
useRefQualShape,
|
|
248
|
+
`${context}: 'referenceQual' is required when 'useReferenceQualifier' is 'advanced'.`
|
|
249
|
+
)
|
|
250
|
+
return false
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return true
|
|
254
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CallExpressionShape,
|
|
3
|
+
type Record,
|
|
4
|
+
type Factory,
|
|
5
|
+
type ObjectShape,
|
|
6
|
+
type Diagnostics,
|
|
7
|
+
} from '@servicenow/sdk-build-core'
|
|
8
|
+
import { getVariableTypeFromName } from './variable-helper'
|
|
9
|
+
import { VariableTypeName } from './variable-helper'
|
|
10
|
+
import { convertRolesToString, getVisibilityId, validateFieldNameBelongsToTable } from './utils'
|
|
11
|
+
import {
|
|
12
|
+
validateMapToFieldRequiresField,
|
|
13
|
+
validateMandatoryReadOnlyHidden,
|
|
14
|
+
validateLookupSourceExclusivity,
|
|
15
|
+
validateReferenceQualifierExclusivity,
|
|
16
|
+
} from './service-catalog-diagnostics'
|
|
17
|
+
|
|
18
|
+
export async function buildVariableRecords(options: {
|
|
19
|
+
factory: Factory
|
|
20
|
+
diagnostics: Diagnostics
|
|
21
|
+
variablesConfig: ObjectShape
|
|
22
|
+
parent: Record
|
|
23
|
+
parentArg?: ObjectShape
|
|
24
|
+
}): Promise<Record[]> {
|
|
25
|
+
const { variablesConfig, factory, parent, diagnostics, parentArg } = options
|
|
26
|
+
const records: Record[] = []
|
|
27
|
+
let catItemRecord: Record
|
|
28
|
+
let variableSetRecord: Record
|
|
29
|
+
if (parent?.getTable() === 'sc_cat_item' || parent?.getTable() === 'sc_cat_item_producer') {
|
|
30
|
+
catItemRecord = parent
|
|
31
|
+
}
|
|
32
|
+
if (parent?.getTable() === 'item_option_new_set') {
|
|
33
|
+
variableSetRecord = parent
|
|
34
|
+
}
|
|
35
|
+
if (parent?.getTable() === 'sc_cat_item_producer' && parentArg) {
|
|
36
|
+
validateFieldNameBelongsToTable(parentArg, diagnostics, 'RecordProducer')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Convert entries to array to use for-of loop
|
|
40
|
+
const entries = Array.from(variablesConfig.entries())
|
|
41
|
+
|
|
42
|
+
// Use for-of loop with await instead of forEach
|
|
43
|
+
for (const [k, v] of entries) {
|
|
44
|
+
const callExpr = v.as(CallExpressionShape)
|
|
45
|
+
const calleeName = callExpr.getCallee()
|
|
46
|
+
const variable = callExpr.getArgument(0)
|
|
47
|
+
if (!variable.isObject() || !variable.asObject().isDefined()) {
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
50
|
+
const config = variable.asObject()
|
|
51
|
+
|
|
52
|
+
// Validate mapToField/field consistency (applies to all non-minimal variables)
|
|
53
|
+
if (
|
|
54
|
+
calleeName !== VariableTypeName.BREAK &&
|
|
55
|
+
calleeName !== VariableTypeName.CONTAINER_END &&
|
|
56
|
+
calleeName !== VariableTypeName.CONTAINER_SPLIT
|
|
57
|
+
) {
|
|
58
|
+
validateMapToFieldRequiresField(config, diagnostics)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Validate mandatory/readOnly/hidden consistency (applies to interactive variables)
|
|
62
|
+
if (
|
|
63
|
+
calleeName !== VariableTypeName.BREAK &&
|
|
64
|
+
calleeName !== VariableTypeName.CONTAINER_END &&
|
|
65
|
+
calleeName !== VariableTypeName.CONTAINER_SPLIT &&
|
|
66
|
+
calleeName !== VariableTypeName.CONTAINER_START &&
|
|
67
|
+
calleeName !== VariableTypeName.LABEL &&
|
|
68
|
+
calleeName !== VariableTypeName.RICH_TEXT_LABEL &&
|
|
69
|
+
calleeName !== VariableTypeName.CUSTOM &&
|
|
70
|
+
calleeName !== VariableTypeName.CUSTOM_WITH_LABEL &&
|
|
71
|
+
calleeName !== VariableTypeName.UI_PAGE
|
|
72
|
+
) {
|
|
73
|
+
validateMandatoryReadOnlyHidden(config, diagnostics)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Validate lookup source exclusivity (applies to lookup variables)
|
|
77
|
+
if (
|
|
78
|
+
calleeName === VariableTypeName.LOOKUP_SELECT_BOX ||
|
|
79
|
+
calleeName === VariableTypeName.LOOKUP_MULTIPLE_CHOICE
|
|
80
|
+
) {
|
|
81
|
+
validateLookupSourceExclusivity(config, diagnostics)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Validate reference qualifier exclusivity (applies to reference and requested-for variables)
|
|
85
|
+
if (calleeName === VariableTypeName.REFERENCE) {
|
|
86
|
+
validateReferenceQualifierExclusivity(config, diagnostics, 'ReferenceVariable')
|
|
87
|
+
}
|
|
88
|
+
if (calleeName === VariableTypeName.REQUESTED_FOR) {
|
|
89
|
+
validateReferenceQualifierExclusivity(config, diagnostics, 'RequestedForVariable')
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const useEncryption =
|
|
93
|
+
calleeName === VariableTypeName.MASKED ? (config.get('useEncryption')?.getValue() ?? true) : false
|
|
94
|
+
const varType = getVariableTypeFromName(calleeName)
|
|
95
|
+
|
|
96
|
+
const referenceTable =
|
|
97
|
+
calleeName === VariableTypeName.REQUESTED_FOR ? 'sys_user' : config.get('referenceTable')?.getValue()
|
|
98
|
+
|
|
99
|
+
const useReferenceQualifier =
|
|
100
|
+
calleeName === VariableTypeName.LIST_COLLECTOR ||
|
|
101
|
+
calleeName === VariableTypeName.LOOKUP_SELECT_BOX ||
|
|
102
|
+
calleeName === VariableTypeName.LOOKUP_MULTIPLE_CHOICE
|
|
103
|
+
? 'advanced'
|
|
104
|
+
: 'simple'
|
|
105
|
+
|
|
106
|
+
const props = callExpr
|
|
107
|
+
.getArgument(0)
|
|
108
|
+
.asObject()
|
|
109
|
+
.transform(({ $ }) => ({
|
|
110
|
+
name: $.val(k),
|
|
111
|
+
type: $.val(varType).def(6),
|
|
112
|
+
question_text: $.from('question').def(''),
|
|
113
|
+
order: $.def(0),
|
|
114
|
+
active: $.from('active').toBoolean().def(true),
|
|
115
|
+
mandatory: $.from('mandatory').toBoolean().def(false),
|
|
116
|
+
read_only: $.from('readOnly').toBoolean().def(false),
|
|
117
|
+
hidden: $.from('hidden').toBoolean().def(false),
|
|
118
|
+
disable_initial_slot_fill: $.from('disableInitialSlotFill').toBoolean().def(false),
|
|
119
|
+
conversational_label: $.from('conversationalLabel').def(''),
|
|
120
|
+
layout: $.from('layout').def('normal'),
|
|
121
|
+
tooltip: $.from('tooltip').def(''),
|
|
122
|
+
example_text: $.from('exampleText').def(''),
|
|
123
|
+
show_help: $.from('showHelp').toBoolean().def(false),
|
|
124
|
+
help_tag: $.from('helpTag').def('More information'),
|
|
125
|
+
help_text: $.from('helpText').def(''),
|
|
126
|
+
instructions: $.from('instructions').def('').toCdata(),
|
|
127
|
+
variable_width: $.from('width').def(''),
|
|
128
|
+
attributes: $.from('attributes').def(''),
|
|
129
|
+
default_value: $.from('defaultValue').def(''),
|
|
130
|
+
read_roles: $.from('readRoles').map(convertRolesToString).def([]),
|
|
131
|
+
write_roles: $.from('writeRoles').map(convertRolesToString).def([]),
|
|
132
|
+
create_roles: $.from('createRoles').map(convertRolesToString).def([]),
|
|
133
|
+
delete_roles: $.from('deleteRoles').map(convertRolesToString).def([]),
|
|
134
|
+
cat_item: $.val(catItemRecord).def(''),
|
|
135
|
+
variable_set: $.val(variableSetRecord).def(''),
|
|
136
|
+
reference: $.val(referenceTable).def(''),
|
|
137
|
+
visible_standalone: $.from('visibleStandalone').toBoolean().def(true),
|
|
138
|
+
visible_summary: $.from('visibleSummary').toBoolean().def(true),
|
|
139
|
+
visible_guide: $.from('visibleGuide').toBoolean().def(true),
|
|
140
|
+
visible_bundle: $.from('visibleBundle').toBoolean().def(true),
|
|
141
|
+
not_available_conversation: $.from('removeFromConversationalInterfaces').toBoolean().def(false),
|
|
142
|
+
display_title: $.from('displayTitle').toBoolean().def(false),
|
|
143
|
+
macro: $.from('macro').def(''),
|
|
144
|
+
summary_macro: $.from('summaryMacro').def(''),
|
|
145
|
+
sp_widget: $.from('widget').def(''),
|
|
146
|
+
macroponent: $.from('macroponent').def(''),
|
|
147
|
+
topic_block: $.from('topicBlock').def(''),
|
|
148
|
+
list_table: $.from('listTable').def(''),
|
|
149
|
+
reference_qual: $.from('referenceQual').def(''),
|
|
150
|
+
lookup_source: $.from('lookupSource').def(''),
|
|
151
|
+
lookup_table: $.from('lookupFromTable').def(''),
|
|
152
|
+
lookup_value: $.from('lookupValueField').def(''),
|
|
153
|
+
lookup_label: $.from('lookupLabelFields')
|
|
154
|
+
.def([])
|
|
155
|
+
.map((fields) => (Array.isArray(fields) ? fields.join(',') : fields))
|
|
156
|
+
.def(''),
|
|
157
|
+
lookup_price: $.from('lookupPriceField').def(''),
|
|
158
|
+
rec_lookup_price: $.from('lookupRecurringPriceField').def(''),
|
|
159
|
+
choice_table: $.from('choiceTable').def(''),
|
|
160
|
+
choice_field: $.from('choiceField').def(''),
|
|
161
|
+
lookup_dependent_question: $.from('choicesDependOn').def(''),
|
|
162
|
+
choice_direction: $.from('choiceDirection').def('down'),
|
|
163
|
+
include_none: $.from('includeNone').toBoolean().def(false),
|
|
164
|
+
lookup_unique: $.from('uniqueValuesOnly').toBoolean().def(false),
|
|
165
|
+
mask_use_confirmation: $.from('useConfirmation').toBoolean().def(false),
|
|
166
|
+
mask_use_encryption: $.val(useEncryption).toBoolean().def(false),
|
|
167
|
+
do_not_select_first: $.from('doNotSelectFirstChoice').toBoolean().def(false),
|
|
168
|
+
scale_min: $.from('scaleMin').def(0),
|
|
169
|
+
scale_max: $.from('scaleMax').def(5),
|
|
170
|
+
use_reference_qualifier: $.from('useReferenceQualifier').def(useReferenceQualifier),
|
|
171
|
+
reference_qual_condition: $.from('referenceQualCondition').def(''),
|
|
172
|
+
dynamic_ref_qual: $.from('dynamicRefQual').def(''),
|
|
173
|
+
enable_also_request_for: $.from('enableAlsoRequestFor').toBoolean().def(false),
|
|
174
|
+
rich_text: $.from('richText').toCdata().def(''),
|
|
175
|
+
validate_regex: $.from('validateRegex').def(''),
|
|
176
|
+
ui_page: $.from('uiPage').def(''),
|
|
177
|
+
default_html_value: $.from('defaultHTML').toCdata().def(''),
|
|
178
|
+
map_to_field: $.from('mapToField').toBoolean().def(false),
|
|
179
|
+
field: $.from('field').def(''),
|
|
180
|
+
delivery_plan: $.from('deliveryPlan').def(''),
|
|
181
|
+
visibility: $.from('visibility')
|
|
182
|
+
.map((v) => (v.isString() ? getVisibilityId(v.getValue()) : undefined))
|
|
183
|
+
.def(1),
|
|
184
|
+
roles_to_use_also_request_for: $.from('rolesToUseAlsoRequestFor').map(convertRolesToString).def([]),
|
|
185
|
+
category: $.from('category').def(''),
|
|
186
|
+
pricing_implications: $.from('pricingImplications').toBoolean().def(false),
|
|
187
|
+
show_help_on_load: $.from('alwaysExpand').toBoolean().def(false),
|
|
188
|
+
use_dynamic_default: $.from('useDynamicDefault').toBoolean().def(false),
|
|
189
|
+
// save_script: $.from('saveScript').toCdata().def(DEFAULT_SAVE_SCRIPT),
|
|
190
|
+
read_script: $.from('readScript').toCdata().def(''),
|
|
191
|
+
post_insert_script: $.from('postInsertScript').toCdata().def(''),
|
|
192
|
+
unique: $.def(false),
|
|
193
|
+
global: $.toBoolean().def(false),
|
|
194
|
+
description: $.toCdata().def(''),
|
|
195
|
+
dynamic_value_dot_walk_path: $.from('dotWalkPath').def(''),
|
|
196
|
+
dynamic_value_field: $.from('dependentQuestion').def(''),
|
|
197
|
+
}))
|
|
198
|
+
|
|
199
|
+
const varRecord = await factory.createRecord({
|
|
200
|
+
source: callExpr,
|
|
201
|
+
table: 'item_option_new',
|
|
202
|
+
properties: props,
|
|
203
|
+
})
|
|
204
|
+
const varPricingDetails = config.get('pricingDetails').ifArray()?.getElements() ?? []
|
|
205
|
+
const varPricingDetailsRecords: Record[] = []
|
|
206
|
+
for (const pricingDetail of varPricingDetails) {
|
|
207
|
+
const pricingDetailObj = pricingDetail.asObject()
|
|
208
|
+
varPricingDetailsRecords.push(
|
|
209
|
+
await factory.createRecord({
|
|
210
|
+
source: callExpr,
|
|
211
|
+
table: 'fx_price',
|
|
212
|
+
properties: {
|
|
213
|
+
id: varRecord.getId().getValue(),
|
|
214
|
+
field: pricingDetailObj.get('field').getValue(),
|
|
215
|
+
amount: pricingDetailObj.get('amount').getValue(),
|
|
216
|
+
currency: pricingDetailObj.get('currencyType').getValue(),
|
|
217
|
+
type: 'calculated',
|
|
218
|
+
table: 'item_option_new',
|
|
219
|
+
},
|
|
220
|
+
})
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
if (
|
|
224
|
+
(calleeName === VariableTypeName.MULTIPLE_CHOICE || calleeName === VariableTypeName.SELECT_BOX) &&
|
|
225
|
+
config.get('choices').isDefined()
|
|
226
|
+
) {
|
|
227
|
+
const choices = config.get('choices').asObject()
|
|
228
|
+
const entries = Array.from(choices.entries())
|
|
229
|
+
const choiceRecords: Record[] = []
|
|
230
|
+
|
|
231
|
+
// Use a regular for loop instead of forEach to handle async operations
|
|
232
|
+
for (const [key, value] of entries) {
|
|
233
|
+
const choiceObj = value.asObject()
|
|
234
|
+
const choiceProps = choiceObj.transform(({ $ }) => ({
|
|
235
|
+
value: $.val(key),
|
|
236
|
+
text: $.from('label').def(key),
|
|
237
|
+
inactive: $.from('inactive').toBoolean().def(false),
|
|
238
|
+
order: $.from('sequence').def(0),
|
|
239
|
+
question: $.val(varRecord).def(''),
|
|
240
|
+
}))
|
|
241
|
+
|
|
242
|
+
const choiceRecord = await factory.createRecord({
|
|
243
|
+
source: callExpr,
|
|
244
|
+
table: 'question_choice',
|
|
245
|
+
properties: choiceProps,
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
const pricingDetails = choiceObj.get('pricingDetails').ifArray()?.getElements() ?? []
|
|
249
|
+
const pricingDetailsRecords: Record[] = []
|
|
250
|
+
for (const pricingDetail of pricingDetails) {
|
|
251
|
+
const pricingDetailObj = pricingDetail.asObject()
|
|
252
|
+
pricingDetailsRecords.push(
|
|
253
|
+
await factory.createRecord({
|
|
254
|
+
source: callExpr,
|
|
255
|
+
table: 'fx_price',
|
|
256
|
+
properties: {
|
|
257
|
+
id: choiceRecord.getId().getValue(),
|
|
258
|
+
amount: pricingDetailObj.get('amount')?.getValue(),
|
|
259
|
+
currency: pricingDetailObj.get('currencyType')?.getValue(),
|
|
260
|
+
type: 'calculated',
|
|
261
|
+
field: pricingDetailObj.get('field')?.getValue(),
|
|
262
|
+
table: 'question_choice',
|
|
263
|
+
},
|
|
264
|
+
})
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
choiceRecords.push(choiceRecord.with(...pricingDetailsRecords))
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Now that all choiceRecords are created, add them to the varRecord
|
|
271
|
+
records.push(varRecord.with(...choiceRecords))
|
|
272
|
+
} else {
|
|
273
|
+
records.push(varRecord)
|
|
274
|
+
}
|
|
275
|
+
records.push(...varPricingDetailsRecords)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return records
|
|
279
|
+
}
|