@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
package/src/list-plugin.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
StringShape,
|
|
7
7
|
type ObjectShape,
|
|
8
8
|
type Diagnostics,
|
|
9
|
+
Database,
|
|
9
10
|
} from '@servicenow/sdk-build-core'
|
|
10
11
|
import { create } from 'xmlbuilder2'
|
|
11
12
|
import { generateDeprecatedDiagnostics } from './utils'
|
|
@@ -33,6 +34,35 @@ function generateListColumnProps(column: ObjectShape, index: number, diagnostics
|
|
|
33
34
|
return props
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
function getListUpdateName(list: Record): string {
|
|
38
|
+
const { view: viewShape, parent: parentShape, relationship: relShape, name: tableShape } = list.properties()
|
|
39
|
+
const viewRecordId = viewShape?.isRecord() ? viewShape.getId() : viewShape?.isRecordId() ? viewShape : undefined
|
|
40
|
+
const parent = parentShape?.isString() ? parentShape.asString().getValue() : undefined
|
|
41
|
+
const relationship = relShape?.ifDefined()
|
|
42
|
+
? (relShape.ifString()?.getValue() ?? relShape.asRecord().getId().getValue())
|
|
43
|
+
: undefined
|
|
44
|
+
const table = tableShape?.isString() ? tableShape.asString().getValue() : undefined
|
|
45
|
+
let view = viewRecordId?.isDefined()
|
|
46
|
+
? ((viewRecordId?.getKey('name') as string) ?? 'NULL')
|
|
47
|
+
: viewShape?.asString().getValue()
|
|
48
|
+
view =
|
|
49
|
+
viewRecordId && (viewRecordId.getKey('name') === DEFAULT_VIEW || viewRecordId.getValue() === DEFAULT_VIEW)
|
|
50
|
+
? 'NULL'
|
|
51
|
+
: view
|
|
52
|
+
|
|
53
|
+
const updateNameFormats = new Map([
|
|
54
|
+
['no-parent-no-relationship', [table, view]],
|
|
55
|
+
['parent-no-relationship', [table, parent, view]],
|
|
56
|
+
['no-parent-relationship', ['NULL', relationship, view]],
|
|
57
|
+
['parent-relationship', [parent, relationship, view]],
|
|
58
|
+
])
|
|
59
|
+
|
|
60
|
+
const key = `${parent ? 'parent' : 'no-parent'}-${relationship ? 'relationship' : 'no-relationship'}`
|
|
61
|
+
const segments = updateNameFormats.get(key) ?? []
|
|
62
|
+
|
|
63
|
+
return ['sys_ui_list', ...segments].join('_').toLocaleLowerCase()
|
|
64
|
+
}
|
|
65
|
+
|
|
36
66
|
export const ListPlugin = Plugin.create({
|
|
37
67
|
name: 'ListPlugin',
|
|
38
68
|
records: {
|
|
@@ -49,6 +79,7 @@ export const ListPlugin = Plugin.create({
|
|
|
49
79
|
inverse: true,
|
|
50
80
|
},
|
|
51
81
|
},
|
|
82
|
+
getUpdateName: (list) => ({ success: true, value: getListUpdateName(list) }),
|
|
52
83
|
toShape(record, { descendants }) {
|
|
53
84
|
return {
|
|
54
85
|
success: true,
|
|
@@ -160,12 +191,71 @@ export const ListPlugin = Plugin.create({
|
|
|
160
191
|
success: true,
|
|
161
192
|
value: {
|
|
162
193
|
source: list,
|
|
163
|
-
name:
|
|
194
|
+
name: `${getListUpdateName(list)}.xml`,
|
|
164
195
|
category: list.getInstallCategory(),
|
|
165
196
|
content: xml.end({ prettyPrint: true }),
|
|
166
197
|
},
|
|
167
198
|
}
|
|
168
199
|
},
|
|
200
|
+
async diff(existing, incoming, _, { factory }) {
|
|
201
|
+
if (incoming.query().length === 0 || existing.query().length === 0) {
|
|
202
|
+
return {
|
|
203
|
+
success: true,
|
|
204
|
+
value: incoming.query().length === 0 ? new Database() : new Database(incoming.query()),
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const changeDatabase = new Database()
|
|
208
|
+
let hasChanges = false
|
|
209
|
+
const existingList = existing.query('sys_ui_list')[0]
|
|
210
|
+
const incomingList = incoming.query('sys_ui_list')[0]
|
|
211
|
+
const existingElements = existing.query('sys_ui_list_element')
|
|
212
|
+
const incomingElements = incoming.query('sys_ui_list_element')
|
|
213
|
+
|
|
214
|
+
if (incomingList && existingList) {
|
|
215
|
+
if (!existingList.strictEquals(incomingList)) {
|
|
216
|
+
changeDatabase.insert(existingList.merge(incomingList))
|
|
217
|
+
hasChanges = true
|
|
218
|
+
}
|
|
219
|
+
} else if (incomingList) {
|
|
220
|
+
changeDatabase.insert(incomingList)
|
|
221
|
+
hasChanges = true
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const markForRemoval: Record[] = []
|
|
225
|
+
for (const element of existingElements) {
|
|
226
|
+
const match = incoming.resolve(element.getId())
|
|
227
|
+
if (!match) {
|
|
228
|
+
hasChanges = true
|
|
229
|
+
markForRemoval.push(element)
|
|
230
|
+
} else {
|
|
231
|
+
hasChanges = hasChanges || !element.strictEquals(match)
|
|
232
|
+
changeDatabase.insert(element.merge(match))
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
incomingElements.forEach((element) => {
|
|
237
|
+
const match = changeDatabase.resolve(element.getId())
|
|
238
|
+
if (!match) {
|
|
239
|
+
changeDatabase.insert(element)
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
for (const element of markForRemoval) {
|
|
244
|
+
const deleteRecord = await factory.createRecord({
|
|
245
|
+
source: element.getSource(),
|
|
246
|
+
table: 'sys_ui_list_element',
|
|
247
|
+
explicitId: element.getId(),
|
|
248
|
+
properties: element.properties(),
|
|
249
|
+
action: 'DELETE',
|
|
250
|
+
})
|
|
251
|
+
changeDatabase.insert(deleteRecord)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
success: true,
|
|
256
|
+
value: hasChanges ? changeDatabase : new Database(),
|
|
257
|
+
}
|
|
258
|
+
},
|
|
169
259
|
},
|
|
170
260
|
sys_ui_list_element: {
|
|
171
261
|
coalesce: ['list_id', 'element'],
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import {
|
|
2
|
+
path as pathModule,
|
|
3
|
+
CallExpressionShape,
|
|
4
|
+
FileSystem,
|
|
5
|
+
Plugin,
|
|
6
|
+
type Source,
|
|
7
|
+
type Record,
|
|
8
|
+
crypto,
|
|
9
|
+
path,
|
|
10
|
+
type Factory,
|
|
11
|
+
type AssociateRecordsShape,
|
|
12
|
+
type LazyValue,
|
|
13
|
+
gunzip,
|
|
14
|
+
ObjectShape,
|
|
15
|
+
ts,
|
|
16
|
+
gzipSync,
|
|
17
|
+
isLazyValue,
|
|
18
|
+
hasAssociatedRecords,
|
|
19
|
+
unloadBuilder,
|
|
20
|
+
} from '@servicenow/sdk-build-core'
|
|
21
|
+
import { CHUNK_SIZE, chunkData, generateId } from './static-content-plugin'
|
|
22
|
+
|
|
23
|
+
export async function sha256(message: Buffer) {
|
|
24
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', new Uint8Array(message))
|
|
25
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
|
26
|
+
return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const ImageAttachmentTypes = new Map([
|
|
30
|
+
['.jpg', 'image/jpeg'],
|
|
31
|
+
['.jpeg', 'image/jpeg'],
|
|
32
|
+
['.png', 'image/png'],
|
|
33
|
+
['.bmp', 'image/bmp'],
|
|
34
|
+
['.gif', 'image/gif'],
|
|
35
|
+
['.ico', 'image/ico'],
|
|
36
|
+
['.svg', 'image/svg+xml'],
|
|
37
|
+
])
|
|
38
|
+
|
|
39
|
+
function getExtension(contentType: string) {
|
|
40
|
+
switch (contentType) {
|
|
41
|
+
case 'image/jpeg':
|
|
42
|
+
return '.jpg'
|
|
43
|
+
case 'image/png':
|
|
44
|
+
return '.png'
|
|
45
|
+
case 'image/bmp':
|
|
46
|
+
return '.bmp'
|
|
47
|
+
case 'image/gif':
|
|
48
|
+
return '.gif'
|
|
49
|
+
case 'image/vnd.microsoft.icon':
|
|
50
|
+
case 'image/x-icon':
|
|
51
|
+
case 'image/ico':
|
|
52
|
+
return '.ico'
|
|
53
|
+
case 'image/svg':
|
|
54
|
+
case 'image/svg+xml':
|
|
55
|
+
return '.svg'
|
|
56
|
+
default:
|
|
57
|
+
return ''
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type BaseAttachmentProperties = {
|
|
62
|
+
average_image_color: ''
|
|
63
|
+
chunk_size_bytes: unknown
|
|
64
|
+
compressed: boolean
|
|
65
|
+
content_type: string | undefined
|
|
66
|
+
hash: string
|
|
67
|
+
image_height: ''
|
|
68
|
+
image_width: ''
|
|
69
|
+
size_bytes: unknown
|
|
70
|
+
size_compressed: unknown
|
|
71
|
+
data: string[]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export class NowAttachShape extends CallExpressionShape implements AssociateRecordsShape, LazyValue {
|
|
75
|
+
private readonly baseProperties: BaseAttachmentProperties
|
|
76
|
+
|
|
77
|
+
constructor({
|
|
78
|
+
source,
|
|
79
|
+
path,
|
|
80
|
+
baseProperties,
|
|
81
|
+
}: { source: Source; path: string; baseProperties: BaseAttachmentProperties }) {
|
|
82
|
+
super({ source, callee: 'Now.attach', args: [path] })
|
|
83
|
+
|
|
84
|
+
this.baseProperties = baseProperties
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
evaluate(parentRecord: Record, field: string) {
|
|
88
|
+
return generateId(parentRecord.getId().getValue(), 'sys_attachment', this.baseProperties.hash, field)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getPath(): string {
|
|
92
|
+
return this.getArgument(0).asString().getValue()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getBaseAttachmentProperties() {
|
|
96
|
+
return this.baseProperties
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async getBufferData() {
|
|
100
|
+
const buffers = await Promise.all(this.getBaseAttachmentProperties().data.map((d) => Buffer.from(d, 'base64')))
|
|
101
|
+
const combinedBuffer = Buffer.concat(buffers)
|
|
102
|
+
return await gunzip(combinedBuffer)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async createAssociatedRecords({
|
|
106
|
+
parentRecord,
|
|
107
|
+
factory,
|
|
108
|
+
field,
|
|
109
|
+
}: {
|
|
110
|
+
parentRecord: Record
|
|
111
|
+
factory: Factory
|
|
112
|
+
field: string
|
|
113
|
+
}) {
|
|
114
|
+
const attachment = await factory.createRecord({
|
|
115
|
+
source: parentRecord.getSource(),
|
|
116
|
+
table: 'sys_attachment',
|
|
117
|
+
properties: {
|
|
118
|
+
sys_id: generateId(parentRecord.getId().getValue(), 'sys_attachment', this.baseProperties.hash, field),
|
|
119
|
+
average_image_color: this.baseProperties.average_image_color,
|
|
120
|
+
chunk_size_bytes: this.baseProperties.chunk_size_bytes,
|
|
121
|
+
compressed: this.baseProperties.compressed,
|
|
122
|
+
content_type: this.baseProperties.content_type,
|
|
123
|
+
hash: this.baseProperties.hash,
|
|
124
|
+
image_height: this.baseProperties.image_height,
|
|
125
|
+
image_width: this.baseProperties.image_width,
|
|
126
|
+
size_bytes: this.baseProperties.size_bytes,
|
|
127
|
+
size_compressed: this.baseProperties.size_compressed,
|
|
128
|
+
file_name: field,
|
|
129
|
+
table_name: `ZZ_YY${parentRecord.getTable()}`,
|
|
130
|
+
table_sys_id: parentRecord.getId().getValue(),
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
const attachmentDocs = await Promise.all(
|
|
135
|
+
this.baseProperties.data.map((data, i) =>
|
|
136
|
+
factory.createRecord({
|
|
137
|
+
source: parentRecord.getSource(),
|
|
138
|
+
table: 'sys_attachment_doc',
|
|
139
|
+
properties: {
|
|
140
|
+
sys_id: generateId(parentRecord.getId().getValue(), 'sys_attachment_doc', field, data),
|
|
141
|
+
data,
|
|
142
|
+
length: data.length,
|
|
143
|
+
position: i,
|
|
144
|
+
sys_attachment: attachment.getId().getValue(),
|
|
145
|
+
},
|
|
146
|
+
})
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
return [attachment, ...attachmentDocs]
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
override equals<E = unknown>(value: E): boolean {
|
|
154
|
+
return value instanceof NowAttachShape && value.baseProperties.hash === this.baseProperties.hash
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
static async create(source: Source, fs: FileSystem, filePath: string) {
|
|
158
|
+
const buffer = (await fs.readFileSync(filePath)) as Buffer
|
|
159
|
+
|
|
160
|
+
const hash = await sha256(buffer)
|
|
161
|
+
const gzipped = gzipSync(buffer)
|
|
162
|
+
const compressedFileData = Buffer.from(gzipped)
|
|
163
|
+
|
|
164
|
+
// The first sys_attachment_doc (position=0), contains only the
|
|
165
|
+
// first 10 bytes of the gzip header, which are base64-encoded into 16 characters.
|
|
166
|
+
// For more info on the gzip header: https://www.ietf.org/rfc/rfc1952.txt
|
|
167
|
+
const gzipHeader = compressedFileData.subarray(0, 10).toString('base64')
|
|
168
|
+
const remainingCompressedData = chunkData(compressedFileData.subarray(10).toString('base64'))
|
|
169
|
+
|
|
170
|
+
return new NowAttachShape({
|
|
171
|
+
source,
|
|
172
|
+
path: filePath,
|
|
173
|
+
baseProperties: {
|
|
174
|
+
average_image_color: '',
|
|
175
|
+
chunk_size_bytes: CHUNK_SIZE,
|
|
176
|
+
compressed: true,
|
|
177
|
+
content_type: ImageAttachmentTypes.get(path.extname(filePath).toLowerCase()),
|
|
178
|
+
hash,
|
|
179
|
+
image_height: '',
|
|
180
|
+
image_width: '',
|
|
181
|
+
size_bytes: buffer.length,
|
|
182
|
+
size_compressed: gzipped.length,
|
|
183
|
+
data: [gzipHeader, ...remainingCompressedData],
|
|
184
|
+
},
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static fromAttachmentRecord(parentUpdateName: string, attachment: Record, attachmentDocs: Record[]) {
|
|
189
|
+
const field = attachment.get('file_name').getValue()
|
|
190
|
+
const extension = getExtension(attachment.get('content_type').toString().getValue() || '')
|
|
191
|
+
const relativePath = `.${path.sep}${parentUpdateName}_${field}${extension}`
|
|
192
|
+
|
|
193
|
+
return new NowAttachShape({
|
|
194
|
+
source: attachment,
|
|
195
|
+
path: relativePath,
|
|
196
|
+
baseProperties: {
|
|
197
|
+
average_image_color: '',
|
|
198
|
+
chunk_size_bytes: attachment.get('chunk_size_bytes').getValue(),
|
|
199
|
+
compressed: attachment.get('compressed').toBoolean().getValue(),
|
|
200
|
+
content_type: attachment.get('content_type').toString().getValue() || undefined,
|
|
201
|
+
hash: attachment.get('hash').toString().getValue(),
|
|
202
|
+
image_height: '',
|
|
203
|
+
image_width: '',
|
|
204
|
+
size_bytes: attachment.get('size_bytes').getValue(),
|
|
205
|
+
size_compressed: attachment.get('size_compressed').getValue(),
|
|
206
|
+
data: attachmentDocs.map((doc) => doc.get('data').toString().getValue()),
|
|
207
|
+
},
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export const NowAttachPlugin = Plugin.create({
|
|
213
|
+
name: 'NowAttachPlugin',
|
|
214
|
+
records: {
|
|
215
|
+
'*': {
|
|
216
|
+
async toFile(record, { config, database, factory, transform }) {
|
|
217
|
+
const recordBuilder = unloadBuilder(config)
|
|
218
|
+
const updateName = await transform.getUpdateName(record)
|
|
219
|
+
const builder = recordBuilder.record(record, updateName)
|
|
220
|
+
let attachmentsProcessed = false
|
|
221
|
+
|
|
222
|
+
record
|
|
223
|
+
.entries()
|
|
224
|
+
.sort(([a], [b]) => a.localeCompare(b)) // Sort keys to make outputs more deterministic
|
|
225
|
+
.forEach(([prop, shape]) => {
|
|
226
|
+
if (isLazyValue(shape)) {
|
|
227
|
+
attachmentsProcessed = true
|
|
228
|
+
builder.field(prop, shape.evaluate(record, prop))
|
|
229
|
+
} else {
|
|
230
|
+
builder.field(prop, shape)
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
for (const field in record.properties()) {
|
|
235
|
+
const shape = record.get(field)
|
|
236
|
+
if (hasAssociatedRecords(shape)) {
|
|
237
|
+
attachmentsProcessed = true
|
|
238
|
+
for (const rec of await shape.createAssociatedRecords({
|
|
239
|
+
parentRecord: record,
|
|
240
|
+
factory,
|
|
241
|
+
field,
|
|
242
|
+
})) {
|
|
243
|
+
const claimUpdateName = await transform.getUpdateName(rec)
|
|
244
|
+
const claimBuilder = recordBuilder.record(rec, claimUpdateName)
|
|
245
|
+
rec.entries()
|
|
246
|
+
.sort(([a], [b]) => a.localeCompare(b)) // Sort keys to make outputs more deterministic
|
|
247
|
+
.forEach(([prop, shape]) => claimBuilder.field(prop, shape))
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!attachmentsProcessed) {
|
|
253
|
+
return {
|
|
254
|
+
success: false,
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const claims = database
|
|
259
|
+
.query('sys_claim')
|
|
260
|
+
.filter((claim) => claim.get('metadata_update_name').equals(updateName))
|
|
261
|
+
|
|
262
|
+
for (const claim of claims) {
|
|
263
|
+
const claimUpdateName = await transform.getUpdateName(claim)
|
|
264
|
+
const claimBuilder = recordBuilder.record(claim, claimUpdateName)
|
|
265
|
+
claim
|
|
266
|
+
.entries()
|
|
267
|
+
.sort(([a], [b]) => a.localeCompare(b)) // Sort keys to make outputs more deterministic
|
|
268
|
+
.forEach(([prop, shape]) => claimBuilder.field(prop, shape))
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
success: true,
|
|
273
|
+
value: {
|
|
274
|
+
source: record,
|
|
275
|
+
name: `${updateName}.xml`,
|
|
276
|
+
category: record.getInstallCategory(),
|
|
277
|
+
content: recordBuilder.end(),
|
|
278
|
+
},
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
sys_attachment: {
|
|
283
|
+
toShape: async (record) => {
|
|
284
|
+
const fileName = record.get('file_name').getValue()
|
|
285
|
+
const hash = record.get('hash').getValue()
|
|
286
|
+
const extension = getExtension(record.get('content_type').toString().getValue() || '')
|
|
287
|
+
|
|
288
|
+
return {
|
|
289
|
+
success: true,
|
|
290
|
+
value: new CallExpressionShape({
|
|
291
|
+
source: record,
|
|
292
|
+
args: [`${fileName}_${hash}${extension}`],
|
|
293
|
+
callee: 'Now.attach',
|
|
294
|
+
}),
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
shapes: [
|
|
300
|
+
{
|
|
301
|
+
shape: CallExpressionShape,
|
|
302
|
+
fileTypes: ['fluent'],
|
|
303
|
+
async toSubclass(callExpression, { diagnostics, project, fs }) {
|
|
304
|
+
if (callExpression.getCallee() !== 'Now.attach') {
|
|
305
|
+
return { success: false }
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const arg = callExpression.getArgument(0)
|
|
309
|
+
if (!arg.isString()) {
|
|
310
|
+
diagnostics.error(arg, 'Now.attach() must have a string argument')
|
|
311
|
+
return { success: false }
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const path = arg.getValue()
|
|
315
|
+
if (!/^\.\.?\/.*$/.test(path.trim()) && path.includes('/')) {
|
|
316
|
+
diagnostics.error(arg, 'Now.attach() argument must be a relative path')
|
|
317
|
+
return { success: false }
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const absolutePath = pathModule.resolve(pathModule.dirname(callExpression.getOriginalFilePath()), path)
|
|
321
|
+
|
|
322
|
+
if (pathModule.relative(project.getRootDir(), absolutePath).startsWith('..')) {
|
|
323
|
+
diagnostics.error(arg, `File path is not within project: ${absolutePath}`)
|
|
324
|
+
return { success: false }
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (!FileSystem.existsSync(fs, absolutePath)) {
|
|
328
|
+
diagnostics.error(arg, 'File not found')
|
|
329
|
+
return { success: false }
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const attachment = await NowAttachShape.create(callExpression.getSource(), fs, absolutePath)
|
|
333
|
+
|
|
334
|
+
return {
|
|
335
|
+
success: true,
|
|
336
|
+
value: attachment,
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
shape: NowAttachShape,
|
|
342
|
+
async commit(shape, target, { transform, fs }) {
|
|
343
|
+
const targetResult = await transform.toShape(target)
|
|
344
|
+
if (!targetResult.success) {
|
|
345
|
+
return { success: false }
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const { value: targetShape } = targetResult
|
|
349
|
+
let absolutePath: string
|
|
350
|
+
|
|
351
|
+
if (
|
|
352
|
+
targetShape.is(NowAttachShape) &&
|
|
353
|
+
path.extname(targetShape.getPath()) === path.extname(shape.getPath())
|
|
354
|
+
) {
|
|
355
|
+
absolutePath = targetShape.getPath()
|
|
356
|
+
} else {
|
|
357
|
+
absolutePath = path.resolve(path.dirname(target.getSourceFile().getFilePath()), shape.getPath())
|
|
358
|
+
target.replaceWithText(shape.getCode())
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
fs.mkdirSync(path.dirname(absolutePath), { recursive: true })
|
|
362
|
+
const bufferData = await shape.getBufferData()
|
|
363
|
+
if (!FileSystem.existsSync(fs, absolutePath) || !fs.readFileSync(absolutePath).equals(bufferData)) {
|
|
364
|
+
fs.writeFileSync(absolutePath, bufferData, { encoding: 'binary' })
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return { success: true }
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
// The following is janky. The problem is, in the case of a transform where
|
|
371
|
+
// the ObjectLiteralExpression for a plugin CallExpression exists, but doesn't
|
|
372
|
+
// have the field yet (and will because it's coming from an incoming XML file),
|
|
373
|
+
// the commit code which saves the actual file (like say a .jpg file) is never
|
|
374
|
+
// called. Rather, the field is populated via getCode() instead which doesn't
|
|
375
|
+
// actually save the attached file. This commit is called before the basic-syntax-plugin's
|
|
376
|
+
// ObjectShape commiter, so we populate the Now.attach field so that the NowAttachPlugin's
|
|
377
|
+
// commit functiong gets called.
|
|
378
|
+
{
|
|
379
|
+
shape: ObjectShape,
|
|
380
|
+
async commit(shape, target) {
|
|
381
|
+
if (!ts.Node.isObjectLiteralExpression(target)) {
|
|
382
|
+
return { success: false }
|
|
383
|
+
}
|
|
384
|
+
const attachShapes = shape
|
|
385
|
+
.entries({ resolve: false })
|
|
386
|
+
.filter(([name, value]) => value.is(NowAttachShape) && !target.getProperty(name))
|
|
387
|
+
.map(([name, shape]) => {
|
|
388
|
+
return {
|
|
389
|
+
name: ObjectShape.quotePropertyNameIfNeeded(name),
|
|
390
|
+
initializer: shape.getCode(),
|
|
391
|
+
kind: ts.StructureKind.PropertyAssignment,
|
|
392
|
+
}
|
|
393
|
+
}) as ts.PropertyAssignmentStructure[]
|
|
394
|
+
|
|
395
|
+
if (attachShapes.length > 0) {
|
|
396
|
+
target.addPropertyAssignments(attachShapes)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return { success: false }
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
})
|
package/src/now-config-plugin.ts
CHANGED
|
@@ -130,6 +130,10 @@ export const NowConfigPlugin = Plugin.create({
|
|
|
130
130
|
return { success: false }
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
if (rawConfig.type === 'configuration') {
|
|
134
|
+
return { success: false }
|
|
135
|
+
}
|
|
136
|
+
|
|
133
137
|
const config = Shape.from(file.getJson(), rawConfig).asObject()
|
|
134
138
|
const scope = config.get('scope').asString().getValue()
|
|
135
139
|
|
|
@@ -139,8 +143,8 @@ export const NowConfigPlugin = Plugin.create({
|
|
|
139
143
|
let packageJsonPath: string
|
|
140
144
|
try {
|
|
141
145
|
packageJsonPath = NowConfig.moduleResolutionPath(rawConfig, packageJson, false, 'package.json')
|
|
142
|
-
} catch (e
|
|
143
|
-
diagnostics.error(file, e.message)
|
|
146
|
+
} catch (e) {
|
|
147
|
+
diagnostics.error(file, (e as Error).message)
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
const accessControls = config.get('accessControls').ifDefined()?.asObject()
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Shape,
|
|
10
10
|
FileSystem,
|
|
11
11
|
type Transform,
|
|
12
|
+
taxonomySchemaDefault,
|
|
12
13
|
} from '@servicenow/sdk-build-core'
|
|
13
14
|
import { CallExpressionPlugin } from './call-expression-plugin'
|
|
14
15
|
|
|
@@ -43,9 +44,15 @@ export class NowIncludeShape extends CallExpressionShape {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
static async fromRecord(record: Record, text: string | Shape, transform: Transform): Promise<NowIncludeShape> {
|
|
47
|
+
const scriptType = taxonomySchemaDefault[record.getTable()]
|
|
48
|
+
const scriptIdentifier = scriptType?.startsWith('client-development')
|
|
49
|
+
? '.client'
|
|
50
|
+
: scriptType?.startsWith('server-development')
|
|
51
|
+
? '.server'
|
|
52
|
+
: ''
|
|
46
53
|
return new NowIncludeShape({
|
|
47
54
|
source: record,
|
|
48
|
-
path: `./${await transform.getUpdateName(record)}.js`,
|
|
55
|
+
path: `./${await transform.getUpdateName(record)}${scriptIdentifier}.js`,
|
|
49
56
|
includedText: text instanceof Shape ? text.toString().getValue() : text,
|
|
50
57
|
})
|
|
51
58
|
}
|
|
@@ -16,7 +16,7 @@ export const PackageJsonPlugin = Plugin.create({
|
|
|
16
16
|
{
|
|
17
17
|
shape: JsonFileShape,
|
|
18
18
|
async toRecord(file, { config, packageJson, project, factory, fs, logger }) {
|
|
19
|
-
if (file.getBaseName() !== 'package.json') {
|
|
19
|
+
if (file.getBaseName() !== 'package.json' || config.type === 'configuration') {
|
|
20
20
|
return { success: false }
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -45,7 +45,7 @@ export const PackageJsonPlugin = Plugin.create({
|
|
|
45
45
|
path: sysModulePath,
|
|
46
46
|
content: Shape.from(
|
|
47
47
|
file,
|
|
48
|
-
await fixDependencyVersion(file.getJson(), {
|
|
48
|
+
await fixDependencyVersion(file.getJson().asObject(), {
|
|
49
49
|
fs,
|
|
50
50
|
logger,
|
|
51
51
|
rootDir: project.getRootDir(),
|
|
@@ -71,7 +71,7 @@ async function fixDependencyVersion(json: ObjectShape, context: { fs: FileSystem
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const repack = await RepackService.create(context.logger, context.fs, context.rootDir)
|
|
74
|
-
const resolvedDeps = {}
|
|
74
|
+
const resolvedDeps: { [key: string]: string } = {}
|
|
75
75
|
for (const dep of deps.keys()) {
|
|
76
76
|
const { name, version } = await repack.getResolvedDepDetails(dep)
|
|
77
77
|
resolvedDeps[name] = version
|