@servicenow/sdk-build-plugins 4.4.1 → 4.6.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 +54 -4
- package/dist/acl-plugin.js.map +1 -1
- package/dist/applicability-plugin.js +2 -0
- package/dist/applicability-plugin.js.map +1 -1
- package/dist/application-menu-plugin.js +2 -0
- package/dist/application-menu-plugin.js.map +1 -1
- package/dist/arrow-function-plugin.d.ts +6 -1
- package/dist/arrow-function-plugin.js +105 -12
- package/dist/arrow-function-plugin.js.map +1 -1
- package/dist/atf/test-plugin.js +2 -0
- package/dist/atf/test-plugin.js.map +1 -1
- package/dist/basic-syntax-plugin.js +20 -0
- package/dist/basic-syntax-plugin.js.map +1 -1
- package/dist/call-expression-plugin.js +1 -0
- package/dist/call-expression-plugin.js.map +1 -1
- package/dist/claims-plugin.js +1 -0
- package/dist/claims-plugin.js.map +1 -1
- package/dist/client-script-plugin.js +1 -0
- package/dist/client-script-plugin.js.map +1 -1
- package/dist/column-plugin.js +4 -7
- package/dist/column-plugin.js.map +1 -1
- package/dist/cross-scope-privilege-plugin.js +1 -0
- package/dist/cross-scope-privilege-plugin.js.map +1 -1
- package/dist/dashboard/dashboard-plugin.js +2 -0
- package/dist/dashboard/dashboard-plugin.js.map +1 -1
- package/dist/data-plugin.js +1 -0
- package/dist/data-plugin.js.map +1 -1
- package/dist/email-notification-plugin.js +9 -13
- package/dist/email-notification-plugin.js.map +1 -1
- package/dist/flow/constants/flow-plugin-constants.d.ts +1 -1
- package/dist/flow/constants/flow-plugin-constants.js +1 -1
- package/dist/flow/constants/flow-plugin-constants.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-diagnostics.js +5 -5
- package/dist/flow/flow-logic/flow-logic-diagnostics.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.d.ts +82 -2
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js +48 -40
- package/dist/flow/flow-logic/flow-logic-plugin-helpers.js.map +1 -1
- package/dist/flow/flow-logic/flow-logic-plugin.js +1 -0
- package/dist/flow/flow-logic/flow-logic-plugin.js.map +1 -1
- package/dist/flow/plugins/approval-rules-plugin.js +1 -0
- package/dist/flow/plugins/approval-rules-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-action-definition-plugin.js +1232 -55
- package/dist/flow/plugins/flow-action-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-data-pill-plugin.js +6 -2
- package/dist/flow/plugins/flow-data-pill-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-definition-plugin.js +23 -44
- package/dist/flow/plugins/flow-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-diagnostics-plugin.d.ts +2 -2
- package/dist/flow/plugins/flow-diagnostics-plugin.js +3 -2
- package/dist/flow/plugins/flow-diagnostics-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-instance-plugin.js +136 -34
- package/dist/flow/plugins/flow-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/flow-trigger-instance-plugin.js +1 -0
- package/dist/flow/plugins/flow-trigger-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/inline-script-plugin.js +1 -0
- package/dist/flow/plugins/inline-script-plugin.js.map +1 -1
- package/dist/flow/plugins/step-definition-plugin.js +4 -2
- package/dist/flow/plugins/step-definition-plugin.js.map +1 -1
- package/dist/flow/plugins/step-instance-plugin.d.ts +9 -1
- package/dist/flow/plugins/step-instance-plugin.js +649 -135
- package/dist/flow/plugins/step-instance-plugin.js.map +1 -1
- package/dist/flow/plugins/trigger-plugin.js +2 -0
- package/dist/flow/plugins/trigger-plugin.js.map +1 -1
- package/dist/flow/plugins/wfa-datapill-plugin.js +21 -5
- package/dist/flow/plugins/wfa-datapill-plugin.js.map +1 -1
- package/dist/flow/post-install.d.ts +2 -0
- package/dist/flow/post-install.js +59 -0
- package/dist/flow/post-install.js.map +1 -0
- package/dist/flow/utils/complex-object-resolver.js +4 -1
- package/dist/flow/utils/complex-object-resolver.js.map +1 -1
- package/dist/flow/utils/complex-objects.js +5 -3
- package/dist/flow/utils/complex-objects.js.map +1 -1
- package/dist/flow/utils/flow-constants.d.ts +90 -2
- package/dist/flow/utils/flow-constants.js +430 -7
- package/dist/flow/utils/flow-constants.js.map +1 -1
- package/dist/flow/utils/flow-io-to-record.d.ts +1 -1
- package/dist/flow/utils/flow-io-to-record.js +37 -16
- package/dist/flow/utils/flow-io-to-record.js.map +1 -1
- package/dist/flow/utils/flow-shapes.js +4 -0
- package/dist/flow/utils/flow-shapes.js.map +1 -1
- package/dist/flow/utils/flow-to-xml.d.ts +3 -2
- package/dist/flow/utils/flow-to-xml.js +3 -4
- package/dist/flow/utils/flow-to-xml.js.map +1 -1
- package/dist/flow/utils/label-cache-parser.d.ts +9 -2
- package/dist/flow/utils/label-cache-parser.js +32 -4
- package/dist/flow/utils/label-cache-parser.js.map +1 -1
- package/dist/flow/utils/label-cache-processor.d.ts +5 -0
- package/dist/flow/utils/label-cache-processor.js +14 -2
- package/dist/flow/utils/label-cache-processor.js.map +1 -1
- package/dist/flow/utils/pill-shape-helpers.d.ts +15 -0
- package/dist/flow/utils/pill-shape-helpers.js +35 -0
- package/dist/flow/utils/pill-shape-helpers.js.map +1 -0
- package/dist/flow/utils/pill-string-parser.js +1 -0
- package/dist/flow/utils/pill-string-parser.js.map +1 -1
- package/dist/flow/utils/schema-to-flow-object.d.ts +6 -1
- package/dist/flow/utils/schema-to-flow-object.js +131 -15
- package/dist/flow/utils/schema-to-flow-object.js.map +1 -1
- package/dist/flow/utils/service-catalog.js +5 -1
- package/dist/flow/utils/service-catalog.js.map +1 -1
- package/dist/flow/utils/utils.d.ts +1 -0
- package/dist/flow/utils/utils.js +6 -1
- package/dist/flow/utils/utils.js.map +1 -1
- package/dist/form-plugin.d.ts +2 -0
- package/dist/form-plugin.js +1132 -0
- package/dist/form-plugin.js.map +1 -0
- package/dist/html-import-plugin.js +1 -0
- package/dist/html-import-plugin.js.map +1 -1
- package/dist/import-sets-plugin.js +2 -0
- package/dist/import-sets-plugin.js.map +1 -1
- package/dist/inbound-email-action-plugin.d.ts +10 -0
- package/dist/inbound-email-action-plugin.js +128 -0
- package/dist/inbound-email-action-plugin.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/instance-scan-plugin.d.ts +2 -0
- package/dist/instance-scan-plugin.js +293 -0
- package/dist/instance-scan-plugin.js.map +1 -0
- package/dist/json-plugin.js +1 -0
- package/dist/json-plugin.js.map +1 -1
- package/dist/list-plugin.js +1 -0
- package/dist/list-plugin.js.map +1 -1
- package/dist/now-attach-plugin.js +1 -0
- package/dist/now-attach-plugin.js.map +1 -1
- package/dist/now-config-plugin.js +659 -51
- package/dist/now-config-plugin.js.map +1 -1
- package/dist/now-id-plugin.js +1 -0
- package/dist/now-id-plugin.js.map +1 -1
- package/dist/now-include-plugin.js +1 -0
- package/dist/now-include-plugin.js.map +1 -1
- package/dist/now-ref-plugin.js +1 -0
- package/dist/now-ref-plugin.js.map +1 -1
- package/dist/now-unresolved-plugin.js +1 -0
- package/dist/now-unresolved-plugin.js.map +1 -1
- package/dist/package-json-plugin.js +1 -0
- package/dist/package-json-plugin.js.map +1 -1
- package/dist/property-plugin.js +3 -1
- package/dist/property-plugin.js.map +1 -1
- package/dist/record-plugin.d.ts +37 -0
- package/dist/record-plugin.js +47 -3
- package/dist/record-plugin.js.map +1 -1
- package/dist/repack/lint/Rules.d.ts +11 -2
- package/dist/repack/lint/Rules.js +160 -16
- package/dist/repack/lint/Rules.js.map +1 -1
- package/dist/repack/lint/index.d.ts +10 -5
- package/dist/repack/lint/index.js +76 -50
- package/dist/repack/lint/index.js.map +1 -1
- package/dist/rest-api-plugin.js +22 -1
- package/dist/rest-api-plugin.js.map +1 -1
- package/dist/role-plugin.js +1 -0
- package/dist/role-plugin.js.map +1 -1
- package/dist/schedule-script/index.d.ts +1 -0
- package/dist/schedule-script/index.js +18 -0
- package/dist/schedule-script/index.js.map +1 -0
- package/dist/schedule-script/scheduled-script-plugin.d.ts +2 -0
- package/dist/schedule-script/scheduled-script-plugin.js +556 -0
- package/dist/schedule-script/scheduled-script-plugin.js.map +1 -0
- package/dist/schedule-script/timeZoneConverter.d.ts +61 -0
- package/dist/schedule-script/timeZoneConverter.js +170 -0
- package/dist/schedule-script/timeZoneConverter.js.map +1 -0
- package/dist/script-action-plugin.js +2 -0
- package/dist/script-action-plugin.js.map +1 -1
- package/dist/script-include-plugin.js +2 -0
- package/dist/script-include-plugin.js.map +1 -1
- package/dist/server-module-plugin/index.js +13 -2
- package/dist/server-module-plugin/index.js.map +1 -1
- package/dist/service-catalog/catalog-clientscript-plugin.js +2 -0
- package/dist/service-catalog/catalog-clientscript-plugin.js.map +1 -1
- package/dist/service-catalog/catalog-item-plugin.js +2 -0
- package/dist/service-catalog/catalog-item-plugin.js.map +1 -1
- package/dist/service-catalog/catalog-ui-policy-plugin.js +2 -0
- package/dist/service-catalog/catalog-ui-policy-plugin.js.map +1 -1
- package/dist/service-catalog/sc-record-producer-plugin.js +2 -0
- package/dist/service-catalog/sc-record-producer-plugin.js.map +1 -1
- package/dist/service-catalog/service-catalog-base.d.ts +18 -18
- package/dist/service-catalog/service-catalog-base.js +22 -22
- package/dist/service-catalog/service-catalog-base.js.map +1 -1
- package/dist/service-catalog/service-catalog-diagnostics.d.ts +6 -0
- package/dist/service-catalog/service-catalog-diagnostics.js +20 -0
- package/dist/service-catalog/service-catalog-diagnostics.js.map +1 -1
- package/dist/service-catalog/shape-to-record.js +7 -2
- package/dist/service-catalog/shape-to-record.js.map +1 -1
- package/dist/service-catalog/variable-set-plugin.js +2 -0
- package/dist/service-catalog/variable-set-plugin.js.map +1 -1
- package/dist/service-portal/angular-provider-plugin.js +2 -0
- package/dist/service-portal/angular-provider-plugin.js.map +1 -1
- package/dist/service-portal/dependency-plugin.js +5 -31
- package/dist/service-portal/dependency-plugin.js.map +1 -1
- package/dist/service-portal/header-footer-plugin.d.ts +2 -0
- package/dist/service-portal/header-footer-plugin.js +50 -0
- package/dist/service-portal/header-footer-plugin.js.map +1 -0
- package/dist/service-portal/menu-plugin.d.ts +2 -0
- package/dist/service-portal/menu-plugin.js +334 -0
- package/dist/service-portal/menu-plugin.js.map +1 -0
- package/dist/service-portal/page-plugin.d.ts +2 -0
- package/dist/service-portal/page-plugin.js +681 -0
- package/dist/service-portal/page-plugin.js.map +1 -0
- package/dist/service-portal/page-route-map-plugin.d.ts +2 -0
- package/dist/service-portal/page-route-map-plugin.js +114 -0
- package/dist/service-portal/page-route-map-plugin.js.map +1 -0
- package/dist/service-portal/portal-plugin.d.ts +2 -0
- package/dist/service-portal/portal-plugin.js +309 -0
- package/dist/service-portal/portal-plugin.js.map +1 -0
- package/dist/service-portal/theme-plugin.d.ts +2 -0
- package/dist/service-portal/theme-plugin.js +112 -0
- package/dist/service-portal/theme-plugin.js.map +1 -0
- package/dist/service-portal/utils.d.ts +46 -0
- package/dist/service-portal/utils.js +331 -0
- package/dist/service-portal/utils.js.map +1 -0
- package/dist/service-portal/widget-plugin.js +10 -182
- package/dist/service-portal/widget-plugin.js.map +1 -1
- package/dist/sla-plugin.js +2 -0
- package/dist/sla-plugin.js.map +1 -1
- package/dist/static-content-plugin.js +5 -0
- package/dist/static-content-plugin.js.map +1 -1
- package/dist/table-plugin.js +191 -26
- package/dist/table-plugin.js.map +1 -1
- package/dist/ui-action-plugin.js +3 -4
- package/dist/ui-action-plugin.js.map +1 -1
- package/dist/ui-page-plugin.js +101 -21
- package/dist/ui-page-plugin.js.map +1 -1
- package/dist/ui-policy-plugin.js +1 -0
- package/dist/ui-policy-plugin.js.map +1 -1
- package/dist/user-preference-plugin.js +2 -0
- package/dist/user-preference-plugin.js.map +1 -1
- package/dist/utils.d.ts +20 -2
- package/dist/utils.js +34 -3
- package/dist/utils.js.map +1 -1
- package/dist/ux-list-menu-config-plugin.js +2 -0
- package/dist/ux-list-menu-config-plugin.js.map +1 -1
- package/dist/view-plugin.js +9 -3
- package/dist/view-plugin.js.map +1 -1
- package/dist/workspace-plugin.js +41 -36
- package/dist/workspace-plugin.js.map +1 -1
- package/package.json +11 -11
- package/src/_types/eslint-community-eslint-utils.d.ts +15 -0
- package/src/acl-plugin.ts +97 -8
- package/src/applicability-plugin.ts +2 -0
- package/src/application-menu-plugin.ts +2 -0
- package/src/arrow-function-plugin.ts +128 -13
- package/src/atf/test-plugin.ts +2 -0
- package/src/basic-syntax-plugin.ts +21 -0
- package/src/call-expression-plugin.ts +1 -0
- package/src/claims-plugin.ts +1 -0
- package/src/client-script-plugin.ts +2 -1
- package/src/column-plugin.ts +4 -8
- package/src/cross-scope-privilege-plugin.ts +2 -1
- package/src/dashboard/dashboard-plugin.ts +2 -0
- package/src/data-plugin.ts +1 -0
- package/src/email-notification-plugin.ts +3 -23
- package/src/flow/constants/flow-plugin-constants.ts +1 -1
- package/src/flow/flow-logic/flow-logic-diagnostics.ts +5 -6
- package/src/flow/flow-logic/flow-logic-plugin-helpers.ts +47 -45
- package/src/flow/flow-logic/flow-logic-plugin.ts +1 -0
- package/src/flow/plugins/approval-rules-plugin.ts +1 -0
- package/src/flow/plugins/flow-action-definition-plugin.ts +1584 -62
- package/src/flow/plugins/flow-data-pill-plugin.ts +6 -2
- package/src/flow/plugins/flow-definition-plugin.ts +22 -51
- package/src/flow/plugins/flow-diagnostics-plugin.ts +3 -2
- package/src/flow/plugins/flow-instance-plugin.ts +201 -36
- package/src/flow/plugins/flow-trigger-instance-plugin.ts +1 -0
- package/src/flow/plugins/inline-script-plugin.ts +1 -0
- package/src/flow/plugins/step-definition-plugin.ts +4 -2
- package/src/flow/plugins/step-instance-plugin.ts +772 -155
- package/src/flow/plugins/trigger-plugin.ts +2 -0
- package/src/flow/plugins/wfa-datapill-plugin.ts +26 -5
- package/src/flow/post-install.ts +93 -0
- package/src/flow/utils/complex-object-resolver.ts +4 -1
- package/src/flow/utils/complex-objects.ts +11 -3
- package/src/flow/utils/flow-constants.ts +451 -6
- package/src/flow/utils/flow-io-to-record.ts +43 -17
- package/src/flow/utils/flow-shapes.ts +4 -0
- package/src/flow/utils/flow-to-xml.ts +4 -4
- package/src/flow/utils/label-cache-parser.ts +33 -4
- package/src/flow/utils/label-cache-processor.ts +14 -2
- package/src/flow/utils/pill-shape-helpers.ts +42 -0
- package/src/flow/utils/pill-string-parser.ts +1 -0
- package/src/flow/utils/schema-to-flow-object.ts +183 -15
- package/src/flow/utils/service-catalog.ts +5 -2
- package/src/flow/utils/utils.ts +12 -1
- package/src/form-plugin.ts +1409 -0
- package/src/html-import-plugin.ts +1 -0
- package/src/import-sets-plugin.ts +2 -0
- package/src/inbound-email-action-plugin.ts +145 -0
- package/src/index.ts +13 -0
- package/src/instance-scan-plugin.ts +313 -0
- package/src/json-plugin.ts +1 -0
- package/src/list-plugin.ts +2 -1
- package/src/now-attach-plugin.ts +1 -0
- package/src/now-config-plugin.ts +833 -53
- package/src/now-id-plugin.ts +1 -0
- package/src/now-include-plugin.ts +1 -0
- package/src/now-ref-plugin.ts +1 -0
- package/src/now-unresolved-plugin.ts +1 -0
- package/src/package-json-plugin.ts +1 -0
- package/src/property-plugin.ts +6 -1
- package/src/record-plugin.ts +56 -6
- package/src/repack/lint/Rules.ts +171 -22
- package/src/repack/lint/index.ts +80 -56
- package/src/rest-api-plugin.ts +28 -2
- package/src/role-plugin.ts +2 -1
- package/src/schedule-script/index.ts +1 -0
- package/src/schedule-script/scheduled-script-plugin.ts +690 -0
- package/src/schedule-script/timeZoneConverter.ts +188 -0
- package/src/script-action-plugin.ts +2 -0
- package/src/script-include-plugin.ts +2 -0
- package/src/server-module-plugin/index.ts +14 -2
- package/src/service-catalog/catalog-clientscript-plugin.ts +2 -0
- package/src/service-catalog/catalog-item-plugin.ts +2 -0
- package/src/service-catalog/catalog-ui-policy-plugin.ts +2 -0
- package/src/service-catalog/sc-record-producer-plugin.ts +2 -0
- package/src/service-catalog/service-catalog-base.ts +22 -22
- package/src/service-catalog/service-catalog-diagnostics.ts +30 -0
- package/src/service-catalog/shape-to-record.ts +8 -2
- package/src/service-catalog/variable-set-plugin.ts +2 -0
- package/src/service-portal/angular-provider-plugin.ts +2 -0
- package/src/service-portal/dependency-plugin.ts +6 -53
- package/src/service-portal/header-footer-plugin.ts +57 -0
- package/src/service-portal/menu-plugin.ts +413 -0
- package/src/service-portal/page-plugin.ts +805 -0
- package/src/service-portal/page-route-map-plugin.ts +124 -0
- package/src/service-portal/portal-plugin.ts +342 -0
- package/src/service-portal/theme-plugin.ts +135 -0
- package/src/service-portal/utils.ts +470 -0
- package/src/service-portal/widget-plugin.ts +18 -224
- package/src/sla-plugin.ts +2 -0
- package/src/static-content-plugin.ts +4 -0
- package/src/table-plugin.ts +228 -37
- package/src/ui-action-plugin.ts +3 -8
- package/src/ui-page-plugin.ts +110 -21
- package/src/ui-policy-plugin.ts +2 -1
- package/src/user-preference-plugin.ts +2 -0
- package/src/utils.ts +42 -2
- package/src/ux-list-menu-config-plugin.ts +2 -0
- package/src/view-plugin.ts +11 -4
- package/src/workspace-plugin.ts +45 -43
- package/src/_types/eslint-plugin-es-x.d.ts +0 -17
|
@@ -1,17 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Plugin,
|
|
3
|
+
Shape,
|
|
4
|
+
type Source,
|
|
5
|
+
ts,
|
|
6
|
+
IdentifierShape,
|
|
7
|
+
type StringShape,
|
|
8
|
+
ObjectShape,
|
|
9
|
+
} from '@servicenow/sdk-build-core'
|
|
2
10
|
|
|
3
11
|
export class ArrowFunctionShape extends Shape {
|
|
4
12
|
private readonly parameters: IdentifierShape[]
|
|
5
13
|
private readonly statements: Shape[]
|
|
14
|
+
private readonly returnValue: Shape | undefined
|
|
15
|
+
private readonly implicitReturn: boolean
|
|
6
16
|
|
|
7
17
|
constructor({
|
|
8
18
|
source,
|
|
9
19
|
parameters,
|
|
10
20
|
statements,
|
|
21
|
+
returnValue,
|
|
22
|
+
implicitReturn,
|
|
11
23
|
}: {
|
|
12
24
|
source: Source
|
|
13
25
|
parameters?: (IdentifierShape | StringShape | string)[]
|
|
14
26
|
statements?: Shape[]
|
|
27
|
+
returnValue?: Shape
|
|
28
|
+
implicitReturn?: boolean
|
|
15
29
|
}) {
|
|
16
30
|
super({ source })
|
|
17
31
|
this.parameters = (parameters ?? []).map((s) =>
|
|
@@ -23,6 +37,8 @@ export class ArrowFunctionShape extends Shape {
|
|
|
23
37
|
})
|
|
24
38
|
)
|
|
25
39
|
this.statements = statements ?? []
|
|
40
|
+
this.returnValue = returnValue
|
|
41
|
+
this.implicitReturn = implicitReturn ?? false
|
|
26
42
|
}
|
|
27
43
|
|
|
28
44
|
getParameters(): IdentifierShape[] {
|
|
@@ -51,18 +67,51 @@ export class ArrowFunctionShape extends Shape {
|
|
|
51
67
|
return statement
|
|
52
68
|
}
|
|
53
69
|
|
|
70
|
+
getReturnValue(): Shape | undefined {
|
|
71
|
+
return this.returnValue
|
|
72
|
+
}
|
|
73
|
+
|
|
54
74
|
override getCode(): string {
|
|
55
|
-
|
|
75
|
+
const params = `(${this.getParameters()
|
|
56
76
|
.map((p) => p.getCode())
|
|
57
|
-
.join(', ')})
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
.join(', ')})`
|
|
78
|
+
|
|
79
|
+
// Use concise arrow function syntax when there are no statements and only a return value
|
|
80
|
+
if (this.implicitReturn && this.returnValue) {
|
|
81
|
+
if (this.returnValue instanceof ObjectShape) {
|
|
82
|
+
return `${params} => (${this.returnValue.getCode()})`
|
|
83
|
+
}
|
|
84
|
+
return `${params} => ${this.returnValue.getCode()}`
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Block body syntax
|
|
88
|
+
const parts = this.getStatements().map((s) => s.getCode())
|
|
89
|
+
if (this.returnValue) {
|
|
90
|
+
parts.push(`return ${this.returnValue.getCode()}`)
|
|
91
|
+
}
|
|
92
|
+
return `${params} => {\n ${parts.join('\n ')}\n}`
|
|
60
93
|
}
|
|
61
94
|
}
|
|
62
95
|
|
|
63
96
|
export const ArrowFunctionPlugin = Plugin.create({
|
|
64
97
|
name: 'ArrowFunctionPlugin',
|
|
98
|
+
docs: [],
|
|
65
99
|
nodes: [
|
|
100
|
+
/**
|
|
101
|
+
* Catch-all handler for ReturnStatement nodes encountered outside of arrow functions.
|
|
102
|
+
* Return statements within arrow functions are handled inline by the ArrowFunction
|
|
103
|
+
* node handler below, which extracts the return expression from the last statement.
|
|
104
|
+
* Any ReturnStatement that reaches this handler is outside an arrow function context
|
|
105
|
+
* and is not supported.
|
|
106
|
+
*/
|
|
107
|
+
{
|
|
108
|
+
node: 'ReturnStatement',
|
|
109
|
+
fileTypes: ['fluent'],
|
|
110
|
+
toShape(node, { diagnostics }) {
|
|
111
|
+
diagnostics.error(node, 'Return statements are only supported inside arrow functions')
|
|
112
|
+
return { success: false }
|
|
113
|
+
},
|
|
114
|
+
},
|
|
66
115
|
{
|
|
67
116
|
node: 'ArrowFunction',
|
|
68
117
|
fileTypes: ['fluent'],
|
|
@@ -78,24 +127,64 @@ export const ArrowFunctionPlugin = Plugin.create({
|
|
|
78
127
|
}
|
|
79
128
|
}
|
|
80
129
|
|
|
130
|
+
// Check if this is an expression-body arrow function (concise form) - () => 'value'
|
|
131
|
+
const body = node.getBody()
|
|
132
|
+
const isExpressionBody = body && !ts.Node.isBlock(body)
|
|
133
|
+
|
|
134
|
+
if (isExpressionBody) {
|
|
135
|
+
// Expression body: () => expr - treat the body as the return value
|
|
136
|
+
const result = await transform.toShape(body)
|
|
137
|
+
if (!result.success) {
|
|
138
|
+
diagnostics.error(body, 'Unsupported expression in arrow function body')
|
|
139
|
+
return { success: false }
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
success: true,
|
|
143
|
+
value: new ArrowFunctionShape({
|
|
144
|
+
source: node,
|
|
145
|
+
parameters,
|
|
146
|
+
statements: [],
|
|
147
|
+
returnValue: result.value,
|
|
148
|
+
implicitReturn: true,
|
|
149
|
+
}),
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const nodeStatements = node.getStatements()
|
|
154
|
+
const lastStatement = nodeStatements[nodeStatements.length - 1]
|
|
155
|
+
const hasReturn = lastStatement && ts.Node.isReturnStatement(lastStatement)
|
|
156
|
+
const bodyStatements = hasReturn ? nodeStatements.slice(0, -1) : nodeStatements
|
|
157
|
+
|
|
81
158
|
const statements: Shape[] = []
|
|
82
|
-
for (const statement of
|
|
159
|
+
for (const statement of bodyStatements) {
|
|
83
160
|
const result = await transform.toShape(statement)
|
|
84
161
|
if (!result.success) {
|
|
85
162
|
diagnostics.error(statement, 'Unsupported statement in arrow function body')
|
|
86
163
|
return { success: false }
|
|
87
164
|
}
|
|
88
|
-
|
|
89
165
|
statements.push(result.value)
|
|
90
166
|
}
|
|
91
167
|
|
|
168
|
+
let returnValue: Shape | undefined
|
|
169
|
+
if (hasReturn) {
|
|
170
|
+
const expr = lastStatement.getExpression()
|
|
171
|
+
if (expr) {
|
|
172
|
+
const result = await transform.toShape(expr)
|
|
173
|
+
if (!result.success) {
|
|
174
|
+
diagnostics.error(lastStatement, 'Unsupported expression in return statement')
|
|
175
|
+
return { success: false }
|
|
176
|
+
}
|
|
177
|
+
returnValue = result.value
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const args = { source: node, parameters, statements }
|
|
182
|
+
|
|
92
183
|
return {
|
|
93
184
|
success: true,
|
|
94
|
-
value:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
statements,
|
|
98
|
-
}),
|
|
185
|
+
value: returnValue
|
|
186
|
+
? new ArrowFunctionShape({ ...args, returnValue })
|
|
187
|
+
: new ArrowFunctionShape(args),
|
|
99
188
|
}
|
|
100
189
|
},
|
|
101
190
|
},
|
|
@@ -110,7 +199,19 @@ export const ArrowFunctionPlugin = Plugin.create({
|
|
|
110
199
|
|
|
111
200
|
const nodeStatements = arrowFunction.getStatements()
|
|
112
201
|
const shapeStatements = shape.getStatements()
|
|
113
|
-
const
|
|
202
|
+
const returnValue = shape.getReturnValue()
|
|
203
|
+
|
|
204
|
+
if (ts.Node.isArrowFunction(target)) {
|
|
205
|
+
const body = target.getBody()
|
|
206
|
+
if (!ts.Node.isBlock(body) && shapeStatements.length === 0 && returnValue) {
|
|
207
|
+
// Already inline form - commit directly to the expression
|
|
208
|
+
await commit(returnValue, body)
|
|
209
|
+
return { success: true }
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const totalExpected = shapeStatements.length + (returnValue ? 1 : 0)
|
|
214
|
+
const excess = nodeStatements.length - totalExpected
|
|
114
215
|
for (let i = 1; i <= excess; i++) {
|
|
115
216
|
arrowFunction.removeStatement(nodeStatements.length - i)
|
|
116
217
|
}
|
|
@@ -120,6 +221,20 @@ export const ArrowFunctionPlugin = Plugin.create({
|
|
|
120
221
|
await commit(statement, targetStatement)
|
|
121
222
|
}
|
|
122
223
|
|
|
224
|
+
if (returnValue) {
|
|
225
|
+
const returnIndex = shapeStatements.length
|
|
226
|
+
const targetReturn =
|
|
227
|
+
nodeStatements[returnIndex] ?? arrowFunction.addStatements('return undefined')[0]!
|
|
228
|
+
if (ts.Node.isReturnStatement(targetReturn)) {
|
|
229
|
+
const expr = targetReturn.getExpression()
|
|
230
|
+
if (expr) {
|
|
231
|
+
await commit(returnValue, expr)
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
targetReturn.replaceWithText(`return ${returnValue.getCode()}`)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
123
238
|
return { success: true }
|
|
124
239
|
},
|
|
125
240
|
},
|
package/src/atf/test-plugin.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from '@servicenow/sdk-build-core'
|
|
20
20
|
import { NowIdShape } from '../now-id-plugin'
|
|
21
21
|
import { ArrowFunctionShape } from '../arrow-function-plugin'
|
|
22
|
+
import { createSdkDocEntry } from '../utils'
|
|
22
23
|
import { create } from 'xmlbuilder2'
|
|
23
24
|
import { Test } from '@servicenow/sdk-core/runtime/app'
|
|
24
25
|
import {
|
|
@@ -33,6 +34,7 @@ import type { Duration } from '@servicenow/sdk/core'
|
|
|
33
34
|
|
|
34
35
|
export const TestPlugin = Plugin.create({
|
|
35
36
|
name: 'TestPlugin',
|
|
37
|
+
docs: [createSdkDocEntry('Test', ['sys_atf_test'])],
|
|
36
38
|
records: {
|
|
37
39
|
sys_atf_test: {
|
|
38
40
|
relationships: {
|
|
@@ -30,9 +30,11 @@ import {
|
|
|
30
30
|
} from '@servicenow/sdk-build-core'
|
|
31
31
|
import { isDataHelper } from './data-plugin'
|
|
32
32
|
import { getCallExpressionName } from './utils'
|
|
33
|
+
import { NowIncludePlugin, NowIncludeShape } from './now-include-plugin'
|
|
33
34
|
|
|
34
35
|
export const BasicSyntaxPlugin = Plugin.create({
|
|
35
36
|
name: 'BasicSyntaxPlugin',
|
|
37
|
+
docs: [],
|
|
36
38
|
files: [
|
|
37
39
|
{
|
|
38
40
|
entryPoint: true,
|
|
@@ -309,6 +311,7 @@ export const BasicSyntaxPlugin = Plugin.create({
|
|
|
309
311
|
|
|
310
312
|
const propsToRetain = new Set<string>(['$meta'])
|
|
311
313
|
const propsToAdd: ts.PropertyAssignmentStructure[] = []
|
|
314
|
+
const nowIncludePropsToCommit = new Set<string>()
|
|
312
315
|
for (const [name, value] of shape.entries({ resolve: false })) {
|
|
313
316
|
const existingPropKey = [...shape.getAliases(name), name].find((aliasedKey) =>
|
|
314
317
|
existingNames.has(aliasedKey)
|
|
@@ -324,6 +327,9 @@ export const BasicSyntaxPlugin = Plugin.create({
|
|
|
324
327
|
|
|
325
328
|
await commit(value, existingNames.get(existingPropKey) as ts.Expression)
|
|
326
329
|
} else if (!value.equals(shape.getDefault(name))) {
|
|
330
|
+
if (value.is(NowIncludeShape)) {
|
|
331
|
+
nowIncludePropsToCommit.add(name)
|
|
332
|
+
}
|
|
327
333
|
propsToAdd.push({
|
|
328
334
|
name: ObjectShape.quotePropertyNameIfNeeded(name),
|
|
329
335
|
initializer: value.getCode(),
|
|
@@ -338,6 +344,15 @@ export const BasicSyntaxPlugin = Plugin.create({
|
|
|
338
344
|
target.addPropertyAssignments(propsToAdd)
|
|
339
345
|
}
|
|
340
346
|
|
|
347
|
+
// commit Now.include props to generate the include file.
|
|
348
|
+
for (const prop of nowIncludePropsToCommit) {
|
|
349
|
+
const includeInitializer = target
|
|
350
|
+
.getPropertyOrThrow(prop)
|
|
351
|
+
.asKindOrThrow(ts.SyntaxKind.PropertyAssignment)
|
|
352
|
+
.getInitializerOrThrow()
|
|
353
|
+
await commit(shape.get(prop, false), includeInitializer, NowIncludePlugin)
|
|
354
|
+
}
|
|
355
|
+
|
|
341
356
|
const propsToRemove = [...existingNames.keys()].filter((key) => !propsToRetain.has(key))
|
|
342
357
|
propsToRemove.forEach((prop) => {
|
|
343
358
|
target.getProperty(prop)?.asKindOrThrow(ts.SyntaxKind.PropertyAssignment).remove()
|
|
@@ -544,6 +559,12 @@ export const BasicSyntaxPlugin = Plugin.create({
|
|
|
544
559
|
return transform.toShape(node.getExpression())
|
|
545
560
|
},
|
|
546
561
|
},
|
|
562
|
+
{
|
|
563
|
+
node: 'ParenthesizedExpression',
|
|
564
|
+
toShape(node, { transform }) {
|
|
565
|
+
return transform.toShape(node.getExpression())
|
|
566
|
+
},
|
|
567
|
+
},
|
|
547
568
|
{
|
|
548
569
|
node: 'Identifier',
|
|
549
570
|
async toShape(node, { transform }) {
|
package/src/claims-plugin.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
|
|
2
2
|
import { NowIdShape } from './now-id-plugin'
|
|
3
|
-
import { generateDeprecatedDiagnostics, validateClientSideScript } from './utils'
|
|
3
|
+
import { createSdkDocEntry, generateDeprecatedDiagnostics, validateClientSideScript } from './utils'
|
|
4
4
|
import { NowIncludeShape } from './now-include-plugin'
|
|
5
5
|
|
|
6
6
|
enum UITypeMapping {
|
|
@@ -44,6 +44,7 @@ const clientScriptAliases = {
|
|
|
44
44
|
*/
|
|
45
45
|
export const ClientScriptPlugin = Plugin.create({
|
|
46
46
|
name: 'ClientScriptPlugin',
|
|
47
|
+
docs: [createSdkDocEntry('ClientScript', ['sys_script_client'])],
|
|
47
48
|
records: {
|
|
48
49
|
sys_script_client: {
|
|
49
50
|
async toShape(record, { transform }) {
|
package/src/column-plugin.ts
CHANGED
|
@@ -66,6 +66,7 @@ const documentationAliases = {
|
|
|
66
66
|
|
|
67
67
|
export const ColumnPlugin = Plugin.create({
|
|
68
68
|
name: 'ColumnPlugin',
|
|
69
|
+
docs: [],
|
|
69
70
|
records: {
|
|
70
71
|
sys_choice: {
|
|
71
72
|
coalesce: ['name', 'element', 'value'],
|
|
@@ -91,11 +92,6 @@ export const ColumnPlugin = Plugin.create({
|
|
|
91
92
|
value: `sys_choice_${record.get('name').getValue()}_${record.get('element').getValue()}`,
|
|
92
93
|
}),
|
|
93
94
|
async toFile(choiceSet, { config, descendants, transform }) {
|
|
94
|
-
if (config.tableOutputFormat === 'bootstrap' && config.type === 'package') {
|
|
95
|
-
// Defer to table plugin
|
|
96
|
-
return { success: false }
|
|
97
|
-
}
|
|
98
|
-
|
|
99
95
|
const tableName = choiceSet.get('name').asString().getValue()
|
|
100
96
|
const elementName = choiceSet.get('element').asString().getValue()
|
|
101
97
|
const xml = create().ele('record_update')
|
|
@@ -164,14 +160,14 @@ export const ColumnPlugin = Plugin.create({
|
|
|
164
160
|
factory,
|
|
165
161
|
diagnostics,
|
|
166
162
|
true,
|
|
167
|
-
config.
|
|
163
|
+
config.defaultLanguage
|
|
168
164
|
)
|
|
169
165
|
const choiceRecords = await getChoiceRecords(
|
|
170
166
|
callExpression,
|
|
171
167
|
choiceAliases,
|
|
172
168
|
factory,
|
|
173
169
|
diagnostics,
|
|
174
|
-
config.
|
|
170
|
+
config.defaultLanguage
|
|
175
171
|
)
|
|
176
172
|
const choiceSetRecords: Record[] = []
|
|
177
173
|
if (choiceRecords.length > 0) {
|
|
@@ -355,7 +351,7 @@ export const ColumnPlugin = Plugin.create({
|
|
|
355
351
|
.map((f) => f.isString() && f.getValue() !== '')
|
|
356
352
|
.def(false),
|
|
357
353
|
column_label: $.from('label')
|
|
358
|
-
.map((label) => getLabelForDefaultLanguage(label, config.
|
|
354
|
+
.map((label) => getLabelForDefaultLanguage(label, config.defaultLanguage))
|
|
359
355
|
.def(column.get('name').asString()),
|
|
360
356
|
mandatory: $.toBoolean().def(false),
|
|
361
357
|
max_length: $.from('maxLength')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
|
|
2
2
|
import { NowIdShape } from './now-id-plugin'
|
|
3
|
-
import { generateDeprecatedDiagnostics } from './utils'
|
|
3
|
+
import { createSdkDocEntry, generateDeprecatedDiagnostics } from './utils'
|
|
4
4
|
|
|
5
5
|
const crossScopeAliases = {
|
|
6
6
|
targetName: ['target_name'],
|
|
@@ -23,6 +23,7 @@ const crossScopeAliases = {
|
|
|
23
23
|
*/
|
|
24
24
|
export const CrossScopePrivilegePlugin = Plugin.create({
|
|
25
25
|
name: 'CrossScopePrivilegePlugin',
|
|
26
|
+
docs: [createSdkDocEntry('CrossScopePrivilege', ['sys_scope_privilege'])],
|
|
26
27
|
records: {
|
|
27
28
|
sys_scope_privilege: {
|
|
28
29
|
relationships: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CallExpressionShape, type ObjectShape, Plugin, type Record as RecordType } from '@servicenow/sdk-build-core'
|
|
2
2
|
import { NowIdShape } from '../now-id-plugin'
|
|
3
3
|
import { resolveComponentToSysId, resolveComponentToName } from './dashboard-component-resolver'
|
|
4
|
+
import { createSdkDocEntry } from '../utils'
|
|
4
5
|
import { DEFAULT_PROPERTY_VALUES, removeRestrictedValues } from './dashboard-component-property-defaults'
|
|
5
6
|
|
|
6
7
|
const transformWidget = (widget: RecordType) =>
|
|
@@ -55,6 +56,7 @@ const createWidgetProperties = (widgetData: ObjectShape, canvas: ObjectShape) =>
|
|
|
55
56
|
*/
|
|
56
57
|
export const DashboardPlugin = Plugin.create({
|
|
57
58
|
name: 'DashboardPlugin',
|
|
59
|
+
docs: [createSdkDocEntry('Dashboard', ['par_dashboard'])],
|
|
58
60
|
records: {
|
|
59
61
|
par_dashboard: {
|
|
60
62
|
relationships: {
|
package/src/data-plugin.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CallExpressionShape,
|
|
3
|
-
Plugin,
|
|
4
|
-
isGUID,
|
|
5
|
-
Shape,
|
|
6
|
-
type ObjectShape,
|
|
7
|
-
type Diagnostics,
|
|
8
|
-
} from '@servicenow/sdk-build-core'
|
|
1
|
+
import { CallExpressionShape, Plugin, isGUID, Shape, type ObjectShape } from '@servicenow/sdk-build-core'
|
|
9
2
|
import { NowIdShape } from './now-id-plugin'
|
|
3
|
+
import { showGuidFieldDiagnostic, createSdkDocEntry } from './utils'
|
|
10
4
|
import type { EmailNotification } from '@servicenow/sdk-core/runtime/notification'
|
|
11
5
|
|
|
12
6
|
// Use index access types instead of exported utility types
|
|
@@ -59,23 +53,9 @@ const isValidEmail = (email: string): boolean => {
|
|
|
59
53
|
return emailRegex.test(email)
|
|
60
54
|
}
|
|
61
55
|
|
|
62
|
-
const showGuidFieldDiagnostic = (
|
|
63
|
-
inputReceived: Shape | undefined,
|
|
64
|
-
fieldName: string,
|
|
65
|
-
tableName: string,
|
|
66
|
-
diagnostics: Diagnostics
|
|
67
|
-
) => {
|
|
68
|
-
if (inputReceived) {
|
|
69
|
-
const receivedValue = inputReceived.getValue()
|
|
70
|
-
diagnostics.error(
|
|
71
|
-
inputReceived,
|
|
72
|
-
`'${fieldName}' must be a valid GUID or a Record<'${tableName}'>. Received: '${receivedValue}'`
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
56
|
export const EmailNotificationPlugin = Plugin.create({
|
|
78
57
|
name: 'EmailNotificationPlugin',
|
|
58
|
+
docs: [createSdkDocEntry('EmailNotification', ['sysevent_email_action'])],
|
|
79
59
|
records: {
|
|
80
60
|
sysevent_email_action: {
|
|
81
61
|
toShape(record) {
|
|
@@ -433,7 +433,7 @@ function validateSetFlowVariables(expr: FlowLogicInstanceShape): string | undefi
|
|
|
433
433
|
* Performs comprehensive validation of arguments, types, structure, and placement.
|
|
434
434
|
*
|
|
435
435
|
* **Validations performed:**
|
|
436
|
-
* 1. Placement: Must be within a Subflow
|
|
436
|
+
* 1. Placement: Must be within a Subflow() definition (not in regular Flow)
|
|
437
437
|
* 2. Argument count: Must have exactly 3 arguments
|
|
438
438
|
* 3. Config object: Must contain required $id property
|
|
439
439
|
* 4. Schema argument: Must be params.outputs (schema reference)
|
|
@@ -450,7 +450,7 @@ function validateSetFlowVariables(expr: FlowLogicInstanceShape): string | undefi
|
|
|
450
450
|
* - Datapills: params.action.result, params.complexObject (PropertyAccessShape)
|
|
451
451
|
* - Template expressions: `Result: ${params.action.result}` (TemplateExpressionShape)
|
|
452
452
|
*
|
|
453
|
-
* **Important:** AssignSubflowOutputs can ONLY be used within Subflow
|
|
453
|
+
* **Important:** AssignSubflowOutputs can ONLY be used within a Subflow() definition.
|
|
454
454
|
* Using it in a regular Flow will result in a validation error.
|
|
455
455
|
*
|
|
456
456
|
* @param expr - The AssignSubflowOutputs flow logic instance shape
|
|
@@ -473,12 +473,11 @@ function validateAssignSubflowOutputs(expr: FlowLogicInstanceShape): string | un
|
|
|
473
473
|
return undefined
|
|
474
474
|
}
|
|
475
475
|
|
|
476
|
-
// Validate that this is called within a
|
|
476
|
+
// Validate that this is called within a Subflow() definition
|
|
477
477
|
const node = expr.getOriginalNode()
|
|
478
|
-
const subflowAncestor =
|
|
479
|
-
findAncestorByCalleeName(node, 'SubflowDefinition') || findAncestorByCalleeName(node, 'Subflow')
|
|
478
|
+
const subflowAncestor = findAncestorByCalleeName(node, 'Subflow')
|
|
480
479
|
if (!subflowAncestor) {
|
|
481
|
-
return 'AssignSubflowOutputs can only be used within a
|
|
480
|
+
return 'AssignSubflowOutputs can only be used within a Subflow'
|
|
482
481
|
}
|
|
483
482
|
|
|
484
483
|
// Validate argument count
|
|
@@ -130,7 +130,7 @@ type FlowLogicParseResult =
|
|
|
130
130
|
* FlowLogicValueInput objects with name/value pairs that represent the
|
|
131
131
|
* original TypeScript configuration properties.
|
|
132
132
|
*/
|
|
133
|
-
namespace FlowLogicValueProcessor {
|
|
133
|
+
export namespace FlowLogicValueProcessor {
|
|
134
134
|
/**
|
|
135
135
|
* Generic factory function for creating flow logic entry objects.
|
|
136
136
|
* All entry types (AssignSubflowOutput, SetFlowVariablesInput, FlowLogicValueInput)
|
|
@@ -766,8 +766,6 @@ namespace FlowLogicValueProcessor {
|
|
|
766
766
|
// Constants for type handling
|
|
767
767
|
const ARRAY_TYPE_PREFIX = 'array.' as const
|
|
768
768
|
const ARRAY_TYPE_PREFIX_LENGTH = ARRAY_TYPE_PREFIX.length
|
|
769
|
-
const EXCLUDED_TYPE_ANNOTATIONS = new Set(['string', 'glide_date_time'])
|
|
770
|
-
|
|
771
769
|
/**
|
|
772
770
|
* Interface for child entry structure used in parsing
|
|
773
771
|
*/
|
|
@@ -829,50 +827,29 @@ namespace FlowLogicValueProcessor {
|
|
|
829
827
|
return value
|
|
830
828
|
}
|
|
831
829
|
|
|
832
|
-
/**
|
|
833
|
-
* Adds type annotation to a datapill if needed based on label cache
|
|
834
|
-
* @param pillName - Datapill name without braces
|
|
835
|
-
* @param labelCacheMap - Map of datapill names to types
|
|
836
|
-
* @returns Datapill with annotation if applicable
|
|
837
|
-
*/
|
|
838
|
-
function addTypeAnnotationIfNeeded(pillName: string, labelCacheMap?: Map<string, string>): string {
|
|
839
|
-
if (!labelCacheMap) {
|
|
840
|
-
return `{{${pillName}}}`
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
const cachedType = labelCacheMap.get(pillName.trim())
|
|
844
|
-
if (cachedType && !EXCLUDED_TYPE_ANNOTATIONS.has(cachedType)) {
|
|
845
|
-
return `{{${pillName}|${cachedType}}}`
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
return `{{${pillName}}}`
|
|
849
|
-
}
|
|
850
|
-
|
|
851
830
|
/**
|
|
852
831
|
* Processes a pure datapill value (starts and ends with {{}})
|
|
832
|
+
* Strips any existing |type annotation and returns a clean datapill.
|
|
833
|
+
* Type info is preserved via labelCacheMap in wrapWithWfaDataPillExpression downstream.
|
|
853
834
|
* @param value - Pure datapill string
|
|
854
|
-
* @param
|
|
855
|
-
* @returns
|
|
835
|
+
* @param _labelCacheMap - Unused (type resolution handled downstream by transformDataPill)
|
|
836
|
+
* @returns Clean datapill without type annotation
|
|
856
837
|
*/
|
|
857
|
-
function processPureDatapill(value: string,
|
|
858
|
-
|
|
859
|
-
const pillName = strippedValue.slice(2, -2) // Remove {{ and }}
|
|
860
|
-
return addTypeAnnotationIfNeeded(pillName, labelCacheMap)
|
|
838
|
+
function processPureDatapill(value: string, _labelCacheMap?: Map<string, string>): string {
|
|
839
|
+
return stripDatapillTypeAnnotation(value)
|
|
861
840
|
}
|
|
862
841
|
|
|
863
842
|
/**
|
|
864
|
-
* Processes a template expression containing datapills mixed with text
|
|
843
|
+
* Processes a template expression containing datapills mixed with text.
|
|
844
|
+
* Strips any existing |type annotations and returns clean datapills.
|
|
845
|
+
* Type info is preserved via labelCacheMap in wrapWithWfaDataPillExpression downstream.
|
|
865
846
|
* @param value - Template expression string
|
|
866
|
-
* @param
|
|
867
|
-
* @returns Processed template with type annotations
|
|
847
|
+
* @param _labelCacheMap - Unused (type resolution handled downstream by transformDataPill)
|
|
848
|
+
* @returns Processed template with type annotations stripped from datapills
|
|
868
849
|
*/
|
|
869
|
-
function processTemplateExpression(value: string,
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
const datapillRegex = /\{\{([^}|]+)(?:\|[^}]+)?\}\}/g
|
|
875
|
-
return value.replace(datapillRegex, (_match, pillName) => addTypeAnnotationIfNeeded(pillName, labelCacheMap))
|
|
850
|
+
function processTemplateExpression(value: string, _labelCacheMap?: Map<string, string>): string {
|
|
851
|
+
const datapillRegex = /\{\{([^}|]+)\|[^}]+\}\}/g
|
|
852
|
+
return value.replace(datapillRegex, '{{$1}}')
|
|
876
853
|
}
|
|
877
854
|
|
|
878
855
|
/**
|
|
@@ -972,12 +949,26 @@ namespace FlowLogicValueProcessor {
|
|
|
972
949
|
if (parsed.complexObjectSchema) {
|
|
973
950
|
// Find the $COCollectionField.$type_facets
|
|
974
951
|
for (const schemaKey in parsed.complexObjectSchema) {
|
|
952
|
+
// Skip top-level $type_facets entries (handled as fallback below)
|
|
953
|
+
if (schemaKey.endsWith('.$type_facets')) {
|
|
954
|
+
continue
|
|
955
|
+
}
|
|
975
956
|
const schema = parsed.complexObjectSchema[schemaKey]
|
|
976
|
-
if (schema && schema.$COCollectionField
|
|
977
|
-
|
|
978
|
-
if (
|
|
979
|
-
const facetData = JSON.parse(
|
|
980
|
-
|
|
957
|
+
if (schema && schema.$COCollectionField) {
|
|
958
|
+
// Array.Object format: child_type nested as $COCollectionField.$type_facets
|
|
959
|
+
if (schema['$COCollectionField.$type_facets']?.SimpleMapFacet) {
|
|
960
|
+
const facetData = JSON.parse(schema['$COCollectionField.$type_facets'].SimpleMapFacet)
|
|
961
|
+
if (facetData.child_type) {
|
|
962
|
+
return facetData.child_type
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
// DEF0798866: Array.String format: child_type stored in top-level key "schemaKey.$type_facets"
|
|
966
|
+
const topLevelTypeFacets = parsed.complexObjectSchema[`${schemaKey}.$type_facets`]
|
|
967
|
+
if (topLevelTypeFacets?.SimpleMapFacet) {
|
|
968
|
+
const facetData = JSON.parse(topLevelTypeFacets.SimpleMapFacet)
|
|
969
|
+
if (facetData.child_type) {
|
|
970
|
+
return facetData.child_type
|
|
971
|
+
}
|
|
981
972
|
}
|
|
982
973
|
}
|
|
983
974
|
}
|
|
@@ -1081,8 +1072,15 @@ namespace FlowLogicValueProcessor {
|
|
|
1081
1072
|
const firstBaseName = getBaseName(childObj.name)
|
|
1082
1073
|
|
|
1083
1074
|
// Check if all children have the same base name (indicating FlowArray with repeated childName)
|
|
1075
|
+
// When elementType is defined (i.e., the schema identifies this as a FlowArray — Array.Object,
|
|
1076
|
+
// Array.String, Array.Integer, Array.DateTime, etc.), a single child is still a valid array
|
|
1077
|
+
// element: the child is the childName wrapper whose inner value/children are the actual element.
|
|
1078
|
+
// Without this, single-element FlowArray assignments fall into the object path, generating
|
|
1079
|
+
// { childName: { fields } } or { childName: value } instead of [{ fields }] or [value].
|
|
1080
|
+
// DEF0798866: single-element Array.Object/String subflow outputs generated incorrect Fluent code.
|
|
1081
|
+
const minChildrenForArray = elementType !== undefined ? 1 : 2
|
|
1084
1082
|
const allSameName =
|
|
1085
|
-
children.length
|
|
1083
|
+
children.length >= minChildrenForArray &&
|
|
1086
1084
|
children.every((c) => {
|
|
1087
1085
|
const entry = c as ChildEntry
|
|
1088
1086
|
return getBaseName(entry.name) === firstBaseName
|
|
@@ -1525,7 +1523,11 @@ namespace FlowLogicValueProcessor {
|
|
|
1525
1523
|
// Ignore parse errors
|
|
1526
1524
|
}
|
|
1527
1525
|
}
|
|
1528
|
-
|
|
1526
|
+
// DEF0798866: Use typeMap as fallback when schema-based detection fails.
|
|
1527
|
+
// If entry.value doesn't contain complexObjectSchema (e.g., some ServiceNow XML
|
|
1528
|
+
// formats omit the schema), fall back to the typeMap which always contains the
|
|
1529
|
+
// output/variable type (e.g., 'array.string' -> 'string' element type).
|
|
1530
|
+
const elementType = getArrayElementType(entry) ?? extractArrayElementType(typeMap?.get(entry.name))
|
|
1529
1531
|
const nestedTypeMap = extractNestedTypeSchema(entry)
|
|
1530
1532
|
const parsedValue = parseChildrenArray(
|
|
1531
1533
|
entry.children,
|