@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,656 @@
|
|
|
1
|
+
// biome-ignore-all lint/suspicious/noExplicitAny: This file builds dynamic complex object schemas
|
|
2
|
+
import { CallExpressionShape, type ObjectShape, type Diagnostics } from '@servicenow/sdk-build-core'
|
|
3
|
+
|
|
4
|
+
import { COLUMN_API_TO_TYPE } from '../../column/column-helper'
|
|
5
|
+
import { ELEMENT_MAPPING_PROVIDER } from './flow-constants'
|
|
6
|
+
|
|
7
|
+
const ALLOWED_ARRAY_TYPES = ['String', 'Integer', 'Boolean', 'Date', 'Reference']
|
|
8
|
+
const ALLOWED_OBJECT_TYPES = ['Choice', 'String', 'Integer', 'Boolean', 'Date', 'Reference']
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Maps column types to their corresponding schema types
|
|
12
|
+
*/
|
|
13
|
+
const COLUMN_TYPE_TO_SCHEMA_TYPE = {
|
|
14
|
+
string: 'String',
|
|
15
|
+
object: 'Object',
|
|
16
|
+
integer: 'Integer',
|
|
17
|
+
decimal: 'Decimal',
|
|
18
|
+
number: 'Number',
|
|
19
|
+
boolean: 'Boolean',
|
|
20
|
+
glide_date_time: 'Date',
|
|
21
|
+
choice: 'Choice',
|
|
22
|
+
'array.string': 'String',
|
|
23
|
+
'array.integer': 'Integer',
|
|
24
|
+
'array.object': 'Object',
|
|
25
|
+
'array.boolean': 'Boolean',
|
|
26
|
+
'array.datetime': 'Date',
|
|
27
|
+
reference: 'Reference',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Maps ServiceNow column types to their array UI type equivalents
|
|
32
|
+
* For example: 'glide_date_time' -> 'datetime' (for use in 'array.datetime')
|
|
33
|
+
*/
|
|
34
|
+
const COLUMN_TYPE_TO_ARRAY_UI_TYPE: Record<string, string> = {
|
|
35
|
+
glide_date_time: 'datetime',
|
|
36
|
+
string: 'string',
|
|
37
|
+
integer: 'integer',
|
|
38
|
+
boolean: 'boolean',
|
|
39
|
+
reference: 'reference',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Maps API column types -> schema types (defaults to 'String')
|
|
43
|
+
const mapApiToSchema = (api: string): string =>
|
|
44
|
+
COLUMN_TYPE_TO_SCHEMA_TYPE[COLUMN_API_TO_TYPE[api] as keyof typeof COLUMN_TYPE_TO_SCHEMA_TYPE] ?? 'String' //TODO.. probably throw if the value doesn't exist
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Default max_length for fields inside FlowArray elements.
|
|
48
|
+
* These fields need higher max_length to accommodate larger data structures.
|
|
49
|
+
*/
|
|
50
|
+
const MAX_LENGTH_ARRAY_ELEMENT = 65000
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Default max_length for regular fields (not inside FlowArray elements).
|
|
54
|
+
*/
|
|
55
|
+
const MAX_LENGTH_REGULAR_FIELD = 0
|
|
56
|
+
|
|
57
|
+
type FacetFieldParams = {
|
|
58
|
+
type: string
|
|
59
|
+
config: ObjectShape
|
|
60
|
+
field: string
|
|
61
|
+
order: number
|
|
62
|
+
choiceOption?: string
|
|
63
|
+
mandatoryOverride?: boolean
|
|
64
|
+
columnApiType?: string
|
|
65
|
+
isArrayElement?: boolean
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const buildFieldFacet = ({
|
|
69
|
+
type,
|
|
70
|
+
config,
|
|
71
|
+
field,
|
|
72
|
+
order,
|
|
73
|
+
choiceOption = '',
|
|
74
|
+
columnApiType,
|
|
75
|
+
isArrayElement = false,
|
|
76
|
+
}: FacetFieldParams) => {
|
|
77
|
+
const result: Record<string, string> = {}
|
|
78
|
+
// Map schema types to their uiTypeLabel
|
|
79
|
+
const uiTypeLabel =
|
|
80
|
+
type === 'Boolean' ? 'True/False' : type === 'Date' && columnApiType === 'DateTimeColumn' ? 'Date/Time' : type
|
|
81
|
+
// Use the column API type to determine the correct uiType
|
|
82
|
+
const uiType = columnApiType ? COLUMN_API_TO_TYPE[columnApiType] || type.toLowerCase() : type.toLowerCase()
|
|
83
|
+
|
|
84
|
+
const additionalProperties: globalThis.Record<string, unknown> = {}
|
|
85
|
+
|
|
86
|
+
// Handle reference columns - extract reference table
|
|
87
|
+
if (uiType === 'reference') {
|
|
88
|
+
const referenceTable = config.get('referenceTable')?.ifString()?.getValue()
|
|
89
|
+
if (referenceTable) {
|
|
90
|
+
additionalProperties['reference'] = referenceTable
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Fields inside FlowArray elements should have higher default max_length
|
|
95
|
+
const defaultMaxLength = isArrayElement ? MAX_LENGTH_ARRAY_ELEMENT : MAX_LENGTH_REGULAR_FIELD
|
|
96
|
+
|
|
97
|
+
result['SimpleMapFacet'] = JSON.stringify({
|
|
98
|
+
uiTypeLabel,
|
|
99
|
+
read_only: 'false',
|
|
100
|
+
uiType,
|
|
101
|
+
choiceOption,
|
|
102
|
+
default_value: String(config.get('default')?.ifDefined()?.getValue() ?? ''),
|
|
103
|
+
hint: config.get('hint')?.ifString()?.getValue() ?? '',
|
|
104
|
+
label: config.get('label')?.ifString()?.getValue() ?? field,
|
|
105
|
+
mandatory: String(config.get('mandatory')?.ifBoolean()?.getValue() ?? false),
|
|
106
|
+
order: `${order + 1}`,
|
|
107
|
+
max_length: String(config.get('maxLength')?.ifDefined()?.getValue() ?? defaultMaxLength),
|
|
108
|
+
...additionalProperties,
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
if (type === 'Choice') {
|
|
112
|
+
const choices = config.get('choices')?.ifDefined()?.asObject()
|
|
113
|
+
if (!choices) {
|
|
114
|
+
return result
|
|
115
|
+
}
|
|
116
|
+
result['SimpleChoiceFacet'] = JSON.stringify({
|
|
117
|
+
complex_choice_map_key$: {},
|
|
118
|
+
choice_map_key$: choices.keys().reduce<Record<string, string>>((acc, key, i) => {
|
|
119
|
+
const choiceValue = choices.get(key)
|
|
120
|
+
let choiceLabel = ''
|
|
121
|
+
let order = i + 1
|
|
122
|
+
if (choiceValue.isString()) {
|
|
123
|
+
choiceLabel = choiceValue.getValue()
|
|
124
|
+
} else {
|
|
125
|
+
choiceLabel = choiceValue.asObject().get('label')?.ifString()?.getValue() ?? key
|
|
126
|
+
order = choiceValue.asObject().get('sequence')?.ifNumber()?.getValue() ?? i + 1
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
acc[choiceLabel] = JSON.stringify({ label: choiceLabel, value: key, order })
|
|
130
|
+
return acc
|
|
131
|
+
}, {}),
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return result
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const buildArrayFieldFacet = ({
|
|
139
|
+
type,
|
|
140
|
+
config,
|
|
141
|
+
element,
|
|
142
|
+
field,
|
|
143
|
+
order,
|
|
144
|
+
choiceOption = '',
|
|
145
|
+
actionId,
|
|
146
|
+
columnApiType,
|
|
147
|
+
}: {
|
|
148
|
+
type: string
|
|
149
|
+
config: ObjectShape
|
|
150
|
+
element: ObjectShape
|
|
151
|
+
field: string
|
|
152
|
+
order: number
|
|
153
|
+
choiceOption?: string
|
|
154
|
+
actionId: string
|
|
155
|
+
columnApiType?: string
|
|
156
|
+
}) => {
|
|
157
|
+
const label = config.get('label')?.ifString()?.getValue() ?? field
|
|
158
|
+
const childName = config?.get('childName')?.ifString()?.getValue() || `${field}_child0`
|
|
159
|
+
const childLabel = element.get('label')?.ifString()?.getValue() ?? field
|
|
160
|
+
|
|
161
|
+
// Determine the correct uiType for arrays
|
|
162
|
+
// For DateTimeColumn: columnApiType='DateTimeColumn' -> columnType='glide_date_time' -> arrayUiType='datetime'
|
|
163
|
+
let arrayUiType = type.toLowerCase()
|
|
164
|
+
if (columnApiType) {
|
|
165
|
+
const columnType = COLUMN_API_TO_TYPE[columnApiType]
|
|
166
|
+
if (columnType && COLUMN_TYPE_TO_ARRAY_UI_TYPE[columnType]) {
|
|
167
|
+
arrayUiType = COLUMN_TYPE_TO_ARRAY_UI_TYPE[columnType]
|
|
168
|
+
} else if (columnType) {
|
|
169
|
+
arrayUiType = columnType
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
SimpleMapFacet: JSON.stringify({
|
|
175
|
+
max_rows: null,
|
|
176
|
+
child_hint: '',
|
|
177
|
+
child_maxsize: '',
|
|
178
|
+
child_name: childName || `${field}_child0`,
|
|
179
|
+
child_label: childLabel || `${label}_child0`,
|
|
180
|
+
child_type_label: type,
|
|
181
|
+
child_type: arrayUiType,
|
|
182
|
+
child_defaultValue: '',
|
|
183
|
+
child_uiUniqueId: `${actionId}-${field}-child0`,
|
|
184
|
+
uiUniqueId: `${actionId}-${field}`,
|
|
185
|
+
uiTypeLabel: `Array.${type}`,
|
|
186
|
+
read_only: 'false',
|
|
187
|
+
uiType: `array.${arrayUiType}`,
|
|
188
|
+
choiceOption,
|
|
189
|
+
default_value: type === 'Boolean' ? 'false' : '',
|
|
190
|
+
hint: config.get('hint')?.ifString()?.getValue() ?? '',
|
|
191
|
+
label: label,
|
|
192
|
+
mandatory: String(config.get('mandatory')?.ifBoolean()?.getValue() ?? false),
|
|
193
|
+
order: `${order + 1}`,
|
|
194
|
+
max_length: String(config.get('maxLength')?.ifNumber()?.getValue() ?? 65000),
|
|
195
|
+
}),
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// ---------- Type facet ----------
|
|
200
|
+
|
|
201
|
+
const buildTypeFacet = (
|
|
202
|
+
complexObjectId: string,
|
|
203
|
+
actionId: string,
|
|
204
|
+
objectName: string,
|
|
205
|
+
label: string,
|
|
206
|
+
mandatory: boolean,
|
|
207
|
+
order: number
|
|
208
|
+
) => ({
|
|
209
|
+
//TODO: These fields exist in what FD generates but it is not clear that they are actually all required
|
|
210
|
+
SimpleMapFacet: JSON.stringify({
|
|
211
|
+
sourceId: '',
|
|
212
|
+
choiceOption: '',
|
|
213
|
+
default_value: '',
|
|
214
|
+
label: label || objectName,
|
|
215
|
+
mandatory: String(mandatory),
|
|
216
|
+
uiUniqueId: `${actionId}-${objectName}`, //this is windsurf generated slop but it might be good enough?
|
|
217
|
+
uiTypeLabel: 'Object',
|
|
218
|
+
co_type_name: complexObjectId,
|
|
219
|
+
read_only: 'false',
|
|
220
|
+
hint: null,
|
|
221
|
+
uiType: 'object',
|
|
222
|
+
order: `${order}`,
|
|
223
|
+
max_length: '65000', //TODO max length on complex objects is not enforced but this exists in what FD currently generates, check to see if we can clean it up and remove it
|
|
224
|
+
}),
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
// Build type facet for array types
|
|
228
|
+
const buildArrayTypeFacet = ({
|
|
229
|
+
complexObjectId,
|
|
230
|
+
actionId,
|
|
231
|
+
objectName,
|
|
232
|
+
parentConfig,
|
|
233
|
+
childConfig,
|
|
234
|
+
order,
|
|
235
|
+
elementType,
|
|
236
|
+
child,
|
|
237
|
+
columnApiType,
|
|
238
|
+
}: {
|
|
239
|
+
complexObjectId: string
|
|
240
|
+
actionId: string
|
|
241
|
+
objectName: string
|
|
242
|
+
parentConfig: ObjectShape
|
|
243
|
+
childConfig: ObjectShape
|
|
244
|
+
order: number
|
|
245
|
+
elementType: string
|
|
246
|
+
child: string
|
|
247
|
+
columnApiType?: string
|
|
248
|
+
}) => {
|
|
249
|
+
const label = parentConfig.get('label').ifString()?.getValue() || objectName
|
|
250
|
+
const hint = parentConfig.get('hint').ifString()?.getValue() || ''
|
|
251
|
+
const mandatory = parentConfig.get('mandatory').ifBoolean()?.getValue() || false
|
|
252
|
+
const maxRows = parentConfig.get('maxRows').ifNumber()?.getValue() || ''
|
|
253
|
+
const childLabel = childConfig.get('label').ifString()?.getValue() || `${objectName.toLowerCase()}_child0_label`
|
|
254
|
+
const childMaxLength = childConfig.get('maxLength').ifNumber()?.getValue() || 0
|
|
255
|
+
const childHint = childConfig.get('hint').ifString()?.getValue() || ''
|
|
256
|
+
const childDefaultValue = childConfig.get('default')?.ifDefined()?.getValue() || ''
|
|
257
|
+
const choiceOption = childConfig.get('dropdown')?.ifDefined()?.ifString()?.getValue() || ''
|
|
258
|
+
|
|
259
|
+
// Determine the correct uiType for arrays
|
|
260
|
+
// For DateTimeColumn: columnApiType='DateTimeColumn' -> columnType='glide_date_time' -> arrayUiType='datetime'
|
|
261
|
+
let arrayUiType = elementType.toLowerCase()
|
|
262
|
+
if (columnApiType) {
|
|
263
|
+
const columnType = COLUMN_API_TO_TYPE[columnApiType]
|
|
264
|
+
if (columnType && COLUMN_TYPE_TO_ARRAY_UI_TYPE[columnType]) {
|
|
265
|
+
arrayUiType = COLUMN_TYPE_TO_ARRAY_UI_TYPE[columnType]
|
|
266
|
+
} else if (columnType) {
|
|
267
|
+
arrayUiType = columnType
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
SimpleMapFacet: JSON.stringify({
|
|
273
|
+
sourceId: '',
|
|
274
|
+
max_rows: String(maxRows),
|
|
275
|
+
choiceOption: choiceOption,
|
|
276
|
+
default_value: '',
|
|
277
|
+
label: label || objectName,
|
|
278
|
+
child_hint: childHint,
|
|
279
|
+
child_maxsize: String(childMaxLength),
|
|
280
|
+
mandatory: String(mandatory),
|
|
281
|
+
child_name: child,
|
|
282
|
+
uiUniqueId: `${actionId}-${objectName}`,
|
|
283
|
+
uiTypeLabel: `Array.${elementType}`,
|
|
284
|
+
co_type_name: complexObjectId,
|
|
285
|
+
child_label: childLabel,
|
|
286
|
+
child_type_label: elementType,
|
|
287
|
+
read_only: 'false',
|
|
288
|
+
sourceUiUniqueId: '',
|
|
289
|
+
sourceType: '',
|
|
290
|
+
hint: hint,
|
|
291
|
+
uiType: `array.${arrayUiType}`,
|
|
292
|
+
child_defaultValue: String(childDefaultValue),
|
|
293
|
+
child_type: arrayUiType,
|
|
294
|
+
order: `${order}`,
|
|
295
|
+
max_length: '65000',
|
|
296
|
+
child_uiUniqueId: `${actionId}-${objectName}-child`,
|
|
297
|
+
}),
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function validateReferenceColumnUsage(
|
|
302
|
+
fieldType: string | undefined,
|
|
303
|
+
isFlowVariable: boolean,
|
|
304
|
+
diagnostics: Diagnostics,
|
|
305
|
+
source: CallExpressionShape
|
|
306
|
+
): void {
|
|
307
|
+
if (fieldType === 'ReferenceColumn' && !isFlowVariable) {
|
|
308
|
+
diagnostics.error(
|
|
309
|
+
source,
|
|
310
|
+
'Reference type fields are not allowed inside FlowObject or FlowArray structures when used in subflow or action inputs or outputs.'
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Create the resulting co schema for the fields of a complex object. This will recurse when
|
|
317
|
+
* a nested object is found.
|
|
318
|
+
*/
|
|
319
|
+
function createSchemaForFields(
|
|
320
|
+
fields: ObjectShape,
|
|
321
|
+
actionId: string,
|
|
322
|
+
diagnostics: Diagnostics,
|
|
323
|
+
isFlowVariable: boolean = false,
|
|
324
|
+
isArrayElement: boolean = false
|
|
325
|
+
): Record<string, any> {
|
|
326
|
+
const resultSchema: Record<string, any> = {}
|
|
327
|
+
fields.entries().forEach(([fieldName, fieldValue], order) => {
|
|
328
|
+
const fieldCallExpr = fieldValue.as(CallExpressionShape)
|
|
329
|
+
const fieldConfig = fieldCallExpr.getArgument(0)?.asObject()
|
|
330
|
+
const fieldType = fieldCallExpr.getCallee()
|
|
331
|
+
validateReferenceColumnUsage(fieldType, isFlowVariable, diagnostics, fieldCallExpr)
|
|
332
|
+
|
|
333
|
+
if (fieldType === 'FlowObject') {
|
|
334
|
+
const nestedFields = fieldConfig?.get('fields')?.asObject()
|
|
335
|
+
if (nestedFields) {
|
|
336
|
+
resultSchema[fieldName] = createSchemaForFields(
|
|
337
|
+
nestedFields,
|
|
338
|
+
actionId,
|
|
339
|
+
diagnostics,
|
|
340
|
+
isFlowVariable,
|
|
341
|
+
isArrayElement
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
resultSchema[`${fieldName}.$field_facets`] = buildFieldFacet({
|
|
346
|
+
type: 'Object',
|
|
347
|
+
config: fieldConfig,
|
|
348
|
+
field: fieldName,
|
|
349
|
+
order,
|
|
350
|
+
isArrayElement,
|
|
351
|
+
})
|
|
352
|
+
return
|
|
353
|
+
} else if (fieldType === 'FlowArray') {
|
|
354
|
+
// Handle FlowArray type
|
|
355
|
+
const elementType = fieldConfig?.get('elementType')?.as(CallExpressionShape)
|
|
356
|
+
const elementConfig = elementType?.getArgument(0)?.asObject()
|
|
357
|
+
const elementCallee = elementType?.getCallee()
|
|
358
|
+
|
|
359
|
+
let elementTypeString = 'Any' // Default to 'Any' if we can't determine
|
|
360
|
+
|
|
361
|
+
if (elementCallee === 'FlowObject') {
|
|
362
|
+
const nestedFields = elementConfig?.get('fields')?.asObject()
|
|
363
|
+
if (nestedFields) {
|
|
364
|
+
elementTypeString = 'Object'
|
|
365
|
+
// Create schema for nested FlowObject fields
|
|
366
|
+
// For nested FlowArrays with FlowObject elements, wrap in array with fieldName as key
|
|
367
|
+
// Mark nested fields as array elements for proper max_length defaults
|
|
368
|
+
const nestedSchema = createSchemaForFields(
|
|
369
|
+
nestedFields,
|
|
370
|
+
actionId,
|
|
371
|
+
diagnostics,
|
|
372
|
+
isFlowVariable,
|
|
373
|
+
true
|
|
374
|
+
)
|
|
375
|
+
resultSchema[fieldName] = [
|
|
376
|
+
{
|
|
377
|
+
[fieldName]: nestedSchema,
|
|
378
|
+
},
|
|
379
|
+
]
|
|
380
|
+
resultSchema[`${fieldName}.$field_facets`] = buildArrayFieldFacet({
|
|
381
|
+
type: elementTypeString,
|
|
382
|
+
config: fieldConfig,
|
|
383
|
+
element: elementConfig,
|
|
384
|
+
field: fieldName,
|
|
385
|
+
order,
|
|
386
|
+
actionId,
|
|
387
|
+
})
|
|
388
|
+
return
|
|
389
|
+
}
|
|
390
|
+
} else if (elementCallee) {
|
|
391
|
+
// For primitive types, map to appropriate schema type
|
|
392
|
+
elementTypeString = mapApiToSchema(elementCallee)
|
|
393
|
+
}
|
|
394
|
+
// For primitive arrays, always use "Any" in schema (ServiceNow requirement)
|
|
395
|
+
resultSchema[fieldName] = ['Any']
|
|
396
|
+
resultSchema[`${fieldName}.$field_facets`] = buildArrayFieldFacet({
|
|
397
|
+
type: elementTypeString,
|
|
398
|
+
config: fieldConfig,
|
|
399
|
+
element: elementConfig,
|
|
400
|
+
field: fieldName,
|
|
401
|
+
order,
|
|
402
|
+
actionId,
|
|
403
|
+
columnApiType: elementCallee, // Pass the column API type for correct uiType generation
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
return
|
|
407
|
+
} else {
|
|
408
|
+
//basic field type
|
|
409
|
+
const schemaType = mapApiToSchema(fieldType)
|
|
410
|
+
resultSchema[fieldName] = schemaType === 'Choice' ? 'String' : schemaType
|
|
411
|
+
validateObjectElementType(fieldCallExpr, schemaType, diagnostics)
|
|
412
|
+
|
|
413
|
+
if (schemaType === 'Choice') {
|
|
414
|
+
const isDynamic = fieldConfig.get('dynamicValueDefinitions')?.isDefined()
|
|
415
|
+
if (isDynamic) {
|
|
416
|
+
diagnostics.error(fieldConfig, 'Dynamic value definitions are not supported')
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
resultSchema[`${fieldName}.$field_facets`] = buildFieldFacet({
|
|
421
|
+
type: schemaType,
|
|
422
|
+
config: fieldConfig,
|
|
423
|
+
field: fieldName,
|
|
424
|
+
order,
|
|
425
|
+
columnApiType: fieldType,
|
|
426
|
+
isArrayElement,
|
|
427
|
+
})
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
|
|
431
|
+
return resultSchema
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Generate schema object from FlowObject or FlowArray structure
|
|
436
|
+
* @param objectConfig - The config of the FlowObject or FlowArray {fields/elementType, mandatory, label}
|
|
437
|
+
* @param complexObjectId - The ID of the complex object
|
|
438
|
+
* @param objectName - The name of the object
|
|
439
|
+
* @param actionId - The ID of the action
|
|
440
|
+
* @param order - The order of the object
|
|
441
|
+
* @param isArray - Whether this is a FlowArray type
|
|
442
|
+
* @param diagnostics - Diagnostics instance for error reporting
|
|
443
|
+
* @param isFlowVariable - Whether this is a flow variable (allows ReferenceColumn)
|
|
444
|
+
* @returns The generated schema object
|
|
445
|
+
*/
|
|
446
|
+
export function generateSchemaFromObject(
|
|
447
|
+
objectConfig: ObjectShape,
|
|
448
|
+
complexObjectId: string,
|
|
449
|
+
objectName: string,
|
|
450
|
+
actionId: string,
|
|
451
|
+
order: number,
|
|
452
|
+
isArray: boolean = false,
|
|
453
|
+
diagnostics: Diagnostics,
|
|
454
|
+
isFlowVariable: boolean = false
|
|
455
|
+
): Record<string, any> {
|
|
456
|
+
const rootKey = `FlowDesigner:${complexObjectId}`
|
|
457
|
+
const result: Record<string, any> = {}
|
|
458
|
+
|
|
459
|
+
if (isArray) {
|
|
460
|
+
// Handle FlowArray type
|
|
461
|
+
const elementShape = objectConfig.get('elementType')?.as(CallExpressionShape)
|
|
462
|
+
const elementCallee = elementShape?.getCallee()
|
|
463
|
+
validateReferenceColumnUsage(elementCallee, isFlowVariable, diagnostics, elementShape)
|
|
464
|
+
|
|
465
|
+
let collectionField: string | Record<string, unknown> = 'String' // Default
|
|
466
|
+
let elementTypeString: string | Record<string, unknown> = 'String' // Default
|
|
467
|
+
const child = objectConfig.get('childName').ifString()?.getValue() || `${objectName.toLowerCase()}_child0`
|
|
468
|
+
const config = elementShape.getArgument(0).asObject()
|
|
469
|
+
if (elementCallee === 'FlowObject') {
|
|
470
|
+
const schema = createSchemaForFields(
|
|
471
|
+
config.get('fields').asObject('fields property should be object shaped'),
|
|
472
|
+
actionId,
|
|
473
|
+
diagnostics,
|
|
474
|
+
isFlowVariable
|
|
475
|
+
)
|
|
476
|
+
collectionField = { [child]: schema }
|
|
477
|
+
elementTypeString = 'Object'
|
|
478
|
+
} else if (elementCallee) {
|
|
479
|
+
collectionField = mapApiToSchema(elementCallee)
|
|
480
|
+
elementTypeString = collectionField
|
|
481
|
+
|
|
482
|
+
// Validate the array element type
|
|
483
|
+
validateArrayElementType(elementShape, elementTypeString, diagnostics)
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// Attach the array type facets
|
|
487
|
+
const typeFacets = buildArrayTypeFacet({
|
|
488
|
+
complexObjectId,
|
|
489
|
+
actionId,
|
|
490
|
+
objectName,
|
|
491
|
+
parentConfig: objectConfig,
|
|
492
|
+
childConfig: config,
|
|
493
|
+
order,
|
|
494
|
+
elementType: elementTypeString,
|
|
495
|
+
child,
|
|
496
|
+
columnApiType: elementCallee, // Pass the column API type for correct uiType generation
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
// Create array schema structure
|
|
500
|
+
result[rootKey] = {
|
|
501
|
+
$COCollectionField: [collectionField],
|
|
502
|
+
'$COCollectionField.$field_facets': {
|
|
503
|
+
SimpleMapFacet: JSON.stringify({
|
|
504
|
+
'up-shift-collection-level': 'true',
|
|
505
|
+
}),
|
|
506
|
+
},
|
|
507
|
+
'$COCollectionField.$type_facets': typeFacets,
|
|
508
|
+
}
|
|
509
|
+
result[`${rootKey}.$type_facets`] = typeFacets
|
|
510
|
+
} else {
|
|
511
|
+
// Handle FlowObject type (original behavior)
|
|
512
|
+
result[rootKey] = createSchemaForFields(
|
|
513
|
+
objectConfig.get('fields').asObject('fields property should be object shaped'),
|
|
514
|
+
actionId,
|
|
515
|
+
diagnostics,
|
|
516
|
+
isFlowVariable
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
const label = objectConfig.get('label').ifString()?.getValue() || objectName
|
|
520
|
+
const mandatory = objectConfig.get('mandatory').ifBoolean()?.getValue() || false
|
|
521
|
+
|
|
522
|
+
// Attach the type facets for the root object
|
|
523
|
+
result[`${rootKey}.$type_facets`] = buildTypeFacet(
|
|
524
|
+
complexObjectId,
|
|
525
|
+
actionId,
|
|
526
|
+
objectName,
|
|
527
|
+
label,
|
|
528
|
+
mandatory,
|
|
529
|
+
order
|
|
530
|
+
)
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return result
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Generate variable schema object for FlowObject or FlowArray types
|
|
538
|
+
* @param schemaObject - The schema object
|
|
539
|
+
* @param complexObjectId - The ID of the complex object
|
|
540
|
+
* @param isArray - Whether this is a FlowArray type
|
|
541
|
+
* @returns The generated variable schema object
|
|
542
|
+
*/
|
|
543
|
+
export function generateVariableSchemaObject(
|
|
544
|
+
schemaObject: Record<string, unknown>,
|
|
545
|
+
complexObjectId: string,
|
|
546
|
+
isArray: boolean = false
|
|
547
|
+
): Record<string, unknown> {
|
|
548
|
+
const result: Record<string, unknown> = {}
|
|
549
|
+
|
|
550
|
+
result['version'] = '1.0'
|
|
551
|
+
|
|
552
|
+
if (isArray) {
|
|
553
|
+
// Handle FlowArray type
|
|
554
|
+
result['complexObject'] = {
|
|
555
|
+
name$: complexObjectId,
|
|
556
|
+
$COCollectionField: [],
|
|
557
|
+
}
|
|
558
|
+
} else {
|
|
559
|
+
// Handle FlowObject type
|
|
560
|
+
// Extract the object fields from the schema and convert to the required format
|
|
561
|
+
const rootKey = `FlowDesigner:${complexObjectId}`
|
|
562
|
+
const schemaFields = (schemaObject[rootKey] || {}) as Record<string, string>
|
|
563
|
+
const objectFields: Record<string, unknown> = {}
|
|
564
|
+
|
|
565
|
+
// Process each field in the schema, excluding special fields like $field_facets
|
|
566
|
+
Object.keys(schemaFields).forEach((key) => {
|
|
567
|
+
if (!key.includes('$')) {
|
|
568
|
+
objectFields[key] = {
|
|
569
|
+
$cv: {
|
|
570
|
+
$c: `java.lang.${schemaFields[key]}`,
|
|
571
|
+
$v: '',
|
|
572
|
+
},
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
})
|
|
576
|
+
|
|
577
|
+
result['complexObject'] = objectFields
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
result['complexObjectSchema'] = schemaObject
|
|
581
|
+
result['serializationFormat'] = 'JSON'
|
|
582
|
+
return result
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Get the attributes for a complex object
|
|
587
|
+
* @param schemaObject - The schema object
|
|
588
|
+
* @param complexObjectId - The ID of the complex object
|
|
589
|
+
* @param isArray - Whether this is a FlowArray type
|
|
590
|
+
* @returns The attributes for the complex object
|
|
591
|
+
*/
|
|
592
|
+
export function getComplexObjectAttributes(
|
|
593
|
+
schemaObject: Record<string, any>,
|
|
594
|
+
complexObjectId: string,
|
|
595
|
+
isArray: boolean
|
|
596
|
+
): Record<string, string> {
|
|
597
|
+
const typeFacets = JSON.parse(
|
|
598
|
+
schemaObject[`FlowDesigner:${complexObjectId}.$type_facets`]?.['SimpleMapFacet'] ?? '{}'
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
let result: Record<string, string> = {
|
|
602
|
+
co_type_name: typeFacets.co_type_name,
|
|
603
|
+
element_mapping_provider: ELEMENT_MAPPING_PROVIDER,
|
|
604
|
+
uiType: typeFacets.uiType,
|
|
605
|
+
uiTypeLabel: typeFacets.uiTypeLabel,
|
|
606
|
+
uiUniqueId: typeFacets.uiUniqueId,
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (isArray) {
|
|
610
|
+
result = {
|
|
611
|
+
...result,
|
|
612
|
+
child_maxsize: typeFacets.child_maxsize,
|
|
613
|
+
child_hint: typeFacets.child_hint,
|
|
614
|
+
child_label: typeFacets.child_label,
|
|
615
|
+
child_name: typeFacets.child_name,
|
|
616
|
+
child_type: typeFacets.child_type,
|
|
617
|
+
child_type_label: typeFacets.child_type_label,
|
|
618
|
+
child_uiUniqueId: typeFacets.child_uiUniqueId,
|
|
619
|
+
max_rows: typeFacets.max_rows,
|
|
620
|
+
child_defaultValue: typeFacets.child_defaultValue,
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return result
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Converts the output of getComplexObjectAttributes to a comma-separated string in the format key1=value1,key2=value2
|
|
629
|
+
* @param attributes - The attributes object returned by getComplexObjectAttributes
|
|
630
|
+
* @returns A comma-separated string of key-value pairs
|
|
631
|
+
*/
|
|
632
|
+
export function formatComplexObjectAttributes(attributes: globalThis.Record<string, string | boolean>): string {
|
|
633
|
+
return Object.entries(attributes)
|
|
634
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
635
|
+
.join(',')
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function validateArrayElementType(
|
|
639
|
+
elementType: CallExpressionShape,
|
|
640
|
+
elementTypeString: string,
|
|
641
|
+
diagnostics: Diagnostics
|
|
642
|
+
) {
|
|
643
|
+
if (!ALLOWED_ARRAY_TYPES.includes(elementTypeString)) {
|
|
644
|
+
diagnostics.error(elementType, 'Invalid array element type')
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
function validateObjectElementType(
|
|
649
|
+
elementType: CallExpressionShape,
|
|
650
|
+
elementTypeString: string,
|
|
651
|
+
diagnostics: Diagnostics
|
|
652
|
+
) {
|
|
653
|
+
if (!ALLOWED_OBJECT_TYPES.includes(elementTypeString)) {
|
|
654
|
+
diagnostics.error(elementType, 'Invalid array element type')
|
|
655
|
+
}
|
|
656
|
+
}
|