@servicenow/sdk-build-plugins 4.1.1 → 4.3.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 +22 -4
- 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/application-menu-plugin.js +1 -0
- package/dist/application-menu-plugin.js.map +1 -1
- package/dist/atf/step-configs.d.ts +13 -12
- package/dist/atf/step-configs.js.map +1 -1
- package/dist/atf/test-plugin.d.ts +1 -1
- package/dist/atf/test-plugin.js +13 -7
- package/dist/atf/test-plugin.js.map +1 -1
- package/dist/basic-syntax-plugin.js +58 -14
- 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/claims-plugin.js +1 -1
- package/dist/claims-plugin.js.map +1 -1
- package/dist/client-script-plugin.js +5 -17
- package/dist/client-script-plugin.js.map +1 -1
- package/dist/column/column-helper.d.ts +1 -1
- package/dist/column/column-helper.js +46 -2
- package/dist/column/column-helper.js.map +1 -1
- package/dist/column/column-to-record.js +6 -4
- package/dist/column/column-to-record.js.map +1 -1
- package/dist/column-plugin.js +107 -28
- 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 +6 -0
- package/dist/data-plugin.js +156 -0
- package/dist/data-plugin.js.map +1 -0
- 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 +930 -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 +324 -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 +65 -0
- package/dist/flow/utils/flow-constants.js +223 -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/utils.d.ts +117 -0
- package/dist/flow/utils/utils.js +345 -0
- package/dist/flow/utils/utils.js.map +1 -0
- package/dist/import-sets-plugin.d.ts +2 -0
- package/dist/import-sets-plugin.js +412 -0
- package/dist/import-sets-plugin.js.map +1 -0
- package/dist/index.d.ts +24 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/dist/json-plugin.d.ts +4 -4
- package/dist/json-plugin.js +21 -7
- package/dist/json-plugin.js.map +1 -1
- package/dist/list-plugin.js +83 -1
- package/dist/list-plugin.js.map +1 -1
- package/dist/now-attach-plugin.d.ts +36 -0
- package/dist/now-attach-plugin.js +320 -0
- package/dist/now-attach-plugin.js.map +1 -0
- package/dist/now-config-plugin.js +3 -0
- package/dist/now-config-plugin.js.map +1 -1
- package/dist/now-include-plugin.js +7 -1
- package/dist/now-include-plugin.js.map +1 -1
- package/dist/package-json-plugin.js +2 -2
- package/dist/package-json-plugin.js.map +1 -1
- package/dist/record-plugin.d.ts +35 -0
- package/dist/record-plugin.js +109 -23
- 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/repack/lint/Rules.js.map +1 -1
- package/dist/rest-api-plugin.js +81 -74
- package/dist/rest-api-plugin.js.map +1 -1
- package/dist/role-plugin.js +1 -0
- package/dist/role-plugin.js.map +1 -1
- package/dist/server-module-plugin/index.js +53 -6
- 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 +139 -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 +169 -0
- package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -0
- package/dist/service-catalog/shape-to-record.d.ts +7 -0
- package/dist/service-catalog/shape-to-record.js +232 -0
- package/dist/service-catalog/shape-to-record.js.map +1 -0
- package/dist/service-catalog/utils.d.ts +313 -0
- package/dist/service-catalog/utils.js +1144 -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/service-portal/widget-plugin.js +4 -1
- package/dist/service-portal/widget-plugin.js.map +1 -1
- 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.d.ts +1 -0
- package/dist/static-content-plugin.js +4 -3
- package/dist/static-content-plugin.js.map +1 -1
- package/dist/table-plugin.js +49 -4
- package/dist/table-plugin.js.map +1 -1
- package/dist/ui-page-plugin.js +2 -1
- package/dist/ui-page-plugin.js.map +1 -1
- package/dist/ui-policy-plugin.d.ts +2 -0
- package/dist/ui-policy-plugin.js +405 -0
- package/dist/ui-policy-plugin.js.map +1 -0
- package/dist/utils.d.ts +19 -1
- package/dist/utils.js +40 -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/view-plugin.js +1 -1
- package/dist/view-plugin.js.map +1 -1
- 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/_types/eslint-plugin-es-x.d.ts +17 -0
- package/src/_types/md5.js.d.ts +8 -0
- package/src/acl-plugin.ts +33 -10
- package/src/applicability-plugin.ts +82 -0
- package/src/application-menu-plugin.ts +1 -0
- package/src/atf/step-configs.ts +14 -12
- package/src/atf/test-plugin.ts +46 -24
- package/src/basic-syntax-plugin.ts +71 -14
- package/src/business-rule-plugin.ts +9 -5
- package/src/call-expression-plugin.ts +2 -130
- package/src/claims-plugin.ts +1 -1
- package/src/client-script-plugin.ts +8 -22
- package/src/column/column-helper.ts +65 -3
- package/src/column/column-to-record.ts +6 -4
- package/src/column-plugin.ts +142 -40
- 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 +194 -0
- 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 +1148 -0
- package/src/flow/plugins/flow-trigger-instance-plugin.ts +426 -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 +276 -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/utils.ts +395 -0
- package/src/import-sets-plugin.ts +542 -0
- package/src/index.ts +25 -1
- package/src/json-plugin.ts +31 -12
- package/src/list-plugin.ts +91 -1
- package/src/now-attach-plugin.ts +403 -0
- package/src/now-config-plugin.ts +6 -2
- package/src/now-include-plugin.ts +8 -1
- package/src/package-json-plugin.ts +3 -3
- package/src/record-plugin.ts +126 -30
- package/src/repack/index.ts +14 -0
- package/src/repack/lint/Rules.ts +1 -10
- package/src/rest-api-plugin.ts +106 -100
- package/src/role-plugin.ts +1 -0
- package/src/server-module-plugin/index.ts +74 -22
- 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 +251 -0
- package/src/service-catalog/shape-to-record.ts +275 -0
- package/src/service-catalog/utils.ts +1362 -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/service-portal/widget-plugin.ts +4 -1
- package/src/sla/sla-validators.ts +331 -0
- package/src/sla-plugin.ts +358 -0
- package/src/static-content-plugin.ts +2 -2
- package/src/table-plugin.ts +66 -9
- package/src/ui-page-plugin.ts +2 -1
- package/src/ui-policy-plugin.ts +505 -0
- package/src/utils.ts +50 -1
- package/src/ux-list-menu-config-plugin.ts +312 -0
- package/src/view-plugin.ts +1 -1
- 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,542 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CallExpressionShape,
|
|
3
|
+
Plugin,
|
|
4
|
+
type Record,
|
|
5
|
+
type ObjectShape,
|
|
6
|
+
type Shape,
|
|
7
|
+
type Transform,
|
|
8
|
+
} from '@servicenow/sdk-build-core'
|
|
9
|
+
import { NowIdShape } from './now-id-plugin'
|
|
10
|
+
import { ModuleFunctionShape } from './server-module-plugin'
|
|
11
|
+
import { NowIncludeShape } from './now-include-plugin'
|
|
12
|
+
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// CONSTANTS & CONFIGURATION
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
/** enforce_mandatory_fields: TypeScript → XML */
|
|
18
|
+
const ENFORCE_MANDATORY_TO_XML: { [k: string]: string } = {
|
|
19
|
+
onlyMappedFields: 'Only Mapped Fields',
|
|
20
|
+
allFields: 'All Fields',
|
|
21
|
+
no: 'No',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** enforce_mandatory_fields: XML → TypeScript */
|
|
25
|
+
const ENFORCE_MANDATORY_TO_TS: { [k: string]: string } = {
|
|
26
|
+
'Only Mapped Fields': 'onlyMappedFields',
|
|
27
|
+
'All Fields': 'allFields',
|
|
28
|
+
No: 'no',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Default script template for transform map scripts
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_TRANSFORM_MAP_SCRIPT =
|
|
35
|
+
'(function transformRow(source, target, map, log, isUpdate) {\n\n\t// Add your code here\n\n})(source, target, map, log, action==="update");'
|
|
36
|
+
/**
|
|
37
|
+
* Default script template for transform entry source scripts
|
|
38
|
+
*/
|
|
39
|
+
const DEFAULT_TRANSFORM_ENTRY_SCRIPT = `answer = (function transformEntry(source) {
|
|
40
|
+
|
|
41
|
+
// Add your code here
|
|
42
|
+
return ""; // return the value to be put into the target field
|
|
43
|
+
|
|
44
|
+
})(source);`
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Default script template for transform scripts
|
|
48
|
+
*/
|
|
49
|
+
const DEFAULT_TRANSFORM_SCRIPT = `(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
|
|
50
|
+
|
|
51
|
+
// Add your code here
|
|
52
|
+
|
|
53
|
+
})(source, map, log, target);`
|
|
54
|
+
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// HELPER FUNCTIONS
|
|
57
|
+
// ============================================================================
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Configuration for a transform entry field mapping
|
|
61
|
+
* This is the result of calling .properties() on a transformed shape
|
|
62
|
+
*/
|
|
63
|
+
type FieldConfiguration = { [key: string]: Shape<unknown> }
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Result of buildFieldConfig - partial field configuration with sourceField
|
|
67
|
+
*/
|
|
68
|
+
interface FieldConfigResult {
|
|
69
|
+
sourceField: string
|
|
70
|
+
coalesce?: boolean
|
|
71
|
+
coalesceCaseSensitive?: boolean
|
|
72
|
+
coalesceEmptyFields?: boolean
|
|
73
|
+
choiceAction?: string
|
|
74
|
+
sourceScript?: unknown // Can be string or NowIncludeShape for module references
|
|
75
|
+
useSourceScript?: boolean
|
|
76
|
+
dateFormat?: string
|
|
77
|
+
referenceValueField?: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Checks if a field configuration has any non-default properties
|
|
82
|
+
* @param config - The field configuration object with Shape values
|
|
83
|
+
* @returns true if any additional properties are set
|
|
84
|
+
*/
|
|
85
|
+
function hasAdditionalProperties(config: FieldConfiguration): boolean {
|
|
86
|
+
return !!(
|
|
87
|
+
config['coalesce']?.asBoolean()?.getValue() ||
|
|
88
|
+
config['coalesceCaseSensitive']?.asBoolean()?.getValue() ||
|
|
89
|
+
config['coalesceEmptyFields']?.asBoolean()?.getValue() ||
|
|
90
|
+
(config['choiceAction']?.asString()?.getValue() && config['choiceAction'].asString().getValue() !== '') ||
|
|
91
|
+
config['sourceScript']?.getValue() ||
|
|
92
|
+
config['useSourceScript']?.asBoolean()?.getValue() ||
|
|
93
|
+
config['dateFormat']?.asString()?.getValue() ||
|
|
94
|
+
config['referenceValueField']?.asString()?.getValue()
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Builds a field configuration object with only non-default properties
|
|
100
|
+
* @param sourceField - The source field name
|
|
101
|
+
* @param config - The complete field configuration with Shape values
|
|
102
|
+
* @returns A minimal field configuration object
|
|
103
|
+
*/
|
|
104
|
+
function buildFieldConfig(sourceField: string, config: FieldConfiguration): FieldConfigResult {
|
|
105
|
+
const fieldConfig = Object.entries(config)
|
|
106
|
+
.filter(([k, v]) => {
|
|
107
|
+
// Filter out properties that are undefined or have default values
|
|
108
|
+
if (!v || k === 'sourceField' || k === 'targetField') {
|
|
109
|
+
return false
|
|
110
|
+
}
|
|
111
|
+
const value = v.getValue?.()
|
|
112
|
+
return value !== undefined && value !== false && value !== ''
|
|
113
|
+
})
|
|
114
|
+
.reduce(
|
|
115
|
+
(acc, [k, v]) => {
|
|
116
|
+
// Extract raw value from Shape
|
|
117
|
+
acc[k] = v.getValue()
|
|
118
|
+
if (k === 'sourceScript') {
|
|
119
|
+
acc['useSourceScript'] = true
|
|
120
|
+
}
|
|
121
|
+
return acc
|
|
122
|
+
},
|
|
123
|
+
{ sourceField } as { [key: string]: unknown; sourceField: string }
|
|
124
|
+
) as FieldConfigResult
|
|
125
|
+
|
|
126
|
+
return fieldConfig
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Maps sys_transform_entry records to a fields object for the Fluent API
|
|
131
|
+
* Converts database records into a simplified object structure where:
|
|
132
|
+
* - Simple mappings: { targetField: "sourceField" }
|
|
133
|
+
* - Complex mappings: { targetField: { sourceField: "...", coalesce: true, ... } }
|
|
134
|
+
*
|
|
135
|
+
* @param entries - Array of sys_transform_entry records
|
|
136
|
+
* @param transform - Transform context for creating NowIncludeShape
|
|
137
|
+
* @returns Object mapping target fields to their configurations
|
|
138
|
+
*/
|
|
139
|
+
async function mapTransformEntriesToFields(
|
|
140
|
+
entries: Record[],
|
|
141
|
+
transform: Transform
|
|
142
|
+
): Promise<{ [key: string]: string | FieldConfigResult }> {
|
|
143
|
+
const fieldsObject: { [key: string]: string | FieldConfigResult } = {}
|
|
144
|
+
|
|
145
|
+
for (const entryRecord of entries) {
|
|
146
|
+
// Extract sourceScript using NowIncludeShape for module and Now.include support
|
|
147
|
+
const sourceScript = await NowIncludeShape.fromRecord(entryRecord, entryRecord.get('source_script'), transform)
|
|
148
|
+
|
|
149
|
+
const entry = entryRecord.transform(({ $ }) => ({
|
|
150
|
+
// $id: $.val(NowIdShape.from(entryRecord)),
|
|
151
|
+
sourceField: $.from('source_field').def(''),
|
|
152
|
+
targetField: $.from('target_field').def(''),
|
|
153
|
+
coalesce: $.from('coalesce').toBoolean().def(false),
|
|
154
|
+
coalesceCaseSensitive: $.from('coalesce_case_sensitive').toBoolean().def(false),
|
|
155
|
+
coalesceEmptyFields: $.from('coalesce_empty_fields').toBoolean().def(false),
|
|
156
|
+
choiceAction: $.from('choice_action').def(''),
|
|
157
|
+
sourceScript: $.val(sourceScript).def(''),
|
|
158
|
+
useSourceScript: $.from('use_source_script').toBoolean().def(false),
|
|
159
|
+
dateFormat: $.from('date_format').def(''),
|
|
160
|
+
referenceValueField: $.from('reference_value_field').def(''),
|
|
161
|
+
}))
|
|
162
|
+
|
|
163
|
+
const targetField = entry.get('targetField').ifString()?.getValue() ?? ''
|
|
164
|
+
const sourceField = entry.get('sourceField').ifString()?.getValue() ?? ''
|
|
165
|
+
|
|
166
|
+
// Skip entries without a valid target field
|
|
167
|
+
if (!targetField || targetField.trim() === '') {
|
|
168
|
+
continue
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Extract all field properties using .properties() for cleaner code
|
|
172
|
+
const fieldProperties = entry.properties()
|
|
173
|
+
|
|
174
|
+
// Determine if this is a simple or complex mapping
|
|
175
|
+
if (hasAdditionalProperties(fieldProperties)) {
|
|
176
|
+
// Complex mapping: allow empty sourceField if scripts/config drive the value
|
|
177
|
+
fieldsObject[targetField] = buildFieldConfig(sourceField, fieldProperties)
|
|
178
|
+
} else {
|
|
179
|
+
// Simple string mapping: require non-empty sourceField
|
|
180
|
+
if (sourceField && sourceField.trim() !== '') {
|
|
181
|
+
fieldsObject[targetField] = sourceField
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return fieldsObject
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Maps sys_transform_script records to an array of script configurations
|
|
191
|
+
* Returns undefined if no scripts exist (for cleaner API output)
|
|
192
|
+
*
|
|
193
|
+
* @param scripts - Array of sys_transform_script records
|
|
194
|
+
* @param transform - Transform context for creating NowIncludeShape
|
|
195
|
+
* @returns Array of script configurations or undefined if empty
|
|
196
|
+
*/
|
|
197
|
+
async function mapTransformScriptsToShape(scripts: Record[], transform: Transform): Promise<ObjectShape[] | undefined> {
|
|
198
|
+
if (scripts.length === 0) {
|
|
199
|
+
return undefined
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const scriptShapes: ObjectShape[] = []
|
|
203
|
+
for (const scriptRecord of scripts) {
|
|
204
|
+
const script = await NowIncludeShape.fromRecord(scriptRecord, scriptRecord.get('script'), transform)
|
|
205
|
+
|
|
206
|
+
scriptShapes.push(
|
|
207
|
+
scriptRecord.transform(({ $ }) => ({
|
|
208
|
+
$id: $.val(NowIdShape.from(scriptRecord)),
|
|
209
|
+
active: $.toBoolean().def(true),
|
|
210
|
+
order: $.toNumber().def(100),
|
|
211
|
+
when: $.def('onAfter'),
|
|
212
|
+
script: $.val(script).def(DEFAULT_TRANSFORM_SCRIPT),
|
|
213
|
+
}))
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return scriptShapes
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ============================================================================
|
|
221
|
+
// PLUGIN DEFINITION
|
|
222
|
+
// ============================================================================
|
|
223
|
+
|
|
224
|
+
export const ImportSetPlugin = Plugin.create({
|
|
225
|
+
name: 'ImportSetPlugin',
|
|
226
|
+
records: {
|
|
227
|
+
sys_transform_entry: {
|
|
228
|
+
coalesce: ['map', 'target_field'],
|
|
229
|
+
},
|
|
230
|
+
sys_transform_script: {},
|
|
231
|
+
sys_transform_map: {
|
|
232
|
+
relationships: {
|
|
233
|
+
sys_transform_entry: {
|
|
234
|
+
via: 'map',
|
|
235
|
+
descendant: true,
|
|
236
|
+
},
|
|
237
|
+
sys_transform_script: {
|
|
238
|
+
via: 'map',
|
|
239
|
+
descendant: true,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
async toShape(record, { descendants, transform }) {
|
|
243
|
+
const entries = descendants.query('sys_transform_entry')
|
|
244
|
+
const scripts = descendants.query('sys_transform_script')
|
|
245
|
+
|
|
246
|
+
// Extract main transform map script using NowIncludeShape
|
|
247
|
+
const mapScript = await NowIncludeShape.fromRecord(record, record.get('script'), transform)
|
|
248
|
+
|
|
249
|
+
// Extract transform scripts using NowIncludeShape
|
|
250
|
+
const transformScripts = await mapTransformScriptsToShape(scripts, transform)
|
|
251
|
+
|
|
252
|
+
// Extract field mappings with module and Now.include support for source scripts
|
|
253
|
+
const fieldsObject = await mapTransformEntriesToFields(entries, transform)
|
|
254
|
+
|
|
255
|
+
// Check if runScript is enabled to determine script handling
|
|
256
|
+
const runScriptValue = record.get('run_script').toBoolean().getValue()
|
|
257
|
+
|
|
258
|
+
// Build the configuration object conditionally
|
|
259
|
+
const config = record.transform(({ $ }) => {
|
|
260
|
+
const baseConfig = {
|
|
261
|
+
$id: $.val(NowIdShape.from(record)),
|
|
262
|
+
name: $,
|
|
263
|
+
targetTable: $.from('target_table'),
|
|
264
|
+
sourceTable: $.from('source_table'),
|
|
265
|
+
order: $.map((v) => v.ifString()?.ifNotEmpty()?.toNumber()).def(100),
|
|
266
|
+
active: $.toBoolean().def(false),
|
|
267
|
+
runBusinessRules: $.from('run_business_rules').toBoolean().def(false),
|
|
268
|
+
enforceMandatoryFields: $.from('enforce_mandatory_fields')
|
|
269
|
+
.map((v) => ENFORCE_MANDATORY_TO_TS[v.ifString()?.ifNotEmpty()?.getValue() ?? ''] ?? 'no')
|
|
270
|
+
.def('no'),
|
|
271
|
+
copyEmptyFields: $.from('copy_empty_fields').toBoolean().def(false),
|
|
272
|
+
createOnEmptyCoalesce: $.from('create_new_record_on_empty_coalesce_fields')
|
|
273
|
+
.toBoolean()
|
|
274
|
+
.def(false),
|
|
275
|
+
fields: $.val(fieldsObject).def({}),
|
|
276
|
+
scripts: $.val(transformScripts).def([]),
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Add script-related properties based on runScript value
|
|
280
|
+
return {
|
|
281
|
+
...baseConfig,
|
|
282
|
+
runScript: $.val(runScriptValue),
|
|
283
|
+
...(runScriptValue && {
|
|
284
|
+
script: $.val(mapScript).def(DEFAULT_TRANSFORM_MAP_SCRIPT),
|
|
285
|
+
}),
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
return {
|
|
290
|
+
success: true,
|
|
291
|
+
value: new CallExpressionShape({
|
|
292
|
+
source: record,
|
|
293
|
+
callee: 'ImportSet',
|
|
294
|
+
args: [config],
|
|
295
|
+
}),
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
shapes: [
|
|
301
|
+
{
|
|
302
|
+
shape: CallExpressionShape,
|
|
303
|
+
fileTypes: ['fluent'],
|
|
304
|
+
async toRecord(callExpression, { factory, diagnostics, config }) {
|
|
305
|
+
if (callExpression.getCallee() !== 'ImportSet') {
|
|
306
|
+
return { success: false }
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const arg = callExpression.getArgument(0).asObject()
|
|
310
|
+
|
|
311
|
+
// ========================================================================
|
|
312
|
+
// VALIDATION
|
|
313
|
+
// ========================================================================
|
|
314
|
+
|
|
315
|
+
const targetTableArg = arg.get('targetTable')
|
|
316
|
+
const targetTable = targetTableArg.ifString()?.getValue() || ''
|
|
317
|
+
const name = arg.get('name')
|
|
318
|
+
|
|
319
|
+
// Validate script reference can be resolved when runScript is true
|
|
320
|
+
const runScriptValue = arg.get('runScript')
|
|
321
|
+
const runScript = runScriptValue.isDefined() ? runScriptValue.toBoolean().getValue() : false
|
|
322
|
+
const script = arg.get('script')
|
|
323
|
+
|
|
324
|
+
if (runScript && script.isDefined() && script.isUnresolved()) {
|
|
325
|
+
diagnostics.error(
|
|
326
|
+
script,
|
|
327
|
+
`Unable to resolve the script reference, ensure the imported module is within the ${config.serverModulesDir} directory.`
|
|
328
|
+
)
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Validate: script should not be provided when runScript is false/undefined
|
|
332
|
+
if (!runScript && script.isDefined()) {
|
|
333
|
+
diagnostics.error(
|
|
334
|
+
script,
|
|
335
|
+
`Property 'script' cannot be used when 'runScript' is false or undefined. Remove the 'script' property or set 'runScript: true'.`
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const sourceTable = arg.get('sourceTable').asString()?.getValue()
|
|
340
|
+
|
|
341
|
+
// ========================================================================
|
|
342
|
+
// CREATE TRANSFORM MAP RECORD
|
|
343
|
+
// ========================================================================
|
|
344
|
+
|
|
345
|
+
const transformMapRecord = await factory.createRecord({
|
|
346
|
+
source: callExpression,
|
|
347
|
+
table: 'sys_transform_map',
|
|
348
|
+
explicitId: arg.get('$id'),
|
|
349
|
+
properties: arg.transform(({ $ }) => ({
|
|
350
|
+
name: $.val(name.ifString()?.getValue()),
|
|
351
|
+
source_table: $.val(sourceTable),
|
|
352
|
+
target_table: $.val(targetTable),
|
|
353
|
+
active: $.from('active').toBoolean().def(false),
|
|
354
|
+
run_business_rules: $.from('runBusinessRules').toBoolean().def(false),
|
|
355
|
+
enforce_mandatory_fields: $.from('enforceMandatoryFields')
|
|
356
|
+
.map((v) => ENFORCE_MANDATORY_TO_XML[v.ifString()?.getValue() ?? ''] ?? 'No')
|
|
357
|
+
.def('No'),
|
|
358
|
+
copy_empty_fields: $.from('copyEmptyFields').toBoolean().def(false),
|
|
359
|
+
create_new_record_on_empty_coalesce_fields: $.from('createOnEmptyCoalesce')
|
|
360
|
+
.toBoolean()
|
|
361
|
+
.def(false),
|
|
362
|
+
script: $.from('script')
|
|
363
|
+
.map(
|
|
364
|
+
(v) =>
|
|
365
|
+
v
|
|
366
|
+
.if(ModuleFunctionShape)
|
|
367
|
+
?.toString(
|
|
368
|
+
(n) => `${n}({{PARAMS}})`,
|
|
369
|
+
['source', 'target', 'map', 'log', 'isUpdate']
|
|
370
|
+
) ?? v
|
|
371
|
+
)
|
|
372
|
+
.toCdata()
|
|
373
|
+
.def(DEFAULT_TRANSFORM_MAP_SCRIPT),
|
|
374
|
+
run_script: $.from('runScript').toBoolean().def(false),
|
|
375
|
+
coalesce: $.from('mapCoalesce').toBoolean().def(false),
|
|
376
|
+
order: $.map((v) => v.ifString()?.ifNotEmpty()?.toNumber()).def(100),
|
|
377
|
+
})),
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
// ========================================================================
|
|
381
|
+
// CREATE TRANSFORM ENTRY RECORDS (Field Mappings)
|
|
382
|
+
// ========================================================================
|
|
383
|
+
|
|
384
|
+
const fieldsArg = arg.get('fields')
|
|
385
|
+
const entryRecords: Record[] = []
|
|
386
|
+
|
|
387
|
+
if (fieldsArg.isDefined()) {
|
|
388
|
+
const fieldsObject = fieldsArg.asObject()
|
|
389
|
+
|
|
390
|
+
for (const [targetField, fieldShape] of fieldsObject.entries()) {
|
|
391
|
+
// Handle both simple string mappings and complex objects
|
|
392
|
+
if (fieldShape.isString()) {
|
|
393
|
+
// Simple mapping: { targetField: "sourceField" }
|
|
394
|
+
const sourceField = fieldShape.getValue()
|
|
395
|
+
entryRecords.push(
|
|
396
|
+
await factory.createRecord({
|
|
397
|
+
source: callExpression,
|
|
398
|
+
table: 'sys_transform_entry',
|
|
399
|
+
properties: {
|
|
400
|
+
map: transformMapRecord,
|
|
401
|
+
source_field: sourceField,
|
|
402
|
+
target_field: targetField,
|
|
403
|
+
choice_action: '',
|
|
404
|
+
source_script: DEFAULT_TRANSFORM_ENTRY_SCRIPT,
|
|
405
|
+
use_source_script: false,
|
|
406
|
+
date_format: '',
|
|
407
|
+
reference_value_field: '',
|
|
408
|
+
source_table: sourceTable,
|
|
409
|
+
target_table: targetTable,
|
|
410
|
+
coalesce: false,
|
|
411
|
+
coalesce_case_sensitive: false,
|
|
412
|
+
coalesce_empty_fields: false,
|
|
413
|
+
},
|
|
414
|
+
})
|
|
415
|
+
)
|
|
416
|
+
} else if (fieldShape.isObject()) {
|
|
417
|
+
// Complex mapping: { targetField: { sourceField: "...", coalesce: true, ... } }
|
|
418
|
+
const fieldObj = fieldShape.asObject()
|
|
419
|
+
|
|
420
|
+
// ============================================================
|
|
421
|
+
// FIELD-LEVEL CONSTRAINT VALIDATION
|
|
422
|
+
// ============================================================
|
|
423
|
+
|
|
424
|
+
// Validate coalesce options
|
|
425
|
+
const coalesceValue = fieldObj.get('coalesce')
|
|
426
|
+
const coalesce = coalesceValue.isDefined() ? coalesceValue.toBoolean().getValue() : false
|
|
427
|
+
const coalesceCaseSensitive = fieldObj.get('coalesceCaseSensitive')
|
|
428
|
+
const coalesceEmptyFields = fieldObj.get('coalesceEmptyFields')
|
|
429
|
+
|
|
430
|
+
if (!coalesce && coalesceCaseSensitive.isDefined()) {
|
|
431
|
+
diagnostics.error(
|
|
432
|
+
coalesceCaseSensitive,
|
|
433
|
+
`Field '${targetField}': Property 'coalesceCaseSensitive' cannot be used when 'coalesce' is false or undefined. Remove the 'coalesceCaseSensitive' property or set 'coalesce: true'.`
|
|
434
|
+
)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
if (!coalesce && coalesceEmptyFields.isDefined()) {
|
|
438
|
+
diagnostics.error(
|
|
439
|
+
coalesceEmptyFields,
|
|
440
|
+
`Field '${targetField}': Property 'coalesceEmptyFields' cannot be used when 'coalesce' is false or undefined. Remove the 'coalesceEmptyFields' property or set 'coalesce: true'.`
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const useSourceScriptValue = fieldObj.get('useSourceScript')
|
|
445
|
+
const useSourceScript = useSourceScriptValue.isDefined()
|
|
446
|
+
? useSourceScriptValue.toBoolean().getValue()
|
|
447
|
+
: false
|
|
448
|
+
const sourceScriptValue = fieldObj.get('sourceScript')
|
|
449
|
+
|
|
450
|
+
// Validate: sourceScript should not be provided when useSourceScript is false/undefined
|
|
451
|
+
if (!useSourceScript && sourceScriptValue.isDefined()) {
|
|
452
|
+
diagnostics.error(
|
|
453
|
+
sourceScriptValue,
|
|
454
|
+
`Field '${targetField}': Property 'sourceScript' cannot be used when 'useSourceScript' is false or undefined. Remove the 'sourceScript' property or set 'useSourceScript: true'.`
|
|
455
|
+
)
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Validate: sourceScript is required when useSourceScript is true
|
|
459
|
+
if (useSourceScript && !sourceScriptValue.isDefined()) {
|
|
460
|
+
diagnostics.error(
|
|
461
|
+
useSourceScriptValue,
|
|
462
|
+
`Field '${targetField}': Property 'sourceScript' is required when 'useSourceScript' is true. Provide a 'sourceScript' function or set 'useSourceScript: false'.`
|
|
463
|
+
)
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
entryRecords.push(
|
|
467
|
+
await factory.createRecord({
|
|
468
|
+
source: callExpression,
|
|
469
|
+
table: 'sys_transform_entry',
|
|
470
|
+
properties: fieldObj.transform(({ $ }) => ({
|
|
471
|
+
map: $.val(transformMapRecord),
|
|
472
|
+
source_field: $.from('sourceField').def(''),
|
|
473
|
+
target_field: $.val(targetField),
|
|
474
|
+
choice_action: $.from('choiceAction').def(''),
|
|
475
|
+
source_script: $.from('sourceScript')
|
|
476
|
+
.map(
|
|
477
|
+
(v) =>
|
|
478
|
+
v
|
|
479
|
+
.if(ModuleFunctionShape)
|
|
480
|
+
?.toString((n) => `${n}({{PARAMS}})`, ['source']) ?? v
|
|
481
|
+
)
|
|
482
|
+
.toCdata()
|
|
483
|
+
.def(DEFAULT_TRANSFORM_ENTRY_SCRIPT),
|
|
484
|
+
use_source_script: $.from('useSourceScript').toBoolean().def(false),
|
|
485
|
+
date_format: $.from('dateFormat').def(''),
|
|
486
|
+
reference_value_field: $.from('referenceValueField').def(''),
|
|
487
|
+
source_table: $.val(sourceTable),
|
|
488
|
+
target_table: $.val(targetTable),
|
|
489
|
+
coalesce: $.from('coalesce').toBoolean().def(false),
|
|
490
|
+
coalesce_case_sensitive: $.from('coalesceCaseSensitive').toBoolean().def(false),
|
|
491
|
+
coalesce_empty_fields: $.from('coalesceEmptyFields').toBoolean().def(false),
|
|
492
|
+
})),
|
|
493
|
+
})
|
|
494
|
+
)
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// ========================================================================
|
|
500
|
+
// CREATE TRANSFORM SCRIPT RECORDS
|
|
501
|
+
// ========================================================================
|
|
502
|
+
|
|
503
|
+
const scripts = arg.get('scripts')?.ifArray()?.getElements() ?? []
|
|
504
|
+
const scriptRecords: Record[] = []
|
|
505
|
+
for (const script of scripts) {
|
|
506
|
+
const obj = script.asObject()
|
|
507
|
+
|
|
508
|
+
scriptRecords.push(
|
|
509
|
+
await factory.createRecord({
|
|
510
|
+
source: callExpression,
|
|
511
|
+
table: 'sys_transform_script',
|
|
512
|
+
explicitId: obj.get('$id'),
|
|
513
|
+
properties: obj.transform(({ $ }) => ({
|
|
514
|
+
map: $.val(transformMapRecord),
|
|
515
|
+
active: $.toBoolean().def(true),
|
|
516
|
+
order: $.map((v) => v.ifString()?.ifNotEmpty()?.toNumber()).def(100),
|
|
517
|
+
when: $.from('when').def('onAfter'),
|
|
518
|
+
script: $.from('script')
|
|
519
|
+
.map(
|
|
520
|
+
(v) =>
|
|
521
|
+
v
|
|
522
|
+
.if(ModuleFunctionShape)
|
|
523
|
+
?.toString(
|
|
524
|
+
(n) => `${n}({{PARAMS}})`,
|
|
525
|
+
['source', 'map', 'log', 'target']
|
|
526
|
+
) ?? v
|
|
527
|
+
)
|
|
528
|
+
.toCdata()
|
|
529
|
+
.def(DEFAULT_TRANSFORM_SCRIPT),
|
|
530
|
+
})),
|
|
531
|
+
})
|
|
532
|
+
)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
return {
|
|
536
|
+
success: true,
|
|
537
|
+
value: transformMapRecord.with(...entryRecords, ...scriptRecords),
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
],
|
|
542
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './user-preference-plugin'
|
|
|
20
20
|
export * from './now-include-plugin'
|
|
21
21
|
export * from './table-plugin'
|
|
22
22
|
export * from './column-plugin'
|
|
23
|
+
export * from './data-plugin'
|
|
23
24
|
export * from './ui-page-plugin'
|
|
24
25
|
export * from './list-plugin'
|
|
25
26
|
export * from './ui-action-plugin'
|
|
@@ -34,7 +35,30 @@ export * from './html-import-plugin'
|
|
|
34
35
|
export * from './static-content-plugin'
|
|
35
36
|
export * from './script-action-plugin'
|
|
36
37
|
export * from './claims-plugin'
|
|
38
|
+
export * from './flow/plugins/flow-action-definition-plugin'
|
|
39
|
+
export * from './flow/plugins/wfa-datapill-plugin'
|
|
40
|
+
export * from './flow/plugins/flow-instance-plugin'
|
|
41
|
+
export * from './flow/plugins/inline-script-plugin'
|
|
42
|
+
export * from './flow/plugins/approval-rules-plugin'
|
|
43
|
+
export * from './flow/plugins/flow-trigger-instance-plugin'
|
|
44
|
+
export * from './flow/plugins/flow-definition-plugin'
|
|
45
|
+
export * from './flow/plugins/trigger-plugin'
|
|
46
|
+
export * from './flow/flow-logic/flow-logic-plugin'
|
|
47
|
+
export * from './flow/plugins/step-instance-plugin'
|
|
48
|
+
export * from './flow/plugins/step-definition-plugin'
|
|
49
|
+
export * from './flow/plugins/flow-diagnostics-plugin'
|
|
50
|
+
export * from './ui-policy-plugin'
|
|
51
|
+
export * from './import-sets-plugin'
|
|
52
|
+
export * from './now-attach-plugin'
|
|
53
|
+
export * from './sla-plugin'
|
|
54
|
+
export * from './email-notification-plugin'
|
|
55
|
+
|
|
56
|
+
export * from './service-catalog'
|
|
57
|
+
export * from './ux-list-menu-config-plugin'
|
|
58
|
+
export * from './workspace-plugin'
|
|
59
|
+
export * from './dashboard/dashboard-plugin'
|
|
60
|
+
export * from './applicability-plugin'
|
|
37
61
|
|
|
38
62
|
// non-plugins
|
|
39
63
|
export * from './atf/step-configs'
|
|
40
|
-
export { REPACK_OUTPUT_DIR, checkModuleExists } from './repack'
|
|
64
|
+
export { REPACK_OUTPUT_DIR, checkModuleExists, resolveModule } from './repack'
|
package/src/json-plugin.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ts,
|
|
3
3
|
JSON5,
|
|
4
|
+
type ArrayShape,
|
|
4
5
|
CallExpressionShape,
|
|
5
6
|
type ObjectShape,
|
|
6
7
|
Plugin,
|
|
@@ -11,12 +12,13 @@ import {
|
|
|
11
12
|
} from '@servicenow/sdk-build-core'
|
|
12
13
|
|
|
13
14
|
export class JsonStringifyShape extends CallExpressionShape {
|
|
14
|
-
constructor({ source, json }: { source: Source; json: NonNullable<object> | ObjectShape }) {
|
|
15
|
+
constructor({ source, json }: { source: Source; json: NonNullable<object> | ObjectShape | ArrayShape }) {
|
|
15
16
|
super({ source, callee: 'JSON.stringify', args: [json] })
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
getJson(): ObjectShape {
|
|
19
|
-
|
|
19
|
+
getJson(): ObjectShape | ArrayShape {
|
|
20
|
+
const arg = this.getArgument(0)
|
|
21
|
+
return arg.isArray() ? arg.asArray() : arg.asObject()
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
override getValue(): string {
|
|
@@ -25,7 +27,7 @@ export class JsonStringifyShape extends CallExpressionShape {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export class JsonFileShape extends SourceFileShape {
|
|
28
|
-
private readonly json: ObjectShape
|
|
30
|
+
private readonly json: ObjectShape | ArrayShape
|
|
29
31
|
|
|
30
32
|
constructor({
|
|
31
33
|
source,
|
|
@@ -34,10 +36,13 @@ export class JsonFileShape extends SourceFileShape {
|
|
|
34
36
|
content,
|
|
35
37
|
}: { source: Source; json: unknown; path: string | Shape; content: string | Shape }) {
|
|
36
38
|
super({ source, path, content })
|
|
37
|
-
|
|
39
|
+
const shape = Shape.from(source, json)
|
|
40
|
+
this.json = shape.isArray()
|
|
41
|
+
? shape.asArray()
|
|
42
|
+
: shape.asObject('Expected JSON file content to be a JSON object or array')
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
getJson(): ObjectShape {
|
|
45
|
+
getJson(): ObjectShape | ArrayShape {
|
|
41
46
|
return this.json
|
|
42
47
|
}
|
|
43
48
|
}
|
|
@@ -62,7 +67,17 @@ export const JsonPlugin = Plugin.create({
|
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
|
|
65
|
-
|
|
70
|
+
// Get the root-level expression from the first statement
|
|
71
|
+
// We need to check the direct child, not descendants, to avoid matching nested arrays/objects
|
|
72
|
+
const firstStatement = actualFile.getStatements()[0]
|
|
73
|
+
const rootExpression = firstStatement?.isKind(ts.SyntaxKind.ExpressionStatement)
|
|
74
|
+
? firstStatement.getExpression()
|
|
75
|
+
: undefined
|
|
76
|
+
const root =
|
|
77
|
+
rootExpression?.isKind(ts.SyntaxKind.ObjectLiteralExpression) ||
|
|
78
|
+
rootExpression?.isKind(ts.SyntaxKind.ArrayLiteralExpression)
|
|
79
|
+
? rootExpression
|
|
80
|
+
: undefined
|
|
66
81
|
if (!root) {
|
|
67
82
|
return { success: false }
|
|
68
83
|
}
|
|
@@ -100,8 +115,11 @@ export const JsonPlugin = Plugin.create({
|
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
const arg = callExpression.getArgument(0)
|
|
103
|
-
if (!arg.isObject() && !arg.is(JsonFileShape)) {
|
|
104
|
-
diagnostics.error(
|
|
118
|
+
if (!arg.isObject() && !arg.isArray() && !arg.is(JsonFileShape)) {
|
|
119
|
+
diagnostics.error(
|
|
120
|
+
arg,
|
|
121
|
+
'Argument to JSON.stringify must be an object, array, or an import from a JSON file'
|
|
122
|
+
)
|
|
105
123
|
return { success: false }
|
|
106
124
|
}
|
|
107
125
|
|
|
@@ -128,13 +146,14 @@ export const JsonPlugin = Plugin.create({
|
|
|
128
146
|
return { success: true }
|
|
129
147
|
}
|
|
130
148
|
|
|
131
|
-
if (!targetShape.isObject() && !targetShape.is(JsonFileShape)) {
|
|
149
|
+
if (!targetShape.isObject() && !targetShape.isArray() && !targetShape.is(JsonFileShape)) {
|
|
132
150
|
return { success: false }
|
|
133
151
|
}
|
|
134
152
|
|
|
135
|
-
let json: ObjectShape
|
|
153
|
+
let json: ObjectShape | ArrayShape
|
|
136
154
|
try {
|
|
137
|
-
|
|
155
|
+
const parsed = Shape.from(shape, JSON5.parse(shape.getValue()))
|
|
156
|
+
json = parsed.isArray() ? parsed.asArray() : parsed.asObject()
|
|
138
157
|
} catch (e) {
|
|
139
158
|
logger.info('Incoming string value could not be parsed as JSON and will overwrite the node')
|
|
140
159
|
return { success: false }
|