@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
|
@@ -10,41 +10,18 @@
|
|
|
10
10
|
*
|
|
11
11
|
* STRY56098244
|
|
12
12
|
*/
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
15
|
};
|
|
36
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
17
|
exports.idGenerator = idGenerator;
|
|
38
|
-
const
|
|
18
|
+
const md5_js_1 = __importDefault(require("md5.js"));
|
|
39
19
|
const lodash_1 = require("lodash");
|
|
40
|
-
const HASH_ALGORITHM = 'md5';
|
|
41
|
-
const HASH_DIGEST = 'hex';
|
|
42
20
|
const HASH_SEPARATOR = ':';
|
|
43
21
|
const ID_PREFIX = 'tectonic-mvp';
|
|
44
22
|
const hash = (parts) => {
|
|
45
|
-
const hash =
|
|
46
|
-
hash.
|
|
47
|
-
return hash.digest(HASH_DIGEST);
|
|
23
|
+
const hash = new md5_js_1.default().update((0, lodash_1.join)(parts, HASH_SEPARATOR));
|
|
24
|
+
return hash.digest('hex');
|
|
48
25
|
};
|
|
49
26
|
const componentAliasTable = {
|
|
50
27
|
'now-alert': 'eds-alert',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tectonicIdGenerator.js","sourceRoot":"","sources":["../../src/uxf/tectonicIdGenerator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG
|
|
1
|
+
{"version":3,"file":"tectonicIdGenerator.js","sourceRoot":"","sources":["../../src/uxf/tectonicIdGenerator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;AAiEH,kCAEC;AAjED,oDAAwB;AACxB,mCAA6B;AAE7B,MAAM,cAAc,GAAG,GAAG,CAAA;AAC1B,MAAM,SAAS,GAAG,cAAc,CAAA;AAEhC,MAAM,IAAI,GAAG,CAAC,KAAe,EAAE,EAAE;IAC7B,MAAM,IAAI,GAAG,IAAI,gBAAG,EAAE,CAAC,MAAM,CAAC,IAAA,aAAI,EAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAA;IAC1D,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG;IACxB,WAAW,EAAE,WAAW;IACxB,gBAAgB,EAAE,gBAAgB;IAClC,YAAY,EAAE,YAAY;IAC1B,WAAW,EAAE,WAAW;IACxB,YAAY,EAAE,YAAY;IAC1B,iBAAiB,EAAE,iBAAiB;IACpC,mBAAmB,EAAE,mBAAmB;IACxC,cAAc,EAAE,aAAa;IAC7B,cAAc,EAAE,cAAc;IAC9B,sBAAsB,EAAE,sBAAsB;IAC9C,kBAAkB,EAAE,kBAAkB;IACtC,iBAAiB,EAAE,SAAS;IAC5B,uBAAuB,EAAE,uBAAuB;IAChD,cAAc,EAAE,cAAc;IAC9B,oBAAoB,EAAE,oBAAoB;IAC1C,wBAAwB,EAAE,oBAAoB;IAC9C,aAAa,EAAE,aAAa;IAC5B,uBAAuB,EAAE,uBAAuB;IAChD,iBAAiB,EAAE,gBAAgB;IACnC,UAAU,EAAE,UAAU;IACtB,mBAAmB,EAAE,mBAAmB;IACxC,gBAAgB,EAAE,qBAAqB;IACvC,wBAAwB,EAAE,wBAAwB;IAClD,yBAAyB,EAAE,yBAAyB;IACpD,wBAAwB,EAAE,wBAAwB;IAClD,iBAAiB,EAAE,iBAAiB;IACpC,YAAY,EAAE,YAAY;IAC1B,mBAAmB,EAAE,aAAa;IAClC,WAAW,EAAE,WAAW;IACxB,6BAA6B,EAAE,4BAA4B;IAC3D,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,UAAU;IACtB,WAAW,EAAE,UAAU;IACvB,eAAe,EAAE,cAAc;IAC/B,kBAAkB,EAAE,kBAAkB;IACtC,eAAe,EAAE,eAAe;IAChC,YAAY,EAAE,YAAY;IAC1B,aAAa,EAAE,aAAa;IAC5B,UAAU,EAAE,mBAAmB;IAC/B,wBAAwB,EAAE,kCAAkC;IAC5D,0BAA0B,EAAE,oCAAoC;IAChE,mBAAmB,EAAE,gBAAgB;IACrC,gBAAgB,EAAE,aAAa;IAC/B,gBAAgB,EAAE,aAAa;IAC/B,gBAAgB,EAAE,aAAa;IAC/B,oBAAoB,EAAE,iBAAiB;IACvC,QAAQ,EAAE,WAAW;CACxB,CAAA;AAED,MAAM,oBAAoB,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,mBAAmB,CAAC,aAAa,CAAC,IAAI,aAAa,CAAA;AAEnG,SAAgB,WAAW,CAAC,gBAAwB;IAChD,OAAO,IAAI,CAAC,CAAC,SAAS,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,CAAC,CAAA;AACnF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicenow/sdk-build-plugins",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "ServiceNow SDK Build System Plugins",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -9,20 +9,18 @@
|
|
|
9
9
|
"src"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@ts-morph/common": "0.24.0",
|
|
13
12
|
"lodash": "4.17.21",
|
|
14
13
|
"moo": "0.5.2",
|
|
15
14
|
"nearley": "2.20.1",
|
|
16
|
-
"ts-morph": "23.0.0",
|
|
17
15
|
"xmlbuilder2": "3.1.1",
|
|
18
16
|
"zod": "3.22.4",
|
|
19
|
-
"
|
|
20
|
-
"@servicenow/sdk-core": "2.
|
|
21
|
-
"@servicenow/sdk-
|
|
22
|
-
"@servicenow/sdk-
|
|
17
|
+
"md5.js": "1.3.5",
|
|
18
|
+
"@servicenow/sdk-build-core": "2.2.2",
|
|
19
|
+
"@servicenow/sdk-core": "2.2.2",
|
|
20
|
+
"@servicenow/sdk-project": "2.2.2"
|
|
23
21
|
},
|
|
24
22
|
"overrides": {
|
|
25
|
-
"micromatch": "
|
|
23
|
+
"micromatch": "4.0.7"
|
|
26
24
|
},
|
|
27
25
|
"devDependencies": {
|
|
28
26
|
"@types/lodash": "4.14.195"
|
package/src/AttachmentPlugin.ts
CHANGED
|
@@ -12,13 +12,11 @@ import {
|
|
|
12
12
|
unloadBuilder,
|
|
13
13
|
} from '@servicenow/sdk-build-core'
|
|
14
14
|
import * as zlib from 'node:zlib'
|
|
15
|
-
import
|
|
16
|
-
import * as crypto from 'crypto'
|
|
15
|
+
import md5 from 'md5.js'
|
|
17
16
|
import { RecordXmlSchema } from './db/RecordPlugin'
|
|
18
17
|
import * as z from 'zod'
|
|
19
18
|
import { SysAttachment, SysAttachmentConfig } from '@servicenow/sdk-core/runtime/sys'
|
|
20
|
-
import {
|
|
21
|
-
import { Diagnostic, FileSystem } from '@servicenow/sdk-project'
|
|
19
|
+
import { Diagnostic, FileSystem, path, ts } from '@servicenow/sdk-project'
|
|
22
20
|
|
|
23
21
|
export const AttachmentPlugin = Plugin({
|
|
24
22
|
name: 'Attachment',
|
|
@@ -183,7 +181,7 @@ export const AttachmentPlugin = Plugin({
|
|
|
183
181
|
}
|
|
184
182
|
|
|
185
183
|
// Compress the file with gzip, then break into chuncks and base64 encode for each sys_attachment_doc
|
|
186
|
-
const hash =
|
|
184
|
+
const hash = new md5()
|
|
187
185
|
|
|
188
186
|
const contents = context.fs.readFileSync(contentFilePath, { flag: 'r' })
|
|
189
187
|
|
|
@@ -233,8 +231,8 @@ export const AttachmentPlugin = Plugin({
|
|
|
233
231
|
},
|
|
234
232
|
})
|
|
235
233
|
|
|
236
|
-
function getSourceFileDirectory(sourceFile: SourceFile): string {
|
|
237
|
-
const parsedPath = path.parse(
|
|
234
|
+
function getSourceFileDirectory(sourceFile: ts.SourceFile): string {
|
|
235
|
+
const parsedPath = path.parse(sourceFile.getFilePath())
|
|
238
236
|
return parsedPath.dir
|
|
239
237
|
}
|
|
240
238
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BusinessRule,
|
|
4
|
+
BusinessRuleSchemaInc,
|
|
5
|
+
getRolesArray,
|
|
6
|
+
localWhenSchemaTransformer,
|
|
7
|
+
} from '@servicenow/sdk-core/runtime/app'
|
|
3
8
|
import {
|
|
4
9
|
Plugin,
|
|
5
10
|
generateCallExpressionExportForDocument,
|
|
@@ -23,9 +28,8 @@ import {
|
|
|
23
28
|
} from '@servicenow/sdk-build-core'
|
|
24
29
|
import { processScript } from './ScriptTemplatePlugin'
|
|
25
30
|
import { extractCallExpressionAsRecord } from './db/RecordPlugin'
|
|
26
|
-
import { SyntaxKind, Node } from 'ts-morph'
|
|
27
31
|
import * as z from 'zod'
|
|
28
|
-
import { Diagnostic } from '@servicenow/sdk-project'
|
|
32
|
+
import { Diagnostic, ts } from '@servicenow/sdk-project'
|
|
29
33
|
import { Record, TableName } from '@servicenow/sdk-core/runtime/db'
|
|
30
34
|
import { getRolesString } from './aclAndRole/RolePlugin'
|
|
31
35
|
import { ModuleFunctionData } from './ServerModulePlugin'
|
|
@@ -60,6 +64,8 @@ function businessRuleAsRecord<const T extends TableName>(entity: EntityData<Busi
|
|
|
60
64
|
(action) => `${action.getValue()}Action`
|
|
61
65
|
)
|
|
62
66
|
|
|
67
|
+
const when = new StringData(localWhenSchemaTransformer(br.when.getValue()), br.when.getNode())
|
|
68
|
+
|
|
63
69
|
return new ObjectData(
|
|
64
70
|
{
|
|
65
71
|
$id: br.$id,
|
|
@@ -75,7 +81,7 @@ function businessRuleAsRecord<const T extends TableName>(entity: EntityData<Busi
|
|
|
75
81
|
action_query: new BooleanData(!!queryAction, queryAction?.getNode() ?? node),
|
|
76
82
|
action_delete: new BooleanData(!!deleteAction, deleteAction?.getNode() ?? node),
|
|
77
83
|
active: br.active ?? new BooleanData(true, node),
|
|
78
|
-
when: br.when
|
|
84
|
+
when: br.when ? when : new StringData('before', node),
|
|
79
85
|
message: br.message ?? new UndefinedData(node),
|
|
80
86
|
add_message: br.add_message ?? new BooleanData(br.message ? true : false, node),
|
|
81
87
|
condition: br.condition ?? new UndefinedData(node),
|
|
@@ -128,7 +134,7 @@ export default Plugin({
|
|
|
128
134
|
},
|
|
129
135
|
BusinessRule,
|
|
130
136
|
{ $id: document.guid }
|
|
131
|
-
).getExpressionIfKindOrThrow(SyntaxKind.CallExpression)
|
|
137
|
+
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
132
138
|
)
|
|
133
139
|
},
|
|
134
140
|
},
|
|
@@ -154,7 +160,7 @@ export default Plugin({
|
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
const [args] = document.node.getArguments()
|
|
157
|
-
if (!Node.isObjectLiteralExpression(args)) {
|
|
163
|
+
if (!ts.Node.isObjectLiteralExpression(args)) {
|
|
158
164
|
return false
|
|
159
165
|
}
|
|
160
166
|
const {
|
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
removeNode,
|
|
13
13
|
transformFunctionArguments,
|
|
14
14
|
} from '@servicenow/sdk-build-core'
|
|
15
|
-
import { SyntaxKind } from 'ts-morph'
|
|
16
15
|
import { RecordPlugin } from './db/RecordPlugin'
|
|
17
|
-
import { Diagnostic } from '@servicenow/sdk-project'
|
|
16
|
+
import { Diagnostic, ts } from '@servicenow/sdk-project'
|
|
18
17
|
import { Record } from '@servicenow/sdk-core/runtime/db'
|
|
19
18
|
import { except } from './scripts/scriptUtils'
|
|
20
19
|
|
|
@@ -84,7 +83,7 @@ export default Plugin({
|
|
|
84
83
|
},
|
|
85
84
|
CrossScopePrivilege,
|
|
86
85
|
{ $id: document.guid }
|
|
87
|
-
).getExpressionIfKindOrThrow(SyntaxKind.CallExpression)
|
|
86
|
+
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
88
87
|
)
|
|
89
88
|
},
|
|
90
89
|
},
|
package/src/DefaultPlugin.ts
CHANGED
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
Data,
|
|
10
10
|
ArrayData,
|
|
11
11
|
ObjectData,
|
|
12
|
+
getDirectiveDiagnostics,
|
|
12
13
|
} from '@servicenow/sdk-build-core'
|
|
13
|
-
import
|
|
14
|
+
import { ts } from '@servicenow/sdk-project'
|
|
14
15
|
|
|
15
16
|
export default Plugin({
|
|
16
17
|
name: 'Default',
|
|
@@ -21,7 +22,7 @@ export default Plugin({
|
|
|
21
22
|
return {
|
|
22
23
|
handled: true,
|
|
23
24
|
diagnostics: [],
|
|
24
|
-
data:
|
|
25
|
+
data: new BooleanData(true, node),
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
|
|
@@ -29,7 +30,7 @@ export default Plugin({
|
|
|
29
30
|
return {
|
|
30
31
|
handled: true,
|
|
31
32
|
diagnostics: [],
|
|
32
|
-
data:
|
|
33
|
+
data: new BooleanData(false, node),
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
|
|
@@ -37,7 +38,7 @@ export default Plugin({
|
|
|
37
38
|
return {
|
|
38
39
|
handled: true,
|
|
39
40
|
diagnostics: [],
|
|
40
|
-
data:
|
|
41
|
+
data: new StringData(node.getLiteralValue(), node),
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
|
|
@@ -45,7 +46,7 @@ export default Plugin({
|
|
|
45
46
|
return {
|
|
46
47
|
handled: true,
|
|
47
48
|
diagnostics: [],
|
|
48
|
-
data:
|
|
49
|
+
data: new StringData(node.getLiteralValue(), node),
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
52
|
|
|
@@ -53,7 +54,7 @@ export default Plugin({
|
|
|
53
54
|
return {
|
|
54
55
|
handled: true,
|
|
55
56
|
diagnostics: [],
|
|
56
|
-
data:
|
|
57
|
+
data: new NumberData(node.getLiteralValue(), node),
|
|
57
58
|
}
|
|
58
59
|
},
|
|
59
60
|
|
|
@@ -86,7 +87,6 @@ export default Plugin({
|
|
|
86
87
|
if (!initializer) {
|
|
87
88
|
return {
|
|
88
89
|
handled: true,
|
|
89
|
-
data: [],
|
|
90
90
|
diagnostics: [
|
|
91
91
|
new FluentDiagnostic(
|
|
92
92
|
node,
|
|
@@ -104,7 +104,6 @@ export default Plugin({
|
|
|
104
104
|
if (!initializer) {
|
|
105
105
|
return {
|
|
106
106
|
handled: true,
|
|
107
|
-
data: [],
|
|
108
107
|
diagnostics: [
|
|
109
108
|
new FluentDiagnostic(
|
|
110
109
|
node,
|
|
@@ -126,19 +125,20 @@ export default Plugin({
|
|
|
126
125
|
if (!result.handled) {
|
|
127
126
|
return {
|
|
128
127
|
handled: true,
|
|
129
|
-
data: [],
|
|
130
128
|
diagnostics: [new FluentDiagnostic(element, 'Unsupported array element')],
|
|
131
129
|
}
|
|
132
130
|
}
|
|
133
131
|
|
|
134
132
|
diagnostics.push(...result.diagnostics)
|
|
135
|
-
|
|
133
|
+
if (result.data) {
|
|
134
|
+
data.push(result.data)
|
|
135
|
+
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
return {
|
|
139
139
|
handled: true,
|
|
140
140
|
diagnostics,
|
|
141
|
-
data:
|
|
141
|
+
data: new ArrayData(data, node),
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
144
|
|
|
@@ -157,13 +157,12 @@ export default Plugin({
|
|
|
157
157
|
if (!result.handled) {
|
|
158
158
|
return {
|
|
159
159
|
handled: true,
|
|
160
|
-
data: [],
|
|
161
160
|
diagnostics: [new FluentDiagnostic(prop, 'Unsupported property assignment')],
|
|
162
161
|
}
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
diagnostics.push(...result.diagnostics)
|
|
166
|
-
if (!
|
|
165
|
+
if (!result.data) {
|
|
167
166
|
diagnostics.push(
|
|
168
167
|
new FluentDiagnostic(nameNode, `Property assignment has unsupported structure`)
|
|
169
168
|
)
|
|
@@ -171,13 +170,13 @@ export default Plugin({
|
|
|
171
170
|
}
|
|
172
171
|
|
|
173
172
|
const name = ts.Node.isStringLiteral(nameNode) ? nameNode.getLiteralValue() : prop.getName()
|
|
174
|
-
data[name] = result.data
|
|
173
|
+
data[name] = result.data
|
|
175
174
|
}
|
|
176
175
|
|
|
177
176
|
return {
|
|
178
177
|
handled: true,
|
|
179
178
|
diagnostics,
|
|
180
|
-
data:
|
|
179
|
+
data: new ObjectData(data, node),
|
|
181
180
|
}
|
|
182
181
|
},
|
|
183
182
|
|
|
@@ -194,20 +193,20 @@ export default Plugin({
|
|
|
194
193
|
return undefined
|
|
195
194
|
}
|
|
196
195
|
|
|
197
|
-
if (!
|
|
196
|
+
if (!result.data) {
|
|
198
197
|
diagnostics.push(new FluentDiagnostic(s, `Unsupported expression in template`))
|
|
199
198
|
return undefined
|
|
200
199
|
}
|
|
201
200
|
|
|
202
201
|
diagnostics.push(...result.diagnostics)
|
|
203
|
-
return `${result.data
|
|
202
|
+
return `${result.data.getValue()}${s.getLiteral().getLiteralText()}`
|
|
204
203
|
})
|
|
205
204
|
.join('')
|
|
206
205
|
|
|
207
206
|
return {
|
|
208
207
|
handled: true,
|
|
209
208
|
diagnostics,
|
|
210
|
-
data:
|
|
209
|
+
data: new StringData(text, node),
|
|
211
210
|
}
|
|
212
211
|
},
|
|
213
212
|
|
|
@@ -219,7 +218,6 @@ export default Plugin({
|
|
|
219
218
|
) {
|
|
220
219
|
return {
|
|
221
220
|
handled: true,
|
|
222
|
-
data: [],
|
|
223
221
|
diagnostics: [new FluentDiagnostic(node, 'Unsupported prefix unary expression')],
|
|
224
222
|
}
|
|
225
223
|
}
|
|
@@ -227,12 +225,10 @@ export default Plugin({
|
|
|
227
225
|
return {
|
|
228
226
|
handled: true,
|
|
229
227
|
diagnostics: [],
|
|
230
|
-
data:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
),
|
|
235
|
-
],
|
|
228
|
+
data: new NumberData(
|
|
229
|
+
-node.getOperand().asKind(ts.SyntaxKind.NumericLiteral)!.getLiteralValue(),
|
|
230
|
+
node
|
|
231
|
+
),
|
|
236
232
|
}
|
|
237
233
|
},
|
|
238
234
|
},
|
|
@@ -241,7 +237,7 @@ export default Plugin({
|
|
|
241
237
|
diagnostics: {
|
|
242
238
|
Node(node) {
|
|
243
239
|
if (isSupportedNode(node)) {
|
|
244
|
-
return
|
|
240
|
+
return getDirectiveDiagnostics(node)
|
|
245
241
|
}
|
|
246
242
|
|
|
247
243
|
return [new FluentDiagnostic(node, `${getRawKindName(node)} is not allowed`)]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Plugin, StringData, UndefinedData } from '@servicenow/sdk-build-core'
|
|
2
|
-
import
|
|
2
|
+
import { ts } from '@servicenow/sdk-project'
|
|
3
3
|
|
|
4
4
|
const TEMPLATE_LITERAL_TAG = 'html'
|
|
5
5
|
|
|
@@ -18,7 +18,7 @@ export default Plugin({
|
|
|
18
18
|
return {
|
|
19
19
|
handled: true,
|
|
20
20
|
diagnostics: [],
|
|
21
|
-
data:
|
|
21
|
+
data: typeof value === 'string' ? new StringData(value, node) : new UndefinedData(node),
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
},
|
package/src/IdPlugin.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { isSupportedNode } from '@servicenow/sdk-project'
|
|
2
|
-
import { SyntaxKind } from 'ts-morph'
|
|
1
|
+
import { isSupportedNode, ts } from '@servicenow/sdk-project'
|
|
3
2
|
import { Plugin, FluentDiagnostic, StringData, Data } from '@servicenow/sdk-build-core'
|
|
4
3
|
|
|
5
4
|
export default Plugin({
|
|
@@ -8,7 +7,7 @@ export default Plugin({
|
|
|
8
7
|
raw: {
|
|
9
8
|
fluent: {
|
|
10
9
|
ElementAccessExpression(node, context) {
|
|
11
|
-
const nowIdExpression = node.getExpressionIfKind(SyntaxKind.PropertyAccessExpression)
|
|
10
|
+
const nowIdExpression = node.getExpressionIfKind(ts.SyntaxKind.PropertyAccessExpression)
|
|
12
11
|
if (!nowIdExpression || nowIdExpression.getText() !== 'Now.ID') {
|
|
13
12
|
return {
|
|
14
13
|
handled: false,
|
|
@@ -19,7 +18,6 @@ export default Plugin({
|
|
|
19
18
|
if (!argExpression || !isSupportedNode(argExpression)) {
|
|
20
19
|
return {
|
|
21
20
|
handled: true,
|
|
22
|
-
data: [],
|
|
23
21
|
diagnostics: [new FluentDiagnostic(node, 'Now.ID must have an argument')],
|
|
24
22
|
}
|
|
25
23
|
}
|
|
@@ -28,15 +26,13 @@ export default Plugin({
|
|
|
28
26
|
if (!result.handled) {
|
|
29
27
|
return {
|
|
30
28
|
handled: true,
|
|
31
|
-
data: [],
|
|
32
29
|
diagnostics: [new FluentDiagnostic(node, 'Unsupported Now.ID argument')],
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
if (!
|
|
33
|
+
if (!result.data) {
|
|
37
34
|
return {
|
|
38
35
|
handled: true,
|
|
39
|
-
data: [],
|
|
40
36
|
diagnostics: [
|
|
41
37
|
...result.diagnostics,
|
|
42
38
|
new FluentDiagnostic(node, 'Unsupported Now.ID argument'),
|
|
@@ -51,7 +47,7 @@ export default Plugin({
|
|
|
51
47
|
return { handled: false }
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
const identifier = node.getExpressionIfKind(SyntaxKind.Identifier)
|
|
50
|
+
const identifier = node.getExpressionIfKind(ts.SyntaxKind.Identifier)
|
|
55
51
|
if (!identifier) {
|
|
56
52
|
return { handled: false }
|
|
57
53
|
}
|
|
@@ -61,7 +57,7 @@ export default Plugin({
|
|
|
61
57
|
return { handled: false }
|
|
62
58
|
}
|
|
63
59
|
|
|
64
|
-
const entity = extraction.data
|
|
60
|
+
const entity = extraction.data
|
|
65
61
|
if (!Data.isEntity(entity)) {
|
|
66
62
|
return { handled: false }
|
|
67
63
|
}
|
|
@@ -69,7 +65,7 @@ export default Plugin({
|
|
|
69
65
|
return {
|
|
70
66
|
handled: true,
|
|
71
67
|
diagnostics: [],
|
|
72
|
-
data:
|
|
68
|
+
data: new StringData(entity.getGuid(), node),
|
|
73
69
|
}
|
|
74
70
|
},
|
|
75
71
|
},
|
package/src/JsonPlugin.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { isSupportedNode } from '@servicenow/sdk-project'
|
|
2
|
-
import { SyntaxKind } from 'ts-morph'
|
|
1
|
+
import { isSupportedNode, ts } from '@servicenow/sdk-project'
|
|
3
2
|
import { Plugin, FluentDiagnostic, Data, StringData } from '@servicenow/sdk-build-core'
|
|
4
3
|
|
|
5
4
|
export default Plugin({
|
|
@@ -9,16 +8,16 @@ export default Plugin({
|
|
|
9
8
|
json: {
|
|
10
9
|
SourceFile(node, context) {
|
|
11
10
|
const objectLiteral = node
|
|
12
|
-
.getFirstChildIfKind(SyntaxKind.SyntaxList)
|
|
13
|
-
?.getFirstChildIfKind(SyntaxKind.ExpressionStatement)
|
|
14
|
-
?.getFirstChildIfKind(SyntaxKind.ObjectLiteralExpression)
|
|
11
|
+
.getFirstChildIfKind(ts.SyntaxKind.SyntaxList)
|
|
12
|
+
?.getFirstChildIfKind(ts.SyntaxKind.ExpressionStatement)
|
|
13
|
+
?.getFirstChildIfKind(ts.SyntaxKind.ObjectLiteralExpression)
|
|
15
14
|
|
|
16
15
|
return objectLiteral ? context.extractAst(objectLiteral) : { handled: false }
|
|
17
16
|
},
|
|
18
17
|
},
|
|
19
18
|
fluent: {
|
|
20
19
|
CallExpression(node, context) {
|
|
21
|
-
const expression = node.getExpressionIfKind(SyntaxKind.PropertyAccessExpression)
|
|
20
|
+
const expression = node.getExpressionIfKind(ts.SyntaxKind.PropertyAccessExpression)
|
|
22
21
|
if (!expression || expression.getText() !== 'JSON.stringify') {
|
|
23
22
|
return {
|
|
24
23
|
handled: false,
|
|
@@ -29,7 +28,6 @@ export default Plugin({
|
|
|
29
28
|
if (!argument || !isSupportedNode(argument)) {
|
|
30
29
|
return {
|
|
31
30
|
handled: true,
|
|
32
|
-
data: [],
|
|
33
31
|
diagnostics: [new FluentDiagnostic(node, 'JSON.stringify must have an argument')],
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -38,7 +36,6 @@ export default Plugin({
|
|
|
38
36
|
if (secondArgument) {
|
|
39
37
|
return {
|
|
40
38
|
handled: true,
|
|
41
|
-
data: [],
|
|
42
39
|
diagnostics: [
|
|
43
40
|
new FluentDiagnostic(
|
|
44
41
|
secondArgument,
|
|
@@ -52,16 +49,14 @@ export default Plugin({
|
|
|
52
49
|
if (!result.handled) {
|
|
53
50
|
return {
|
|
54
51
|
handled: true,
|
|
55
|
-
data: [],
|
|
56
52
|
diagnostics: [new FluentDiagnostic(argument, 'Unsupported JSON.stringify argument')],
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
const data = result.data
|
|
56
|
+
const data = result.data
|
|
61
57
|
if (!Data.isObject(data)) {
|
|
62
58
|
return {
|
|
63
59
|
handled: true,
|
|
64
|
-
data: [],
|
|
65
60
|
diagnostics: [
|
|
66
61
|
...result.diagnostics,
|
|
67
62
|
new FluentDiagnostic(argument, 'Unsupported JSON.stringify argument'),
|
|
@@ -72,7 +67,7 @@ export default Plugin({
|
|
|
72
67
|
return {
|
|
73
68
|
handled: true,
|
|
74
69
|
diagnostics: result.diagnostics,
|
|
75
|
-
data:
|
|
70
|
+
data: new StringData(JSON.stringify(data.getValue()), node),
|
|
76
71
|
}
|
|
77
72
|
},
|
|
78
73
|
},
|
package/src/ListPlugin.ts
CHANGED
|
@@ -21,9 +21,7 @@ import {
|
|
|
21
21
|
} from '@servicenow/sdk-build-core'
|
|
22
22
|
import { RecordXmlSchema } from './db/RecordPlugin'
|
|
23
23
|
import * as z from 'zod'
|
|
24
|
-
import {
|
|
25
|
-
import * as path from 'path'
|
|
26
|
-
import { Diagnostic } from '@servicenow/sdk-project'
|
|
24
|
+
import { Diagnostic, path, ts } from '@servicenow/sdk-project'
|
|
27
25
|
import { isObject } from 'lodash'
|
|
28
26
|
import { Record as NowRecord } from '@servicenow/sdk-core/runtime/db'
|
|
29
27
|
|
|
@@ -159,7 +157,7 @@ export default Plugin({
|
|
|
159
157
|
return false
|
|
160
158
|
}
|
|
161
159
|
const [listArgument] = document.node.getArguments()
|
|
162
|
-
if (!Node.isObjectLiteralExpression(listArgument)) {
|
|
160
|
+
if (!ts.Node.isObjectLiteralExpression(listArgument)) {
|
|
163
161
|
return false
|
|
164
162
|
}
|
|
165
163
|
|
|
@@ -194,7 +192,7 @@ export default Plugin({
|
|
|
194
192
|
},
|
|
195
193
|
List,
|
|
196
194
|
{ $id: id }
|
|
197
|
-
).getExpressionIfKindOrThrow(SyntaxKind.CallExpression)
|
|
195
|
+
).getExpressionIfKindOrThrow(ts.SyntaxKind.CallExpression)
|
|
198
196
|
)
|
|
199
197
|
},
|
|
200
198
|
},
|
|
@@ -324,7 +322,7 @@ const updateView = (context, listArgument, view) => {
|
|
|
324
322
|
|
|
325
323
|
if (!viewExport.exported) {
|
|
326
324
|
context.logger.warn(
|
|
327
|
-
`View record is defined in ${
|
|
325
|
+
`View record is defined in ${viewNode.getSourceFile().getFilePath()} and is not exported`
|
|
328
326
|
)
|
|
329
327
|
listArgument.addPropertyAssignment({ name: 'view', initializer: `'${view.name}'` })
|
|
330
328
|
return
|
|
@@ -367,19 +365,19 @@ type ExportsInfo =
|
|
|
367
365
|
| { exported: true; identifier: string; type: 'Named' }
|
|
368
366
|
| { exported: true; type: 'Default' }
|
|
369
367
|
|
|
370
|
-
const getExportTypeAndName = (sourceNode: CallExpression): ExportsInfo => {
|
|
368
|
+
const getExportTypeAndName = (sourceNode: ts.CallExpression): ExportsInfo => {
|
|
371
369
|
// const defaultExports = sourceNode.getSourceFile().getExportSymbols()
|
|
372
370
|
const parentNode = sourceNode.getParent()
|
|
373
371
|
|
|
374
372
|
// export declarations are blocked by fluent-diagnostics
|
|
375
373
|
switch (parentNode?.getKind()) {
|
|
376
|
-
case SyntaxKind.ExportAssignment:
|
|
374
|
+
case ts.SyntaxKind.ExportAssignment:
|
|
377
375
|
return { exported: true, type: 'Default' }
|
|
378
|
-
case SyntaxKind.VariableDeclaration: {
|
|
379
|
-
const identifier = getIdentifier(parentNode as VariableDeclaration)!
|
|
376
|
+
case ts.SyntaxKind.VariableDeclaration: {
|
|
377
|
+
const identifier = getIdentifier(parentNode as ts.VariableDeclaration)!
|
|
380
378
|
|
|
381
|
-
const variableStmt = parentNode.getParentIfKind(SyntaxKind.VariableStatement)
|
|
382
|
-
const exportKeyword = variableStmt?.getFirstChildByKind(SyntaxKind.ExportKeyword)
|
|
379
|
+
const variableStmt = parentNode.getParentIfKind(ts.SyntaxKind.VariableStatement)
|
|
380
|
+
const exportKeyword = variableStmt?.getFirstChildByKind(ts.SyntaxKind.ExportKeyword)
|
|
383
381
|
|
|
384
382
|
if (exportKeyword) {
|
|
385
383
|
return { exported: true, type: 'Named', identifier }
|
|
@@ -387,19 +385,19 @@ const getExportTypeAndName = (sourceNode: CallExpression): ExportsInfo => {
|
|
|
387
385
|
return { exported: false, identifier }
|
|
388
386
|
}
|
|
389
387
|
|
|
390
|
-
case SyntaxKind.ExpressionStatement:
|
|
388
|
+
case ts.SyntaxKind.ExpressionStatement:
|
|
391
389
|
default:
|
|
392
390
|
return { exported: false }
|
|
393
391
|
}
|
|
394
392
|
}
|
|
395
393
|
|
|
396
|
-
const getIdentifier = (sourceNode: CallExpression | VariableDeclaration): string | undefined => {
|
|
394
|
+
const getIdentifier = (sourceNode: ts.CallExpression | ts.VariableDeclaration): string | undefined => {
|
|
397
395
|
const variableDeclaration =
|
|
398
|
-
sourceNode.getKind() === SyntaxKind.CallExpression
|
|
399
|
-
? sourceNode.getParentIfKind(SyntaxKind.VariableDeclaration)
|
|
396
|
+
sourceNode.getKind() === ts.SyntaxKind.CallExpression
|
|
397
|
+
? sourceNode.getParentIfKind(ts.SyntaxKind.VariableDeclaration)
|
|
400
398
|
: sourceNode
|
|
401
399
|
|
|
402
|
-
return variableDeclaration?.getFirstChildByKind(SyntaxKind.Identifier)?.getText()
|
|
400
|
+
return variableDeclaration?.getFirstChildByKind(ts.SyntaxKind.Identifier)?.getText()
|
|
403
401
|
}
|
|
404
402
|
|
|
405
403
|
const getImportPath = (listSourcePath, viewSourcePath): string | undefined => {
|
|
@@ -409,20 +407,20 @@ const getImportPath = (listSourcePath, viewSourcePath): string | undefined => {
|
|
|
409
407
|
|
|
410
408
|
const viewFilePath = path.parse(viewSourcePath)
|
|
411
409
|
const listFilePath = path.parse(listSourcePath)
|
|
412
|
-
const relativePath = path.
|
|
410
|
+
const relativePath = path.join(path.relative(listFilePath.dir, viewFilePath.dir), viewFilePath.name)
|
|
413
411
|
// relativePath = relativePath.replace(path.extname(relativePath), '')
|
|
414
412
|
return relativePath.startsWith('.') ? relativePath : `./${relativePath}`
|
|
415
413
|
}
|
|
416
414
|
|
|
417
|
-
const setColumnsList = (columnsProperty: PropertyAssignment, elements: SysUIListElementXml) => {
|
|
418
|
-
const [array] = columnsProperty.getChildrenOfKind(SyntaxKind.ArrayLiteralExpression)
|
|
415
|
+
const setColumnsList = (columnsProperty: ts.PropertyAssignment, elements: SysUIListElementXml) => {
|
|
416
|
+
const [array] = columnsProperty.getChildrenOfKind(ts.SyntaxKind.ArrayLiteralExpression)
|
|
419
417
|
let serializeValue: string = '[]'
|
|
420
418
|
if (array) {
|
|
421
|
-
const elementSyntaxList = array.getChildAtIndexIfKind(1, SyntaxKind.SyntaxList)
|
|
419
|
+
const elementSyntaxList = array.getChildAtIndexIfKind(1, ts.SyntaxKind.SyntaxList)
|
|
422
420
|
|
|
423
421
|
//If the columns are defined as objects or need to be expressed that way due to additional properties set on instance
|
|
424
422
|
if (
|
|
425
|
-
!!elementSyntaxList?.getChildrenOfKind(SyntaxKind.ObjectLiteralExpression).length ||
|
|
423
|
+
!!elementSyntaxList?.getChildrenOfKind(ts.SyntaxKind.ObjectLiteralExpression).length ||
|
|
426
424
|
columnsNeedObjectLiterals(elements)
|
|
427
425
|
) {
|
|
428
426
|
const newElements = elements.map((element, index) => {
|