@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
package/src/data-plugin.ts
CHANGED
|
@@ -3,17 +3,19 @@ import {
|
|
|
3
3
|
type Shape,
|
|
4
4
|
type Result,
|
|
5
5
|
type Diagnostics,
|
|
6
|
+
CallExpressionShape,
|
|
6
7
|
DurationShape,
|
|
7
8
|
TimeShape,
|
|
8
9
|
FieldListShape,
|
|
9
10
|
TemplateValueShape,
|
|
10
|
-
CallExpressionShape,
|
|
11
|
-
ts,
|
|
12
11
|
DATA_HELPER_NAMES,
|
|
12
|
+
ts,
|
|
13
13
|
} from '@servicenow/sdk-build-core'
|
|
14
14
|
import { getCallExpressionName } from './utils'
|
|
15
|
-
import type { Duration, TimeOfDay } from '@servicenow/sdk-core/runtime/db'
|
|
16
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Check if a ts.Node is a data helper call expression.
|
|
18
|
+
*/
|
|
17
19
|
export function isDataHelper(node: ts.Node): boolean {
|
|
18
20
|
if (!ts.Node.isCallExpression(node)) {
|
|
19
21
|
return false
|
|
@@ -25,10 +27,11 @@ export function isDataHelper(node: ts.Node): boolean {
|
|
|
25
27
|
/**
|
|
26
28
|
* Shape creators for each data helper.
|
|
27
29
|
* Maps helper function names to their shape creation logic.
|
|
30
|
+
* All data helper shapes extend CallExpressionShape.
|
|
28
31
|
*/
|
|
29
32
|
const shapeCreators: Record<
|
|
30
33
|
string,
|
|
31
|
-
(
|
|
34
|
+
(shape: CallExpressionShape, diagnostics: Diagnostics) => Result<CallExpressionShape>
|
|
32
35
|
> = {
|
|
33
36
|
[DATA_HELPER_NAMES.DURATION]: createDurationShape,
|
|
34
37
|
[DATA_HELPER_NAMES.TIME]: createTimeShape,
|
|
@@ -38,97 +41,19 @@ const shapeCreators: Record<
|
|
|
38
41
|
|
|
39
42
|
export const DataPlugin = Plugin.create({
|
|
40
43
|
name: 'DataPlugin',
|
|
41
|
-
|
|
44
|
+
shapes: [
|
|
42
45
|
{
|
|
43
|
-
|
|
46
|
+
shape: CallExpressionShape,
|
|
44
47
|
fileTypes: ['fluent'],
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const callee = getCallExpressionName(node)
|
|
48
|
-
const args = node.getArguments()
|
|
49
|
-
const nodeData = args[0]
|
|
48
|
+
toSubclass(shape, { diagnostics }) {
|
|
49
|
+
const callee = shape.getCallee()
|
|
50
50
|
const shapeCreator = shapeCreators[callee]
|
|
51
|
-
|
|
51
|
+
// Only handle known data helper callees (Duration, Time, FieldList, TemplateValue)
|
|
52
|
+
if (!shapeCreator) {
|
|
52
53
|
return { success: false }
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
if (!result.success) {
|
|
57
|
-
return result
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Extract optional second argument (e.g., timezone for Time helper)
|
|
61
|
-
let secondArg: string | undefined
|
|
62
|
-
if (callee === DATA_HELPER_NAMES.TIME && args[1]) {
|
|
63
|
-
if (!ts.Node.isStringLiteral(args[1])) {
|
|
64
|
-
diagnostics.error(args[1], 'Second argument must be a string literal')
|
|
65
|
-
return { success: false }
|
|
66
|
-
}
|
|
67
|
-
secondArg = args[1].getLiteralValue()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return shapeCreator(node, result.value, diagnostics, secondArg)
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
shapes: [
|
|
75
|
-
{
|
|
76
|
-
shape: DurationShape,
|
|
77
|
-
async commit(shape, target, { commit }) {
|
|
78
|
-
const durationExpression = new CallExpressionShape({
|
|
79
|
-
source: shape.getSource(),
|
|
80
|
-
callee: DATA_HELPER_NAMES.DURATION,
|
|
81
|
-
args: [shape.getDuration()],
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
await commit(durationExpression, target)
|
|
85
|
-
return { success: true }
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
shape: TimeShape,
|
|
90
|
-
async commit(shape, target, { commit }) {
|
|
91
|
-
const args: unknown[] = [shape.getTimeData()]
|
|
92
|
-
// Preserve timezone if it was specified in the source code
|
|
93
|
-
const timeZone = shape.getTimeZone()
|
|
94
|
-
if (timeZone) {
|
|
95
|
-
args.push(timeZone)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const timeExpression = new CallExpressionShape({
|
|
99
|
-
source: shape.getSource(),
|
|
100
|
-
callee: DATA_HELPER_NAMES.TIME,
|
|
101
|
-
args,
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
await commit(timeExpression, target)
|
|
105
|
-
return { success: true }
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
shape: FieldListShape,
|
|
110
|
-
async commit(shape, target, { commit }) {
|
|
111
|
-
const fieldListExpression = new CallExpressionShape({
|
|
112
|
-
source: shape.getSource(),
|
|
113
|
-
callee: DATA_HELPER_NAMES.FIELD_LIST,
|
|
114
|
-
args: [shape.getFields()],
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
await commit(fieldListExpression, target)
|
|
118
|
-
return { success: true }
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
shape: TemplateValueShape,
|
|
123
|
-
async commit(shape, target, { commit }) {
|
|
124
|
-
const templateValueExpression = new CallExpressionShape({
|
|
125
|
-
source: shape.getSource(),
|
|
126
|
-
callee: DATA_HELPER_NAMES.TEMPLATE_VALUE,
|
|
127
|
-
args: [shape.getValue()],
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
await commit(templateValueExpression, target)
|
|
131
|
-
return { success: true }
|
|
56
|
+
return shapeCreator(shape, diagnostics)
|
|
132
57
|
},
|
|
133
58
|
},
|
|
134
59
|
],
|
|
@@ -136,121 +61,124 @@ export const DataPlugin = Plugin.create({
|
|
|
136
61
|
|
|
137
62
|
/**
|
|
138
63
|
* Helper to validate that all defined fields are non-negative.
|
|
139
|
-
* Returns
|
|
64
|
+
* Returns errors for negative values
|
|
140
65
|
*/
|
|
141
|
-
function validateNonNegative(data: Record<string,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
66
|
+
function validateNonNegative(data: Record<string, Shape>, fields: string[]): string[] {
|
|
67
|
+
const errors: string[] = []
|
|
68
|
+
for (const field of fields) {
|
|
69
|
+
const value = data[field]
|
|
70
|
+
if (!value?.isDefined() || !value.isNumber()) {
|
|
71
|
+
continue // Skip undefined or non-numeric (will be caught by constructor)
|
|
72
|
+
}
|
|
73
|
+
const numericValue = value.asNumber().getValue()
|
|
74
|
+
if (numericValue < 0) {
|
|
75
|
+
errors.push(`${field} must be >= 0, got ${numericValue}`)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return errors
|
|
145
79
|
}
|
|
146
80
|
|
|
147
81
|
/**
|
|
148
82
|
* Helper to validate that at least one field is defined.
|
|
149
83
|
* Returns true if at least one field has a defined value.
|
|
150
84
|
*/
|
|
151
|
-
function hasAtLeastOneField(data: Record<string,
|
|
152
|
-
return fields.some((field) => data[field]
|
|
85
|
+
function hasAtLeastOneField(data: Record<string, Shape>, fields: string[]): boolean {
|
|
86
|
+
return fields.some((field) => data[field]?.isDefined())
|
|
153
87
|
}
|
|
154
88
|
|
|
155
89
|
/**
|
|
156
|
-
* Creates a DurationShape from
|
|
90
|
+
* Creates a DurationShape from a CallExpressionShape.
|
|
157
91
|
* Validates that duration values are within acceptable ranges.
|
|
158
92
|
*/
|
|
159
|
-
function createDurationShape(
|
|
160
|
-
const
|
|
93
|
+
function createDurationShape(shape: CallExpressionShape, diagnostics: Diagnostics): Result<DurationShape> {
|
|
94
|
+
const argShape = shape.getArgument(0)
|
|
95
|
+
const duration = argShape.asObject().properties({ resolve: false })
|
|
161
96
|
|
|
162
97
|
// Validate at least one field is provided
|
|
163
98
|
if (!hasAtLeastOneField(duration, ['days', 'hours', 'minutes', 'seconds'])) {
|
|
164
|
-
diagnostics.error(
|
|
99
|
+
diagnostics.error(shape, 'Duration must have at least one field defined (days, hours, minutes, or seconds)')
|
|
165
100
|
return { success: false }
|
|
166
101
|
}
|
|
167
102
|
|
|
168
103
|
const errors = validateNonNegative(duration, ['days', 'hours', 'minutes', 'seconds'])
|
|
169
104
|
|
|
170
105
|
if (errors.length > 0) {
|
|
171
|
-
diagnostics.error(
|
|
106
|
+
diagnostics.error(shape, `Invalid duration values: ${errors.join(', ')}`)
|
|
172
107
|
return { success: false }
|
|
173
108
|
}
|
|
174
109
|
|
|
175
|
-
return { success: true, value: new DurationShape({ source, value:
|
|
110
|
+
return { success: true, value: new DurationShape({ source: shape, value: argShape.asObject() }) }
|
|
176
111
|
}
|
|
177
112
|
|
|
178
113
|
/**
|
|
179
|
-
* Creates a TimeShape from
|
|
114
|
+
* Creates a TimeShape from a CallExpressionShape.
|
|
180
115
|
* Validates that time values are within acceptable ranges.
|
|
181
|
-
* @param source - The source CallExpression node
|
|
182
|
-
* @param shape - The shape containing time data
|
|
183
|
-
* @param diagnostics - Diagnostics for error reporting
|
|
184
|
-
* @param timeZone - Optional IANA timezone string (e.g., 'America/New_York')
|
|
185
116
|
*/
|
|
186
|
-
function createTimeShape(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
diagnostics: Diagnostics,
|
|
190
|
-
timeZone?: string
|
|
191
|
-
): Result<TimeShape> {
|
|
192
|
-
const timeData = shape.asObject().getValue() as TimeOfDay
|
|
117
|
+
function createTimeShape(shape: CallExpressionShape, diagnostics: Diagnostics): Result<TimeShape> {
|
|
118
|
+
const argShape = shape.getArgument(0)
|
|
119
|
+
const timeData = argShape.asObject().properties({ resolve: false })
|
|
193
120
|
|
|
194
121
|
// Validate at least one field is provided
|
|
195
122
|
if (!hasAtLeastOneField(timeData, ['hours', 'minutes', 'seconds'])) {
|
|
196
|
-
diagnostics.error(
|
|
123
|
+
diagnostics.error(shape, 'Time must have at least one field defined (hours, minutes, or seconds)')
|
|
197
124
|
return { success: false }
|
|
198
125
|
}
|
|
199
126
|
|
|
200
127
|
const errors = validateNonNegative(timeData, ['hours', 'minutes', 'seconds'])
|
|
201
128
|
|
|
202
129
|
if (errors.length > 0) {
|
|
203
|
-
diagnostics.error(
|
|
130
|
+
diagnostics.error(shape, `Invalid time values: ${errors.join(', ')}`)
|
|
204
131
|
return { success: false }
|
|
205
132
|
}
|
|
206
133
|
|
|
207
|
-
//
|
|
208
|
-
|
|
134
|
+
// Extract and validate optional timezone from second argument
|
|
135
|
+
const tzArg = shape.getArgument(1)
|
|
136
|
+
if (tzArg.isUndefined()) {
|
|
137
|
+
return { success: true, value: new TimeShape({ source: shape, value: argShape.asObject() }) }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!tzArg.isString()) {
|
|
141
|
+
diagnostics.error(shape, 'Second argument (timezone) must be a string literal')
|
|
142
|
+
return { success: false }
|
|
143
|
+
}
|
|
144
|
+
const timeZone = tzArg.asString().getValue()
|
|
145
|
+
if (!isValidTimeZone(timeZone)) {
|
|
209
146
|
diagnostics.error(
|
|
210
|
-
|
|
147
|
+
shape,
|
|
211
148
|
`Invalid IANA timezone: '${timeZone}'. Use a valid timezone like 'America/New_York', 'Europe/London', or 'UTC'.`
|
|
212
149
|
)
|
|
213
150
|
return { success: false }
|
|
214
151
|
}
|
|
215
152
|
|
|
216
|
-
return { success: true, value: new TimeShape({ source, value:
|
|
153
|
+
return { success: true, value: new TimeShape({ source: shape, value: argShape.asObject(), timeZone }) }
|
|
217
154
|
}
|
|
218
155
|
|
|
219
156
|
/**
|
|
220
|
-
* Creates a FieldListShape from
|
|
157
|
+
* Creates a FieldListShape from a CallExpressionShape.
|
|
221
158
|
*/
|
|
222
|
-
function createFieldListShape(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
_diagnostics: Diagnostics
|
|
226
|
-
): Result<FieldListShape> {
|
|
227
|
-
const fields = shape.asArray().getElements()
|
|
228
|
-
const fieldListShape = new FieldListShape({ source, fields })
|
|
229
|
-
return { success: true, value: fieldListShape }
|
|
159
|
+
function createFieldListShape(shape: CallExpressionShape, _diagnostics: Diagnostics): Result<FieldListShape> {
|
|
160
|
+
const fields = shape.getArgument(0).asArray().getElements()
|
|
161
|
+
return { success: true, value: new FieldListShape({ source: shape, fields }) }
|
|
230
162
|
}
|
|
231
163
|
|
|
232
164
|
/**
|
|
233
|
-
* Creates a TemplateValueShape from
|
|
165
|
+
* Creates a TemplateValueShape from a CallExpressionShape.
|
|
234
166
|
*/
|
|
235
|
-
function createTemplateValueShape(
|
|
236
|
-
|
|
237
|
-
shape: Shape,
|
|
238
|
-
diagnostics: Diagnostics
|
|
239
|
-
): Result<TemplateValueShape> {
|
|
240
|
-
const value = shape.asObject().getValue()
|
|
167
|
+
function createTemplateValueShape(shape: CallExpressionShape, diagnostics: Diagnostics): Result<TemplateValueShape> {
|
|
168
|
+
const value = shape.getArgument(0).asObject().properties({ resolve: false })
|
|
241
169
|
|
|
242
170
|
// Validate that values don't contain ^^ (double caret)
|
|
243
171
|
for (const [key, val] of Object.entries(value)) {
|
|
244
|
-
if (
|
|
172
|
+
if (val.isString() && val.getValue().includes('^^')) {
|
|
245
173
|
diagnostics.error(
|
|
246
|
-
|
|
174
|
+
shape,
|
|
247
175
|
`Template field '${key}' contains an invalid character sequence: multiple carets (^^). Use a single caret (^) if needed, it will be escaped automatically.`
|
|
248
176
|
)
|
|
249
177
|
return { success: false }
|
|
250
178
|
}
|
|
251
179
|
}
|
|
252
180
|
|
|
253
|
-
return { success: true, value: new TemplateValueShape({ source, value }) }
|
|
181
|
+
return { success: true, value: new TemplateValueShape({ source: shape, value }) }
|
|
254
182
|
}
|
|
255
183
|
|
|
256
184
|
/**
|