@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
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Acl,
|
|
3
|
-
TableAcl,
|
|
4
|
-
NamedAcl,
|
|
5
|
-
AclAttributes,
|
|
6
|
-
AclBase,
|
|
7
|
-
AclOperations,
|
|
8
|
-
AclTypes,
|
|
9
|
-
AclSchema,
|
|
10
|
-
} from '@servicenow/sdk-core/runtime/app'
|
|
11
|
-
import {
|
|
12
|
-
Plugin,
|
|
13
|
-
extractCallExpression,
|
|
14
|
-
generateCallExpressionExportForDocument,
|
|
15
|
-
getOrCreateEntitySourceFile,
|
|
16
|
-
getSysUpdateName,
|
|
17
|
-
linkDocument,
|
|
18
|
-
removeNode,
|
|
19
|
-
transformFunctionArguments,
|
|
20
|
-
FluentDiagnostic,
|
|
21
|
-
findObjectPropertyValue,
|
|
22
|
-
EntityData,
|
|
23
|
-
ObjectData,
|
|
24
|
-
ArrayData,
|
|
25
|
-
Data,
|
|
26
|
-
getCallExpressionName,
|
|
27
|
-
} from '@servicenow/sdk-build-core'
|
|
28
|
-
import { addObjectToArrayById, removeObjectFromArrayById } from './Util'
|
|
29
|
-
import { additionalProperties } from '@servicenow/sdk-core/runtime/util'
|
|
30
|
-
import { Record as DBRecord, TableName } from '@servicenow/sdk-core/runtime/db'
|
|
31
|
-
import { except } from '../scripts/scriptUtils'
|
|
32
|
-
import { ts } from '@servicenow/sdk-project'
|
|
33
|
-
import { AclNamedTypes } from '@servicenow/sdk-core/runtime/app'
|
|
34
|
-
import { processScript } from '../ScriptTemplatePlugin'
|
|
35
|
-
import { Diagnostic } from '@servicenow/sdk-project'
|
|
36
|
-
import { ModuleFunctionData } from '../ServerModulePlugin'
|
|
37
|
-
import { RecordPlugin } from '../db'
|
|
38
|
-
|
|
39
|
-
type AclDoc = {
|
|
40
|
-
table: string
|
|
41
|
-
data: {
|
|
42
|
-
sys_id: string
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type AclRole = {
|
|
47
|
-
table: string
|
|
48
|
-
data: {
|
|
49
|
-
sys_security_acl: string
|
|
50
|
-
sys_user_role: string
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
type AclData = AclBase & {
|
|
55
|
-
name: string
|
|
56
|
-
type: keyof typeof AclTypes
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const ExecuteOnlyTypes = new Set([
|
|
60
|
-
'client_callable_flow_object',
|
|
61
|
-
'client_callable_script_include',
|
|
62
|
-
'graphql',
|
|
63
|
-
'processor',
|
|
64
|
-
'rest_endpoint',
|
|
65
|
-
])
|
|
66
|
-
|
|
67
|
-
function aclAsRecord<T extends TableName>(config: Acl<T>) {
|
|
68
|
-
const tableConfig = config as TableAcl<T>
|
|
69
|
-
const namedConfig = config as NamedAcl
|
|
70
|
-
|
|
71
|
-
const field = String(tableConfig.field || '')
|
|
72
|
-
const name = namedConfig.name || (field ? `${tableConfig.table}.${field}` : tableConfig.table)
|
|
73
|
-
if (!name) {
|
|
74
|
-
throw new Error(`ACL of type ${config.type} and $id '${config.$id}' has no name or associated table`)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (config.operation !== 'execute' && ExecuteOnlyTypes.has(config.type)) {
|
|
78
|
-
throw new Error(`ACL ${name} must use operation 'execute', because it is of type '${config.type}'`)
|
|
79
|
-
}
|
|
80
|
-
if (config.script && config.type === 'graphql') {
|
|
81
|
-
throw new Error(`ACL ${name} does not support scripts, because it is of type ${config.type}`)
|
|
82
|
-
}
|
|
83
|
-
if (tableConfig.applies_to && tableConfig.type !== 'record') {
|
|
84
|
-
throw new Error(`ACL ${name} cannot set applies_to unless its type is 'record'`)
|
|
85
|
-
}
|
|
86
|
-
if (tableConfig.operation === 'add_to_list' && (config.script || config.condition)) {
|
|
87
|
-
throw new Error(`ACL ${name} cannot have a script or condition due to its 'add_to_list' operation`)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return DBRecord({
|
|
91
|
-
table: 'sys_security_acl',
|
|
92
|
-
$id: config.$id,
|
|
93
|
-
data: {
|
|
94
|
-
name,
|
|
95
|
-
active: config.active ?? true,
|
|
96
|
-
type: AclTypes[config.type ?? 'record'],
|
|
97
|
-
operation: AclOperations[config.operation as keyof typeof AclOperations] || config.operation || '',
|
|
98
|
-
decision_type: config.decision_type ?? 'allow',
|
|
99
|
-
description: config.description || '',
|
|
100
|
-
local_or_existing: config.local_or_existing || 'Local',
|
|
101
|
-
admin_overrides: config.admin_overrides ?? true,
|
|
102
|
-
advanced: !!config.script,
|
|
103
|
-
condition: config.condition ?? '',
|
|
104
|
-
applies_to: tableConfig.applies_to ?? '',
|
|
105
|
-
script: config.script as any,
|
|
106
|
-
security_attribute:
|
|
107
|
-
(config.security_attribute && AclAttributes[config.security_attribute as keyof typeof AclAttributes]) ||
|
|
108
|
-
config.security_attribute ||
|
|
109
|
-
'',
|
|
110
|
-
...additionalProperties(config, AclSchema),
|
|
111
|
-
},
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default Plugin({
|
|
116
|
-
name: 'Acl',
|
|
117
|
-
ownedTables: {
|
|
118
|
-
sys_security_acl: { diagnosticLevel: Diagnostic.Level.Warn },
|
|
119
|
-
},
|
|
120
|
-
extractors: {
|
|
121
|
-
entity: {
|
|
122
|
-
fluent: {
|
|
123
|
-
CallExpression(node, context) {
|
|
124
|
-
const result = extractCallExpression(Acl, 'record', node, context, (acl) =>
|
|
125
|
-
context.registerExplicitId('sys_security_acl', acl.$id)
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
if (!result.handled || !result.data) {
|
|
129
|
-
return result
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const acl = result.data
|
|
133
|
-
const aclRecord = aclAsRecord(acl.getValue())
|
|
134
|
-
const scriptVal = ModuleFunctionData.getGlueCode(
|
|
135
|
-
acl.getProperty('script'),
|
|
136
|
-
(n) => `answer = ${n}(current)`
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
const m2mRoleToAcl =
|
|
140
|
-
acl
|
|
141
|
-
.getProperty('roles')
|
|
142
|
-
?.getValue(true)
|
|
143
|
-
?.map((role) => {
|
|
144
|
-
const roleId = typeof role === 'string' ? role : role.$id
|
|
145
|
-
|
|
146
|
-
const roleSysId =
|
|
147
|
-
typeof role === 'string'
|
|
148
|
-
? role
|
|
149
|
-
: context.registerExplicitId('sys_user_role', role.$id)
|
|
150
|
-
const guid = context.keys.registerCompositeId('sys_security_acl_role', {
|
|
151
|
-
sys_security_acl: aclRecord.$id,
|
|
152
|
-
sys_user_role: roleId,
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
return new EntityData(
|
|
156
|
-
'record',
|
|
157
|
-
guid,
|
|
158
|
-
ObjectData.fromObjectValue(
|
|
159
|
-
DBRecord({
|
|
160
|
-
table: 'sys_security_acl_role',
|
|
161
|
-
$id: guid,
|
|
162
|
-
data: {
|
|
163
|
-
sys_security_acl: acl.getGuid(),
|
|
164
|
-
sys_user_role: roleSysId,
|
|
165
|
-
},
|
|
166
|
-
}),
|
|
167
|
-
node
|
|
168
|
-
),
|
|
169
|
-
node,
|
|
170
|
-
acl.getInstallMethod()
|
|
171
|
-
)
|
|
172
|
-
}) || []
|
|
173
|
-
|
|
174
|
-
const diagnostics = performDiagnosticChecksOnSecurityAttribute(
|
|
175
|
-
node,
|
|
176
|
-
acl.getValue(true),
|
|
177
|
-
m2mRoleToAcl
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
const aclWithScript = { ...aclRecord, data: { ...aclRecord.data, script: scriptVal || '' } }
|
|
181
|
-
const aclEntityData = new EntityData(
|
|
182
|
-
'record',
|
|
183
|
-
acl.getGuid(),
|
|
184
|
-
ObjectData.fromObjectValue(aclWithScript, node),
|
|
185
|
-
node,
|
|
186
|
-
acl.getInstallMethod()
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
const wrapperEntity = new EntityData(
|
|
190
|
-
'acl',
|
|
191
|
-
acl.getGuid(),
|
|
192
|
-
new ObjectData(
|
|
193
|
-
{
|
|
194
|
-
records: new ArrayData([aclEntityData, ...m2mRoleToAcl], node),
|
|
195
|
-
},
|
|
196
|
-
node
|
|
197
|
-
),
|
|
198
|
-
node,
|
|
199
|
-
acl.getInstallMethod(),
|
|
200
|
-
acl.getExplicitIds()
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
handled: true,
|
|
205
|
-
diagnostics: [...result.diagnostics, ...diagnostics],
|
|
206
|
-
data: wrapperEntity,
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
composers: {
|
|
213
|
-
entity: {
|
|
214
|
-
acl(entity, context) {
|
|
215
|
-
return Promise.all(
|
|
216
|
-
entity
|
|
217
|
-
.getPropertyOrThrow('records', 'array')
|
|
218
|
-
.getElements()
|
|
219
|
-
.map((record) => {
|
|
220
|
-
if (!Data.isEntity(record)) {
|
|
221
|
-
throw new Error('Expected entity')
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return RecordPlugin.composers.entity.record(record, context)
|
|
225
|
-
})
|
|
226
|
-
.flat()
|
|
227
|
-
)
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
arrangers: {
|
|
232
|
-
record(document, context) {
|
|
233
|
-
if ((document.data as any).table !== 'sys_security_acl_role') {
|
|
234
|
-
return { handled: false }
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const aclId = (document.data as any).data.sys_security_acl
|
|
238
|
-
const aclDoc = context.getDocument(aclId, 'record')
|
|
239
|
-
const aclDeleted = aclDoc && aclDoc.action === 'DELETE'
|
|
240
|
-
if (aclDeleted && document.action === 'INSERT_OR_UPDATE') {
|
|
241
|
-
throw new Error(
|
|
242
|
-
`Existing sys_security_acl_role with id ${document.guid} is referencing deleted ACL ${aclId}. This can be fixed by either deleting the sys_security_acl_role record or updating its sys_security_acl reference.`
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return {
|
|
247
|
-
handled: true,
|
|
248
|
-
result: aclId ? { kind: 'record', guid: aclId } : undefined,
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
generators: {
|
|
253
|
-
record(document, context, linkedDocuments) {
|
|
254
|
-
const documentType = (document.data as any)?.table
|
|
255
|
-
if (documentType === 'sys_security_acl_role') {
|
|
256
|
-
if (!document.parent) {
|
|
257
|
-
return undefined
|
|
258
|
-
}
|
|
259
|
-
const acl = linkedDocuments.find(
|
|
260
|
-
(doc) =>
|
|
261
|
-
(doc.data as AclDoc).table === 'sys_security_acl' &&
|
|
262
|
-
doc.guid === (document.data as AclRole).data.sys_security_acl
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
return acl && acl.node ? { ...document, node: acl.node } : undefined
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (documentType !== 'sys_security_acl') {
|
|
269
|
-
return undefined
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return linkDocument(
|
|
273
|
-
document,
|
|
274
|
-
generateCallExpressionExportForDocument(
|
|
275
|
-
context,
|
|
276
|
-
{
|
|
277
|
-
sourceFile: getOrCreateEntitySourceFile(
|
|
278
|
-
context,
|
|
279
|
-
getSysUpdateName(document, 'sys_security_acl')
|
|
280
|
-
),
|
|
281
|
-
moduleSpecifier: '@servicenow/sdk/core',
|
|
282
|
-
},
|
|
283
|
-
Acl,
|
|
284
|
-
{ $id: document.guid }
|
|
285
|
-
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
286
|
-
)
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
transformers: {
|
|
290
|
-
record: {
|
|
291
|
-
CallExpression(document, context) {
|
|
292
|
-
const documentType = (document.data as any)?.table
|
|
293
|
-
|
|
294
|
-
const [args] = document.node.getArguments()
|
|
295
|
-
if (!ts.Node.isObjectLiteralExpression(args)) {
|
|
296
|
-
return false
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (documentType === 'sys_security_acl_role') {
|
|
300
|
-
if (!document.parent || getCallExpressionName(document.node) !== Acl.name) {
|
|
301
|
-
// Record plugin can handle this as its own entity
|
|
302
|
-
return false
|
|
303
|
-
}
|
|
304
|
-
const acl2Role = (document.data as AclRole).data
|
|
305
|
-
if (document.action === 'DELETE') {
|
|
306
|
-
const roleId = acl2Role.sys_user_role
|
|
307
|
-
if (roleId) {
|
|
308
|
-
removeObjectFromArrayById(document, 'roles', context)
|
|
309
|
-
}
|
|
310
|
-
return true
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
addObjectToArrayById(document, 'roles', acl2Role.sys_user_role, context)
|
|
314
|
-
return true
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (document.action === 'DELETE') {
|
|
318
|
-
removeNode(document.node)
|
|
319
|
-
return true
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (documentType !== 'sys_security_acl' || !document.changedData) {
|
|
323
|
-
return false
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
const modifiedAclData = (document.changedData as any).data as AclBase
|
|
327
|
-
const unmodifiedAclData = (document.data as any).data as AclData
|
|
328
|
-
const type = reverseLookup(AclTypes, unmodifiedAclData.type)
|
|
329
|
-
|
|
330
|
-
const aclData = {
|
|
331
|
-
...except(
|
|
332
|
-
modifiedAclData,
|
|
333
|
-
(key) =>
|
|
334
|
-
key.startsWith('sys_') ||
|
|
335
|
-
key === 'advanced' ||
|
|
336
|
-
key === 'name' ||
|
|
337
|
-
key === 'operation' ||
|
|
338
|
-
key === 'script'
|
|
339
|
-
),
|
|
340
|
-
...getTableOrName(type, unmodifiedAclData.name),
|
|
341
|
-
security_attribute:
|
|
342
|
-
reverseLookup(AclAttributes, unmodifiedAclData.security_attribute) ||
|
|
343
|
-
unmodifiedAclData.security_attribute,
|
|
344
|
-
operation: reverseLookup(AclOperations, unmodifiedAclData.operation) || unmodifiedAclData.operation,
|
|
345
|
-
type,
|
|
346
|
-
} as any
|
|
347
|
-
|
|
348
|
-
const { script } = modifiedAclData as { script?: string }
|
|
349
|
-
if (script !== undefined) {
|
|
350
|
-
processScript(args, 'script', script)
|
|
351
|
-
}
|
|
352
|
-
transformFunctionArguments(document.node, Acl, aclData)
|
|
353
|
-
context.argTypesToFix.push(document.node)
|
|
354
|
-
return true
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
// security_attribute.is_localizsed ? 'Local' : 'Existing'
|
|
361
|
-
function performDiagnosticChecksOnSecurityAttribute<T>(
|
|
362
|
-
callExpression: ts.CallExpression,
|
|
363
|
-
aclData: AclBase,
|
|
364
|
-
roles: Array<T>
|
|
365
|
-
) {
|
|
366
|
-
const diagnostics: FluentDiagnostic[] = []
|
|
367
|
-
|
|
368
|
-
if (roles.length < 1) {
|
|
369
|
-
const attributeRecord = aclData.security_attribute as DBRecord<'sys_security_attribute'>
|
|
370
|
-
if (!aclData.security_attribute && !aclData.script && !aclData.condition) {
|
|
371
|
-
diagnostics.push(
|
|
372
|
-
new FluentDiagnostic(
|
|
373
|
-
callExpression,
|
|
374
|
-
'ACLs must have at least one of the following: roles, security_attribute, condition, or script',
|
|
375
|
-
{ level: Diagnostic.Level.Warn }
|
|
376
|
-
)
|
|
377
|
-
)
|
|
378
|
-
} else if (attributeRecord && attributeRecord.data) {
|
|
379
|
-
if (
|
|
380
|
-
aclData.local_or_existing === 'Existing' &&
|
|
381
|
-
(attributeRecord.data.type !== 'compound' || attributeRecord.data.is_localized)
|
|
382
|
-
) {
|
|
383
|
-
diagnostics.push(
|
|
384
|
-
new FluentDiagnostic(
|
|
385
|
-
findObjectPropertyValue(callExpression, 'security_attribute'),
|
|
386
|
-
`Invalid ACL with 'Existing' sys_security_attribute: Must have a security_attribute with a type of 'compound' and is_localized set to false.`
|
|
387
|
-
)
|
|
388
|
-
)
|
|
389
|
-
} else if (
|
|
390
|
-
(!aclData.local_or_existing || aclData.local_or_existing === 'Local') &&
|
|
391
|
-
!attributeRecord.data.is_localized
|
|
392
|
-
) {
|
|
393
|
-
diagnostics.push(
|
|
394
|
-
new FluentDiagnostic(
|
|
395
|
-
findObjectPropertyValue(callExpression, 'security_attribute'),
|
|
396
|
-
`Invalid ACL with 'Local' security_attribute: security_attribute must have is_localized set to true`
|
|
397
|
-
)
|
|
398
|
-
)
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
return diagnostics
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function getTableOrName(type: keyof typeof AclTypes, name: string) {
|
|
406
|
-
if (AclNamedTypes[type]) {
|
|
407
|
-
return { name }
|
|
408
|
-
}
|
|
409
|
-
const tablePathParts = name.split('.')
|
|
410
|
-
const table = tablePathParts[0] || ''
|
|
411
|
-
const field = tablePathParts[1] || ''
|
|
412
|
-
|
|
413
|
-
return { table, field }
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function reverseLookup<T extends object>(obj: T, sysId): keyof T {
|
|
417
|
-
return (Object.entries(obj)
|
|
418
|
-
.filter(([_, id]) => id === sysId)
|
|
419
|
-
.map(([key]) => key)[0] || '') as keyof T
|
|
420
|
-
}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { Role, RoleConfig, roleSchema } from '@servicenow/sdk-core/runtime/app'
|
|
2
|
-
import {
|
|
3
|
-
Context,
|
|
4
|
-
Plugin,
|
|
5
|
-
linkDocument,
|
|
6
|
-
extractCallExpression,
|
|
7
|
-
FluentDiagnostic,
|
|
8
|
-
findObjectPropertyValue,
|
|
9
|
-
Data,
|
|
10
|
-
isSNScope,
|
|
11
|
-
LinkedDocument,
|
|
12
|
-
ArrayData,
|
|
13
|
-
} from '@servicenow/sdk-build-core'
|
|
14
|
-
import {
|
|
15
|
-
generateCallExpressionExportForDocument,
|
|
16
|
-
getOrCreateEntitySourceFile,
|
|
17
|
-
transformFunctionArguments,
|
|
18
|
-
getSysUpdateName,
|
|
19
|
-
removeNode,
|
|
20
|
-
} from '@servicenow/sdk-build-core'
|
|
21
|
-
import { addObjectToArrayById, removeObjectFromArrayById } from './Util'
|
|
22
|
-
import { except } from '../scripts/scriptUtils'
|
|
23
|
-
import { Diagnostic, SupportedNode, ts } from '@servicenow/sdk-project'
|
|
24
|
-
|
|
25
|
-
export function getRolesString(roles: ArrayData<unknown[]>): string {
|
|
26
|
-
const uniqueRoles = [
|
|
27
|
-
...new Set(
|
|
28
|
-
roles.getElements().map((role) => {
|
|
29
|
-
return Data.isEntity(role) ? role.getPropertyOrThrow('name', 'string').getValue() : role.getValue()
|
|
30
|
-
})
|
|
31
|
-
),
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
return uniqueRoles.join(',')
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function mapRoleToRole(context: Context, roleId: string, containedRoleId: string, node: SupportedNode): LinkedDocument {
|
|
38
|
-
const mappingId = context.keys.registerCompositeId('sys_user_role_contains', {
|
|
39
|
-
role: roleId,
|
|
40
|
-
contains: containedRoleId,
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
kind: 'record',
|
|
45
|
-
guid: mappingId,
|
|
46
|
-
node,
|
|
47
|
-
data: {
|
|
48
|
-
$id: mappingId,
|
|
49
|
-
table: 'sys_user_role_contains',
|
|
50
|
-
data: {
|
|
51
|
-
contains: containedRoleId,
|
|
52
|
-
role: roleId,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
type RoleDoc = {
|
|
59
|
-
table: string
|
|
60
|
-
data: {
|
|
61
|
-
sys_id: string
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
type RoleContainsDoc = {
|
|
66
|
-
table: string
|
|
67
|
-
data: {
|
|
68
|
-
role: string
|
|
69
|
-
contains: string
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default Plugin({
|
|
74
|
-
name: 'Role',
|
|
75
|
-
ownedTables: {
|
|
76
|
-
sys_user_role: { diagnosticLevel: Diagnostic.Level.Error },
|
|
77
|
-
},
|
|
78
|
-
extractors: {
|
|
79
|
-
entity: {
|
|
80
|
-
fluent: {
|
|
81
|
-
CallExpression: (node, context) => {
|
|
82
|
-
const result = extractCallExpression(
|
|
83
|
-
Role as (role: RoleConfig) => RoleConfig,
|
|
84
|
-
'role',
|
|
85
|
-
node,
|
|
86
|
-
context,
|
|
87
|
-
({ $id }) => context.registerExplicitId('sys_user_role', $id as string)
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
if (!result.handled || !result.data) {
|
|
91
|
-
return result
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const role = result.data
|
|
95
|
-
const diagnostics = result.diagnostics
|
|
96
|
-
const scope = context.app?.config?.scope
|
|
97
|
-
const name = role.getProperty('name').getValue()
|
|
98
|
-
if (!isSNScope(scope) && !name.startsWith(`${scope}.`)) {
|
|
99
|
-
const nameValue = findObjectPropertyValue(node, 'name')
|
|
100
|
-
diagnostics.push(new FluentDiagnostic(nameValue, `Role name must begin with '${scope}.'`))
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
handled: true,
|
|
105
|
-
diagnostics,
|
|
106
|
-
data: role,
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
composers: {
|
|
113
|
-
entity: {
|
|
114
|
-
role(entity, context) {
|
|
115
|
-
const scope = context.app?.config?.scope
|
|
116
|
-
const guid = entity.getGuid()
|
|
117
|
-
|
|
118
|
-
const role = roleSchema.safeParse(entity.getValue())
|
|
119
|
-
if (!role.success) {
|
|
120
|
-
return Promise.resolve(undefined)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const { $id: _, name, contains_roles, ...rest } = role.data
|
|
124
|
-
|
|
125
|
-
const roleMappingDocuments: LinkedDocument[] = []
|
|
126
|
-
const containsRoles = entity.getProperty('contains_roles')
|
|
127
|
-
if (Data.isArray(containsRoles)) {
|
|
128
|
-
for (const containedRole of containsRoles.getElements()) {
|
|
129
|
-
const containedRoleSysId = Data.isEntity(containedRole)
|
|
130
|
-
? containedRole.getGuid()
|
|
131
|
-
: Data.isString(containedRole)
|
|
132
|
-
? containedRole.getValue()
|
|
133
|
-
: undefined
|
|
134
|
-
|
|
135
|
-
if (!containedRoleSysId) {
|
|
136
|
-
throw new Error(`Invalid contained role value: ${containedRole.getValue()}`)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
roleMappingDocuments.push(
|
|
140
|
-
mapRoleToRole(context, guid, containedRoleSysId, containedRole.getNode())
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const suffix = name.replace(new RegExp(`^${scope}\\.`), '')
|
|
146
|
-
const roleDocument = {
|
|
147
|
-
kind: 'record',
|
|
148
|
-
guid,
|
|
149
|
-
node: entity.getNode(),
|
|
150
|
-
data: {
|
|
151
|
-
$id: guid,
|
|
152
|
-
table: 'sys_user_role',
|
|
153
|
-
data: {
|
|
154
|
-
name,
|
|
155
|
-
suffix,
|
|
156
|
-
...rest,
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return Promise.resolve([roleDocument, ...roleMappingDocuments])
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
arrangers: {
|
|
166
|
-
record(document) {
|
|
167
|
-
if ((document.data as any).table !== 'sys_user_role_contains') {
|
|
168
|
-
return { handled: false }
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const roleId = (document.data as any).data.role
|
|
172
|
-
return {
|
|
173
|
-
handled: true,
|
|
174
|
-
result: roleId ? { kind: 'record', guid: roleId } : undefined,
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
generators: {
|
|
179
|
-
record(document, context: Context, linkedDocuments) {
|
|
180
|
-
const documentType = (document.data as any)?.table
|
|
181
|
-
if (documentType === 'sys_user_role_contains') {
|
|
182
|
-
const role = linkedDocuments.find(
|
|
183
|
-
(doc) =>
|
|
184
|
-
(doc.data as RoleDoc).table === 'sys_user_role' &&
|
|
185
|
-
doc.guid === (document.data as RoleContainsDoc).data.role
|
|
186
|
-
)
|
|
187
|
-
return role && role.node ? { ...document, node: role.node } : undefined
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (documentType !== 'sys_user_role') {
|
|
191
|
-
return undefined
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return linkDocument(
|
|
195
|
-
document,
|
|
196
|
-
generateCallExpressionExportForDocument(
|
|
197
|
-
context,
|
|
198
|
-
{
|
|
199
|
-
sourceFile: getOrCreateEntitySourceFile(context, getSysUpdateName(document, 'sys_user_role')),
|
|
200
|
-
moduleSpecifier: '@servicenow/sdk/core',
|
|
201
|
-
},
|
|
202
|
-
Role,
|
|
203
|
-
{ $id: document.guid }
|
|
204
|
-
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
205
|
-
)
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
transformers: {
|
|
209
|
-
record: {
|
|
210
|
-
CallExpression(document, context) {
|
|
211
|
-
const documentType = (document.data as any)?.table
|
|
212
|
-
if (documentType === 'sys_user_role_contains') {
|
|
213
|
-
const [args] = document.node.getArguments()
|
|
214
|
-
if (!ts.Node.isObjectLiteralExpression(args) || !document.parent) {
|
|
215
|
-
return false
|
|
216
|
-
}
|
|
217
|
-
if (document.action === 'DELETE') {
|
|
218
|
-
removeObjectFromArrayById(document, 'contains_roles', context)
|
|
219
|
-
return true
|
|
220
|
-
}
|
|
221
|
-
const m2mData = (document.data as RoleContainsDoc).data
|
|
222
|
-
addObjectToArrayById(document, 'contains_roles', m2mData.contains, context)
|
|
223
|
-
return true
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (documentType !== 'sys_user_role') {
|
|
227
|
-
return false
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (document.action === 'DELETE') {
|
|
231
|
-
removeNode(document.node)
|
|
232
|
-
return true
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (!document.changedData) {
|
|
236
|
-
return true
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const rawRoleData = (document.changedData as any).data
|
|
240
|
-
const roleData = except(
|
|
241
|
-
rawRoleData,
|
|
242
|
-
(key) =>
|
|
243
|
-
key.startsWith('sys_') ||
|
|
244
|
-
key === 'requires_subscription' ||
|
|
245
|
-
key === 'suffix' ||
|
|
246
|
-
key === 'includes_roles'
|
|
247
|
-
)
|
|
248
|
-
transformFunctionArguments(document.node, Role, roleData)
|
|
249
|
-
context.argTypesToFix.push(document.node)
|
|
250
|
-
return true
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
})
|