@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,533 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CallExpressionShape,
|
|
3
|
+
type Logger,
|
|
4
|
+
type Database,
|
|
5
|
+
type Diagnostics,
|
|
6
|
+
type Factory,
|
|
7
|
+
type ObjectShape,
|
|
8
|
+
type Record,
|
|
9
|
+
} from '@servicenow/sdk-build-core'
|
|
10
|
+
import {
|
|
11
|
+
addFieldsToColumn,
|
|
12
|
+
COLUMN_API_TO_TYPE,
|
|
13
|
+
COLUMN_TYPE_TO_API,
|
|
14
|
+
getDefaultMaxLength,
|
|
15
|
+
} from '../../column/column-helper'
|
|
16
|
+
import { ChoiceColumn, choiceDropdown, type choiceDropdownType, GenericColumn } from '@servicenow/sdk-core/runtime/db'
|
|
17
|
+
import { builtInComplexObjects } from './built-in-complex-objects'
|
|
18
|
+
import { buildComplexObjectFromSchema, parseAttributesToObject } from './schema-to-flow-object'
|
|
19
|
+
import {
|
|
20
|
+
formatComplexObjectAttributes,
|
|
21
|
+
generateSchemaFromObject,
|
|
22
|
+
generateVariableSchemaObject,
|
|
23
|
+
getComplexObjectAttributes,
|
|
24
|
+
} from './complex-objects'
|
|
25
|
+
import { getChoiceRecords, getDocumentationRecords } from '../../column/column-to-record'
|
|
26
|
+
|
|
27
|
+
import { ChoiceDropdown, COLUMN_DEFAULTS, createActionErrorAndStatusRecords } from './flow-constants'
|
|
28
|
+
import { NowIdShape } from '../../now-id-plugin'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to extract user-defined attributes from a column config's attributes object.
|
|
32
|
+
* Handles string, number, and boolean values.
|
|
33
|
+
*
|
|
34
|
+
* @param config - The ObjectShape containing the column configuration
|
|
35
|
+
* @returns A Record of attribute key-value pairs (all values converted to strings)
|
|
36
|
+
*/
|
|
37
|
+
function extractUserAttributes(config: ObjectShape): globalThis.Record<string, string> {
|
|
38
|
+
const userAttributes: globalThis.Record<string, string> = {}
|
|
39
|
+
const userAttributesObj = config.get('attributes')?.ifObject()?.asObject()
|
|
40
|
+
|
|
41
|
+
if (userAttributesObj) {
|
|
42
|
+
const entries = userAttributesObj.entries()
|
|
43
|
+
for (const [key, value] of entries) {
|
|
44
|
+
userAttributes[key] = value.getValue()?.toString() ?? ''
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return userAttributes
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Generate the variable records and possibly complex object records for the inputs or outputs
|
|
53
|
+
* of an action/subflow. The main input here is the ObjectShape for a single set of inputs or outputs
|
|
54
|
+
* of an action/subflow definition.
|
|
55
|
+
*/
|
|
56
|
+
export async function buildVariableRecords(options: {
|
|
57
|
+
variablesConfig: ObjectShape
|
|
58
|
+
parentRecord: Record
|
|
59
|
+
factory: Factory
|
|
60
|
+
diagnostics: Diagnostics
|
|
61
|
+
parentTable: string
|
|
62
|
+
varTable: string
|
|
63
|
+
isOutput?: boolean
|
|
64
|
+
}): Promise<{ variableRecords: Record[]; complexObjectRecords: Record[] }> {
|
|
65
|
+
const { variablesConfig, parentRecord, factory, diagnostics, parentTable, varTable, isOutput = false } = options
|
|
66
|
+
|
|
67
|
+
const records: Record[] = []
|
|
68
|
+
const complexObjects: Record[] = []
|
|
69
|
+
|
|
70
|
+
const tableName = `var__m_${varTable}_${parentRecord.getId().getValue()}`
|
|
71
|
+
const entries = variablesConfig.entries()
|
|
72
|
+
for (const [i, [k, v]] of entries.entries()) {
|
|
73
|
+
const callExpr = v.as(CallExpressionShape)
|
|
74
|
+
const config = callExpr.getArgument(0).asObject()
|
|
75
|
+
const props = config.transform(({ $ }) => ({
|
|
76
|
+
element: $.val(k),
|
|
77
|
+
label: $.def(k),
|
|
78
|
+
mandatory: $.toBoolean().def(false),
|
|
79
|
+
active: $.val(true),
|
|
80
|
+
order: $.val(i + 1),
|
|
81
|
+
hint: $.def(''),
|
|
82
|
+
model: $.val(parentRecord),
|
|
83
|
+
model_id: $.val(parentRecord),
|
|
84
|
+
model_table: $.val(parentTable),
|
|
85
|
+
name: $.val(tableName),
|
|
86
|
+
default_value: $.from('default').def(''),
|
|
87
|
+
}))
|
|
88
|
+
const partialVarRecord = await factory.createRecord({
|
|
89
|
+
source: callExpr,
|
|
90
|
+
table: varTable,
|
|
91
|
+
properties: props,
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const additionalProperties: globalThis.Record<string, unknown> = {}
|
|
95
|
+
const varSysId = partialVarRecord.getId().getValue()
|
|
96
|
+
if (callExpr.getCallee() === 'FlowObject' || callExpr.getCallee() === 'FlowArray') {
|
|
97
|
+
// Create a new complex-object schema row
|
|
98
|
+
const co_type_name = config.get('co_type_name')?.ifString()?.getValue()
|
|
99
|
+
const complexObjectId = co_type_name || `FD${varSysId}`
|
|
100
|
+
const isArray = callExpr.getCallee() === 'FlowArray'
|
|
101
|
+
const isFlowVariable = varTable === 'sys_hub_flow_variable'
|
|
102
|
+
const schemaObj = generateSchemaFromObject(
|
|
103
|
+
config,
|
|
104
|
+
complexObjectId,
|
|
105
|
+
k,
|
|
106
|
+
parentRecord.getId().getValue(),
|
|
107
|
+
i,
|
|
108
|
+
isArray,
|
|
109
|
+
diagnostics,
|
|
110
|
+
isFlowVariable
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
// Use explicit $id from config if provided (for non-deterministic complex objects from UI)
|
|
114
|
+
const explicitId = config.get('$id')?.ifString()?.getValue()
|
|
115
|
+
|
|
116
|
+
const complexRecord = await factory.createRecord({
|
|
117
|
+
source: callExpr,
|
|
118
|
+
table: 'sys_complex_object',
|
|
119
|
+
properties: {
|
|
120
|
+
name: complexObjectId,
|
|
121
|
+
namespace: 'FlowDesigner',
|
|
122
|
+
type: callExpr.getCallee() === 'FlowArray' ? 'complex_object_collection' : 'complex_object_schema',
|
|
123
|
+
serialized_content: JSON.stringify(schemaObj),
|
|
124
|
+
...(explicitId ? { sys_id: explicitId } : {}),
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const systemAttributes = getComplexObjectAttributes(schemaObj, complexObjectId, isArray)
|
|
129
|
+
// Extract user-defined attributes from column config if present (e.g., visible: 'false')
|
|
130
|
+
const userAttributes = extractUserAttributes(config)
|
|
131
|
+
// Merge system attributes with user-defined attributes
|
|
132
|
+
const allAttributes = { ...systemAttributes, ...userAttributes }
|
|
133
|
+
additionalProperties['attributes'] = formatComplexObjectAttributes(allAttributes)
|
|
134
|
+
additionalProperties['internal_type'] = 'string'
|
|
135
|
+
additionalProperties['max_length'] = 65000
|
|
136
|
+
|
|
137
|
+
complexObjects.push(complexRecord)
|
|
138
|
+
|
|
139
|
+
// Create additional sys_variable_value record for FlowObject and FlowArray types, but only for outputs
|
|
140
|
+
if (isOutput) {
|
|
141
|
+
const variableValue = generateVariableSchemaObject(schemaObj, complexObjectId, isArray)
|
|
142
|
+
const variableValueRecord = await createVariableValueRecord({
|
|
143
|
+
callExpr,
|
|
144
|
+
factory,
|
|
145
|
+
varSysId,
|
|
146
|
+
parentRecord,
|
|
147
|
+
parentTable,
|
|
148
|
+
name: k,
|
|
149
|
+
index: i,
|
|
150
|
+
variableValue,
|
|
151
|
+
})
|
|
152
|
+
records.push(variableValueRecord)
|
|
153
|
+
}
|
|
154
|
+
const updatedCallExpr = addFieldsToColumn({ name: k, table: tableName, display: false }, callExpr)
|
|
155
|
+
const columnRecords = await getDocumentationRecords(updatedCallExpr, {}, factory, diagnostics, true)
|
|
156
|
+
records.push(...columnRecords)
|
|
157
|
+
} else {
|
|
158
|
+
// Extract attributes from column config if present
|
|
159
|
+
const userAttributes = extractUserAttributes(config)
|
|
160
|
+
const attributesStr = Object.entries(userAttributes)
|
|
161
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
162
|
+
.join(',')
|
|
163
|
+
additionalProperties['attributes'] = attributesStr
|
|
164
|
+
let internal_type: string
|
|
165
|
+
if (callExpr.getCallee() === GenericColumn.name) {
|
|
166
|
+
internal_type = config.get('columnType')?.ifString()?.getValue() ?? 'string'
|
|
167
|
+
} else {
|
|
168
|
+
internal_type = COLUMN_API_TO_TYPE[callExpr.getCallee() as keyof typeof COLUMN_API_TO_TYPE] ?? 'string'
|
|
169
|
+
}
|
|
170
|
+
// Handle reference columns - extract reference table
|
|
171
|
+
if (internal_type === 'reference') {
|
|
172
|
+
const referenceTable = config.get('referenceTable')?.ifString()?.getValue()
|
|
173
|
+
if (referenceTable) {
|
|
174
|
+
additionalProperties['reference'] = referenceTable
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
additionalProperties['internal_type'] = internal_type
|
|
178
|
+
additionalProperties['max_length'] =
|
|
179
|
+
config.get('maxLength')?.ifNumber()?.getValue() ?? getDefaultMaxLength(internal_type)
|
|
180
|
+
const updatedCallExpr = addFieldsToColumn({ name: k, table: tableName, display: false }, callExpr)
|
|
181
|
+
const columnRecords = await getColumnRecords(updatedCallExpr, factory, diagnostics)
|
|
182
|
+
records.push(...columnRecords)
|
|
183
|
+
|
|
184
|
+
if (internal_type === 'choice') {
|
|
185
|
+
validateAndPopulateChoiceProperties(config, additionalProperties, diagnostics)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const varRecord = partialVarRecord.merge(additionalProperties)
|
|
190
|
+
records.push(varRecord)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (isOutput) {
|
|
194
|
+
const additionalOutputs = await createActionErrorAndStatusRecords(
|
|
195
|
+
parentRecord,
|
|
196
|
+
tableName,
|
|
197
|
+
varTable,
|
|
198
|
+
factory,
|
|
199
|
+
diagnostics
|
|
200
|
+
)
|
|
201
|
+
records.push(...additionalOutputs)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return { variableRecords: records, complexObjectRecords: complexObjects }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Generate an object corresponding to the variable records passed in.
|
|
209
|
+
*
|
|
210
|
+
* For each variable record passed in there will be a key/value in the return value where
|
|
211
|
+
* the key is the element name of the variable record and the value is a call expression corresponding
|
|
212
|
+
* to the details of that variable record. The call expressions match the FlowValueType and can be
|
|
213
|
+
* a Column or a FlowObject (FlowArrays are currently not yet handled)
|
|
214
|
+
*
|
|
215
|
+
* If the variable record has a co_object_name attribute we will lookup a corresponding sys_complex_object
|
|
216
|
+
* record where the name field matches the attributes value. That complex object record will hold the schema
|
|
217
|
+
* for this object input in the serialized_content column. We use that data to construct the related call expression
|
|
218
|
+
* data for the full flow object definition
|
|
219
|
+
*
|
|
220
|
+
* @param variableRecords Records representing inputs or outputs (sys_hub_*_input / output)
|
|
221
|
+
* @param ctx Plugin context object supplied by build-core plugin
|
|
222
|
+
*/
|
|
223
|
+
export function buildVariableShapes(
|
|
224
|
+
variableRecords: Record[],
|
|
225
|
+
descendants: Database,
|
|
226
|
+
logger?: Logger
|
|
227
|
+
): globalThis.Record<string, CallExpressionShape> | undefined {
|
|
228
|
+
const shapes: globalThis.Record<string, CallExpressionShape> = {}
|
|
229
|
+
|
|
230
|
+
for (const variable of variableRecords) {
|
|
231
|
+
const name = variable.get('element').asString().getValue()
|
|
232
|
+
|
|
233
|
+
if (name === '__action_status__' || name === '__dont_treat_as_error__') {
|
|
234
|
+
continue
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const callExpressionName =
|
|
238
|
+
COLUMN_TYPE_TO_API[variable.get('internal_type').asString().getValue()] ?? GenericColumn.name
|
|
239
|
+
const additionalProps = {}
|
|
240
|
+
|
|
241
|
+
// Detect FlowObject variables by looking for a co_type_name attribute.
|
|
242
|
+
const attributesStr = variable.get('attributes')?.ifString()?.getValue() ?? ''
|
|
243
|
+
const attributes = parseAttributesToObject(attributesStr)
|
|
244
|
+
|
|
245
|
+
if (attributes.dynamic === 'true') {
|
|
246
|
+
logger?.warn(`Unsupported data type found for input = ${name}, falling back to Record() api`)
|
|
247
|
+
return undefined
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const maybeCoTypeName = attributes.co_type_name
|
|
251
|
+
if (maybeCoTypeName !== undefined) {
|
|
252
|
+
const coRecord = descendants.query('sys_complex_object', { name: maybeCoTypeName })
|
|
253
|
+
|
|
254
|
+
// First try descendants, then fallback to built-in complex objects
|
|
255
|
+
let serializedContent = coRecord[0]?.get('serialized_content')?.ifString()?.getValue()
|
|
256
|
+
let complexObjectSysId: string | undefined = coRecord[0]?.getId().getValue()
|
|
257
|
+
if (!serializedContent) {
|
|
258
|
+
// Check built-in complex objects
|
|
259
|
+
const builtIn = builtInComplexObjects[maybeCoTypeName]
|
|
260
|
+
serializedContent = builtIn?.data.serialized_content
|
|
261
|
+
complexObjectSysId = undefined // Built-in objects don't have a sys_id
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (!serializedContent) {
|
|
265
|
+
throw new Error(`unable to find sys_complex_object with co_type_name: ${maybeCoTypeName}`)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Check if co_type_name is deterministically generated (pattern: FD<variable_sys_id>)
|
|
269
|
+
const varSysId = variable.getId().getValue()
|
|
270
|
+
const isDeterministic = maybeCoTypeName === `FD${varSysId}`
|
|
271
|
+
|
|
272
|
+
// Only include $id and co_type_name if NOT deterministically generated
|
|
273
|
+
const schema = JSON.parse(serializedContent)
|
|
274
|
+
shapes[name] = buildComplexObjectFromSchema(
|
|
275
|
+
variable,
|
|
276
|
+
schema,
|
|
277
|
+
attributes,
|
|
278
|
+
isDeterministic ? undefined : complexObjectSysId,
|
|
279
|
+
isDeterministic ? undefined : maybeCoTypeName
|
|
280
|
+
)
|
|
281
|
+
} else {
|
|
282
|
+
const variableName = variable.get('name').ifString()?.getValue()
|
|
283
|
+
const documentation = variableName
|
|
284
|
+
? descendants.query('sys_documentation', { name: variableName, element: name })
|
|
285
|
+
: []
|
|
286
|
+
|
|
287
|
+
shapes[name] = buildBasicVariableShape(
|
|
288
|
+
callExpressionName,
|
|
289
|
+
variable,
|
|
290
|
+
additionalProps,
|
|
291
|
+
descendants,
|
|
292
|
+
documentation
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return shapes
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function buildBasicVariableShape(
|
|
301
|
+
callExpressionName: string,
|
|
302
|
+
variable: Record,
|
|
303
|
+
additionalProps: globalThis.Record<string, unknown>,
|
|
304
|
+
descendants: Database,
|
|
305
|
+
documentation: Record[]
|
|
306
|
+
) {
|
|
307
|
+
if (callExpressionName === ChoiceColumn.name) {
|
|
308
|
+
// choice column with choices from other table
|
|
309
|
+
const choiceTable = variable.get('choice_table').ifString()?.getValue()
|
|
310
|
+
if (choiceTable && choiceTable !== '') {
|
|
311
|
+
additionalProps = {
|
|
312
|
+
dynamicValueDefinitions: {
|
|
313
|
+
type: 'choices_from_other_table',
|
|
314
|
+
table: choiceTable,
|
|
315
|
+
field: variable.get('choice_field').asString().getValue(),
|
|
316
|
+
},
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
const name = variable.get('name').ifString()?.getValue()
|
|
320
|
+
const element = variable.get('element').ifString()?.getValue()
|
|
321
|
+
const choices = descendants.query('sys_choice', { name, element })
|
|
322
|
+
additionalProps = {
|
|
323
|
+
choices: choices.reduce<
|
|
324
|
+
globalThis.Record<string, { label?: string | undefined; sequence?: number | undefined }>
|
|
325
|
+
>((acc, choice) => {
|
|
326
|
+
const value = choice.get('value').ifString()?.getValue()
|
|
327
|
+
const sequence = Number(choice.get('sequence').ifString()?.getValue() ?? 0)
|
|
328
|
+
if (!value || value === '-- None --') {
|
|
329
|
+
return acc
|
|
330
|
+
}
|
|
331
|
+
const entry: { label?: string | undefined; sequence?: number | undefined } = {
|
|
332
|
+
label: choice.get('label').ifString()?.getValue(),
|
|
333
|
+
}
|
|
334
|
+
if (sequence !== 0) {
|
|
335
|
+
entry.sequence = sequence
|
|
336
|
+
}
|
|
337
|
+
acc[value] = entry
|
|
338
|
+
return acc
|
|
339
|
+
}, {}),
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const fieldType = variable.get('internal_type').ifString()?.getValue() ?? 'string'
|
|
345
|
+
const defaultMaxLength = getDefaultMaxLength(fieldType)
|
|
346
|
+
const maxLength = Number(variable.get('max_length').ifString()?.getValue() ?? defaultMaxLength)
|
|
347
|
+
const hint = documentation[0]?.get('hint')?.ifString()?.getValue() ?? ''
|
|
348
|
+
|
|
349
|
+
// Extract referenceTable for reference and records column types
|
|
350
|
+
const referenceTable = variable.get('reference')?.ifString()?.getValue()
|
|
351
|
+
if (referenceTable && (fieldType === 'reference' || fieldType === 'records')) {
|
|
352
|
+
additionalProps['referenceTable'] = referenceTable
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Add dependent field for template_value and field_list column types
|
|
356
|
+
if (fieldType === 'template_value' || fieldType === 'field_list') {
|
|
357
|
+
const dependent = variable.get('dependent')?.ifString()?.getValue()
|
|
358
|
+
additionalProps['dependent'] = dependent ?? ''
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return new CallExpressionShape({
|
|
362
|
+
source: variable,
|
|
363
|
+
callee: callExpressionName,
|
|
364
|
+
args: [
|
|
365
|
+
variable
|
|
366
|
+
.transform(({ $ }) => ({
|
|
367
|
+
label: $,
|
|
368
|
+
...(variable.getTable() === 'sys_flow_step_definition_output' ||
|
|
369
|
+
variable.getTable() === 'sys_flow_step_definition_input'
|
|
370
|
+
? { sysId: $.val(NowIdShape.from(variable)) }
|
|
371
|
+
: {}),
|
|
372
|
+
mandatory: $.toBoolean().def(false),
|
|
373
|
+
maxLength: $.val(maxLength).def(defaultMaxLength),
|
|
374
|
+
dropdown: $.from('choice')
|
|
375
|
+
.map((choice) => (choice.isNumber() ? choiceDropdown[choice.getValue()] : undefined))
|
|
376
|
+
.def(choiceDropdown[1]),
|
|
377
|
+
default: $.from('default_value')
|
|
378
|
+
.map((value) => {
|
|
379
|
+
if (!value.isDefined()) {
|
|
380
|
+
return undefined
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (fieldType === 'string') {
|
|
384
|
+
return value.toString().getValue()
|
|
385
|
+
}
|
|
386
|
+
if (fieldType === 'boolean') {
|
|
387
|
+
return Boolean(value.getValue())
|
|
388
|
+
}
|
|
389
|
+
if (fieldType === 'integer') {
|
|
390
|
+
return Number(value.getValue())
|
|
391
|
+
}
|
|
392
|
+
return value.getValue()
|
|
393
|
+
})
|
|
394
|
+
.def(COLUMN_DEFAULTS[fieldType as keyof typeof COLUMN_DEFAULTS] ?? ''),
|
|
395
|
+
...(hint ? { hint: $.val(hint) } : {}),
|
|
396
|
+
columnType: $.from('internal_type')
|
|
397
|
+
.map((fieldType) => {
|
|
398
|
+
if (callExpressionName === GenericColumn.name) {
|
|
399
|
+
return fieldType
|
|
400
|
+
}
|
|
401
|
+
return undefined
|
|
402
|
+
})
|
|
403
|
+
.def(undefined),
|
|
404
|
+
}))
|
|
405
|
+
.merge(additionalProps),
|
|
406
|
+
],
|
|
407
|
+
})
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Creates a sys_variable_value record for FlowObject and FlowArray types
|
|
412
|
+
*/
|
|
413
|
+
async function createVariableValueRecord(options: {
|
|
414
|
+
callExpr: CallExpressionShape
|
|
415
|
+
factory: Factory
|
|
416
|
+
varSysId: string
|
|
417
|
+
parentRecord: Record
|
|
418
|
+
parentTable: string
|
|
419
|
+
name: string
|
|
420
|
+
index: number
|
|
421
|
+
variableValue: object
|
|
422
|
+
}): Promise<Record> {
|
|
423
|
+
const { callExpr, factory, varSysId, parentRecord, parentTable, name, index, variableValue } = options
|
|
424
|
+
|
|
425
|
+
return await factory.createRecord({
|
|
426
|
+
source: callExpr,
|
|
427
|
+
table: 'sys_variable_value',
|
|
428
|
+
properties: {
|
|
429
|
+
document: parentTable,
|
|
430
|
+
document_key: parentRecord.getId().getValue(),
|
|
431
|
+
value: JSON.stringify(variableValue),
|
|
432
|
+
order: index + 1,
|
|
433
|
+
name,
|
|
434
|
+
variable: varSysId,
|
|
435
|
+
},
|
|
436
|
+
})
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export async function getColumnRecords(
|
|
440
|
+
callExpression: CallExpressionShape,
|
|
441
|
+
factory: Factory,
|
|
442
|
+
diagnostics: Diagnostics
|
|
443
|
+
) {
|
|
444
|
+
// Verify
|
|
445
|
+
const callee = callExpression.getCallee()
|
|
446
|
+
if (!(callee in COLUMN_API_TO_TYPE) && !(callee === GenericColumn.name)) {
|
|
447
|
+
return []
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const column = callExpression.getArgument(0).asObject()
|
|
451
|
+
if (!column.has('table') || !column.has('name')) {
|
|
452
|
+
return []
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const choiceRecords = await getChoiceRecords(callExpression, {}, factory, diagnostics)
|
|
456
|
+
const documentationRecords = await getDocumentationRecords(callExpression, {}, factory, diagnostics, true)
|
|
457
|
+
return [...choiceRecords, ...documentationRecords]
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Validates and populates choice properties for dynamic value definitions
|
|
462
|
+
* that use choices from other tables
|
|
463
|
+
*/
|
|
464
|
+
function validateAndPopulateChoiceProperties(
|
|
465
|
+
config: ObjectShape,
|
|
466
|
+
additionalProperties: globalThis.Record<string, unknown>,
|
|
467
|
+
diagnostics: Diagnostics
|
|
468
|
+
) {
|
|
469
|
+
// Check if dynamic value definitions exist
|
|
470
|
+
const dynamicValueDefs = config.has('dynamicValueDefinitions')
|
|
471
|
+
? config.get('dynamicValueDefinitions').asObject()
|
|
472
|
+
: undefined
|
|
473
|
+
|
|
474
|
+
if (dynamicValueDefs) {
|
|
475
|
+
// Validate type is 'choices_from_other_table'
|
|
476
|
+
const type = dynamicValueDefs.get('type')
|
|
477
|
+
if (!type.isString() || type.getValue() !== 'choices_from_other_table') {
|
|
478
|
+
diagnostics.error(type, 'Invalid dynamicValueDefinitions type, expected "choices_from_other_table"')
|
|
479
|
+
return
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Populate required choice properties
|
|
483
|
+
additionalProperties['choice_table'] = dynamicValueDefs.get('table').getValue()
|
|
484
|
+
additionalProperties['choice_field'] = dynamicValueDefs.get('field').getValue()
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// Default to dropdown_with_none
|
|
488
|
+
let choiceValue = ChoiceDropdown.DROPDOWN_WITHOUT_NONE
|
|
489
|
+
|
|
490
|
+
// Handle dropdown type configuration
|
|
491
|
+
const defaultValue = config.get('default')
|
|
492
|
+
const choiceTypeNode = config.get('dropdown')
|
|
493
|
+
|
|
494
|
+
if (choiceTypeNode.isString()) {
|
|
495
|
+
const choiceTypeValue = choiceTypeNode.getValue() as choiceDropdownType
|
|
496
|
+
const choiceDropdownValue = choiceDropdown.indexOf(choiceTypeValue)
|
|
497
|
+
|
|
498
|
+
if (choiceDropdownValue === ChoiceDropdown.DROPDOWN_WITHOUT_NONE) {
|
|
499
|
+
// Validate default value exists for dropdown_without_none
|
|
500
|
+
if (defaultValue.isUndefined()) {
|
|
501
|
+
diagnostics.error(config, 'Default value is required for dropdown type "dropdown_without_none"')
|
|
502
|
+
return
|
|
503
|
+
}
|
|
504
|
+
choiceValue = ChoiceDropdown.DROPDOWN_WITHOUT_NONE
|
|
505
|
+
} else if (choiceDropdownValue !== ChoiceDropdown.DROPDOWN_WITH_NONE) {
|
|
506
|
+
// Only dropdown_with_none and dropdown_without_none are valid
|
|
507
|
+
diagnostics.error(
|
|
508
|
+
choiceTypeNode,
|
|
509
|
+
'Invalid dropdown type, expected "dropdown_with_none" or "dropdown_without_none"'
|
|
510
|
+
)
|
|
511
|
+
return
|
|
512
|
+
} else {
|
|
513
|
+
choiceValue = choiceDropdownValue
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Set the choice value
|
|
518
|
+
additionalProperties['choice'] = choiceValue
|
|
519
|
+
|
|
520
|
+
// Add default value if provided
|
|
521
|
+
if (!defaultValue.isUndefined()) {
|
|
522
|
+
additionalProperties['default_value'] = defaultValue.getValue()
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Via regex matcher for sys_complex_object relationships that checks if the parent's
|
|
528
|
+
* co_type_name attribute matches the child's name field.
|
|
529
|
+
*/
|
|
530
|
+
export const complexObjectMatchesIoRecord: { parent: [string, string]; child: [string, string] } = {
|
|
531
|
+
parent: ['attributes', 'co_type_name=([^,]+)'],
|
|
532
|
+
child: ['name', '(.+)'],
|
|
533
|
+
}
|