@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,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildComplexObjectFromSchema = buildComplexObjectFromSchema;
|
|
4
|
+
exports.getAttributeValue = getAttributeValue;
|
|
5
|
+
exports.parseAttributesToObject = parseAttributesToObject;
|
|
6
|
+
// biome-ignore-all lint/suspicious/noExplicitAny: This file processes dynamic JSON schemas
|
|
7
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
8
|
+
const db_1 = require("@servicenow/sdk-core/runtime/db");
|
|
9
|
+
const flow_constants_1 = require("./flow-constants");
|
|
10
|
+
/**
|
|
11
|
+
* Reverse of `generateSchemaFromObject`.
|
|
12
|
+
* Takes the `serialized_content` field from a `sys_complex_object` record and
|
|
13
|
+
* rebuilds a `FlowObject(...)` call-expression shape that can be placed back in
|
|
14
|
+
* the Fluent source.
|
|
15
|
+
*/
|
|
16
|
+
// ------------------------------------------------------------
|
|
17
|
+
// Schema <-> Column API mappings (inverse of COLUMN_TYPE_TO_SCHEMA_TYPE)
|
|
18
|
+
// ------------------------------------------------------------
|
|
19
|
+
const SCHEMA_TYPE_TO_COLUMN_API = {
|
|
20
|
+
string: db_1.StringColumn.name,
|
|
21
|
+
integer: db_1.IntegerColumn.name,
|
|
22
|
+
number: db_1.DecimalColumn.name,
|
|
23
|
+
boolean: db_1.BooleanColumn.name,
|
|
24
|
+
date: db_1.DateTimeColumn.name,
|
|
25
|
+
glide_date_time: db_1.DateTimeColumn.name,
|
|
26
|
+
choice: db_1.ChoiceColumn.name,
|
|
27
|
+
reference: db_1.ReferenceColumn.name,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Build a `CallExpressionShape` for a simple (non-object) field given its
|
|
31
|
+
* schema primitive type and associated facets.
|
|
32
|
+
*/
|
|
33
|
+
function buildPrimitiveFieldCallExpr(fieldFacet, source) {
|
|
34
|
+
const childType = fieldFacet.get('childType').ifDefined()?.asString()?.getValue();
|
|
35
|
+
const schemaType = childType ?? fieldFacet.get('type')?.asString()?.getValue();
|
|
36
|
+
const callee = SCHEMA_TYPE_TO_COLUMN_API[schemaType] ?? db_1.StringColumn.name;
|
|
37
|
+
const additionalProps = {};
|
|
38
|
+
// Extract referenceTable for ReferenceColumn type
|
|
39
|
+
const referenceTable = fieldFacet.get('reference')?.ifString()?.getValue();
|
|
40
|
+
if (referenceTable && schemaType === 'reference') {
|
|
41
|
+
additionalProps['referenceTable'] = referenceTable;
|
|
42
|
+
}
|
|
43
|
+
const isChoiceColumn = callee === db_1.ChoiceColumn.name;
|
|
44
|
+
const isStringColumn = callee === db_1.StringColumn.name;
|
|
45
|
+
return new sdk_build_core_1.CallExpressionShape({
|
|
46
|
+
source,
|
|
47
|
+
callee,
|
|
48
|
+
args: [
|
|
49
|
+
fieldFacet
|
|
50
|
+
.transform(({ $ }) => ({
|
|
51
|
+
label: $.from('label', 'childLabel').map((label, child) => (child.isDefined() ? child : label)),
|
|
52
|
+
mandatory: $.toBoolean().def(false),
|
|
53
|
+
...(isStringColumn && {
|
|
54
|
+
maxLength: $.from('maxLength', 'childMaxLength')
|
|
55
|
+
.map((maxLength, child) => {
|
|
56
|
+
const value = child.isDefined() ? child : maxLength;
|
|
57
|
+
if (value.isString() && value.getValue() !== '') {
|
|
58
|
+
return value.toNumber().getValue();
|
|
59
|
+
}
|
|
60
|
+
return 0;
|
|
61
|
+
})
|
|
62
|
+
.def(0),
|
|
63
|
+
}),
|
|
64
|
+
default: $.from('defaultValue', 'childDefaultValue')
|
|
65
|
+
.map((defaultValue, childDefault) => (childDefault.isDefined() ? childDefault : defaultValue))
|
|
66
|
+
.def(''),
|
|
67
|
+
hint: $.from('hint', 'childHint')
|
|
68
|
+
.map((hint, childHint) => (childHint.isDefined() ? childHint : hint))
|
|
69
|
+
.def(''),
|
|
70
|
+
...(isChoiceColumn && {
|
|
71
|
+
choices: $.def({}),
|
|
72
|
+
dropdown: $.from('choiceOption')
|
|
73
|
+
.map((value) => {
|
|
74
|
+
const val = value.getValue();
|
|
75
|
+
if (value.if(sdk_build_core_1.UndefinedShape) ||
|
|
76
|
+
val === '' ||
|
|
77
|
+
value.toNumber().getValue() === flow_constants_1.ChoiceDropdown.DROPDOWN_WITH_NONE) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
return db_1.choiceDropdown[flow_constants_1.ChoiceDropdown.DROPDOWN_WITHOUT_NONE];
|
|
81
|
+
})
|
|
82
|
+
.def(db_1.choiceDropdown[flow_constants_1.ChoiceDropdown.DROPDOWN_WITH_NONE]),
|
|
83
|
+
}),
|
|
84
|
+
}))
|
|
85
|
+
.merge(additionalProps),
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Recursively converts the schema representation for a FlowArray into an
|
|
91
|
+
* `ObjectShape` that will be supplied as the first argument to a
|
|
92
|
+
* `FlowArray(...)` call-expression.
|
|
93
|
+
*/
|
|
94
|
+
function buildFlowArrayFromSchema(schemaContent, source, parentTypeFacet, complexObjectSysId, co_type_name) {
|
|
95
|
+
const rootContent = schemaContent['$COCollectionField'];
|
|
96
|
+
if (!rootContent) {
|
|
97
|
+
throw new Error('Invalid complex object schema: $COCollectionField not found');
|
|
98
|
+
}
|
|
99
|
+
let rootTypeFacet = parseTypeFacet(source, schemaContent, '$COCollectionField');
|
|
100
|
+
if (!rootTypeFacet) {
|
|
101
|
+
rootTypeFacet = parentTypeFacet;
|
|
102
|
+
}
|
|
103
|
+
const type = rootTypeFacet.get('type')?.asString()?.getValue();
|
|
104
|
+
let elementType;
|
|
105
|
+
if (type === 'array.object') {
|
|
106
|
+
const childKey = parentTypeFacet.get('childName')?.asString()?.getValue();
|
|
107
|
+
elementType = buildFlowObjectFromSchema(rootContent[0][childKey], source, rootTypeFacet);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
elementType = buildPrimitiveFieldCallExpr(parentTypeFacet, source);
|
|
111
|
+
}
|
|
112
|
+
return new sdk_build_core_1.CallExpressionShape({
|
|
113
|
+
source,
|
|
114
|
+
callee: 'FlowArray',
|
|
115
|
+
args: [
|
|
116
|
+
parentTypeFacet.transform(({ $ }) => ({
|
|
117
|
+
...(complexObjectSysId ? { $id: $.val(complexObjectSysId) } : {}),
|
|
118
|
+
...(co_type_name ? { co_type_name: $.val(co_type_name) } : {}),
|
|
119
|
+
elementType: $.val(elementType),
|
|
120
|
+
label: $.def(''),
|
|
121
|
+
mandatory: $.toBoolean().def(false),
|
|
122
|
+
hint: $.def(''),
|
|
123
|
+
maxRows: $.from('maxRows', 'max_rows')
|
|
124
|
+
.map((maxRows, max_rows) => {
|
|
125
|
+
const value = max_rows.isDefined() ? max_rows : maxRows;
|
|
126
|
+
if (value.isString() && value.getValue() !== '') {
|
|
127
|
+
return value.toNumber().getValue();
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
})
|
|
131
|
+
.def(undefined),
|
|
132
|
+
childName: $,
|
|
133
|
+
})),
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function buildNestedFlowArrayFromSchema(schemaContent, source, parentTypeFacet) {
|
|
138
|
+
const type = parentTypeFacet.get('type')?.asString()?.getValue();
|
|
139
|
+
let elementType;
|
|
140
|
+
if (type === 'array.object') {
|
|
141
|
+
// Unwrap the wrapper if present (used for nested array.object)
|
|
142
|
+
// ServiceNow stores nested array.object elements in two ways:
|
|
143
|
+
// 1. With $<num>_<fieldName> wrapper (e.g., $0_task)
|
|
144
|
+
// 2. With the field name itself as wrapper (e.g., tasks inside tasks array)
|
|
145
|
+
const keys = Object.keys(schemaContent);
|
|
146
|
+
const wrapperKey = keys.find((k) => /^\$\d+_/.test(k)) ?? keys.find((k) => !k.endsWith('.$field_facets'));
|
|
147
|
+
const innerContent = wrapperKey ? schemaContent[wrapperKey] : schemaContent;
|
|
148
|
+
elementType = buildFlowObjectFromSchema(innerContent, source, parentTypeFacet);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
elementType = buildPrimitiveFieldCallExpr(parentTypeFacet, source);
|
|
152
|
+
}
|
|
153
|
+
return new sdk_build_core_1.CallExpressionShape({
|
|
154
|
+
source,
|
|
155
|
+
callee: 'FlowArray',
|
|
156
|
+
args: [
|
|
157
|
+
parentTypeFacet.transform(({ $ }) => ({
|
|
158
|
+
elementType: $.val(elementType),
|
|
159
|
+
label: $.def(''),
|
|
160
|
+
mandatory: $.toBoolean().def(false),
|
|
161
|
+
hint: $.def(''),
|
|
162
|
+
maxRows: $.from('maxRows', 'max_rows')
|
|
163
|
+
.map((maxRows, max_rows) => {
|
|
164
|
+
const value = max_rows.isDefined() ? max_rows : maxRows;
|
|
165
|
+
if (value.isString() && value.getValue() !== '') {
|
|
166
|
+
return value.toNumber().getValue();
|
|
167
|
+
}
|
|
168
|
+
return undefined;
|
|
169
|
+
})
|
|
170
|
+
.def(undefined),
|
|
171
|
+
childName: $,
|
|
172
|
+
})),
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Recursively converts the schema representation for a FlowObject into an
|
|
178
|
+
* `ObjectShape` that will be supplied as the first argument to a
|
|
179
|
+
* `FlowObject(...)` call-expression.
|
|
180
|
+
*/
|
|
181
|
+
function buildFlowObjectFromSchema(schemaContent, source, parentTypeFacet, complexObjectSysId, co_type_name) {
|
|
182
|
+
const properties = {};
|
|
183
|
+
if (typeof schemaContent === 'object') {
|
|
184
|
+
for (const [key, value] of Object.entries(schemaContent)) {
|
|
185
|
+
// Skip facet keys – they belong to the previous field name.
|
|
186
|
+
if (key.endsWith('.$field_facets')) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const fieldFacet = parseFieldFacet(source, schemaContent, key);
|
|
190
|
+
if (!fieldFacet) {
|
|
191
|
+
throw new Error(`Invalid complex object schema: ${key} facet not found`);
|
|
192
|
+
}
|
|
193
|
+
if (typeof value === 'string') {
|
|
194
|
+
// Primitive field
|
|
195
|
+
properties[key] = buildPrimitiveFieldCallExpr(fieldFacet, source);
|
|
196
|
+
}
|
|
197
|
+
else if (typeof value === 'object' && value !== null) {
|
|
198
|
+
if (Array.isArray(value)) {
|
|
199
|
+
// Nested FlowArray
|
|
200
|
+
properties[key] = buildNestedFlowArrayFromSchema(value[0], source, fieldFacet);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// Nested FlowObject
|
|
204
|
+
properties[key] = buildFlowObjectFromSchema(value, source, fieldFacet);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return new sdk_build_core_1.CallExpressionShape({
|
|
210
|
+
source,
|
|
211
|
+
callee: 'FlowObject',
|
|
212
|
+
args: [
|
|
213
|
+
parentTypeFacet.transform(({ $ }) => ({
|
|
214
|
+
...(complexObjectSysId ? { $id: $.val(complexObjectSysId) } : {}),
|
|
215
|
+
...(co_type_name ? { co_type_name: $.val(co_type_name) } : {}),
|
|
216
|
+
fields: $.val(properties),
|
|
217
|
+
label: $.from('label', 'childLabel')
|
|
218
|
+
.map((label, child) => (child.isDefined() ? child : label))
|
|
219
|
+
.def(''),
|
|
220
|
+
mandatory: $.toBoolean().def(false),
|
|
221
|
+
})),
|
|
222
|
+
],
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Main entry ‑ convert `serialized_content` JSON → FlowObject or FlowArray call expression.
|
|
227
|
+
*
|
|
228
|
+
* @param schema Parsed `serialized_content`.
|
|
229
|
+
* @param source Optional source node to attach to created shapes.
|
|
230
|
+
* @param complexObjectSysId The sys_id of the sys_complex_object record (if available)
|
|
231
|
+
* @param co_type_name The name field from sys_complex_object
|
|
232
|
+
*/
|
|
233
|
+
function buildComplexObjectFromSchema(source, schema, attributes, complexObjectSysId, co_type_name) {
|
|
234
|
+
const { co_type_name: attrCoTypeName, uiType, ...rest } = attributes;
|
|
235
|
+
const rootKey = `FlowDesigner:${attrCoTypeName}`;
|
|
236
|
+
if (!rootKey) {
|
|
237
|
+
throw new Error(`Invalid complex object schema: ${attrCoTypeName} not found`);
|
|
238
|
+
}
|
|
239
|
+
const rootContent = schema[rootKey];
|
|
240
|
+
let rootTypeFacet = parseTypeFacet(source, schema, rootKey);
|
|
241
|
+
if (!rootTypeFacet) {
|
|
242
|
+
throw new Error('Invalid complex object schema: root type facet not found');
|
|
243
|
+
}
|
|
244
|
+
rootTypeFacet = rootTypeFacet.merge({
|
|
245
|
+
type: uiType,
|
|
246
|
+
...rest,
|
|
247
|
+
});
|
|
248
|
+
// Pass the explicit co_type_name parameter (undefined for deterministic, value for non-deterministic)
|
|
249
|
+
if (uiType.startsWith('array.')) {
|
|
250
|
+
return buildFlowArrayFromSchema(rootContent, source, rootTypeFacet, complexObjectSysId, co_type_name);
|
|
251
|
+
}
|
|
252
|
+
return buildFlowObjectFromSchema(rootContent, source, rootTypeFacet, complexObjectSysId, co_type_name);
|
|
253
|
+
}
|
|
254
|
+
function parseTypeFacet(source, schema, key) {
|
|
255
|
+
const facetKey = `${key}.$type_facets`;
|
|
256
|
+
return parseFacet(source, schema, facetKey);
|
|
257
|
+
}
|
|
258
|
+
function parseFieldFacet(source, schema, key) {
|
|
259
|
+
const facetKey = `${key}.$field_facets`;
|
|
260
|
+
return parseFacet(source, schema, facetKey);
|
|
261
|
+
}
|
|
262
|
+
function parseFacet(source, schema, facetKey) {
|
|
263
|
+
const facet = schema[facetKey]?.SimpleMapFacet;
|
|
264
|
+
if (!facet) {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
const choices = schema[facetKey]?.SimpleChoiceFacet;
|
|
268
|
+
try {
|
|
269
|
+
const parsed = JSON.parse(facet);
|
|
270
|
+
const parsedChoices = choices ? JSON.parse(choices)['choice_map_key$'] : {};
|
|
271
|
+
return new sdk_build_core_1.ObjectShape({
|
|
272
|
+
source,
|
|
273
|
+
properties: {
|
|
274
|
+
type: parsed['uiType'],
|
|
275
|
+
label: parsed['label'],
|
|
276
|
+
mandatory: parsed['mandatory'],
|
|
277
|
+
reference: parsed['reference'],
|
|
278
|
+
childName: parsed['child_name'],
|
|
279
|
+
childMaxLength: parsed['child_maxsize'],
|
|
280
|
+
childHint: parsed['child_hint'],
|
|
281
|
+
maxLength: parsed['max_length'],
|
|
282
|
+
maxRows: parsed['max_rows'],
|
|
283
|
+
childType: parsed['child_type'],
|
|
284
|
+
childLabel: parsed['child_label'],
|
|
285
|
+
choiceOption: parsed['choiceOption'],
|
|
286
|
+
defaultValue: parsed['default_value'],
|
|
287
|
+
childDefaultValue: parsed['child_defaultValue'],
|
|
288
|
+
hint: parsed['hint'],
|
|
289
|
+
choices: Object.keys(parsedChoices).reduce((acc, key) => {
|
|
290
|
+
const { label, value, order } = JSON.parse(parsedChoices[key]);
|
|
291
|
+
acc[value] = { label, sequence: order };
|
|
292
|
+
return acc;
|
|
293
|
+
}, {}),
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
// Failed to parse facet - returning undefined
|
|
299
|
+
}
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
function getAttributeValue(attributesStr, key) {
|
|
303
|
+
const attributes = parseAttributesToObject(attributesStr);
|
|
304
|
+
return attributes[key];
|
|
305
|
+
}
|
|
306
|
+
function parseAttributesToObject(attributesStr) {
|
|
307
|
+
return attributesStr
|
|
308
|
+
.split(',')
|
|
309
|
+
.map((p) => p.trim())
|
|
310
|
+
.reduce((acc, pair) => {
|
|
311
|
+
const [key, value] = pair.split('=');
|
|
312
|
+
if (key && value !== undefined) {
|
|
313
|
+
acc[key] = value;
|
|
314
|
+
}
|
|
315
|
+
return acc;
|
|
316
|
+
}, {});
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=schema-to-flow-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-to-flow-object.js","sourceRoot":"","sources":["../../../src/flow/utils/schema-to-flow-object.ts"],"names":[],"mappings":";;AA+QA,oEA4BC;AA2DD,8CAGC;AAYD,0DAWC;AAhYD,2FAA2F;AAC3F,+DAKmC;AACnC,wDASwC;AACxC,qDAAiD;AAEjD;;;;;GAKG;AAEH,+DAA+D;AAC/D,yEAAyE;AACzE,+DAA+D;AAC/D,MAAM,yBAAyB,GAA2B;IACtD,MAAM,EAAE,iBAAY,CAAC,IAAI;IACzB,OAAO,EAAE,kBAAa,CAAC,IAAI;IAC3B,MAAM,EAAE,kBAAa,CAAC,IAAI;IAC1B,OAAO,EAAE,kBAAa,CAAC,IAAI;IAC3B,IAAI,EAAE,mBAAc,CAAC,IAAI;IACzB,eAAe,EAAE,mBAAc,CAAC,IAAI;IACpC,MAAM,EAAE,iBAAY,CAAC,IAAI;IACzB,SAAS,EAAE,oBAAe,CAAC,IAAI;CAClC,CAAA;AAED;;;GAGG;AACH,SAAS,2BAA2B,CAAC,UAAuB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AAE,IAAI,EAAE,EAAE;QAClB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACpC,IAAI,GAAG,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,GAAG,CAAC,GAAyB,CAAC,GAAG,KAAK,CAAA;QAC1C,CAAC;QACD,OAAO,GAAG,CAAA;IACd,CAAC,EAAE,EAAkB,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Database, Record, Shape, Source } from '@servicenow/sdk-build-core';
|
|
2
|
+
import { ArrayShape, PropertyAccessShape, TemplateExpressionShape } from '@servicenow/sdk-build-core';
|
|
3
|
+
/**
|
|
4
|
+
* Service Catalog Utility Functions
|
|
5
|
+
*
|
|
6
|
+
* This module contains utilities for transforming catalog item and catalog variable
|
|
7
|
+
* data between XML and Fluent formats, including:
|
|
8
|
+
* - Checking if an action is catalog-related
|
|
9
|
+
* - Finding catalog items by sys_id
|
|
10
|
+
* - Creating template expressions for catalog item references
|
|
11
|
+
* - Converting slushbucket format to catalog variable arrays
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Check if an action definition is a catalog-related action (getCatalogVariables or createCatalogTask).
|
|
15
|
+
* @param actionDefinition - The action definition shape
|
|
16
|
+
* @returns true if the action is getCatalogVariables or createCatalogTask, false otherwise
|
|
17
|
+
*/
|
|
18
|
+
export declare function isCatalogAction(actionDefinition: Shape | undefined): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to find catalog item record by sys_id from database.
|
|
21
|
+
* @param sysId - The sys_id of the catalog item (must be 32 characters)
|
|
22
|
+
* @param database - Database instance to query
|
|
23
|
+
* @returns Catalog item record or undefined if not found
|
|
24
|
+
*/
|
|
25
|
+
export declare function findCatalogItemBySysId(sysId: string | undefined, database: Database | undefined): Record | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Helper function to create a template expression from an identifier.
|
|
28
|
+
* Creates: `${identifierName}`
|
|
29
|
+
*/
|
|
30
|
+
export declare function createTemplateExpressionFromIdentifier(identifierName: string, source: Source): TemplateExpressionShape;
|
|
31
|
+
/**
|
|
32
|
+
* Helper function to create a PropertyAccessShape for a catalog variable reference.
|
|
33
|
+
* Creates: catalogItemIdentifierName.variables.varName
|
|
34
|
+
*/
|
|
35
|
+
export declare function createCatalogVariablePropertyAccess(catalogItemRecord: Record, catalogItemIdentifierName: string, varName: string, source: Source): PropertyAccessShape;
|
|
36
|
+
/**
|
|
37
|
+
* Convert slushbucket format (comma-separated sys_id:name pairs) to an array of catalog variable references.
|
|
38
|
+
* Example: "abc123:email,def456:html" → [catalogItem.variables.email, catalogItem.variables.html]
|
|
39
|
+
*
|
|
40
|
+
* @param slushBucketValue - Slushbucket string from XML
|
|
41
|
+
* @param catalogItemRecord - Catalog item record to look up variables
|
|
42
|
+
* @param source - Source for creating shapes
|
|
43
|
+
* @param actionInstanceUUID - UUID of the action instance (for label_cache lookup)
|
|
44
|
+
* @param flowRecord - Flow record containing label_cache
|
|
45
|
+
* @returns ArrayShape of PropertyAccessShape elements or undefined if conversion fails
|
|
46
|
+
*/
|
|
47
|
+
export declare function convertSlushBucketToCatalogVariableArray(slushBucketValue: string, catalogItemRecord: Record | undefined, source: Source): ArrayShape | undefined;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCatalogAction = isCatalogAction;
|
|
4
|
+
exports.findCatalogItemBySysId = findCatalogItemBySysId;
|
|
5
|
+
exports.createTemplateExpressionFromIdentifier = createTemplateExpressionFromIdentifier;
|
|
6
|
+
exports.createCatalogVariablePropertyAccess = createCatalogVariablePropertyAccess;
|
|
7
|
+
exports.convertSlushBucketToCatalogVariableArray = convertSlushBucketToCatalogVariableArray;
|
|
8
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
const flow_constants_1 = require("./flow-constants");
|
|
11
|
+
/**
|
|
12
|
+
* Service Catalog Utility Functions
|
|
13
|
+
*
|
|
14
|
+
* This module contains utilities for transforming catalog item and catalog variable
|
|
15
|
+
* data between XML and Fluent formats, including:
|
|
16
|
+
* - Checking if an action is catalog-related
|
|
17
|
+
* - Finding catalog items by sys_id
|
|
18
|
+
* - Creating template expressions for catalog item references
|
|
19
|
+
* - Converting slushbucket format to catalog variable arrays
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Check if an action definition is a catalog-related action (getCatalogVariables or createCatalogTask).
|
|
23
|
+
* @param actionDefinition - The action definition shape
|
|
24
|
+
* @returns true if the action is getCatalogVariables or createCatalogTask, false otherwise
|
|
25
|
+
*/
|
|
26
|
+
function isCatalogAction(actionDefinition) {
|
|
27
|
+
const actionName = flow_constants_1.CORE_ACTIONS_SYS_ID_NAME_MAP[actionDefinition?.getValue()];
|
|
28
|
+
return actionName ? flow_constants_1.CATALOG_VARIABLE_ACTIONS.includes(actionName) : false;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to find catalog item record by sys_id from database.
|
|
32
|
+
* @param sysId - The sys_id of the catalog item (must be 32 characters)
|
|
33
|
+
* @param database - Database instance to query
|
|
34
|
+
* @returns Catalog item record or undefined if not found
|
|
35
|
+
*/
|
|
36
|
+
function findCatalogItemBySysId(sysId, database) {
|
|
37
|
+
if (!database || !sysId || !(0, sdk_build_core_1.isGUID)(sysId)) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return database.get(flow_constants_1.CATALOG_ITEM_TABLE, sysId);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Helper function to create a template expression from an identifier.
|
|
44
|
+
* Creates: `${identifierName}`
|
|
45
|
+
*/
|
|
46
|
+
function createTemplateExpressionFromIdentifier(identifierName, source) {
|
|
47
|
+
return new sdk_build_core_1.TemplateExpressionShape({
|
|
48
|
+
source,
|
|
49
|
+
literalText: '',
|
|
50
|
+
spans: [
|
|
51
|
+
new sdk_build_core_1.TemplateSpanShape({
|
|
52
|
+
source,
|
|
53
|
+
expression: new sdk_build_core_1.IdentifierShape({ source, name: identifierName }),
|
|
54
|
+
literalText: '',
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Helper function to create a PropertyAccessShape for a catalog variable reference.
|
|
61
|
+
* Creates: catalogItemIdentifierName.variables.varName
|
|
62
|
+
*/
|
|
63
|
+
function createCatalogVariablePropertyAccess(catalogItemRecord, catalogItemIdentifierName, varName, source) {
|
|
64
|
+
const catalogItemIdentifier = new sdk_build_core_1.IdentifierShape({
|
|
65
|
+
source: catalogItemRecord.getOriginalNode() || source,
|
|
66
|
+
name: catalogItemIdentifierName,
|
|
67
|
+
value: catalogItemRecord,
|
|
68
|
+
});
|
|
69
|
+
const variablesIdentifier = new sdk_build_core_1.IdentifierShape({
|
|
70
|
+
source,
|
|
71
|
+
name: 'variables',
|
|
72
|
+
});
|
|
73
|
+
const varNameIdentifier = new sdk_build_core_1.IdentifierShape({
|
|
74
|
+
source,
|
|
75
|
+
name: varName,
|
|
76
|
+
});
|
|
77
|
+
return new sdk_build_core_1.PropertyAccessShape({
|
|
78
|
+
source,
|
|
79
|
+
elements: [catalogItemIdentifier, variablesIdentifier, varNameIdentifier],
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Convert slushbucket format (comma-separated sys_id:name pairs) to an array of catalog variable references.
|
|
84
|
+
* Example: "abc123:email,def456:html" → [catalogItem.variables.email, catalogItem.variables.html]
|
|
85
|
+
*
|
|
86
|
+
* @param slushBucketValue - Slushbucket string from XML
|
|
87
|
+
* @param catalogItemRecord - Catalog item record to look up variables
|
|
88
|
+
* @param source - Source for creating shapes
|
|
89
|
+
* @param actionInstanceUUID - UUID of the action instance (for label_cache lookup)
|
|
90
|
+
* @param flowRecord - Flow record containing label_cache
|
|
91
|
+
* @returns ArrayShape of PropertyAccessShape elements or undefined if conversion fails
|
|
92
|
+
*/
|
|
93
|
+
function convertSlushBucketToCatalogVariableArray(slushBucketValue, catalogItemRecord, source) {
|
|
94
|
+
if (!catalogItemRecord) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
const variableShapes = [];
|
|
98
|
+
const catalogItemIdentifierName = (0, utils_1.getIdentifierFromRecord)(catalogItemRecord) || 'catalogItem';
|
|
99
|
+
//use slushbucket sys_ids to look up variable names
|
|
100
|
+
if (!slushBucketValue || !slushBucketValue.trim()) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const entries = slushBucketValue
|
|
104
|
+
.split(',')
|
|
105
|
+
.map((entry) => entry.trim())
|
|
106
|
+
.filter(Boolean);
|
|
107
|
+
// Build a map of sysId → record by iterating allRecords once
|
|
108
|
+
const variableRecordBySysId = new Map();
|
|
109
|
+
for (const rec of catalogItemRecord.flat()) {
|
|
110
|
+
if (rec.getTable() === flow_constants_1.CATALOG_VARIABLE_TABLE) {
|
|
111
|
+
variableRecordBySysId.set(rec.getId().getValue(), rec);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (const entry of entries) {
|
|
115
|
+
const [sysId] = entry.split(':');
|
|
116
|
+
if (!sysId || !sysId.trim()) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const variableRecord = variableRecordBySysId.get(sysId);
|
|
120
|
+
if (variableRecord) {
|
|
121
|
+
const varName = variableRecord.get('name')?.asString()?.getValue();
|
|
122
|
+
if (varName) {
|
|
123
|
+
// Create PropertyAccessShape: catalogItemIdentifierName.variables.varName
|
|
124
|
+
const propertyAccess = createCatalogVariablePropertyAccess(catalogItemRecord, catalogItemIdentifierName, varName, source);
|
|
125
|
+
variableShapes.push(propertyAccess);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (variableShapes.length === 0) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
return new sdk_build_core_1.ArrayShape({
|
|
133
|
+
source,
|
|
134
|
+
elements: variableShapes,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=service-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-catalog.js","sourceRoot":"","sources":["../../../src/flow/utils/service-catalog.ts"],"names":[],"mappings":";;AAiCA,0CAGC;AAQD,wDAKC;AAMD,wFAeC;AAMD,kFAwBC;AAaD,4FA4DC;AA5KD,+DAOmC;AACnC,mCAAiD;AACjD,qDAKyB;AAEzB;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,SAAgB,eAAe,CAAC,gBAAmC;IAC/D,MAAM,UAAU,GAAG,6CAA4B,CAAC,gBAAgB,EAAE,QAAQ,EAAY,CAAC,CAAA;IACvF,OAAO,UAAU,CAAC,CAAC,CAAC,yCAAwB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAC7E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,KAAyB,EAAE,QAA8B;IAC5F,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,IAAA,uBAAM,EAAC,KAAK,CAAC,EAAE,CAAC;QACxC,OAAO,SAAS,CAAA;IACpB,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,mCAAkB,EAAE,KAAK,CAAC,CAAA;AAClD,CAAC;AAED;;;GAGG;AACH,SAAgB,sCAAsC,CAClD,cAAsB,EACtB,MAAc;IAEd,OAAO,IAAI,wCAAuB,CAAC;QAC/B,MAAM;QACN,WAAW,EAAE,EAAE;QACf,KAAK,EAAE;YACH,IAAI,kCAAiB,CAAC;gBAClB,MAAM;gBACN,UAAU,EAAE,IAAI,gCAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;g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pressionShape, type Database, type Diagnostics, type IdentifierShape, type Logger, type ObjectShape, type PropertyAccessShape, type Record, type Shape, type TemplateExpressionShape, type Transform, ts } from '@servicenow/sdk-build-core';
|
|
2
|
+
import { PillShape } from '../utils/data-pill-shapes';
|
|
3
|
+
export declare function sysIdToUuid(id: string): string;
|
|
4
|
+
export declare function uuidToSysId(id: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Get the identifier name from an original source (TypeScript node)
|
|
7
|
+
* Searches for a VariableDeclaration ancestor and extracts the identifier name
|
|
8
|
+
*
|
|
9
|
+
* @param originalSource - The original TypeScript source node
|
|
10
|
+
* @returns The identifier name if found, undefined otherwise
|
|
11
|
+
*/
|
|
12
|
+
export declare function getIdentifierFromSource(originalSource: unknown): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Get the identifier name for an action/subflow instance from its original source
|
|
15
|
+
* Only checks if this node is DIRECTLY wrapped in a VariableDeclaration (not any ancestor)
|
|
16
|
+
* This prevents scope collisions where inner actions inherit parent Subflow/Flow variable names
|
|
17
|
+
*
|
|
18
|
+
* Use this specifically for preserving action/subflow variable names during transform
|
|
19
|
+
*
|
|
20
|
+
* @param originalSource - The original source to extract the identifier from
|
|
21
|
+
* @returns The identifier name if found, undefined otherwise
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDirectVariableIdentifier(originalSource: unknown): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Get the identifier name from a record's original source
|
|
26
|
+
* Convenience wrapper around getIdentifierFromSource for Record types
|
|
27
|
+
*
|
|
28
|
+
* @param record - The record to extract the identifier from
|
|
29
|
+
* @returns The identifier name if found, undefined otherwise
|
|
30
|
+
*/
|
|
31
|
+
export declare function getIdentifierFromRecord(record: Record): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Get the identifier name from a shape's original source
|
|
34
|
+
* Convenience wrapper around getIdentifierFromSource for Shape types
|
|
35
|
+
*
|
|
36
|
+
* @param shape - The shape to extract the identifier from
|
|
37
|
+
* @returns The identifier name if found, undefined otherwise
|
|
38
|
+
*/
|
|
39
|
+
export declare function getIdentifierFromShape(shape: Shape): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Set of allowed FlowValueType helper function names for flow variable validation
|
|
42
|
+
*
|
|
43
|
+
* @constant {Set<string>}
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // Supported types: StringColumn, IntegerColumn, DecimalColumn, ReferenceColumn,
|
|
47
|
+
* // DateTimeColumn, BooleanColumn, GenericColumn, FlowObject, FlowArray
|
|
48
|
+
* if (ALLOWED_VARIABLE_CALLEES.has('StringColumn')) {
|
|
49
|
+
* // StringColumn is supported
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare const ALLOWED_VARIABLE_CALLEES: Set<string>;
|
|
54
|
+
export declare const ALLOWED_VARIABLE_CALLEES_IN_FLOW_OBJECT: Set<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Validates a single flow variable call expression for type safety and correctness
|
|
57
|
+
*
|
|
58
|
+
* @param variableCall - The CallExpressionShape representing the variable definition
|
|
59
|
+
* @param path - The path/name of the variable for error reporting
|
|
60
|
+
* @param diagnostics - Diagnostics object for reporting validation errors
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // Validates allowed types, GenericColumn columnType (json/float only),
|
|
65
|
+
* // and recursively validates FlowArray/FlowObject structures
|
|
66
|
+
* validateFlowVariableCall(StringColumn({ label: 'Name' }), 'flow_variables.userName', diagnostics)
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function validateFlowVariableCall(variableCall: CallExpressionShape, path: string, diagnostics: Diagnostics): void;
|
|
70
|
+
/**
|
|
71
|
+
* Recursively validates FlowObject fields for nested FlowArray violations and other type validations
|
|
72
|
+
*
|
|
73
|
+
* @param flowObjectCall - The CallExpressionShape representing the FlowObject definition
|
|
74
|
+
* @param path - The path/name of the variable for error reporting
|
|
75
|
+
* @param diagnostics - Diagnostics object for reporting validation errors
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Validates all field types are allowed, recursively validates nested
|
|
80
|
+
* // FlowArray/FlowObject structures, and checks GenericColumn columnType
|
|
81
|
+
* FlowObject({ fields: { name: StringColumn({...}), data: FlowArray({...}) } })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function validateFlowObjectFields(flowObjectCall: CallExpressionShape, path: string, diagnostics: Diagnostics): void;
|
|
85
|
+
/**
|
|
86
|
+
* Recursively searches ancestors of a node to find a CallExpression
|
|
87
|
+
* with any of the given callee names.
|
|
88
|
+
*
|
|
89
|
+
* @param node - The starting node
|
|
90
|
+
* @param calleeNames - One or more function names to match against
|
|
91
|
+
* @returns The CallExpression if found, otherwise undefined
|
|
92
|
+
*/
|
|
93
|
+
export declare function findAncestorByCalleeName(node: ts.Node | undefined, ...calleeNames: string[]): ts.CallExpression | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Resolves a data pill shape by transforming it and handling trigger pills
|
|
96
|
+
* @param shape - The shape to resolve (PropertyAccessShape, TemplateExpressionShape, or IdentifierShape)
|
|
97
|
+
* @param transform - The transform instance
|
|
98
|
+
* @returns The resolved value or the original shape value if not a data pill
|
|
99
|
+
*/
|
|
100
|
+
export declare function resolveDataPillShape(shape: PillShape | PropertyAccessShape | TemplateExpressionShape | IdentifierShape, transform: Transform): Promise<unknown>;
|
|
101
|
+
/**
|
|
102
|
+
* Function to get the record by transforming the FDInstanceShape
|
|
103
|
+
* @param shape - The shape to transform (VariableStatementShape, CallExpressionShape)
|
|
104
|
+
* @param transform - The transform instance
|
|
105
|
+
* @returns The instance record of the FDInstanceShape
|
|
106
|
+
*/
|
|
107
|
+
export declare function getRecordFromFlowInstaceShape(shape: Shape, transform: Transform): Promise<Record | undefined>;
|
|
108
|
+
export declare function checkForUnsupportedFlowDescendants(descendants: Database, record: Record, logger: Logger): boolean;
|
|
109
|
+
export declare const getCoreActionIdentifier: (sysId: string) => string | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Extracts the order value from a record for sorting purposes.
|
|
112
|
+
* Converts the 'order' field to a number, defaulting to 0 if not present or invalid.
|
|
113
|
+
*
|
|
114
|
+
* @param record - The record containing the order field
|
|
115
|
+
* @returns The numeric order value
|
|
116
|
+
*/
|
|
117
|
+
export declare function getOrder(x: ObjectShape): number;
|