@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
package/src/db/RecordPlugin.ts
DELETED
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
import { Record, TableName } from '@servicenow/sdk-core/runtime/db'
|
|
2
|
-
import {
|
|
3
|
-
Context,
|
|
4
|
-
Plugin,
|
|
5
|
-
getCallExpressionName,
|
|
6
|
-
isGUID,
|
|
7
|
-
removeNode,
|
|
8
|
-
transformFunctionArguments,
|
|
9
|
-
unloadBuilder,
|
|
10
|
-
linkDocument,
|
|
11
|
-
generateCallExpressionExportForDocument,
|
|
12
|
-
getOrCreateEntitySourceFile,
|
|
13
|
-
XmlData,
|
|
14
|
-
FluentDiagnostic,
|
|
15
|
-
ExtractionResult,
|
|
16
|
-
EntityData,
|
|
17
|
-
extractCallExpression,
|
|
18
|
-
Data,
|
|
19
|
-
ObjectData,
|
|
20
|
-
Document,
|
|
21
|
-
type Directories,
|
|
22
|
-
} from '@servicenow/sdk-build-core'
|
|
23
|
-
import { z } from 'zod'
|
|
24
|
-
import { ts } from '@servicenow/sdk-project'
|
|
25
|
-
import { except } from '../scripts/scriptUtils'
|
|
26
|
-
import { fieldHasNowIncludeCallExpression } from '../IncludePlugin'
|
|
27
|
-
|
|
28
|
-
// TODO: This schema should live with the Record entity function itself
|
|
29
|
-
export const RecordEntitySchema = z.object({
|
|
30
|
-
$id: z.string().or(z.number()),
|
|
31
|
-
data: z.record(z.any()),
|
|
32
|
-
table: z.string(),
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
type RecordData = z.output<typeof RecordEntitySchema>
|
|
36
|
-
|
|
37
|
-
const RecordUpdate = z.object({
|
|
38
|
-
record_update: z.record(z.any()),
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const RecordUpdateTableSchema = z.object({
|
|
42
|
-
'@_table': z.string(),
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
export const TextStringSchema = z.object({ '#text': z.string() }).transform((val) => val['#text'])
|
|
46
|
-
export const TextBooleanSchema = z.object({ '#text': z.boolean() }).transform((val) => val['#text'])
|
|
47
|
-
export const TextNumberSchema = z.object({ '#text': z.number().or(z.literal('')) }).transform((val) => val['#text'])
|
|
48
|
-
|
|
49
|
-
const ignoreFields = [
|
|
50
|
-
'sys_created_by',
|
|
51
|
-
'sys_created_on',
|
|
52
|
-
'sys_updated_by',
|
|
53
|
-
'sys_updated_on',
|
|
54
|
-
'sys_mod_count',
|
|
55
|
-
'sys_class_name',
|
|
56
|
-
'sys_id',
|
|
57
|
-
'sys_package',
|
|
58
|
-
'sys_policy',
|
|
59
|
-
'sys_scope',
|
|
60
|
-
'sys_update_name',
|
|
61
|
-
]
|
|
62
|
-
const ignoreXMLElement = ['sys_translated_text', 'sys_es_latest_script']
|
|
63
|
-
|
|
64
|
-
export const RecordXmlSchema = z
|
|
65
|
-
.object({
|
|
66
|
-
'@_action': z.union([z.literal('INSERT_OR_UPDATE'), z.literal('DELETE'), z.literal('delete_multiple')]),
|
|
67
|
-
sys_id: z.object({
|
|
68
|
-
'#text': z
|
|
69
|
-
.string()
|
|
70
|
-
.min(32)
|
|
71
|
-
.max(32)
|
|
72
|
-
.or(z.number().transform((val) => val.toString())),
|
|
73
|
-
}),
|
|
74
|
-
})
|
|
75
|
-
.catchall(
|
|
76
|
-
z.intersection(
|
|
77
|
-
z.object({
|
|
78
|
-
'#text': z.union([z.string(), z.boolean(), z.number(), z.undefined()]),
|
|
79
|
-
}),
|
|
80
|
-
z.record(z.any()) // capture all attributes
|
|
81
|
-
)
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
const RecordDocumentSchema = z.object({
|
|
85
|
-
data: z.record(z.union([z.string(), z.number(), z.boolean(), z.undefined(), z.null()])),
|
|
86
|
-
table: z.string(),
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
const InstallDir = z
|
|
90
|
-
.union([
|
|
91
|
-
z.literal('update'),
|
|
92
|
-
z.literal('dictionary'),
|
|
93
|
-
z.literal('scope'),
|
|
94
|
-
z.literal('demo'),
|
|
95
|
-
z.literal('first install'),
|
|
96
|
-
])
|
|
97
|
-
.default('update')
|
|
98
|
-
.transform((directory) => {
|
|
99
|
-
if (directory === 'demo') {
|
|
100
|
-
return 'unload.demo'
|
|
101
|
-
} else if (directory === 'first install') {
|
|
102
|
-
return 'unload'
|
|
103
|
-
}
|
|
104
|
-
return directory
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
export function getOutputDirectoryForDocument(document: Document, table: string): Directories {
|
|
108
|
-
if (table === 'sys_app') {
|
|
109
|
-
return 'scope'
|
|
110
|
-
}
|
|
111
|
-
return InstallDir.parse(document['directory'])
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function cleanRecordUpdate(recordUpdate: globalThis.Record<string, unknown>) {
|
|
115
|
-
ignoreXMLElement.forEach((element) => delete recordUpdate[element])
|
|
116
|
-
return recordUpdate
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function propertyAssignmentIsInlineScript(pa: ts.PropertyAssignment) {
|
|
120
|
-
return (
|
|
121
|
-
pa.getInitializerIfKind(ts.SyntaxKind.StringLiteral) ||
|
|
122
|
-
pa.getInitializerIfKind(ts.SyntaxKind.TaggedTemplateExpression) ||
|
|
123
|
-
pa.getInitializerIfKind(ts.SyntaxKind.TemplateExpression) ||
|
|
124
|
-
pa.getInitializerIfKind(ts.SyntaxKind.NoSubstitutionTemplateLiteral)
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export const RecordPlugin = Plugin({
|
|
129
|
-
name: 'Record',
|
|
130
|
-
extractors: {
|
|
131
|
-
entity: {
|
|
132
|
-
fluent: {
|
|
133
|
-
CallExpression: (node, context) => {
|
|
134
|
-
const result = extractCallExpression(
|
|
135
|
-
Record,
|
|
136
|
-
'record',
|
|
137
|
-
node,
|
|
138
|
-
context,
|
|
139
|
-
(record) => {
|
|
140
|
-
// Take the guid from the id property, a sys_id property, or generate one
|
|
141
|
-
if ('sys_id' in record.data) {
|
|
142
|
-
return record.data['sys_id'] as string
|
|
143
|
-
} else if (isGUID(record.$id as string)) {
|
|
144
|
-
return record.$id as string
|
|
145
|
-
} else {
|
|
146
|
-
return context.keys.registerExplicitId(record.table, record.$id as string)
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
(record): record is Record => RecordEntitySchema.safeParse(record).success
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
if (!result.handled || !result.data) {
|
|
153
|
-
return result
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const record = result.data
|
|
157
|
-
const diagnostics = result.diagnostics
|
|
158
|
-
const tableName = record.getProperty('table').getValue()
|
|
159
|
-
const pluginInfo = context.getPluginForTable(tableName)
|
|
160
|
-
|
|
161
|
-
if (pluginInfo) {
|
|
162
|
-
const { logLevel, api } = pluginInfo
|
|
163
|
-
const tableNode = node
|
|
164
|
-
.getFirstChildByKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
165
|
-
.getPropertyOrThrow('table')
|
|
166
|
-
|
|
167
|
-
diagnostics.push(
|
|
168
|
-
new FluentDiagnostic(
|
|
169
|
-
tableNode,
|
|
170
|
-
`${tableName} should not be created by the Record API. Please use the ${api} API.`,
|
|
171
|
-
{ level: logLevel }
|
|
172
|
-
)
|
|
173
|
-
)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// TODO: Get this out of the RecordPlugin somehow. Maybe need to provide a new mechanism for
|
|
177
|
-
// plugins to add diagnostics for entities extracted by other plugins?
|
|
178
|
-
if (tableName === 'sys_ui_view') {
|
|
179
|
-
const viewName = record.getProperty('data').getProperty('name')?.getValue()
|
|
180
|
-
const viewDataNode = node
|
|
181
|
-
.getFirstChildByKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
182
|
-
.getPropertyOrThrow('data')
|
|
183
|
-
.asKindOrThrow(ts.SyntaxKind.PropertyAssignment)
|
|
184
|
-
.getInitializerIfKind(ts.SyntaxKind.ObjectLiteralExpression)
|
|
185
|
-
|
|
186
|
-
const viewNameNode = viewDataNode?.getPropertyOrThrow('name')
|
|
187
|
-
const nameRegex = new RegExp(`^[a-zA-Z0-9_]+$`)
|
|
188
|
-
|
|
189
|
-
if (typeof viewName !== 'string' || !viewName.match(nameRegex)) {
|
|
190
|
-
diagnostics.push(
|
|
191
|
-
new FluentDiagnostic(
|
|
192
|
-
viewNameNode!,
|
|
193
|
-
`View name can only contain alphanumeric characters`
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
handled: true,
|
|
201
|
-
diagnostics,
|
|
202
|
-
data: record,
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
xml(xml) {
|
|
208
|
-
// Parse out record_Update info
|
|
209
|
-
const recordUpdateResult = RecordUpdate.safeParse(xml.data)
|
|
210
|
-
if (!recordUpdateResult.success) {
|
|
211
|
-
return undefined
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Parse root level @_table from record_update
|
|
215
|
-
const recordUpdate = cleanRecordUpdate(recordUpdateResult.data.record_update)
|
|
216
|
-
let tableRecord, recordTable
|
|
217
|
-
const table = RecordUpdateTableSchema.safeParse(recordUpdate)
|
|
218
|
-
if (!table.success) {
|
|
219
|
-
// TODO A record plugin should only handle 1 table record?
|
|
220
|
-
// Taking the first one for now. Shouldn't assume this is the right one
|
|
221
|
-
recordTable = Object.keys(recordUpdate)[0] as string
|
|
222
|
-
tableRecord = recordUpdate[recordTable]
|
|
223
|
-
} else {
|
|
224
|
-
recordTable = table.data['@_table']
|
|
225
|
-
tableRecord = recordUpdate[table.data['@_table']]
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (!tableRecord) {
|
|
229
|
-
return undefined
|
|
230
|
-
}
|
|
231
|
-
const recordParse = RecordXmlSchema.safeParse(tableRecord)
|
|
232
|
-
if (!recordParse.success) {
|
|
233
|
-
return undefined
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
tableRecord['@_action'] !== 'DELETE' &&
|
|
238
|
-
Object.keys(recordUpdate).some((k) => k !== recordTable && !k.startsWith('@_'))
|
|
239
|
-
) {
|
|
240
|
-
// Record contains other entries in the file that cannot be processed
|
|
241
|
-
return undefined
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
try {
|
|
245
|
-
const {
|
|
246
|
-
'@_action': action,
|
|
247
|
-
sys_id: { '#text': sysId },
|
|
248
|
-
...rest
|
|
249
|
-
} = tableRecord
|
|
250
|
-
|
|
251
|
-
const record = Object.entries(rest).reduce((out, [k, v]) => {
|
|
252
|
-
out[k] = v ? v['#text'] : undefined
|
|
253
|
-
return out
|
|
254
|
-
}, {})
|
|
255
|
-
|
|
256
|
-
return new XmlData(
|
|
257
|
-
{
|
|
258
|
-
id: sysId,
|
|
259
|
-
table: recordTable,
|
|
260
|
-
data: record,
|
|
261
|
-
},
|
|
262
|
-
xml.filePath,
|
|
263
|
-
'record',
|
|
264
|
-
action
|
|
265
|
-
)
|
|
266
|
-
} catch (err) {
|
|
267
|
-
return undefined // TODO: What are we catching here?
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
composers: {
|
|
272
|
-
entity: {
|
|
273
|
-
record(entity, _context) {
|
|
274
|
-
const $id = entity.getProperty('$id')
|
|
275
|
-
if (!Data.isString($id) && !Data.isNumber($id)) {
|
|
276
|
-
Promise.reject(`Record ID must be a string or number`)
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const table = entity.getProperty('table')
|
|
280
|
-
if (!Data.isString(table)) {
|
|
281
|
-
Promise.reject(`Record table must be a string`)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const data = entity.getProperty('data')
|
|
285
|
-
if (!Data.isObject(data)) {
|
|
286
|
-
Promise.reject(`Record data must be an object`)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const dataProps = entity.getProperty('data', 'object')?.getProperties()
|
|
290
|
-
const cdataFields: string[] = []
|
|
291
|
-
if (dataProps) {
|
|
292
|
-
cdataFields.push(
|
|
293
|
-
...Object.entries(dataProps).reduce((fields, [key, value]) => {
|
|
294
|
-
if (Data.isString(value) && value.needsCDATATag()) {
|
|
295
|
-
fields.push(key)
|
|
296
|
-
}
|
|
297
|
-
return fields
|
|
298
|
-
}, [] as string[])
|
|
299
|
-
)
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return Promise.resolve({
|
|
303
|
-
kind: 'record',
|
|
304
|
-
guid: entity.getGuid(),
|
|
305
|
-
node: entity.getNode(),
|
|
306
|
-
directory: entity.getInstallMethod(),
|
|
307
|
-
cdataFields,
|
|
308
|
-
data: {
|
|
309
|
-
$id: $id.getValue(),
|
|
310
|
-
table: table.getValue(),
|
|
311
|
-
data: data.getValue(),
|
|
312
|
-
},
|
|
313
|
-
})
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
xml: {
|
|
317
|
-
record(xml) {
|
|
318
|
-
const table = xml.data['table'] as string
|
|
319
|
-
const sysId = xml.data['id'] as string
|
|
320
|
-
|
|
321
|
-
return {
|
|
322
|
-
action: xml.action,
|
|
323
|
-
guid: sysId,
|
|
324
|
-
kind: 'record',
|
|
325
|
-
data: { table, data: xml.data['data'] },
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
|
-
serializers: {
|
|
331
|
-
record(document, context) {
|
|
332
|
-
const cdataFields = document['cdataFields']
|
|
333
|
-
const { table, data } = RecordDocumentSchema.parse(document.data)
|
|
334
|
-
const recordBuilder = unloadBuilder(context)
|
|
335
|
-
const builder = recordBuilder.record(table, document.guid, document.action)
|
|
336
|
-
|
|
337
|
-
Object.entries(data)
|
|
338
|
-
.filter(([c, v]) => typeof v !== 'undefined' && c !== 'sys_id')
|
|
339
|
-
.forEach(([c, v]) => {
|
|
340
|
-
if (cdataFields && cdataFields.includes(c)) {
|
|
341
|
-
builder.field(c, v, {}, true)
|
|
342
|
-
} else {
|
|
343
|
-
builder.field(c, v)
|
|
344
|
-
}
|
|
345
|
-
})
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
name: `${table}_${document.guid}.xml`,
|
|
349
|
-
directory: getOutputDirectoryForDocument(document, table),
|
|
350
|
-
content: recordBuilder.end(),
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
generators: {
|
|
355
|
-
record(document, context) {
|
|
356
|
-
return linkDocument(
|
|
357
|
-
document,
|
|
358
|
-
generateCallExpressionExportForDocument(
|
|
359
|
-
context,
|
|
360
|
-
{
|
|
361
|
-
sourceFile: getOrCreateEntitySourceFile(
|
|
362
|
-
context,
|
|
363
|
-
`${document.data?.['table']}_${document.guid}`
|
|
364
|
-
),
|
|
365
|
-
moduleSpecifier: '@servicenow/sdk/core',
|
|
366
|
-
},
|
|
367
|
-
Record,
|
|
368
|
-
{ $id: document.guid }
|
|
369
|
-
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
370
|
-
)
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
transformers: {
|
|
374
|
-
record: {
|
|
375
|
-
CallExpression(document, context) {
|
|
376
|
-
if (getCallExpressionName(document.node) !== Record.name) {
|
|
377
|
-
return false
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if (document.action === 'DELETE') {
|
|
381
|
-
removeNode(document.node)
|
|
382
|
-
return true
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (!document.changedData) {
|
|
386
|
-
return false
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const [args] = document.node.getArguments()
|
|
390
|
-
if (!ts.Node.isObjectLiteralExpression(args)) {
|
|
391
|
-
return false
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
const { table } = document.data as RecordData
|
|
395
|
-
const data = (document.changedData as any).data
|
|
396
|
-
|
|
397
|
-
const properties = Object.keys(data).reduce((out, key) => {
|
|
398
|
-
if (ignoreFields.includes(key)) {
|
|
399
|
-
return out
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (data[key] !== '' && data[key] !== undefined) {
|
|
403
|
-
out[key] = data[key]
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
return out
|
|
407
|
-
}, {} as Record)
|
|
408
|
-
|
|
409
|
-
const preexistingData = args
|
|
410
|
-
.getProperty('data')
|
|
411
|
-
?.asKind(ts.SyntaxKind.PropertyAssignment)
|
|
412
|
-
?.getInitializerIfKind(ts.SyntaxKind.ObjectLiteralExpression)
|
|
413
|
-
|
|
414
|
-
transformFunctionArguments(document.node, Record, {
|
|
415
|
-
table,
|
|
416
|
-
data: except(
|
|
417
|
-
properties,
|
|
418
|
-
(field) => !!preexistingData && fieldHasNowIncludeCallExpression(preexistingData, field)
|
|
419
|
-
),
|
|
420
|
-
})
|
|
421
|
-
|
|
422
|
-
context.argTypesToFix.push(document.node)
|
|
423
|
-
return true
|
|
424
|
-
},
|
|
425
|
-
},
|
|
426
|
-
},
|
|
427
|
-
})
|
|
428
|
-
|
|
429
|
-
export function extractCallExpressionAsRecord<
|
|
430
|
-
const A extends unknown[],
|
|
431
|
-
const E extends A extends [infer T extends globalThis.Record<string, unknown>] ? T : never,
|
|
432
|
-
const T extends TableName,
|
|
433
|
-
>(
|
|
434
|
-
fn: (...args: A) => E,
|
|
435
|
-
asRecord: (entity: EntityData<E>) => ObjectData<Record<T>>,
|
|
436
|
-
guid: (entity: E) => string,
|
|
437
|
-
node: ts.CallExpression,
|
|
438
|
-
context: Context
|
|
439
|
-
): ExtractionResult<EntityData<Record<T>>> {
|
|
440
|
-
const result = extractCallExpression(fn, 'record', node, context, guid)
|
|
441
|
-
if (!result.handled) {
|
|
442
|
-
return result
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return {
|
|
446
|
-
handled: true,
|
|
447
|
-
diagnostics: result.diagnostics,
|
|
448
|
-
data: result.data
|
|
449
|
-
? new EntityData(
|
|
450
|
-
'record',
|
|
451
|
-
result.data.getGuid(),
|
|
452
|
-
asRecord(result.data),
|
|
453
|
-
node,
|
|
454
|
-
result.data.getInstallMethod(),
|
|
455
|
-
result.data.getExplicitIds()
|
|
456
|
-
)
|
|
457
|
-
: undefined,
|
|
458
|
-
}
|
|
459
|
-
}
|