@servicenow/sdk-build-plugins 3.0.2 → 4.0.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.d.ts +19 -0
- package/dist/acl-plugin.js +210 -0
- package/dist/acl-plugin.js.map +1 -0
- package/dist/application-menu-plugin.d.ts +18 -0
- package/dist/application-menu-plugin.js +104 -0
- package/dist/application-menu-plugin.js.map +1 -0
- package/dist/arrow-function-plugin.d.ts +16 -0
- package/dist/arrow-function-plugin.js +107 -0
- package/dist/arrow-function-plugin.js.map +1 -0
- package/dist/atf/step-configs.d.ts +37 -0
- package/dist/atf/step-configs.js +2236 -0
- package/dist/atf/step-configs.js.map +1 -0
- package/dist/atf/test-plugin.d.ts +4 -0
- package/dist/atf/test-plugin.js +591 -0
- package/dist/atf/test-plugin.js.map +1 -0
- package/dist/basic-syntax-plugin.d.ts +2 -0
- package/dist/basic-syntax-plugin.js +636 -0
- package/dist/basic-syntax-plugin.js.map +1 -0
- package/dist/business-rule-plugin.d.ts +3 -0
- package/dist/business-rule-plugin.js +205 -0
- package/dist/business-rule-plugin.js.map +1 -0
- package/dist/call-expression-plugin.d.ts +2 -0
- package/dist/call-expression-plugin.js +175 -0
- package/dist/call-expression-plugin.js.map +1 -0
- package/dist/client-script-plugin.d.ts +29 -0
- package/dist/client-script-plugin.js +157 -0
- package/dist/client-script-plugin.js.map +1 -0
- package/dist/column/column-helper.d.ts +12 -0
- package/dist/column/column-helper.js +84 -0
- package/dist/column/column-helper.js.map +1 -0
- package/dist/column/column-to-record.d.ts +3 -0
- package/dist/column/column-to-record.js +105 -0
- package/dist/column/column-to-record.js.map +1 -0
- package/dist/column-plugin.d.ts +8 -0
- package/dist/column-plugin.js +453 -0
- package/dist/column-plugin.js.map +1 -0
- package/dist/cross-scope-privilege-plugin.d.ts +15 -0
- package/dist/cross-scope-privilege-plugin.js +82 -0
- package/dist/cross-scope-privilege-plugin.js.map +1 -0
- package/dist/html-import-plugin.d.ts +2 -0
- package/dist/html-import-plugin.js +72 -0
- package/dist/html-import-plugin.js.map +1 -0
- package/dist/index.d.ts +37 -21
- package/dist/index.js +40 -45
- package/dist/index.js.map +1 -1
- package/dist/json-plugin.d.ts +15 -0
- package/dist/json-plugin.js +104 -0
- package/dist/json-plugin.js.map +1 -0
- package/dist/list-plugin.d.ts +2 -0
- package/dist/list-plugin.js +191 -0
- package/dist/list-plugin.js.map +1 -0
- package/dist/now-config-plugin.d.ts +4 -0
- package/dist/now-config-plugin.js +154 -0
- package/dist/now-config-plugin.js.map +1 -0
- package/dist/now-id-plugin.d.ts +11 -0
- package/dist/now-id-plugin.js +71 -0
- package/dist/now-id-plugin.js.map +1 -0
- package/dist/now-include-plugin.d.ts +16 -0
- package/dist/now-include-plugin.js +118 -0
- package/dist/now-include-plugin.js.map +1 -0
- package/dist/now-ref-plugin.d.ts +2 -0
- package/dist/now-ref-plugin.js +43 -0
- package/dist/now-ref-plugin.js.map +1 -0
- package/dist/now-unresolved-plugin.d.ts +2 -0
- package/dist/now-unresolved-plugin.js +32 -0
- package/dist/now-unresolved-plugin.js.map +1 -0
- package/dist/package-json-plugin.d.ts +2 -0
- package/dist/package-json-plugin.js +70 -0
- package/dist/package-json-plugin.js.map +1 -0
- package/dist/property-plugin.d.ts +2 -0
- package/dist/property-plugin.js +105 -0
- package/dist/property-plugin.js.map +1 -0
- package/dist/record-plugin.d.ts +43 -0
- package/dist/record-plugin.js +147 -0
- package/dist/record-plugin.js.map +1 -0
- package/dist/repack/index.d.ts +1 -0
- package/dist/repack/index.js +10 -2
- package/dist/repack/index.js.map +1 -1
- package/dist/repack/lint/Rules.d.ts +1 -1
- package/dist/repack/lint/Rules.js +7 -3
- package/dist/repack/lint/Rules.js.map +1 -1
- package/dist/repack/lint/index.js +1 -1
- package/dist/rest-api-plugin.d.ts +2 -0
- package/dist/rest-api-plugin.js +469 -0
- package/dist/rest-api-plugin.js.map +1 -0
- package/dist/role-plugin.d.ts +2 -0
- package/dist/role-plugin.js +117 -0
- package/dist/role-plugin.js.map +1 -0
- package/dist/script-action-plugin.d.ts +2 -0
- package/dist/script-action-plugin.js +62 -0
- package/dist/script-action-plugin.js.map +1 -0
- package/dist/script-include-plugin.d.ts +2 -0
- package/dist/script-include-plugin.js +102 -0
- package/dist/script-include-plugin.js.map +1 -0
- package/dist/server-module-plugin/index.d.ts +14 -0
- package/dist/server-module-plugin/index.js +378 -0
- package/dist/server-module-plugin/index.js.map +1 -0
- package/dist/server-module-plugin/sbom-builder.d.ts +45 -0
- package/dist/server-module-plugin/sbom-builder.js +179 -0
- package/dist/server-module-plugin/sbom-builder.js.map +1 -0
- package/dist/service-portal/angular-provider-plugin.d.ts +2 -0
- package/dist/service-portal/angular-provider-plugin.js +78 -0
- package/dist/service-portal/angular-provider-plugin.js.map +1 -0
- package/dist/service-portal/dependency-plugin.d.ts +2 -0
- package/dist/service-portal/dependency-plugin.js +235 -0
- package/dist/service-portal/dependency-plugin.js.map +1 -0
- package/dist/service-portal/widget-plugin.d.ts +6 -0
- package/dist/service-portal/widget-plugin.js +230 -0
- package/dist/service-portal/widget-plugin.js.map +1 -0
- package/dist/static-content-plugin.d.ts +2 -0
- package/dist/static-content-plugin.js +272 -0
- package/dist/static-content-plugin.js.map +1 -0
- package/dist/table-plugin.d.ts +3 -0
- package/dist/table-plugin.js +1324 -0
- package/dist/table-plugin.js.map +1 -0
- package/dist/ui-action-plugin.d.ts +2 -0
- package/dist/ui-action-plugin.js +291 -0
- package/dist/ui-action-plugin.js.map +1 -0
- package/dist/ui-page-plugin.d.ts +2 -0
- package/dist/ui-page-plugin.js +165 -0
- package/dist/ui-page-plugin.js.map +1 -0
- package/dist/user-preference-plugin.d.ts +15 -0
- package/dist/user-preference-plugin.js +63 -0
- package/dist/user-preference-plugin.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.js +72 -0
- package/dist/utils.js.map +1 -0
- package/dist/view-plugin.d.ts +2 -0
- package/dist/view-plugin.js +45 -0
- package/dist/view-plugin.js.map +1 -0
- package/package.json +17 -13
- package/src/acl-plugin.ts +256 -0
- package/src/application-menu-plugin.ts +109 -0
- package/src/arrow-function-plugin.ts +127 -0
- package/src/atf/step-configs.ts +2284 -0
- package/src/atf/test-plugin.ts +728 -0
- package/src/basic-syntax-plugin.ts +729 -0
- package/src/business-rule-plugin.ts +266 -0
- package/src/call-expression-plugin.ts +202 -0
- package/src/client-script-plugin.ts +170 -0
- package/src/column/column-helper.ts +119 -0
- package/src/column/column-to-record.ts +131 -0
- package/src/column-plugin.ts +506 -0
- package/src/cross-scope-privilege-plugin.ts +82 -0
- package/src/html-import-plugin.ts +79 -0
- package/src/index.ts +39 -21
- package/src/json-plugin.ts +128 -0
- package/src/list-plugin.ts +222 -0
- package/src/now-config-plugin.ts +194 -0
- package/src/now-id-plugin.ts +78 -0
- package/src/now-include-plugin.ts +140 -0
- package/src/now-ref-plugin.ts +48 -0
- package/src/now-unresolved-plugin.ts +30 -0
- package/src/package-json-plugin.ts +87 -0
- package/src/property-plugin.ts +118 -0
- package/src/record-plugin.ts +171 -0
- package/src/repack/index.ts +10 -1
- package/src/repack/lint/Rules.ts +5 -4
- package/src/repack/lint/index.ts +1 -1
- package/src/rest-api-plugin.ts +651 -0
- package/src/role-plugin.ts +128 -0
- package/src/script-action-plugin.ts +63 -0
- package/src/script-include-plugin.ts +110 -0
- package/src/server-module-plugin/index.ts +470 -0
- package/src/server-module-plugin/sbom-builder.ts +183 -0
- package/src/service-portal/angular-provider-plugin.ts +83 -0
- package/src/service-portal/dependency-plugin.ts +284 -0
- package/src/service-portal/widget-plugin.ts +263 -0
- package/src/static-content-plugin.ts +254 -0
- package/src/table-plugin.ts +1698 -0
- package/src/ui-action-plugin.ts +324 -0
- package/src/ui-page-plugin.ts +168 -0
- package/src/user-preference-plugin.ts +62 -0
- package/src/utils.ts +69 -0
- package/src/view-plugin.ts +46 -0
- package/dist/AttachmentPlugin.d.ts +0 -254
- package/dist/AttachmentPlugin.js +0 -220
- package/dist/AttachmentPlugin.js.map +0 -1
- package/dist/BusinessRulePlugin.d.ts +0 -30
- package/dist/BusinessRulePlugin.js +0 -149
- package/dist/BusinessRulePlugin.js.map +0 -1
- package/dist/CrossScopePrivilegePlugin.d.ts +0 -35
- package/dist/CrossScopePrivilegePlugin.js +0 -80
- package/dist/CrossScopePrivilegePlugin.js.map +0 -1
- package/dist/DefaultPlugin.d.ts +0 -86
- package/dist/DefaultPlugin.js +0 -226
- package/dist/DefaultPlugin.js.map +0 -1
- package/dist/HtmlTemplatePlugin.d.ts +0 -21
- package/dist/HtmlTemplatePlugin.js +0 -29
- package/dist/HtmlTemplatePlugin.js.map +0 -1
- package/dist/IdPlugin.d.ts +0 -28
- package/dist/IdPlugin.js +0 -68
- package/dist/IdPlugin.js.map +0 -1
- package/dist/IncludePlugin.d.ts +0 -34
- package/dist/IncludePlugin.js +0 -155
- package/dist/IncludePlugin.js.map +0 -1
- package/dist/JsonPlugin.d.ts +0 -28
- package/dist/JsonPlugin.js +0 -69
- package/dist/JsonPlugin.js.map +0 -1
- package/dist/ListPlugin.d.ts +0 -93
- package/dist/ListPlugin.js +0 -456
- package/dist/ListPlugin.js.map +0 -1
- package/dist/NowConfigPlugin.d.ts +0 -45
- package/dist/NowConfigPlugin.js +0 -64
- package/dist/NowConfigPlugin.js.map +0 -1
- package/dist/PackageJsonPlugin.d.ts +0 -34
- package/dist/PackageJsonPlugin.js +0 -63
- package/dist/PackageJsonPlugin.js.map +0 -1
- package/dist/PropertyPlugin.d.ts +0 -51
- package/dist/PropertyPlugin.js +0 -181
- package/dist/PropertyPlugin.js.map +0 -1
- package/dist/ScriptTemplatePlugin.d.ts +0 -13
- package/dist/ScriptTemplatePlugin.js +0 -55
- package/dist/ScriptTemplatePlugin.js.map +0 -1
- package/dist/ServerModulePlugin.d.ts +0 -75
- package/dist/ServerModulePlugin.js +0 -368
- package/dist/ServerModulePlugin.js.map +0 -1
- package/dist/UserPreferencePlugin.d.ts +0 -19
- package/dist/UserPreferencePlugin.js +0 -32
- package/dist/UserPreferencePlugin.js.map +0 -1
- package/dist/aclAndRole/AclPlugin.d.ts +0 -82
- package/dist/aclAndRole/AclPlugin.js +0 -262
- package/dist/aclAndRole/AclPlugin.js.map +0 -1
- package/dist/aclAndRole/RolePlugin.d.ts +0 -66
- package/dist/aclAndRole/RolePlugin.js +0 -179
- package/dist/aclAndRole/RolePlugin.js.map +0 -1
- package/dist/aclAndRole/Util.d.ts +0 -3
- package/dist/aclAndRole/Util.js +0 -90
- package/dist/aclAndRole/Util.js.map +0 -1
- package/dist/app/ApplicationMenuPlugin.d.ts +0 -34
- package/dist/app/ApplicationMenuPlugin.js +0 -112
- package/dist/app/ApplicationMenuPlugin.js.map +0 -1
- package/dist/db/ColumnPlugins.d.ts +0 -750
- package/dist/db/ColumnPlugins.js +0 -114
- package/dist/db/ColumnPlugins.js.map +0 -1
- package/dist/db/DBUtils.d.ts +0 -2
- package/dist/db/DBUtils.js +0 -27
- package/dist/db/DBUtils.js.map +0 -1
- package/dist/db/DocumentationPlugin.d.ts +0 -67
- package/dist/db/DocumentationPlugin.js +0 -258
- package/dist/db/DocumentationPlugin.js.map +0 -1
- package/dist/db/LicensingPlugin.d.ts +0 -60
- package/dist/db/LicensingPlugin.js +0 -117
- package/dist/db/LicensingPlugin.js.map +0 -1
- package/dist/db/RecordPlugin.d.ts +0 -133
- package/dist/db/RecordPlugin.js +0 -337
- package/dist/db/RecordPlugin.js.map +0 -1
- package/dist/db/TablePlugin.d.ts +0 -231
- package/dist/db/TablePlugin.js +0 -1628
- package/dist/db/TablePlugin.js.map +0 -1
- package/dist/db/index.d.ts +0 -6
- package/dist/db/index.js +0 -32
- package/dist/db/index.js.map +0 -1
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.d.ts +0 -10
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js +0 -373
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RESTSerializationUtils.d.ts +0 -13
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js +0 -177
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RestApiPlugin.d.ts +0 -81
- package/dist/scriptedRESTAPI/RestApiPlugin.js +0 -345
- package/dist/scriptedRESTAPI/RestApiPlugin.js.map +0 -1
- package/dist/scriptedRESTAPI/RestSchemaUtils.d.ts +0 -190
- package/dist/scriptedRESTAPI/RestSchemaUtils.js +0 -53
- package/dist/scriptedRESTAPI/RestSchemaUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RestUtils.d.ts +0 -69
- package/dist/scriptedRESTAPI/RestUtils.js +0 -497
- package/dist/scriptedRESTAPI/RestUtils.js.map +0 -1
- package/dist/scripts/ClientScriptPlugin.d.ts +0 -64
- package/dist/scripts/ClientScriptPlugin.js +0 -170
- package/dist/scripts/ClientScriptPlugin.js.map +0 -1
- package/dist/scripts/scriptUtils.d.ts +0 -1
- package/dist/scripts/scriptUtils.js +0 -9
- package/dist/scripts/scriptUtils.js.map +0 -1
- package/dist/uxf/ExperiencePlugin.d.ts +0 -45
- package/dist/uxf/ExperiencePlugin.js +0 -61
- package/dist/uxf/ExperiencePlugin.js.map +0 -1
- package/dist/uxf/RoutesPlugin.d.ts +0 -29
- package/dist/uxf/RoutesPlugin.js +0 -181
- package/dist/uxf/RoutesPlugin.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/cleanUxValue.d.ts +0 -4
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js +0 -65
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/api.d.ts +0 -189
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js +0 -158
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.d.ts +0 -13
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -604
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.d.ts +0 -12
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.d.ts +0 -31
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -64
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/index.d.ts +0 -3
- package/dist/uxf/UxfFormulaParser/index.js +0 -11
- package/dist/uxf/UxfFormulaParser/index.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/parser.d.ts +0 -8
- package/dist/uxf/UxfFormulaParser/parser.js +0 -87
- package/dist/uxf/UxfFormulaParser/parser.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.d.ts +0 -8
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js +0 -17
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js.map +0 -1
- package/dist/uxf/constants.d.ts +0 -2
- package/dist/uxf/constants.js +0 -8
- package/dist/uxf/constants.js.map +0 -1
- package/dist/uxf/index.d.ts +0 -2
- package/dist/uxf/index.js +0 -11
- package/dist/uxf/index.js.map +0 -1
- package/dist/uxf/tectonicIdGenerator.d.ts +0 -12
- package/dist/uxf/tectonicIdGenerator.js +0 -79
- package/dist/uxf/tectonicIdGenerator.js.map +0 -1
- package/src/AttachmentPlugin.ts +0 -268
- package/src/BusinessRulePlugin.ts +0 -238
- package/src/CrossScopePrivilegePlugin.ts +0 -115
- package/src/DefaultPlugin.ts +0 -288
- package/src/HtmlTemplatePlugin.ts +0 -31
- package/src/IdPlugin.ts +0 -74
- package/src/IncludePlugin.ts +0 -206
- package/src/JsonPlugin.ts +0 -76
- package/src/ListPlugin.ts +0 -570
- package/src/NowConfigPlugin.ts +0 -69
- package/src/PackageJsonPlugin.ts +0 -68
- package/src/PropertyPlugin.ts +0 -237
- package/src/ScriptTemplatePlugin.ts +0 -53
- package/src/ServerModulePlugin.ts +0 -480
- package/src/UserPreferencePlugin.ts +0 -45
- package/src/aclAndRole/AclPlugin.ts +0 -420
- package/src/aclAndRole/RolePlugin.ts +0 -254
- package/src/aclAndRole/Util.ts +0 -113
- package/src/app/ApplicationMenuPlugin.ts +0 -165
- package/src/db/ColumnPlugins.ts +0 -114
- package/src/db/DBUtils.ts +0 -36
- package/src/db/DocumentationPlugin.ts +0 -316
- package/src/db/LicensingPlugin.ts +0 -138
- package/src/db/RecordPlugin.ts +0 -459
- package/src/db/TablePlugin.ts +0 -2070
- package/src/db/index.ts +0 -6
- package/src/scriptedRESTAPI/RESTDeserializationUtils.ts +0 -419
- package/src/scriptedRESTAPI/RESTSerializationUtils.ts +0 -228
- package/src/scriptedRESTAPI/RestApiPlugin.ts +0 -469
- package/src/scriptedRESTAPI/RestSchemaUtils.ts +0 -72
- package/src/scriptedRESTAPI/RestUtils.ts +0 -569
- package/src/scripts/ClientScriptPlugin.ts +0 -257
- package/src/scripts/scriptUtils.ts +0 -5
- package/src/uxf/ExperiencePlugin.ts +0 -67
- package/src/uxf/RoutesPlugin.ts +0 -211
- package/src/uxf/UxfFormulaParser/cleanUxValue.ts +0 -73
- package/src/uxf/UxfFormulaParser/grammerParser/api.js +0 -166
- package/src/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -606
- package/src/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
- package/src/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -65
- package/src/uxf/UxfFormulaParser/index.ts +0 -4
- package/src/uxf/UxfFormulaParser/parser.ts +0 -64
- package/src/uxf/UxfFormulaParser/utils/getErrorMsg.ts +0 -13
- package/src/uxf/constants.ts +0 -4
- package/src/uxf/index.ts +0 -2
- package/src/uxf/tectonicIdGenerator.ts +0 -78
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ts, Plugin, type Source, type Record, ElementAccessExpressionShape } from '@servicenow/sdk-build-core'
|
|
2
|
+
|
|
3
|
+
export class NowIdShape extends ElementAccessExpressionShape {
|
|
4
|
+
constructor({ source, id }: { source: Source; id: string | number }) {
|
|
5
|
+
super({ source, callee: 'Now.ID', arg: id })
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
override getValue(): string | number {
|
|
9
|
+
return this.getArg().getValue()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static override from(record: Record): NowIdShape {
|
|
13
|
+
const id = record.getId().getNowIdKey() ?? record.getId().getValue()
|
|
14
|
+
|
|
15
|
+
return new NowIdShape({ source: record, id })
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override getCode(): string {
|
|
19
|
+
return `Now.ID[${this.getArg().getCode()}]`
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const NowIdPlugin = Plugin.create({
|
|
24
|
+
name: 'NowIdPlugin',
|
|
25
|
+
shapes: [
|
|
26
|
+
{
|
|
27
|
+
shape: ElementAccessExpressionShape,
|
|
28
|
+
fileTypes: ['fluent'],
|
|
29
|
+
toSubclass(expression, { diagnostics }) {
|
|
30
|
+
if (expression.getCallee() !== 'Now.ID') {
|
|
31
|
+
return { success: false }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const arg = expression.getArg()
|
|
35
|
+
if (!arg.isString() && !arg.isNumber()) {
|
|
36
|
+
diagnostics.error(arg, 'Now.ID argument must be a string or number')
|
|
37
|
+
return { success: false }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
value: new NowIdShape({ source: expression, id: arg.getValue().toString() }),
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
nodes: [
|
|
48
|
+
{
|
|
49
|
+
node: 'PropertyAccessExpression',
|
|
50
|
+
fileTypes: ['fluent'],
|
|
51
|
+
async toShape(node, { transform }) {
|
|
52
|
+
if (node.getName() !== '$id') {
|
|
53
|
+
return { success: false }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const identifier = node.getExpressionIfKind(ts.SyntaxKind.Identifier)
|
|
57
|
+
if (!identifier) {
|
|
58
|
+
return { success: false }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const result = await transform.toShape(identifier)
|
|
62
|
+
if (!result.success || !result.value.isIdentifier()) {
|
|
63
|
+
return { success: false }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const record = result.value.resolve()
|
|
67
|
+
if (!record.isRecord()) {
|
|
68
|
+
return { success: false }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
success: true,
|
|
73
|
+
value: record.getId(),
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
})
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ts,
|
|
3
|
+
path as pathModule,
|
|
4
|
+
CallExpressionShape,
|
|
5
|
+
Plugin,
|
|
6
|
+
type ProjectFile,
|
|
7
|
+
type Source,
|
|
8
|
+
StringShape,
|
|
9
|
+
Shape,
|
|
10
|
+
} from '@servicenow/sdk-build-core'
|
|
11
|
+
import { CallExpressionPlugin } from './call-expression-plugin'
|
|
12
|
+
|
|
13
|
+
export class NowIncludeShape extends CallExpressionShape {
|
|
14
|
+
private readonly includedFile: ProjectFile
|
|
15
|
+
|
|
16
|
+
constructor({ source, path, includedFile }: { source: Source; path: string; includedFile: ProjectFile }) {
|
|
17
|
+
super({ source, callee: 'Now.include', args: [path] })
|
|
18
|
+
this.includedFile = includedFile
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getPath(): string {
|
|
22
|
+
return this.getArgument(0).asString().getValue()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getAbsolutePath(): string {
|
|
26
|
+
return this.getIncludedFile().getPath()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getRelativePathFrom(node: ts.Node): string {
|
|
30
|
+
return pathModule.relative(pathModule.dirname(node.getSourceFile().getFilePath()), this.getAbsolutePath())
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getIncludedFile(): ProjectFile {
|
|
34
|
+
return this.includedFile
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override getValue(): string {
|
|
38
|
+
return this.getIncludedFile().getContent()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override toString(): StringShape {
|
|
42
|
+
return Shape.from(this, this.getValue()).asString().withContentType('cdata')
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const NowIncludePlugin = Plugin.create({
|
|
47
|
+
name: 'NowIncludePlugin',
|
|
48
|
+
shapes: [
|
|
49
|
+
{
|
|
50
|
+
shape: CallExpressionShape,
|
|
51
|
+
fileTypes: ['fluent'],
|
|
52
|
+
toSubclass(callExpression, { diagnostics, project }) {
|
|
53
|
+
if (callExpression.getCallee() !== 'Now.include') {
|
|
54
|
+
return { success: false }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const arg = callExpression.getArgument(0)
|
|
58
|
+
if (!arg.isString()) {
|
|
59
|
+
diagnostics.error(arg, 'Now.include() must have a string argument')
|
|
60
|
+
return { success: false }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const path = arg.getValue()
|
|
64
|
+
|
|
65
|
+
if (!/^\.\.?\/.*$/.test(path.trim()) && path.includes('/')) {
|
|
66
|
+
diagnostics.error(arg, 'Now.include() argument must be a relative path')
|
|
67
|
+
return { success: false }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const absolutePath = pathModule.resolve(pathModule.dirname(callExpression.getOriginalFilePath()), path)
|
|
71
|
+
if (!project.isInRootDir(absolutePath)) {
|
|
72
|
+
diagnostics.error(arg, `Included file path is not within project: ${absolutePath}`)
|
|
73
|
+
return { success: false }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let includedFile: ProjectFile
|
|
77
|
+
try {
|
|
78
|
+
includedFile = project.addFile(absolutePath, {
|
|
79
|
+
resolveDependencies: false,
|
|
80
|
+
excludeFromCompiler: true,
|
|
81
|
+
})
|
|
82
|
+
} catch (e) {
|
|
83
|
+
diagnostics.error(arg, `Failed to include file. Reason: ${e instanceof Error ? e.message : e}`)
|
|
84
|
+
return { success: false }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
success: true,
|
|
89
|
+
value: new NowIncludeShape({ source: callExpression, path, includedFile }),
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
shape: NowIncludeShape,
|
|
95
|
+
async commit(shape, target, { transform, commit }) {
|
|
96
|
+
const targetResult = await transform.toShape(target)
|
|
97
|
+
if (!targetResult.success) {
|
|
98
|
+
return { success: false }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const { value: targetShape } = targetResult
|
|
102
|
+
if (targetShape.is(NowIncludeShape)) {
|
|
103
|
+
if (targetShape.getAbsolutePath() === shape.getAbsolutePath()) {
|
|
104
|
+
// It's already a Now.include() call pointing to the same file, so nothing to do
|
|
105
|
+
return { success: true }
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
if (targetShape.equals(shape.getIncludedFile().getContent())) {
|
|
109
|
+
// It's not a Now.include() call, but it's equivalent to the content, so leave it (probably an inline string literal)
|
|
110
|
+
return { success: true }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
await commit(shape, target, CallExpressionPlugin)
|
|
115
|
+
return { success: true }
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
shape: StringShape,
|
|
120
|
+
async commit(shape, target, { transform }) {
|
|
121
|
+
const targetResult = await transform.toShape(target)
|
|
122
|
+
if (!targetResult.success) {
|
|
123
|
+
return { success: false }
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const targetShape = targetResult.value.ifIdentifier()?.resolve() ?? targetResult.value
|
|
127
|
+
if (!targetShape.is(NowIncludeShape)) {
|
|
128
|
+
return { success: false }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const file = targetShape.getIncludedFile()
|
|
132
|
+
if (!shape.equals(file.getContent())) {
|
|
133
|
+
file.setContent(shape.getValue())
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return { success: true }
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Plugin, CallExpressionShape, StringShape, ObjectShape } from '@servicenow/sdk-build-core'
|
|
2
|
+
import { CallExpressionPlugin } from './call-expression-plugin'
|
|
3
|
+
|
|
4
|
+
export const NowRefPlugin = Plugin.create({
|
|
5
|
+
name: 'NowRefPlugin',
|
|
6
|
+
nodes: [
|
|
7
|
+
{
|
|
8
|
+
node: 'CallExpression',
|
|
9
|
+
async toShape(node, { transform, factory }) {
|
|
10
|
+
const result = await transform.toShape(node, CallExpressionPlugin)
|
|
11
|
+
if (
|
|
12
|
+
!result.success ||
|
|
13
|
+
!result.value.is(CallExpressionShape) ||
|
|
14
|
+
result.value.getCallee() !== 'Now.ref'
|
|
15
|
+
) {
|
|
16
|
+
return { success: false }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const callExpression = result.value
|
|
20
|
+
const table = callExpression
|
|
21
|
+
.getArgument(0)
|
|
22
|
+
.asString('The first argument to Now.ref() must be a table name')
|
|
23
|
+
const guidOrKeys = callExpression
|
|
24
|
+
.getArgument(1)
|
|
25
|
+
.as(
|
|
26
|
+
[StringShape, ObjectShape],
|
|
27
|
+
'The second argument to Now.ref() must be a GUID or a coalesce keys object'
|
|
28
|
+
)
|
|
29
|
+
const maybeKeys = callExpression.hasArgument(2)
|
|
30
|
+
? callExpression
|
|
31
|
+
.getArgument(2)
|
|
32
|
+
.asObject('The third argument to Now.ref() must be a coalesce keys object')
|
|
33
|
+
: undefined
|
|
34
|
+
|
|
35
|
+
const [guid, keys] = maybeKeys
|
|
36
|
+
? [guidOrKeys.asString(), maybeKeys] // Now.ref(table, guid, keys)
|
|
37
|
+
: guidOrKeys.isString()
|
|
38
|
+
? [guidOrKeys.asString(), undefined] // Now.ref(table, guid)
|
|
39
|
+
: [undefined, guidOrKeys.asObject()] // Now.ref(table, keys)
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
success: true,
|
|
43
|
+
value: factory.createReference({ source: node, table, guid, keys }),
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Plugin, UnresolvedShape } from '@servicenow/sdk-build-core'
|
|
2
|
+
|
|
3
|
+
export const NowUnresolvedPlugin = Plugin.create({
|
|
4
|
+
name: 'NowUnresolvedPlugin',
|
|
5
|
+
shapes: [
|
|
6
|
+
{
|
|
7
|
+
shape: UnresolvedShape,
|
|
8
|
+
commit(shape, target) {
|
|
9
|
+
target.replaceWithText(shape.getCode())
|
|
10
|
+
return { success: true }
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
nodes: [
|
|
15
|
+
{
|
|
16
|
+
node: 'PropertyAccessExpression',
|
|
17
|
+
fileTypes: ['fluent'],
|
|
18
|
+
toShape(node) {
|
|
19
|
+
if (node.getText() !== UnresolvedShape.CODE) {
|
|
20
|
+
return { success: false }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
success: true,
|
|
25
|
+
value: new UnresolvedShape({ source: node }),
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
})
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type FileSystem,
|
|
3
|
+
type Logger,
|
|
4
|
+
path as pathModule,
|
|
5
|
+
Plugin,
|
|
6
|
+
type ObjectShape,
|
|
7
|
+
Shape,
|
|
8
|
+
} from '@servicenow/sdk-build-core'
|
|
9
|
+
import { RepackService } from './repack'
|
|
10
|
+
import { JsonFileShape } from './json-plugin'
|
|
11
|
+
|
|
12
|
+
export const PackageJsonPlugin = Plugin.create({
|
|
13
|
+
name: 'PackageJsonPlugin',
|
|
14
|
+
shapes: [
|
|
15
|
+
{
|
|
16
|
+
shape: JsonFileShape,
|
|
17
|
+
async toRecord(file, { config, packageJson, project, factory, fs, logger }) {
|
|
18
|
+
if (file.getBaseName() !== 'package.json') {
|
|
19
|
+
return { success: false }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const relativePath = pathModule.relative(project.getRootDir(), file.getPath())
|
|
23
|
+
const sysModulePath = pathModule.join(config.scope, packageJson.name, packageJson.version, relativePath)
|
|
24
|
+
|
|
25
|
+
const sbomRecord = factory.createRecord({
|
|
26
|
+
source: file,
|
|
27
|
+
table: 'sys_module',
|
|
28
|
+
explicitId: 'bom_json',
|
|
29
|
+
properties: {
|
|
30
|
+
path: pathModule.join(config.scope, packageJson.name, packageJson.version, 'bom.json'),
|
|
31
|
+
external_source: false,
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
success: true,
|
|
37
|
+
value: factory
|
|
38
|
+
.createRecord({
|
|
39
|
+
source: file,
|
|
40
|
+
table: 'sys_module',
|
|
41
|
+
explicitId: relativePath.replaceAll(/[./\\]/g, '_'),
|
|
42
|
+
properties: {
|
|
43
|
+
// Module resolution at runtime requires this format
|
|
44
|
+
path: sysModulePath,
|
|
45
|
+
content: Shape.from(
|
|
46
|
+
file,
|
|
47
|
+
await fixDependencyVersion(file.getJson(), {
|
|
48
|
+
fs,
|
|
49
|
+
logger,
|
|
50
|
+
rootDir: project.getRootDir(),
|
|
51
|
+
})
|
|
52
|
+
)
|
|
53
|
+
.asString()
|
|
54
|
+
.withContentType('cdata'),
|
|
55
|
+
external_source: false,
|
|
56
|
+
sys_name: sysModulePath,
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
.with(sbomRecord),
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
async function fixDependencyVersion(json: ObjectShape, context: { fs: FileSystem; logger: Logger; rootDir: string }) {
|
|
67
|
+
const deps = json.get('dependencies').ifObject()
|
|
68
|
+
if (!deps) {
|
|
69
|
+
return JSON.stringify(json.getValue(), null, 2)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const repack = await RepackService.create(context.logger, context.fs, context.rootDir)
|
|
73
|
+
const resolvedDeps = {}
|
|
74
|
+
for (const dep of deps.keys()) {
|
|
75
|
+
const { name, version } = await repack.getResolvedDepDetails(dep)
|
|
76
|
+
resolvedDeps[name] = version
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return JSON.stringify(
|
|
80
|
+
{
|
|
81
|
+
...json.getValue(),
|
|
82
|
+
dependencies: resolvedDeps,
|
|
83
|
+
},
|
|
84
|
+
null,
|
|
85
|
+
2
|
|
86
|
+
)
|
|
87
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { isSNScope } from '@servicenow/sdk-build-core'
|
|
2
|
+
import { CallExpressionShape, Plugin, type Shape } from '@servicenow/sdk-build-core'
|
|
3
|
+
import { NowIdShape } from './now-id-plugin'
|
|
4
|
+
|
|
5
|
+
const getRolesArray = (roles: string): Array<string> => {
|
|
6
|
+
return roles
|
|
7
|
+
.split(',')
|
|
8
|
+
.map((role) => role.trim())
|
|
9
|
+
.filter((role) => role)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const PropertyPlugin = Plugin.create({
|
|
13
|
+
name: 'PropertyPlugin',
|
|
14
|
+
records: {
|
|
15
|
+
sys_properties: {
|
|
16
|
+
toShape(record, { config }) {
|
|
17
|
+
return {
|
|
18
|
+
success: true,
|
|
19
|
+
value: new CallExpressionShape({
|
|
20
|
+
source: record,
|
|
21
|
+
callee: 'Property',
|
|
22
|
+
args: [
|
|
23
|
+
record.transform(({ $ }) => ({
|
|
24
|
+
$id: $.val(NowIdShape.from(record)),
|
|
25
|
+
name: $.from('name', 'suffix').map(
|
|
26
|
+
(name, suffix) =>
|
|
27
|
+
name.ifString() ??
|
|
28
|
+
(config.scope === 'global'
|
|
29
|
+
? suffix
|
|
30
|
+
: `${config.scope}.${suffix.asString().getValue()}`)
|
|
31
|
+
),
|
|
32
|
+
value: $,
|
|
33
|
+
description: $.def(''),
|
|
34
|
+
type: $.def('string'),
|
|
35
|
+
choices: $.map((c) => {
|
|
36
|
+
const value = c.toString().getValue()
|
|
37
|
+
return value
|
|
38
|
+
.split(/[,\n]/)
|
|
39
|
+
.map((v) => v.trim())
|
|
40
|
+
.filter((v) => v)
|
|
41
|
+
}).def([]),
|
|
42
|
+
isPrivate: $.from('is_private').toBoolean().def(false),
|
|
43
|
+
ignoreCache: $.from('ignore_cache').toBoolean().def(false),
|
|
44
|
+
roles: $.from('read_roles', 'write_roles')
|
|
45
|
+
.def({ read: [], write: [] })
|
|
46
|
+
.map((r, w) => ({
|
|
47
|
+
read: r.ifString()?.pipe((v) => getRolesArray(v.getValue())),
|
|
48
|
+
write: w.ifString()?.pipe((v) => getRolesArray(v.getValue())),
|
|
49
|
+
})),
|
|
50
|
+
})),
|
|
51
|
+
],
|
|
52
|
+
}),
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
shapes: [
|
|
58
|
+
{
|
|
59
|
+
shape: CallExpressionShape,
|
|
60
|
+
fileTypes: ['fluent'],
|
|
61
|
+
async toRecord(callExpression, { config, diagnostics, factory }) {
|
|
62
|
+
if (callExpression.getCallee() !== 'Property') {
|
|
63
|
+
return { success: false }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const prop = callExpression.getArgument(0).asObject()
|
|
67
|
+
const scope = config.scope
|
|
68
|
+
const name = prop.get('name').asString()
|
|
69
|
+
|
|
70
|
+
if (!isSNScope(scope) && config.scope !== 'global' && !name.asString().startsWith(`${scope}.`)) {
|
|
71
|
+
diagnostics.error(name.getOriginalNode(), `Property name must begin with '${scope}.'`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
success: true,
|
|
76
|
+
value: factory.createRecord({
|
|
77
|
+
source: callExpression,
|
|
78
|
+
table: 'sys_properties',
|
|
79
|
+
explicitId: prop.get('$id'),
|
|
80
|
+
properties: prop.transform(({ $, merge }) => ({
|
|
81
|
+
name: $,
|
|
82
|
+
suffix: $.from('name').map((v) =>
|
|
83
|
+
v.asString().replace(new RegExp(`^${config.scope}\\.`), '')
|
|
84
|
+
),
|
|
85
|
+
description: $,
|
|
86
|
+
type: $.def('string'),
|
|
87
|
+
value: $.toString(), // TODO: Should be allowed to assign non-strings to string properties
|
|
88
|
+
is_private: $.from('isPrivate').def(false),
|
|
89
|
+
ignore_cache: $.from('ignoreCache').def(false),
|
|
90
|
+
choices: $.map((v) => v.ifArray()?.getValue().join(',')),
|
|
91
|
+
[merge]: $.from('roles')
|
|
92
|
+
.def({ read_roles: '', write_roles: '' })
|
|
93
|
+
.map((v) =>
|
|
94
|
+
v
|
|
95
|
+
.ifObject()
|
|
96
|
+
?.transform(({ $ }) => ({
|
|
97
|
+
read_roles: $.from('read').map((r) => getRolesString(r)),
|
|
98
|
+
write_roles: $.from('write').map((r) => getRolesString(r)),
|
|
99
|
+
}))
|
|
100
|
+
.properties()
|
|
101
|
+
),
|
|
102
|
+
})),
|
|
103
|
+
}),
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
function getRolesString(roles: Shape): string | undefined {
|
|
111
|
+
return roles
|
|
112
|
+
.ifArray()
|
|
113
|
+
?.pipe((r) =>
|
|
114
|
+
Array.from(new Set(r.getElements().map((r) => r.ifRecord()?.get('name').getValue() ?? r.getValue()))).join(
|
|
115
|
+
','
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
|
|
2
|
+
import { unloadBuilder } from '@servicenow/sdk-build-core'
|
|
3
|
+
import { NowIdShape } from './now-id-plugin'
|
|
4
|
+
import {
|
|
5
|
+
Acl,
|
|
6
|
+
ApplicationMenu,
|
|
7
|
+
BusinessRule,
|
|
8
|
+
CrossScopePrivilege,
|
|
9
|
+
Property,
|
|
10
|
+
Role,
|
|
11
|
+
Test,
|
|
12
|
+
UserPreference,
|
|
13
|
+
} from '@servicenow/sdk-core/runtime/app'
|
|
14
|
+
import {
|
|
15
|
+
SPWidget,
|
|
16
|
+
SPAngularProvider,
|
|
17
|
+
SPWidgetDependency,
|
|
18
|
+
CssInclude,
|
|
19
|
+
JsInclude,
|
|
20
|
+
} from '@servicenow/sdk-core/runtime/service-portal'
|
|
21
|
+
import { ClientScript } from '@servicenow/sdk-core/runtime/clientscript'
|
|
22
|
+
import { ScriptAction, ScriptInclude } from '@servicenow/sdk-core/runtime/sys'
|
|
23
|
+
import { List } from '@servicenow/sdk-core/runtime/ui'
|
|
24
|
+
import { Table } from '@servicenow/sdk-core/runtime/db'
|
|
25
|
+
import { RestApi } from '@servicenow/sdk-core/runtime/rest'
|
|
26
|
+
import { UiAction, UiPage } from '@servicenow/sdk-core/runtime/ui'
|
|
27
|
+
|
|
28
|
+
export const RecordPlugin = Plugin.create({
|
|
29
|
+
name: 'RecordPlugin',
|
|
30
|
+
records: {
|
|
31
|
+
'*': {
|
|
32
|
+
toShape(record) {
|
|
33
|
+
return {
|
|
34
|
+
success: true,
|
|
35
|
+
value: new CallExpressionShape({
|
|
36
|
+
source: record,
|
|
37
|
+
callee: 'Record',
|
|
38
|
+
args: [
|
|
39
|
+
{
|
|
40
|
+
$id: NowIdShape.from(record),
|
|
41
|
+
table: record.getTable(),
|
|
42
|
+
data: record.transform(
|
|
43
|
+
({ $ }) =>
|
|
44
|
+
Object.fromEntries(
|
|
45
|
+
record
|
|
46
|
+
.keys()
|
|
47
|
+
.map((key) => [key, record.get(key).isString() ? $.def('') : $])
|
|
48
|
+
) //to avoid writing empty string values to the code
|
|
49
|
+
),
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
}),
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
toFile(record, { config }) {
|
|
56
|
+
const recordBuilder = unloadBuilder(config)
|
|
57
|
+
const table = record.getTable()
|
|
58
|
+
const guid = record.getId().getValue()
|
|
59
|
+
const builder = recordBuilder.record(record)
|
|
60
|
+
|
|
61
|
+
record
|
|
62
|
+
.entries()
|
|
63
|
+
.sort(([a], [b]) => a.localeCompare(b)) // Sort keys to make outputs more deterministic
|
|
64
|
+
.forEach(([prop, shape]) => builder.field(prop, shape))
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
value: {
|
|
69
|
+
name: `${table}_${guid}.xml`,
|
|
70
|
+
category: record.getInstallCategory(),
|
|
71
|
+
content: recordBuilder.end(),
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
shapes: [
|
|
78
|
+
{
|
|
79
|
+
shape: CallExpressionShape,
|
|
80
|
+
fileTypes: ['fluent'],
|
|
81
|
+
toRecord(callExpression, { factory, diagnostics }) {
|
|
82
|
+
if (callExpression.getCallee() !== 'Record') {
|
|
83
|
+
return { success: false }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const record = callExpression.getArgument(0).asObject()
|
|
87
|
+
const table = record.get('table').asString().getValue()
|
|
88
|
+
const tableOwningPlugin = TableOwnership[table]
|
|
89
|
+
if (tableOwningPlugin) {
|
|
90
|
+
diagnostics.hint(
|
|
91
|
+
callExpression,
|
|
92
|
+
`For a better experience, consider using the ${tableOwningPlugin} API`
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
success: true,
|
|
97
|
+
value: factory.createRecord({
|
|
98
|
+
source: callExpression,
|
|
99
|
+
table,
|
|
100
|
+
explicitId: record.get('$id'),
|
|
101
|
+
properties: record.get('data').asObject(),
|
|
102
|
+
}),
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
files: [
|
|
108
|
+
{
|
|
109
|
+
matcher: /\.xml$/,
|
|
110
|
+
toRecord(file, { parser, logger }) {
|
|
111
|
+
try {
|
|
112
|
+
const [first, ...rest] = parser.parsePayload(file)
|
|
113
|
+
|
|
114
|
+
if (!first) {
|
|
115
|
+
return { success: false }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
success: true,
|
|
120
|
+
value: first.with(...rest),
|
|
121
|
+
}
|
|
122
|
+
} catch (e) {
|
|
123
|
+
logger.debug(e)
|
|
124
|
+
return { success: false }
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
export const TableOwnership = {
|
|
132
|
+
sys_security_acl: Acl.name,
|
|
133
|
+
sys_security_acl_role: Acl.name,
|
|
134
|
+
sys_app_application: ApplicationMenu.name,
|
|
135
|
+
sys_script: BusinessRule.name,
|
|
136
|
+
sys_script_client: ClientScript.name,
|
|
137
|
+
sys_scope_privilege: CrossScopePrivilege.name,
|
|
138
|
+
sys_ui_list_element: List.name,
|
|
139
|
+
sys_ui_list: List.name,
|
|
140
|
+
sys_properties: Property.name,
|
|
141
|
+
sys_user_role: Role.name,
|
|
142
|
+
sys_user_role_contains: Role.name,
|
|
143
|
+
sys_script_include: ScriptInclude.name,
|
|
144
|
+
sp_widget: SPWidget.name,
|
|
145
|
+
m2m_sp_widget_dependency: SPWidget.name,
|
|
146
|
+
m2m_sp_ng_pro_sp_widget: SPWidget.name,
|
|
147
|
+
sp_ng_template: SPWidget.name,
|
|
148
|
+
sp_dependency: SPWidgetDependency.name,
|
|
149
|
+
m2m_sp_dependency_css_include: SPWidgetDependency.name,
|
|
150
|
+
m2m_sp_dependency_js_include: SPWidgetDependency.name,
|
|
151
|
+
sp_css_include: CssInclude.name,
|
|
152
|
+
sp_js_include: JsInclude.name,
|
|
153
|
+
sp_angular_provider: SPAngularProvider.name,
|
|
154
|
+
m2m_sp_ng_pro_sp_ng_pro: SPAngularProvider.name,
|
|
155
|
+
sys_atf_test: Test.name,
|
|
156
|
+
sys_ws_header_map: RestApi.name,
|
|
157
|
+
sys_ws_query_parameter_map: RestApi.name,
|
|
158
|
+
sys_ws_definition: RestApi.name,
|
|
159
|
+
sys_ws_operation: RestApi.name,
|
|
160
|
+
sys_ws_version: RestApi.name,
|
|
161
|
+
sys_ws_header: RestApi.name,
|
|
162
|
+
sys_ws_query_parameter: RestApi.name,
|
|
163
|
+
sys_user_preference: UserPreference.name,
|
|
164
|
+
sys_ui_page: UiPage.name,
|
|
165
|
+
sys_ui_action: UiAction.name,
|
|
166
|
+
sys_ui_action_role: UiAction.name,
|
|
167
|
+
sys_ui_action_view: UiAction.name,
|
|
168
|
+
sysevent_script_action: ScriptAction.name,
|
|
169
|
+
sys_db_object: Table.name,
|
|
170
|
+
sys_dictionary: Table.name,
|
|
171
|
+
}
|