@servicenow/sdk-build-plugins 2.1.4 → 2.2.2
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/AttachmentPlugin.d.ts +6 -7
- package/dist/AttachmentPlugin.js +8 -6
- package/dist/AttachmentPlugin.js.map +1 -1
- package/dist/BusinessRulePlugin.d.ts +5 -5
- package/dist/BusinessRulePlugin.js +4 -4
- package/dist/BusinessRulePlugin.js.map +1 -1
- package/dist/CrossScopePrivilegePlugin.d.ts +5 -5
- package/dist/CrossScopePrivilegePlugin.js +1 -2
- package/dist/CrossScopePrivilegePlugin.js.map +1 -1
- package/dist/DefaultPlugin.d.ts +19 -11
- package/dist/DefaultPlugin.js +23 -51
- package/dist/DefaultPlugin.js.map +1 -1
- package/dist/HtmlTemplatePlugin.d.ts +2 -2
- package/dist/HtmlTemplatePlugin.js +3 -26
- package/dist/HtmlTemplatePlugin.js.map +1 -1
- package/dist/IdPlugin.d.ts +5 -4
- package/dist/IdPlugin.js +5 -9
- package/dist/IdPlugin.js.map +1 -1
- package/dist/JsonPlugin.d.ts +8 -3
- package/dist/JsonPlugin.js +6 -11
- package/dist/JsonPlugin.js.map +1 -1
- package/dist/ListPlugin.d.ts +6 -7
- package/dist/ListPlugin.js +17 -19
- package/dist/ListPlugin.js.map +1 -1
- package/dist/NowConfigPlugin.d.ts +1 -1
- package/dist/NowConfigPlugin.js +5 -31
- package/dist/NowConfigPlugin.js.map +1 -1
- package/dist/PackageJsonPlugin.d.ts +1 -1
- package/dist/PackageJsonPlugin.js +1 -1
- package/dist/PackageJsonPlugin.js.map +1 -1
- package/dist/PropertyPlugin.d.ts +5 -66
- package/dist/PropertyPlugin.js +6 -12
- package/dist/PropertyPlugin.js.map +1 -1
- package/dist/ScriptTemplatePlugin.d.ts +1 -1
- package/dist/ScriptTemplatePlugin.js +5 -5
- package/dist/ScriptTemplatePlugin.js.map +1 -1
- package/dist/ServerModulePlugin.d.ts +5 -6
- package/dist/ServerModulePlugin.js +10 -39
- package/dist/ServerModulePlugin.js.map +1 -1
- package/dist/UserPreferencePlugin.d.ts +1 -1
- package/dist/aclAndRole/AclPlugin.d.ts +44 -28
- package/dist/aclAndRole/AclPlugin.js +30 -33
- package/dist/aclAndRole/AclPlugin.js.map +1 -1
- package/dist/aclAndRole/RolePlugin.d.ts +5 -6
- package/dist/aclAndRole/RolePlugin.js +6 -7
- package/dist/aclAndRole/RolePlugin.js.map +1 -1
- package/dist/aclAndRole/Util.js +7 -30
- package/dist/aclAndRole/Util.js.map +1 -1
- package/dist/app/ApplicationMenuPlugin.d.ts +5 -5
- package/dist/app/ApplicationMenuPlugin.js +2 -3
- package/dist/app/ApplicationMenuPlugin.js.map +1 -1
- package/dist/atf/TestPlugin.d.ts +3 -3
- package/dist/atf/TestPlugin.js +1 -1
- package/dist/atf/TestPlugin.js.map +1 -1
- package/dist/db/ColumnPlugins.d.ts +85 -85
- package/dist/db/ColumnPlugins.js +17 -19
- package/dist/db/ColumnPlugins.js.map +1 -1
- package/dist/db/DocumentationPlugin.d.ts +6 -6
- package/dist/db/DocumentationPlugin.js +17 -49
- package/dist/db/DocumentationPlugin.js.map +1 -1
- package/dist/db/RecordPlugin.d.ts +7 -101
- package/dist/db/RecordPlugin.js +25 -24
- package/dist/db/RecordPlugin.js.map +1 -1
- package/dist/db/TablePlugin.d.ts +9 -610
- package/dist/db/TablePlugin.js +185 -84
- package/dist/db/TablePlugin.js.map +1 -1
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.d.ts +0 -2
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js +17 -18
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js.map +1 -1
- package/dist/scriptedRESTAPI/RESTSerializationUtils.d.ts +1 -3
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js +0 -1
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js.map +1 -1
- package/dist/scriptedRESTAPI/RestApiPlugin.d.ts +3 -4
- package/dist/scriptedRESTAPI/RestApiPlugin.js +7 -33
- package/dist/scriptedRESTAPI/RestApiPlugin.js.map +1 -1
- package/dist/scriptedRESTAPI/RestUtils.d.ts +1 -10
- package/dist/scriptedRESTAPI/RestUtils.js +11 -35
- package/dist/scriptedRESTAPI/RestUtils.js.map +1 -1
- package/dist/scripts/ClientScriptPlugin.d.ts +3 -4
- package/dist/scripts/ClientScriptPlugin.js +11 -37
- package/dist/scripts/ClientScriptPlugin.js.map +1 -1
- package/dist/uxf/ExperiencePlugin.d.ts +2 -2
- package/dist/uxf/RoutesPlugin.d.ts +2 -2
- package/dist/uxf/RoutesPlugin.js +2 -3
- package/dist/uxf/RoutesPlugin.js.map +1 -1
- package/dist/uxf/tectonicIdGenerator.d.ts +1 -1
- package/dist/uxf/tectonicIdGenerator.js +5 -28
- package/dist/uxf/tectonicIdGenerator.js.map +1 -1
- package/package.json +6 -8
- package/src/AttachmentPlugin.ts +5 -7
- package/src/BusinessRulePlugin.ts +12 -6
- package/src/CrossScopePrivilegePlugin.ts +2 -3
- package/src/DefaultPlugin.ts +22 -26
- package/src/HtmlTemplatePlugin.ts +2 -2
- package/src/IdPlugin.ts +6 -10
- package/src/JsonPlugin.ts +7 -12
- package/src/ListPlugin.ts +20 -22
- package/src/NowConfigPlugin.ts +10 -13
- package/src/PackageJsonPlugin.ts +1 -1
- package/src/PropertyPlugin.ts +8 -14
- package/src/ScriptTemplatePlugin.ts +1 -1
- package/src/ServerModulePlugin.ts +15 -20
- package/src/aclAndRole/AclPlugin.ts +37 -6
- package/src/aclAndRole/RolePlugin.ts +7 -9
- package/src/aclAndRole/Util.ts +2 -2
- package/src/app/ApplicationMenuPlugin.ts +3 -4
- package/src/atf/TestPlugin.ts +3 -3
- package/src/db/ColumnPlugins.ts +20 -22
- package/src/db/DocumentationPlugin.ts +7 -41
- package/src/db/RecordPlugin.ts +23 -26
- package/src/db/TablePlugin.ts +222 -115
- package/src/scriptedRESTAPI/RESTDeserializationUtils.ts +18 -19
- package/src/scriptedRESTAPI/RESTSerializationUtils.ts +1 -1
- package/src/scriptedRESTAPI/RestApiPlugin.ts +15 -18
- package/src/scriptedRESTAPI/RestUtils.ts +7 -7
- package/src/scripts/ClientScriptPlugin.ts +10 -12
- package/src/uxf/RoutesPlugin.ts +2 -3
- package/src/uxf/tectonicIdGenerator.ts +3 -6
package/src/NowConfigPlugin.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
1
|
import { Plugin, Data, EntityData, ObjectData } from '@servicenow/sdk-build-core'
|
|
3
2
|
import JsonPlugin from './JsonPlugin'
|
|
4
|
-
import { NowConfigFileName } from '@servicenow/sdk-project'
|
|
3
|
+
import { NowConfigFileName, path } from '@servicenow/sdk-project'
|
|
5
4
|
|
|
6
5
|
export default Plugin({
|
|
7
6
|
name: 'NowConfig',
|
|
@@ -18,12 +17,12 @@ export default Plugin({
|
|
|
18
17
|
return { handled: false }
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
const configObject = configExtraction.data
|
|
20
|
+
const configObject = configExtraction.data
|
|
22
21
|
if (!Data.isObject(configObject)) {
|
|
23
22
|
return { handled: false }
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const { scope: scopeName, scopeId } = context.app.config
|
|
25
|
+
const { scope: scopeName, scopeId, name } = context.app.config
|
|
27
26
|
const { name: packageName, version } = context.app.package
|
|
28
27
|
|
|
29
28
|
const sysAppRecord = {
|
|
@@ -40,7 +39,7 @@ export default Plugin({
|
|
|
40
39
|
license_category: 'none',
|
|
41
40
|
license_model: 'none',
|
|
42
41
|
package_json: `${scopeName}/${packageName}/${version}/package.json`,
|
|
43
|
-
name: packageName,
|
|
42
|
+
name: name || packageName,
|
|
44
43
|
private: false,
|
|
45
44
|
restrict_table_access: false,
|
|
46
45
|
runtime_access_tracking: 'permissive',
|
|
@@ -56,14 +55,12 @@ export default Plugin({
|
|
|
56
55
|
return {
|
|
57
56
|
handled: true,
|
|
58
57
|
diagnostics: configExtraction.diagnostics,
|
|
59
|
-
data:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
),
|
|
66
|
-
],
|
|
58
|
+
data: new EntityData(
|
|
59
|
+
'record',
|
|
60
|
+
context.app.config.scopeId,
|
|
61
|
+
ObjectData.fromObjectValue(sysAppRecord, configObject.getNode()),
|
|
62
|
+
node
|
|
63
|
+
),
|
|
67
64
|
}
|
|
68
65
|
},
|
|
69
66
|
},
|
package/src/PackageJsonPlugin.ts
CHANGED
|
@@ -14,7 +14,7 @@ export default Plugin({
|
|
|
14
14
|
return {
|
|
15
15
|
handled: true,
|
|
16
16
|
diagnostics: [],
|
|
17
|
-
data:
|
|
17
|
+
data: new ModuleEntityData(file.getFilePath(), file.getFullText(), file, context),
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
},
|
package/src/PropertyPlugin.ts
CHANGED
|
@@ -19,9 +19,8 @@ import {
|
|
|
19
19
|
} from '@servicenow/sdk-build-core'
|
|
20
20
|
import { RecordPlugin } from './db/RecordPlugin'
|
|
21
21
|
import { z } from 'zod'
|
|
22
|
-
import { SyntaxKind, Node, ObjectLiteralExpression } from 'ts-morph'
|
|
23
22
|
import { pickBy } from 'lodash'
|
|
24
|
-
import { Diagnostic } from '@servicenow/sdk-project'
|
|
23
|
+
import { Diagnostic, ts } from '@servicenow/sdk-project'
|
|
25
24
|
import { getRolesString } from './aclAndRole/RolePlugin'
|
|
26
25
|
|
|
27
26
|
const PropertySchema = z.object({
|
|
@@ -50,11 +49,6 @@ const PropertyConfigSchema = z.object({
|
|
|
50
49
|
choices: z.string().optional(),
|
|
51
50
|
})
|
|
52
51
|
|
|
53
|
-
export const PropertyDocumentSchema = z.object({
|
|
54
|
-
table: z.literal('sys_properties'),
|
|
55
|
-
data: PropertyConfigSchema,
|
|
56
|
-
})
|
|
57
|
-
|
|
58
52
|
type PropertyConfig = z.output<typeof PropertyConfigSchema>
|
|
59
53
|
|
|
60
54
|
const transformProperties = (
|
|
@@ -99,11 +93,11 @@ export default Plugin({
|
|
|
99
93
|
context.registerExplicitId('sys_properties', prop.$id as string)
|
|
100
94
|
)
|
|
101
95
|
|
|
102
|
-
if (!result.handled || !
|
|
96
|
+
if (!result.handled || !result.data) {
|
|
103
97
|
return result
|
|
104
98
|
}
|
|
105
99
|
|
|
106
|
-
const propertyData = result.data
|
|
100
|
+
const propertyData = result.data
|
|
107
101
|
const diagnostics = result.diagnostics
|
|
108
102
|
const scope = context.app.config.scope
|
|
109
103
|
const nameData = propertyData.getProperty('name')
|
|
@@ -116,7 +110,7 @@ export default Plugin({
|
|
|
116
110
|
return {
|
|
117
111
|
handled: true,
|
|
118
112
|
diagnostics,
|
|
119
|
-
data:
|
|
113
|
+
data: propertyData,
|
|
120
114
|
}
|
|
121
115
|
},
|
|
122
116
|
},
|
|
@@ -188,7 +182,7 @@ export default Plugin({
|
|
|
188
182
|
},
|
|
189
183
|
Property,
|
|
190
184
|
{ $id: document.guid }
|
|
191
|
-
).getExpressionIfKindOrThrow(SyntaxKind.CallExpression)
|
|
185
|
+
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
192
186
|
)
|
|
193
187
|
},
|
|
194
188
|
},
|
|
@@ -214,7 +208,7 @@ export default Plugin({
|
|
|
214
208
|
})
|
|
215
209
|
|
|
216
210
|
const [args] = document.node.getArguments()
|
|
217
|
-
if (!Node.isObjectLiteralExpression(args)) {
|
|
211
|
+
if (!ts.Node.isObjectLiteralExpression(args)) {
|
|
218
212
|
return false
|
|
219
213
|
}
|
|
220
214
|
transformFunctionArguments(document.node, Property, data)
|
|
@@ -230,10 +224,10 @@ export default Plugin({
|
|
|
230
224
|
},
|
|
231
225
|
})
|
|
232
226
|
|
|
233
|
-
function removeEmptyRoles(arg: ObjectLiteralExpression, data: Partial<Property>) {
|
|
227
|
+
function removeEmptyRoles(arg: ts.ObjectLiteralExpression, data: Partial<Property>) {
|
|
234
228
|
;['read', 'write'].forEach((type) => {
|
|
235
229
|
if (data.roles?.[type].length === 0) {
|
|
236
|
-
arg.getProperty('roles')?.asKind(SyntaxKind.ObjectLiteralExpression)?.getProperty(type)?.remove()
|
|
230
|
+
arg.getProperty('roles')?.asKind(ts.SyntaxKind.ObjectLiteralExpression)?.getProperty(type)?.remove()
|
|
237
231
|
delete data.roles?.[type]
|
|
238
232
|
}
|
|
239
233
|
})
|
|
@@ -11,25 +11,22 @@ import {
|
|
|
11
11
|
} from '@servicenow/sdk-build-core'
|
|
12
12
|
import {
|
|
13
13
|
Diagnostic,
|
|
14
|
-
|
|
15
|
-
ts,
|
|
14
|
+
FileSystem,
|
|
16
15
|
TsMorphFileSystemWrapper,
|
|
17
16
|
TypeScriptDiagnostic,
|
|
18
|
-
|
|
17
|
+
path as pathModule,
|
|
18
|
+
ts,
|
|
19
|
+
SupportedNode,
|
|
19
20
|
} from '@servicenow/sdk-project'
|
|
20
|
-
import * as pathModule from 'path'
|
|
21
|
-
import { FunctionDeclaration, VariableDeclaration, SourceFile, Project, ScriptTarget, ModuleKind } from 'ts-morph'
|
|
22
21
|
|
|
23
22
|
export class ModuleEntityData extends EntityData {
|
|
24
23
|
constructor(path: string, content: string, node: SupportedNode, context: Context) {
|
|
25
24
|
const { scope } = context.app.config
|
|
26
25
|
const { name: packageName, version } = context.app.package
|
|
27
|
-
|
|
28
|
-
let relativePath = pathModule.relative(context.app.rootDir, pathModule.normalize(path))
|
|
29
|
-
relativePath = relativePath.split(pathModule.sep).join(pathModule.posix.sep)
|
|
26
|
+
const relativePath = pathModule.relative(context.app.rootDir, path)
|
|
30
27
|
|
|
31
28
|
// Module resolution at runtime requires this format
|
|
32
|
-
const modulePath = pathModule.
|
|
29
|
+
const modulePath = pathModule.join(scope, packageName, version, relativePath)
|
|
33
30
|
|
|
34
31
|
super(
|
|
35
32
|
'module',
|
|
@@ -47,7 +44,7 @@ export class ModuleEntityData extends EntityData {
|
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
export class ModuleFunctionData extends ObjectData<{ exportName: string; modulePath: string; isDefault: boolean }> {
|
|
50
|
-
constructor(name: string, module: ModuleEntityData, node: FunctionDeclaration | VariableDeclaration) {
|
|
47
|
+
constructor(name: string, module: ModuleEntityData, node: ts.FunctionDeclaration | ts.VariableDeclaration) {
|
|
51
48
|
super(
|
|
52
49
|
{
|
|
53
50
|
exportName: new StringData(name, node),
|
|
@@ -135,7 +132,7 @@ function extractFunctionDeclaration(
|
|
|
135
132
|
return result
|
|
136
133
|
}
|
|
137
134
|
|
|
138
|
-
const module = result.data
|
|
135
|
+
const module = result.data
|
|
139
136
|
if (!(module instanceof ModuleEntityData)) {
|
|
140
137
|
return { handled: false }
|
|
141
138
|
}
|
|
@@ -144,7 +141,6 @@ function extractFunctionDeclaration(
|
|
|
144
141
|
if (!name) {
|
|
145
142
|
return {
|
|
146
143
|
handled: true,
|
|
147
|
-
data: [],
|
|
148
144
|
diagnostics: [new FluentDiagnostic(node, 'Function declaration must have a name')],
|
|
149
145
|
}
|
|
150
146
|
}
|
|
@@ -152,22 +148,22 @@ function extractFunctionDeclaration(
|
|
|
152
148
|
return {
|
|
153
149
|
handled: true,
|
|
154
150
|
diagnostics: [],
|
|
155
|
-
data:
|
|
151
|
+
data: new ModuleFunctionData(name, module, node),
|
|
156
152
|
}
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
function getEmitOutput(file: SourceFile, fs: FileSystem): string | Diagnostic[] {
|
|
160
|
-
const path =
|
|
155
|
+
function getEmitOutput(file: ts.SourceFile, fs: FileSystem): string | Diagnostic[] {
|
|
156
|
+
const path = file.getFilePath()
|
|
161
157
|
if (!path.endsWith('.ts')) {
|
|
162
158
|
return file.getFullText()
|
|
163
159
|
}
|
|
164
160
|
|
|
165
|
-
const project = new Project({
|
|
161
|
+
const project = new ts.Project({
|
|
166
162
|
fileSystem: new TsMorphFileSystemWrapper(fs),
|
|
167
163
|
// TODO: Use the project's local tsconfig.json if there is one
|
|
168
164
|
compilerOptions: {
|
|
169
|
-
target: ScriptTarget.ES2022,
|
|
170
|
-
module: ModuleKind.ES2022,
|
|
165
|
+
target: ts.ScriptTarget.ES2022,
|
|
166
|
+
module: ts.ModuleKind.ES2022,
|
|
171
167
|
declaration: false,
|
|
172
168
|
sourceMap: false,
|
|
173
169
|
},
|
|
@@ -234,7 +230,6 @@ export default Plugin({
|
|
|
234
230
|
if (Array.isArray(content)) {
|
|
235
231
|
return {
|
|
236
232
|
handled: true,
|
|
237
|
-
data: [],
|
|
238
233
|
diagnostics: content,
|
|
239
234
|
}
|
|
240
235
|
}
|
|
@@ -242,7 +237,7 @@ export default Plugin({
|
|
|
242
237
|
return {
|
|
243
238
|
handled: true,
|
|
244
239
|
diagnostics: [],
|
|
245
|
-
data:
|
|
240
|
+
data: new ModuleEntityData(mappedPath, content, file, context),
|
|
246
241
|
}
|
|
247
242
|
},
|
|
248
243
|
},
|
|
@@ -20,16 +20,18 @@ import {
|
|
|
20
20
|
findObjectPropertyValue,
|
|
21
21
|
EntityData,
|
|
22
22
|
ObjectData,
|
|
23
|
-
|
|
23
|
+
ArrayData,
|
|
24
|
+
Data,
|
|
24
25
|
} from '@servicenow/sdk-build-core'
|
|
25
26
|
import { addObjectToArrayById, removeObjectFromArrayById } from './Util'
|
|
26
27
|
import { Record as DBRecord, TableName } from '@servicenow/sdk-core/runtime/db'
|
|
27
28
|
import { except } from '../scripts/scriptUtils'
|
|
28
|
-
import
|
|
29
|
+
import { ts } from '@servicenow/sdk-project'
|
|
29
30
|
import { AclNamedTypes } from '@servicenow/sdk-core/runtime/app'
|
|
30
31
|
import { processScript } from '../ScriptTemplatePlugin'
|
|
31
32
|
import { Diagnostic } from '@servicenow/sdk-project'
|
|
32
33
|
import { ModuleFunctionData } from '../ServerModulePlugin'
|
|
34
|
+
import { RecordPlugin } from '../db'
|
|
33
35
|
|
|
34
36
|
type AclDoc = {
|
|
35
37
|
table: string
|
|
@@ -119,11 +121,11 @@ export default Plugin({
|
|
|
119
121
|
context.registerExplicitId('sys_security_acl', acl.$id)
|
|
120
122
|
)
|
|
121
123
|
|
|
122
|
-
if (!result.handled || !
|
|
124
|
+
if (!result.handled || !result.data) {
|
|
123
125
|
return result
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
const acl = result.data
|
|
128
|
+
const acl = result.data
|
|
127
129
|
const aclRecord = aclAsRecord(acl.getValue())
|
|
128
130
|
const scriptVal = ModuleFunctionData.getGlueCode(
|
|
129
131
|
acl.getProperty('script'),
|
|
@@ -178,15 +180,44 @@ export default Plugin({
|
|
|
178
180
|
node
|
|
179
181
|
)
|
|
180
182
|
|
|
183
|
+
const wrapperEntity = new EntityData(
|
|
184
|
+
'acl',
|
|
185
|
+
acl.getGuid(),
|
|
186
|
+
new ObjectData(
|
|
187
|
+
{
|
|
188
|
+
records: new ArrayData([aclEntityData, ...m2mRoleToAcl], node),
|
|
189
|
+
},
|
|
190
|
+
node
|
|
191
|
+
),
|
|
192
|
+
node
|
|
193
|
+
)
|
|
194
|
+
|
|
181
195
|
return {
|
|
182
196
|
handled: true,
|
|
183
197
|
diagnostics: [...result.diagnostics, ...diagnostics],
|
|
184
|
-
data:
|
|
198
|
+
data: wrapperEntity,
|
|
185
199
|
}
|
|
186
200
|
},
|
|
187
201
|
},
|
|
188
202
|
},
|
|
189
203
|
},
|
|
204
|
+
composers: {
|
|
205
|
+
entity: {
|
|
206
|
+
acl(entity, context) {
|
|
207
|
+
return entity
|
|
208
|
+
.getPropertyOrThrow('records', 'array')
|
|
209
|
+
.getElements()
|
|
210
|
+
.map((record) => {
|
|
211
|
+
if (!Data.isEntity(record)) {
|
|
212
|
+
throw new Error('Expected entity')
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return RecordPlugin.composers.entity.record(record, context)
|
|
216
|
+
})
|
|
217
|
+
.flat()
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
190
221
|
arrangers: {
|
|
191
222
|
record(document, context) {
|
|
192
223
|
if ((document.data as any).table !== 'sys_security_acl_role') {
|
|
@@ -309,7 +340,7 @@ export default Plugin({
|
|
|
309
340
|
processScript(args, 'script', script)
|
|
310
341
|
}
|
|
311
342
|
transformFunctionArguments(document.node, Acl, aclData)
|
|
312
|
-
|
|
343
|
+
context.argTypesToFix.push(document.node)
|
|
313
344
|
return true
|
|
314
345
|
},
|
|
315
346
|
},
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
isSNScope,
|
|
11
11
|
LinkedDocument,
|
|
12
12
|
ArrayData,
|
|
13
|
-
fixFunctionArgumentTypes,
|
|
14
13
|
} from '@servicenow/sdk-build-core'
|
|
15
14
|
import {
|
|
16
15
|
generateCallExpressionExportForDocument,
|
|
@@ -20,9 +19,8 @@ import {
|
|
|
20
19
|
removeNode,
|
|
21
20
|
} from '@servicenow/sdk-build-core'
|
|
22
21
|
import { addObjectToArrayById, removeObjectFromArrayById } from './Util'
|
|
23
|
-
import { SyntaxKind, Node } from 'ts-morph'
|
|
24
22
|
import { except } from '../scripts/scriptUtils'
|
|
25
|
-
import { Diagnostic, SupportedNode } from '@servicenow/sdk-project'
|
|
23
|
+
import { Diagnostic, SupportedNode, ts } from '@servicenow/sdk-project'
|
|
26
24
|
|
|
27
25
|
export function getRolesString(roles: ArrayData<unknown[]>): string {
|
|
28
26
|
const uniqueRoles = [
|
|
@@ -89,11 +87,11 @@ export default Plugin({
|
|
|
89
87
|
({ $id }) => context.registerExplicitId('sys_user_role', $id as string)
|
|
90
88
|
)
|
|
91
89
|
|
|
92
|
-
if (!result.handled || !
|
|
90
|
+
if (!result.handled || !result.data) {
|
|
93
91
|
return result
|
|
94
92
|
}
|
|
95
93
|
|
|
96
|
-
const role = result.data
|
|
94
|
+
const role = result.data
|
|
97
95
|
const diagnostics = result.diagnostics
|
|
98
96
|
const scope = context.app?.config?.scope
|
|
99
97
|
const name = role.getProperty('name').getValue()
|
|
@@ -105,7 +103,7 @@ export default Plugin({
|
|
|
105
103
|
return {
|
|
106
104
|
handled: true,
|
|
107
105
|
diagnostics,
|
|
108
|
-
data:
|
|
106
|
+
data: role,
|
|
109
107
|
}
|
|
110
108
|
},
|
|
111
109
|
},
|
|
@@ -203,7 +201,7 @@ export default Plugin({
|
|
|
203
201
|
},
|
|
204
202
|
Role,
|
|
205
203
|
{ $id: document.guid }
|
|
206
|
-
).getExpressionIfKindOrThrow(SyntaxKind.CallExpression)
|
|
204
|
+
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
207
205
|
)
|
|
208
206
|
},
|
|
209
207
|
},
|
|
@@ -213,7 +211,7 @@ export default Plugin({
|
|
|
213
211
|
const documentType = (document.data as any)?.table
|
|
214
212
|
if (documentType === 'sys_user_role_contains') {
|
|
215
213
|
const [args] = document.node.getArguments()
|
|
216
|
-
if (!Node.isObjectLiteralExpression(args) || !document.parent) {
|
|
214
|
+
if (!ts.Node.isObjectLiteralExpression(args) || !document.parent) {
|
|
217
215
|
return false
|
|
218
216
|
}
|
|
219
217
|
if (document.action === 'DELETE') {
|
|
@@ -244,7 +242,7 @@ export default Plugin({
|
|
|
244
242
|
key === 'includes_roles'
|
|
245
243
|
)
|
|
246
244
|
transformFunctionArguments(document.node, Role, roleData)
|
|
247
|
-
|
|
245
|
+
context.argTypesToFix.push(document.node)
|
|
248
246
|
return true
|
|
249
247
|
},
|
|
250
248
|
},
|
package/src/aclAndRole/Util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEqual } from 'lodash'
|
|
2
|
-
import
|
|
2
|
+
import { ts, tsc } from '@servicenow/sdk-project'
|
|
3
3
|
import {
|
|
4
4
|
Document,
|
|
5
5
|
Context,
|
|
@@ -75,7 +75,7 @@ export function removeObjectFromArrayById(document: Document, name: string, cont
|
|
|
75
75
|
return
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
const propertyAssignment = property.asKind(
|
|
78
|
+
const propertyAssignment = property.asKind(tsc.SyntaxKind.PropertyAssignment)
|
|
79
79
|
if (!propertyAssignment) {
|
|
80
80
|
return
|
|
81
81
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
|
-
import { Node, SyntaxKind } from 'ts-morph'
|
|
3
2
|
import { ApplicationMenu, ApplicationMenuSchema, getRolesArray } from '@servicenow/sdk-core/runtime/app'
|
|
4
3
|
import {
|
|
5
4
|
Plugin,
|
|
@@ -18,7 +17,7 @@ import {
|
|
|
18
17
|
} from '@servicenow/sdk-build-core'
|
|
19
18
|
import { RecordPlugin } from '../db/RecordPlugin'
|
|
20
19
|
import { Record } from '@servicenow/sdk-core/runtime/db'
|
|
21
|
-
import { Diagnostic } from '@servicenow/sdk-project'
|
|
20
|
+
import { Diagnostic, ts } from '@servicenow/sdk-project'
|
|
22
21
|
import { getRolesString } from '../aclAndRole/RolePlugin'
|
|
23
22
|
|
|
24
23
|
type AppMenuDocumentSchema = z.output<typeof AppMenuDocumentSchema>
|
|
@@ -114,7 +113,7 @@ export default Plugin({
|
|
|
114
113
|
},
|
|
115
114
|
ApplicationMenu,
|
|
116
115
|
{ $id: document.guid }
|
|
117
|
-
).getExpressionIfKindOrThrow(SyntaxKind.CallExpression)
|
|
116
|
+
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
118
117
|
)
|
|
119
118
|
},
|
|
120
119
|
},
|
|
@@ -138,7 +137,7 @@ export default Plugin({
|
|
|
138
137
|
}
|
|
139
138
|
const { roles, category } = (document.xmlData as AppMenuDocumentSchema).data
|
|
140
139
|
const [args] = document.node.getArguments()
|
|
141
|
-
if (!Node.isObjectLiteralExpression(args)) {
|
|
140
|
+
if (!ts.Node.isObjectLiteralExpression(args)) {
|
|
142
141
|
return false
|
|
143
142
|
}
|
|
144
143
|
|
package/src/atf/TestPlugin.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ts } from '@servicenow/sdk-project'
|
|
2
2
|
import {
|
|
3
3
|
ConfigEntity,
|
|
4
4
|
ConfigurationFunctionExtractor,
|
|
@@ -19,7 +19,7 @@ export default Plugin({
|
|
|
19
19
|
extractors: {
|
|
20
20
|
entity: {
|
|
21
21
|
fluent: {
|
|
22
|
-
CallExpression: (node: CallExpression, context: Context) => {
|
|
22
|
+
CallExpression: (node: ts.CallExpression, context: Context) => {
|
|
23
23
|
// This constructs an entity of kind 'test' and returns it. This entity is then parsed by the composer
|
|
24
24
|
const configExtractor = new ConfigurationFunctionExtractor(node, context, ATF)
|
|
25
25
|
const result = configExtractor.extractConfigFunction('test', context.logger)
|
|
@@ -30,7 +30,7 @@ export default Plugin({
|
|
|
30
30
|
return {
|
|
31
31
|
handled: true,
|
|
32
32
|
diagnostics: [],
|
|
33
|
-
data:
|
|
33
|
+
data: result,
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
},
|
package/src/db/ColumnPlugins.ts
CHANGED
|
@@ -34,16 +34,16 @@ function ColumnPlugin<
|
|
|
34
34
|
CallExpression(node, context) {
|
|
35
35
|
const result = extractCallExpression(
|
|
36
36
|
fn,
|
|
37
|
-
`${entityKind}
|
|
37
|
+
`${entityKind}_column`,
|
|
38
38
|
node,
|
|
39
39
|
context,
|
|
40
40
|
() => 'NO_GUID_GENERATED' // TODO: We shouldn't need to generate any GUID here but maybe should provide something unique to be on the safe side
|
|
41
41
|
)
|
|
42
|
-
if (!result.handled || !
|
|
42
|
+
if (!result.handled || !result.data) {
|
|
43
43
|
return result
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const entity = result.data
|
|
46
|
+
const entity = result.data
|
|
47
47
|
const diagnostics = result.diagnostics
|
|
48
48
|
diagnostics.push(...getLabelDiagnostics(entity))
|
|
49
49
|
const functionDefinition = entity.getProperty('function_definition')?.getValue()
|
|
@@ -63,15 +63,13 @@ function ColumnPlugin<
|
|
|
63
63
|
return {
|
|
64
64
|
handled: true,
|
|
65
65
|
diagnostics,
|
|
66
|
-
data:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
),
|
|
74
|
-
],
|
|
66
|
+
data: ObjectData.fromObjectValue(
|
|
67
|
+
{
|
|
68
|
+
...entity.getValue(),
|
|
69
|
+
entityKind,
|
|
70
|
+
},
|
|
71
|
+
entity.getNode()
|
|
72
|
+
),
|
|
75
73
|
}
|
|
76
74
|
},
|
|
77
75
|
},
|
|
@@ -83,24 +81,24 @@ function ColumnPlugin<
|
|
|
83
81
|
export const StringColumnPlugin = ColumnPlugin(db.StringColumn, 'string')
|
|
84
82
|
export const BooleanColumnPlugin = ColumnPlugin(db.BooleanColumn, 'boolean')
|
|
85
83
|
export const IntegerColumnPlugin = ColumnPlugin(db.IntegerColumn, 'integer')
|
|
86
|
-
export const BasicImageColumnPlugin = ColumnPlugin(db.BasicImageColumn, '
|
|
84
|
+
export const BasicImageColumnPlugin = ColumnPlugin(db.BasicImageColumn, 'image')
|
|
87
85
|
export const ConditionsColumnPlugin = ColumnPlugin(db.ConditionsColumn, 'conditions')
|
|
88
86
|
export const ChoiceColumnPlugin = ColumnPlugin(db.ChoiceColumn, 'choice')
|
|
89
87
|
export const DecimalColumnPlugin = ColumnPlugin(db.DecimalColumn, 'decimal')
|
|
90
|
-
export const DocumentIdColumnPlugin = ColumnPlugin(db.DocumentIdColumn, '
|
|
91
|
-
export const DomainIdColumnPlugin = ColumnPlugin(db.DomainIdColumn, '
|
|
92
|
-
export const DomainPathColumnPlugin = ColumnPlugin(db.DomainPathColumn, '
|
|
88
|
+
export const DocumentIdColumnPlugin = ColumnPlugin(db.DocumentIdColumn, 'document_id')
|
|
89
|
+
export const DomainIdColumnPlugin = ColumnPlugin(db.DomainIdColumn, 'domain_id')
|
|
90
|
+
export const DomainPathColumnPlugin = ColumnPlugin(db.DomainPathColumn, 'domain_path')
|
|
93
91
|
export const ListColumnPlugin = ColumnPlugin(db.ListColumn, 'glide_list')
|
|
94
92
|
export const ReferenceColumnPlugin = ColumnPlugin(db.ReferenceColumn, 'reference')
|
|
95
93
|
export const RadioColumnPlugin = ColumnPlugin(db.RadioColumn, 'radio')
|
|
96
94
|
export const ScriptColumnPlugin = ColumnPlugin(db.ScriptColumn, 'script')
|
|
97
|
-
export const SystemClassNameColumnPlugin = ColumnPlugin(db.SystemClassNameColumn, '
|
|
98
|
-
export const TableNameColumnPlugin = ColumnPlugin(db.TableNameColumn, '
|
|
99
|
-
export const TranslatedFieldColumnPlugin = ColumnPlugin(db.TranslatedFieldColumn, '
|
|
100
|
-
export const TranslatedTextColumnPlugin = ColumnPlugin(db.TranslatedTextColumn, '
|
|
101
|
-
export const UserRolesColumnPlugin = ColumnPlugin(db.UserRolesColumn, '
|
|
95
|
+
export const SystemClassNameColumnPlugin = ColumnPlugin(db.SystemClassNameColumn, 'sys_class_name')
|
|
96
|
+
export const TableNameColumnPlugin = ColumnPlugin(db.TableNameColumn, 'table_name')
|
|
97
|
+
export const TranslatedFieldColumnPlugin = ColumnPlugin(db.TranslatedFieldColumn, 'translated_field')
|
|
98
|
+
export const TranslatedTextColumnPlugin = ColumnPlugin(db.TranslatedTextColumn, 'translated_text')
|
|
99
|
+
export const UserRolesColumnPlugin = ColumnPlugin(db.UserRolesColumn, 'user_roles')
|
|
102
100
|
export const VersionColumnPlugin = ColumnPlugin(db.VersionColumn, 'version')
|
|
103
|
-
export const FieldNameColumnPlugin = ColumnPlugin(db.FieldNameColumn, '
|
|
101
|
+
export const FieldNameColumnPlugin = ColumnPlugin(db.FieldNameColumn, 'field_name')
|
|
104
102
|
|
|
105
103
|
// Date columns
|
|
106
104
|
export const DateColumnPlugin = ColumnPlugin(db.DateColumn, 'glide_date')
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCallExpressionName,
|
|
3
3
|
getPropertyAssignment,
|
|
4
|
-
mergeDataIntoObjectLiteral,
|
|
5
4
|
Plugin,
|
|
6
5
|
stringify,
|
|
7
6
|
Context,
|
|
8
7
|
getOrCreatePropertyAssignment,
|
|
8
|
+
mergeDataIntoObjectLiteralArray,
|
|
9
|
+
filterEmpty,
|
|
9
10
|
} from '@servicenow/sdk-build-core'
|
|
10
11
|
import { Documentation, Record, Table } from '@servicenow/sdk-core/runtime/db'
|
|
11
12
|
import { createObjectExpression } from './TablePlugin'
|
|
12
|
-
import { ts } from '
|
|
13
|
+
import { ts, tsc } from '@servicenow/sdk-project'
|
|
13
14
|
import { RecordPlugin } from './RecordPlugin'
|
|
14
15
|
import { isEqual } from 'lodash'
|
|
15
16
|
|
|
@@ -110,7 +111,8 @@ export default Plugin({
|
|
|
110
111
|
// Do transformation
|
|
111
112
|
const labelArrayNode = labelNode?.getFirstChildByKind(ts.SyntaxKind.ArrayLiteralExpression)
|
|
112
113
|
if (labelArrayNode) {
|
|
113
|
-
|
|
114
|
+
mergeDataIntoObjectLiteralArray(labelArrayNode, [docData], 'language', document.action)
|
|
115
|
+
return true
|
|
114
116
|
} else {
|
|
115
117
|
const literalNode = labelNode?.getFirstChildByKind(ts.SyntaxKind.StringLiteral)
|
|
116
118
|
if (isDefaultDocumentationRecord(docData)) {
|
|
@@ -155,7 +157,7 @@ function createArrayLabel(labelNode, objLitNode, docData) {
|
|
|
155
157
|
|
|
156
158
|
// Create the array since it didn't exist before
|
|
157
159
|
labelNode.transform((traversal) => {
|
|
158
|
-
if (
|
|
160
|
+
if (tsc.isPropertyAssignment(traversal.currentNode)) {
|
|
159
161
|
const arrayLit = traversal.factory.createArrayLiteralExpression([
|
|
160
162
|
createObjectExpression({
|
|
161
163
|
...filterEmpty(docData),
|
|
@@ -163,7 +165,7 @@ function createArrayLabel(labelNode, objLitNode, docData) {
|
|
|
163
165
|
])
|
|
164
166
|
return traversal.factory.updatePropertyAssignment(
|
|
165
167
|
traversal.currentNode,
|
|
166
|
-
|
|
168
|
+
tsc.factory.createIdentifier('label'),
|
|
167
169
|
arrayLit
|
|
168
170
|
)
|
|
169
171
|
}
|
|
@@ -177,42 +179,6 @@ function createArrayLabel(labelNode, objLitNode, docData) {
|
|
|
177
179
|
return true
|
|
178
180
|
}
|
|
179
181
|
|
|
180
|
-
function updateArrayLabel(labelNode, labelArrayNode, docData, action) {
|
|
181
|
-
const transformElement = labelArrayNode.getElements().find((element) => {
|
|
182
|
-
const existingLanguage =
|
|
183
|
-
element
|
|
184
|
-
.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
185
|
-
.getProperty('language')
|
|
186
|
-
?.getFirstChildByKind(ts.SyntaxKind.StringLiteral) ?? undefined
|
|
187
|
-
return docData.language === existingLanguage?.getLiteralValue()
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
// Found existing element in array, either remove or update it
|
|
191
|
-
if (transformElement) {
|
|
192
|
-
if (action === 'DELETE') {
|
|
193
|
-
labelArrayNode.removeElement(transformElement)
|
|
194
|
-
return true
|
|
195
|
-
}
|
|
196
|
-
mergeDataIntoObjectLiteral(transformElement.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression), docData)
|
|
197
|
-
} else {
|
|
198
|
-
// labelNode will exist here as array
|
|
199
|
-
labelNode!
|
|
200
|
-
.getFirstChildByKindOrThrow(ts.SyntaxKind.ArrayLiteralExpression)
|
|
201
|
-
.addElement(stringify(filterEmpty(docData)))
|
|
202
|
-
}
|
|
203
|
-
return true
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Remove defualt empty values
|
|
207
|
-
function filterEmpty(data: any) {
|
|
208
|
-
return Object.entries(data).reduce((acc, [key, value]) => {
|
|
209
|
-
if (value !== '') {
|
|
210
|
-
acc[key] = value
|
|
211
|
-
}
|
|
212
|
-
return acc
|
|
213
|
-
}, {})
|
|
214
|
-
}
|
|
215
|
-
|
|
216
182
|
function isDefaultDocumentationRecord(docData) {
|
|
217
183
|
const { label, name, element } = docData
|
|
218
184
|
const defaultRecord = defaultDocumentationRecord(label, name, element)
|