@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
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import MD5 from 'md5.js'
|
|
2
|
+
import * as mime from 'mime-types'
|
|
3
|
+
import { Shape, Plugin, type Record, unloadBuilder, gzipSync } from '@servicenow/sdk-build-core'
|
|
4
|
+
import { path as pathModule } from '@servicenow/sdk-build-core'
|
|
5
|
+
import { INVALID_XML_CHARACTERS } from './utils'
|
|
6
|
+
|
|
7
|
+
// based on tectonic code for attachments
|
|
8
|
+
// https://code.devsnc.com/dev/sn-tectonic/blob/b3ab42ce742158cb5a0d00efd540b97eeafcbdd7/core/metadata-transform-san-diego/utils/index.js#L66
|
|
9
|
+
const MAX_INLINE_CONTENT_SIZE = 4194304
|
|
10
|
+
// https://code.devsnc.com/dev/sn-tectonic/blob/b3ab42ce742158cb5a0d00efd540b97eeafcbdd7/core/metadata-transform-san-diego/attachment/index.js#L7
|
|
11
|
+
const CHUNK_SIZE = 933336
|
|
12
|
+
|
|
13
|
+
const base64 = (data: Uint8Array | Buffer | string): string => Buffer.from(data).toString('base64')
|
|
14
|
+
|
|
15
|
+
const chunkData = (data: string): string[] => {
|
|
16
|
+
const numChunks = Math.ceil(data.length / CHUNK_SIZE)
|
|
17
|
+
const chunks: string[] = new Array(numChunks)
|
|
18
|
+
for (let chunk = 0, offset = 0; chunk < numChunks; chunk += 1, offset += CHUNK_SIZE) {
|
|
19
|
+
chunks[chunk] = data.substring(offset, CHUNK_SIZE)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return chunks
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const generateId = (...parts: Array<string | number>): string => new MD5().update(parts.join(':')).digest('hex')
|
|
26
|
+
|
|
27
|
+
// based on tectonic code for validating XML content
|
|
28
|
+
// https://code.devsnc.com/dev/sn-tectonic/blob/b3ab42ce742158cb5a0d00efd540b97eeafcbdd7/core/metadata-transform-san-diego/utils/index.js#L51-L63
|
|
29
|
+
function validateCdata(data: string): boolean {
|
|
30
|
+
if (data && data.includes('<![CDATA[')) {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
if (data.match(INVALID_XML_CHARACTERS)) {
|
|
34
|
+
return false
|
|
35
|
+
}
|
|
36
|
+
return true
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const multipleRecordsToFile = (mainRecord, { config }) => {
|
|
40
|
+
const recordBuilder = unloadBuilder(config)
|
|
41
|
+
for (const record of mainRecord.flat()) {
|
|
42
|
+
const builder = recordBuilder.record(record)
|
|
43
|
+
|
|
44
|
+
record
|
|
45
|
+
.entries()
|
|
46
|
+
.sort(([a], [b]) => a.localeCompare(b)) // Sort keys to make outputs more deterministic
|
|
47
|
+
.forEach(([prop, shape]) => builder.field(prop, shape))
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
success: true,
|
|
51
|
+
value: {
|
|
52
|
+
name: `${mainRecord.getTable()}_${mainRecord.getId().getValue()}.xml`,
|
|
53
|
+
category: mainRecord.getInstallCategory(),
|
|
54
|
+
content: recordBuilder.end(),
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const attachmentRelationships = {
|
|
60
|
+
sys_attachment: {
|
|
61
|
+
via: 'table_sys_id',
|
|
62
|
+
descendant: true,
|
|
63
|
+
relationships: {
|
|
64
|
+
sys_attachment_doc: {
|
|
65
|
+
via: 'sys_attachment',
|
|
66
|
+
descendant: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const toNoOpShape = (record) => {
|
|
73
|
+
return { success: true, value: Shape.noOp(record) }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const StaticContentPlugin = Plugin.create({
|
|
77
|
+
name: 'StaticContentPlugin',
|
|
78
|
+
records: {
|
|
79
|
+
// TODO: remove when we have generic attachment support
|
|
80
|
+
sys_attachment: {
|
|
81
|
+
toShape: toNoOpShape,
|
|
82
|
+
},
|
|
83
|
+
// TODO: remove when we have generic attachment support
|
|
84
|
+
sys_attachment_doc: {
|
|
85
|
+
toShape: toNoOpShape,
|
|
86
|
+
},
|
|
87
|
+
sys_ux_lib_asset: {
|
|
88
|
+
relationships: attachmentRelationships,
|
|
89
|
+
toShape: toNoOpShape,
|
|
90
|
+
toFile: multipleRecordsToFile,
|
|
91
|
+
},
|
|
92
|
+
db_image: {
|
|
93
|
+
relationships: attachmentRelationships,
|
|
94
|
+
toShape: toNoOpShape,
|
|
95
|
+
toFile: multipleRecordsToFile,
|
|
96
|
+
},
|
|
97
|
+
sys_ux_theme_asset: {
|
|
98
|
+
relationships: attachmentRelationships,
|
|
99
|
+
toShape: toNoOpShape,
|
|
100
|
+
toFile: multipleRecordsToFile,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
files: [
|
|
104
|
+
{
|
|
105
|
+
entryPoint: true,
|
|
106
|
+
matcher: (path, { config, project }) => project.isInDir(config.staticContentDir, path),
|
|
107
|
+
toRecord(file, { project, config, factory, logger, fs }) {
|
|
108
|
+
const { path } = file
|
|
109
|
+
const relativePath = pathModule.relative(project.resolvePath(config.staticContentDir), path)
|
|
110
|
+
const ext = pathModule.extname(relativePath)
|
|
111
|
+
const normalizedExt = ext.replace('dbx', '')
|
|
112
|
+
const mimeType = mime.lookup(normalizedExt)
|
|
113
|
+
// TODO: support binary file content so we don't have to read the contents again here
|
|
114
|
+
const rawFileContent = fs.readFileSync(path)
|
|
115
|
+
const stringFileContent = file.content
|
|
116
|
+
const hash = new MD5().update(rawFileContent).digest('hex')
|
|
117
|
+
let tableName: string | undefined
|
|
118
|
+
let assetName: string | undefined
|
|
119
|
+
const uxAssetProperties = {
|
|
120
|
+
sys_package: config.scopeId,
|
|
121
|
+
mime_type: mimeType,
|
|
122
|
+
checksum: hash,
|
|
123
|
+
}
|
|
124
|
+
const recordProperties = {}
|
|
125
|
+
let useAttachment = false
|
|
126
|
+
const logSkippedWithReason = (reason: string) => {
|
|
127
|
+
// it would be nice to use diagnostics.warn here, but we don't have a compatible source for this file
|
|
128
|
+
// so we use logger instead, similar to what the server-module-plugin does
|
|
129
|
+
// https://code.devsnc.com/dev/fluent/blob/fbb5dfcf19dd3bf1ad8700de939a12817b16d0ad/packages/build-plugins/src/server-module-plugin.ts#L367-L368
|
|
130
|
+
logger.warn(`Skipping packaging of '${relativePath}'. ${reason}`)
|
|
131
|
+
}
|
|
132
|
+
if (rawFileContent.length > MAX_INLINE_CONTENT_SIZE || !validateCdata(stringFileContent)) {
|
|
133
|
+
useAttachment = true
|
|
134
|
+
}
|
|
135
|
+
Object.assign(uxAssetProperties, {
|
|
136
|
+
is_attachment: useAttachment,
|
|
137
|
+
content: useAttachment
|
|
138
|
+
? undefined
|
|
139
|
+
: Shape.from(file, stringFileContent).asString().withContentType('cdata'),
|
|
140
|
+
})
|
|
141
|
+
if (mimeType === 'text/html') {
|
|
142
|
+
// This content will be handled by the UiPage referencing it
|
|
143
|
+
} else if (mimeType === 'application/javascript') {
|
|
144
|
+
tableName = 'sys_ux_lib_asset'
|
|
145
|
+
assetName = pathModule.join(
|
|
146
|
+
config.scope,
|
|
147
|
+
relativePath.substring(0, relativePath.length - ext.length)
|
|
148
|
+
)
|
|
149
|
+
Object.assign(recordProperties, {
|
|
150
|
+
...uxAssetProperties,
|
|
151
|
+
name: assetName,
|
|
152
|
+
category: 'component',
|
|
153
|
+
es_module: true,
|
|
154
|
+
engine: 21,
|
|
155
|
+
})
|
|
156
|
+
} else if (normalizedExt === '.map') {
|
|
157
|
+
tableName = 'sys_ux_lib_asset'
|
|
158
|
+
assetName = pathModule.join(config.scope, relativePath.replace('dbx', ''))
|
|
159
|
+
Object.assign(recordProperties, {
|
|
160
|
+
...uxAssetProperties,
|
|
161
|
+
name: assetName,
|
|
162
|
+
category: 'source_map',
|
|
163
|
+
es_module: false,
|
|
164
|
+
})
|
|
165
|
+
} else if (!mimeType) {
|
|
166
|
+
logSkippedWithReason('Unknown content type.')
|
|
167
|
+
} else if (mimeType.indexOf('image/') === 0) {
|
|
168
|
+
useAttachment = true
|
|
169
|
+
tableName = 'db_image'
|
|
170
|
+
assetName = pathModule.join(config.scope, relativePath)
|
|
171
|
+
Object.assign(recordProperties, {
|
|
172
|
+
name: assetName,
|
|
173
|
+
size_bytes: rawFileContent.length,
|
|
174
|
+
active: true,
|
|
175
|
+
})
|
|
176
|
+
} else if (mimeType.indexOf('font/') === 0 || mimeType === 'text/css') {
|
|
177
|
+
useAttachment = true
|
|
178
|
+
tableName = 'sys_ux_theme_asset'
|
|
179
|
+
assetName = relativePath
|
|
180
|
+
Object.assign(recordProperties, {
|
|
181
|
+
name: assetName,
|
|
182
|
+
// this is a required field, and the only other value allowed is 'image'
|
|
183
|
+
// it doesn't affect the content type of the response
|
|
184
|
+
category: 'font',
|
|
185
|
+
})
|
|
186
|
+
} else {
|
|
187
|
+
logSkippedWithReason(`Unsupported content type ${mimeType}.`)
|
|
188
|
+
}
|
|
189
|
+
if (tableName && assetName) {
|
|
190
|
+
const mainRecord = factory.createRecord({
|
|
191
|
+
source: file,
|
|
192
|
+
table: tableName,
|
|
193
|
+
explicitId: assetName,
|
|
194
|
+
properties: recordProperties,
|
|
195
|
+
})
|
|
196
|
+
const mainRecordId = mainRecord.getId().getValue()
|
|
197
|
+
const overrideMainRecordProperties = {}
|
|
198
|
+
const attachmentRecords: Record[] = []
|
|
199
|
+
if (useAttachment) {
|
|
200
|
+
const attachmentRecordId = generateId(mainRecordId, 'sys_attachment', assetName)
|
|
201
|
+
const zipEncodedContent = gzipSync(rawFileContent, { mtime: 0 })
|
|
202
|
+
const attachmentRecord = factory.createRecord({
|
|
203
|
+
source: file,
|
|
204
|
+
table: 'sys_attachment',
|
|
205
|
+
properties: {
|
|
206
|
+
sys_id: attachmentRecordId,
|
|
207
|
+
file_name: assetName,
|
|
208
|
+
hash: hash,
|
|
209
|
+
table_name: tableName,
|
|
210
|
+
table_sys_id: mainRecordId,
|
|
211
|
+
size_bytes: rawFileContent.length,
|
|
212
|
+
size_compressed: zipEncodedContent.length,
|
|
213
|
+
chunk_size_bytes: CHUNK_SIZE,
|
|
214
|
+
compressed: true,
|
|
215
|
+
content_type: mimeType,
|
|
216
|
+
state: 'available',
|
|
217
|
+
},
|
|
218
|
+
})
|
|
219
|
+
attachmentRecords.push(attachmentRecord)
|
|
220
|
+
if (tableName === 'db_image') {
|
|
221
|
+
Object.assign(overrideMainRecordProperties, { image: attachmentRecordId })
|
|
222
|
+
}
|
|
223
|
+
const base64Encoding = base64(zipEncodedContent)
|
|
224
|
+
const chunks = chunkData(base64Encoding)
|
|
225
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
226
|
+
const sysId = generateId(mainRecordId, 'sys_attachment_doc', assetName, i)
|
|
227
|
+
attachmentRecords.push(
|
|
228
|
+
factory.createRecord({
|
|
229
|
+
source: file,
|
|
230
|
+
table: 'sys_attachment_doc',
|
|
231
|
+
properties: {
|
|
232
|
+
sys_id: sysId,
|
|
233
|
+
data: chunks[i],
|
|
234
|
+
position: i,
|
|
235
|
+
length: chunks[i]!.length,
|
|
236
|
+
sys_attachment: attachmentRecordId,
|
|
237
|
+
},
|
|
238
|
+
})
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const mergedRecord = mainRecord.merge(overrideMainRecordProperties)
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
success: true,
|
|
247
|
+
value: mergedRecord.with(...attachmentRecords),
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return { success: false }
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
})
|