@servicenow/sdk-build-plugins 3.0.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acl-plugin.d.ts +19 -0
- package/dist/acl-plugin.js +210 -0
- package/dist/acl-plugin.js.map +1 -0
- package/dist/application-menu-plugin.d.ts +18 -0
- package/dist/application-menu-plugin.js +104 -0
- package/dist/application-menu-plugin.js.map +1 -0
- package/dist/arrow-function-plugin.d.ts +16 -0
- package/dist/arrow-function-plugin.js +107 -0
- package/dist/arrow-function-plugin.js.map +1 -0
- package/dist/atf/step-configs.d.ts +37 -0
- package/dist/atf/step-configs.js +2236 -0
- package/dist/atf/step-configs.js.map +1 -0
- package/dist/atf/test-plugin.d.ts +4 -0
- package/dist/atf/test-plugin.js +591 -0
- package/dist/atf/test-plugin.js.map +1 -0
- package/dist/basic-syntax-plugin.d.ts +2 -0
- package/dist/basic-syntax-plugin.js +636 -0
- package/dist/basic-syntax-plugin.js.map +1 -0
- package/dist/business-rule-plugin.d.ts +3 -0
- package/dist/business-rule-plugin.js +205 -0
- package/dist/business-rule-plugin.js.map +1 -0
- package/dist/call-expression-plugin.d.ts +2 -0
- package/dist/call-expression-plugin.js +175 -0
- package/dist/call-expression-plugin.js.map +1 -0
- package/dist/client-script-plugin.d.ts +29 -0
- package/dist/client-script-plugin.js +157 -0
- package/dist/client-script-plugin.js.map +1 -0
- package/dist/column/column-helper.d.ts +12 -0
- package/dist/column/column-helper.js +84 -0
- package/dist/column/column-helper.js.map +1 -0
- package/dist/column/column-to-record.d.ts +3 -0
- package/dist/column/column-to-record.js +105 -0
- package/dist/column/column-to-record.js.map +1 -0
- package/dist/column-plugin.d.ts +8 -0
- package/dist/column-plugin.js +453 -0
- package/dist/column-plugin.js.map +1 -0
- package/dist/cross-scope-privilege-plugin.d.ts +15 -0
- package/dist/cross-scope-privilege-plugin.js +82 -0
- package/dist/cross-scope-privilege-plugin.js.map +1 -0
- package/dist/html-import-plugin.d.ts +2 -0
- package/dist/html-import-plugin.js +72 -0
- package/dist/html-import-plugin.js.map +1 -0
- package/dist/index.d.ts +37 -21
- package/dist/index.js +40 -45
- package/dist/index.js.map +1 -1
- package/dist/json-plugin.d.ts +15 -0
- package/dist/json-plugin.js +104 -0
- package/dist/json-plugin.js.map +1 -0
- package/dist/list-plugin.d.ts +2 -0
- package/dist/list-plugin.js +191 -0
- package/dist/list-plugin.js.map +1 -0
- package/dist/now-config-plugin.d.ts +4 -0
- package/dist/now-config-plugin.js +154 -0
- package/dist/now-config-plugin.js.map +1 -0
- package/dist/now-id-plugin.d.ts +11 -0
- package/dist/now-id-plugin.js +71 -0
- package/dist/now-id-plugin.js.map +1 -0
- package/dist/now-include-plugin.d.ts +16 -0
- package/dist/now-include-plugin.js +118 -0
- package/dist/now-include-plugin.js.map +1 -0
- package/dist/now-ref-plugin.d.ts +2 -0
- package/dist/now-ref-plugin.js +43 -0
- package/dist/now-ref-plugin.js.map +1 -0
- package/dist/now-unresolved-plugin.d.ts +2 -0
- package/dist/now-unresolved-plugin.js +32 -0
- package/dist/now-unresolved-plugin.js.map +1 -0
- package/dist/package-json-plugin.d.ts +2 -0
- package/dist/package-json-plugin.js +70 -0
- package/dist/package-json-plugin.js.map +1 -0
- package/dist/property-plugin.d.ts +2 -0
- package/dist/property-plugin.js +105 -0
- package/dist/property-plugin.js.map +1 -0
- package/dist/record-plugin.d.ts +43 -0
- package/dist/record-plugin.js +147 -0
- package/dist/record-plugin.js.map +1 -0
- package/dist/repack/index.d.ts +1 -0
- package/dist/repack/index.js +10 -2
- package/dist/repack/index.js.map +1 -1
- package/dist/repack/lint/Rules.d.ts +1 -1
- package/dist/repack/lint/Rules.js +7 -3
- package/dist/repack/lint/Rules.js.map +1 -1
- package/dist/repack/lint/index.js +1 -1
- package/dist/rest-api-plugin.d.ts +2 -0
- package/dist/rest-api-plugin.js +469 -0
- package/dist/rest-api-plugin.js.map +1 -0
- package/dist/role-plugin.d.ts +2 -0
- package/dist/role-plugin.js +117 -0
- package/dist/role-plugin.js.map +1 -0
- package/dist/script-action-plugin.d.ts +2 -0
- package/dist/script-action-plugin.js +62 -0
- package/dist/script-action-plugin.js.map +1 -0
- package/dist/script-include-plugin.d.ts +2 -0
- package/dist/script-include-plugin.js +102 -0
- package/dist/script-include-plugin.js.map +1 -0
- package/dist/server-module-plugin/index.d.ts +14 -0
- package/dist/server-module-plugin/index.js +378 -0
- package/dist/server-module-plugin/index.js.map +1 -0
- package/dist/server-module-plugin/sbom-builder.d.ts +45 -0
- package/dist/server-module-plugin/sbom-builder.js +179 -0
- package/dist/server-module-plugin/sbom-builder.js.map +1 -0
- package/dist/service-portal/angular-provider-plugin.d.ts +2 -0
- package/dist/service-portal/angular-provider-plugin.js +78 -0
- package/dist/service-portal/angular-provider-plugin.js.map +1 -0
- package/dist/service-portal/dependency-plugin.d.ts +2 -0
- package/dist/service-portal/dependency-plugin.js +235 -0
- package/dist/service-portal/dependency-plugin.js.map +1 -0
- package/dist/service-portal/widget-plugin.d.ts +6 -0
- package/dist/service-portal/widget-plugin.js +230 -0
- package/dist/service-portal/widget-plugin.js.map +1 -0
- package/dist/static-content-plugin.d.ts +2 -0
- package/dist/static-content-plugin.js +272 -0
- package/dist/static-content-plugin.js.map +1 -0
- package/dist/table-plugin.d.ts +3 -0
- package/dist/table-plugin.js +1324 -0
- package/dist/table-plugin.js.map +1 -0
- package/dist/ui-action-plugin.d.ts +2 -0
- package/dist/ui-action-plugin.js +291 -0
- package/dist/ui-action-plugin.js.map +1 -0
- package/dist/ui-page-plugin.d.ts +2 -0
- package/dist/ui-page-plugin.js +165 -0
- package/dist/ui-page-plugin.js.map +1 -0
- package/dist/user-preference-plugin.d.ts +15 -0
- package/dist/user-preference-plugin.js +63 -0
- package/dist/user-preference-plugin.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.js +72 -0
- package/dist/utils.js.map +1 -0
- package/dist/view-plugin.d.ts +2 -0
- package/dist/view-plugin.js +45 -0
- package/dist/view-plugin.js.map +1 -0
- package/package.json +17 -13
- package/src/acl-plugin.ts +256 -0
- package/src/application-menu-plugin.ts +109 -0
- package/src/arrow-function-plugin.ts +127 -0
- package/src/atf/step-configs.ts +2284 -0
- package/src/atf/test-plugin.ts +728 -0
- package/src/basic-syntax-plugin.ts +729 -0
- package/src/business-rule-plugin.ts +266 -0
- package/src/call-expression-plugin.ts +202 -0
- package/src/client-script-plugin.ts +170 -0
- package/src/column/column-helper.ts +119 -0
- package/src/column/column-to-record.ts +131 -0
- package/src/column-plugin.ts +506 -0
- package/src/cross-scope-privilege-plugin.ts +82 -0
- package/src/html-import-plugin.ts +79 -0
- package/src/index.ts +39 -21
- package/src/json-plugin.ts +128 -0
- package/src/list-plugin.ts +222 -0
- package/src/now-config-plugin.ts +194 -0
- package/src/now-id-plugin.ts +78 -0
- package/src/now-include-plugin.ts +140 -0
- package/src/now-ref-plugin.ts +48 -0
- package/src/now-unresolved-plugin.ts +30 -0
- package/src/package-json-plugin.ts +87 -0
- package/src/property-plugin.ts +118 -0
- package/src/record-plugin.ts +171 -0
- package/src/repack/index.ts +10 -1
- package/src/repack/lint/Rules.ts +5 -4
- package/src/repack/lint/index.ts +1 -1
- package/src/rest-api-plugin.ts +651 -0
- package/src/role-plugin.ts +128 -0
- package/src/script-action-plugin.ts +63 -0
- package/src/script-include-plugin.ts +110 -0
- package/src/server-module-plugin/index.ts +470 -0
- package/src/server-module-plugin/sbom-builder.ts +183 -0
- package/src/service-portal/angular-provider-plugin.ts +83 -0
- package/src/service-portal/dependency-plugin.ts +284 -0
- package/src/service-portal/widget-plugin.ts +263 -0
- package/src/static-content-plugin.ts +254 -0
- package/src/table-plugin.ts +1698 -0
- package/src/ui-action-plugin.ts +324 -0
- package/src/ui-page-plugin.ts +168 -0
- package/src/user-preference-plugin.ts +62 -0
- package/src/utils.ts +69 -0
- package/src/view-plugin.ts +46 -0
- package/dist/AttachmentPlugin.d.ts +0 -254
- package/dist/AttachmentPlugin.js +0 -220
- package/dist/AttachmentPlugin.js.map +0 -1
- package/dist/BusinessRulePlugin.d.ts +0 -30
- package/dist/BusinessRulePlugin.js +0 -149
- package/dist/BusinessRulePlugin.js.map +0 -1
- package/dist/CrossScopePrivilegePlugin.d.ts +0 -35
- package/dist/CrossScopePrivilegePlugin.js +0 -80
- package/dist/CrossScopePrivilegePlugin.js.map +0 -1
- package/dist/DefaultPlugin.d.ts +0 -86
- package/dist/DefaultPlugin.js +0 -226
- package/dist/DefaultPlugin.js.map +0 -1
- package/dist/HtmlTemplatePlugin.d.ts +0 -21
- package/dist/HtmlTemplatePlugin.js +0 -29
- package/dist/HtmlTemplatePlugin.js.map +0 -1
- package/dist/IdPlugin.d.ts +0 -28
- package/dist/IdPlugin.js +0 -68
- package/dist/IdPlugin.js.map +0 -1
- package/dist/IncludePlugin.d.ts +0 -34
- package/dist/IncludePlugin.js +0 -155
- package/dist/IncludePlugin.js.map +0 -1
- package/dist/JsonPlugin.d.ts +0 -28
- package/dist/JsonPlugin.js +0 -69
- package/dist/JsonPlugin.js.map +0 -1
- package/dist/ListPlugin.d.ts +0 -93
- package/dist/ListPlugin.js +0 -456
- package/dist/ListPlugin.js.map +0 -1
- package/dist/NowConfigPlugin.d.ts +0 -45
- package/dist/NowConfigPlugin.js +0 -64
- package/dist/NowConfigPlugin.js.map +0 -1
- package/dist/PackageJsonPlugin.d.ts +0 -34
- package/dist/PackageJsonPlugin.js +0 -63
- package/dist/PackageJsonPlugin.js.map +0 -1
- package/dist/PropertyPlugin.d.ts +0 -51
- package/dist/PropertyPlugin.js +0 -181
- package/dist/PropertyPlugin.js.map +0 -1
- package/dist/ScriptTemplatePlugin.d.ts +0 -13
- package/dist/ScriptTemplatePlugin.js +0 -55
- package/dist/ScriptTemplatePlugin.js.map +0 -1
- package/dist/ServerModulePlugin.d.ts +0 -75
- package/dist/ServerModulePlugin.js +0 -368
- package/dist/ServerModulePlugin.js.map +0 -1
- package/dist/UserPreferencePlugin.d.ts +0 -19
- package/dist/UserPreferencePlugin.js +0 -32
- package/dist/UserPreferencePlugin.js.map +0 -1
- package/dist/aclAndRole/AclPlugin.d.ts +0 -82
- package/dist/aclAndRole/AclPlugin.js +0 -262
- package/dist/aclAndRole/AclPlugin.js.map +0 -1
- package/dist/aclAndRole/RolePlugin.d.ts +0 -66
- package/dist/aclAndRole/RolePlugin.js +0 -179
- package/dist/aclAndRole/RolePlugin.js.map +0 -1
- package/dist/aclAndRole/Util.d.ts +0 -3
- package/dist/aclAndRole/Util.js +0 -90
- package/dist/aclAndRole/Util.js.map +0 -1
- package/dist/app/ApplicationMenuPlugin.d.ts +0 -34
- package/dist/app/ApplicationMenuPlugin.js +0 -112
- package/dist/app/ApplicationMenuPlugin.js.map +0 -1
- package/dist/db/ColumnPlugins.d.ts +0 -750
- package/dist/db/ColumnPlugins.js +0 -114
- package/dist/db/ColumnPlugins.js.map +0 -1
- package/dist/db/DBUtils.d.ts +0 -2
- package/dist/db/DBUtils.js +0 -27
- package/dist/db/DBUtils.js.map +0 -1
- package/dist/db/DocumentationPlugin.d.ts +0 -67
- package/dist/db/DocumentationPlugin.js +0 -258
- package/dist/db/DocumentationPlugin.js.map +0 -1
- package/dist/db/LicensingPlugin.d.ts +0 -60
- package/dist/db/LicensingPlugin.js +0 -117
- package/dist/db/LicensingPlugin.js.map +0 -1
- package/dist/db/RecordPlugin.d.ts +0 -133
- package/dist/db/RecordPlugin.js +0 -337
- package/dist/db/RecordPlugin.js.map +0 -1
- package/dist/db/TablePlugin.d.ts +0 -231
- package/dist/db/TablePlugin.js +0 -1628
- package/dist/db/TablePlugin.js.map +0 -1
- package/dist/db/index.d.ts +0 -6
- package/dist/db/index.js +0 -32
- package/dist/db/index.js.map +0 -1
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.d.ts +0 -10
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js +0 -373
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RESTSerializationUtils.d.ts +0 -13
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js +0 -177
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RestApiPlugin.d.ts +0 -81
- package/dist/scriptedRESTAPI/RestApiPlugin.js +0 -345
- package/dist/scriptedRESTAPI/RestApiPlugin.js.map +0 -1
- package/dist/scriptedRESTAPI/RestSchemaUtils.d.ts +0 -190
- package/dist/scriptedRESTAPI/RestSchemaUtils.js +0 -53
- package/dist/scriptedRESTAPI/RestSchemaUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RestUtils.d.ts +0 -69
- package/dist/scriptedRESTAPI/RestUtils.js +0 -497
- package/dist/scriptedRESTAPI/RestUtils.js.map +0 -1
- package/dist/scripts/ClientScriptPlugin.d.ts +0 -64
- package/dist/scripts/ClientScriptPlugin.js +0 -170
- package/dist/scripts/ClientScriptPlugin.js.map +0 -1
- package/dist/scripts/scriptUtils.d.ts +0 -1
- package/dist/scripts/scriptUtils.js +0 -9
- package/dist/scripts/scriptUtils.js.map +0 -1
- package/dist/uxf/ExperiencePlugin.d.ts +0 -45
- package/dist/uxf/ExperiencePlugin.js +0 -61
- package/dist/uxf/ExperiencePlugin.js.map +0 -1
- package/dist/uxf/RoutesPlugin.d.ts +0 -29
- package/dist/uxf/RoutesPlugin.js +0 -181
- package/dist/uxf/RoutesPlugin.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/cleanUxValue.d.ts +0 -4
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js +0 -65
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/api.d.ts +0 -189
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js +0 -158
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.d.ts +0 -13
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -604
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.d.ts +0 -12
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.d.ts +0 -31
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -64
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/index.d.ts +0 -3
- package/dist/uxf/UxfFormulaParser/index.js +0 -11
- package/dist/uxf/UxfFormulaParser/index.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/parser.d.ts +0 -8
- package/dist/uxf/UxfFormulaParser/parser.js +0 -87
- package/dist/uxf/UxfFormulaParser/parser.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.d.ts +0 -8
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js +0 -17
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js.map +0 -1
- package/dist/uxf/constants.d.ts +0 -2
- package/dist/uxf/constants.js +0 -8
- package/dist/uxf/constants.js.map +0 -1
- package/dist/uxf/index.d.ts +0 -2
- package/dist/uxf/index.js +0 -11
- package/dist/uxf/index.js.map +0 -1
- package/dist/uxf/tectonicIdGenerator.d.ts +0 -12
- package/dist/uxf/tectonicIdGenerator.js +0 -79
- package/dist/uxf/tectonicIdGenerator.js.map +0 -1
- package/src/AttachmentPlugin.ts +0 -268
- package/src/BusinessRulePlugin.ts +0 -238
- package/src/CrossScopePrivilegePlugin.ts +0 -115
- package/src/DefaultPlugin.ts +0 -288
- package/src/HtmlTemplatePlugin.ts +0 -31
- package/src/IdPlugin.ts +0 -74
- package/src/IncludePlugin.ts +0 -206
- package/src/JsonPlugin.ts +0 -76
- package/src/ListPlugin.ts +0 -570
- package/src/NowConfigPlugin.ts +0 -69
- package/src/PackageJsonPlugin.ts +0 -68
- package/src/PropertyPlugin.ts +0 -237
- package/src/ScriptTemplatePlugin.ts +0 -53
- package/src/ServerModulePlugin.ts +0 -480
- package/src/UserPreferencePlugin.ts +0 -45
- package/src/aclAndRole/AclPlugin.ts +0 -420
- package/src/aclAndRole/RolePlugin.ts +0 -254
- package/src/aclAndRole/Util.ts +0 -113
- package/src/app/ApplicationMenuPlugin.ts +0 -165
- package/src/db/ColumnPlugins.ts +0 -114
- package/src/db/DBUtils.ts +0 -36
- package/src/db/DocumentationPlugin.ts +0 -316
- package/src/db/LicensingPlugin.ts +0 -138
- package/src/db/RecordPlugin.ts +0 -459
- package/src/db/TablePlugin.ts +0 -2070
- package/src/db/index.ts +0 -6
- package/src/scriptedRESTAPI/RESTDeserializationUtils.ts +0 -419
- package/src/scriptedRESTAPI/RESTSerializationUtils.ts +0 -228
- package/src/scriptedRESTAPI/RestApiPlugin.ts +0 -469
- package/src/scriptedRESTAPI/RestSchemaUtils.ts +0 -72
- package/src/scriptedRESTAPI/RestUtils.ts +0 -569
- package/src/scripts/ClientScriptPlugin.ts +0 -257
- package/src/scripts/scriptUtils.ts +0 -5
- package/src/uxf/ExperiencePlugin.ts +0 -67
- package/src/uxf/RoutesPlugin.ts +0 -211
- package/src/uxf/UxfFormulaParser/cleanUxValue.ts +0 -73
- package/src/uxf/UxfFormulaParser/grammerParser/api.js +0 -166
- package/src/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -606
- package/src/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
- package/src/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -65
- package/src/uxf/UxfFormulaParser/index.ts +0 -4
- package/src/uxf/UxfFormulaParser/parser.ts +0 -64
- package/src/uxf/UxfFormulaParser/utils/getErrorMsg.ts +0 -13
- package/src/uxf/constants.ts +0 -4
- package/src/uxf/index.ts +0 -2
- package/src/uxf/tectonicIdGenerator.ts +0 -78
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Plugin } from '@servicenow/sdk-build-core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a User Preference (sys_user_preference).
|
|
4
|
+
*
|
|
5
|
+
* @see https://docs.servicenow.com/csh?topicname=c_UserPreferences.html&version=latest
|
|
6
|
+
*
|
|
7
|
+
* @param config - an object containing the following properties:
|
|
8
|
+
* * **$id** - unique id for the record, typically using `Now.ID["value"]`
|
|
9
|
+
* * **name** - name of the feature or functionality
|
|
10
|
+
* * **type** - the data type of entry accepted for the `value`
|
|
11
|
+
* * **value** - current setting for this record
|
|
12
|
+
* * **description**? - short description of the feature or functionality
|
|
13
|
+
* * **system**? - whether this record indicates the system-wide default
|
|
14
|
+
*/
|
|
15
|
+
export declare const UserPreferencePlugin: Plugin;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserPreferencePlugin = void 0;
|
|
4
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
5
|
+
const now_id_plugin_1 = require("./now-id-plugin");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a User Preference (sys_user_preference).
|
|
8
|
+
*
|
|
9
|
+
* @see https://docs.servicenow.com/csh?topicname=c_UserPreferences.html&version=latest
|
|
10
|
+
*
|
|
11
|
+
* @param config - an object containing the following properties:
|
|
12
|
+
* * **$id** - unique id for the record, typically using `Now.ID["value"]`
|
|
13
|
+
* * **name** - name of the feature or functionality
|
|
14
|
+
* * **type** - the data type of entry accepted for the `value`
|
|
15
|
+
* * **value** - current setting for this record
|
|
16
|
+
* * **description**? - short description of the feature or functionality
|
|
17
|
+
* * **system**? - whether this record indicates the system-wide default
|
|
18
|
+
*/
|
|
19
|
+
exports.UserPreferencePlugin = sdk_build_core_1.Plugin.create({
|
|
20
|
+
name: 'UserPreferencePlugin',
|
|
21
|
+
records: {
|
|
22
|
+
sys_user_preference: {
|
|
23
|
+
toShape(record) {
|
|
24
|
+
return {
|
|
25
|
+
success: true,
|
|
26
|
+
value: new sdk_build_core_1.CallExpressionShape({
|
|
27
|
+
source: record,
|
|
28
|
+
callee: 'UserPreference',
|
|
29
|
+
args: [
|
|
30
|
+
record.transform(({ $, merge }) => ({
|
|
31
|
+
$id: $.val(now_id_plugin_1.NowIdShape.from(record)),
|
|
32
|
+
system: $.from('system').toBoolean(),
|
|
33
|
+
[merge]: $,
|
|
34
|
+
})),
|
|
35
|
+
],
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
shapes: [
|
|
42
|
+
{
|
|
43
|
+
shape: sdk_build_core_1.CallExpressionShape,
|
|
44
|
+
fileTypes: ['fluent'],
|
|
45
|
+
toRecord(callExpression, { factory }) {
|
|
46
|
+
if (callExpression.getCallee() !== 'UserPreference') {
|
|
47
|
+
return { success: false };
|
|
48
|
+
}
|
|
49
|
+
const pref = callExpression.getArgument(0).asObject();
|
|
50
|
+
return {
|
|
51
|
+
success: true,
|
|
52
|
+
value: factory.createRecord({
|
|
53
|
+
source: callExpression,
|
|
54
|
+
table: 'sys_user_preference',
|
|
55
|
+
explicitId: pref.get('$id'),
|
|
56
|
+
properties: pref.pick(['name', 'type', 'value', 'description', 'system']),
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=user-preference-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-preference-plugin.js","sourceRoot":"","sources":["../src/user-preference-plugin.ts"],"names":[],"mappings":";;;AAAA,+DAAwE;AACxE,mDAA4C;AAE5C;;;;;;;;;;;;GAYG;AACU,QAAA,oBAAoB,GAAG,uBAAM,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE;QACL,mBAAmB,EAAE;YACjB,OAAO,CAAC,MAAM;gBACV,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,IAAI,oCAAmB,CAAC;wBAC3B,MAAM,EAAE,MAAM;wBACd,MAAM,EAAE,gBAAgB;wBACxB,IAAI,EAAE;4BACF,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;gCAChC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,0BAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gCACnC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE;gCACpC,CAAC,KAAK,CAAC,EAAE,CAAC;6BACb,CAAC,CAAC;yBACN;qBACJ,CAAC;iBACL,CAAA;YACL,CAAC;SACJ;KACJ;IACD,MAAM,EAAE;QACJ;YACI,KAAK,EAAE,oCAAmB;YAC1B,SAAS,EAAE,CAAC,QAAQ,CAAC;YACrB,QAAQ,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE;gBAChC,IAAI,cAAc,CAAC,SAAS,EAAE,KAAK,gBAAgB,EAAE,CAAC;oBAClD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;gBAC7B,CAAC;gBAED,MAAM,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;gBAErD,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC;wBACxB,MAAM,EAAE,cAAc;wBACtB,KAAK,EAAE,qBAAqB;wBAC5B,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;wBAC3B,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;qBAC5E,CAAC;iBACL,CAAA;YACL,CAAC;SACJ;KACJ;CACJ,CAAC,CAAA"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ts, type Shape, type ObjectShape, type Diagnostics } from '@servicenow/sdk-build-core';
|
|
2
|
+
export declare function toReference(shape: Shape): string | import("@servicenow/sdk-build-core").RecordId;
|
|
3
|
+
/**
|
|
4
|
+
* Reverses an object, swapping keys and values. **reverseObject** should only be used
|
|
5
|
+
* where the key/values are all known ahead of time and the values are unique.
|
|
6
|
+
* @example
|
|
7
|
+
* reverseObject({ a: 'foo', b: 'bar' }) // { foo: 'a', bar: 'b' }
|
|
8
|
+
*/
|
|
9
|
+
export declare function reverseObject<K extends string, V extends string>(obj: Record<K, V>): Record<V, K>;
|
|
10
|
+
export declare function noThrow<T>(action: () => T): T | Error;
|
|
11
|
+
/**
|
|
12
|
+
* Regex taken from: https://github.com/oozcitak/xmlbuilder-js/blob/b20136cd1591d0f17ab2f184053c7150150428b2/src/XMLStringifier.coffee#L119C15-L119C127
|
|
13
|
+
*/
|
|
14
|
+
export declare const INVALID_XML_CHARACTERS: RegExp;
|
|
15
|
+
export declare function applyPathMappings(path: string, mappings: Record<string, string>): string;
|
|
16
|
+
export declare function getCallExpressionName(node: ts.CallExpression): string;
|
|
17
|
+
export declare function generateDeprecatedDiagnostics(object: ObjectShape, diagnostics: Diagnostics): void;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INVALID_XML_CHARACTERS = void 0;
|
|
4
|
+
exports.toReference = toReference;
|
|
5
|
+
exports.reverseObject = reverseObject;
|
|
6
|
+
exports.noThrow = noThrow;
|
|
7
|
+
exports.applyPathMappings = applyPathMappings;
|
|
8
|
+
exports.getCallExpressionName = getCallExpressionName;
|
|
9
|
+
exports.generateDeprecatedDiagnostics = generateDeprecatedDiagnostics;
|
|
10
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
11
|
+
function toReference(shape) {
|
|
12
|
+
return shape.ifRecord()?.getId() ?? shape.ifString()?.getValue() ?? '';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Reverses an object, swapping keys and values. **reverseObject** should only be used
|
|
16
|
+
* where the key/values are all known ahead of time and the values are unique.
|
|
17
|
+
* @example
|
|
18
|
+
* reverseObject({ a: 'foo', b: 'bar' }) // { foo: 'a', bar: 'b' }
|
|
19
|
+
*/
|
|
20
|
+
function reverseObject(obj) {
|
|
21
|
+
const reversed = {};
|
|
22
|
+
for (const key in obj) {
|
|
23
|
+
const value = obj[key];
|
|
24
|
+
if (typeof value === 'string') {
|
|
25
|
+
reversed[value] = key;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return reversed;
|
|
29
|
+
}
|
|
30
|
+
function noThrow(action) {
|
|
31
|
+
try {
|
|
32
|
+
return action();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Regex taken from: https://github.com/oozcitak/xmlbuilder-js/blob/b20136cd1591d0f17ab2f184053c7150150428b2/src/XMLStringifier.coffee#L119C15-L119C127
|
|
40
|
+
*/
|
|
41
|
+
exports.INVALID_XML_CHARACTERS =
|
|
42
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: This is intentional
|
|
43
|
+
/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
|
|
44
|
+
function applyPathMappings(path, mappings) {
|
|
45
|
+
if (!mappings) {
|
|
46
|
+
return path;
|
|
47
|
+
}
|
|
48
|
+
// TODO: Naive implementation for now that just supports simple patterns. We can explore supporting more complex patterns later.
|
|
49
|
+
for (const [source, target] of Object.entries(mappings)) {
|
|
50
|
+
const match = path.match(`${source.replace(/\./, '\\.').replace(/\*+/, '(.*)')}$`)?.[1];
|
|
51
|
+
if (match !== undefined) {
|
|
52
|
+
return target.replace(/\*+/, match);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return path;
|
|
56
|
+
}
|
|
57
|
+
function getCallExpressionName(node) {
|
|
58
|
+
const expression = node.getExpression();
|
|
59
|
+
if (sdk_build_core_1.ts.Node.isIdentifier(expression) || sdk_build_core_1.ts.Node.isPropertyAccessExpression(expression)) {
|
|
60
|
+
return expression.getText();
|
|
61
|
+
}
|
|
62
|
+
throw `CallExpression does not have a name: ${expression.getText()}`;
|
|
63
|
+
}
|
|
64
|
+
function generateDeprecatedDiagnostics(object, diagnostics) {
|
|
65
|
+
Object.keys(object.getAliasedKeys()).forEach((key) => {
|
|
66
|
+
const alias = object.findAliasUsed(key);
|
|
67
|
+
if (alias) {
|
|
68
|
+
diagnostics.hint(object.get(key), `The property '${alias}' is deprecated, use '${key}' instead.`);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA,kCAEC;AAQD,sCASC;AAED,0BAMC;AASD,8CAYC;AAED,sDAOC;AAED,sEAOC;AApED,+DAA+F;AAE/F,SAAgB,WAAW,CAAC,KAAY;IACpC,OAAO,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;AAC1E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAqC,GAAiB;IAC/E,MAAM,QAAQ,GAAG,EAAkB,CAAA;IACnC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;QACtB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,CAAA;QACzB,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAA;AACnB,CAAC;AAED,SAAgB,OAAO,CAAI,MAAe;IACtC,IAAI,CAAC;QACD,OAAO,MAAM,EAAE,CAAA;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,KAAc,CAAA;IACzB,CAAC;AACL,CAAC;AAED;;GAEG;AACU,QAAA,sBAAsB;AAC/B,+EAA+E;AAC/E,gHAAgH,CAAA;AAEpH,SAAgB,iBAAiB,CAAC,IAAY,EAAE,QAAgC;IAC5E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,IAAI,CAAA;IACf,CAAC;IACD,gIAAgI;IAChI,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACvF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QACvC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAA;AACf,CAAC;AAED,SAAgB,qBAAqB,CAAC,IAAuB;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;IACvC,IAAI,mBAAE,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,mBAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC,EAAE,CAAC;QACrF,OAAO,UAAU,CAAC,OAAO,EAAE,CAAA;IAC/B,CAAC;IAED,MAAM,wCAAwC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAA;AACxE,CAAC;AAED,SAAgB,6BAA6B,CAAC,MAAmB,EAAE,WAAwB;IACvF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;QACvC,IAAI,KAAK,EAAE,CAAC;YACR,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,iBAAiB,KAAK,yBAAyB,GAAG,YAAY,CAAC,CAAA;QACrG,CAAC;IACL,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViewPlugin = void 0;
|
|
4
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
5
|
+
exports.ViewPlugin = sdk_build_core_1.Plugin.create({
|
|
6
|
+
name: 'ViewPlugin',
|
|
7
|
+
records: {
|
|
8
|
+
sys_ui_view: {
|
|
9
|
+
coalesce: ['name'],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
shapes: [
|
|
13
|
+
{
|
|
14
|
+
shape: sdk_build_core_1.Record,
|
|
15
|
+
inspect(record, { diagnostics }) {
|
|
16
|
+
if (record.getTable() !== 'sys_ui_view') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (record.get('title').equals('Default view')) {
|
|
20
|
+
// The default view's name will be empty, so skip the validation
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const viewName = record.get('name');
|
|
24
|
+
if (!viewName.isString() || !/^[a-zA-Z0-9_]+$/.test(viewName.getValue())) {
|
|
25
|
+
diagnostics.error(viewName.getOriginalNode(), `View name can only contain alphanumeric characters`);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
shape: sdk_build_core_1.RecordId,
|
|
31
|
+
async commit(id, target, { commit }) {
|
|
32
|
+
if (id.getTable() !== 'sys_ui_view') {
|
|
33
|
+
return { success: false };
|
|
34
|
+
}
|
|
35
|
+
const viewName = id.getKey('name');
|
|
36
|
+
if (!viewName) {
|
|
37
|
+
return { success: false };
|
|
38
|
+
}
|
|
39
|
+
await commit(sdk_build_core_1.Shape.from(id, viewName).asString(), target);
|
|
40
|
+
return { success: true };
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=view-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-plugin.js","sourceRoot":"","sources":["../src/view-plugin.ts"],"names":[],"mappings":";;;AAAA,+DAA4E;AAE/D,QAAA,UAAU,GAAG,uBAAM,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE;QACL,WAAW,EAAE;YACT,QAAQ,EAAE,CAAC,MAAM,CAAC;SACrB;KACJ;IACD,MAAM,EAAE;QACJ;YACI,KAAK,EAAE,uBAAM;YACb,OAAO,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE;gBAC3B,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,aAAa,EAAE,CAAC;oBACtC,OAAM;gBACV,CAAC;gBAED,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;oBAC7C,gEAAgE;oBAChE,OAAM;gBACV,CAAC;gBAED,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;gBACnC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;oBACvE,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,EAAE,oDAAoD,CAAC,CAAA;gBACvG,CAAC;YACL,CAAC;SACJ;QACD;YACI,KAAK,EAAE,yBAAQ;YACf,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE;gBAC/B,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,aAAa,EAAE,CAAC;oBAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;gBAC7B,CAAC;gBAED,MAAM,QAAQ,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;gBAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;gBAC7B,CAAC;gBAED,MAAM,MAAM,CAAC,sBAAK,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAA;gBACzD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;YAC5B,CAAC;SACJ;KACJ;CACJ,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicenow/sdk-build-plugins",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "ServiceNow SDK Build System Plugins",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,41 +8,45 @@
|
|
|
8
8
|
"dist",
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./dist/index.js"
|
|
13
|
+
},
|
|
11
14
|
"dependencies": {
|
|
15
|
+
"@cyclonedx/cyclonedx-library": "7.1.0",
|
|
12
16
|
"@servicenow/glide": "26.0.1",
|
|
13
17
|
"eslint": "8.50.0",
|
|
14
18
|
"eslint-formatter-stylish": "8.40.0",
|
|
15
19
|
"eslint-plugin-es-x": "7.2.0",
|
|
20
|
+
"fast-xml-parser": "4.4.1",
|
|
16
21
|
"globals": "13.23.0",
|
|
17
22
|
"lodash": "4.17.21",
|
|
23
|
+
"md5.js": "1.3.5",
|
|
24
|
+
"mime-types": "2.1.35",
|
|
18
25
|
"moo": "0.5.2",
|
|
19
26
|
"nearley": "2.20.1",
|
|
27
|
+
"packageurl-js": "2.0.1",
|
|
20
28
|
"xmlbuilder2": "3.1.1",
|
|
21
29
|
"zod": "3.22.4",
|
|
22
|
-
"
|
|
23
|
-
"@servicenow/
|
|
24
|
-
"@servicenow/sdk-
|
|
25
|
-
"@servicenow/sdk-
|
|
26
|
-
"@servicenow/sdk-project": "3.0.2",
|
|
27
|
-
"@servicenow/sdk-repack": "3.0.2"
|
|
30
|
+
"@servicenow/sdk-build-core": "4.0.0",
|
|
31
|
+
"@servicenow/sdk-repack": "4.0.0",
|
|
32
|
+
"@servicenow/eslint-plugin-sdk-app-plugin": "4.0.0",
|
|
33
|
+
"@servicenow/sdk-core": "4.0.0"
|
|
28
34
|
},
|
|
29
35
|
"overrides": {
|
|
30
36
|
"micromatch": "4.0.7"
|
|
31
37
|
},
|
|
32
38
|
"devDependencies": {
|
|
33
39
|
"@types/eslint": "8.56.0",
|
|
34
|
-
"@types/lodash": "4.14.195"
|
|
40
|
+
"@types/lodash": "4.14.195",
|
|
41
|
+
"@types/mime-types": "2.1.4"
|
|
35
42
|
},
|
|
36
43
|
"engines": {
|
|
37
|
-
"node": ">=18.
|
|
38
|
-
"pnpm": ">=
|
|
44
|
+
"node": ">=20.18.0",
|
|
45
|
+
"pnpm": ">=10.8.0"
|
|
39
46
|
},
|
|
40
47
|
"scripts": {
|
|
41
48
|
"build": "tsc -b",
|
|
42
49
|
"clean": "tsc -b --clean",
|
|
43
|
-
"lint": "eslint . --ext .ts",
|
|
44
|
-
"prettier:check": "prettier --check --ignore-path=../../.prettierignore .",
|
|
45
|
-
"prettier:write": "prettier --write --ignore-path=../../.prettierignore .",
|
|
46
50
|
"watch": "tsc -b -w"
|
|
47
51
|
}
|
|
48
52
|
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { CallExpressionShape, isGUID, Plugin } from '@servicenow/sdk-build-core'
|
|
2
|
+
import { AclTypes, AclOperations, AclAttributes, AclNamedTypes } from '@servicenow/sdk-core/runtime/app'
|
|
3
|
+
import { ModuleFunctionShape } from './server-module-plugin'
|
|
4
|
+
import { NowIdShape } from './now-id-plugin'
|
|
5
|
+
import { generateDeprecatedDiagnostics } from './utils'
|
|
6
|
+
|
|
7
|
+
const ExecuteOnlyTypes = new Set([
|
|
8
|
+
'client_callable_flow_object',
|
|
9
|
+
'client_callable_script_include',
|
|
10
|
+
'graphql',
|
|
11
|
+
'processor',
|
|
12
|
+
'rest_endpoint',
|
|
13
|
+
])
|
|
14
|
+
|
|
15
|
+
const aclAliases = {
|
|
16
|
+
adminOverrides: ['admin_overrides'],
|
|
17
|
+
decisionType: ['decision_type'],
|
|
18
|
+
localOrExisting: ['local_or_existing'],
|
|
19
|
+
securityAttribute: ['security_attribute'],
|
|
20
|
+
appliesTo: ['applies_to'],
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param config - an object containing the following properties:
|
|
25
|
+
* * **$id** - unique id for the record, typically using `Now.ID["value"]`
|
|
26
|
+
* * **operation** - the operation this ACL rule secure
|
|
27
|
+
* * **active**? - whether the ACL is enabled
|
|
28
|
+
* * **adminOverrides**? - indicates whether users with the admin role automatically pass the permissions check for this ACL rule
|
|
29
|
+
* * **condition**? - a filter query that specifies the fields and values that must be true for users to access the object
|
|
30
|
+
* * **decisionType**? - whether the ACL should allow or deny access
|
|
31
|
+
* * **description**? - description of the object or permissions this ACL rule secures
|
|
32
|
+
* * **localOrExisting**? - if `"Local"`: A security attribute based on the
|
|
33
|
+
* condition property that is saved only for the ACL it is created in\
|
|
34
|
+
* if `"Exisiting"`: An existing security attribute to reference in the `security_attribute` property
|
|
35
|
+
* * **roles**? - `Role` objects or sys_ids of roles that a user must have to access the object
|
|
36
|
+
* * **script**? - a function or inline script preceded by a `script` tagged
|
|
37
|
+
* template literal. The script should define the permissions required to access the object
|
|
38
|
+
* * **securityAttribute**? - pre-defined conditions to use. For example, whether a user is impersonating another user
|
|
39
|
+
*/
|
|
40
|
+
export const AclPlugin = Plugin.create({
|
|
41
|
+
name: 'AclPlugin',
|
|
42
|
+
records: {
|
|
43
|
+
sys_security_acl: {
|
|
44
|
+
relationships: {
|
|
45
|
+
sys_security_acl_role: {
|
|
46
|
+
via: 'sys_security_acl',
|
|
47
|
+
descendant: true,
|
|
48
|
+
relationships: {
|
|
49
|
+
sys_user_role: {
|
|
50
|
+
via: 'sys_user_role',
|
|
51
|
+
inverse: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
toShape(record, { descendants }) {
|
|
57
|
+
const type = reverseLookup(AclTypes, record.get('type').getValue()) || record.get('type')
|
|
58
|
+
const roles = descendants.query('sys_security_acl_role').map((m2m) => m2m.get('sys_user_role'))
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
value: new CallExpressionShape({
|
|
63
|
+
source: record,
|
|
64
|
+
callee: 'Acl',
|
|
65
|
+
args: [
|
|
66
|
+
record
|
|
67
|
+
.transform(({ $, merge }) => ({
|
|
68
|
+
$id: $.val(NowIdShape.from(record)),
|
|
69
|
+
condition: $.def(''),
|
|
70
|
+
description: $.def(''),
|
|
71
|
+
localOrExisting: $.from('local_or_existing').def('Local'),
|
|
72
|
+
active: $.toBoolean().def(true),
|
|
73
|
+
decisionType: $.from('decision_type').def('allow'),
|
|
74
|
+
adminOverrides: $.from('admin_overrides').toBoolean().def(true),
|
|
75
|
+
appliesTo: $.from('applies_to').def(''),
|
|
76
|
+
type: $.val(type),
|
|
77
|
+
securityAttribute: $.from('security_attribute')
|
|
78
|
+
.map((v) => reverseLookup(AclAttributes, v.getValue()) || v)
|
|
79
|
+
.def(''),
|
|
80
|
+
operation: $.map((v) => reverseLookup(AclOperations, v.getValue()) || v),
|
|
81
|
+
script: $.map((v) => v.ifString()?.getValue()).def(''),
|
|
82
|
+
roles: $.val(roles.length > 0 ? roles : undefined),
|
|
83
|
+
[merge]: $.from('type', 'name').map((type, name) =>
|
|
84
|
+
getTableOrName(
|
|
85
|
+
type.pipe((t) => reverseLookup(AclTypes, t.getValue())),
|
|
86
|
+
name.asString().getValue()
|
|
87
|
+
)
|
|
88
|
+
),
|
|
89
|
+
}))
|
|
90
|
+
.withAliasedKeys(aclAliases),
|
|
91
|
+
],
|
|
92
|
+
}),
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
sys_security_acl_role: {
|
|
97
|
+
coalesce: ['sys_security_acl', 'sys_user_role'],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
shapes: [
|
|
101
|
+
{
|
|
102
|
+
shape: CallExpressionShape,
|
|
103
|
+
fileTypes: ['fluent'],
|
|
104
|
+
async toRecord(callExpression, { config, diagnostics, factory }) {
|
|
105
|
+
if (callExpression.getCallee() !== 'Acl') {
|
|
106
|
+
return { success: false }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const arg = callExpression.getArgument(0).asObject().withAliasedKeys(aclAliases)
|
|
110
|
+
generateDeprecatedDiagnostics(arg, diagnostics)
|
|
111
|
+
const operation = arg.get('operation')
|
|
112
|
+
const type = arg.get('type').asString()
|
|
113
|
+
if (!operation.equals('execute') && ExecuteOnlyTypes.has(type.getValue())) {
|
|
114
|
+
diagnostics.error(
|
|
115
|
+
operation,
|
|
116
|
+
`ACL must use operation 'execute', because it is of type '${type.getValue()}'`
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const script = arg.get('script')
|
|
121
|
+
const advanced = !script.isUndefined()
|
|
122
|
+
if (advanced && type.equals('graphql')) {
|
|
123
|
+
diagnostics.error(script, `ACL does not support scripts, because it is of type graphql`)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const appliesTo = arg.get('appliesTo').ifString()
|
|
127
|
+
if (appliesTo && !type.equals('record')) {
|
|
128
|
+
diagnostics.error(appliesTo, `ACL cannot set applies_to unless its type is 'record'`)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (operation.equals('add_to_list')) {
|
|
132
|
+
const condition = arg.get('condition').ifString()
|
|
133
|
+
if (advanced) {
|
|
134
|
+
diagnostics.error(script, `ACL cannot have a script due to its 'add_to_list' operation`)
|
|
135
|
+
} else if (condition) {
|
|
136
|
+
diagnostics.error(condition, `ACL cannot have a condition due to its 'add_to_list' operation`)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (arg.get('script').isUnresolved()) {
|
|
141
|
+
diagnostics.error(
|
|
142
|
+
arg.get('script').getOriginalNode(),
|
|
143
|
+
`Unable to resolve the script reference, ensure the imported module is within the ${config.serverModulesDir} directory.`
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const acl = factory.createRecord({
|
|
148
|
+
source: callExpression,
|
|
149
|
+
table: 'sys_security_acl',
|
|
150
|
+
explicitId: arg.get('$id'),
|
|
151
|
+
properties: arg.transform(({ $ }) => ({
|
|
152
|
+
active: $.def(true),
|
|
153
|
+
decision_type: $.from('decisionType').def('allow'),
|
|
154
|
+
description: $.def(''),
|
|
155
|
+
local_or_existing: $.from('localOrExisting').def('Local'),
|
|
156
|
+
admin_overrides: $.from('adminOverrides').def(true),
|
|
157
|
+
condition: $.def(''),
|
|
158
|
+
applies_to: $.from('appliesTo').def(''),
|
|
159
|
+
name: $.from('name', 'table', 'field').map(
|
|
160
|
+
(n, t, f) => n.ifString() ?? (f.ifString() ? `${t.getValue()}.${f.getValue()}` : t)
|
|
161
|
+
),
|
|
162
|
+
type: $.map((type) => AclTypes[type.asString().getValue()] ?? type),
|
|
163
|
+
operation: $.map((op) => AclOperations[op.asString().getValue()] ?? op),
|
|
164
|
+
advanced: $.val(advanced),
|
|
165
|
+
script: $.map(
|
|
166
|
+
(v) =>
|
|
167
|
+
v.if(ModuleFunctionShape)?.toString((n) => `answer = ${n}({{PARAMS}})`, ['current']) ??
|
|
168
|
+
v
|
|
169
|
+
).toCdata(),
|
|
170
|
+
security_attribute: $.from('securityAttribute').map(
|
|
171
|
+
(v) => v.ifString()?.pipe((v) => AclAttributes[v.getValue()]) ?? v
|
|
172
|
+
),
|
|
173
|
+
})),
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
const roles = arg.get('roles').ifArray()?.getElements() ?? []
|
|
177
|
+
const securityAttribute = arg.get('securityAttribute')
|
|
178
|
+
const attributeRecord = securityAttribute.ifRecord()
|
|
179
|
+
if (roles.length < 1) {
|
|
180
|
+
if (!securityAttribute.getValue() && !advanced && !arg.get('condition').getValue()) {
|
|
181
|
+
diagnostics.warn(
|
|
182
|
+
callExpression,
|
|
183
|
+
'ACLs must have at least one of the following: roles, security_attribute, condition, or script'
|
|
184
|
+
)
|
|
185
|
+
} else if (attributeRecord) {
|
|
186
|
+
const localOrExisting = arg.get('localOrExisting').ifString()?.getValue()
|
|
187
|
+
if (
|
|
188
|
+
localOrExisting === 'Existing' &&
|
|
189
|
+
(attributeRecord.get('type').getValue() !== 'compound' ||
|
|
190
|
+
attributeRecord.get('is_localized').getValue())
|
|
191
|
+
) {
|
|
192
|
+
diagnostics.error(
|
|
193
|
+
arg,
|
|
194
|
+
`Invalid ACL with 'Existing' security_attribute: Must have a security_attribute with a type of 'compound' and is_localized set to false.`
|
|
195
|
+
)
|
|
196
|
+
} else if (
|
|
197
|
+
(!localOrExisting || localOrExisting === 'Local') &&
|
|
198
|
+
!attributeRecord.get('is_localized').ifBoolean()?.getValue()
|
|
199
|
+
) {
|
|
200
|
+
diagnostics.error(
|
|
201
|
+
arg,
|
|
202
|
+
`Invalid ACL with 'Local' security_attribute: security_attribute must have is_localized set to true`
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
success: true,
|
|
210
|
+
value: acl.with(
|
|
211
|
+
...roles.map((role) =>
|
|
212
|
+
factory.createRecord({
|
|
213
|
+
source: callExpression,
|
|
214
|
+
table: 'sys_security_acl_role',
|
|
215
|
+
properties: {
|
|
216
|
+
sys_security_acl: acl,
|
|
217
|
+
sys_user_role:
|
|
218
|
+
role.ifString()?.pipe((roleNameOrGuid) =>
|
|
219
|
+
isGUID(roleNameOrGuid.getValue())
|
|
220
|
+
? factory.createReference({
|
|
221
|
+
source: roleNameOrGuid,
|
|
222
|
+
table: 'sys_user_role',
|
|
223
|
+
guid: roleNameOrGuid.getValue(),
|
|
224
|
+
})
|
|
225
|
+
: factory.createReference({
|
|
226
|
+
source: roleNameOrGuid,
|
|
227
|
+
table: 'sys_user_role',
|
|
228
|
+
keys: { name: roleNameOrGuid },
|
|
229
|
+
})
|
|
230
|
+
) ?? role,
|
|
231
|
+
},
|
|
232
|
+
})
|
|
233
|
+
)
|
|
234
|
+
),
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
function getTableOrName(type: keyof typeof AclTypes, name: string) {
|
|
242
|
+
if (AclNamedTypes[type]) {
|
|
243
|
+
return { name }
|
|
244
|
+
}
|
|
245
|
+
const split = name.indexOf('.')
|
|
246
|
+
const table = split === -1 ? name : name.substring(0, split)
|
|
247
|
+
const field = split === -1 ? '' : name.substring(split + 1)
|
|
248
|
+
|
|
249
|
+
return { table, ...(field ? { field } : {}) }
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function reverseLookup<T extends object>(obj: T, sysId): keyof T {
|
|
253
|
+
return (Object.entries(obj)
|
|
254
|
+
.filter(([_, id]) => id === sysId)
|
|
255
|
+
.map(([key]) => key)[0] || '') as keyof T
|
|
256
|
+
}
|