@servicenow/sdk-build-core 3.0.3 → 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/app.d.ts +25 -0
- package/dist/app.js +8 -0
- package/dist/app.js.map +1 -0
- package/dist/compiler.d.ts +60 -0
- package/dist/compiler.js +320 -0
- package/dist/compiler.js.map +1 -0
- package/dist/compression.d.ts +7 -0
- package/dist/compression.js +79 -0
- package/dist/compression.js.map +1 -0
- package/dist/crypto.d.ts +1 -0
- package/dist/crypto.js +9 -0
- package/dist/crypto.js.map +1 -0
- package/dist/diagnostic.d.ts +41 -0
- package/dist/diagnostic.js +130 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/{plugins/Diagnostic.d.ts → fluent-diagnostic.d.ts} +3 -2
- package/dist/fluent-diagnostic.js +23 -0
- package/dist/fluent-diagnostic.js.map +1 -0
- package/dist/fluent-directive.d.ts +8 -0
- package/dist/fluent-directive.js +54 -0
- package/dist/fluent-directive.js.map +1 -0
- package/dist/fluent-file.d.ts +5 -0
- package/dist/fluent-file.js +15 -0
- package/dist/fluent-file.js.map +1 -0
- package/dist/formatter.d.ts +11 -0
- package/dist/formatter.js +77 -0
- package/dist/formatter.js.map +1 -0
- package/dist/fs.d.ts +174 -0
- package/dist/fs.js +313 -0
- package/dist/fs.js.map +1 -0
- package/dist/guid.d.ts +2 -0
- package/dist/{GUID.js → guid.js} +3 -6
- package/dist/guid.js.map +1 -0
- package/dist/index.d.ts +19 -5
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +5 -0
- package/dist/json.js +43 -0
- package/dist/json.js.map +1 -0
- package/dist/keys-registry.d.ts +64 -0
- package/dist/keys-registry.js +339 -0
- package/dist/keys-registry.js.map +1 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.js +17 -0
- package/dist/logger.js.map +1 -0
- package/dist/now-config.d.ts +348 -0
- package/dist/now-config.js +283 -0
- package/dist/now-config.js.map +1 -0
- package/dist/path.d.ts +3 -0
- package/dist/path.js +12 -0
- package/dist/path.js.map +1 -0
- package/dist/plugins/cache.d.ts +20 -0
- package/dist/plugins/cache.js +46 -0
- package/dist/plugins/cache.js.map +1 -0
- package/dist/plugins/context.d.ts +85 -0
- package/dist/plugins/{Context.js → context.js} +1 -1
- package/dist/plugins/context.js.map +1 -0
- package/dist/plugins/database.d.ts +27 -0
- package/dist/plugins/database.js +102 -0
- package/dist/plugins/database.js.map +1 -0
- package/dist/plugins/file.d.ts +10 -0
- package/dist/plugins/{behaviors/Arranger.js → file.js} +1 -1
- package/dist/plugins/file.js.map +1 -0
- package/dist/plugins/index.d.ts +9 -5
- package/dist/plugins/index.js +9 -6
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/plugin.d.ts +478 -0
- package/dist/plugins/plugin.js +533 -0
- package/dist/plugins/plugin.js.map +1 -0
- package/dist/plugins/product.d.ts +15 -0
- package/dist/plugins/product.js +38 -0
- package/dist/plugins/product.js.map +1 -0
- package/dist/plugins/project.d.ts +25 -0
- package/dist/plugins/{behaviors/Generator.js → project.js} +1 -1
- package/dist/plugins/project.js.map +1 -0
- package/dist/plugins/shape.d.ts +424 -0
- package/dist/plugins/shape.js +1181 -0
- package/dist/plugins/shape.js.map +1 -0
- package/dist/plugins/time.d.ts +12 -0
- package/dist/plugins/time.js +84 -0
- package/dist/plugins/time.js.map +1 -0
- package/dist/plugins/usage.d.ts +11 -0
- package/dist/plugins/usage.js +26 -0
- package/dist/plugins/usage.js.map +1 -0
- package/dist/prettier/config-loader.d.ts +13 -0
- package/dist/prettier/config-loader.js +105 -0
- package/dist/prettier/config-loader.js.map +1 -0
- package/dist/telemetry/index.d.ts +25 -0
- package/dist/telemetry/index.js +18 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/typescript.d.ts +293 -0
- package/dist/typescript.js +454 -0
- package/dist/typescript.js.map +1 -0
- package/dist/util/get-file-type.d.ts +2 -0
- package/dist/util/get-file-type.js +13 -0
- package/dist/util/get-file-type.js.map +1 -0
- package/dist/util/index.d.ts +2 -6
- package/dist/util/index.js +2 -6
- package/dist/util/index.js.map +1 -1
- package/dist/util/{Scope.js → is-sn-scope.js} +1 -1
- package/dist/util/is-sn-scope.js.map +1 -0
- package/dist/xml.d.ts +24 -0
- package/dist/xml.js +71 -0
- package/dist/xml.js.map +1 -0
- package/now.config.schema.json +336 -0
- package/package.json +22 -12
- package/src/app.ts +33 -0
- package/src/compiler.ts +384 -0
- package/src/compression.ts +93 -0
- package/src/crypto.ts +5 -0
- package/src/diagnostic.ts +108 -0
- package/src/{plugins/Diagnostic.ts → fluent-diagnostic.ts} +3 -10
- package/src/fluent-directive.ts +63 -0
- package/src/fluent-file.ts +13 -0
- package/src/formatter.ts +58 -0
- package/src/fs.ts +438 -0
- package/src/{GUID.ts → guid.ts} +2 -6
- package/src/index.ts +19 -5
- package/src/json.ts +20 -0
- package/src/keys-registry.ts +384 -0
- package/src/logger.ts +20 -0
- package/src/now-config.ts +337 -0
- package/src/path.ts +9 -0
- package/src/plugins/cache.ts +45 -0
- package/src/plugins/context.ts +93 -0
- package/src/plugins/database.ts +121 -0
- package/src/plugins/file.ts +19 -0
- package/src/plugins/index.ts +9 -5
- package/src/plugins/plugin.ts +995 -0
- package/src/plugins/product.ts +44 -0
- package/src/plugins/project.ts +39 -0
- package/src/plugins/shape.ts +1532 -0
- package/src/plugins/time.ts +108 -0
- package/src/plugins/usage.ts +26 -0
- package/src/prettier/config-loader.ts +130 -0
- package/src/telemetry/index.ts +27 -0
- package/src/typescript.ts +502 -0
- package/src/util/get-file-type.ts +11 -0
- package/src/util/index.ts +2 -6
- package/src/xml.ts +86 -0
- package/dist/GUID.d.ts +0 -2
- package/dist/GUID.js.map +0 -1
- package/dist/IncludePaths.d.ts +0 -25
- package/dist/IncludePaths.js +0 -97
- package/dist/IncludePaths.js.map +0 -1
- package/dist/Keys.d.ts +0 -32
- package/dist/Keys.js +0 -245
- package/dist/Keys.js.map +0 -1
- package/dist/TypeScript.d.ts +0 -5
- package/dist/TypeScript.js +0 -58
- package/dist/TypeScript.js.map +0 -1
- package/dist/XML.d.ts +0 -32
- package/dist/XML.js +0 -83
- package/dist/XML.js.map +0 -1
- package/dist/plugins/Context.d.ts +0 -190
- package/dist/plugins/Context.js.map +0 -1
- package/dist/plugins/Diagnostic.js +0 -28
- package/dist/plugins/Diagnostic.js.map +0 -1
- package/dist/plugins/Plugin.d.ts +0 -175
- package/dist/plugins/Plugin.js +0 -15
- package/dist/plugins/Plugin.js.map +0 -1
- package/dist/plugins/behaviors/Arranger.d.ts +0 -26
- package/dist/plugins/behaviors/Arranger.js.map +0 -1
- package/dist/plugins/behaviors/Composer.d.ts +0 -102
- package/dist/plugins/behaviors/Composer.js +0 -15
- package/dist/plugins/behaviors/Composer.js.map +0 -1
- package/dist/plugins/behaviors/Diagnostics.d.ts +0 -7
- package/dist/plugins/behaviors/Diagnostics.js +0 -3
- package/dist/plugins/behaviors/Diagnostics.js.map +0 -1
- package/dist/plugins/behaviors/Generator.d.ts +0 -21
- package/dist/plugins/behaviors/Generator.js.map +0 -1
- package/dist/plugins/behaviors/OwnedTables.d.ts +0 -6
- package/dist/plugins/behaviors/OwnedTables.js +0 -3
- package/dist/plugins/behaviors/OwnedTables.js.map +0 -1
- package/dist/plugins/behaviors/PostProcessor.d.ts +0 -5
- package/dist/plugins/behaviors/PostProcessor.js +0 -3
- package/dist/plugins/behaviors/PostProcessor.js.map +0 -1
- package/dist/plugins/behaviors/Serializer.d.ts +0 -30
- package/dist/plugins/behaviors/Serializer.js +0 -3
- package/dist/plugins/behaviors/Serializer.js.map +0 -1
- package/dist/plugins/behaviors/Transformer.d.ts +0 -23
- package/dist/plugins/behaviors/Transformer.js +0 -3
- package/dist/plugins/behaviors/Transformer.js.map +0 -1
- package/dist/plugins/behaviors/extractors/Data.d.ts +0 -119
- package/dist/plugins/behaviors/extractors/Data.js +0 -244
- package/dist/plugins/behaviors/extractors/Data.js.map +0 -1
- package/dist/plugins/behaviors/extractors/Extractors.d.ts +0 -63
- package/dist/plugins/behaviors/extractors/Extractors.js +0 -3
- package/dist/plugins/behaviors/extractors/Extractors.js.map +0 -1
- package/dist/plugins/behaviors/extractors/index.d.ts +0 -2
- package/dist/plugins/behaviors/extractors/index.js +0 -19
- package/dist/plugins/behaviors/extractors/index.js.map +0 -1
- package/dist/plugins/behaviors/index.d.ts +0 -9
- package/dist/plugins/behaviors/index.js +0 -26
- package/dist/plugins/behaviors/index.js.map +0 -1
- package/dist/plugins/util/CallExpression.d.ts +0 -5
- package/dist/plugins/util/CallExpression.js +0 -88
- package/dist/plugins/util/CallExpression.js.map +0 -1
- package/dist/plugins/util/CodeTransformation.d.ts +0 -95
- package/dist/plugins/util/CodeTransformation.js +0 -624
- package/dist/plugins/util/CodeTransformation.js.map +0 -1
- package/dist/plugins/util/ObjectLiteral.d.ts +0 -9
- package/dist/plugins/util/ObjectLiteral.js +0 -37
- package/dist/plugins/util/ObjectLiteral.js.map +0 -1
- package/dist/plugins/util/index.d.ts +0 -3
- package/dist/plugins/util/index.js +0 -20
- package/dist/plugins/util/index.js.map +0 -1
- package/dist/util/Debug.d.ts +0 -4
- package/dist/util/Debug.js +0 -20
- package/dist/util/Debug.js.map +0 -1
- package/dist/util/Directive.d.ts +0 -16
- package/dist/util/Directive.js +0 -107
- package/dist/util/Directive.js.map +0 -1
- package/dist/util/RuntimeTableSchema.d.ts +0 -5
- package/dist/util/RuntimeTableSchema.js +0 -58
- package/dist/util/RuntimeTableSchema.js.map +0 -1
- package/dist/util/Scope.js.map +0 -1
- package/dist/util/Util.d.ts +0 -1
- package/dist/util/Util.js +0 -12
- package/dist/util/Util.js.map +0 -1
- package/dist/util/XMLUploadParser.d.ts +0 -22
- package/dist/util/XMLUploadParser.js +0 -67
- package/dist/util/XMLUploadParser.js.map +0 -1
- package/src/IncludePaths.ts +0 -122
- package/src/Keys.ts +0 -274
- package/src/TypeScript.ts +0 -65
- package/src/XML.ts +0 -98
- package/src/plugins/Context.ts +0 -239
- package/src/plugins/Plugin.ts +0 -278
- package/src/plugins/behaviors/Arranger.ts +0 -42
- package/src/plugins/behaviors/Composer.ts +0 -125
- package/src/plugins/behaviors/Diagnostics.ts +0 -12
- package/src/plugins/behaviors/Generator.ts +0 -31
- package/src/plugins/behaviors/OwnedTables.ts +0 -5
- package/src/plugins/behaviors/PostProcessor.ts +0 -6
- package/src/plugins/behaviors/Serializer.ts +0 -40
- package/src/plugins/behaviors/Transformer.ts +0 -32
- package/src/plugins/behaviors/extractors/Data.ts +0 -332
- package/src/plugins/behaviors/extractors/Extractors.ts +0 -73
- package/src/plugins/behaviors/extractors/index.ts +0 -2
- package/src/plugins/behaviors/index.ts +0 -9
- package/src/plugins/util/CallExpression.ts +0 -110
- package/src/plugins/util/CodeTransformation.ts +0 -731
- package/src/plugins/util/ObjectLiteral.ts +0 -37
- package/src/plugins/util/index.ts +0 -3
- package/src/util/Debug.ts +0 -24
- package/src/util/Directive.ts +0 -123
- package/src/util/RuntimeTableSchema.ts +0 -44
- package/src/util/Util.ts +0 -7
- package/src/util/XMLUploadParser.ts +0 -90
- /package/dist/util/{Scope.d.ts → is-sn-scope.d.ts} +0 -0
- /package/src/util/{Scope.ts → is-sn-scope.ts} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPropertyAssignment = getPropertyAssignment;
|
|
4
|
-
const sdk_project_1 = require("@servicenow/sdk-project");
|
|
5
|
-
/**
|
|
6
|
-
* Retrieves the property assignment with the specified name and subpath from the given node.
|
|
7
|
-
* @param node - The node to search for the property assignment.
|
|
8
|
-
* @param property - The name of the property assignment to retrieve.
|
|
9
|
-
* @param subPath - Optional subpath to navigate within the property assignment.
|
|
10
|
-
* @returns The property assignment node if found, otherwise undefined.
|
|
11
|
-
*/
|
|
12
|
-
function getPropertyAssignment(node, property, ...subPath) {
|
|
13
|
-
let current = node
|
|
14
|
-
?.asKind(sdk_project_1.ts.SyntaxKind.ObjectLiteralExpression)
|
|
15
|
-
// get the property assignment with the specified name
|
|
16
|
-
?.getProperty((p) => hasPropertyAssignment(p, property))
|
|
17
|
-
?.asKind(sdk_project_1.ts.SyntaxKind.PropertyAssignment);
|
|
18
|
-
for (const pathPart of subPath) {
|
|
19
|
-
current = current
|
|
20
|
-
?.getInitializerIfKind(sdk_project_1.ts.SyntaxKind.ObjectLiteralExpression)
|
|
21
|
-
// get the property assignment with the specified name
|
|
22
|
-
?.getProperty((p) => hasPropertyAssignment(p, pathPart))
|
|
23
|
-
?.asKind(sdk_project_1.ts.SyntaxKind.PropertyAssignment);
|
|
24
|
-
}
|
|
25
|
-
return current;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Checks if the given property assignment has the specified path.
|
|
29
|
-
* @param property - The property assignment to check.
|
|
30
|
-
* @param path - The path to compare against.
|
|
31
|
-
* @returns True if the property assignment has the specified path, otherwise false.
|
|
32
|
-
*/
|
|
33
|
-
function hasPropertyAssignment(property, path) {
|
|
34
|
-
const child = property?.getChildren().find((c) => sdk_project_1.ts.Node.isStringLiteral(c) || sdk_project_1.ts.Node.isIdentifier(c));
|
|
35
|
-
return child?.getSymbol()?.getEscapedName() === path;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=ObjectLiteral.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectLiteral.js","sourceRoot":"","sources":["../../../src/plugins/util/ObjectLiteral.ts"],"names":[],"mappings":";;AASA,sDAgBC;AAzBD,yDAA4C;AAE5C;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAyB,EAAE,QAAgB,EAAE,GAAG,OAAiB;IACnG,IAAI,OAAO,GAAG,IAAI;QACd,EAAE,MAAM,CAAC,gBAAE,CAAC,UAAU,CAAC,uBAAuB,CAAC;QAC/C,sDAAsD;QACtD,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QACxD,EAAE,MAAM,CAAC,gBAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAA;IAE9C,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;QAC7B,OAAO,GAAG,OAAO;YACb,EAAE,oBAAoB,CAAC,gBAAE,CAAC,UAAU,CAAC,uBAAuB,CAAC;YAC7D,sDAAsD;YACtD,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;YACxD,EAAE,MAAM,CAAC,gBAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,OAAO,CAAA;AAClB,CAAC;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,QAAiD,EAAE,IAAY;IAC1F,MAAM,KAAK,GAAG,QAAQ,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,gBAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;IACxG,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE,cAAc,EAAE,KAAK,IAAI,CAAA;AACxD,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./CallExpression"), exports);
|
|
18
|
-
__exportStar(require("./CodeTransformation"), exports);
|
|
19
|
-
__exportStar(require("./ObjectLiteral"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,uDAAoC;AACpC,kDAA+B"}
|
package/dist/util/Debug.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Document } from '../plugins/behaviors';
|
|
2
|
-
import { Logger } from '@servicenow/sdk-project';
|
|
3
|
-
export declare function inspect(val: unknown, depth?: number): string;
|
|
4
|
-
export declare function debugDocuments(documents: Document[], logger: Logger, message?: string): void;
|
package/dist/util/Debug.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inspect = inspect;
|
|
4
|
-
exports.debugDocuments = debugDocuments;
|
|
5
|
-
const util_1 = require("util");
|
|
6
|
-
function inspect(val, depth = 2) {
|
|
7
|
-
return (0, util_1.inspect)(val, {
|
|
8
|
-
colors: true,
|
|
9
|
-
compact: false,
|
|
10
|
-
depth,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
function debugDocuments(documents, logger, message = 'DOCUMENTS:') {
|
|
14
|
-
logger.debug(`${message} ${inspect(documents.map((d) => {
|
|
15
|
-
const { node, ...rest } = d;
|
|
16
|
-
node;
|
|
17
|
-
return rest;
|
|
18
|
-
}), 5)}`);
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=Debug.js.map
|
package/dist/util/Debug.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Debug.js","sourceRoot":"","sources":["../../src/util/Debug.ts"],"names":[],"mappings":";;AAIA,0BAMC;AAED,wCAWC;AAvBD,+BAA6C;AAI7C,SAAgB,OAAO,CAAC,GAAY,EAAE,KAAK,GAAG,CAAC;IAC3C,OAAO,IAAA,cAAW,EAAC,GAAG,EAAE;QACpB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,KAAK;QACd,KAAK;KACR,CAAC,CAAA;AACN,CAAC;AAED,SAAgB,cAAc,CAAC,SAAqB,EAAE,MAAc,EAAE,OAAO,GAAG,YAAY;IACxF,MAAM,CAAC,KAAK,CACR,GAAG,OAAO,IAAI,OAAO,CACjB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAChB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;QAC3B,IAAI,CAAA;QACJ,OAAO,IAAI,CAAA;IACf,CAAC,CAAC,EACF,CAAC,CACJ,EAAE,CACN,CAAA;AACL,CAAC"}
|
package/dist/util/Directive.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ts, Diagnostic } from '@servicenow/sdk-project';
|
|
2
|
-
import { Context } from '../plugins/Context';
|
|
3
|
-
import { FluentDiagnostic } from '../plugins';
|
|
4
|
-
declare enum FluentDirectiveType {
|
|
5
|
-
Ignore = "ignore"
|
|
6
|
-
}
|
|
7
|
-
export type FluentDirective = {
|
|
8
|
-
filePath: string;
|
|
9
|
-
start: number;
|
|
10
|
-
type: FluentDirectiveType;
|
|
11
|
-
};
|
|
12
|
-
export declare function syncDisabledForNode(node: ts.Node): boolean;
|
|
13
|
-
export declare function syncDisabledForFile(sourceFile: ts.SourceFile): boolean | undefined;
|
|
14
|
-
export declare function applyFluentDirectives(context: Context, diagnostics: Diagnostic[]): Diagnostic[];
|
|
15
|
-
export declare function getDirectiveDiagnostics(node: ts.Node): FluentDiagnostic[];
|
|
16
|
-
export {};
|
package/dist/util/Directive.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.syncDisabledForNode = syncDisabledForNode;
|
|
4
|
-
exports.syncDisabledForFile = syncDisabledForFile;
|
|
5
|
-
exports.applyFluentDirectives = applyFluentDirectives;
|
|
6
|
-
exports.getDirectiveDiagnostics = getDirectiveDiagnostics;
|
|
7
|
-
const sdk_project_1 = require("@servicenow/sdk-project");
|
|
8
|
-
const plugins_1 = require("../plugins");
|
|
9
|
-
const FluentDisableSyncDirective = '@fluent-disable-sync';
|
|
10
|
-
const FluentDisableSyncForFileDirective = '@fluent-disable-sync-for-file';
|
|
11
|
-
const fluentCommentDirectiveRegEx = /^\/\/\/?\s*@fluent-ignore\b/;
|
|
12
|
-
var FluentDirectiveType;
|
|
13
|
-
(function (FluentDirectiveType) {
|
|
14
|
-
FluentDirectiveType["Ignore"] = "ignore";
|
|
15
|
-
})(FluentDirectiveType || (FluentDirectiveType = {}));
|
|
16
|
-
function getDirectiveFromCommentText(text) {
|
|
17
|
-
const directiveRegex = /^.*(\/{2,}|\/\*{1,})*\s*(@fluent-[-_a-zA-Z0-9]+).*$/m;
|
|
18
|
-
return text.match(directiveRegex)?.[2];
|
|
19
|
-
}
|
|
20
|
-
function getDirectivesFromAncestors(node) {
|
|
21
|
-
return [node].concat(node.getAncestors()).flatMap((ancestor) => ancestor
|
|
22
|
-
.getLeadingCommentRanges()
|
|
23
|
-
.map((comment) => getDirectiveFromCommentText(comment.getText()))
|
|
24
|
-
.filter((directive) => directive));
|
|
25
|
-
}
|
|
26
|
-
function isFluentDirective(text, kind) {
|
|
27
|
-
text = text.trim();
|
|
28
|
-
if (kind === sdk_project_1.tsc.SyntaxKind.SingleLineCommentTrivia) {
|
|
29
|
-
return fluentCommentDirectiveRegEx.test(text);
|
|
30
|
-
}
|
|
31
|
-
text = text.substring(2, text.length - 2).trim();
|
|
32
|
-
return /^@fluent-ignore\b/.test(text);
|
|
33
|
-
}
|
|
34
|
-
function parseFluentDirectives(filePath, context) {
|
|
35
|
-
const fluentDirectives = [];
|
|
36
|
-
const visitedRange = new Set();
|
|
37
|
-
const sourceFile = context.compiler.getSourceFile(filePath);
|
|
38
|
-
if (sourceFile) {
|
|
39
|
-
const sourceCode = sourceFile.getFullText();
|
|
40
|
-
context.compiler.visitNodeTree(sourceFile, (node) => {
|
|
41
|
-
;
|
|
42
|
-
[
|
|
43
|
-
...(sdk_project_1.tsc.getLeadingCommentRanges(sourceCode, node.getFullStart()) ?? []),
|
|
44
|
-
...(sdk_project_1.tsc.getTrailingCommentRanges(sourceCode, node.getFullStart()) ?? []),
|
|
45
|
-
].forEach((range) => {
|
|
46
|
-
if (!visitedRange.has(range.pos) &&
|
|
47
|
-
isFluentDirective(sourceCode.substring(range.pos, range.end), range.kind)) {
|
|
48
|
-
fluentDirectives.push({
|
|
49
|
-
filePath,
|
|
50
|
-
start: range.pos,
|
|
51
|
-
type: FluentDirectiveType.Ignore,
|
|
52
|
-
});
|
|
53
|
-
visitedRange.add(range.pos);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return fluentDirectives;
|
|
59
|
-
}
|
|
60
|
-
function syncDisabledForNode(node) {
|
|
61
|
-
return getDirectivesFromAncestors(node).some((directive) => directive === FluentDisableSyncDirective);
|
|
62
|
-
}
|
|
63
|
-
function syncDisabledForFile(sourceFile) {
|
|
64
|
-
return sourceFile
|
|
65
|
-
.getStatements()?.[0]
|
|
66
|
-
?.getLeadingCommentRanges()
|
|
67
|
-
.map((comment) => getDirectiveFromCommentText(comment.getText()))
|
|
68
|
-
.some((directive) => directive === FluentDisableSyncForFileDirective);
|
|
69
|
-
}
|
|
70
|
-
function applyFluentDirectives(context, diagnostics) {
|
|
71
|
-
const directiveCache = new Map();
|
|
72
|
-
const filteredDiagnostics = diagnostics.filter((diagnostic) => {
|
|
73
|
-
const filePath = diagnostic.file.getFilePath();
|
|
74
|
-
let fluentDirectives = directiveCache.get(filePath);
|
|
75
|
-
if (!fluentDirectives) {
|
|
76
|
-
fluentDirectives = parseFluentDirectives(filePath, context);
|
|
77
|
-
directiveCache.set(filePath, fluentDirectives);
|
|
78
|
-
}
|
|
79
|
-
let allowDiagnostic = true;
|
|
80
|
-
for (const directive of fluentDirectives) {
|
|
81
|
-
const { line: direcLine } = diagnostic.file.getLineAndColumnAtPos(directive.start);
|
|
82
|
-
const { line: diagLine } = diagnostic.file.getLineAndColumnAtPos(diagnostic.position.start);
|
|
83
|
-
if (direcLine + 1 === diagLine) {
|
|
84
|
-
allowDiagnostic = false;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return allowDiagnostic;
|
|
89
|
-
});
|
|
90
|
-
return filteredDiagnostics;
|
|
91
|
-
}
|
|
92
|
-
function getDirectiveDiagnostics(node) {
|
|
93
|
-
// Currently, the @fluent-disable-sync directive is only allowed before a CallExpression
|
|
94
|
-
// If we see it, within one (say, in a PropertyAssignment), we should flag it
|
|
95
|
-
if (node.isKind(sdk_project_1.ts.SyntaxKind.CallExpression)) {
|
|
96
|
-
return node
|
|
97
|
-
.getDescendantsOfKind(sdk_project_1.ts.SyntaxKind.SingleLineCommentTrivia)
|
|
98
|
-
.filter((commentNode) => getDirectiveFromCommentText(commentNode.getText()) === FluentDisableSyncDirective)
|
|
99
|
-
.map((n) => {
|
|
100
|
-
return new plugins_1.FluentDiagnostic(n, `${FluentDisableSyncDirective} directive only allowed before a call expression`, { level: sdk_project_1.Diagnostic.Level.Warn });
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
return [];
|
|
105
|
-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EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;YAClF,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YAC3F,IAAI,SAAS,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;gBAC7B,eAAe,GAAG,KAAK,CAAA;gBACvB,MAAK;YACT,CAAC;QACL,CAAC;QACD,OAAO,eAAe,CAAA;IAC1B,CAAC,CAAC,CAAA;IAEF,OAAO,mBAAmB,CAAA;AAC9B,CAAC;AAED,SAAgB,uBAAuB,CAAC,IAAa;IACjD,wFAAwF;IACxF,6EAA6E;IAC7E,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QAC5C,OAAO,IAAI;aACN,oBAAoB,CAAC,gBAAE,CAAC,UAAU,CAAC,uBAAuB,CAAC;aAC3D,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,2BAA2B,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK,0BAA0B,CAAC;aAC1G,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACP,OAAO,IAAI,0BAAgB,CACvB,CAAC,EACD,GAAG,0BAA0B,kDAAkD,EAC/E,EAAE,KAAK,EAAE,wBAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CACnC,CAAA;QACL,CAAC,CAAC,CAAA;IACV,CAAC;SAAM,CAAC;QACJ,OAAO,EAAE,CAAA;IACb,CAAC;AACL,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.maybeGetFieldToTagMap = maybeGetFieldToTagMap;
|
|
27
|
-
const tables = __importStar(require("@servicenow/sdk-core/runtime/fluent"));
|
|
28
|
-
const internalTypeToScriptTag = {
|
|
29
|
-
html: 'html',
|
|
30
|
-
translated_html: 'html',
|
|
31
|
-
html_template: 'html',
|
|
32
|
-
message_html: 'html',
|
|
33
|
-
html_script: 'html',
|
|
34
|
-
script: 'script',
|
|
35
|
-
script_plain: 'script',
|
|
36
|
-
xml: 'xml',
|
|
37
|
-
};
|
|
38
|
-
function maybeGetFieldToTagMap(table, documents) {
|
|
39
|
-
return getTagsForColumnsFromSystemTables(table) || getTagsForColumnsFromBootstrapDocs(table, documents) || {};
|
|
40
|
-
}
|
|
41
|
-
function getTagsForColumnsFromSystemTables(table) {
|
|
42
|
-
const schema = tables[table]?.schema;
|
|
43
|
-
return (schema &&
|
|
44
|
-
Object.entries(schema)
|
|
45
|
-
.filter(([_, schema]) => internalTypeToScriptTag[schema.column_type])
|
|
46
|
-
.map(([field, schema]) => ({ [field]: internalTypeToScriptTag[schema.column_type] }))
|
|
47
|
-
.reduce((acc, val) => ({ ...acc, ...val }), {}));
|
|
48
|
-
}
|
|
49
|
-
function getTagsForColumnsFromBootstrapDocs(table, documents) {
|
|
50
|
-
const bootstrapDoc = documents.find((doc) => doc.kind === 'bootstrap' && doc.guid === table);
|
|
51
|
-
const columns = bootstrapDoc?.data?.['data']?.bootstrapData.columns;
|
|
52
|
-
return (columns &&
|
|
53
|
-
Object.entries(columns)
|
|
54
|
-
.filter(([, column]) => internalTypeToScriptTag[column.type])
|
|
55
|
-
.map(([field, column]) => ({ [field]: internalTypeToScriptTag[column.type] }))
|
|
56
|
-
.reduce((acc, val) => ({ ...acc, ...val }), {}));
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=RuntimeTableSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeTableSchema.js","sourceRoot":"","sources":["../../src/util/RuntimeTableSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,sDAEC;AApBD,4EAA6D;AAO7D,MAAM,uBAAuB,GAAkB;IAC3C,IAAI,EAAE,MAAM;IACZ,eAAe,EAAE,MAAM;IACvB,aAAa,EAAE,MAAM;IACrB,YAAY,EAAE,MAAM;IACpB,WAAW,EAAE,MAAM;IACnB,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,QAAQ;IACtB,GAAG,EAAE,KAAK;CACb,CAAA;AAED,SAAgB,qBAAqB,CAAC,KAAa,EAAE,SAAqB;IACtE,OAAO,iCAAiC,CAAC,KAAK,CAAC,IAAI,kCAAkC,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,CAAA;AACjH,CAAC;AAED,SAAS,iCAAiC,CAAC,KAAa;IACpD,MAAM,MAAM,GA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AAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CACtD,CAAA;AACL,CAAC"}
|
package/dist/util/Scope.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Scope.js","sourceRoot":"","sources":["../../src/util/Scope.ts"],"names":[],"mappings":";;AAAA,8BAEC;AAFD,SAAgB,SAAS,CAAC,SAAiB;IACvC,OAAO,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AACpE,CAAC"}
|
package/dist/util/Util.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function noThrow<T>(action: () => T): Error | T;
|
package/dist/util/Util.js
DELETED
package/dist/util/Util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Util.js","sourceRoot":"","sources":["../../src/util/Util.ts"],"names":[],"mappings":";;AAAA,0BAMC;AAND,SAAgB,OAAO,CAAI,MAAe;IACtC,IAAI,CAAC;QACD,OAAO,MAAM,EAAE,CAAA;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,KAAc,CAAA;IACzB,CAAC;AACL,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
declare enum Action {
|
|
2
|
-
INSERT_OR_UPDATE = "INSERT_OR_UPDATE",
|
|
3
|
-
DELETE = "DELETE",
|
|
4
|
-
DELETE_MULTIPLE = "delete_multiple"
|
|
5
|
-
}
|
|
6
|
-
export type Record = {
|
|
7
|
-
table: string;
|
|
8
|
-
action: Action;
|
|
9
|
-
id: string;
|
|
10
|
-
data: {
|
|
11
|
-
[element: string]: string | undefined | boolean | number;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export declare class XMLUnloadParser {
|
|
15
|
-
readonly records: Record[];
|
|
16
|
-
static parse: (xml: string) => XMLUnloadParser;
|
|
17
|
-
private parse;
|
|
18
|
-
private processResult;
|
|
19
|
-
private parseRecord;
|
|
20
|
-
private parseAction;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XMLUnloadParser = void 0;
|
|
4
|
-
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
5
|
-
var Action;
|
|
6
|
-
(function (Action) {
|
|
7
|
-
Action["INSERT_OR_UPDATE"] = "INSERT_OR_UPDATE";
|
|
8
|
-
Action["DELETE"] = "DELETE";
|
|
9
|
-
Action["DELETE_MULTIPLE"] = "delete_multiple";
|
|
10
|
-
})(Action || (Action = {}));
|
|
11
|
-
class XMLUnloadParser {
|
|
12
|
-
records = [];
|
|
13
|
-
static parse = (xml) => {
|
|
14
|
-
const parser = new XMLUnloadParser();
|
|
15
|
-
parser.parse(xml);
|
|
16
|
-
return parser;
|
|
17
|
-
};
|
|
18
|
-
parse = (xml) => {
|
|
19
|
-
const parsed = new fast_xml_parser_1.XMLParser({
|
|
20
|
-
ignoreAttributes: false,
|
|
21
|
-
alwaysCreateTextNode: false,
|
|
22
|
-
ignoreDeclaration: true,
|
|
23
|
-
}).parse(xml, true);
|
|
24
|
-
this.processResult(parsed);
|
|
25
|
-
};
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
processResult(result) {
|
|
28
|
-
const recordUpdate = result['record_update'];
|
|
29
|
-
for (const tag in recordUpdate) {
|
|
30
|
-
if (!tag.startsWith('@') && typeof recordUpdate[tag] === 'object') {
|
|
31
|
-
const records = recordUpdate[tag];
|
|
32
|
-
if (Array.isArray(records)) {
|
|
33
|
-
for (const record of records) {
|
|
34
|
-
this.parseRecord(tag, record);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.parseRecord(tag, recordUpdate[tag]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
parseRecord(table, record) {
|
|
44
|
-
const { '@_action': action, sys_id, ...data } = record;
|
|
45
|
-
const parsedAction = this.parseAction(action);
|
|
46
|
-
this.records.push({
|
|
47
|
-
table,
|
|
48
|
-
action: parsedAction,
|
|
49
|
-
id: sys_id || 'unknown',
|
|
50
|
-
data,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
parseAction(actionStr) {
|
|
54
|
-
switch (actionStr) {
|
|
55
|
-
case 'INSERT_OR_UPDATE':
|
|
56
|
-
return Action.INSERT_OR_UPDATE;
|
|
57
|
-
case 'DELETE':
|
|
58
|
-
return Action.DELETE;
|
|
59
|
-
case 'delete_multiple':
|
|
60
|
-
return Action.DELETE_MULTIPLE;
|
|
61
|
-
default:
|
|
62
|
-
throw new Error(`Invalid action string: ${actionStr}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.XMLUnloadParser = XMLUnloadParser;
|
|
67
|
-
//# sourceMappingURL=XMLUploadParser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"XMLUploadParser.js","sourceRoot":"","sources":["../../src/util/XMLUploadParser.ts"],"names":[],"mappings":";;;AAAA,qDAA2C;AAE3C,IAAK,MAIJ;AAJD,WAAK,MAAM;IACP,+CAAqC,CAAA;IACrC,2BAAiB,CAAA;IACjB,6CAAmC,CAAA;AACvC,CAAC,EAJI,MAAM,KAAN,MAAM,QAIV;AASD,MAAa,eAAe;IACf,OAAO,GAAa,EAAE,CAAA;IAE/B,MAAM,CAAC,KAAK,GAAG,CAAC,GAAW,EAAE,EAAE;QAC3B,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAA;QACpC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAEjB,OAAO,MAAM,CAAA;IACjB,CAAC,CAAA;IAEO,KAAK,GAAG,CAAC,GAAW,EAAE,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AI;SACP,CAAC,CAAA;IACN,CAAC;IAEO,WAAW,CAAC,SAAiB;QACjC,QAAQ,SAAS,EAAE,CAAC;YAChB,KAAK,kBAAkB;gBACnB,OAAO,MAAM,CAAC,gBAAgB,CAAA;YAClC,KAAK,QAAQ;gBACT,OAAO,MAAM,CAAC,MAAM,CAAA;YACxB,KAAK,iBAAiB;gBAClB,OAAO,MAAM,CAAC,eAAe,CAAA;YACjC;gBACI,MAAM,IAAI,KAAK,CAAC,0BAA0B,SAAS,EAAE,CAAC,CAAA;QAC9D,CAAC;IACL,CAAC;;AA9DL,0CA+DC"}
|
package/src/IncludePaths.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { FileSystem, path } from '@servicenow/sdk-project'
|
|
2
|
-
import { Context } from './plugins'
|
|
3
|
-
|
|
4
|
-
export type IncludePaths = {
|
|
5
|
-
[table: string]: {
|
|
6
|
-
fields: { [field: string]: string }[]
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type CustomizedFieldPaths = {
|
|
11
|
-
field: string
|
|
12
|
-
path: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type CustomizedIncludePathForTable = {
|
|
16
|
-
table: string
|
|
17
|
-
guid: string
|
|
18
|
-
fields: CustomizedFieldPaths[]
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type CustomizedIncludePaths = {
|
|
22
|
-
[table: string]: CustomizedIncludePathForTable[]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const DefaultIncludePaths: IncludePaths = {
|
|
26
|
-
// Example of how to define include paths:
|
|
27
|
-
// sys_script_include: {
|
|
28
|
-
// fields: [{ script: '{{name}}.server.js' }],
|
|
29
|
-
// },
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const getIncludePaths = (context: Context) => {
|
|
33
|
-
const mappingFileName = path.join(context.app.rootDir, 'now.includes-mapping.json')
|
|
34
|
-
const compilerSourceFile = context.compiler.getSourceFile(mappingFileName)
|
|
35
|
-
let fileText = ''
|
|
36
|
-
if (compilerSourceFile) {
|
|
37
|
-
fileText = compilerSourceFile.getFullText()
|
|
38
|
-
} else {
|
|
39
|
-
// now-sdk fetch doesn't load the file into the compiler, so
|
|
40
|
-
// for now we'll just read the file from the filesystem
|
|
41
|
-
fileText = FileSystem.existsSync(context.fs, mappingFileName)
|
|
42
|
-
? context.fs.readFileSync(mappingFileName).toString()
|
|
43
|
-
: ''
|
|
44
|
-
}
|
|
45
|
-
return fileText ? (JSON.parse(fileText) as IncludePaths) : (DefaultIncludePaths as IncludePaths)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const calculateCustomPathsFromDocs = (context: Context): CustomizedIncludePaths => {
|
|
49
|
-
const includePaths = getIncludePaths(context)
|
|
50
|
-
const customizedIncludePaths = context
|
|
51
|
-
.getAllDocuments()
|
|
52
|
-
.filter((doc) => doc.kind === 'record')
|
|
53
|
-
.map((doc) => ({ table: doc.data?.['table'], guid: doc.guid, data: doc.data?.['data'] }))
|
|
54
|
-
.filter((record) => includePaths[record.table])
|
|
55
|
-
.map((record) => ({
|
|
56
|
-
table: record.table,
|
|
57
|
-
guid: record.guid,
|
|
58
|
-
fields:
|
|
59
|
-
(includePaths[record.table]?.fields || []).flatMap(Object.entries).map(([field, path]) => ({
|
|
60
|
-
field,
|
|
61
|
-
path: replaceTemplate(path, { sys_id: record.guid, ...record.data }),
|
|
62
|
-
})) || [],
|
|
63
|
-
}))
|
|
64
|
-
.reduce((acc, record) => {
|
|
65
|
-
acc[record.table] = acc[record.table] || []
|
|
66
|
-
acc[record.table].push(record)
|
|
67
|
-
return acc
|
|
68
|
-
}, {})
|
|
69
|
-
|
|
70
|
-
return dedupeFilenames(customizedIncludePaths)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function replaceTemplate(template: string, properties: Record<string, any>) {
|
|
74
|
-
let replacedString = template
|
|
75
|
-
const matches = template.matchAll(/{{([a-z_]+)}}/g)
|
|
76
|
-
for (const m of matches) {
|
|
77
|
-
const [, field] = m
|
|
78
|
-
if (field) {
|
|
79
|
-
const sanitizedValue = sanitizeForFilesystem(properties[field])
|
|
80
|
-
replacedString = replacedString.replaceAll(`{{${field}}}`, sanitizedValue)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return replacedString
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const IllegalCharacters = /[/<>?\\:|*"]/g
|
|
87
|
-
const Reserved = /^\.+$/
|
|
88
|
-
const WindowsTrailing = /[. ]+$/
|
|
89
|
-
|
|
90
|
-
function sanitizeForFilesystem(filename: string) {
|
|
91
|
-
return filename.replace(IllegalCharacters, '_').replace(Reserved, '').replace(WindowsTrailing, '')
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function dedupeFilename(filePath: string, fixedCount: { [path: string]: number }) {
|
|
95
|
-
const parsedPath = path.parse(filePath)
|
|
96
|
-
fixedCount[filePath] = (fixedCount[filePath] || 0) + 1
|
|
97
|
-
const pathParts = parsedPath.base.split('.')
|
|
98
|
-
pathParts[0] = `${pathParts[0]}-${fixedCount[filePath]}`
|
|
99
|
-
return path.join(parsedPath.dir, pathParts.join('.'))
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function dedupeFilenames(customizedFieldPaths: CustomizedIncludePaths) {
|
|
103
|
-
const pathCount = {}
|
|
104
|
-
for (const table in customizedFieldPaths) {
|
|
105
|
-
const paths = customizedFieldPaths[table]!.flatMap((record) => record.fields.map((f) => f.path))
|
|
106
|
-
paths.forEach((p) => (pathCount[p] = (pathCount[p] || 0) + 1))
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const fixedCount = {}
|
|
110
|
-
for (const table in customizedFieldPaths) {
|
|
111
|
-
const pathForTable = customizedFieldPaths[table] || []
|
|
112
|
-
for (const includePathForTable of pathForTable) {
|
|
113
|
-
for (let i = 0; i < includePathForTable.fields.length; i++) {
|
|
114
|
-
const p = includePathForTable.fields[i]?.path
|
|
115
|
-
if (p && pathCount[p] > 1) {
|
|
116
|
-
includePathForTable.fields[i]!.path = dedupeFilename(p, fixedCount)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return customizedFieldPaths
|
|
122
|
-
}
|