@servicenow/sdk-build-plugins 4.2.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acl-plugin.js +11 -0
- package/dist/acl-plugin.js.map +1 -1
- package/dist/applicability-plugin.d.ts +2 -0
- package/dist/applicability-plugin.js +72 -0
- package/dist/applicability-plugin.js.map +1 -0
- package/dist/atf/test-plugin.js +5 -2
- package/dist/atf/test-plugin.js.map +1 -1
- package/dist/basic-syntax-plugin.js +7 -1
- package/dist/basic-syntax-plugin.js.map +1 -1
- package/dist/business-rule-plugin.js +1 -0
- package/dist/business-rule-plugin.js.map +1 -1
- package/dist/call-expression-plugin.js +1 -107
- package/dist/call-expression-plugin.js.map +1 -1
- package/dist/column/column-to-record.d.ts +10 -3
- package/dist/column/column-to-record.js +44 -7
- package/dist/column/column-to-record.js.map +1 -1
- package/dist/column-plugin.d.ts +3 -1
- package/dist/column-plugin.js +12 -12
- package/dist/column-plugin.js.map +1 -1
- package/dist/dashboard/dashboard-component-property-defaults.d.ts +152 -0
- package/dist/dashboard/dashboard-component-property-defaults.js +264 -0
- package/dist/dashboard/dashboard-component-property-defaults.js.map +1 -0
- package/dist/dashboard/dashboard-component-resolver.d.ts +13 -0
- package/dist/dashboard/dashboard-component-resolver.js +69 -0
- package/dist/dashboard/dashboard-component-resolver.js.map +1 -0
- package/dist/dashboard/dashboard-plugin.d.ts +12 -0
- package/dist/dashboard/dashboard-plugin.js +397 -0
- package/dist/dashboard/dashboard-plugin.js.map +1 -0
- package/dist/data-plugin.d.ts +3 -0
- package/dist/data-plugin.js +61 -113
- package/dist/data-plugin.js.map +1 -1
- package/dist/email-notification-plugin.d.ts +2 -0
- package/dist/email-notification-plugin.js +541 -0
- package/dist/email-notification-plugin.js.map +1 -0
- package/dist/flow/constants/flow-plugin-constants.d.ts +58 -0
- package/dist/flow/constants/flow-plugin-constants.js +70 -0
- package/dist/flow/constants/flow-plugin-constants.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-constants.d.ts +38 -0
- package/dist/flow/flow-logic/flow-logic-constants.js +118 -0
- package/dist/flow/flow-logic/flow-logic-constants.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-diagnostics.d.ts +19 -0
- package/dist/flow/flow-logic/flow-logic-diagnostics.js +503 -0
- package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +62 -0
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +2092 -0
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-plugin.d.ts +52 -0
- package/dist/flow/flow-logic/flow-logic-plugin.js +283 -0
- package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -0
- package/dist/flow/flow-logic/flow-logic-shapes.d.ts +104 -0
- package/dist/flow/flow-logic/flow-logic-shapes.js +201 -0
- package/dist/flow/flow-logic/flow-logic-shapes.js.map +1 -0
- package/dist/flow/plugins/approval-rules-plugin.d.ts +2 -0
- package/dist/flow/plugins/approval-rules-plugin.js +49 -0
- package/dist/flow/plugins/approval-rules-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-action-definition-plugin.d.ts +2 -0
- package/dist/flow/plugins/flow-action-definition-plugin.js +286 -0
- package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-data-pill-plugin.d.ts +9 -0
- package/dist/flow/plugins/flow-data-pill-plugin.js +212 -0
- package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-definition-plugin.d.ts +2 -0
- package/dist/flow/plugins/flow-definition-plugin.js +1668 -0
- package/dist/flow/plugins/flow-definition-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +26 -0
- package/dist/flow/plugins/flow-diagnostics-plugin.js +217 -0
- package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-instance-plugin.d.ts +12 -0
- package/dist/flow/plugins/flow-instance-plugin.js +1205 -0
- package/dist/flow/plugins/flow-instance-plugin.js.map +1 -0
- package/dist/flow/plugins/flow-trigger-instance-plugin.d.ts +2 -0
- package/dist/flow/plugins/flow-trigger-instance-plugin.js +338 -0
- package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -0
- package/dist/flow/plugins/inline-script-plugin.d.ts +39 -0
- package/dist/flow/plugins/inline-script-plugin.js +80 -0
- package/dist/flow/plugins/inline-script-plugin.js.map +1 -0
- package/dist/flow/plugins/step-definition-plugin.d.ts +5 -0
- package/dist/flow/plugins/step-definition-plugin.js +71 -0
- package/dist/flow/plugins/step-definition-plugin.js.map +1 -0
- package/dist/flow/plugins/step-instance-plugin.d.ts +31 -0
- package/dist/flow/plugins/step-instance-plugin.js +339 -0
- package/dist/flow/plugins/step-instance-plugin.js.map +1 -0
- package/dist/flow/plugins/trigger-plugin.d.ts +2 -0
- package/dist/flow/plugins/trigger-plugin.js +96 -0
- package/dist/flow/plugins/trigger-plugin.js.map +1 -0
- package/dist/flow/plugins/wfa-datapill-plugin.d.ts +15 -0
- package/dist/flow/plugins/wfa-datapill-plugin.js +178 -0
- package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -0
- package/dist/flow/utils/approval-rules-processor.d.ts +13 -0
- package/dist/flow/utils/approval-rules-processor.js +267 -0
- package/dist/flow/utils/approval-rules-processor.js.map +1 -0
- package/dist/flow/utils/built-in-complex-objects.d.ts +19 -0
- package/dist/flow/utils/built-in-complex-objects.js +62 -0
- package/dist/flow/utils/built-in-complex-objects.js.map +1 -0
- package/dist/flow/utils/complex-object-resolver.d.ts +8 -0
- package/dist/flow/utils/complex-object-resolver.js +614 -0
- package/dist/flow/utils/complex-object-resolver.js.map +1 -0
- package/dist/flow/utils/complex-objects.d.ts +36 -0
- package/dist/flow/utils/complex-objects.js +481 -0
- package/dist/flow/utils/complex-objects.js.map +1 -0
- package/dist/flow/utils/data-pill-shapes.d.ts +58 -0
- package/dist/flow/utils/data-pill-shapes.js +135 -0
- package/dist/flow/utils/data-pill-shapes.js.map +1 -0
- package/dist/flow/utils/datapill-transformer.d.ts +110 -0
- package/dist/flow/utils/datapill-transformer.js +503 -0
- package/dist/flow/utils/datapill-transformer.js.map +1 -0
- package/dist/flow/utils/flow-constants.d.ts +72 -0
- package/dist/flow/utils/flow-constants.js +230 -0
- package/dist/flow/utils/flow-constants.js.map +1 -0
- package/dist/flow/utils/flow-io-to-record.d.ts +44 -0
- package/dist/flow/utils/flow-io-to-record.js +409 -0
- package/dist/flow/utils/flow-io-to-record.js.map +1 -0
- package/dist/flow/utils/flow-shapes.d.ts +161 -0
- package/dist/flow/utils/flow-shapes.js +255 -0
- package/dist/flow/utils/flow-shapes.js.map +1 -0
- package/dist/flow/utils/flow-to-xml.d.ts +16 -0
- package/dist/flow/utils/flow-to-xml.js +237 -0
- package/dist/flow/utils/flow-to-xml.js.map +1 -0
- package/dist/flow/utils/flow-variable-processor.d.ts +51 -0
- package/dist/flow/utils/flow-variable-processor.js +69 -0
- package/dist/flow/utils/flow-variable-processor.js.map +1 -0
- package/dist/flow/utils/label-cache-parser.d.ts +7 -0
- package/dist/flow/utils/label-cache-parser.js +24 -0
- package/dist/flow/utils/label-cache-parser.js.map +1 -0
- package/dist/flow/utils/label-cache-processor.d.ts +119 -0
- package/dist/flow/utils/label-cache-processor.js +719 -0
- package/dist/flow/utils/label-cache-processor.js.map +1 -0
- package/dist/flow/utils/pill-string-parser.d.ts +88 -0
- package/dist/flow/utils/pill-string-parser.js +306 -0
- package/dist/flow/utils/pill-string-parser.js.map +1 -0
- package/dist/flow/utils/schema-to-flow-object.d.ts +22 -0
- package/dist/flow/utils/schema-to-flow-object.js +318 -0
- package/dist/flow/utils/schema-to-flow-object.js.map +1 -0
- package/dist/flow/utils/service-catalog.d.ts +47 -0
- package/dist/flow/utils/service-catalog.js +137 -0
- package/dist/flow/utils/service-catalog.js.map +1 -0
- package/dist/flow/utils/utils.d.ts +117 -0
- package/dist/flow/utils/utils.js +345 -0
- package/dist/flow/utils/utils.js.map +1 -0
- package/dist/index.d.ts +20 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/list-plugin.js +1 -1
- package/dist/list-plugin.js.map +1 -1
- package/dist/now-attach-plugin.d.ts +1 -0
- package/dist/now-attach-plugin.js +10 -10
- package/dist/now-attach-plugin.js.map +1 -1
- package/dist/now-ref-plugin.js +1 -1
- package/dist/now-ref-plugin.js.map +1 -1
- package/dist/record-plugin.d.ts +29 -0
- package/dist/record-plugin.js +66 -7
- package/dist/record-plugin.js.map +1 -1
- package/dist/repack/index.d.ts +2 -0
- package/dist/repack/index.js +8 -0
- package/dist/repack/index.js.map +1 -1
- package/dist/rest-api-plugin.js +54 -44
- package/dist/rest-api-plugin.js.map +1 -1
- package/dist/server-module-plugin/index.d.ts +10 -0
- package/dist/server-module-plugin/index.js +83 -59
- package/dist/server-module-plugin/index.js.map +1 -1
- package/dist/service-catalog/catalog-clientscript-plugin.d.ts +2 -0
- package/dist/service-catalog/catalog-clientscript-plugin.js +117 -0
- package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -0
- package/dist/service-catalog/catalog-item-plugin.d.ts +2 -0
- package/dist/service-catalog/catalog-item-plugin.js +115 -0
- package/dist/service-catalog/catalog-item-plugin.js.map +1 -0
- package/dist/service-catalog/catalog-ui-policy-plugin.d.ts +2 -0
- package/dist/service-catalog/catalog-ui-policy-plugin.js +266 -0
- package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -0
- package/dist/service-catalog/index.d.ts +5 -0
- package/dist/service-catalog/index.js +22 -0
- package/dist/service-catalog/index.js.map +1 -0
- package/dist/service-catalog/record-to-shape.d.ts +6 -0
- package/dist/service-catalog/record-to-shape.js +93 -0
- package/dist/service-catalog/record-to-shape.js.map +1 -0
- package/dist/service-catalog/sc-record-producer-plugin.d.ts +2 -0
- package/dist/service-catalog/sc-record-producer-plugin.js +140 -0
- package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -0
- package/dist/service-catalog/service-catalog-base.d.ts +311 -0
- package/dist/service-catalog/service-catalog-base.js +542 -0
- package/dist/service-catalog/service-catalog-base.js.map +1 -0
- package/dist/service-catalog/service-catalog-diagnostics.d.ts +45 -0
- package/dist/service-catalog/service-catalog-diagnostics.js +172 -0
- package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -0
- package/dist/service-catalog/shape-to-record.d.ts +8 -0
- package/dist/service-catalog/shape-to-record.js +235 -0
- package/dist/service-catalog/shape-to-record.js.map +1 -0
- package/dist/service-catalog/utils.d.ts +323 -0
- package/dist/service-catalog/utils.js +1216 -0
- package/dist/service-catalog/utils.js.map +1 -0
- package/dist/service-catalog/variable-helper.d.ts +43 -0
- package/dist/service-catalog/variable-helper.js +92 -0
- package/dist/service-catalog/variable-helper.js.map +1 -0
- package/dist/service-catalog/variable-set-plugin.d.ts +2 -0
- package/dist/service-catalog/variable-set-plugin.js +175 -0
- package/dist/service-catalog/variable-set-plugin.js.map +1 -0
- package/dist/service-catalog/variables-transform.d.ts +139 -0
- package/dist/service-catalog/variables-transform.js +403 -0
- package/dist/service-catalog/variables-transform.js.map +1 -0
- package/dist/sla/sla-validators.d.ts +61 -0
- package/dist/sla/sla-validators.js +224 -0
- package/dist/sla/sla-validators.js.map +1 -0
- package/dist/sla-plugin.d.ts +5 -0
- package/dist/sla-plugin.js +280 -0
- package/dist/sla-plugin.js.map +1 -0
- package/dist/static-content-plugin.js +25 -2
- package/dist/static-content-plugin.js.map +1 -1
- package/dist/table-plugin.js +32 -15
- package/dist/table-plugin.js.map +1 -1
- package/dist/ui-page-plugin.js +832 -19
- package/dist/ui-page-plugin.js.map +1 -1
- package/dist/ui-policy-plugin.js +5 -7
- package/dist/ui-policy-plugin.js.map +1 -1
- package/dist/utils.d.ts +10 -1
- package/dist/utils.js +16 -0
- package/dist/utils.js.map +1 -1
- package/dist/ux-list-menu-config-plugin.d.ts +2 -0
- package/dist/ux-list-menu-config-plugin.js +292 -0
- package/dist/ux-list-menu-config-plugin.js.map +1 -0
- package/dist/workspace-plugin/chrome-tab.d.ts +2 -0
- package/dist/workspace-plugin/chrome-tab.js +46 -0
- package/dist/workspace-plugin/chrome-tab.js.map +1 -0
- package/dist/workspace-plugin/constants.d.ts +52 -0
- package/dist/workspace-plugin/constants.js +56 -0
- package/dist/workspace-plugin/constants.js.map +1 -0
- package/dist/workspace-plugin/fluent-utils.d.ts +9 -0
- package/dist/workspace-plugin/fluent-utils.js +60 -0
- package/dist/workspace-plugin/fluent-utils.js.map +1 -0
- package/dist/workspace-plugin/page.d.ts +8 -0
- package/dist/workspace-plugin/page.js +108 -0
- package/dist/workspace-plugin/page.js.map +1 -0
- package/dist/workspace-plugin/screen.d.ts +1 -0
- package/dist/workspace-plugin/screen.js +38 -0
- package/dist/workspace-plugin/screen.js.map +1 -0
- package/dist/workspace-plugin/templates/index.d.ts +10 -0
- package/dist/workspace-plugin/templates/index.js +20 -0
- package/dist/workspace-plugin/templates/index.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-composition.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-composition.js +4043 -0
- package/dist/workspace-plugin/templates/record-page-composition.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-data.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-data.js +527 -0
- package/dist/workspace-plugin/templates/record-page-data.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-interalEventMappings.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-interalEventMappings.js +39 -0
- package/dist/workspace-plugin/templates/record-page-interalEventMappings.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-layoutModel.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-layoutModel.js +55 -0
- package/dist/workspace-plugin/templates/record-page-layoutModel.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page-properties.d.ts +1 -0
- package/dist/workspace-plugin/templates/record-page-properties.js +135 -0
- package/dist/workspace-plugin/templates/record-page-properties.js.map +1 -0
- package/dist/workspace-plugin/templates/record-page.d.ts +3 -0
- package/dist/workspace-plugin/templates/record-page.js +8 -0
- package/dist/workspace-plugin/templates/record-page.js.map +1 -0
- package/dist/workspace-plugin.d.ts +2 -0
- package/dist/workspace-plugin.js +453 -0
- package/dist/workspace-plugin.js.map +1 -0
- package/package.json +10 -12
- package/src/acl-plugin.ts +16 -1
- package/src/applicability-plugin.ts +82 -0
- package/src/atf/test-plugin.ts +6 -3
- package/src/basic-syntax-plugin.ts +10 -1
- package/src/business-rule-plugin.ts +2 -1
- package/src/call-expression-plugin.ts +2 -130
- package/src/column/column-to-record.ts +54 -8
- package/src/column-plugin.ts +29 -13
- package/src/dashboard/dashboard-component-property-defaults.ts +277 -0
- package/src/dashboard/dashboard-component-resolver.ts +69 -0
- package/src/dashboard/dashboard-plugin.ts +450 -0
- package/src/data-plugin.ts +67 -139
- package/src/email-notification-plugin.ts +850 -0
- package/src/flow/constants/flow-plugin-constants.ts +79 -0
- package/src/flow/flow-logic/flow-logic-constants.ts +120 -0
- package/src/flow/flow-logic/flow-logic-diagnostics.ts +591 -0
- package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +2550 -0
- package/src/flow/flow-logic/flow-logic-plugin.ts +337 -0
- package/src/flow/flow-logic/flow-logic-shapes.ts +215 -0
- package/src/flow/plugins/approval-rules-plugin.ts +48 -0
- package/src/flow/plugins/flow-action-definition-plugin.ts +295 -0
- package/src/flow/plugins/flow-data-pill-plugin.ts +258 -0
- package/src/flow/plugins/flow-definition-plugin.ts +2173 -0
- package/src/flow/plugins/flow-diagnostics-plugin.ts +280 -0
- package/src/flow/plugins/flow-instance-plugin.ts +1499 -0
- package/src/flow/plugins/flow-trigger-instance-plugin.ts +444 -0
- package/src/flow/plugins/inline-script-plugin.ts +83 -0
- package/src/flow/plugins/step-definition-plugin.ts +67 -0
- package/src/flow/plugins/step-instance-plugin.ts +431 -0
- package/src/flow/plugins/trigger-plugin.ts +95 -0
- package/src/flow/plugins/wfa-datapill-plugin.ts +213 -0
- package/src/flow/utils/approval-rules-processor.ts +298 -0
- package/src/flow/utils/built-in-complex-objects.ts +81 -0
- package/src/flow/utils/complex-object-resolver.ts +875 -0
- package/src/flow/utils/complex-objects.ts +656 -0
- package/src/flow/utils/data-pill-shapes.ts +165 -0
- package/src/flow/utils/datapill-transformer.ts +632 -0
- package/src/flow/utils/flow-constants.ts +285 -0
- package/src/flow/utils/flow-io-to-record.ts +533 -0
- package/src/flow/utils/flow-shapes.ts +296 -0
- package/src/flow/utils/flow-to-xml.ts +318 -0
- package/src/flow/utils/flow-variable-processor.ts +100 -0
- package/src/flow/utils/label-cache-parser.ts +37 -0
- package/src/flow/utils/label-cache-processor.ts +870 -0
- package/src/flow/utils/pill-string-parser.ts +375 -0
- package/src/flow/utils/schema-to-flow-object.ts +385 -0
- package/src/flow/utils/service-catalog.ts +174 -0
- package/src/flow/utils/utils.ts +395 -0
- package/src/index.ts +20 -1
- package/src/list-plugin.ts +1 -1
- package/src/now-attach-plugin.ts +14 -11
- package/src/now-ref-plugin.ts +1 -1
- package/src/record-plugin.ts +76 -11
- package/src/repack/index.ts +14 -0
- package/src/rest-api-plugin.ts +62 -50
- package/src/server-module-plugin/index.ts +112 -86
- package/src/service-catalog/catalog-clientscript-plugin.ts +140 -0
- package/src/service-catalog/catalog-item-plugin.ts +162 -0
- package/src/service-catalog/catalog-ui-policy-plugin.ts +324 -0
- package/src/service-catalog/index.ts +5 -0
- package/src/service-catalog/record-to-shape.ts +109 -0
- package/src/service-catalog/sc-record-producer-plugin.ts +201 -0
- package/src/service-catalog/service-catalog-base.ts +600 -0
- package/src/service-catalog/service-catalog-diagnostics.ts +254 -0
- package/src/service-catalog/shape-to-record.ts +279 -0
- package/src/service-catalog/utils.ts +1455 -0
- package/src/service-catalog/variable-helper.ts +135 -0
- package/src/service-catalog/variable-set-plugin.ts +197 -0
- package/src/service-catalog/variables-transform.ts +438 -0
- package/src/sla/sla-validators.ts +331 -0
- package/src/sla-plugin.ts +358 -0
- package/src/static-content-plugin.ts +25 -2
- package/src/table-plugin.ts +49 -16
- package/src/ui-page-plugin.ts +1063 -20
- package/src/ui-policy-plugin.ts +5 -9
- package/src/utils.ts +24 -1
- package/src/ux-list-menu-config-plugin.ts +312 -0
- package/src/workspace-plugin/chrome-tab.ts +44 -0
- package/src/workspace-plugin/constants.ts +53 -0
- package/src/workspace-plugin/fluent-utils.ts +60 -0
- package/src/workspace-plugin/page.ts +139 -0
- package/src/workspace-plugin/screen.ts +34 -0
- package/src/workspace-plugin/templates/index.ts +17 -0
- package/src/workspace-plugin/templates/record-page-composition.ts +4051 -0
- package/src/workspace-plugin/templates/record-page-data.ts +523 -0
- package/src/workspace-plugin/templates/record-page-interalEventMappings.ts +35 -0
- package/src/workspace-plugin/templates/record-page-layoutModel.ts +51 -0
- package/src/workspace-plugin/templates/record-page-properties.ts +131 -0
- package/src/workspace-plugin/templates/record-page.ts +6 -0
- package/src/workspace-plugin.ts +574 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import { CallExpressionShape, type ObjectShape, Plugin, type Record as RecordType } from '@servicenow/sdk-build-core'
|
|
2
|
+
import { NowIdShape } from '../now-id-plugin'
|
|
3
|
+
import { resolveComponentToSysId, resolveComponentToName } from './dashboard-component-resolver'
|
|
4
|
+
import { DEFAULT_PROPERTY_VALUES, removeRestrictedValues } from './dashboard-component-property-defaults'
|
|
5
|
+
|
|
6
|
+
const transformWidget = (widget: RecordType) =>
|
|
7
|
+
widget.transform(({ $ }) => ({
|
|
8
|
+
$id: $.val(NowIdShape.from(widget)),
|
|
9
|
+
component: $.map((v) => resolveComponentToName(v.toString().getValue())),
|
|
10
|
+
componentProps: $.from('component_props')
|
|
11
|
+
.map((v) => {
|
|
12
|
+
const json = v.ifString()?.getValue()
|
|
13
|
+
const props = json ? JSON.parse(json) : v.getValue()
|
|
14
|
+
return removeRestrictedValues(props)
|
|
15
|
+
})
|
|
16
|
+
.def(DEFAULT_PROPERTY_VALUES),
|
|
17
|
+
height: $.from('h').toNumber(),
|
|
18
|
+
width: $.from('w').toNumber(),
|
|
19
|
+
position: $.map(() => ({
|
|
20
|
+
x: widget.get('x').toNumber().getValue(),
|
|
21
|
+
y: widget.get('y').toNumber().getValue(),
|
|
22
|
+
})),
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
const createWidgetProperties = (widgetData: ObjectShape, canvas: ObjectShape) =>
|
|
26
|
+
widgetData.transform(({ $ }) => ({
|
|
27
|
+
canvas: $.val(canvas),
|
|
28
|
+
component: $.map((v) => resolveComponentToSysId(v.toString().getValue())),
|
|
29
|
+
component_props: $.from('componentProps').map((v) => {
|
|
30
|
+
const props = v.getValue() || {}
|
|
31
|
+
|
|
32
|
+
return JSON.stringify({ ...DEFAULT_PROPERTY_VALUES, ...props })
|
|
33
|
+
}),
|
|
34
|
+
h: $.from('height').toNumber(),
|
|
35
|
+
w: $.from('width').toNumber(),
|
|
36
|
+
x: $.from('position').map((v) => {
|
|
37
|
+
const posObj = v.asObject()
|
|
38
|
+
return posObj.get('x').toNumber().getValue()
|
|
39
|
+
}),
|
|
40
|
+
y: $.from('position').map((v) => {
|
|
41
|
+
const posObj = v.asObject()
|
|
42
|
+
return posObj.get('y').toNumber().getValue()
|
|
43
|
+
}),
|
|
44
|
+
}))
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Creates a Dashboard (`par_dashboard`).
|
|
48
|
+
*
|
|
49
|
+
* @param config - an object containing the following properties:
|
|
50
|
+
* * **$id** - unique id for the record, typically using `Now.ID["value"]`
|
|
51
|
+
* * **name** - The name of the dashboard
|
|
52
|
+
* * **tabs**? - Array of dashboard tabs (each with $id, name, and widgets array)
|
|
53
|
+
* * **visibilities**? - Array of visibility rules (each with $id and experience reference)
|
|
54
|
+
* * **permissions**? - Array of user permissions (each with $id, user, can_read, can_write, can_share, owner)
|
|
55
|
+
*/
|
|
56
|
+
export const DashboardPlugin = Plugin.create({
|
|
57
|
+
name: 'DashboardPlugin',
|
|
58
|
+
records: {
|
|
59
|
+
par_dashboard: {
|
|
60
|
+
relationships: {
|
|
61
|
+
par_dashboard_tab: {
|
|
62
|
+
via: 'dashboard',
|
|
63
|
+
descendant: true,
|
|
64
|
+
relationships: {
|
|
65
|
+
par_dashboard_canvas: {
|
|
66
|
+
via: 'dashboard_tab',
|
|
67
|
+
descendant: true,
|
|
68
|
+
relationships: {
|
|
69
|
+
par_dashboard_widget: {
|
|
70
|
+
via: 'canvas',
|
|
71
|
+
descendant: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
par_dashboard_canvas: {
|
|
78
|
+
via: 'dashboard',
|
|
79
|
+
descendant: true,
|
|
80
|
+
relationships: {
|
|
81
|
+
par_dashboard_widget: {
|
|
82
|
+
via: 'canvas',
|
|
83
|
+
descendant: true,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
par_dashboard_visibility: {
|
|
88
|
+
via: 'dashboard',
|
|
89
|
+
descendant: true,
|
|
90
|
+
},
|
|
91
|
+
par_dashboard_permission: {
|
|
92
|
+
via: 'dashboard',
|
|
93
|
+
descendant: true,
|
|
94
|
+
relationships: {
|
|
95
|
+
sys_user: {
|
|
96
|
+
via: 'user',
|
|
97
|
+
inverse: true,
|
|
98
|
+
},
|
|
99
|
+
sys_user_group: {
|
|
100
|
+
via: 'group',
|
|
101
|
+
inverse: true,
|
|
102
|
+
},
|
|
103
|
+
sys_user_role: {
|
|
104
|
+
via: 'role',
|
|
105
|
+
inverse: true,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
toShape(record, { descendants }) {
|
|
111
|
+
const topCanvas = descendants.query('par_dashboard_canvas').find((c) => {
|
|
112
|
+
const tabField = c.get('dashboard_tab')
|
|
113
|
+
return (
|
|
114
|
+
!tabField ||
|
|
115
|
+
tabField.getValue() === undefined ||
|
|
116
|
+
tabField.getValue() === null ||
|
|
117
|
+
tabField.getValue() === ''
|
|
118
|
+
)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const topWidgets = topCanvas
|
|
122
|
+
? descendants
|
|
123
|
+
.query('par_dashboard_widget')
|
|
124
|
+
.filter((w) => {
|
|
125
|
+
const canvasField = w.get('canvas')
|
|
126
|
+
const canvasValue = canvasField.isRecord()
|
|
127
|
+
? canvasField.asRecord().getId().getValue()
|
|
128
|
+
: canvasField.asRecordId().getValue()
|
|
129
|
+
return canvasValue === topCanvas.getId().getValue()
|
|
130
|
+
})
|
|
131
|
+
.map(transformWidget)
|
|
132
|
+
: []
|
|
133
|
+
|
|
134
|
+
const topLayout = topWidgets.length > 0 ? { widgets: topWidgets } : undefined
|
|
135
|
+
|
|
136
|
+
const tabs = descendants
|
|
137
|
+
.query('par_dashboard_tab')
|
|
138
|
+
.sort((a, b) => a.get('order').toNumber().getValue() - b.get('order').toNumber().getValue())
|
|
139
|
+
.map((tab) => {
|
|
140
|
+
// Find the canvas for this tab
|
|
141
|
+
const canvas = descendants.query('par_dashboard_canvas').find((c) => {
|
|
142
|
+
const tabField = c.get('dashboard_tab')
|
|
143
|
+
if (
|
|
144
|
+
!tabField ||
|
|
145
|
+
tabField.getValue() === undefined ||
|
|
146
|
+
tabField.getValue() === null ||
|
|
147
|
+
tabField.getValue() === ''
|
|
148
|
+
) {
|
|
149
|
+
return false
|
|
150
|
+
}
|
|
151
|
+
const tabValue = tabField.isRecord()
|
|
152
|
+
? tabField.asRecord().getId().getValue()
|
|
153
|
+
: tabField.asRecordId().getValue()
|
|
154
|
+
return tabValue === tab.getId().getValue()
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
const widgets = canvas
|
|
158
|
+
? descendants
|
|
159
|
+
.query('par_dashboard_widget')
|
|
160
|
+
.filter((w) => {
|
|
161
|
+
const canvasField = w.get('canvas')
|
|
162
|
+
const canvasValue = canvasField.isRecord()
|
|
163
|
+
? canvasField.asRecord().getId().getValue()
|
|
164
|
+
: canvasField.asRecordId().getValue()
|
|
165
|
+
return canvasValue === canvas.getId().getValue()
|
|
166
|
+
})
|
|
167
|
+
.map(transformWidget)
|
|
168
|
+
: []
|
|
169
|
+
|
|
170
|
+
return tab.transform(({ $ }) => ({
|
|
171
|
+
$id: $.val(NowIdShape.from(tab)),
|
|
172
|
+
name: $,
|
|
173
|
+
active: $.toBoolean().def(true),
|
|
174
|
+
widgets: $.val(widgets),
|
|
175
|
+
}))
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
const visibilities = descendants.query('par_dashboard_visibility').map((visibility) => {
|
|
179
|
+
return visibility.transform(({ $ }) => ({
|
|
180
|
+
$id: $.val(NowIdShape.from(visibility)),
|
|
181
|
+
experience: $.from('experience').def(''),
|
|
182
|
+
}))
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
const permissions = descendants.query('par_dashboard_permission').map((permission) =>
|
|
186
|
+
permission.transform(({ $ }) => {
|
|
187
|
+
const hasUser = permission.get('user').asString().getValue() || false
|
|
188
|
+
const hasRole = permission.get('role').asString().getValue() || false
|
|
189
|
+
const hasGroup = permission.get('group').asString().getValue() || false
|
|
190
|
+
|
|
191
|
+
const permissionSubject = hasUser
|
|
192
|
+
? { user: $ }
|
|
193
|
+
: hasRole
|
|
194
|
+
? { role: $ }
|
|
195
|
+
: hasGroup
|
|
196
|
+
? { group: $ }
|
|
197
|
+
: {}
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
$id: $.val(NowIdShape.from(permission)),
|
|
201
|
+
canRead: $.from('can_read').toBoolean(),
|
|
202
|
+
canShare: $.from('can_share').toBoolean(),
|
|
203
|
+
canWrite: $.from('can_write').toBoolean(),
|
|
204
|
+
owner: $.toBoolean(),
|
|
205
|
+
...permissionSubject,
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
const dashboardShape = record.transform(({ $ }) => ({
|
|
211
|
+
$id: $.val(NowIdShape.from(record)),
|
|
212
|
+
name: $,
|
|
213
|
+
active: $.toBoolean().def(true),
|
|
214
|
+
tabs: $.val(tabs).def([]),
|
|
215
|
+
visibilities: $.val(visibilities).def([]),
|
|
216
|
+
permissions: $.val(permissions).def([]),
|
|
217
|
+
topLayout: $.val(topLayout),
|
|
218
|
+
}))
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
success: true,
|
|
222
|
+
value: new CallExpressionShape({
|
|
223
|
+
source: record,
|
|
224
|
+
callee: 'Dashboard',
|
|
225
|
+
args: [dashboardShape],
|
|
226
|
+
}),
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
par_dashboard_tab: {
|
|
231
|
+
relationships: {
|
|
232
|
+
par_dashboard_canvas: {
|
|
233
|
+
via: 'dashboard_tab',
|
|
234
|
+
descendant: true,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
par_dashboard_canvas: {
|
|
239
|
+
coalesce: ['dashboard', 'dashboard_tab'],
|
|
240
|
+
relationships: {
|
|
241
|
+
par_dashboard_widget: {
|
|
242
|
+
via: 'canvas',
|
|
243
|
+
descendant: true,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
par_dashboard_visibility: {
|
|
248
|
+
coalesce: ['dashboard', 'experience'],
|
|
249
|
+
},
|
|
250
|
+
par_dashboard_widget: {},
|
|
251
|
+
par_dashboard_user_metadata: {},
|
|
252
|
+
|
|
253
|
+
par_dashboard_permission: {
|
|
254
|
+
coalesce: ['dashboard', 'user', 'group', 'role'],
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
shapes: [
|
|
258
|
+
{
|
|
259
|
+
shape: CallExpressionShape,
|
|
260
|
+
fileTypes: ['fluent'],
|
|
261
|
+
async toRecord(source, { factory }) {
|
|
262
|
+
if (source.getCallee() !== 'Dashboard') {
|
|
263
|
+
return { success: false }
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const arg = source.getArgument(0).asObject()
|
|
267
|
+
|
|
268
|
+
const dashboard = await factory.createRecord({
|
|
269
|
+
source: source,
|
|
270
|
+
table: 'par_dashboard',
|
|
271
|
+
explicitId: arg.get('$id'),
|
|
272
|
+
properties: arg.transform(({ $ }) => ({
|
|
273
|
+
name: $,
|
|
274
|
+
active: $.def(true),
|
|
275
|
+
})),
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
const topLayoutRecords: RecordType[] = []
|
|
279
|
+
|
|
280
|
+
// Process top layout
|
|
281
|
+
if (arg.get('topLayout').ifObject()) {
|
|
282
|
+
const topLayout = arg.get('topLayout').asObject()
|
|
283
|
+
|
|
284
|
+
const topCanvas = await factory.createRecord({
|
|
285
|
+
source,
|
|
286
|
+
table: 'par_dashboard_canvas',
|
|
287
|
+
properties: {
|
|
288
|
+
dashboard: dashboard,
|
|
289
|
+
},
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
const topWidgets = topLayout.get('widgets').ifArray()?.getElements() ?? []
|
|
293
|
+
|
|
294
|
+
topLayoutRecords.push(topCanvas)
|
|
295
|
+
|
|
296
|
+
for (const widgetObj of topWidgets) {
|
|
297
|
+
const widgetData = widgetObj.asObject()
|
|
298
|
+
const widget = await factory.createRecord({
|
|
299
|
+
source: widgetObj,
|
|
300
|
+
table: 'par_dashboard_widget',
|
|
301
|
+
explicitId: widgetData.get('$id'),
|
|
302
|
+
properties: createWidgetProperties(widgetData, topCanvas),
|
|
303
|
+
})
|
|
304
|
+
topLayoutRecords.push(widget)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Process tabs
|
|
309
|
+
const tabs = arg.get('tabs').ifArray()?.getElements() ?? []
|
|
310
|
+
const tabRecords: RecordType[] = []
|
|
311
|
+
|
|
312
|
+
for (const [index, tabObj] of tabs.entries()) {
|
|
313
|
+
const tabData = tabObj.asObject()
|
|
314
|
+
const tab = await factory.createRecord({
|
|
315
|
+
source: tabObj,
|
|
316
|
+
table: 'par_dashboard_tab',
|
|
317
|
+
explicitId: tabData.get('$id'),
|
|
318
|
+
properties: tabData.transform(({ $ }) => ({
|
|
319
|
+
dashboard: $.val(dashboard),
|
|
320
|
+
name: $,
|
|
321
|
+
order: $.val(index),
|
|
322
|
+
active: $.def(true),
|
|
323
|
+
})),
|
|
324
|
+
})
|
|
325
|
+
tabRecords.push(tab)
|
|
326
|
+
|
|
327
|
+
// Create canvas for this tab
|
|
328
|
+
const canvas = await factory.createRecord({
|
|
329
|
+
source: tabObj,
|
|
330
|
+
table: 'par_dashboard_canvas',
|
|
331
|
+
properties: {
|
|
332
|
+
dashboard: dashboard,
|
|
333
|
+
dashboard_tab: tab,
|
|
334
|
+
},
|
|
335
|
+
})
|
|
336
|
+
tabRecords.push(canvas)
|
|
337
|
+
|
|
338
|
+
// Process widgets for this tab's canvas
|
|
339
|
+
const widgets = tabData.get('widgets').ifArray()?.getElements() ?? []
|
|
340
|
+
for (const widgetObj of widgets) {
|
|
341
|
+
const widgetData = widgetObj.asObject()
|
|
342
|
+
const widget = await factory.createRecord({
|
|
343
|
+
source: widgetObj,
|
|
344
|
+
table: 'par_dashboard_widget',
|
|
345
|
+
explicitId: widgetData.get('$id'),
|
|
346
|
+
properties: createWidgetProperties(widgetData, canvas),
|
|
347
|
+
})
|
|
348
|
+
tabRecords.push(widget)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// Process visibilities
|
|
353
|
+
const visibilities = arg.get('visibilities').ifArray()?.getElements() ?? []
|
|
354
|
+
const visibilityRecords: RecordType[] = []
|
|
355
|
+
|
|
356
|
+
if (visibilities.length === 0) {
|
|
357
|
+
// Add default visibility if none provided
|
|
358
|
+
visibilityRecords.push(
|
|
359
|
+
await factory.createRecord({
|
|
360
|
+
source: source,
|
|
361
|
+
table: 'par_dashboard_visibility',
|
|
362
|
+
properties: {
|
|
363
|
+
dashboard: dashboard,
|
|
364
|
+
experience: '08c73d60537101100834ddeeff7b1287',
|
|
365
|
+
},
|
|
366
|
+
})
|
|
367
|
+
)
|
|
368
|
+
} else {
|
|
369
|
+
for (const visibility of visibilities) {
|
|
370
|
+
const visibilityObj = visibility.asObject()
|
|
371
|
+
|
|
372
|
+
visibilityRecords.push(
|
|
373
|
+
await factory.createRecord({
|
|
374
|
+
source: visibility,
|
|
375
|
+
table: 'par_dashboard_visibility',
|
|
376
|
+
explicitId: visibilityObj.get('$id'),
|
|
377
|
+
properties: visibilityObj.transform(({ $ }) => {
|
|
378
|
+
return {
|
|
379
|
+
dashboard: $.val(dashboard),
|
|
380
|
+
experience: $.from('experience'),
|
|
381
|
+
}
|
|
382
|
+
}),
|
|
383
|
+
})
|
|
384
|
+
)
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Process permissions
|
|
389
|
+
const permissions = arg.get('permissions').ifArray()?.getElements() ?? []
|
|
390
|
+
const permissionRecords: RecordType[] = []
|
|
391
|
+
|
|
392
|
+
for (const permission of permissions) {
|
|
393
|
+
const permissionObj = permission.asObject()
|
|
394
|
+
|
|
395
|
+
// Build properties object
|
|
396
|
+
const properties: Record<string, unknown> = {
|
|
397
|
+
dashboard: dashboard,
|
|
398
|
+
can_read: permissionObj.get('canRead').ifUndefined()
|
|
399
|
+
? true
|
|
400
|
+
: permissionObj.get('canRead').getValue(),
|
|
401
|
+
can_write: permissionObj.get('canWrite').ifUndefined()
|
|
402
|
+
? false
|
|
403
|
+
: permissionObj.get('canWrite').getValue(),
|
|
404
|
+
can_share: permissionObj.get('canShare').ifUndefined()
|
|
405
|
+
? false
|
|
406
|
+
: permissionObj.get('canShare').getValue(),
|
|
407
|
+
owner: permissionObj.get('owner').ifUndefined() ? false : permissionObj.get('owner').getValue(),
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Handle user reference (optional)
|
|
411
|
+
const userValue = permissionObj.get('user')
|
|
412
|
+
if (!userValue.ifUndefined()) {
|
|
413
|
+
properties['user'] = userValue
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Handle group reference (optional)
|
|
417
|
+
const groupValue = permissionObj.get('group')
|
|
418
|
+
if (!groupValue.ifUndefined()) {
|
|
419
|
+
properties['group'] = groupValue
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Handle role reference (optional)
|
|
423
|
+
const roleValue = permissionObj.get('role')
|
|
424
|
+
if (!roleValue.ifUndefined()) {
|
|
425
|
+
properties['role'] = roleValue
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
permissionRecords.push(
|
|
429
|
+
await factory.createRecord({
|
|
430
|
+
source: permission,
|
|
431
|
+
table: 'par_dashboard_permission',
|
|
432
|
+
explicitId: permissionObj.get('$id'),
|
|
433
|
+
properties: properties,
|
|
434
|
+
})
|
|
435
|
+
)
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return {
|
|
439
|
+
success: true,
|
|
440
|
+
value: dashboard.with(
|
|
441
|
+
...topLayoutRecords,
|
|
442
|
+
...tabRecords,
|
|
443
|
+
...visibilityRecords,
|
|
444
|
+
...permissionRecords
|
|
445
|
+
),
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
],
|
|
450
|
+
})
|