@servicenow/sdk-build-plugins 3.0.3 → 4.0.1
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 +39 -0
- package/dist/atf/step-configs.js +2334 -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 +600 -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 +164 -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 +2384 -0
- package/src/atf/test-plugin.ts +739 -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 +179 -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 +658 -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/aclAndRole/Util.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { isEqual } from 'lodash'
|
|
2
|
-
import { ts, tsc } from '@servicenow/sdk-project'
|
|
3
|
-
import {
|
|
4
|
-
Document,
|
|
5
|
-
Context,
|
|
6
|
-
getNodeId,
|
|
7
|
-
getOrCreatePropertyAssignment,
|
|
8
|
-
ArrayIterator,
|
|
9
|
-
stringify,
|
|
10
|
-
Data,
|
|
11
|
-
isGUID,
|
|
12
|
-
} from '@servicenow/sdk-build-core'
|
|
13
|
-
|
|
14
|
-
const getElementKey = (element: ts.Expression, context: Context): string => {
|
|
15
|
-
const result = context.extractAst(element)
|
|
16
|
-
if (result.handled && result.data) {
|
|
17
|
-
const data = result.data
|
|
18
|
-
if (Data.isString(data)) {
|
|
19
|
-
return data.getValue()
|
|
20
|
-
}
|
|
21
|
-
if (Data.isEntity(data) && data.getKind() === 'role') {
|
|
22
|
-
return data.getProperty('$id') ? `${data.getProperty('$id').getValue()}` : ''
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return ''
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function addObjectToArrayById(document: Document, name: string, roleId: string, context: Context) {
|
|
29
|
-
const arg = document.node?.asKind(ts.SyntaxKind.CallExpression)?.getArguments()[0] as ts.ObjectLiteralExpression
|
|
30
|
-
const table = document.data!['table']
|
|
31
|
-
const primaryKey = getNodeId(arg)
|
|
32
|
-
const propertyAssignment = getOrCreatePropertyAssignment(arg, name, '[]')
|
|
33
|
-
|
|
34
|
-
let handled = false
|
|
35
|
-
const rolesIterator = new ArrayIterator(propertyAssignment)
|
|
36
|
-
const primaryKeyName = table === 'sys_security_acl_role' ? 'sys_security_acl' : 'role'
|
|
37
|
-
const secondaryKeyName = table === 'sys_security_acl_role' ? 'sys_user_role' : 'contains'
|
|
38
|
-
|
|
39
|
-
while (rolesIterator.hasNext()) {
|
|
40
|
-
const element = rolesIterator.next()
|
|
41
|
-
const secondaryKey = getElementKey(element, context)
|
|
42
|
-
const secondaryKeySysId =
|
|
43
|
-
secondaryKey && isGUID(secondaryKey) ? secondaryKey : context.getIdUsingExplicitKey(secondaryKey) || ''
|
|
44
|
-
if (secondaryKeySysId === roleId) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const foundIdx = context.keys.composite.findIndex((k) =>
|
|
49
|
-
isEqual(k.key, {
|
|
50
|
-
[primaryKeyName]: primaryKey,
|
|
51
|
-
[secondaryKeyName]: secondaryKey,
|
|
52
|
-
})
|
|
53
|
-
)
|
|
54
|
-
if (foundIdx !== -1 && context.keys.composite[foundIdx]?.id == document.guid) {
|
|
55
|
-
if (context.keys.explicit[secondaryKey]?.id === roleId || secondaryKey === roleId) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
element?.replaceWithText(stringify(roleId))
|
|
59
|
-
context.keys.composite.splice(foundIdx, 1)
|
|
60
|
-
handled = true
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!handled) {
|
|
65
|
-
const stringValue = stringify(roleId)
|
|
66
|
-
rolesIterator.getExpression().addElement(stringValue)
|
|
67
|
-
}
|
|
68
|
-
context.keys.registerCompositeId(
|
|
69
|
-
table,
|
|
70
|
-
{
|
|
71
|
-
[primaryKeyName]: primaryKey!,
|
|
72
|
-
[secondaryKeyName]: roleId,
|
|
73
|
-
},
|
|
74
|
-
document.guid
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function removeObjectFromArrayById(document: Document, name: string, context: Context) {
|
|
79
|
-
const arg = document.node?.asKind(ts.SyntaxKind.CallExpression)?.getArguments()[0] as ts.ObjectLiteralExpression
|
|
80
|
-
const table = document.data!['table']
|
|
81
|
-
const argId = getNodeId(arg)
|
|
82
|
-
const property = arg.getProperty(name)
|
|
83
|
-
if (!property) {
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const propertyAssignment = property.asKind(tsc.SyntaxKind.PropertyAssignment)
|
|
88
|
-
if (!propertyAssignment) {
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const rolesIterator = new ArrayIterator(propertyAssignment)
|
|
93
|
-
while (rolesIterator.hasNext()) {
|
|
94
|
-
const element = rolesIterator.next()
|
|
95
|
-
const secKey = getElementKey(element, context)
|
|
96
|
-
const primaryKey = table === 'sys_security_acl_role' ? 'sys_security_acl' : 'role'
|
|
97
|
-
const secondKey = table === 'sys_security_acl_role' ? 'sys_user_role' : 'contains'
|
|
98
|
-
const foundIdx = context.keys.composite.findIndex((k) =>
|
|
99
|
-
isEqual(k.key, {
|
|
100
|
-
[primaryKey]: argId,
|
|
101
|
-
[secondKey]: secKey,
|
|
102
|
-
})
|
|
103
|
-
)
|
|
104
|
-
if (foundIdx !== -1 && context.keys.composite[foundIdx]?.id === document.guid) {
|
|
105
|
-
rolesIterator.getExpression().removeElement(element)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (!element.wasForgotten() && element.asKind(ts.SyntaxKind.Identifier) && !element.getSymbol()) {
|
|
109
|
-
//remove if the identifier doesn't have symbol, happens when the identifier declaration is removed prior to this
|
|
110
|
-
rolesIterator.getExpression().removeElement(element)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { ApplicationMenu, ApplicationMenuSchema, getRolesArray } from '@servicenow/sdk-core/runtime/app'
|
|
3
|
-
import {
|
|
4
|
-
Plugin,
|
|
5
|
-
extractCallExpression,
|
|
6
|
-
generateCallExpressionExportForDocument,
|
|
7
|
-
getSysUpdateName,
|
|
8
|
-
getCallExpressionName,
|
|
9
|
-
getOrCreateEntitySourceFile,
|
|
10
|
-
linkDocument,
|
|
11
|
-
removeNode,
|
|
12
|
-
transformFunctionArguments,
|
|
13
|
-
writeArrayPropertyAsReference,
|
|
14
|
-
EntityData,
|
|
15
|
-
ObjectData,
|
|
16
|
-
transformCustomizedProperties,
|
|
17
|
-
} from '@servicenow/sdk-build-core'
|
|
18
|
-
import { RecordPlugin } from '../db/RecordPlugin'
|
|
19
|
-
import { Record } from '@servicenow/sdk-core/runtime/db'
|
|
20
|
-
import { Diagnostic, ts } from '@servicenow/sdk-project'
|
|
21
|
-
import { getRolesString } from '../aclAndRole/RolePlugin'
|
|
22
|
-
|
|
23
|
-
type AppMenuDocumentSchema = z.output<typeof AppMenuDocumentSchema>
|
|
24
|
-
|
|
25
|
-
const AppMenuDocumentSchema = z.object({
|
|
26
|
-
table: z.literal('sys_app_application'),
|
|
27
|
-
data: ApplicationMenuSchema.omit({ roles: true, category: true, $id: true }).extend({
|
|
28
|
-
roles: z.string().optional(),
|
|
29
|
-
category: z.coerce.string().optional(),
|
|
30
|
-
device_type: z.coerce.string().optional(),
|
|
31
|
-
view_name: z.coerce.string().optional(),
|
|
32
|
-
}),
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const AppMenuDocumentTransformer = AppMenuDocumentSchema.transform(
|
|
36
|
-
({ data: data }): Partial<typeof ApplicationMenuSchema> => {
|
|
37
|
-
const { roles, category, device_type, view_name, ...rest } = data
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
...rest,
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
export default Plugin({
|
|
46
|
-
name: 'ApplicationMenu',
|
|
47
|
-
ownedTables: {
|
|
48
|
-
sys_app_application: { diagnosticLevel: Diagnostic.Level.Warn },
|
|
49
|
-
},
|
|
50
|
-
extractors: {
|
|
51
|
-
entity: {
|
|
52
|
-
fluent: {
|
|
53
|
-
CallExpression: (node, context) =>
|
|
54
|
-
extractCallExpression(ApplicationMenu, 'appMenu', node, context, (menu) =>
|
|
55
|
-
context.registerExplicitId('sys_app_application', menu.$id as string)
|
|
56
|
-
),
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
composers: {
|
|
61
|
-
entity: {
|
|
62
|
-
appMenu(entity, context) {
|
|
63
|
-
const appMenuData = ApplicationMenuSchema.and(z.any()).safeParse(entity.getValue())
|
|
64
|
-
if (!appMenuData.success) {
|
|
65
|
-
return Promise.resolve(undefined)
|
|
66
|
-
}
|
|
67
|
-
const { $id, category, ...props } = appMenuData.data
|
|
68
|
-
const roles = entity.getProperty('roles', 'array')
|
|
69
|
-
const rolesString = roles ? getRolesString(roles) : ''
|
|
70
|
-
|
|
71
|
-
const recordEntity = Record({
|
|
72
|
-
$id,
|
|
73
|
-
table: 'sys_app_application',
|
|
74
|
-
data: {
|
|
75
|
-
...props,
|
|
76
|
-
roles: rolesString,
|
|
77
|
-
category: (category as string) ?? '',
|
|
78
|
-
device_type: 'browser',
|
|
79
|
-
view_name: '',
|
|
80
|
-
},
|
|
81
|
-
})
|
|
82
|
-
return context.composeEntities(
|
|
83
|
-
[
|
|
84
|
-
new EntityData(
|
|
85
|
-
'record',
|
|
86
|
-
entity.getGuid(),
|
|
87
|
-
ObjectData.fromObjectValue(recordEntity, entity.getNode()),
|
|
88
|
-
entity.getNode(),
|
|
89
|
-
entity.getInstallMethod()
|
|
90
|
-
),
|
|
91
|
-
],
|
|
92
|
-
[RecordPlugin]
|
|
93
|
-
)
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
generators: {
|
|
99
|
-
record(document, context) {
|
|
100
|
-
const tableName = document.data!['table']
|
|
101
|
-
if (tableName !== 'sys_app_application') {
|
|
102
|
-
return undefined
|
|
103
|
-
}
|
|
104
|
-
return linkDocument(
|
|
105
|
-
document,
|
|
106
|
-
generateCallExpressionExportForDocument(
|
|
107
|
-
context,
|
|
108
|
-
{
|
|
109
|
-
sourceFile: getOrCreateEntitySourceFile(
|
|
110
|
-
context,
|
|
111
|
-
getSysUpdateName(document, 'sys_app_application')
|
|
112
|
-
),
|
|
113
|
-
moduleSpecifier: '@servicenow/sdk/core',
|
|
114
|
-
},
|
|
115
|
-
ApplicationMenu,
|
|
116
|
-
{ $id: document.guid }
|
|
117
|
-
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
118
|
-
)
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
transformers: {
|
|
122
|
-
record: {
|
|
123
|
-
CallExpression(document, _context) {
|
|
124
|
-
if (getCallExpressionName(document.node) !== ApplicationMenu.name) {
|
|
125
|
-
return false
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (document.action === 'DELETE') {
|
|
129
|
-
removeNode(document.node)
|
|
130
|
-
return true
|
|
131
|
-
}
|
|
132
|
-
if (!document.changedData) {
|
|
133
|
-
return false
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const menu = AppMenuDocumentTransformer.safeParse(document.data)
|
|
137
|
-
if (!menu.success) {
|
|
138
|
-
return false
|
|
139
|
-
}
|
|
140
|
-
const { roles } = (document.xmlData as AppMenuDocumentSchema).data
|
|
141
|
-
const [args] = document.node.getArguments()
|
|
142
|
-
if (!ts.Node.isObjectLiteralExpression(args)) {
|
|
143
|
-
return false
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (roles && document.changedData?.['data']['roles']) {
|
|
147
|
-
writeArrayPropertyAsReference(args, 'roles', '[]', getRolesArray(roles))
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const {
|
|
151
|
-
roles: _roles,
|
|
152
|
-
device_type: _device_type,
|
|
153
|
-
...data
|
|
154
|
-
} = (AppMenuDocumentSchema.deepPartial().parse(document.changedData) as AppMenuDocumentSchema).data
|
|
155
|
-
|
|
156
|
-
transformCustomizedProperties(ApplicationMenu, document.node, (document.changedData as any).data, {
|
|
157
|
-
roles: _roles,
|
|
158
|
-
device_type: _device_type,
|
|
159
|
-
...data,
|
|
160
|
-
})
|
|
161
|
-
return transformFunctionArguments(document.node, ApplicationMenu, data as any)
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
})
|
package/src/db/ColumnPlugins.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import * as db from '@servicenow/sdk-core/runtime/db'
|
|
2
|
-
import { FluentDiagnostic, ObjectData, Plugin, extractCallExpression } from '@servicenow/sdk-build-core'
|
|
3
|
-
import { getLabelDiagnostics } from './DBUtils'
|
|
4
|
-
|
|
5
|
-
const validFunctions = [
|
|
6
|
-
'add',
|
|
7
|
-
'coalesce',
|
|
8
|
-
'concat',
|
|
9
|
-
'datediff',
|
|
10
|
-
'dayofweek',
|
|
11
|
-
'distance_sphere',
|
|
12
|
-
'divide',
|
|
13
|
-
'greatest',
|
|
14
|
-
'least',
|
|
15
|
-
'length',
|
|
16
|
-
'multiply',
|
|
17
|
-
'position',
|
|
18
|
-
'substring',
|
|
19
|
-
'subtract',
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
const regExp = new RegExp(`^glidefunction:(${validFunctions.join('|')})[(].*?[)]$`, 'g')
|
|
23
|
-
|
|
24
|
-
function ColumnPlugin<
|
|
25
|
-
const A extends unknown[],
|
|
26
|
-
const E extends A extends [infer T extends Record<string, unknown>] ? T : never,
|
|
27
|
-
const K extends string,
|
|
28
|
-
>(fn: (...args: A) => E, entityKind: K) {
|
|
29
|
-
return Plugin({
|
|
30
|
-
name: `${entityKind}Column`,
|
|
31
|
-
extractors: {
|
|
32
|
-
raw: {
|
|
33
|
-
fluent: {
|
|
34
|
-
CallExpression(node, context) {
|
|
35
|
-
const result = extractCallExpression(
|
|
36
|
-
fn,
|
|
37
|
-
`${entityKind}_column`,
|
|
38
|
-
node,
|
|
39
|
-
context,
|
|
40
|
-
() => 'NO_GUID_GENERATED' // TODO: We shouldn't need to generate any GUID here but maybe should provide something unique to be on the safe side
|
|
41
|
-
)
|
|
42
|
-
if (!result.handled || !result.data) {
|
|
43
|
-
return result
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const entity = result.data
|
|
47
|
-
const diagnostics = result.diagnostics
|
|
48
|
-
diagnostics.push(...getLabelDiagnostics(entity))
|
|
49
|
-
const functionDefinition = entity.getProperty('function_definition')?.getValue()
|
|
50
|
-
if (functionDefinition) {
|
|
51
|
-
if (typeof functionDefinition !== 'string' || !functionDefinition.match(regExp)) {
|
|
52
|
-
diagnostics.push(
|
|
53
|
-
new FluentDiagnostic(
|
|
54
|
-
node,
|
|
55
|
-
`'function_definition' must start with 'glidefunction:' and include a single function call to a predefined function:\n${validFunctions.join(
|
|
56
|
-
'\n'
|
|
57
|
-
)}`
|
|
58
|
-
)
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
handled: true,
|
|
65
|
-
diagnostics,
|
|
66
|
-
data: ObjectData.fromObjectValue(
|
|
67
|
-
{
|
|
68
|
-
...entity.getValue(),
|
|
69
|
-
entityKind,
|
|
70
|
-
},
|
|
71
|
-
entity.getNode()
|
|
72
|
-
),
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const StringColumnPlugin = ColumnPlugin(db.StringColumn, 'string')
|
|
82
|
-
export const BooleanColumnPlugin = ColumnPlugin(db.BooleanColumn, 'boolean')
|
|
83
|
-
export const IntegerColumnPlugin = ColumnPlugin(db.IntegerColumn, 'integer')
|
|
84
|
-
export const BasicImageColumnPlugin = ColumnPlugin(db.BasicImageColumn, 'image')
|
|
85
|
-
export const ConditionsColumnPlugin = ColumnPlugin(db.ConditionsColumn, 'conditions')
|
|
86
|
-
export const ChoiceColumnPlugin = ColumnPlugin(db.ChoiceColumn, 'choice')
|
|
87
|
-
export const DecimalColumnPlugin = ColumnPlugin(db.DecimalColumn, 'decimal')
|
|
88
|
-
export const DocumentIdColumnPlugin = ColumnPlugin(db.DocumentIdColumn, 'document_id')
|
|
89
|
-
export const DomainIdColumnPlugin = ColumnPlugin(db.DomainIdColumn, 'domain_id')
|
|
90
|
-
export const DomainPathColumnPlugin = ColumnPlugin(db.DomainPathColumn, 'domain_path')
|
|
91
|
-
export const ListColumnPlugin = ColumnPlugin(db.ListColumn, 'glide_list')
|
|
92
|
-
export const ReferenceColumnPlugin = ColumnPlugin(db.ReferenceColumn, 'reference')
|
|
93
|
-
export const RadioColumnPlugin = ColumnPlugin(db.RadioColumn, 'radio')
|
|
94
|
-
export const ScriptColumnPlugin = ColumnPlugin(db.ScriptColumn, 'script')
|
|
95
|
-
export const SystemClassNameColumnPlugin = ColumnPlugin(db.SystemClassNameColumn, 'sys_class_name')
|
|
96
|
-
export const TableNameColumnPlugin = ColumnPlugin(db.TableNameColumn, 'table_name')
|
|
97
|
-
export const TranslatedFieldColumnPlugin = ColumnPlugin(db.TranslatedFieldColumn, 'translated_field')
|
|
98
|
-
export const TranslatedTextColumnPlugin = ColumnPlugin(db.TranslatedTextColumn, 'translated_text')
|
|
99
|
-
export const UserRolesColumnPlugin = ColumnPlugin(db.UserRolesColumn, 'user_roles')
|
|
100
|
-
export const VersionColumnPlugin = ColumnPlugin(db.VersionColumn, 'version')
|
|
101
|
-
export const FieldNameColumnPlugin = ColumnPlugin(db.FieldNameColumn, 'field_name')
|
|
102
|
-
|
|
103
|
-
// Date columns
|
|
104
|
-
export const DateColumnPlugin = ColumnPlugin(db.DateColumn, 'glide_date')
|
|
105
|
-
export const DateTimeColumnPlugin = ColumnPlugin(db.DateTimeColumn, 'glide_date_time')
|
|
106
|
-
export const CalendarDateTimeColumnPlugin = ColumnPlugin(db.CalendarDateTimeColumn, 'calendar_date_time')
|
|
107
|
-
export const BasicDateTimeColumnPlugin = ColumnPlugin(db.BasicDateTimeColumn, 'datetime')
|
|
108
|
-
export const DueDateColumnPlugin = ColumnPlugin(db.DueDateColumn, 'due_date')
|
|
109
|
-
export const IntegerDateColumnPlugin = ColumnPlugin(db.IntegerDateColumn, 'integer_date')
|
|
110
|
-
export const ScheduleDateTimeColumnPlugin = ColumnPlugin(db.ScheduleDateTimeColumn, 'schedule_date_time')
|
|
111
|
-
export const OtherDateColumnPlugin = ColumnPlugin(db.OtherDateColumn, 'date')
|
|
112
|
-
|
|
113
|
-
// Catch all column type which keys of off 'internal_type'
|
|
114
|
-
export const GenericColumnPlugin = ColumnPlugin(db.GenericColumn, 'generic')
|
package/src/db/DBUtils.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { FluentDiagnostic } from '@servicenow/sdk-build-core'
|
|
2
|
-
import { isArray } from 'lodash'
|
|
3
|
-
import { Diagnostic } from '@servicenow/sdk-project'
|
|
4
|
-
|
|
5
|
-
export function getLabelDiagnostics(entity) {
|
|
6
|
-
const diagnostics: FluentDiagnostic[] = []
|
|
7
|
-
const label = entity.getProperty('label')?.getValue()
|
|
8
|
-
if (label && isArray(label)) {
|
|
9
|
-
const languages = {}
|
|
10
|
-
label.forEach((l, i) => {
|
|
11
|
-
const language = l.language
|
|
12
|
-
if (languages[language] !== undefined) {
|
|
13
|
-
diagnostics.push(
|
|
14
|
-
new FluentDiagnostic(
|
|
15
|
-
entity.getProperty('label')!.getNode().getChildrenOfKind(210)![i]?.getProperty('language') ??
|
|
16
|
-
entity.getProperty('label')!.getNode(),
|
|
17
|
-
`'language' must be unique per table/column`,
|
|
18
|
-
{ level: Diagnostic.Level.Error }
|
|
19
|
-
)
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
languages[language] = i
|
|
23
|
-
if (language === '' || (language && language.length !== 2)) {
|
|
24
|
-
diagnostics.push(
|
|
25
|
-
new FluentDiagnostic(
|
|
26
|
-
entity.getProperty('label')!.getNode().getChildrenOfKind(210)![i]?.getProperty('language') ??
|
|
27
|
-
entity.getProperty('label')!.getNode(),
|
|
28
|
-
`'language' must be a 2 character identifier (Ex. 'en', 'es')`,
|
|
29
|
-
{ level: Diagnostic.Level.Error }
|
|
30
|
-
)
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
return diagnostics
|
|
36
|
-
}
|