@servicenow/sdk-build-plugins 3.0.3 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acl-plugin.d.ts +19 -0
- package/dist/acl-plugin.js +210 -0
- package/dist/acl-plugin.js.map +1 -0
- package/dist/application-menu-plugin.d.ts +18 -0
- package/dist/application-menu-plugin.js +104 -0
- package/dist/application-menu-plugin.js.map +1 -0
- package/dist/arrow-function-plugin.d.ts +16 -0
- package/dist/arrow-function-plugin.js +107 -0
- package/dist/arrow-function-plugin.js.map +1 -0
- package/dist/atf/step-configs.d.ts +37 -0
- package/dist/atf/step-configs.js +2236 -0
- package/dist/atf/step-configs.js.map +1 -0
- package/dist/atf/test-plugin.d.ts +4 -0
- package/dist/atf/test-plugin.js +591 -0
- package/dist/atf/test-plugin.js.map +1 -0
- package/dist/basic-syntax-plugin.d.ts +2 -0
- package/dist/basic-syntax-plugin.js +636 -0
- package/dist/basic-syntax-plugin.js.map +1 -0
- package/dist/business-rule-plugin.d.ts +3 -0
- package/dist/business-rule-plugin.js +205 -0
- package/dist/business-rule-plugin.js.map +1 -0
- package/dist/call-expression-plugin.d.ts +2 -0
- package/dist/call-expression-plugin.js +175 -0
- package/dist/call-expression-plugin.js.map +1 -0
- package/dist/client-script-plugin.d.ts +29 -0
- package/dist/client-script-plugin.js +157 -0
- package/dist/client-script-plugin.js.map +1 -0
- package/dist/column/column-helper.d.ts +12 -0
- package/dist/column/column-helper.js +84 -0
- package/dist/column/column-helper.js.map +1 -0
- package/dist/column/column-to-record.d.ts +3 -0
- package/dist/column/column-to-record.js +105 -0
- package/dist/column/column-to-record.js.map +1 -0
- package/dist/column-plugin.d.ts +8 -0
- package/dist/column-plugin.js +453 -0
- package/dist/column-plugin.js.map +1 -0
- package/dist/cross-scope-privilege-plugin.d.ts +15 -0
- package/dist/cross-scope-privilege-plugin.js +82 -0
- package/dist/cross-scope-privilege-plugin.js.map +1 -0
- package/dist/html-import-plugin.d.ts +2 -0
- package/dist/html-import-plugin.js +72 -0
- package/dist/html-import-plugin.js.map +1 -0
- package/dist/index.d.ts +37 -21
- package/dist/index.js +40 -45
- package/dist/index.js.map +1 -1
- package/dist/json-plugin.d.ts +15 -0
- package/dist/json-plugin.js +104 -0
- package/dist/json-plugin.js.map +1 -0
- package/dist/list-plugin.d.ts +2 -0
- package/dist/list-plugin.js +191 -0
- package/dist/list-plugin.js.map +1 -0
- package/dist/now-config-plugin.d.ts +4 -0
- package/dist/now-config-plugin.js +154 -0
- package/dist/now-config-plugin.js.map +1 -0
- package/dist/now-id-plugin.d.ts +11 -0
- package/dist/now-id-plugin.js +71 -0
- package/dist/now-id-plugin.js.map +1 -0
- package/dist/now-include-plugin.d.ts +16 -0
- package/dist/now-include-plugin.js +118 -0
- package/dist/now-include-plugin.js.map +1 -0
- package/dist/now-ref-plugin.d.ts +2 -0
- package/dist/now-ref-plugin.js +43 -0
- package/dist/now-ref-plugin.js.map +1 -0
- package/dist/now-unresolved-plugin.d.ts +2 -0
- package/dist/now-unresolved-plugin.js +32 -0
- package/dist/now-unresolved-plugin.js.map +1 -0
- package/dist/package-json-plugin.d.ts +2 -0
- package/dist/package-json-plugin.js +70 -0
- package/dist/package-json-plugin.js.map +1 -0
- package/dist/property-plugin.d.ts +2 -0
- package/dist/property-plugin.js +105 -0
- package/dist/property-plugin.js.map +1 -0
- package/dist/record-plugin.d.ts +43 -0
- package/dist/record-plugin.js +147 -0
- package/dist/record-plugin.js.map +1 -0
- package/dist/repack/index.d.ts +1 -0
- package/dist/repack/index.js +10 -2
- package/dist/repack/index.js.map +1 -1
- package/dist/repack/lint/Rules.d.ts +1 -1
- package/dist/repack/lint/Rules.js +7 -3
- package/dist/repack/lint/Rules.js.map +1 -1
- package/dist/repack/lint/index.js +1 -1
- package/dist/rest-api-plugin.d.ts +2 -0
- package/dist/rest-api-plugin.js +469 -0
- package/dist/rest-api-plugin.js.map +1 -0
- package/dist/role-plugin.d.ts +2 -0
- package/dist/role-plugin.js +117 -0
- package/dist/role-plugin.js.map +1 -0
- package/dist/script-action-plugin.d.ts +2 -0
- package/dist/script-action-plugin.js +62 -0
- package/dist/script-action-plugin.js.map +1 -0
- package/dist/script-include-plugin.d.ts +2 -0
- package/dist/script-include-plugin.js +102 -0
- package/dist/script-include-plugin.js.map +1 -0
- package/dist/server-module-plugin/index.d.ts +14 -0
- package/dist/server-module-plugin/index.js +378 -0
- package/dist/server-module-plugin/index.js.map +1 -0
- package/dist/server-module-plugin/sbom-builder.d.ts +45 -0
- package/dist/server-module-plugin/sbom-builder.js +179 -0
- package/dist/server-module-plugin/sbom-builder.js.map +1 -0
- package/dist/service-portal/angular-provider-plugin.d.ts +2 -0
- package/dist/service-portal/angular-provider-plugin.js +78 -0
- package/dist/service-portal/angular-provider-plugin.js.map +1 -0
- package/dist/service-portal/dependency-plugin.d.ts +2 -0
- package/dist/service-portal/dependency-plugin.js +235 -0
- package/dist/service-portal/dependency-plugin.js.map +1 -0
- package/dist/service-portal/widget-plugin.d.ts +6 -0
- package/dist/service-portal/widget-plugin.js +230 -0
- package/dist/service-portal/widget-plugin.js.map +1 -0
- package/dist/static-content-plugin.d.ts +2 -0
- package/dist/static-content-plugin.js +272 -0
- package/dist/static-content-plugin.js.map +1 -0
- package/dist/table-plugin.d.ts +3 -0
- package/dist/table-plugin.js +1324 -0
- package/dist/table-plugin.js.map +1 -0
- package/dist/ui-action-plugin.d.ts +2 -0
- package/dist/ui-action-plugin.js +291 -0
- package/dist/ui-action-plugin.js.map +1 -0
- package/dist/ui-page-plugin.d.ts +2 -0
- package/dist/ui-page-plugin.js +165 -0
- package/dist/ui-page-plugin.js.map +1 -0
- package/dist/user-preference-plugin.d.ts +15 -0
- package/dist/user-preference-plugin.js +63 -0
- package/dist/user-preference-plugin.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.js +72 -0
- package/dist/utils.js.map +1 -0
- package/dist/view-plugin.d.ts +2 -0
- package/dist/view-plugin.js +45 -0
- package/dist/view-plugin.js.map +1 -0
- package/package.json +17 -13
- package/src/acl-plugin.ts +256 -0
- package/src/application-menu-plugin.ts +109 -0
- package/src/arrow-function-plugin.ts +127 -0
- package/src/atf/step-configs.ts +2284 -0
- package/src/atf/test-plugin.ts +728 -0
- package/src/basic-syntax-plugin.ts +729 -0
- package/src/business-rule-plugin.ts +266 -0
- package/src/call-expression-plugin.ts +202 -0
- package/src/client-script-plugin.ts +170 -0
- package/src/column/column-helper.ts +119 -0
- package/src/column/column-to-record.ts +131 -0
- package/src/column-plugin.ts +506 -0
- package/src/cross-scope-privilege-plugin.ts +82 -0
- package/src/html-import-plugin.ts +79 -0
- package/src/index.ts +39 -21
- package/src/json-plugin.ts +128 -0
- package/src/list-plugin.ts +222 -0
- package/src/now-config-plugin.ts +194 -0
- package/src/now-id-plugin.ts +78 -0
- package/src/now-include-plugin.ts +140 -0
- package/src/now-ref-plugin.ts +48 -0
- package/src/now-unresolved-plugin.ts +30 -0
- package/src/package-json-plugin.ts +87 -0
- package/src/property-plugin.ts +118 -0
- package/src/record-plugin.ts +171 -0
- package/src/repack/index.ts +10 -1
- package/src/repack/lint/Rules.ts +5 -4
- package/src/repack/lint/index.ts +1 -1
- package/src/rest-api-plugin.ts +651 -0
- package/src/role-plugin.ts +128 -0
- package/src/script-action-plugin.ts +63 -0
- package/src/script-include-plugin.ts +110 -0
- package/src/server-module-plugin/index.ts +470 -0
- package/src/server-module-plugin/sbom-builder.ts +183 -0
- package/src/service-portal/angular-provider-plugin.ts +83 -0
- package/src/service-portal/dependency-plugin.ts +284 -0
- package/src/service-portal/widget-plugin.ts +263 -0
- package/src/static-content-plugin.ts +254 -0
- package/src/table-plugin.ts +1698 -0
- package/src/ui-action-plugin.ts +324 -0
- package/src/ui-page-plugin.ts +168 -0
- package/src/user-preference-plugin.ts +62 -0
- package/src/utils.ts +69 -0
- package/src/view-plugin.ts +46 -0
- package/dist/AttachmentPlugin.d.ts +0 -254
- package/dist/AttachmentPlugin.js +0 -220
- package/dist/AttachmentPlugin.js.map +0 -1
- package/dist/BusinessRulePlugin.d.ts +0 -30
- package/dist/BusinessRulePlugin.js +0 -149
- package/dist/BusinessRulePlugin.js.map +0 -1
- package/dist/CrossScopePrivilegePlugin.d.ts +0 -35
- package/dist/CrossScopePrivilegePlugin.js +0 -80
- package/dist/CrossScopePrivilegePlugin.js.map +0 -1
- package/dist/DefaultPlugin.d.ts +0 -86
- package/dist/DefaultPlugin.js +0 -226
- package/dist/DefaultPlugin.js.map +0 -1
- package/dist/HtmlTemplatePlugin.d.ts +0 -21
- package/dist/HtmlTemplatePlugin.js +0 -29
- package/dist/HtmlTemplatePlugin.js.map +0 -1
- package/dist/IdPlugin.d.ts +0 -28
- package/dist/IdPlugin.js +0 -68
- package/dist/IdPlugin.js.map +0 -1
- package/dist/IncludePlugin.d.ts +0 -34
- package/dist/IncludePlugin.js +0 -155
- package/dist/IncludePlugin.js.map +0 -1
- package/dist/JsonPlugin.d.ts +0 -28
- package/dist/JsonPlugin.js +0 -69
- package/dist/JsonPlugin.js.map +0 -1
- package/dist/ListPlugin.d.ts +0 -93
- package/dist/ListPlugin.js +0 -456
- package/dist/ListPlugin.js.map +0 -1
- package/dist/NowConfigPlugin.d.ts +0 -45
- package/dist/NowConfigPlugin.js +0 -64
- package/dist/NowConfigPlugin.js.map +0 -1
- package/dist/PackageJsonPlugin.d.ts +0 -34
- package/dist/PackageJsonPlugin.js +0 -63
- package/dist/PackageJsonPlugin.js.map +0 -1
- package/dist/PropertyPlugin.d.ts +0 -51
- package/dist/PropertyPlugin.js +0 -181
- package/dist/PropertyPlugin.js.map +0 -1
- package/dist/ScriptTemplatePlugin.d.ts +0 -13
- package/dist/ScriptTemplatePlugin.js +0 -55
- package/dist/ScriptTemplatePlugin.js.map +0 -1
- package/dist/ServerModulePlugin.d.ts +0 -75
- package/dist/ServerModulePlugin.js +0 -368
- package/dist/ServerModulePlugin.js.map +0 -1
- package/dist/UserPreferencePlugin.d.ts +0 -19
- package/dist/UserPreferencePlugin.js +0 -32
- package/dist/UserPreferencePlugin.js.map +0 -1
- package/dist/aclAndRole/AclPlugin.d.ts +0 -82
- package/dist/aclAndRole/AclPlugin.js +0 -262
- package/dist/aclAndRole/AclPlugin.js.map +0 -1
- package/dist/aclAndRole/RolePlugin.d.ts +0 -66
- package/dist/aclAndRole/RolePlugin.js +0 -179
- package/dist/aclAndRole/RolePlugin.js.map +0 -1
- package/dist/aclAndRole/Util.d.ts +0 -3
- package/dist/aclAndRole/Util.js +0 -90
- package/dist/aclAndRole/Util.js.map +0 -1
- package/dist/app/ApplicationMenuPlugin.d.ts +0 -34
- package/dist/app/ApplicationMenuPlugin.js +0 -112
- package/dist/app/ApplicationMenuPlugin.js.map +0 -1
- package/dist/db/ColumnPlugins.d.ts +0 -750
- package/dist/db/ColumnPlugins.js +0 -114
- package/dist/db/ColumnPlugins.js.map +0 -1
- package/dist/db/DBUtils.d.ts +0 -2
- package/dist/db/DBUtils.js +0 -27
- package/dist/db/DBUtils.js.map +0 -1
- package/dist/db/DocumentationPlugin.d.ts +0 -67
- package/dist/db/DocumentationPlugin.js +0 -258
- package/dist/db/DocumentationPlugin.js.map +0 -1
- package/dist/db/LicensingPlugin.d.ts +0 -60
- package/dist/db/LicensingPlugin.js +0 -117
- package/dist/db/LicensingPlugin.js.map +0 -1
- package/dist/db/RecordPlugin.d.ts +0 -133
- package/dist/db/RecordPlugin.js +0 -337
- package/dist/db/RecordPlugin.js.map +0 -1
- package/dist/db/TablePlugin.d.ts +0 -231
- package/dist/db/TablePlugin.js +0 -1630
- package/dist/db/TablePlugin.js.map +0 -1
- package/dist/db/index.d.ts +0 -6
- package/dist/db/index.js +0 -32
- package/dist/db/index.js.map +0 -1
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.d.ts +0 -10
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js +0 -373
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RESTSerializationUtils.d.ts +0 -13
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js +0 -177
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RestApiPlugin.d.ts +0 -81
- package/dist/scriptedRESTAPI/RestApiPlugin.js +0 -345
- package/dist/scriptedRESTAPI/RestApiPlugin.js.map +0 -1
- package/dist/scriptedRESTAPI/RestSchemaUtils.d.ts +0 -190
- package/dist/scriptedRESTAPI/RestSchemaUtils.js +0 -53
- package/dist/scriptedRESTAPI/RestSchemaUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RestUtils.d.ts +0 -69
- package/dist/scriptedRESTAPI/RestUtils.js +0 -497
- package/dist/scriptedRESTAPI/RestUtils.js.map +0 -1
- package/dist/scripts/ClientScriptPlugin.d.ts +0 -64
- package/dist/scripts/ClientScriptPlugin.js +0 -170
- package/dist/scripts/ClientScriptPlugin.js.map +0 -1
- package/dist/scripts/scriptUtils.d.ts +0 -1
- package/dist/scripts/scriptUtils.js +0 -9
- package/dist/scripts/scriptUtils.js.map +0 -1
- package/dist/uxf/ExperiencePlugin.d.ts +0 -45
- package/dist/uxf/ExperiencePlugin.js +0 -61
- package/dist/uxf/ExperiencePlugin.js.map +0 -1
- package/dist/uxf/RoutesPlugin.d.ts +0 -29
- package/dist/uxf/RoutesPlugin.js +0 -181
- package/dist/uxf/RoutesPlugin.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/cleanUxValue.d.ts +0 -4
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js +0 -65
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/api.d.ts +0 -189
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js +0 -158
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.d.ts +0 -13
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -604
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.d.ts +0 -12
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.d.ts +0 -31
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -64
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/index.d.ts +0 -3
- package/dist/uxf/UxfFormulaParser/index.js +0 -11
- package/dist/uxf/UxfFormulaParser/index.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/parser.d.ts +0 -8
- package/dist/uxf/UxfFormulaParser/parser.js +0 -87
- package/dist/uxf/UxfFormulaParser/parser.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.d.ts +0 -8
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js +0 -17
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js.map +0 -1
- package/dist/uxf/constants.d.ts +0 -2
- package/dist/uxf/constants.js +0 -8
- package/dist/uxf/constants.js.map +0 -1
- package/dist/uxf/index.d.ts +0 -2
- package/dist/uxf/index.js +0 -11
- package/dist/uxf/index.js.map +0 -1
- package/dist/uxf/tectonicIdGenerator.d.ts +0 -12
- package/dist/uxf/tectonicIdGenerator.js +0 -79
- package/dist/uxf/tectonicIdGenerator.js.map +0 -1
- package/src/AttachmentPlugin.ts +0 -268
- package/src/BusinessRulePlugin.ts +0 -238
- package/src/CrossScopePrivilegePlugin.ts +0 -115
- package/src/DefaultPlugin.ts +0 -288
- package/src/HtmlTemplatePlugin.ts +0 -31
- package/src/IdPlugin.ts +0 -74
- package/src/IncludePlugin.ts +0 -206
- package/src/JsonPlugin.ts +0 -76
- package/src/ListPlugin.ts +0 -570
- package/src/NowConfigPlugin.ts +0 -69
- package/src/PackageJsonPlugin.ts +0 -68
- package/src/PropertyPlugin.ts +0 -237
- package/src/ScriptTemplatePlugin.ts +0 -53
- package/src/ServerModulePlugin.ts +0 -480
- package/src/UserPreferencePlugin.ts +0 -45
- package/src/aclAndRole/AclPlugin.ts +0 -420
- package/src/aclAndRole/RolePlugin.ts +0 -254
- package/src/aclAndRole/Util.ts +0 -113
- package/src/app/ApplicationMenuPlugin.ts +0 -165
- package/src/db/ColumnPlugins.ts +0 -114
- package/src/db/DBUtils.ts +0 -36
- package/src/db/DocumentationPlugin.ts +0 -316
- package/src/db/LicensingPlugin.ts +0 -138
- package/src/db/RecordPlugin.ts +0 -459
- package/src/db/TablePlugin.ts +0 -2072
- package/src/db/index.ts +0 -6
- package/src/scriptedRESTAPI/RESTDeserializationUtils.ts +0 -419
- package/src/scriptedRESTAPI/RESTSerializationUtils.ts +0 -228
- package/src/scriptedRESTAPI/RestApiPlugin.ts +0 -469
- package/src/scriptedRESTAPI/RestSchemaUtils.ts +0 -72
- package/src/scriptedRESTAPI/RestUtils.ts +0 -569
- package/src/scripts/ClientScriptPlugin.ts +0 -257
- package/src/scripts/scriptUtils.ts +0 -5
- package/src/uxf/ExperiencePlugin.ts +0 -67
- package/src/uxf/RoutesPlugin.ts +0 -211
- package/src/uxf/UxfFormulaParser/cleanUxValue.ts +0 -73
- package/src/uxf/UxfFormulaParser/grammerParser/api.js +0 -166
- package/src/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -606
- package/src/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
- package/src/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -65
- package/src/uxf/UxfFormulaParser/index.ts +0 -4
- package/src/uxf/UxfFormulaParser/parser.ts +0 -64
- package/src/uxf/UxfFormulaParser/utils/getErrorMsg.ts +0 -13
- package/src/uxf/constants.ts +0 -4
- package/src/uxf/index.ts +0 -2
- package/src/uxf/tectonicIdGenerator.ts +0 -78
|
@@ -1,469 +0,0 @@
|
|
|
1
|
-
import { RestApi, RestApiConfig, RestApiSchema, Version } from '@servicenow/sdk-core/runtime/rest'
|
|
2
|
-
import { Record, RecordWithLegacyId } from '@servicenow/sdk-core/runtime/db'
|
|
3
|
-
import { additionalProperties } from '@servicenow/sdk-core/runtime/util'
|
|
4
|
-
import {
|
|
5
|
-
linkDocument,
|
|
6
|
-
Context,
|
|
7
|
-
Plugin,
|
|
8
|
-
Document,
|
|
9
|
-
extractCallExpression,
|
|
10
|
-
getCallExpressionName,
|
|
11
|
-
generateCallExpressionExportForDocument,
|
|
12
|
-
getOrCreateEntitySourceFile,
|
|
13
|
-
getSysUpdateName,
|
|
14
|
-
EntityData,
|
|
15
|
-
ObjectData,
|
|
16
|
-
Data,
|
|
17
|
-
FluentDiagnostic,
|
|
18
|
-
} from '@servicenow/sdk-build-core'
|
|
19
|
-
import { RecordPlugin } from '../db/RecordPlugin'
|
|
20
|
-
import {
|
|
21
|
-
EnforceAcl,
|
|
22
|
-
mergeACLIds,
|
|
23
|
-
generateVersionRecords,
|
|
24
|
-
generateRoutesAndRouteAttrRecords,
|
|
25
|
-
} from './RESTSerializationUtils'
|
|
26
|
-
import {
|
|
27
|
-
transformDefinition,
|
|
28
|
-
transformRestAttrs,
|
|
29
|
-
transformRouteAttrs,
|
|
30
|
-
transformRouteAttrsMap,
|
|
31
|
-
transformRoutes,
|
|
32
|
-
} from './RESTDeserializationUtils'
|
|
33
|
-
import { RestRouteHeaderMap, RestRouteQueryMap } from './RestSchemaUtils'
|
|
34
|
-
import {
|
|
35
|
-
getRestDocumentMap,
|
|
36
|
-
getRouteAttrResult,
|
|
37
|
-
getRouteAttrMapResult,
|
|
38
|
-
getRouteAttrWithRecordNodeResult,
|
|
39
|
-
getRouteAttrWithRestNodeResult,
|
|
40
|
-
getRouteAttrMapWithRecordNodeResult,
|
|
41
|
-
getRouteAttrMapWithRestNodeResult,
|
|
42
|
-
handleAndReturnResult,
|
|
43
|
-
createRecordCall,
|
|
44
|
-
restTables,
|
|
45
|
-
unHandledIds,
|
|
46
|
-
completelyUnassociatedParamIds,
|
|
47
|
-
potentialRecordCallRouteParams,
|
|
48
|
-
extractNestedIds,
|
|
49
|
-
} from './RestUtils'
|
|
50
|
-
import * as z from 'zod'
|
|
51
|
-
import { Diagnostic, ts, tsc } from '@servicenow/sdk-project'
|
|
52
|
-
import { ModuleFunctionData } from '../ServerModulePlugin'
|
|
53
|
-
|
|
54
|
-
const methodsAllowedToOverrideRequests = ['PUT', 'PATCH', 'POST']
|
|
55
|
-
const parseAcls = (enforce_acl: EnforceAcl, context: Context) =>
|
|
56
|
-
enforce_acl.map((acl) => (typeof acl === 'string' ? acl : context.keys.registerExplicitId(acl.table, acl.$id)))
|
|
57
|
-
|
|
58
|
-
function restApiAsRecord<I extends number, V extends Version<I>>(config: RestApiConfig<I, V>) {
|
|
59
|
-
const api = RestApiSchema.parse(config)
|
|
60
|
-
const rest = additionalProperties(config, RestApiSchema)
|
|
61
|
-
|
|
62
|
-
return Record({
|
|
63
|
-
table: 'sys_ws_definition',
|
|
64
|
-
$id: api.$id,
|
|
65
|
-
data: {
|
|
66
|
-
active: api.active,
|
|
67
|
-
name: api.name,
|
|
68
|
-
consumes: api.consumes,
|
|
69
|
-
consumes_customized: api.consumes === RestApiSchema.shape.consumes._def.defaultValue() ? false : true,
|
|
70
|
-
produces: api.produces,
|
|
71
|
-
produces_customized: api.produces === RestApiSchema.shape.produces._def.defaultValue() ? false : true,
|
|
72
|
-
default_version: '',
|
|
73
|
-
doc_link: api.doc_link,
|
|
74
|
-
is_versioned: false,
|
|
75
|
-
service_id: api.service_id,
|
|
76
|
-
short_description: api.short_description,
|
|
77
|
-
base_uri: '',
|
|
78
|
-
namespace: '',
|
|
79
|
-
enforce_acl: api.enforce_acl as any,
|
|
80
|
-
...(api.policy && { sys_policy: api.policy }),
|
|
81
|
-
...rest,
|
|
82
|
-
},
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* TODO: Apparently the REST API plugin's arranger actually has pretty severe side effects such as
|
|
88
|
-
* transforming code and dropping keys from the registry. I failed to unravel the web of code spread
|
|
89
|
-
* across all the REST API "utils" files to understand how and why it is doing this. For some reason
|
|
90
|
-
* this is only an issue when doing a regular build and not during bidirectional sync... For now I'm
|
|
91
|
-
* preserving the existing behavior of skipping the arranger during regular builds and putting that
|
|
92
|
-
* logic here in this namespace so we can easily find it and rip it out later.
|
|
93
|
-
*
|
|
94
|
-
* @deprecated
|
|
95
|
-
*/
|
|
96
|
-
export namespace RestApiPluginTechDebt {
|
|
97
|
-
export function applyArrangerSkipFlag(context: Context) {
|
|
98
|
-
context['skipRestApiArranger'] = true
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function removeArrangerSkipFlag(context: Context) {
|
|
102
|
-
delete context['skipRestApiArranger']
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function shouldSkipArranger(context: Context) {
|
|
106
|
-
return context['skipRestApiArranger'] === true
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export default Plugin({
|
|
111
|
-
name: 'RestApi',
|
|
112
|
-
ownedTables: {
|
|
113
|
-
sys_ws_definition: { diagnosticLevel: Diagnostic.Level.Warn },
|
|
114
|
-
sys_ws_version: { diagnosticLevel: Diagnostic.Level.Warn },
|
|
115
|
-
sys_ws_operation: { diagnosticLevel: Diagnostic.Level.Warn },
|
|
116
|
-
},
|
|
117
|
-
extractors: {
|
|
118
|
-
entity: {
|
|
119
|
-
fluent: {
|
|
120
|
-
CallExpression: (node, context) => {
|
|
121
|
-
const result = extractCallExpression(RestApi, 'restApi', node, context, (restApi) =>
|
|
122
|
-
context.registerExplicitId('sys_ws_definition', restApi.$id as string)
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
if (!result.handled || !result.data) {
|
|
126
|
-
return result
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const restApiEntity = result.data
|
|
130
|
-
const restExplicitIds = extractNestedIds(restApiEntity)
|
|
131
|
-
const entityData = RestApiSchema.and(z.any()).parse(restApiEntity.getValue())
|
|
132
|
-
const service_id = restApiEntity.getProperty('service_id')
|
|
133
|
-
const { routes, enforce_acl, consumes, produces } = entityData
|
|
134
|
-
const serviceIdRegex = new RegExp(`^[a-z0-9_]*[a-z0-9]$`)
|
|
135
|
-
|
|
136
|
-
if (!service_id.getValue().match(serviceIdRegex)) {
|
|
137
|
-
result.diagnostics.push(
|
|
138
|
-
new FluentDiagnostic(
|
|
139
|
-
service_id.getNode(),
|
|
140
|
-
`Rest service_id must only contain lowercase letters, numbers, and underscores and end with a letter or number`
|
|
141
|
-
)
|
|
142
|
-
)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const routesData = restApiEntity.getProperty('routes', 'array')?.getElements() ?? []
|
|
146
|
-
for (let i = 0; i < routesData.length; i++) {
|
|
147
|
-
const routeData = routesData[i]!
|
|
148
|
-
if (!Data.isObject(routeData)) {
|
|
149
|
-
result.diagnostics.push(new FluentDiagnostic(routeData.getNode(), 'Invalid route value'))
|
|
150
|
-
continue
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const scriptData = routeData.getProperty('script')
|
|
154
|
-
const scriptValue =
|
|
155
|
-
scriptData instanceof ModuleFunctionData
|
|
156
|
-
? scriptData.getGlueCode((n) => `${n}(request, response)`)
|
|
157
|
-
: scriptData.getValue()?.toString() ?? ''
|
|
158
|
-
|
|
159
|
-
const route = routes[i]!
|
|
160
|
-
route.script = scriptValue
|
|
161
|
-
|
|
162
|
-
/** allow users to override consumes for allowed http methods*/
|
|
163
|
-
if (
|
|
164
|
-
route.consumes &&
|
|
165
|
-
route.consumes !== consumes &&
|
|
166
|
-
!methodsAllowedToOverrideRequests.includes(route.method)
|
|
167
|
-
) {
|
|
168
|
-
throw Error(`Cannot override consumer type for ${route.method} method`)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
route.name = route.name ? route.name : route.path
|
|
172
|
-
route.consumes = route.consumes ? route.consumes : consumes
|
|
173
|
-
route.produces = route.produces ? route.produces : produces
|
|
174
|
-
route.enforce_acl = parseAcls(route.enforce_acl, context)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
handled: true,
|
|
179
|
-
diagnostics: result.diagnostics,
|
|
180
|
-
data: new EntityData(
|
|
181
|
-
restApiEntity.getKind(),
|
|
182
|
-
restApiEntity.getGuid(),
|
|
183
|
-
ObjectData.fromObjectValue(
|
|
184
|
-
{
|
|
185
|
-
...entityData,
|
|
186
|
-
enforce_acl: parseAcls(enforce_acl, context),
|
|
187
|
-
},
|
|
188
|
-
restApiEntity.getNode()
|
|
189
|
-
),
|
|
190
|
-
restApiEntity.getNode(),
|
|
191
|
-
restApiEntity.getInstallMethod(),
|
|
192
|
-
restExplicitIds
|
|
193
|
-
),
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
composers: {
|
|
200
|
-
entity: {
|
|
201
|
-
restApi(entity, context) {
|
|
202
|
-
const restEntity = entity.getValue()
|
|
203
|
-
const parsedEntity = RestApiSchema.safeParse(restEntity)
|
|
204
|
-
if (!parsedEntity.success) {
|
|
205
|
-
return Promise.resolve(undefined)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const { routes, versions, enforce_acl } = parsedEntity.data
|
|
209
|
-
const defaultVersions = versions.filter((version) => version.is_default)
|
|
210
|
-
if (defaultVersions.length > 1) {
|
|
211
|
-
Promise.reject(`Multiple versions cannot be set to default.`)
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const {
|
|
215
|
-
app: {
|
|
216
|
-
config: { scope },
|
|
217
|
-
},
|
|
218
|
-
} = context
|
|
219
|
-
const restRecord = restApiAsRecord(restEntity as any) as RecordWithLegacyId<'sys_ws_definition'>
|
|
220
|
-
const apiData = { ...restRecord.data }
|
|
221
|
-
|
|
222
|
-
apiData.base_uri = `/api/${scope}/${apiData.service_id}`
|
|
223
|
-
apiData.namespace = scope
|
|
224
|
-
apiData.default_version =
|
|
225
|
-
defaultVersions.length > 0 ? `v${defaultVersions[0]!.version}` : 'No active default version'
|
|
226
|
-
apiData.enforce_acl = mergeACLIds(enforce_acl) as any
|
|
227
|
-
apiData.is_versioned = versions.length > 0 ? true : false
|
|
228
|
-
|
|
229
|
-
/** generates sys_ws_definition record */
|
|
230
|
-
const updatedRestRecord = Record({
|
|
231
|
-
table: 'sys_ws_definition',
|
|
232
|
-
$id: entity.getGuid(),
|
|
233
|
-
data: apiData,
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
/** generates the sys_ws_version record */
|
|
237
|
-
const versionRecordsAndMap = generateVersionRecords(
|
|
238
|
-
context,
|
|
239
|
-
apiData.default_version,
|
|
240
|
-
versions,
|
|
241
|
-
updatedRestRecord
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
/** generates the sys_ws_operation, sys_ws_header, sys_ws_header_map, sys_ws_query_paramter, sys_ws_query_parameter_map records */
|
|
245
|
-
const routesAndRouteAttrRecords = generateRoutesAndRouteAttrRecords(
|
|
246
|
-
context,
|
|
247
|
-
restRecord.$id,
|
|
248
|
-
routes,
|
|
249
|
-
apiData,
|
|
250
|
-
updatedRestRecord,
|
|
251
|
-
versionRecordsAndMap.mapping
|
|
252
|
-
)
|
|
253
|
-
|
|
254
|
-
return context.composeEntities(
|
|
255
|
-
[updatedRestRecord, ...versionRecordsAndMap.records, ...routesAndRouteAttrRecords].map(
|
|
256
|
-
(r) =>
|
|
257
|
-
new EntityData(
|
|
258
|
-
'record',
|
|
259
|
-
r.$id as string,
|
|
260
|
-
ObjectData.fromObjectValue(r, entity.getNode()),
|
|
261
|
-
entity.getNode(),
|
|
262
|
-
entity.getInstallMethod()
|
|
263
|
-
)
|
|
264
|
-
),
|
|
265
|
-
[RecordPlugin]
|
|
266
|
-
)
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
arrangers: {
|
|
271
|
-
record(document, context) {
|
|
272
|
-
const table = document.data!['table']
|
|
273
|
-
if (!restTables.includes(table) || RestApiPluginTechDebt.shouldSkipArranger(context)) {
|
|
274
|
-
return { handled: false }
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/** generates rest document map and validates the params and their mapping records */
|
|
278
|
-
const restDocMap = getRestDocumentMap(context)
|
|
279
|
-
switch (table) {
|
|
280
|
-
case 'sys_ws_operation':
|
|
281
|
-
case 'sys_ws_version':
|
|
282
|
-
return {
|
|
283
|
-
handled: true,
|
|
284
|
-
result: {
|
|
285
|
-
kind: 'record',
|
|
286
|
-
guid: document.data!['data']['web_service_definition'],
|
|
287
|
-
},
|
|
288
|
-
}
|
|
289
|
-
case 'sys_ws_header':
|
|
290
|
-
case 'sys_ws_query_parameter':
|
|
291
|
-
if (!document.node) {
|
|
292
|
-
/** handles case where the incoming xml doesn't have any node associated with it. */
|
|
293
|
-
return handleAndReturnResult(getRouteAttrResult(document, restDocMap), document)
|
|
294
|
-
} else {
|
|
295
|
-
const docNode = document.node as ts.CallExpression
|
|
296
|
-
if (getCallExpressionName(docNode) === Record.name) {
|
|
297
|
-
/** handles case where the incoming xml is currently associated with record call */
|
|
298
|
-
return handleAndReturnResult(
|
|
299
|
-
getRouteAttrWithRecordNodeResult(document, context, restDocMap),
|
|
300
|
-
document
|
|
301
|
-
)
|
|
302
|
-
} else {
|
|
303
|
-
/** handles case where the incoming xml is currently associated with rest call */
|
|
304
|
-
return handleAndReturnResult(
|
|
305
|
-
getRouteAttrWithRestNodeResult(document, context, restDocMap),
|
|
306
|
-
document
|
|
307
|
-
)
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
case 'sys_ws_header_map':
|
|
311
|
-
case 'sys_ws_query_parameter_map':
|
|
312
|
-
if (!document.node) {
|
|
313
|
-
/** handles case where the incoming xml doesn't have any node associated with it. */
|
|
314
|
-
return handleAndReturnResult(getRouteAttrMapResult(document, restDocMap), document)
|
|
315
|
-
} else {
|
|
316
|
-
const docNode = document.node as ts.CallExpression
|
|
317
|
-
if (getCallExpressionName(docNode) === Record.name) {
|
|
318
|
-
/** handles case where the incoming xml is currently associated with record call */
|
|
319
|
-
return handleAndReturnResult(
|
|
320
|
-
getRouteAttrMapWithRecordNodeResult(document, context, restDocMap),
|
|
321
|
-
document
|
|
322
|
-
)
|
|
323
|
-
} else {
|
|
324
|
-
/** handles case where the incoming xml is currently associated with rest call */
|
|
325
|
-
return handleAndReturnResult(
|
|
326
|
-
getRouteAttrMapWithRestNodeResult(document, context, restDocMap),
|
|
327
|
-
document
|
|
328
|
-
)
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
default:
|
|
332
|
-
return { handled: true, result: undefined }
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
generators: {
|
|
337
|
-
record(document, context, linkedDocuments) {
|
|
338
|
-
const table = document.data!['table']
|
|
339
|
-
/**
|
|
340
|
-
* Edge case: m2m record maps non-app rest causing you to unassociate the only associated
|
|
341
|
-
* param record to rest. May require creation of record call for unassociated param if not consumed
|
|
342
|
-
* by any
|
|
343
|
-
*/
|
|
344
|
-
completelyUnassociatedParamIds.forEach((id) => {
|
|
345
|
-
if (potentialRecordCallRouteParams.has(id)) {
|
|
346
|
-
createRecordCall(id, context)
|
|
347
|
-
potentialRecordCallRouteParams.delete(id)
|
|
348
|
-
}
|
|
349
|
-
})
|
|
350
|
-
completelyUnassociatedParamIds.clear()
|
|
351
|
-
/** unHandledIds contains rest record ids for which we need to create record call */
|
|
352
|
-
if (!restTables.includes(table) || unHandledIds.includes(document.guid)) {
|
|
353
|
-
return undefined
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
switch (table) {
|
|
357
|
-
case 'sys_ws_definition':
|
|
358
|
-
// eslint-disable-next-line no-case-declarations
|
|
359
|
-
const linkedDoc = linkDocument(
|
|
360
|
-
document,
|
|
361
|
-
generateCallExpressionExportForDocument(
|
|
362
|
-
context,
|
|
363
|
-
{
|
|
364
|
-
sourceFile: getOrCreateEntitySourceFile(
|
|
365
|
-
context,
|
|
366
|
-
getSysUpdateName(document, 'sys_ws_definition')
|
|
367
|
-
),
|
|
368
|
-
moduleSpecifier: '@servicenow/sdk/core',
|
|
369
|
-
},
|
|
370
|
-
RestApi,
|
|
371
|
-
{}
|
|
372
|
-
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
373
|
-
)
|
|
374
|
-
return linkedDoc
|
|
375
|
-
case 'sys_ws_operation':
|
|
376
|
-
case 'sys_ws_version':
|
|
377
|
-
case 'sys_ws_header':
|
|
378
|
-
case 'sys_ws_query_parameter':
|
|
379
|
-
// eslint-disable-next-line no-case-declarations
|
|
380
|
-
const restDef = linkedDocuments.find(
|
|
381
|
-
(doc) =>
|
|
382
|
-
(doc.data as any).table === 'sys_ws_definition' &&
|
|
383
|
-
doc.guid === (document.data as any).data.web_service_definition
|
|
384
|
-
)
|
|
385
|
-
// eslint-disable-next-line no-case-declarations
|
|
386
|
-
const o_v_node = document.parent?.node ? document.parent!.node : restDef?.node
|
|
387
|
-
if (!o_v_node) {
|
|
388
|
-
return undefined
|
|
389
|
-
}
|
|
390
|
-
return linkDocument(document, o_v_node as ts.CallExpression<tsc.CallExpression>)
|
|
391
|
-
case 'sys_ws_header_map':
|
|
392
|
-
case 'sys_ws_query_parameter_map':
|
|
393
|
-
// eslint-disable-next-line no-case-declarations
|
|
394
|
-
const operationDef = linkedDocuments.find(
|
|
395
|
-
(doc) =>
|
|
396
|
-
(doc.data as any).table === 'sys_ws_operation' &&
|
|
397
|
-
doc.guid === (document.data as any).data.web_service_operation
|
|
398
|
-
)
|
|
399
|
-
// eslint-disable-next-line no-case-declarations
|
|
400
|
-
const h_q_node = document.parent?.node ? document.parent?.node : operationDef?.node
|
|
401
|
-
if (!h_q_node) {
|
|
402
|
-
return undefined
|
|
403
|
-
}
|
|
404
|
-
return linkDocument(document, h_q_node as ts.CallExpression<tsc.CallExpression>)
|
|
405
|
-
}
|
|
406
|
-
return undefined
|
|
407
|
-
},
|
|
408
|
-
},
|
|
409
|
-
transformers: {
|
|
410
|
-
record: {
|
|
411
|
-
CallExpression(document, context) {
|
|
412
|
-
if (!shouldHandle(document)) {
|
|
413
|
-
return false
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
const documentMap = context.getDocumentMap()
|
|
417
|
-
const table = document.data!['table']
|
|
418
|
-
switch (table) {
|
|
419
|
-
case 'sys_ws_definition':
|
|
420
|
-
return transformDefinition(document, context)
|
|
421
|
-
case 'sys_ws_version':
|
|
422
|
-
return transformRestAttrs(document, context)
|
|
423
|
-
case 'sys_ws_operation':
|
|
424
|
-
return transformRoutes(document, context, documentMap!)
|
|
425
|
-
case 'sys_ws_header':
|
|
426
|
-
return transformRouteAttrs(document, context, 'headers')
|
|
427
|
-
case 'sys_ws_query_parameter':
|
|
428
|
-
return transformRouteAttrs(document, context, 'parameters')
|
|
429
|
-
case 'sys_ws_query_parameter_map':
|
|
430
|
-
return transformRouteAttrsMap(
|
|
431
|
-
document,
|
|
432
|
-
context,
|
|
433
|
-
documentMap!,
|
|
434
|
-
RestRouteQueryMap,
|
|
435
|
-
'parameters',
|
|
436
|
-
(data: z.infer<typeof RestRouteQueryMap>) => {
|
|
437
|
-
return {
|
|
438
|
-
operationId: data.web_service_operation,
|
|
439
|
-
attrId: data.web_service_query_parameter,
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
)
|
|
443
|
-
case 'sys_ws_header_map':
|
|
444
|
-
return transformRouteAttrsMap(
|
|
445
|
-
document,
|
|
446
|
-
context,
|
|
447
|
-
documentMap!,
|
|
448
|
-
RestRouteHeaderMap,
|
|
449
|
-
'headers',
|
|
450
|
-
(data: z.infer<typeof RestRouteHeaderMap>) => {
|
|
451
|
-
return { operationId: data.web_service_operation, attrId: data.web_service_header }
|
|
452
|
-
}
|
|
453
|
-
)
|
|
454
|
-
}
|
|
455
|
-
return false
|
|
456
|
-
},
|
|
457
|
-
},
|
|
458
|
-
},
|
|
459
|
-
})
|
|
460
|
-
|
|
461
|
-
function shouldHandle(document: Document): boolean {
|
|
462
|
-
const docNode = document.node as ts.CallExpression
|
|
463
|
-
return !docNode.wasForgotten() &&
|
|
464
|
-
getCallExpressionName(docNode) === RestApi.name &&
|
|
465
|
-
document.data!['table'] &&
|
|
466
|
-
docNode.getArguments()[0]
|
|
467
|
-
? true
|
|
468
|
-
: false
|
|
469
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseRestApiSchema,
|
|
3
|
-
BaseRouteSchema,
|
|
4
|
-
RouteAttributeSchema,
|
|
5
|
-
VersionSchema,
|
|
6
|
-
} from '@servicenow/sdk-core/runtime/rest'
|
|
7
|
-
import { z } from 'zod'
|
|
8
|
-
|
|
9
|
-
export const RestRouteHeaderMap = z.object({
|
|
10
|
-
web_service_operation: z.string(),
|
|
11
|
-
web_service_header: z.string(),
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
export const RestRouteQueryMap = z.object({
|
|
15
|
-
web_service_operation: z.string(),
|
|
16
|
-
web_service_query_parameter: z.string(),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
export const RouteAttrWithOutIdSchema = RouteAttributeSchema.omit({ $id: true })
|
|
20
|
-
|
|
21
|
-
export const VersionWithOutIdSchema = VersionSchema.omit({ $id: true })
|
|
22
|
-
|
|
23
|
-
const RestDefinitionSchema = BaseRestApiSchema.omit({ $id: true }).extend({
|
|
24
|
-
enforce_acl: z.string().default(''),
|
|
25
|
-
sys_policy: z.enum(['', 'read', 'protected']).default(''),
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
export const RestDefinitionTransformer = RestDefinitionSchema.partial().transform((data) => {
|
|
29
|
-
const { sys_policy, enforce_acl, ...rest } = data
|
|
30
|
-
return {
|
|
31
|
-
...rest,
|
|
32
|
-
...(enforce_acl !== undefined && { enforce_acl: enforce_acl ? enforce_acl.split(',') : [] }),
|
|
33
|
-
...(sys_policy && { policy: sys_policy }),
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const RestRouteSchema = BaseRouteSchema.omit({ $id: true }).extend({
|
|
38
|
-
operation_script: z.string().default(''),
|
|
39
|
-
http_method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).default('GET'),
|
|
40
|
-
relative_path: z.string().default('/'),
|
|
41
|
-
requires_acl_authorization: z.boolean().default(true),
|
|
42
|
-
requires_authentication: z.boolean().default(true),
|
|
43
|
-
requires_snc_internal_role: z.boolean().default(true),
|
|
44
|
-
sys_policy: z.enum(['', 'read', 'protected']).default(''),
|
|
45
|
-
enforce_acl: z.string().default(''),
|
|
46
|
-
web_service_version: z.string().default(''),
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
export const RestRouteTransformer = RestRouteSchema.partial().transform((data) => {
|
|
50
|
-
const {
|
|
51
|
-
operation_script,
|
|
52
|
-
http_method,
|
|
53
|
-
relative_path,
|
|
54
|
-
requires_acl_authorization,
|
|
55
|
-
requires_authentication,
|
|
56
|
-
requires_snc_internal_role,
|
|
57
|
-
sys_policy,
|
|
58
|
-
enforce_acl,
|
|
59
|
-
...rest
|
|
60
|
-
} = data
|
|
61
|
-
return {
|
|
62
|
-
...rest,
|
|
63
|
-
...(enforce_acl !== undefined && { enforce_acl: enforce_acl ? enforce_acl.split(',') : [] }),
|
|
64
|
-
...(operation_script !== undefined && { script: operation_script }),
|
|
65
|
-
...(http_method && { method: http_method }),
|
|
66
|
-
...(relative_path && { path: relative_path }),
|
|
67
|
-
...(requires_acl_authorization !== undefined && { authorization: requires_acl_authorization }),
|
|
68
|
-
...(requires_authentication !== undefined && { authentication: requires_authentication }),
|
|
69
|
-
...(requires_snc_internal_role !== undefined && { internalRole: requires_snc_internal_role }),
|
|
70
|
-
...(sys_policy && { policy: sys_policy }),
|
|
71
|
-
}
|
|
72
|
-
})
|