@servicenow/sdk-build-plugins 3.0.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acl-plugin.d.ts +19 -0
- package/dist/acl-plugin.js +210 -0
- package/dist/acl-plugin.js.map +1 -0
- package/dist/application-menu-plugin.d.ts +18 -0
- package/dist/application-menu-plugin.js +104 -0
- package/dist/application-menu-plugin.js.map +1 -0
- package/dist/arrow-function-plugin.d.ts +16 -0
- package/dist/arrow-function-plugin.js +107 -0
- package/dist/arrow-function-plugin.js.map +1 -0
- package/dist/atf/step-configs.d.ts +37 -0
- package/dist/atf/step-configs.js +2236 -0
- package/dist/atf/step-configs.js.map +1 -0
- package/dist/atf/test-plugin.d.ts +4 -0
- package/dist/atf/test-plugin.js +591 -0
- package/dist/atf/test-plugin.js.map +1 -0
- package/dist/basic-syntax-plugin.d.ts +2 -0
- package/dist/basic-syntax-plugin.js +636 -0
- package/dist/basic-syntax-plugin.js.map +1 -0
- package/dist/business-rule-plugin.d.ts +3 -0
- package/dist/business-rule-plugin.js +205 -0
- package/dist/business-rule-plugin.js.map +1 -0
- package/dist/call-expression-plugin.d.ts +2 -0
- package/dist/call-expression-plugin.js +175 -0
- package/dist/call-expression-plugin.js.map +1 -0
- package/dist/client-script-plugin.d.ts +29 -0
- package/dist/client-script-plugin.js +157 -0
- package/dist/client-script-plugin.js.map +1 -0
- package/dist/column/column-helper.d.ts +12 -0
- package/dist/column/column-helper.js +84 -0
- package/dist/column/column-helper.js.map +1 -0
- package/dist/column/column-to-record.d.ts +3 -0
- package/dist/column/column-to-record.js +105 -0
- package/dist/column/column-to-record.js.map +1 -0
- package/dist/column-plugin.d.ts +8 -0
- package/dist/column-plugin.js +453 -0
- package/dist/column-plugin.js.map +1 -0
- package/dist/cross-scope-privilege-plugin.d.ts +15 -0
- package/dist/cross-scope-privilege-plugin.js +82 -0
- package/dist/cross-scope-privilege-plugin.js.map +1 -0
- package/dist/html-import-plugin.d.ts +2 -0
- package/dist/html-import-plugin.js +72 -0
- package/dist/html-import-plugin.js.map +1 -0
- package/dist/index.d.ts +37 -21
- package/dist/index.js +40 -45
- package/dist/index.js.map +1 -1
- package/dist/json-plugin.d.ts +15 -0
- package/dist/json-plugin.js +104 -0
- package/dist/json-plugin.js.map +1 -0
- package/dist/list-plugin.d.ts +2 -0
- package/dist/list-plugin.js +191 -0
- package/dist/list-plugin.js.map +1 -0
- package/dist/now-config-plugin.d.ts +4 -0
- package/dist/now-config-plugin.js +154 -0
- package/dist/now-config-plugin.js.map +1 -0
- package/dist/now-id-plugin.d.ts +11 -0
- package/dist/now-id-plugin.js +71 -0
- package/dist/now-id-plugin.js.map +1 -0
- package/dist/now-include-plugin.d.ts +16 -0
- package/dist/now-include-plugin.js +118 -0
- package/dist/now-include-plugin.js.map +1 -0
- package/dist/now-ref-plugin.d.ts +2 -0
- package/dist/now-ref-plugin.js +43 -0
- package/dist/now-ref-plugin.js.map +1 -0
- package/dist/now-unresolved-plugin.d.ts +2 -0
- package/dist/now-unresolved-plugin.js +32 -0
- package/dist/now-unresolved-plugin.js.map +1 -0
- package/dist/package-json-plugin.d.ts +2 -0
- package/dist/package-json-plugin.js +70 -0
- package/dist/package-json-plugin.js.map +1 -0
- package/dist/property-plugin.d.ts +2 -0
- package/dist/property-plugin.js +105 -0
- package/dist/property-plugin.js.map +1 -0
- package/dist/record-plugin.d.ts +43 -0
- package/dist/record-plugin.js +147 -0
- package/dist/record-plugin.js.map +1 -0
- package/dist/repack/index.d.ts +1 -0
- package/dist/repack/index.js +10 -2
- package/dist/repack/index.js.map +1 -1
- package/dist/repack/lint/Rules.d.ts +1 -1
- package/dist/repack/lint/Rules.js +7 -3
- package/dist/repack/lint/Rules.js.map +1 -1
- package/dist/repack/lint/index.js +1 -1
- package/dist/rest-api-plugin.d.ts +2 -0
- package/dist/rest-api-plugin.js +469 -0
- package/dist/rest-api-plugin.js.map +1 -0
- package/dist/role-plugin.d.ts +2 -0
- package/dist/role-plugin.js +117 -0
- package/dist/role-plugin.js.map +1 -0
- package/dist/script-action-plugin.d.ts +2 -0
- package/dist/script-action-plugin.js +62 -0
- package/dist/script-action-plugin.js.map +1 -0
- package/dist/script-include-plugin.d.ts +2 -0
- package/dist/script-include-plugin.js +102 -0
- package/dist/script-include-plugin.js.map +1 -0
- package/dist/server-module-plugin/index.d.ts +14 -0
- package/dist/server-module-plugin/index.js +378 -0
- package/dist/server-module-plugin/index.js.map +1 -0
- package/dist/server-module-plugin/sbom-builder.d.ts +45 -0
- package/dist/server-module-plugin/sbom-builder.js +179 -0
- package/dist/server-module-plugin/sbom-builder.js.map +1 -0
- package/dist/service-portal/angular-provider-plugin.d.ts +2 -0
- package/dist/service-portal/angular-provider-plugin.js +78 -0
- package/dist/service-portal/angular-provider-plugin.js.map +1 -0
- package/dist/service-portal/dependency-plugin.d.ts +2 -0
- package/dist/service-portal/dependency-plugin.js +235 -0
- package/dist/service-portal/dependency-plugin.js.map +1 -0
- package/dist/service-portal/widget-plugin.d.ts +6 -0
- package/dist/service-portal/widget-plugin.js +230 -0
- package/dist/service-portal/widget-plugin.js.map +1 -0
- package/dist/static-content-plugin.d.ts +2 -0
- package/dist/static-content-plugin.js +272 -0
- package/dist/static-content-plugin.js.map +1 -0
- package/dist/table-plugin.d.ts +3 -0
- package/dist/table-plugin.js +1324 -0
- package/dist/table-plugin.js.map +1 -0
- package/dist/ui-action-plugin.d.ts +2 -0
- package/dist/ui-action-plugin.js +291 -0
- package/dist/ui-action-plugin.js.map +1 -0
- package/dist/ui-page-plugin.d.ts +2 -0
- package/dist/ui-page-plugin.js +165 -0
- package/dist/ui-page-plugin.js.map +1 -0
- package/dist/user-preference-plugin.d.ts +15 -0
- package/dist/user-preference-plugin.js +63 -0
- package/dist/user-preference-plugin.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.js +72 -0
- package/dist/utils.js.map +1 -0
- package/dist/view-plugin.d.ts +2 -0
- package/dist/view-plugin.js +45 -0
- package/dist/view-plugin.js.map +1 -0
- package/package.json +17 -13
- package/src/acl-plugin.ts +256 -0
- package/src/application-menu-plugin.ts +109 -0
- package/src/arrow-function-plugin.ts +127 -0
- package/src/atf/step-configs.ts +2284 -0
- package/src/atf/test-plugin.ts +728 -0
- package/src/basic-syntax-plugin.ts +729 -0
- package/src/business-rule-plugin.ts +266 -0
- package/src/call-expression-plugin.ts +202 -0
- package/src/client-script-plugin.ts +170 -0
- package/src/column/column-helper.ts +119 -0
- package/src/column/column-to-record.ts +131 -0
- package/src/column-plugin.ts +506 -0
- package/src/cross-scope-privilege-plugin.ts +82 -0
- package/src/html-import-plugin.ts +79 -0
- package/src/index.ts +39 -21
- package/src/json-plugin.ts +128 -0
- package/src/list-plugin.ts +222 -0
- package/src/now-config-plugin.ts +194 -0
- package/src/now-id-plugin.ts +78 -0
- package/src/now-include-plugin.ts +140 -0
- package/src/now-ref-plugin.ts +48 -0
- package/src/now-unresolved-plugin.ts +30 -0
- package/src/package-json-plugin.ts +87 -0
- package/src/property-plugin.ts +118 -0
- package/src/record-plugin.ts +171 -0
- package/src/repack/index.ts +10 -1
- package/src/repack/lint/Rules.ts +5 -4
- package/src/repack/lint/index.ts +1 -1
- package/src/rest-api-plugin.ts +651 -0
- package/src/role-plugin.ts +128 -0
- package/src/script-action-plugin.ts +63 -0
- package/src/script-include-plugin.ts +110 -0
- package/src/server-module-plugin/index.ts +470 -0
- package/src/server-module-plugin/sbom-builder.ts +183 -0
- package/src/service-portal/angular-provider-plugin.ts +83 -0
- package/src/service-portal/dependency-plugin.ts +284 -0
- package/src/service-portal/widget-plugin.ts +263 -0
- package/src/static-content-plugin.ts +254 -0
- package/src/table-plugin.ts +1698 -0
- package/src/ui-action-plugin.ts +324 -0
- package/src/ui-page-plugin.ts +168 -0
- package/src/user-preference-plugin.ts +62 -0
- package/src/utils.ts +69 -0
- package/src/view-plugin.ts +46 -0
- package/dist/AttachmentPlugin.d.ts +0 -254
- package/dist/AttachmentPlugin.js +0 -220
- package/dist/AttachmentPlugin.js.map +0 -1
- package/dist/BusinessRulePlugin.d.ts +0 -30
- package/dist/BusinessRulePlugin.js +0 -149
- package/dist/BusinessRulePlugin.js.map +0 -1
- package/dist/CrossScopePrivilegePlugin.d.ts +0 -35
- package/dist/CrossScopePrivilegePlugin.js +0 -80
- package/dist/CrossScopePrivilegePlugin.js.map +0 -1
- package/dist/DefaultPlugin.d.ts +0 -86
- package/dist/DefaultPlugin.js +0 -226
- package/dist/DefaultPlugin.js.map +0 -1
- package/dist/HtmlTemplatePlugin.d.ts +0 -21
- package/dist/HtmlTemplatePlugin.js +0 -29
- package/dist/HtmlTemplatePlugin.js.map +0 -1
- package/dist/IdPlugin.d.ts +0 -28
- package/dist/IdPlugin.js +0 -68
- package/dist/IdPlugin.js.map +0 -1
- package/dist/IncludePlugin.d.ts +0 -34
- package/dist/IncludePlugin.js +0 -155
- package/dist/IncludePlugin.js.map +0 -1
- package/dist/JsonPlugin.d.ts +0 -28
- package/dist/JsonPlugin.js +0 -69
- package/dist/JsonPlugin.js.map +0 -1
- package/dist/ListPlugin.d.ts +0 -93
- package/dist/ListPlugin.js +0 -456
- package/dist/ListPlugin.js.map +0 -1
- package/dist/NowConfigPlugin.d.ts +0 -45
- package/dist/NowConfigPlugin.js +0 -64
- package/dist/NowConfigPlugin.js.map +0 -1
- package/dist/PackageJsonPlugin.d.ts +0 -34
- package/dist/PackageJsonPlugin.js +0 -63
- package/dist/PackageJsonPlugin.js.map +0 -1
- package/dist/PropertyPlugin.d.ts +0 -51
- package/dist/PropertyPlugin.js +0 -181
- package/dist/PropertyPlugin.js.map +0 -1
- package/dist/ScriptTemplatePlugin.d.ts +0 -13
- package/dist/ScriptTemplatePlugin.js +0 -55
- package/dist/ScriptTemplatePlugin.js.map +0 -1
- package/dist/ServerModulePlugin.d.ts +0 -75
- package/dist/ServerModulePlugin.js +0 -368
- package/dist/ServerModulePlugin.js.map +0 -1
- package/dist/UserPreferencePlugin.d.ts +0 -19
- package/dist/UserPreferencePlugin.js +0 -32
- package/dist/UserPreferencePlugin.js.map +0 -1
- package/dist/aclAndRole/AclPlugin.d.ts +0 -82
- package/dist/aclAndRole/AclPlugin.js +0 -262
- package/dist/aclAndRole/AclPlugin.js.map +0 -1
- package/dist/aclAndRole/RolePlugin.d.ts +0 -66
- package/dist/aclAndRole/RolePlugin.js +0 -179
- package/dist/aclAndRole/RolePlugin.js.map +0 -1
- package/dist/aclAndRole/Util.d.ts +0 -3
- package/dist/aclAndRole/Util.js +0 -90
- package/dist/aclAndRole/Util.js.map +0 -1
- package/dist/app/ApplicationMenuPlugin.d.ts +0 -34
- package/dist/app/ApplicationMenuPlugin.js +0 -112
- package/dist/app/ApplicationMenuPlugin.js.map +0 -1
- package/dist/db/ColumnPlugins.d.ts +0 -750
- package/dist/db/ColumnPlugins.js +0 -114
- package/dist/db/ColumnPlugins.js.map +0 -1
- package/dist/db/DBUtils.d.ts +0 -2
- package/dist/db/DBUtils.js +0 -27
- package/dist/db/DBUtils.js.map +0 -1
- package/dist/db/DocumentationPlugin.d.ts +0 -67
- package/dist/db/DocumentationPlugin.js +0 -258
- package/dist/db/DocumentationPlugin.js.map +0 -1
- package/dist/db/LicensingPlugin.d.ts +0 -60
- package/dist/db/LicensingPlugin.js +0 -117
- package/dist/db/LicensingPlugin.js.map +0 -1
- package/dist/db/RecordPlugin.d.ts +0 -133
- package/dist/db/RecordPlugin.js +0 -337
- package/dist/db/RecordPlugin.js.map +0 -1
- package/dist/db/TablePlugin.d.ts +0 -231
- package/dist/db/TablePlugin.js +0 -1628
- package/dist/db/TablePlugin.js.map +0 -1
- package/dist/db/index.d.ts +0 -6
- package/dist/db/index.js +0 -32
- package/dist/db/index.js.map +0 -1
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.d.ts +0 -10
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js +0 -373
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RESTSerializationUtils.d.ts +0 -13
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js +0 -177
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RestApiPlugin.d.ts +0 -81
- package/dist/scriptedRESTAPI/RestApiPlugin.js +0 -345
- package/dist/scriptedRESTAPI/RestApiPlugin.js.map +0 -1
- package/dist/scriptedRESTAPI/RestSchemaUtils.d.ts +0 -190
- package/dist/scriptedRESTAPI/RestSchemaUtils.js +0 -53
- package/dist/scriptedRESTAPI/RestSchemaUtils.js.map +0 -1
- package/dist/scriptedRESTAPI/RestUtils.d.ts +0 -69
- package/dist/scriptedRESTAPI/RestUtils.js +0 -497
- package/dist/scriptedRESTAPI/RestUtils.js.map +0 -1
- package/dist/scripts/ClientScriptPlugin.d.ts +0 -64
- package/dist/scripts/ClientScriptPlugin.js +0 -170
- package/dist/scripts/ClientScriptPlugin.js.map +0 -1
- package/dist/scripts/scriptUtils.d.ts +0 -1
- package/dist/scripts/scriptUtils.js +0 -9
- package/dist/scripts/scriptUtils.js.map +0 -1
- package/dist/uxf/ExperiencePlugin.d.ts +0 -45
- package/dist/uxf/ExperiencePlugin.js +0 -61
- package/dist/uxf/ExperiencePlugin.js.map +0 -1
- package/dist/uxf/RoutesPlugin.d.ts +0 -29
- package/dist/uxf/RoutesPlugin.js +0 -181
- package/dist/uxf/RoutesPlugin.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/cleanUxValue.d.ts +0 -4
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js +0 -65
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/api.d.ts +0 -189
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js +0 -158
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.d.ts +0 -13
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -604
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.d.ts +0 -12
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.d.ts +0 -31
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -64
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/index.d.ts +0 -3
- package/dist/uxf/UxfFormulaParser/index.js +0 -11
- package/dist/uxf/UxfFormulaParser/index.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/parser.d.ts +0 -8
- package/dist/uxf/UxfFormulaParser/parser.js +0 -87
- package/dist/uxf/UxfFormulaParser/parser.js.map +0 -1
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.d.ts +0 -8
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js +0 -17
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js.map +0 -1
- package/dist/uxf/constants.d.ts +0 -2
- package/dist/uxf/constants.js +0 -8
- package/dist/uxf/constants.js.map +0 -1
- package/dist/uxf/index.d.ts +0 -2
- package/dist/uxf/index.js +0 -11
- package/dist/uxf/index.js.map +0 -1
- package/dist/uxf/tectonicIdGenerator.d.ts +0 -12
- package/dist/uxf/tectonicIdGenerator.js +0 -79
- package/dist/uxf/tectonicIdGenerator.js.map +0 -1
- package/src/AttachmentPlugin.ts +0 -268
- package/src/BusinessRulePlugin.ts +0 -238
- package/src/CrossScopePrivilegePlugin.ts +0 -115
- package/src/DefaultPlugin.ts +0 -288
- package/src/HtmlTemplatePlugin.ts +0 -31
- package/src/IdPlugin.ts +0 -74
- package/src/IncludePlugin.ts +0 -206
- package/src/JsonPlugin.ts +0 -76
- package/src/ListPlugin.ts +0 -570
- package/src/NowConfigPlugin.ts +0 -69
- package/src/PackageJsonPlugin.ts +0 -68
- package/src/PropertyPlugin.ts +0 -237
- package/src/ScriptTemplatePlugin.ts +0 -53
- package/src/ServerModulePlugin.ts +0 -480
- package/src/UserPreferencePlugin.ts +0 -45
- package/src/aclAndRole/AclPlugin.ts +0 -420
- package/src/aclAndRole/RolePlugin.ts +0 -254
- package/src/aclAndRole/Util.ts +0 -113
- package/src/app/ApplicationMenuPlugin.ts +0 -165
- package/src/db/ColumnPlugins.ts +0 -114
- package/src/db/DBUtils.ts +0 -36
- package/src/db/DocumentationPlugin.ts +0 -316
- package/src/db/LicensingPlugin.ts +0 -138
- package/src/db/RecordPlugin.ts +0 -459
- package/src/db/TablePlugin.ts +0 -2070
- package/src/db/index.ts +0 -6
- package/src/scriptedRESTAPI/RESTDeserializationUtils.ts +0 -419
- package/src/scriptedRESTAPI/RESTSerializationUtils.ts +0 -228
- package/src/scriptedRESTAPI/RestApiPlugin.ts +0 -469
- package/src/scriptedRESTAPI/RestSchemaUtils.ts +0 -72
- package/src/scriptedRESTAPI/RestUtils.ts +0 -569
- package/src/scripts/ClientScriptPlugin.ts +0 -257
- package/src/scripts/scriptUtils.ts +0 -5
- package/src/uxf/ExperiencePlugin.ts +0 -67
- package/src/uxf/RoutesPlugin.ts +0 -211
- package/src/uxf/UxfFormulaParser/cleanUxValue.ts +0 -73
- package/src/uxf/UxfFormulaParser/grammerParser/api.js +0 -166
- package/src/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +0 -606
- package/src/uxf/UxfFormulaParser/grammerParser/grammarParser.js +0 -551
- package/src/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +0 -65
- package/src/uxf/UxfFormulaParser/index.ts +0 -4
- package/src/uxf/UxfFormulaParser/parser.ts +0 -64
- package/src/uxf/UxfFormulaParser/utils/getErrorMsg.ts +0 -13
- package/src/uxf/constants.ts +0 -4
- package/src/uxf/index.ts +0 -2
- package/src/uxf/tectonicIdGenerator.ts +0 -78
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CallExpressionShape, Plugin } from '@servicenow/sdk-build-core'
|
|
2
|
+
import { NowIdShape } from '../now-id-plugin'
|
|
3
|
+
|
|
4
|
+
export const SPAngularProviderPlugin = Plugin.create({
|
|
5
|
+
name: 'SPAngularProviderPlugin',
|
|
6
|
+
records: {
|
|
7
|
+
sp_angular_provider: {
|
|
8
|
+
relationships: {
|
|
9
|
+
m2m_sp_ng_pro_sp_ng_pro: { via: 'required_by', descendant: true },
|
|
10
|
+
},
|
|
11
|
+
toShape(record, { descendants }) {
|
|
12
|
+
const requiredProviders = descendants.query('m2m_sp_ng_pro_sp_ng_pro').map((p) => p.get('requires'))
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
success: true,
|
|
16
|
+
value: new CallExpressionShape({
|
|
17
|
+
source: record,
|
|
18
|
+
callee: 'SPAngularProvider',
|
|
19
|
+
args: [
|
|
20
|
+
record.transform(({ $ }) => ({
|
|
21
|
+
$id: $.val(NowIdShape.from(record)),
|
|
22
|
+
name: $,
|
|
23
|
+
type: $,
|
|
24
|
+
script: $.def(''),
|
|
25
|
+
requires: $.val(requiredProviders.length > 0 ? requiredProviders : undefined),
|
|
26
|
+
})),
|
|
27
|
+
],
|
|
28
|
+
}),
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
m2m_sp_ng_pro_sp_ng_pro: {
|
|
33
|
+
coalesce: ['required_by', 'requires'],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
shapes: [
|
|
37
|
+
{
|
|
38
|
+
shape: CallExpressionShape,
|
|
39
|
+
fileTypes: ['fluent'],
|
|
40
|
+
async toRecord(callExpression, { factory, diagnostics }) {
|
|
41
|
+
if (callExpression.getCallee() !== 'SPAngularProvider') {
|
|
42
|
+
return { success: false }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const providerObj = callExpression.getArgument(0).asObject()
|
|
46
|
+
const providerId = providerObj.get('$id')
|
|
47
|
+
|
|
48
|
+
const requires = providerObj.get('requires').ifArray()?.getElements() || []
|
|
49
|
+
|
|
50
|
+
requires
|
|
51
|
+
.filter((provider) => provider.equals(providerId))
|
|
52
|
+
.forEach((provider) => diagnostics.error(provider, 'recursive dependency detected'))
|
|
53
|
+
|
|
54
|
+
const providerRecord = factory.createRecord({
|
|
55
|
+
source: callExpression,
|
|
56
|
+
table: 'sp_angular_provider',
|
|
57
|
+
explicitId: providerObj.get('$id'),
|
|
58
|
+
properties: providerObj.transform(({ $ }) => ({
|
|
59
|
+
name: $,
|
|
60
|
+
type: $.def('directive'),
|
|
61
|
+
script: $.def(''),
|
|
62
|
+
})),
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
success: true,
|
|
67
|
+
value: providerRecord.with(
|
|
68
|
+
...requires.map((child) => {
|
|
69
|
+
return factory.createRecord({
|
|
70
|
+
source: providerObj,
|
|
71
|
+
table: 'm2m_sp_ng_pro_sp_ng_pro',
|
|
72
|
+
properties: {
|
|
73
|
+
required_by: providerRecord.getId(),
|
|
74
|
+
requires: child.ifString()?.getValue() ?? child.ifRecord()?.getId(),
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
),
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
})
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CallExpressionShape,
|
|
3
|
+
type Diagnostics,
|
|
4
|
+
type Factory,
|
|
5
|
+
Plugin,
|
|
6
|
+
type Record,
|
|
7
|
+
type Shape,
|
|
8
|
+
type RecordId,
|
|
9
|
+
} from '@servicenow/sdk-build-core'
|
|
10
|
+
import { toReference } from '../utils'
|
|
11
|
+
import { NowIdShape } from '../now-id-plugin'
|
|
12
|
+
|
|
13
|
+
export const SPWidgetDependencyPlugin = Plugin.create({
|
|
14
|
+
name: 'SPWidgetDependencyPlugin',
|
|
15
|
+
records: {
|
|
16
|
+
sp_dependency: {
|
|
17
|
+
relationships: {
|
|
18
|
+
m2m_sp_dependency_css_include: { via: 'sp_dependency', descendant: true },
|
|
19
|
+
m2m_sp_dependency_js_include: { via: 'sp_dependency', descendant: true },
|
|
20
|
+
},
|
|
21
|
+
toShape(record, { descendants }) {
|
|
22
|
+
const cssIncludeRecords = descendants.query('m2m_sp_dependency_css_include')
|
|
23
|
+
const cssIncludes = cssIncludeRecords
|
|
24
|
+
.map((m2m) => ({ order: m2m.get('order').toNumber(), include: m2m.get('sp_css_include') }))
|
|
25
|
+
.sort((a, b) => a.order.getValue() - b.order.getValue())
|
|
26
|
+
|
|
27
|
+
const jsIncludeRecords = descendants.query('m2m_sp_dependency_js_include')
|
|
28
|
+
const jsIncludes = jsIncludeRecords
|
|
29
|
+
.map((m2m) => ({ order: m2m.get('order').toNumber(), include: m2m.get('sp_js_include') }))
|
|
30
|
+
.sort((a, b) => a.order.getValue() - b.order.getValue())
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
value: new CallExpressionShape({
|
|
35
|
+
source: record,
|
|
36
|
+
callee: 'SPWidgetDependency',
|
|
37
|
+
args: [
|
|
38
|
+
record.transform(({ $ }) => ({
|
|
39
|
+
$id: $.val(NowIdShape.from(record)),
|
|
40
|
+
name: $,
|
|
41
|
+
angularModuleName: $.from('module'),
|
|
42
|
+
cssIncludes: $.val(cssIncludes.length > 0 ? cssIncludes : undefined),
|
|
43
|
+
jsIncludes: $.val(jsIncludes.length > 0 ? jsIncludes : undefined),
|
|
44
|
+
})),
|
|
45
|
+
],
|
|
46
|
+
}),
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
sp_js_include: {
|
|
51
|
+
relationships: {
|
|
52
|
+
m2m_sp_dependency_js_include: { via: 'sp_js_include', descendant: true },
|
|
53
|
+
},
|
|
54
|
+
toShape(record) {
|
|
55
|
+
return {
|
|
56
|
+
success: true,
|
|
57
|
+
value: new CallExpressionShape({
|
|
58
|
+
source: record,
|
|
59
|
+
callee: 'JsInclude',
|
|
60
|
+
args: [
|
|
61
|
+
record.transform(({ $ }) => ({
|
|
62
|
+
$id: $.val(NowIdShape.from(record)),
|
|
63
|
+
name: $.from('display_name'),
|
|
64
|
+
url: $.def(''),
|
|
65
|
+
sysUiScript: $.from('sys_ui_script').def(''),
|
|
66
|
+
})),
|
|
67
|
+
],
|
|
68
|
+
}),
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
sp_css_include: {
|
|
73
|
+
relationships: {
|
|
74
|
+
m2m_sp_dependency_css_include: { via: 'sp_css_include', descendant: true },
|
|
75
|
+
},
|
|
76
|
+
toShape(record) {
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
value: new CallExpressionShape({
|
|
80
|
+
source: record,
|
|
81
|
+
callee: 'CssInclude',
|
|
82
|
+
args: [
|
|
83
|
+
record.transform(({ $ }) => ({
|
|
84
|
+
$id: $.val(NowIdShape.from(record)),
|
|
85
|
+
name: $,
|
|
86
|
+
url: record.get('url').getValue() ? $ : undefined,
|
|
87
|
+
spCss: $.from('sp_css').def(''),
|
|
88
|
+
lazyLoad: $.from('lazy_load').toBoolean().def(false),
|
|
89
|
+
rtlCssUrl: $.from('rtl_css_file_url').def(''),
|
|
90
|
+
})),
|
|
91
|
+
],
|
|
92
|
+
}),
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
m2m_sp_dependency_css_include: {
|
|
97
|
+
coalesce: ['sp_css_include', 'sp_dependency'],
|
|
98
|
+
},
|
|
99
|
+
m2m_sp_dependency_js_include: {
|
|
100
|
+
coalesce: ['sp_js_include', 'sp_dependency'],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
shapes: [
|
|
104
|
+
{
|
|
105
|
+
shape: CallExpressionShape,
|
|
106
|
+
fileTypes: ['fluent'],
|
|
107
|
+
async toRecord(callExpression, { diagnostics, factory }) {
|
|
108
|
+
if (callExpression.getCallee() !== 'JsInclude') {
|
|
109
|
+
return { success: false }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const jsInclude = callExpression.getArgument(0).asObject()
|
|
113
|
+
const jsIncludeId = jsInclude.get('$id')
|
|
114
|
+
const urlDefined = jsInclude.get('url').isDefined()
|
|
115
|
+
const uiScriptDefined = jsInclude.get('sysUiScript').isDefined()
|
|
116
|
+
const source = urlDefined ? 'url' : 'local'
|
|
117
|
+
if ((!urlDefined && !uiScriptDefined) || (urlDefined && uiScriptDefined)) {
|
|
118
|
+
diagnostics.error(
|
|
119
|
+
jsInclude,
|
|
120
|
+
`JsInclude must define either a url or sysUiScript property, but not both`
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
success: true,
|
|
126
|
+
value: factory.createRecord({
|
|
127
|
+
source: callExpression,
|
|
128
|
+
table: 'sp_js_include',
|
|
129
|
+
explicitId: jsIncludeId,
|
|
130
|
+
properties: jsInclude.transform(({ $ }) => ({
|
|
131
|
+
display_name: $.from('name'),
|
|
132
|
+
source: $.val(source),
|
|
133
|
+
sys_ui_script: $.from('sysUiScript').map(toReference),
|
|
134
|
+
url: $.from('url').def(''),
|
|
135
|
+
})),
|
|
136
|
+
}),
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
shape: CallExpressionShape,
|
|
142
|
+
fileTypes: ['fluent'],
|
|
143
|
+
async toRecord(callExpression, { diagnostics, factory }) {
|
|
144
|
+
if (callExpression.getCallee() !== 'CssInclude') {
|
|
145
|
+
return { success: false }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const cssInclude = callExpression.getArgument(0).asObject()
|
|
149
|
+
const cssIncludeId = cssInclude.get('$id')
|
|
150
|
+
const urlDefined = cssInclude.get('url').isDefined()
|
|
151
|
+
const cssDefined = cssInclude.get('spCss').isDefined()
|
|
152
|
+
if ((!urlDefined && !cssDefined) || (urlDefined && cssDefined)) {
|
|
153
|
+
diagnostics.error(cssInclude, `CssInclude must define either a url or spCss property, but not both`)
|
|
154
|
+
}
|
|
155
|
+
const source = urlDefined ? 'url' : 'local'
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
success: true,
|
|
159
|
+
value: factory.createRecord({
|
|
160
|
+
source: callExpression,
|
|
161
|
+
table: 'sp_css_include',
|
|
162
|
+
explicitId: cssIncludeId,
|
|
163
|
+
properties: cssInclude.transform(({ $ }) => ({
|
|
164
|
+
lazy_load: $.from('lazyLoad').def(false),
|
|
165
|
+
name: $,
|
|
166
|
+
rtl_css_file_url: $.from('rtlCssUrl').def(''),
|
|
167
|
+
source: $.val(source),
|
|
168
|
+
sp_css: $.from('spCss').map(toReference),
|
|
169
|
+
url: $.from('url').def(''),
|
|
170
|
+
})),
|
|
171
|
+
}),
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
shape: CallExpressionShape,
|
|
177
|
+
fileTypes: ['fluent'],
|
|
178
|
+
async toRecord(callExpression, { diagnostics, factory }) {
|
|
179
|
+
if (callExpression.getCallee() !== 'SPWidgetDependency') {
|
|
180
|
+
return { success: false }
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const dependency = callExpression.getArgument(0).asObject()
|
|
184
|
+
const portals =
|
|
185
|
+
(dependency
|
|
186
|
+
.get('portalsForPageLoad')
|
|
187
|
+
?.ifArray()
|
|
188
|
+
?.map((p) => {
|
|
189
|
+
if (p.isString()) {
|
|
190
|
+
return p.getValue()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (p.isRecord()) {
|
|
194
|
+
return p.getId()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
diagnostics.error(p, `Must be a sys_id or Record<'sp_portal'>`)
|
|
198
|
+
return undefined
|
|
199
|
+
})
|
|
200
|
+
.filter((guid) => guid) as string[]) || []
|
|
201
|
+
|
|
202
|
+
const dependencyRecord = factory.createRecord({
|
|
203
|
+
source: callExpression,
|
|
204
|
+
table: 'sp_dependency',
|
|
205
|
+
explicitId: dependency.get('$id'),
|
|
206
|
+
properties: dependency.transform(({ $ }) => ({
|
|
207
|
+
name: $,
|
|
208
|
+
module: $.from('angularModuleName').def(''),
|
|
209
|
+
page_load: $.from('includeOnPageLoad').def(false),
|
|
210
|
+
sp_portals: $.val(portals.toString()),
|
|
211
|
+
})),
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
const cssIncludes = getIncludeRecords(
|
|
215
|
+
dependency.get('cssIncludes'),
|
|
216
|
+
dependencyRecord.getId(),
|
|
217
|
+
factory,
|
|
218
|
+
'm2m_sp_dependency_css_include',
|
|
219
|
+
'sp_css_include',
|
|
220
|
+
diagnostics
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
const jsIncludes = getIncludeRecords(
|
|
224
|
+
dependency.get('jsIncludes'),
|
|
225
|
+
dependencyRecord.getId(),
|
|
226
|
+
factory,
|
|
227
|
+
'm2m_sp_dependency_js_include',
|
|
228
|
+
'sp_js_include',
|
|
229
|
+
diagnostics
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
success: true,
|
|
234
|
+
value: dependencyRecord.with(...cssIncludes, ...jsIncludes),
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
function getIncludeRecords(
|
|
242
|
+
shape: Shape,
|
|
243
|
+
dependencyId: Shape,
|
|
244
|
+
factory: Factory,
|
|
245
|
+
m2mTable: string,
|
|
246
|
+
includeTable: string,
|
|
247
|
+
diagnostics: Diagnostics
|
|
248
|
+
) {
|
|
249
|
+
return (
|
|
250
|
+
(shape
|
|
251
|
+
?.ifArray()
|
|
252
|
+
?.map((include) => {
|
|
253
|
+
const includeProps = include.ifObject()?.get('include')
|
|
254
|
+
|
|
255
|
+
let includeId: string | RecordId
|
|
256
|
+
if (includeProps?.isString()) {
|
|
257
|
+
includeId = includeProps.toString().getValue()
|
|
258
|
+
} else if (includeProps?.isRecord()) {
|
|
259
|
+
includeId = includeProps.getId()
|
|
260
|
+
} else {
|
|
261
|
+
const necessaryPlugin = includeTable === 'sp_js_include' ? 'JsInclude' : 'CssInclude'
|
|
262
|
+
diagnostics.error(
|
|
263
|
+
includeProps!,
|
|
264
|
+
`include must contain a valid ${necessaryPlugin}, Record<'${includeTable}'> or sys_id'`
|
|
265
|
+
)
|
|
266
|
+
return undefined
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const m2mProps = {
|
|
270
|
+
[includeTable]: includeId,
|
|
271
|
+
sp_dependency: dependencyId,
|
|
272
|
+
}
|
|
273
|
+
return factory.createRecord({
|
|
274
|
+
source: shape,
|
|
275
|
+
table: m2mTable,
|
|
276
|
+
properties: {
|
|
277
|
+
order: include.ifObject()?.get('order').asNumber().getValue() || 100,
|
|
278
|
+
...m2mProps,
|
|
279
|
+
},
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
.filter((rec) => rec) as Record[]) || []
|
|
283
|
+
)
|
|
284
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { CallExpressionShape, isGUID, Plugin, type Shape } from '@servicenow/sdk-build-core'
|
|
2
|
+
import { noThrow, reverseObject } from '../utils'
|
|
3
|
+
import { type SPTemplate, WidgetCategories } from '@servicenow/sdk-core/runtime/service-portal'
|
|
4
|
+
import { NowIdShape } from '../now-id-plugin'
|
|
5
|
+
import { NowIncludeShape } from '../now-include-plugin'
|
|
6
|
+
|
|
7
|
+
export const SPWidgetPlugin = Plugin.create({
|
|
8
|
+
name: 'SPWidgetPlugin',
|
|
9
|
+
records: {
|
|
10
|
+
sp_widget: {
|
|
11
|
+
relationships: {
|
|
12
|
+
m2m_sp_widget_dependency: { via: 'sp_widget', descendant: true },
|
|
13
|
+
m2m_sp_ng_pro_sp_widget: { via: 'sp_widget', descendant: true },
|
|
14
|
+
sp_ng_template: { via: 'sp_widget', descendant: true },
|
|
15
|
+
},
|
|
16
|
+
toShape(record, { descendants }) {
|
|
17
|
+
const dependencies = descendants.query('m2m_sp_widget_dependency')
|
|
18
|
+
const angularProviders = descendants.query('m2m_sp_ng_pro_sp_widget')
|
|
19
|
+
const templates = descendants.query('sp_ng_template').map((template) => {
|
|
20
|
+
return {
|
|
21
|
+
$id: template.getId(),
|
|
22
|
+
id: template.get('id'),
|
|
23
|
+
htmlTemplate: template.get('template'),
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const category = reverseObject(WidgetCategories)[record.get('category').ifString()?.getValue() || '']
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
success: true,
|
|
31
|
+
value: new CallExpressionShape({
|
|
32
|
+
source: record,
|
|
33
|
+
callee: 'SPWidget',
|
|
34
|
+
args: [
|
|
35
|
+
record.transform(({ $ }) => ({
|
|
36
|
+
$id: $.val(NowIdShape.from(record)),
|
|
37
|
+
name: $,
|
|
38
|
+
category: $.val(category).def('custom'),
|
|
39
|
+
clientScript: $.from('client_script').def(''),
|
|
40
|
+
serverScript: $.from('script').def(''),
|
|
41
|
+
controllerAs: $.from('controller_as').def('c'),
|
|
42
|
+
htmlTemplate: $.from('template').def(''),
|
|
43
|
+
customCss: $.from('css').def(''),
|
|
44
|
+
dataTable: $.from('data_table').def('sp_instance'),
|
|
45
|
+
demoData: $.from('demo_data')
|
|
46
|
+
.map((d) => {
|
|
47
|
+
const json = d.ifString()?.getValue()
|
|
48
|
+
|
|
49
|
+
const parsed = noThrow(() => json && JSON.parse(json))
|
|
50
|
+
return parsed instanceof Error ? json : parsed
|
|
51
|
+
})
|
|
52
|
+
.def(''),
|
|
53
|
+
description: $.def(''),
|
|
54
|
+
docs: $.def(''),
|
|
55
|
+
fields: $.from('field_list')
|
|
56
|
+
.map((fields) => {
|
|
57
|
+
const fieldStr = fields.ifString()?.getValue()
|
|
58
|
+
return fieldStr && fieldStr.split(',')
|
|
59
|
+
})
|
|
60
|
+
.def(''),
|
|
61
|
+
hasPreview: $.from('has_preview').toBoolean().def(false),
|
|
62
|
+
id: $.def(''),
|
|
63
|
+
internal: $.toBoolean().def(false),
|
|
64
|
+
linkScript: $.from('link').def(''),
|
|
65
|
+
roles: $.map((role) => {
|
|
66
|
+
const roleStr = role.ifString()?.getValue()
|
|
67
|
+
return roleStr && roleStr.split(',')
|
|
68
|
+
}).def(''),
|
|
69
|
+
servicenow: $.toBoolean().def(false),
|
|
70
|
+
optionSchema: $.from('option_schema')
|
|
71
|
+
.map((v) => {
|
|
72
|
+
const json = v.ifString()?.getValue()
|
|
73
|
+
const parsed = noThrow(() => json && JSON.parse(json))
|
|
74
|
+
return parsed instanceof Error ? json : parsed
|
|
75
|
+
})
|
|
76
|
+
.def(''),
|
|
77
|
+
public: $.toBoolean().def(false),
|
|
78
|
+
dependencies: $.val(
|
|
79
|
+
dependencies.length > 0
|
|
80
|
+
? dependencies.map((dep) => dep.get('sp_dependency'))
|
|
81
|
+
: undefined
|
|
82
|
+
),
|
|
83
|
+
angularProviders: $.val(
|
|
84
|
+
angularProviders.length > 0
|
|
85
|
+
? angularProviders.map((ap) => ap.get('sp_angular_provider'))
|
|
86
|
+
: undefined
|
|
87
|
+
),
|
|
88
|
+
templates: $.val(templates.length > 0 ? templates : undefined),
|
|
89
|
+
})),
|
|
90
|
+
],
|
|
91
|
+
}),
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
m2m_sp_widget_dependency: {
|
|
96
|
+
coalesce: ['sp_widget', 'sp_dependency'],
|
|
97
|
+
},
|
|
98
|
+
m2m_sp_ng_pro_sp_widget: {
|
|
99
|
+
coalesce: ['sp_widget', 'sp_angular_provider'],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
shapes: [
|
|
103
|
+
{
|
|
104
|
+
shape: CallExpressionShape,
|
|
105
|
+
fileTypes: ['fluent'],
|
|
106
|
+
async toRecord(callExpression, { diagnostics, factory, config }) {
|
|
107
|
+
if (callExpression.getCallee() !== 'SPWidget') {
|
|
108
|
+
return { success: false }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const widget = callExpression.getArgument(0).asObject()
|
|
112
|
+
const dependencies =
|
|
113
|
+
widget
|
|
114
|
+
.get('dependencies')
|
|
115
|
+
.ifArray()
|
|
116
|
+
?.map((dep) => (dep.isString() ? dep.getValue() : dep.ifRecord()?.getId())) || []
|
|
117
|
+
const angularProviders =
|
|
118
|
+
widget
|
|
119
|
+
.get('angularProviders')
|
|
120
|
+
.ifArray()
|
|
121
|
+
?.map((ap) => (ap.isString() ? ap.getValue() : ap.ifRecord()?.getId())) || []
|
|
122
|
+
|
|
123
|
+
const templates =
|
|
124
|
+
widget
|
|
125
|
+
.get('templates')
|
|
126
|
+
.ifArray()
|
|
127
|
+
?.map((shp) => shp.getValue() as SPTemplate) || []
|
|
128
|
+
const widgetId = widget.get('id').ifString()
|
|
129
|
+
if (widgetId && !/^[a-zA-Z0-9_-]+$/g.test(widgetId.getValue())) {
|
|
130
|
+
diagnostics.error(
|
|
131
|
+
widgetId.getOriginalNode(),
|
|
132
|
+
`Invalid value: must contain only alphanumeric, -, or _ characters`
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const roles = widget
|
|
137
|
+
.get('roles')
|
|
138
|
+
.ifArray()
|
|
139
|
+
?.map((role) => {
|
|
140
|
+
if (role.isString()) {
|
|
141
|
+
return role
|
|
142
|
+
}
|
|
143
|
+
if (role.isRecord()) {
|
|
144
|
+
return role.get('name')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return undefined
|
|
148
|
+
})
|
|
149
|
+
.filter((role) => role) as Shape[] | undefined
|
|
150
|
+
|
|
151
|
+
if (roles) {
|
|
152
|
+
roles
|
|
153
|
+
.filter((role) => isGUID(role.getValue() as string))
|
|
154
|
+
.forEach((role) =>
|
|
155
|
+
diagnostics.error(
|
|
156
|
+
role!.getOriginalNode(),
|
|
157
|
+
`expecting role names or role records created by the Role or Record plugins, not sys_ids`
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const controller = widget.get('controllerAs').ifString()?.getValue() || 'c'
|
|
163
|
+
const servicenow =
|
|
164
|
+
(widget.get('servicenow').ifBoolean()?.getValue() &&
|
|
165
|
+
(config.scope.startsWith('sn_') || config.scope.startsWith('snc_'))) ||
|
|
166
|
+
false
|
|
167
|
+
|
|
168
|
+
const widgetRecord = factory.createRecord({
|
|
169
|
+
source: callExpression,
|
|
170
|
+
table: 'sp_widget',
|
|
171
|
+
explicitId: widget.get('$id'),
|
|
172
|
+
properties: widget.transform(({ $ }) => ({
|
|
173
|
+
name: $,
|
|
174
|
+
category: $.map((v) => WidgetCategories[v.ifString()?.getValue() || '']).def('custom'),
|
|
175
|
+
client_script: $.from('clientScript').def(getDefaultClientScript(controller)),
|
|
176
|
+
script: $.from('serverScript').def(SP_WIDGET_DEFAULT_SERVER_SCRIPT),
|
|
177
|
+
controller_as: $.from('controllerAs').def('c'),
|
|
178
|
+
template: $.from('htmlTemplate').def(SP_WIDGET_DEFAULT_HTML_TEMPLATE),
|
|
179
|
+
css: $.from('customCss').def(''),
|
|
180
|
+
data_table: $.from('dataTable').def('sp_instance'),
|
|
181
|
+
demo_data: $.from('demoData')
|
|
182
|
+
.map((v) =>
|
|
183
|
+
v.ifString() || v instanceof NowIncludeShape ? v : JSON.stringify(v.getValue())
|
|
184
|
+
)
|
|
185
|
+
.def(''),
|
|
186
|
+
description: $.def(''),
|
|
187
|
+
docs: $.map((v) => (v.isString() ? v : v.ifRecord()?.getId())),
|
|
188
|
+
field_list: $.from('fields')
|
|
189
|
+
.map((v) => v.getValue()?.toString())
|
|
190
|
+
.def(''),
|
|
191
|
+
has_preview: $.from('hasPreview').toBoolean().def(false),
|
|
192
|
+
id: $.def(''),
|
|
193
|
+
internal: $.def(false),
|
|
194
|
+
servicenow: $.val(servicenow),
|
|
195
|
+
link: $.from('linkScript').def(SP_WIDGET_DEFAULT_LINK_SCRIPT),
|
|
196
|
+
roles: $.val(roles?.map((r) => r.getValue()).toString()).def(''),
|
|
197
|
+
option_schema: $.from('optionSchema')
|
|
198
|
+
.map((v) => {
|
|
199
|
+
const json = v.getValue()
|
|
200
|
+
return json && JSON.stringify(json)
|
|
201
|
+
})
|
|
202
|
+
.def(''),
|
|
203
|
+
public: $.def(false),
|
|
204
|
+
})),
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
success: true,
|
|
209
|
+
value: widgetRecord.with(
|
|
210
|
+
...templates.map((template: SPTemplate) => {
|
|
211
|
+
return factory.createRecord({
|
|
212
|
+
source: widget,
|
|
213
|
+
table: 'sp_ng_template',
|
|
214
|
+
explicitId: template.$id as string,
|
|
215
|
+
properties: {
|
|
216
|
+
id: template.id,
|
|
217
|
+
sp_widget: widgetRecord.getId(),
|
|
218
|
+
template: template.htmlTemplate,
|
|
219
|
+
},
|
|
220
|
+
})
|
|
221
|
+
}),
|
|
222
|
+
...dependencies.map((dep) => {
|
|
223
|
+
return factory.createRecord({
|
|
224
|
+
source: widget,
|
|
225
|
+
table: 'm2m_sp_widget_dependency',
|
|
226
|
+
properties: {
|
|
227
|
+
sp_dependency: dep!,
|
|
228
|
+
sp_widget: widgetRecord.getId(),
|
|
229
|
+
},
|
|
230
|
+
})
|
|
231
|
+
}),
|
|
232
|
+
...angularProviders.map((ap) => {
|
|
233
|
+
return factory.createRecord({
|
|
234
|
+
source: widget,
|
|
235
|
+
table: 'm2m_sp_ng_pro_sp_widget',
|
|
236
|
+
properties: {
|
|
237
|
+
sp_angular_provider: ap!,
|
|
238
|
+
sp_widget: widgetRecord.getId(),
|
|
239
|
+
},
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
),
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
export const getDefaultClientScript = (controller: string) => `api.controller = function () {
|
|
250
|
+
/* widget controller */
|
|
251
|
+
var ${controller} = this;
|
|
252
|
+
};
|
|
253
|
+
`
|
|
254
|
+
|
|
255
|
+
export const SP_WIDGET_DEFAULT_LINK_SCRIPT = `function link(scope, element, attrs, controller) {
|
|
256
|
+
}`
|
|
257
|
+
|
|
258
|
+
export const SP_WIDGET_DEFAULT_SERVER_SCRIPT = `(function () {
|
|
259
|
+
/* populate the 'data' object */
|
|
260
|
+
/* e.g., data.table = $sp.getValue('table'); */
|
|
261
|
+
})();`
|
|
262
|
+
|
|
263
|
+
export const SP_WIDGET_DEFAULT_HTML_TEMPLATE = `<div><!-- your widget template --></div>`
|