@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,316 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getCallExpressionName,
|
|
3
|
-
getPropertyAssignment,
|
|
4
|
-
Plugin,
|
|
5
|
-
stringify,
|
|
6
|
-
Context,
|
|
7
|
-
getOrCreatePropertyAssignment,
|
|
8
|
-
mergeDataIntoObjectLiteralArray,
|
|
9
|
-
filterEmpty,
|
|
10
|
-
generateCallExpressionExportForDocument,
|
|
11
|
-
getOrCreateEntitySourceFile,
|
|
12
|
-
linkDocument,
|
|
13
|
-
extractCallExpression,
|
|
14
|
-
} from '@servicenow/sdk-build-core'
|
|
15
|
-
import { Documentation, Record, Table } from '@servicenow/sdk-core/runtime/db'
|
|
16
|
-
import { createObjectExpression } from './TablePlugin'
|
|
17
|
-
import { ts, tsc } from '@servicenow/sdk-project'
|
|
18
|
-
import { RecordPlugin, RecordEntitySchema } from './RecordPlugin'
|
|
19
|
-
import { isEqual } from 'lodash'
|
|
20
|
-
|
|
21
|
-
function isSysDocumentationRecord(node: ts.CallExpression) {
|
|
22
|
-
try {
|
|
23
|
-
return (
|
|
24
|
-
getCallExpressionName(node) === Record.name &&
|
|
25
|
-
((node.getArguments()[0] as ts.ObjectLiteralExpression)?.getProperty('table') as ts.PropertyAssignment)
|
|
26
|
-
?.getInitializerIfKind(ts.SyntaxKind.StringLiteral)
|
|
27
|
-
?.getLiteralValue() === 'sys_documentation'
|
|
28
|
-
)
|
|
29
|
-
} catch (e) {
|
|
30
|
-
//don't throw
|
|
31
|
-
}
|
|
32
|
-
return false
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type SysDocKey = { name: string; element: string | undefined; language: string }
|
|
36
|
-
const generateSysId = (data: SysDocKey) =>
|
|
37
|
-
`${data['name']}_${data['element'] ? data['element'] + '_' : ''}${data['language']}`
|
|
38
|
-
|
|
39
|
-
export default Plugin({
|
|
40
|
-
name: 'Documentation',
|
|
41
|
-
extractors: {
|
|
42
|
-
entity: {
|
|
43
|
-
fluent: {
|
|
44
|
-
CallExpression: (node, context) => {
|
|
45
|
-
if (isSysDocumentationRecord(node)) {
|
|
46
|
-
const result = extractCallExpression(
|
|
47
|
-
Record,
|
|
48
|
-
'record',
|
|
49
|
-
node,
|
|
50
|
-
context,
|
|
51
|
-
(record) => {
|
|
52
|
-
//Generate guid similar to documentation_plugin during sys_documentation record extraction
|
|
53
|
-
return generateSysId(record.data as SysDocKey)
|
|
54
|
-
},
|
|
55
|
-
(record): record is Record => RecordEntitySchema.safeParse(record).success
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
if (!result.handled || !result.data) {
|
|
59
|
-
return result
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
handled: true,
|
|
64
|
-
diagnostics: result.diagnostics,
|
|
65
|
-
data: result.data,
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return { handled: false }
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
composers: {
|
|
74
|
-
xml: {
|
|
75
|
-
sys_documentation(xml) {
|
|
76
|
-
const data = xml.data['data']!
|
|
77
|
-
return {
|
|
78
|
-
kind: 'sys_documentation',
|
|
79
|
-
guid: generateSysId(data as SysDocKey),
|
|
80
|
-
data: xml.data,
|
|
81
|
-
action: xml.action,
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
serializers: {
|
|
87
|
-
sys_documentation(document, context) {
|
|
88
|
-
return RecordPlugin.serializers.record(document, context)
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
arrangers: {
|
|
92
|
-
sys_documentation(document) {
|
|
93
|
-
if ((document.data as any).table !== 'sys_documentation') {
|
|
94
|
-
return { handled: false }
|
|
95
|
-
}
|
|
96
|
-
const tableName = (document.data as any).data.name
|
|
97
|
-
return {
|
|
98
|
-
handled: true,
|
|
99
|
-
result: tableName ? { kind: 'bootstrap', guid: tableName } : undefined,
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
generators: {
|
|
104
|
-
sys_documentation(document, context: Context, linkedDocuments) {
|
|
105
|
-
const tableName = (document.data as any).data.name
|
|
106
|
-
const table = linkedDocuments.find((doc) => doc.guid === tableName)
|
|
107
|
-
return table && table.node
|
|
108
|
-
? { ...document, node: table.node }
|
|
109
|
-
: linkDocument(
|
|
110
|
-
document,
|
|
111
|
-
generateCallExpressionExportForDocument(
|
|
112
|
-
context,
|
|
113
|
-
{
|
|
114
|
-
sourceFile: getOrCreateEntitySourceFile(context, `${document.guid}`),
|
|
115
|
-
moduleSpecifier: '@servicenow/sdk/core',
|
|
116
|
-
},
|
|
117
|
-
Record,
|
|
118
|
-
{ $id: document.guid }
|
|
119
|
-
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
120
|
-
)
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
transformers: {
|
|
124
|
-
sys_documentation: {
|
|
125
|
-
CallExpression(document, context) {
|
|
126
|
-
const expressionName = getCallExpressionName(document.node)
|
|
127
|
-
if (expressionName !== Table.name) {
|
|
128
|
-
return RecordPlugin.transformers!.record!.CallExpression(document, context)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const { element: column } = (document.data as any).data
|
|
132
|
-
const [baseArgs] = document.node.getArguments()
|
|
133
|
-
if (!baseArgs) {
|
|
134
|
-
return false
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const docData: Documentation = (document as any).data.data as Documentation
|
|
138
|
-
delete docData['element'], delete docData['name'], delete docData['sys_id']
|
|
139
|
-
|
|
140
|
-
let labelNode, objLitNode, existingNameNode
|
|
141
|
-
if (column) {
|
|
142
|
-
const schemaProperty = getPropertyAssignment(baseArgs, 'schema')
|
|
143
|
-
const schemaLiteral = schemaProperty?.getChildrenOfKind(ts.SyntaxKind.ObjectLiteralExpression)[0]
|
|
144
|
-
if (!schemaLiteral) {
|
|
145
|
-
return false
|
|
146
|
-
}
|
|
147
|
-
const columnNode = schemaLiteral
|
|
148
|
-
.getProperties()
|
|
149
|
-
.find(
|
|
150
|
-
(prop) =>
|
|
151
|
-
column === prop.getFirstChildByKindOrThrow(ts.SyntaxKind.Identifier).getText().trim()
|
|
152
|
-
)
|
|
153
|
-
if (!columnNode) {
|
|
154
|
-
return false
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const callExpNode = columnNode!.getFirstChildByKind(ts.SyntaxKind.CallExpression)
|
|
158
|
-
if (!callExpNode) {
|
|
159
|
-
return false
|
|
160
|
-
}
|
|
161
|
-
objLitNode = callExpNode.getFirstChildByKind(ts.SyntaxKind.ObjectLiteralExpression)
|
|
162
|
-
if (!objLitNode) {
|
|
163
|
-
return false
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
existingNameNode = columnNode.getFirstChildByKindOrThrow(ts.SyntaxKind.Identifier)
|
|
167
|
-
labelNode = getPropertyAssignment(objLitNode, 'label')
|
|
168
|
-
} else {
|
|
169
|
-
objLitNode =
|
|
170
|
-
baseArgs.asKind(ts.SyntaxKind.ObjectLiteralExpression) ??
|
|
171
|
-
baseArgs.getFirstDescendantByKind(ts.SyntaxKind.ObjectLiteralExpression)
|
|
172
|
-
if (!objLitNode) {
|
|
173
|
-
return false
|
|
174
|
-
}
|
|
175
|
-
existingNameNode = getPropertyAssignment(objLitNode, 'name')
|
|
176
|
-
labelNode = getPropertyAssignment(objLitNode, 'label')
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Do transformation
|
|
180
|
-
const labelArrayNode = labelNode?.getFirstChildByKind(ts.SyntaxKind.ArrayLiteralExpression)
|
|
181
|
-
if (labelArrayNode) {
|
|
182
|
-
mergeDataIntoObjectLiteralArray(labelArrayNode, [docData], 'language', document.action)
|
|
183
|
-
return true
|
|
184
|
-
} else {
|
|
185
|
-
const literalNode = labelNode?.getFirstChildByKind(ts.SyntaxKind.StringLiteral)
|
|
186
|
-
if (isDefaultDocumentationRecord(docData)) {
|
|
187
|
-
return updateDefaultLabelParameters(literalNode, docData, existingNameNode, objLitNode)
|
|
188
|
-
} else {
|
|
189
|
-
return createArrayLabel(labelNode, objLitNode, docData)
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
function updateDefaultLabelParameters(literalNode, docData, existingNameNode, objLitNode) {
|
|
198
|
-
// Label should be written as a StringLiteral
|
|
199
|
-
if (literalNode) {
|
|
200
|
-
if (
|
|
201
|
-
literalNode.getLiteralValue() &&
|
|
202
|
-
docData.label?.toLowerCase().trim() === literalNode.getLiteralValue().toLowerCase().trim()
|
|
203
|
-
) {
|
|
204
|
-
// Incoming label is the same as the node in code
|
|
205
|
-
return true
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
literalNode.setLiteralValue(docData.label)
|
|
209
|
-
} else {
|
|
210
|
-
if (
|
|
211
|
-
existingNameNode &&
|
|
212
|
-
existingNameNode.getText().toLowerCase().trim() === docData.label?.toLowerCase().trim()
|
|
213
|
-
) {
|
|
214
|
-
// Label matches either `Table({name: 'xyz'})` or `name: xyzColumn({})`
|
|
215
|
-
return true
|
|
216
|
-
}
|
|
217
|
-
getOrCreatePropertyAssignment(objLitNode, 'label', stringify(docData.label))
|
|
218
|
-
}
|
|
219
|
-
return true
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function createArrayLabel(labelNode, objLitNode, docData) {
|
|
223
|
-
labelNode = getOrCreatePropertyAssignment(objLitNode, 'label', '[]')
|
|
224
|
-
const existingLabel = labelNode.getFirstChildByKind(ts.SyntaxKind.StringLiteral)?.getLiteralText()
|
|
225
|
-
|
|
226
|
-
// Create the array since it didn't exist before
|
|
227
|
-
labelNode.transform((traversal) => {
|
|
228
|
-
if (tsc.isPropertyAssignment(traversal.currentNode)) {
|
|
229
|
-
const arrayLit = traversal.factory.createArrayLiteralExpression([
|
|
230
|
-
createObjectExpression({
|
|
231
|
-
...filterEmpty(docData),
|
|
232
|
-
}),
|
|
233
|
-
])
|
|
234
|
-
return traversal.factory.updatePropertyAssignment(
|
|
235
|
-
traversal.currentNode,
|
|
236
|
-
tsc.factory.createIdentifier('label'),
|
|
237
|
-
arrayLit
|
|
238
|
-
)
|
|
239
|
-
}
|
|
240
|
-
return traversal.currentNode
|
|
241
|
-
})
|
|
242
|
-
if (existingLabel && docData.label?.toLowerCase().trim() !== existingLabel.toLowerCase().trim()) {
|
|
243
|
-
labelNode!
|
|
244
|
-
.getFirstChildByKindOrThrow(ts.SyntaxKind.ArrayLiteralExpression)
|
|
245
|
-
.addElement(stringify({ label: existingLabel }))
|
|
246
|
-
}
|
|
247
|
-
return true
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function isDefaultDocumentationRecord(docData) {
|
|
251
|
-
const { label, name, element } = docData
|
|
252
|
-
const defaultRecord = defaultDocumentationRecord(label, name, element)
|
|
253
|
-
return isEqual(defaultRecord.data, docData)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// TODO make default language configurable
|
|
257
|
-
function defaultDocumentationRecord(label: string, tableName: string, columnName: string) {
|
|
258
|
-
return Record({
|
|
259
|
-
table: 'sys_documentation',
|
|
260
|
-
$id: `${tableName}_${columnName ? columnName + '_' : ''}en`,
|
|
261
|
-
data: {
|
|
262
|
-
label: label,
|
|
263
|
-
hint: '',
|
|
264
|
-
help: '',
|
|
265
|
-
language: 'en',
|
|
266
|
-
plural: generatePlural(label),
|
|
267
|
-
url: '',
|
|
268
|
-
url_target: '',
|
|
269
|
-
},
|
|
270
|
-
})
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const PLURAL_EQUALS_LABEL = [
|
|
274
|
-
's',
|
|
275
|
-
'ed',
|
|
276
|
-
'by',
|
|
277
|
-
'Active',
|
|
278
|
-
')',
|
|
279
|
-
' to',
|
|
280
|
-
' with',
|
|
281
|
-
' for',
|
|
282
|
-
' in',
|
|
283
|
-
' out',
|
|
284
|
-
' use',
|
|
285
|
-
'Data',
|
|
286
|
-
' data',
|
|
287
|
-
]
|
|
288
|
-
const PLURAL_SPECIAL_CASE_Y_TO_IES = ['ry', 'ty', 'dy', 'cy', 'fy', 'ly', 'ny']
|
|
289
|
-
const PLURAL_SPECIAL_CASE_ADD_ES = ['x', 'sh', 'ch', 'z']
|
|
290
|
-
|
|
291
|
-
// Modified from GlideLabelGenerator
|
|
292
|
-
function generatePlural(label: string) {
|
|
293
|
-
if (!label) {
|
|
294
|
-
return ''
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
for (const l of PLURAL_EQUALS_LABEL) {
|
|
298
|
-
if (label.endsWith(l)) {
|
|
299
|
-
return label
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
for (const l of PLURAL_SPECIAL_CASE_Y_TO_IES) {
|
|
304
|
-
if (label.endsWith(l)) {
|
|
305
|
-
return label.substring(0, label.lastIndexOf('y')) + 'ies'
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
for (const l of PLURAL_SPECIAL_CASE_ADD_ES) {
|
|
310
|
-
if (label.endsWith(l)) {
|
|
311
|
-
return label + 'es'
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return label + 's'
|
|
316
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getCallExpressionName,
|
|
3
|
-
Plugin,
|
|
4
|
-
Context,
|
|
5
|
-
getPropertyAssignment,
|
|
6
|
-
mergeDataIntoObjectLiteral,
|
|
7
|
-
linkDocument,
|
|
8
|
-
generateCallExpressionExportForDocument,
|
|
9
|
-
getOrCreateEntitySourceFile,
|
|
10
|
-
GUID,
|
|
11
|
-
} from '@servicenow/sdk-build-core'
|
|
12
|
-
import { Table, Record } from '@servicenow/sdk-core/runtime/db'
|
|
13
|
-
import { RecordPlugin } from './RecordPlugin'
|
|
14
|
-
import { ts } from '@servicenow/sdk-project'
|
|
15
|
-
import { isEqual } from 'lodash'
|
|
16
|
-
|
|
17
|
-
export const ua_table_licensing_config = 'ua_table_licensing_config'
|
|
18
|
-
|
|
19
|
-
export default Plugin({
|
|
20
|
-
name: 'LicensingConfig',
|
|
21
|
-
composers: {
|
|
22
|
-
xml: {
|
|
23
|
-
ua_table_licensing_config(xml) {
|
|
24
|
-
return {
|
|
25
|
-
kind: ua_table_licensing_config,
|
|
26
|
-
guid: (xml.data['id'] as string) ?? GUID(),
|
|
27
|
-
data: xml.data,
|
|
28
|
-
action: xml.action,
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
serializers: {
|
|
34
|
-
ua_table_licensing_config(document, context) {
|
|
35
|
-
return RecordPlugin.serializers.record(document, context)
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
arrangers: {
|
|
39
|
-
ua_table_licensing_config(document) {
|
|
40
|
-
if ((document.data as any).table !== ua_table_licensing_config) {
|
|
41
|
-
return { handled: false }
|
|
42
|
-
}
|
|
43
|
-
const tableName = (document.data as any).data.name
|
|
44
|
-
return {
|
|
45
|
-
handled: true,
|
|
46
|
-
result: tableName ? { kind: 'bootstrap', guid: tableName } : undefined,
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
generators: {
|
|
51
|
-
ua_table_licensing_config(document, context: Context, linkedDocuments) {
|
|
52
|
-
const table = linkedDocuments.find((doc) => doc.guid === (document.data as any).data.name)
|
|
53
|
-
return table && table.node
|
|
54
|
-
? { ...document, node: table.node }
|
|
55
|
-
: linkDocument(
|
|
56
|
-
document,
|
|
57
|
-
generateCallExpressionExportForDocument(
|
|
58
|
-
context,
|
|
59
|
-
{
|
|
60
|
-
sourceFile: getOrCreateEntitySourceFile(context, `${document.kind}_${document.guid}`),
|
|
61
|
-
moduleSpecifier: '@servicenow/sdk/core',
|
|
62
|
-
},
|
|
63
|
-
Record,
|
|
64
|
-
{ $id: document.guid }
|
|
65
|
-
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
66
|
-
)
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
transformers: {
|
|
70
|
-
ua_table_licensing_config: {
|
|
71
|
-
CallExpression(document, context) {
|
|
72
|
-
const expressionName = getCallExpressionName(document.node)
|
|
73
|
-
if (expressionName !== Table.name) {
|
|
74
|
-
return RecordPlugin.transformers!.record!.CallExpression(document, context)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const [baseArgs] = document.node.getArguments()
|
|
78
|
-
if (!baseArgs) {
|
|
79
|
-
return false
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const changedData = (document.changedData as any).data
|
|
83
|
-
const data = (document.data as any).data
|
|
84
|
-
|
|
85
|
-
let objLit, dataToMerge
|
|
86
|
-
const licensingProp = getPropertyAssignment(baseArgs, 'licensing_config')
|
|
87
|
-
if (!licensingProp) {
|
|
88
|
-
if (isDefaultLicensingConfig(data)) {
|
|
89
|
-
return true
|
|
90
|
-
}
|
|
91
|
-
const defaultValues = defaultLicensingConfigRecord(data.name).data
|
|
92
|
-
dataToMerge = {}
|
|
93
|
-
Object.entries(data)
|
|
94
|
-
.filter(([prop]) => {
|
|
95
|
-
return data[prop] !== defaultValues[prop]
|
|
96
|
-
})
|
|
97
|
-
.map(([k, v]) => {
|
|
98
|
-
dataToMerge[k] = v
|
|
99
|
-
})
|
|
100
|
-
const callExpLit = document.node.getFirstChildByKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
101
|
-
const newProp = callExpLit.addPropertyAssignment({ name: 'licensing_config', initializer: '{}' })
|
|
102
|
-
objLit = newProp!.getFirstChildByKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
103
|
-
} else {
|
|
104
|
-
dataToMerge = changedData
|
|
105
|
-
objLit = licensingProp!.getFirstChildByKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (dataToMerge.license_roles) {
|
|
109
|
-
dataToMerge.license_roles = dataToMerge.license_roles.split(',')
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
mergeDataIntoObjectLiteral(objLit, dataToMerge)
|
|
113
|
-
return true
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
})
|
|
118
|
-
function isDefaultLicensingConfig(data) {
|
|
119
|
-
return isEqual(data, defaultLicensingConfigRecord(data.name).data)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function defaultLicensingConfigRecord(tableName: string) {
|
|
123
|
-
return Record({
|
|
124
|
-
table: ua_table_licensing_config,
|
|
125
|
-
$id: `${tableName}_license`,
|
|
126
|
-
data: {
|
|
127
|
-
name: tableName,
|
|
128
|
-
op_insert: true,
|
|
129
|
-
op_update: true,
|
|
130
|
-
op_delete: true,
|
|
131
|
-
is_fulfillment: false,
|
|
132
|
-
license_model: 'none',
|
|
133
|
-
owner_condition: '',
|
|
134
|
-
license_condition: '',
|
|
135
|
-
license_roles: '',
|
|
136
|
-
},
|
|
137
|
-
})
|
|
138
|
-
}
|