@servicenow/sdk-build-plugins 3.0.3 → 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 -1630
- 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 -2072
- 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
package/src/ListPlugin.ts
DELETED
|
@@ -1,570 +0,0 @@
|
|
|
1
|
-
import { List } from '@servicenow/sdk-core/runtime/ui'
|
|
2
|
-
import {
|
|
3
|
-
Data,
|
|
4
|
-
Plugin,
|
|
5
|
-
PrimitiveData,
|
|
6
|
-
extractCallExpression,
|
|
7
|
-
generateCallExpressionExportForDocument,
|
|
8
|
-
getCallExpressionName,
|
|
9
|
-
getOrCreateEntitySourceFile,
|
|
10
|
-
linkDocument,
|
|
11
|
-
recordXml,
|
|
12
|
-
removeNode,
|
|
13
|
-
unloadBuilder,
|
|
14
|
-
getOrCreatePropertyAssignment,
|
|
15
|
-
setPropertyAssignmentValue,
|
|
16
|
-
getSysUpdateName,
|
|
17
|
-
XmlData,
|
|
18
|
-
writePropertyAsReference,
|
|
19
|
-
addDefaultImportIfAbsent,
|
|
20
|
-
addNamedImportIfAbsent,
|
|
21
|
-
getPropertyAssignment,
|
|
22
|
-
} from '@servicenow/sdk-build-core'
|
|
23
|
-
import { getOutputDirectoryForDocument, RecordXmlSchema } from './db/RecordPlugin'
|
|
24
|
-
import * as z from 'zod'
|
|
25
|
-
import { Diagnostic, path, ts } from '@servicenow/sdk-project'
|
|
26
|
-
import { isObject } from 'lodash'
|
|
27
|
-
import { Record as NowRecord } from '@servicenow/sdk-core/runtime/db'
|
|
28
|
-
|
|
29
|
-
const DEFAULT_VIEW = 'Default view'
|
|
30
|
-
|
|
31
|
-
type View = {
|
|
32
|
-
id: string
|
|
33
|
-
name: string
|
|
34
|
-
title: string
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type TransformData = {
|
|
38
|
-
sys_id: string
|
|
39
|
-
parent?: string
|
|
40
|
-
relationship?: { id: string; name: string }
|
|
41
|
-
view: View
|
|
42
|
-
list: Omit<List, 'columns'>
|
|
43
|
-
table: string
|
|
44
|
-
elements: SysUIListElementXml
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default Plugin({
|
|
48
|
-
name: 'List',
|
|
49
|
-
ownedTables: {
|
|
50
|
-
sys_ui_list: { diagnosticLevel: Diagnostic.Level.Warn },
|
|
51
|
-
},
|
|
52
|
-
extractors: {
|
|
53
|
-
entity: {
|
|
54
|
-
fluent: {
|
|
55
|
-
CallExpression(node, context) {
|
|
56
|
-
return extractCallExpression(List, 'list', node, context, (list) =>
|
|
57
|
-
context.keys.registerExplicitId('sys_ui_list', list.$id as string)
|
|
58
|
-
)
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
xml(xml) {
|
|
63
|
-
const result = SysUIListXmlSchema.safeParse(xml.data['record_update'])
|
|
64
|
-
if (!result.success) {
|
|
65
|
-
return undefined
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const {
|
|
69
|
-
data: {
|
|
70
|
-
sys_ui_list: { sys_ui_list, sys_ui_list_element },
|
|
71
|
-
sys_metadata_delete,
|
|
72
|
-
},
|
|
73
|
-
} = result
|
|
74
|
-
|
|
75
|
-
//Delete only gets set on the top level sys_ui_list action attribute, not on sub nodes
|
|
76
|
-
const isDelete = result.data.sys_ui_list['@_action'] === 'DELETE'
|
|
77
|
-
const list = xmlElementToObject(sys_ui_list)
|
|
78
|
-
const elements = toArray(sys_ui_list_element).map(xmlElementToObject)
|
|
79
|
-
let updateName = list['sys_update_name']
|
|
80
|
-
// sys_update_name is not present on the list element, but is present on the delete element on delete payload
|
|
81
|
-
if (isDelete && sys_metadata_delete) {
|
|
82
|
-
const metadataDelete = xmlElementToObject(sys_metadata_delete)
|
|
83
|
-
updateName = metadataDelete['sys_update_name']
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const viewName = sys_ui_list['view']['@_name']
|
|
87
|
-
const view = {
|
|
88
|
-
title: sys_ui_list['view']['@_display_value'],
|
|
89
|
-
name: viewName === 'NULL' ? 'default_view' : viewName,
|
|
90
|
-
id: sys_ui_list['view']['#text'],
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return new XmlData(
|
|
94
|
-
{
|
|
95
|
-
updateName,
|
|
96
|
-
sys_id: list['sys_id'],
|
|
97
|
-
view,
|
|
98
|
-
elements,
|
|
99
|
-
table: list['name'],
|
|
100
|
-
parent: list['parent'],
|
|
101
|
-
relationship: {
|
|
102
|
-
id: list['relationship'],
|
|
103
|
-
name: sys_ui_list['relationship']?.['@_display_value'],
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
xml.filePath,
|
|
107
|
-
'list',
|
|
108
|
-
isDelete ? 'DELETE' : list['@_action']
|
|
109
|
-
)
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
composers: {
|
|
113
|
-
entity: {
|
|
114
|
-
list(entity, context) {
|
|
115
|
-
const node = entity.getNode()
|
|
116
|
-
const guid = entity.getGuid()
|
|
117
|
-
const view = entity.getProperty('view').getValue()
|
|
118
|
-
const table = entity.getPropertyOrThrow('table', 'string').getValue()
|
|
119
|
-
const parent = entity.getProperty('parent', 'string')?.getValue()
|
|
120
|
-
|
|
121
|
-
const relationship = entity.getProperty('relationship')
|
|
122
|
-
const relationshipId = Data.isEntity(relationship)
|
|
123
|
-
? relationship?.getGuid()
|
|
124
|
-
: (relationship?.getValue() as string)
|
|
125
|
-
|
|
126
|
-
const columns = entity.getPropertyOrThrow('columns', 'array').getValue()
|
|
127
|
-
const viewInfo: View = composeView(view as List['view'], context)
|
|
128
|
-
|
|
129
|
-
return Promise.resolve({
|
|
130
|
-
kind: 'list',
|
|
131
|
-
node,
|
|
132
|
-
guid: getListUpdateName(viewInfo, table, parent, relationshipId),
|
|
133
|
-
data: {
|
|
134
|
-
id: guid,
|
|
135
|
-
table,
|
|
136
|
-
view: viewInfo,
|
|
137
|
-
elements: columns,
|
|
138
|
-
parent,
|
|
139
|
-
relationship: relationshipId,
|
|
140
|
-
},
|
|
141
|
-
})
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
xml: {
|
|
145
|
-
list(xml) {
|
|
146
|
-
const { sys_id, view, elements, table } = xml.data as unknown as TransformData
|
|
147
|
-
return {
|
|
148
|
-
action: xml.action,
|
|
149
|
-
kind: xml.kind,
|
|
150
|
-
guid: xml.data['updateName'] as string,
|
|
151
|
-
data: {
|
|
152
|
-
id: sys_id,
|
|
153
|
-
table,
|
|
154
|
-
view,
|
|
155
|
-
elements,
|
|
156
|
-
parent: xml.data['parent'],
|
|
157
|
-
relationship: xml.data['relationship'],
|
|
158
|
-
},
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
transformers: {
|
|
164
|
-
list: {
|
|
165
|
-
CallExpression(document, context) {
|
|
166
|
-
const expressionName = getCallExpressionName(document.node)
|
|
167
|
-
if (expressionName !== List.name) {
|
|
168
|
-
return false
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (document.action === 'DELETE') {
|
|
172
|
-
removeNode(document.node)
|
|
173
|
-
return true
|
|
174
|
-
}
|
|
175
|
-
if (document.action !== 'INSERT_OR_UPDATE') {
|
|
176
|
-
return false
|
|
177
|
-
}
|
|
178
|
-
const [listArgument] = document.node.getArguments()
|
|
179
|
-
if (!ts.Node.isObjectLiteralExpression(listArgument)) {
|
|
180
|
-
return false
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const { elements, view, table, parent, relationship } = document.xmlData as TransformData
|
|
184
|
-
updateView(context, listArgument, view)
|
|
185
|
-
|
|
186
|
-
//create the table reference for now, user will need to fix to proper import
|
|
187
|
-
const tableProperty = getOrCreatePropertyAssignment(listArgument, 'table', '')
|
|
188
|
-
setPropertyAssignmentValue(tableProperty, table)
|
|
189
|
-
|
|
190
|
-
const arrayElements = toArray(elements)
|
|
191
|
-
|
|
192
|
-
//update the columns
|
|
193
|
-
const columnsProperty = getOrCreatePropertyAssignment(listArgument, 'columns', '[]')
|
|
194
|
-
const columns = arrayElements.sort((a, b) => (a['position'] as number) - (b['position'] as number))
|
|
195
|
-
setColumnsList(columnsProperty, columns)
|
|
196
|
-
|
|
197
|
-
if (parent) {
|
|
198
|
-
const parentProperty = getOrCreatePropertyAssignment(listArgument, 'parent', '')
|
|
199
|
-
setPropertyAssignmentValue(parentProperty, parent)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const relationAssignment = getPropertyAssignment(listArgument, 'relationship')
|
|
203
|
-
if (!relationAssignment && relationship?.id) {
|
|
204
|
-
const { id, name } = relationship
|
|
205
|
-
writeRecordReference(context, listArgument, 'relationship', { id, refName: name })
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return true
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
generators: {
|
|
213
|
-
list(document, context) {
|
|
214
|
-
const { id } = document.data as any
|
|
215
|
-
return linkDocument(
|
|
216
|
-
document,
|
|
217
|
-
generateCallExpressionExportForDocument(
|
|
218
|
-
context,
|
|
219
|
-
{
|
|
220
|
-
sourceFile: getOrCreateEntitySourceFile(context, getSysUpdateName(document, 'sys_ui_list')),
|
|
221
|
-
moduleSpecifier: '@servicenow/sdk/core',
|
|
222
|
-
},
|
|
223
|
-
List,
|
|
224
|
-
{ $id: id }
|
|
225
|
-
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
226
|
-
)
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
serializers: {
|
|
230
|
-
list(document, context) {
|
|
231
|
-
const {
|
|
232
|
-
id: listId,
|
|
233
|
-
elements: columns,
|
|
234
|
-
table,
|
|
235
|
-
view,
|
|
236
|
-
parent,
|
|
237
|
-
relationship,
|
|
238
|
-
} = document.data as {
|
|
239
|
-
id: string
|
|
240
|
-
elements: Array<any>
|
|
241
|
-
table: string
|
|
242
|
-
view: View
|
|
243
|
-
parent: string
|
|
244
|
-
relationship: string
|
|
245
|
-
}
|
|
246
|
-
const xmlBuilder = unloadBuilder(context)
|
|
247
|
-
/**
|
|
248
|
-
* Structure that needs to be built for sys_ui_list
|
|
249
|
-
* <sys_ui_list>
|
|
250
|
-
* <sys_ui_list_element>
|
|
251
|
-
* <sys_id/>
|
|
252
|
-
* </sys_ui_list_element>
|
|
253
|
-
* <sys_ui_list>
|
|
254
|
-
* <sys_id/>
|
|
255
|
-
* <view/>
|
|
256
|
-
* </sys_ui_list>
|
|
257
|
-
* </sys_ui_list>
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
const listBuilder = xmlBuilder.xml.ele('sys_ui_list', {
|
|
261
|
-
table: table,
|
|
262
|
-
view: view.id === DEFAULT_VIEW ? '' : view.name,
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
columns.forEach((column, index) => {
|
|
266
|
-
let elementProperties = column
|
|
267
|
-
|
|
268
|
-
if (typeof column === 'string') {
|
|
269
|
-
elementProperties = {
|
|
270
|
-
element: column,
|
|
271
|
-
position: index,
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (elementProperties.position === undefined) {
|
|
276
|
-
elementProperties.position = index
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const childNode = recordXml(
|
|
280
|
-
listBuilder,
|
|
281
|
-
'sys_ui_list_element',
|
|
282
|
-
context.keys.registerCompositeId('sys_ui_list_element', {
|
|
283
|
-
list: listId,
|
|
284
|
-
element: elementProperties.element,
|
|
285
|
-
})
|
|
286
|
-
)
|
|
287
|
-
|
|
288
|
-
childNode.field('list_id', listId, {
|
|
289
|
-
display_value: table,
|
|
290
|
-
view: view.id,
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
Object.entries(elementProperties)
|
|
294
|
-
.filter(([, v]) => typeof v !== 'undefined')
|
|
295
|
-
.forEach(([n, v]) => childNode.field(n, v))
|
|
296
|
-
})
|
|
297
|
-
|
|
298
|
-
const sysUIList = recordXml(listBuilder, 'sys_ui_list', listId)
|
|
299
|
-
sysUIList.addSysScope(context)
|
|
300
|
-
sysUIList.field('view', view.id, {
|
|
301
|
-
display_value: view.title,
|
|
302
|
-
name: view.name,
|
|
303
|
-
})
|
|
304
|
-
sysUIList.field('name', table)
|
|
305
|
-
|
|
306
|
-
sysUIList.field('parent', parent ?? '')
|
|
307
|
-
sysUIList.field('relationship', relationship ?? '')
|
|
308
|
-
|
|
309
|
-
return {
|
|
310
|
-
name: `${document.guid}.xml`,
|
|
311
|
-
directory: getOutputDirectoryForDocument(document, table),
|
|
312
|
-
content: xmlBuilder.end(),
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
/*
|
|
319
|
-
* Update the view property of the list argument
|
|
320
|
-
* If the view is the default view, write view as a reference from the core package
|
|
321
|
-
* If the view is a record, look for a record entity and write the view as a reference
|
|
322
|
-
*
|
|
323
|
-
* **Note:** View Cannot be updated using list layout on the instance,
|
|
324
|
-
* if the view is updated directly from sys_ui_list table, then update name changes and a new List entity is created
|
|
325
|
-
*
|
|
326
|
-
*/
|
|
327
|
-
const updateView = (context, listArgument, view) => {
|
|
328
|
-
const viewAssignment = getPropertyAssignment(listArgument, 'view')
|
|
329
|
-
if (viewAssignment) {
|
|
330
|
-
return
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (view.id === DEFAULT_VIEW) {
|
|
334
|
-
writePropertyAsReference(context.logger, listArgument, 'view', '', view.name)
|
|
335
|
-
return
|
|
336
|
-
}
|
|
337
|
-
if (!writeRecordReference(context, listArgument, 'view', { id: view.id, refName: view.name })) {
|
|
338
|
-
writePropertyAsReference(context.logger, listArgument, 'view', '', view.name)
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
function writeRecordReference(context, listArgument, field, record: { id: string; refName: string }) {
|
|
343
|
-
const refName = record.refName.replace(/\s+/g, '_').toLowerCase()
|
|
344
|
-
const refRecord = context.getDocument(record.id)
|
|
345
|
-
const refNode = refRecord?.node
|
|
346
|
-
if (!refRecord || !refNode) {
|
|
347
|
-
context.logger.debug(`Could not find a reference record with sys_id ${record.id}`)
|
|
348
|
-
return false
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const nodeSource = listArgument.getSourceFile()
|
|
352
|
-
const refPath = getImportPath(nodeSource.getFilePath(), refNode.getSourceFile().getFilePath())
|
|
353
|
-
|
|
354
|
-
if (!refPath) {
|
|
355
|
-
// reference is in the same file
|
|
356
|
-
const identifier = getIdentifier(refNode)
|
|
357
|
-
if (identifier) {
|
|
358
|
-
listArgument.addPropertyAssignment({ name: field, initializer: identifier })
|
|
359
|
-
return true
|
|
360
|
-
}
|
|
361
|
-
context.logger.warn(
|
|
362
|
-
`Could not find identifier for ${field}, with sys_id ${record.id}, consider adding one to use as a reference`
|
|
363
|
-
)
|
|
364
|
-
listArgument.addPropertyAssignment({ name: field, initializer: `'${refName ?? record.id}'` })
|
|
365
|
-
return true
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// If the view record is not in the same file, add a reference to the view record
|
|
369
|
-
const viewExport = getExportTypeAndName(refNode)
|
|
370
|
-
|
|
371
|
-
if (!viewExport.exported) {
|
|
372
|
-
context.logger.warn(`View record is defined in ${refNode.getSourceFile().getFilePath()} and is not exported`)
|
|
373
|
-
listArgument.addPropertyAssignment({ name: field, initializer: `'${record.id}'` })
|
|
374
|
-
return true
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Add a reference to the view record and add an import statement
|
|
378
|
-
if (viewExport.type === 'Default') {
|
|
379
|
-
listArgument.addPropertyAssignment({ name: field, initializer: refName })
|
|
380
|
-
addDefaultImportIfAbsent(nodeSource, refPath, refName)
|
|
381
|
-
} else {
|
|
382
|
-
listArgument.addPropertyAssignment({ name: field, initializer: viewExport.identifier })
|
|
383
|
-
addNamedImportIfAbsent(context, nodeSource, refPath, viewExport.identifier)
|
|
384
|
-
}
|
|
385
|
-
return true
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function composeView(view: NowRecord<'sys_ui_view'> | string, context): View {
|
|
389
|
-
if (isObject(view)) {
|
|
390
|
-
return {
|
|
391
|
-
id:
|
|
392
|
-
view.$id === DEFAULT_VIEW
|
|
393
|
-
? view.$id
|
|
394
|
-
: context.keys.registerExplicitId('sys_ui_view', view.$id as unknown as string),
|
|
395
|
-
name: view.data.name,
|
|
396
|
-
title: view.data.title,
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
return {
|
|
401
|
-
id: view,
|
|
402
|
-
name: view,
|
|
403
|
-
title: view,
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
type ExportsInfo =
|
|
408
|
-
| { exported: false; identifier?: string }
|
|
409
|
-
| { exported: true; identifier: string; type: 'Named' }
|
|
410
|
-
| { exported: true; type: 'Default' }
|
|
411
|
-
|
|
412
|
-
const getExportTypeAndName = (sourceNode: ts.CallExpression): ExportsInfo => {
|
|
413
|
-
// const defaultExports = sourceNode.getSourceFile().getExportSymbols()
|
|
414
|
-
const parentNode = sourceNode.getParent()
|
|
415
|
-
|
|
416
|
-
// export declarations are blocked by fluent-diagnostics
|
|
417
|
-
switch (parentNode?.getKind()) {
|
|
418
|
-
case ts.SyntaxKind.ExportAssignment:
|
|
419
|
-
return { exported: true, type: 'Default' }
|
|
420
|
-
case ts.SyntaxKind.VariableDeclaration: {
|
|
421
|
-
const identifier = getIdentifier(parentNode as ts.VariableDeclaration)!
|
|
422
|
-
|
|
423
|
-
const variableStmt = parentNode.getFirstAncestorByKind(ts.SyntaxKind.VariableStatement)
|
|
424
|
-
const exportKeyword = variableStmt?.getFirstModifierByKind(ts.SyntaxKind.ExportKeyword)
|
|
425
|
-
if (exportKeyword) {
|
|
426
|
-
return { exported: true, type: 'Named', identifier }
|
|
427
|
-
}
|
|
428
|
-
return { exported: false, identifier }
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
case ts.SyntaxKind.ExpressionStatement:
|
|
432
|
-
default:
|
|
433
|
-
return { exported: false }
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
const getIdentifier = (sourceNode: ts.CallExpression | ts.VariableDeclaration): string | undefined => {
|
|
438
|
-
const variableDeclaration =
|
|
439
|
-
sourceNode.getKind() === ts.SyntaxKind.CallExpression
|
|
440
|
-
? sourceNode.getParentIfKind(ts.SyntaxKind.VariableDeclaration)
|
|
441
|
-
: sourceNode
|
|
442
|
-
|
|
443
|
-
return variableDeclaration?.getFirstChildByKind(ts.SyntaxKind.Identifier)?.getText()
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
const getImportPath = (listSourcePath, viewSourcePath): string | undefined => {
|
|
447
|
-
if (listSourcePath === viewSourcePath) {
|
|
448
|
-
return
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const viewFilePath = path.parse(viewSourcePath)
|
|
452
|
-
const listFilePath = path.parse(listSourcePath)
|
|
453
|
-
const relativePath = path.join(path.relative(listFilePath.dir, viewFilePath.dir), viewFilePath.name)
|
|
454
|
-
// relativePath = relativePath.replace(path.extname(relativePath), '')
|
|
455
|
-
return relativePath.startsWith('.') ? relativePath : `./${relativePath}`
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
const setColumnsList = (columnsProperty: ts.PropertyAssignment, elements: SysUIListElementXml) => {
|
|
459
|
-
const [array] = columnsProperty.getChildrenOfKind(ts.SyntaxKind.ArrayLiteralExpression)
|
|
460
|
-
let serializeValue: string = '[]'
|
|
461
|
-
if (array) {
|
|
462
|
-
const elementSyntaxList = array.getChildAtIndexIfKind(1, ts.SyntaxKind.SyntaxList)
|
|
463
|
-
|
|
464
|
-
//If the columns are defined as objects or need to be expressed that way due to additional properties set on instance
|
|
465
|
-
if (
|
|
466
|
-
!!elementSyntaxList?.getChildrenOfKind(ts.SyntaxKind.ObjectLiteralExpression).length ||
|
|
467
|
-
columnsNeedObjectLiterals(elements)
|
|
468
|
-
) {
|
|
469
|
-
const newElements = elements.map((element, index) => {
|
|
470
|
-
let newValue: Record<string, unknown>
|
|
471
|
-
|
|
472
|
-
if (typeof element === 'string') {
|
|
473
|
-
newValue = element
|
|
474
|
-
} else {
|
|
475
|
-
newValue = {
|
|
476
|
-
element: element['element'],
|
|
477
|
-
position: element['position'] ?? index,
|
|
478
|
-
}
|
|
479
|
-
if (element['average_value']) {
|
|
480
|
-
newValue['average_value'] = true
|
|
481
|
-
}
|
|
482
|
-
if (element['max_value']) {
|
|
483
|
-
newValue['max_value'] = true
|
|
484
|
-
}
|
|
485
|
-
if (element['min_value']) {
|
|
486
|
-
newValue['min_value'] = true
|
|
487
|
-
}
|
|
488
|
-
if (element['sum']) {
|
|
489
|
-
newValue['sum'] = true
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
return newValue
|
|
494
|
-
})
|
|
495
|
-
|
|
496
|
-
serializeValue = JSON.stringify(newElements)
|
|
497
|
-
} else {
|
|
498
|
-
serializeValue = JSON.stringify(elements.map((e) => e['element']))
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
columnsProperty?.replaceWithText(`columns: ${serializeValue}`)
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
const columnsNeedObjectLiterals = (elements: SysUIListElementXml) => {
|
|
505
|
-
return elements.some((element) => {
|
|
506
|
-
return Object.keys(element)
|
|
507
|
-
.filter((key) => !key.startsWith('sys_') && !key.startsWith('@_'))
|
|
508
|
-
.some((key) => {
|
|
509
|
-
switch (key) {
|
|
510
|
-
case 'position':
|
|
511
|
-
case 'list_id':
|
|
512
|
-
case 'element':
|
|
513
|
-
return false
|
|
514
|
-
case 'average_value':
|
|
515
|
-
case 'max_value':
|
|
516
|
-
case 'sum':
|
|
517
|
-
case 'min_value':
|
|
518
|
-
return !!element[key]
|
|
519
|
-
default: //Non default properties are unknown so just return true
|
|
520
|
-
return true
|
|
521
|
-
}
|
|
522
|
-
})
|
|
523
|
-
})
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
const xmlElementToObject = (element: PrimitiveData) => {
|
|
527
|
-
return Object.entries(element).reduce((out, [k, v]) => {
|
|
528
|
-
out[k] = typeof v === 'string' ? v : v ? v['#text'] : ''
|
|
529
|
-
return out
|
|
530
|
-
}, {})
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
const getListUpdateName = (view: View, table: string, parent: string | undefined, relation: string | undefined) => {
|
|
534
|
-
const viewName = view.title === DEFAULT_VIEW ? 'null' : view.name
|
|
535
|
-
|
|
536
|
-
if (!parent && !relation) {
|
|
537
|
-
// Case 1: no parent/ no relation - sys_ui_list_table_view
|
|
538
|
-
return `sys_ui_list_${table}_${viewName}`
|
|
539
|
-
}
|
|
540
|
-
if (parent && !relation) {
|
|
541
|
-
// Case 2: parent/ no relation - sys_ui_list_table_parent_view
|
|
542
|
-
return `sys_ui_list_${table}_${parent}_${viewName}`
|
|
543
|
-
}
|
|
544
|
-
if (!parent && relation) {
|
|
545
|
-
// Case 3: no parent/ relation - sys_ui_list_null_relation_view
|
|
546
|
-
return `sys_ui_list_null_${relation}_${viewName}`
|
|
547
|
-
}
|
|
548
|
-
// Case 4: parent/ relation - sys_ui_list_parent_relation_view
|
|
549
|
-
return `sys_ui_list_${parent}_${relation}_${viewName}`
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
const SysUIListXmlSchema = z.object({
|
|
553
|
-
sys_ui_list: z.object({
|
|
554
|
-
'@_action': z.union([z.literal('DELETE'), z.literal('INSERT_OR_UPDATE')]).optional(),
|
|
555
|
-
'@_table': z.string(),
|
|
556
|
-
'@_view': z.string(),
|
|
557
|
-
sys_ui_list: RecordXmlSchema,
|
|
558
|
-
sys_ui_list_element: z.union([z.array(RecordXmlSchema), RecordXmlSchema]),
|
|
559
|
-
}),
|
|
560
|
-
sys_metadata_delete: z
|
|
561
|
-
.object({
|
|
562
|
-
sys_update_name: z.object({
|
|
563
|
-
'#text': z.string(),
|
|
564
|
-
}),
|
|
565
|
-
})
|
|
566
|
-
.optional(),
|
|
567
|
-
})
|
|
568
|
-
|
|
569
|
-
const toArray = (value: unknown) => (Array.isArray(value) ? value : [value])
|
|
570
|
-
type SysUIListElementXml = z.infer<typeof RecordXmlSchema>[]
|
package/src/NowConfigPlugin.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Plugin, Data, EntityData, ObjectData } from '@servicenow/sdk-build-core'
|
|
2
|
-
import JsonPlugin from './JsonPlugin'
|
|
3
|
-
import { NowConfigFileName, path } from '@servicenow/sdk-project'
|
|
4
|
-
|
|
5
|
-
export default Plugin({
|
|
6
|
-
name: 'NowConfig',
|
|
7
|
-
extractors: {
|
|
8
|
-
entity: {
|
|
9
|
-
json: {
|
|
10
|
-
SourceFile(node, context) {
|
|
11
|
-
if (path.basename(node.getFilePath()) !== NowConfigFileName) {
|
|
12
|
-
return { handled: false }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const configExtraction = context.extractAst(node, [JsonPlugin])
|
|
16
|
-
if (!configExtraction.handled) {
|
|
17
|
-
return { handled: false }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const configObject = configExtraction.data
|
|
21
|
-
if (!Data.isObject(configObject)) {
|
|
22
|
-
return { handled: false }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const { scope: scopeName, scopeId, name } = context.app.config
|
|
26
|
-
const { name: packageName, version } = context.app.package
|
|
27
|
-
|
|
28
|
-
const sysAppRecord = {
|
|
29
|
-
$id: scopeId,
|
|
30
|
-
table: 'sys_app',
|
|
31
|
-
data: {
|
|
32
|
-
active: true,
|
|
33
|
-
can_edit_in_studio: true,
|
|
34
|
-
enforce_license: 'none',
|
|
35
|
-
hide_on_ui: false,
|
|
36
|
-
installed_as_dependency: false,
|
|
37
|
-
js_level: 'es_latest',
|
|
38
|
-
licensable: true,
|
|
39
|
-
license_category: 'none',
|
|
40
|
-
license_model: 'none',
|
|
41
|
-
package_json: `${scopeName}/${packageName}/${version}/package.json`,
|
|
42
|
-
name: name || packageName,
|
|
43
|
-
private: false,
|
|
44
|
-
restrict_table_access: false,
|
|
45
|
-
runtime_access_tracking: 'permissive',
|
|
46
|
-
scope: scopeName,
|
|
47
|
-
scoped_administration: false,
|
|
48
|
-
source: scopeName,
|
|
49
|
-
trackable: true,
|
|
50
|
-
uninstall_blocked: false,
|
|
51
|
-
version: version,
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
handled: true,
|
|
57
|
-
diagnostics: configExtraction.diagnostics,
|
|
58
|
-
data: new EntityData(
|
|
59
|
-
'record',
|
|
60
|
-
context.app.config.scopeId,
|
|
61
|
-
ObjectData.fromObjectValue(sysAppRecord, configObject.getNode()),
|
|
62
|
-
node
|
|
63
|
-
),
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
})
|