@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
|
@@ -11,9 +11,8 @@ import {
|
|
|
11
11
|
ArrayIterator,
|
|
12
12
|
} from '@servicenow/sdk-build-core'
|
|
13
13
|
import { RouteSchema, RestApiSchema } from '@servicenow/sdk-core/runtime/rest'
|
|
14
|
-
import
|
|
14
|
+
import { ts } from '@servicenow/sdk-project'
|
|
15
15
|
import * as z from 'zod'
|
|
16
|
-
import { SyntaxKind } from 'ts-morph'
|
|
17
16
|
import { processScript } from '../ScriptTemplatePlugin'
|
|
18
17
|
import {
|
|
19
18
|
RestDefinitionTransformer,
|
|
@@ -76,7 +75,7 @@ function transformEnforceAcl(args: ts.ObjectLiteralExpression, enforce_acl: stri
|
|
|
76
75
|
while (enforceAclIterator.hasNext()) {
|
|
77
76
|
const aclElement = enforceAclIterator.next()
|
|
78
77
|
let aclSysId: string | undefined = undefined
|
|
79
|
-
if (aclElement.isKind(SyntaxKind.StringLiteral)) {
|
|
78
|
+
if (aclElement.isKind(ts.SyntaxKind.StringLiteral)) {
|
|
80
79
|
aclSysId = aclElement.getLiteralValue()
|
|
81
80
|
} else {
|
|
82
81
|
const varDec = (aclElement.getSymbol()?.getValueDeclaration() ??
|
|
@@ -84,7 +83,7 @@ function transformEnforceAcl(args: ts.ObjectLiteralExpression, enforce_acl: stri
|
|
|
84
83
|
if (varDec) {
|
|
85
84
|
const nodeID = getNodeId(
|
|
86
85
|
varDec
|
|
87
|
-
.getInitializerIfKind(SyntaxKind.CallExpression)
|
|
86
|
+
.getInitializerIfKind(ts.SyntaxKind.CallExpression)
|
|
88
87
|
?.getArguments()[0] as ts.ObjectLiteralExpression
|
|
89
88
|
)!
|
|
90
89
|
aclSysId = context.keys.explicit[nodeID]?.id
|
|
@@ -120,13 +119,13 @@ export function transformRestAttrs(document: Document, context: Context) {
|
|
|
120
119
|
let isHandled = false
|
|
121
120
|
while (versionArrayIterator.hasNext() && !isHandled) {
|
|
122
121
|
const element = versionArrayIterator.next()
|
|
123
|
-
const verId = getNodeId(element.asKindOrThrow(SyntaxKind.ObjectLiteralExpression))!
|
|
122
|
+
const verId = getNodeId(element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression))!
|
|
124
123
|
const verSysId = context.keys.explicit[verId]?.id
|
|
125
124
|
if (verSysId === document.guid) {
|
|
126
125
|
if (document.action === 'DELETE') {
|
|
127
126
|
expression.removeElement(element)
|
|
128
127
|
} else {
|
|
129
|
-
const eleObj = element.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)
|
|
128
|
+
const eleObj = element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
130
129
|
cleanUpDefault(VersionWithOutIdSchema, cData, eleObj)
|
|
131
130
|
mergeDataIntoObjectLiteral(eleObj, cData)
|
|
132
131
|
}
|
|
@@ -135,7 +134,7 @@ export function transformRestAttrs(document: Document, context: Context) {
|
|
|
135
134
|
}
|
|
136
135
|
if (!isHandled && document.action !== 'DELETE') {
|
|
137
136
|
cleanUpDefault(VersionWithOutIdSchema, cData)
|
|
138
|
-
const element = expression.addElement(stringify(cData)).asKindOrThrow(SyntaxKind.ObjectLiteralExpression)
|
|
137
|
+
const element = expression.addElement(stringify(cData)).asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
139
138
|
transformId(element, '$id', document.guid, 'sys_ws_version', context)
|
|
140
139
|
return true
|
|
141
140
|
}
|
|
@@ -155,7 +154,7 @@ export function transformRouteAttrs(document: Document, context: Context, argNam
|
|
|
155
154
|
while (routeArrayIterator.hasNext()) {
|
|
156
155
|
const element = routeArrayIterator.next()
|
|
157
156
|
const routeAttrsNode = getOrCreatePropertyAssignment(
|
|
158
|
-
element.asKindOrThrow(SyntaxKind.ObjectLiteralExpression),
|
|
157
|
+
element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression),
|
|
159
158
|
argName,
|
|
160
159
|
'[]'
|
|
161
160
|
)
|
|
@@ -163,13 +162,13 @@ export function transformRouteAttrs(document: Document, context: Context, argNam
|
|
|
163
162
|
const arrayExpression = routeAttrIterator.getExpression()
|
|
164
163
|
while (routeAttrIterator.hasNext()) {
|
|
165
164
|
const attrElement = routeAttrIterator.next()
|
|
166
|
-
const attrId = getNodeId(attrElement.asKindOrThrow(SyntaxKind.ObjectLiteralExpression))
|
|
165
|
+
const attrId = getNodeId(attrElement.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression))
|
|
167
166
|
const attrSysId = context.keys.explicit[attrId!]?.id
|
|
168
167
|
if (attrSysId === document.guid) {
|
|
169
168
|
if (document.action === 'DELETE') {
|
|
170
169
|
arrayExpression.removeElement(attrElement)
|
|
171
170
|
} else {
|
|
172
|
-
const attrEleObj = attrElement.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)
|
|
171
|
+
const attrEleObj = attrElement.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
173
172
|
cleanUpDefault(RouteAttrWithOutIdSchema, routeAttrData, attrEleObj)
|
|
174
173
|
mergeDataIntoObjectLiteral(attrEleObj, routeAttrData)
|
|
175
174
|
}
|
|
@@ -197,7 +196,7 @@ function getDefaults<Schema extends z.AnyZodObject>(schema: Schema) {
|
|
|
197
196
|
)
|
|
198
197
|
}
|
|
199
198
|
|
|
200
|
-
|
|
199
|
+
function cleanUpDefault<Schema extends z.AnyZodObject>(
|
|
201
200
|
schema: Schema,
|
|
202
201
|
targetObj: any,
|
|
203
202
|
node?: ts.ObjectLiteralExpression
|
|
@@ -235,13 +234,13 @@ export function transformRoutes(document: Document, context: Context, documentMa
|
|
|
235
234
|
let isHandled = false
|
|
236
235
|
while (routeArrayIterator.hasNext() && !isHandled) {
|
|
237
236
|
const element = routeArrayIterator.next()
|
|
238
|
-
const routeId = getNodeId(element.asKindOrThrow(SyntaxKind.ObjectLiteralExpression))!
|
|
237
|
+
const routeId = getNodeId(element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression))!
|
|
239
238
|
const routeSysId = context.keys.explicit[routeId]?.id
|
|
240
239
|
if (routeSysId === document.guid) {
|
|
241
240
|
if (document.action === 'DELETE') {
|
|
242
241
|
expression.removeElement(element)
|
|
243
242
|
} else {
|
|
244
|
-
const eleObj = element.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)
|
|
243
|
+
const eleObj = element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
245
244
|
transformEnforceAcl(eleObj, enforce_acl, context)
|
|
246
245
|
if (script !== undefined) {
|
|
247
246
|
processScript(eleObj, 'script', script)
|
|
@@ -257,7 +256,7 @@ export function transformRoutes(document: Document, context: Context, documentMa
|
|
|
257
256
|
cleanUpDefault(RouteSchema, parsedRouteData)
|
|
258
257
|
const element = expression
|
|
259
258
|
.addElement(stringify(parsedRouteData))
|
|
260
|
-
.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)
|
|
259
|
+
.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
261
260
|
transformEnforceAcl(element, enforce_acl, context)
|
|
262
261
|
if (script !== undefined) {
|
|
263
262
|
processScript(element, 'script', script)
|
|
@@ -330,11 +329,11 @@ export function transformRouteAttrsMap<T>(
|
|
|
330
329
|
const routeArrayIterator = new ArrayIterator(routesArrayNode)
|
|
331
330
|
while (routeArrayIterator.hasNext()) {
|
|
332
331
|
const element = routeArrayIterator.next()
|
|
333
|
-
const routeId = getNodeId(element.asKindOrThrow(SyntaxKind.ObjectLiteralExpression))!
|
|
332
|
+
const routeId = getNodeId(element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression))!
|
|
334
333
|
const routeSysId = context.keys.explicit[routeId]?.id
|
|
335
334
|
if (routeSysId === operationId || (removalKey && removalKey.route === routeId)) {
|
|
336
335
|
const routeAttrsNode = getOrCreatePropertyAssignment(
|
|
337
|
-
element.asKindOrThrow(SyntaxKind.ObjectLiteralExpression),
|
|
336
|
+
element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression),
|
|
338
337
|
argName,
|
|
339
338
|
'[]'
|
|
340
339
|
)
|
|
@@ -343,7 +342,7 @@ export function transformRouteAttrsMap<T>(
|
|
|
343
342
|
let isHandled = false
|
|
344
343
|
while (routeAttrIterator.hasNext()) {
|
|
345
344
|
const attrElement = routeAttrIterator.next()
|
|
346
|
-
const attrNodeId = getNodeId(attrElement.asKindOrThrow(SyntaxKind.ObjectLiteralExpression))
|
|
345
|
+
const attrNodeId = getNodeId(attrElement.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression))
|
|
347
346
|
const attrMapId = context.keys.composite.find((k) =>
|
|
348
347
|
isEqual(k.key, {
|
|
349
348
|
attr: attrNodeId!,
|
|
@@ -360,7 +359,7 @@ export function transformRouteAttrsMap<T>(
|
|
|
360
359
|
deletedParamID = attrId
|
|
361
360
|
attrExpression.removeElement(attrElement)
|
|
362
361
|
} else {
|
|
363
|
-
const attrEleObj = attrElement.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)
|
|
362
|
+
const attrEleObj = attrElement.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
364
363
|
cleanUpDefault(RouteAttrWithOutIdSchema, parsedAttrData, attrEleObj)
|
|
365
364
|
mergeDataIntoObjectLiteral(attrEleObj, parsedAttrData)
|
|
366
365
|
}
|
|
@@ -371,7 +370,7 @@ export function transformRouteAttrsMap<T>(
|
|
|
371
370
|
cleanUpDefault(RouteAttrWithOutIdSchema, parsedAttrData)
|
|
372
371
|
const element = attrExpression
|
|
373
372
|
.addElement(stringify({}))
|
|
374
|
-
.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)
|
|
373
|
+
.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression)
|
|
375
374
|
mergeDataIntoObjectLiteral(element, parsedAttrData)
|
|
376
375
|
const table = argName === 'headers' ? 'sys_ws_header' : 'sys_ws_query_parameter'
|
|
377
376
|
const foundAttrId = context.keys.findExplicitKeyById(attrId)
|
|
@@ -52,7 +52,7 @@ export function generateVersionRecords(
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
function generateRouteAttributesRecords<T extends TableName, M extends TableName>(
|
|
56
56
|
context: Context,
|
|
57
57
|
restId: string | number,
|
|
58
58
|
routeId: string | number,
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
generateVersionRecords,
|
|
23
23
|
generateRoutesAndRouteAttrRecords,
|
|
24
24
|
} from './RESTSerializationUtils'
|
|
25
|
-
import * as ts from 'ts-morph'
|
|
26
25
|
import {
|
|
27
26
|
transformDefinition,
|
|
28
27
|
transformRestAttrs,
|
|
@@ -47,7 +46,7 @@ import {
|
|
|
47
46
|
potentialRecordCallRouteParams,
|
|
48
47
|
} from './RestUtils'
|
|
49
48
|
import * as z from 'zod'
|
|
50
|
-
import { Diagnostic } from '@servicenow/sdk-project'
|
|
49
|
+
import { Diagnostic, ts, tsc } from '@servicenow/sdk-project'
|
|
51
50
|
import { ModuleFunctionData } from '../ServerModulePlugin'
|
|
52
51
|
|
|
53
52
|
const methodsAllowedToOverrideRequests = ['PUT', 'PATCH', 'POST']
|
|
@@ -118,11 +117,11 @@ export default Plugin({
|
|
|
118
117
|
context.registerExplicitId('sys_ws_definition', restApi.$id as string)
|
|
119
118
|
)
|
|
120
119
|
|
|
121
|
-
if (!result.handled || !
|
|
120
|
+
if (!result.handled || !result.data) {
|
|
122
121
|
return result
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
const restApiEntity = result.data
|
|
124
|
+
const restApiEntity = result.data
|
|
126
125
|
const entityData = RestApiSchema.parse(restApiEntity.getValue())
|
|
127
126
|
const { routes, enforce_acl, consumes, produces } = entityData
|
|
128
127
|
const routesData = restApiEntity.getProperty('routes', 'array')?.getElements() ?? []
|
|
@@ -160,20 +159,18 @@ export default Plugin({
|
|
|
160
159
|
return {
|
|
161
160
|
handled: true,
|
|
162
161
|
diagnostics: result.diagnostics,
|
|
163
|
-
data:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
restApiEntity.getNode()
|
|
173
|
-
),
|
|
162
|
+
data: new EntityData(
|
|
163
|
+
restApiEntity.getKind(),
|
|
164
|
+
restApiEntity.getGuid(),
|
|
165
|
+
ObjectData.fromObjectValue(
|
|
166
|
+
{
|
|
167
|
+
...entityData,
|
|
168
|
+
enforce_acl: parseAcls(enforce_acl, context),
|
|
169
|
+
},
|
|
174
170
|
restApiEntity.getNode()
|
|
175
171
|
),
|
|
176
|
-
|
|
172
|
+
restApiEntity.getNode()
|
|
173
|
+
),
|
|
177
174
|
}
|
|
178
175
|
},
|
|
179
176
|
},
|
|
@@ -366,7 +363,7 @@ export default Plugin({
|
|
|
366
363
|
if (!o_v_node) {
|
|
367
364
|
return undefined
|
|
368
365
|
}
|
|
369
|
-
return linkDocument(document, o_v_node as ts.CallExpression<
|
|
366
|
+
return linkDocument(document, o_v_node as ts.CallExpression<tsc.CallExpression>)
|
|
370
367
|
case 'sys_ws_header_map':
|
|
371
368
|
case 'sys_ws_query_parameter_map':
|
|
372
369
|
// eslint-disable-next-line no-case-declarations
|
|
@@ -380,7 +377,7 @@ export default Plugin({
|
|
|
380
377
|
if (!h_q_node) {
|
|
381
378
|
return undefined
|
|
382
379
|
}
|
|
383
|
-
return linkDocument(document, h_q_node as ts.CallExpression<
|
|
380
|
+
return linkDocument(document, h_q_node as ts.CallExpression<tsc.CallExpression>)
|
|
384
381
|
}
|
|
385
382
|
return undefined
|
|
386
383
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-case-declarations */
|
|
2
|
-
import
|
|
2
|
+
import { ts, tsc } from '@servicenow/sdk-project'
|
|
3
3
|
import {
|
|
4
4
|
Context,
|
|
5
5
|
Document,
|
|
@@ -72,7 +72,7 @@ export const getArgs = (document: Document) => {
|
|
|
72
72
|
* utility function that iterates over all the headers or parameters of all routes
|
|
73
73
|
* inside a rest api and calls the provided callback function.
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
function iterateAllRouteAttrNode(
|
|
76
76
|
document: Document,
|
|
77
77
|
eleAttrName: string,
|
|
78
78
|
callback: (
|
|
@@ -85,16 +85,16 @@ export function iterateAllRouteAttrNode(
|
|
|
85
85
|
const restId = getNodeId(argsNode)!
|
|
86
86
|
argsNode
|
|
87
87
|
.getProperty('routes')
|
|
88
|
-
?.asKind(
|
|
89
|
-
?.getInitializerIfKindOrThrow(
|
|
88
|
+
?.asKind(tsc.SyntaxKind.PropertyAssignment)
|
|
89
|
+
?.getInitializerIfKindOrThrow(tsc.SyntaxKind.ArrayLiteralExpression)
|
|
90
90
|
?.getElements()
|
|
91
91
|
.forEach((element) => {
|
|
92
92
|
const routeId = getNodeId(element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression))!
|
|
93
93
|
const arrayExpression = element
|
|
94
|
-
.asKind(
|
|
94
|
+
.asKind(tsc.SyntaxKind.ObjectLiteralExpression)
|
|
95
95
|
?.getProperty(eleAttrName)
|
|
96
|
-
?.asKind(
|
|
97
|
-
?.getInitializerIfKindOrThrow(
|
|
96
|
+
?.asKind(tsc.SyntaxKind.PropertyAssignment)
|
|
97
|
+
?.getInitializerIfKindOrThrow(tsc.SyntaxKind.ArrayLiteralExpression)
|
|
98
98
|
|
|
99
99
|
arrayExpression?.getElements().forEach((element) => {
|
|
100
100
|
const attrId = getNodeId(element.asKindOrThrow(ts.SyntaxKind.ObjectLiteralExpression))!
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import { Record } from '@servicenow/sdk-core/runtime/db'
|
|
20
20
|
import { ClientScriptSchema } from '@servicenow/sdk-core/runtime/clientscript'
|
|
21
21
|
import { z } from 'zod'
|
|
22
|
-
import
|
|
22
|
+
import { ts } from '@servicenow/sdk-project'
|
|
23
23
|
import { processScript } from '../ScriptTemplatePlugin'
|
|
24
24
|
import { Diagnostic } from '@servicenow/sdk-project'
|
|
25
25
|
import { except } from './scriptUtils'
|
|
@@ -52,11 +52,11 @@ export default Plugin({
|
|
|
52
52
|
context.registerExplicitId('sys_script_client', script.$id as string)
|
|
53
53
|
)
|
|
54
54
|
|
|
55
|
-
if (!result.handled || !
|
|
55
|
+
if (!result.handled || !result.data) {
|
|
56
56
|
return result
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const clientScriptEntityData = result.data
|
|
59
|
+
const clientScriptEntityData = result.data
|
|
60
60
|
const args = node.getArguments()[0] as ts.ObjectLiteralExpression
|
|
61
61
|
|
|
62
62
|
if (!args) {
|
|
@@ -104,14 +104,12 @@ export default Plugin({
|
|
|
104
104
|
return {
|
|
105
105
|
handled: true,
|
|
106
106
|
diagnostics,
|
|
107
|
-
data:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
),
|
|
114
|
-
],
|
|
107
|
+
data: new EntityData(
|
|
108
|
+
'record',
|
|
109
|
+
clientScriptEntityData.getGuid(),
|
|
110
|
+
ObjectData.fromObjectValue(record, node),
|
|
111
|
+
node
|
|
112
|
+
),
|
|
115
113
|
}
|
|
116
114
|
},
|
|
117
115
|
},
|
|
@@ -241,7 +239,7 @@ function getUITypeId(value: string) {
|
|
|
241
239
|
throw Error('Invalid ui_type found in xml')
|
|
242
240
|
}
|
|
243
241
|
|
|
244
|
-
|
|
242
|
+
function isRequire(callExpression: ts.CallExpression): boolean {
|
|
245
243
|
const expression = callExpression.getExpression()
|
|
246
244
|
return ts.Node.isIdentifier(expression) && expression.getText() === 'require'
|
|
247
245
|
}
|
package/src/uxf/RoutesPlugin.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BaseUXRouteSchema, ExperienceSchema, Routes } from '@servicenow/sdk-core/runtime/experience'
|
|
2
2
|
import { Record } from '@servicenow/sdk-core/runtime/db'
|
|
3
|
-
import { SdkError } from '@servicenow/sdk-metrics'
|
|
4
3
|
import { Plugin, extractCallExpression } from '@servicenow/sdk-build-core'
|
|
5
4
|
import { parser as uxValueParser, cleanUxValue } from './UxfFormulaParser'
|
|
6
5
|
import { idGenerator } from './tectonicIdGenerator'
|
|
@@ -21,7 +20,7 @@ type RouteParts = {
|
|
|
21
20
|
function getRouteParts(route: string): RouteParts {
|
|
22
21
|
const chunks = route.split('/').filter((chunk) => chunk && chunk.length > 0)
|
|
23
22
|
if (chunks.length === 0) {
|
|
24
|
-
throw new
|
|
23
|
+
throw new Error('Invalid route - routes may not be empty')
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
const parts: RouteParts = {
|
|
@@ -66,7 +65,7 @@ const createComposition = (component: Component) => {
|
|
|
66
65
|
const propertyValues = Object.keys(properties).reduce((newObj, key) => {
|
|
67
66
|
const parseResult = UxfFormulaParser.parse(properties[key])
|
|
68
67
|
if (parseResult.errors.length) {
|
|
69
|
-
throw new
|
|
68
|
+
throw new Error('Failed to parse formula.')
|
|
70
69
|
}
|
|
71
70
|
newObj[key] = cleanUxValue(parseResult.result.uxValue)
|
|
72
71
|
return newObj
|
|
@@ -10,18 +10,15 @@
|
|
|
10
10
|
* STRY56098244
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import md5 from 'md5.js'
|
|
14
14
|
import { join } from 'lodash'
|
|
15
15
|
|
|
16
|
-
const HASH_ALGORITHM = 'md5'
|
|
17
|
-
const HASH_DIGEST = 'hex'
|
|
18
16
|
const HASH_SEPARATOR = ':'
|
|
19
17
|
const ID_PREFIX = 'tectonic-mvp'
|
|
20
18
|
|
|
21
19
|
const hash = (parts: string[]) => {
|
|
22
|
-
const hash =
|
|
23
|
-
hash.
|
|
24
|
-
return hash.digest(HASH_DIGEST)
|
|
20
|
+
const hash = new md5().update(join(parts, HASH_SEPARATOR))
|
|
21
|
+
return hash.digest('hex')
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
const componentAliasTable = {
|