@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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare class SuccessEntry<T = unknown> {
|
|
2
|
+
private readonly value;
|
|
3
|
+
constructor(value: T);
|
|
4
|
+
unwrap(): T;
|
|
5
|
+
isError(): this is ErrorEntry;
|
|
6
|
+
}
|
|
7
|
+
declare class ErrorEntry {
|
|
8
|
+
private readonly error;
|
|
9
|
+
constructor(error: unknown);
|
|
10
|
+
unwrap(): unknown;
|
|
11
|
+
isError(): this is ErrorEntry;
|
|
12
|
+
}
|
|
13
|
+
export declare class Cache<K extends object, V> {
|
|
14
|
+
private cache;
|
|
15
|
+
get(key: K): SuccessEntry<V> | ErrorEntry | undefined;
|
|
16
|
+
put<const T extends V>(key: K, value: T): T;
|
|
17
|
+
error<const T>(key: K, error: T): T;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cache = void 0;
|
|
4
|
+
class SuccessEntry {
|
|
5
|
+
value;
|
|
6
|
+
constructor(value) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
}
|
|
9
|
+
unwrap() {
|
|
10
|
+
return this.value;
|
|
11
|
+
}
|
|
12
|
+
isError() {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class ErrorEntry {
|
|
17
|
+
error;
|
|
18
|
+
constructor(error) {
|
|
19
|
+
this.error = error;
|
|
20
|
+
}
|
|
21
|
+
unwrap() {
|
|
22
|
+
return this.error;
|
|
23
|
+
}
|
|
24
|
+
isError() {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
class Cache {
|
|
29
|
+
cache = new WeakMap();
|
|
30
|
+
get(key) {
|
|
31
|
+
return this.cache.get(key);
|
|
32
|
+
}
|
|
33
|
+
put(key, value) {
|
|
34
|
+
this.cache.set(key, new SuccessEntry(value));
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
error(key, error) {
|
|
38
|
+
this.cache.set(key, new ErrorEntry(error));
|
|
39
|
+
return error;
|
|
40
|
+
}
|
|
41
|
+
clear() {
|
|
42
|
+
this.cache = new WeakMap();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.Cache = Cache;
|
|
46
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/plugins/cache.ts"],"names":[],"mappings":";;;AAAA,MAAM,YAAY;IACe;IAA7B,YAA6B,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAG,CAAC;IAEzC,MAAM;QACF,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,CAAC;IAED,OAAO;QACH,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AAED,MAAM,UAAU;IACiB;IAA7B,YAA6B,KAAc;QAAd,UAAK,GAAL,KAAK,CAAS;IAAG,CAAC;IAE/C,MAAM;QACF,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAED,MAAa,KAAK;IACN,KAAK,GAAG,IAAI,OAAO,EAAE,CAAA;IAE7B,GAAG,CAAC,GAAM;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IAED,GAAG,CAAoB,GAAM,EAAE,KAAQ;QACnC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;QAC5C,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,KAAK,CAAU,GAAM,EAAE,KAAQ;QAC3B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;QAC1C,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,KAAK;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,EAAE,CAAA;IAC9B,CAAC;CACJ;AApBD,sBAoBC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Compiler } from '../compiler';
|
|
2
|
+
import type { Diagnostic } from '../diagnostic';
|
|
3
|
+
import type { FileSystem } from '../fs';
|
|
4
|
+
import type { Logger } from '../logger';
|
|
5
|
+
import type { Package } from '../app';
|
|
6
|
+
import type { ts } from '../typescript';
|
|
7
|
+
import type { Plugin, Plugins, Result } from './plugin';
|
|
8
|
+
import type { Product, Source } from './product';
|
|
9
|
+
import type { Project } from './project';
|
|
10
|
+
import type { Action, CoalesceKeys, ObjectShape, Record, RecordId, Shape, StringShape } from './shape';
|
|
11
|
+
import type { File, InstallCategory } from './file';
|
|
12
|
+
import type { Formatter } from '../formatter';
|
|
13
|
+
import type { NowConfig } from '../now-config';
|
|
14
|
+
import type { Database } from './database';
|
|
15
|
+
export interface Keys {
|
|
16
|
+
queryExplicitId(table: string, key: string | number | Shape): string | undefined;
|
|
17
|
+
registerExplicitId(table: string, key: string | number | Shape, guidOverride?: string): string;
|
|
18
|
+
deleteExplicitId(table: string, key: string | number, guidOverride?: string): string;
|
|
19
|
+
queryCoalesceId(table: string, key: CoalesceKeys): string | undefined;
|
|
20
|
+
registerCoalesceId(table: string, key: CoalesceKeys, guidOverride?: string): string;
|
|
21
|
+
deleteCoalesceId(table: string, key: CoalesceKeys, guidOverride?: string): string;
|
|
22
|
+
getEffectiveDeletedKeys(): Now.Internal.AnyKey[];
|
|
23
|
+
getSourceFile(): ts.SourceFile;
|
|
24
|
+
getFilePath(): string;
|
|
25
|
+
getValue(): Now.Internal.KeysRegistry;
|
|
26
|
+
commit(formatter?: Formatter): Promise<void>;
|
|
27
|
+
reload(): void;
|
|
28
|
+
}
|
|
29
|
+
export interface Diagnostics {
|
|
30
|
+
error(source: Product | ts.Node, message: string): void;
|
|
31
|
+
warn(source: Product | ts.Node, message: string): void;
|
|
32
|
+
info(source: Product | ts.Node, message: string): void;
|
|
33
|
+
hint(source: Product | ts.Node, message: string): void;
|
|
34
|
+
add(diagnostic: Diagnostic): void;
|
|
35
|
+
getAll(file?: string): Diagnostic[];
|
|
36
|
+
clear(file?: string): void;
|
|
37
|
+
getWarnings(file?: string): Diagnostic[];
|
|
38
|
+
hasErrors(file?: string): boolean;
|
|
39
|
+
getErrors(file?: string): Diagnostic[];
|
|
40
|
+
}
|
|
41
|
+
export interface Transform {
|
|
42
|
+
toShape(node: ts.Node, ...plugins: Plugin[]): Promise<Result<Shape>>;
|
|
43
|
+
recordToShape(record: Record, database: Database, ...plugins: Plugin[]): Promise<Result<Shape>>;
|
|
44
|
+
toSubclass<const S extends Shape>(shape: S, ...plugins: Plugin[]): Result<S>;
|
|
45
|
+
toRecord(node: ts.Node, ...plugins: Plugin[]): Promise<Result<Record>>;
|
|
46
|
+
toRecord(shape: Shape, ...plugins: Plugin[]): Promise<Result<Record>>;
|
|
47
|
+
toRecord(file: File, ...plugins: Plugin[]): Promise<Result<Record>>;
|
|
48
|
+
toRecord(source: ts.Node | Shape | File, ...plugins: Plugin[]): Promise<Result<Record>>;
|
|
49
|
+
}
|
|
50
|
+
export interface Factory {
|
|
51
|
+
createShape<const S extends Shape>(shape: S): S;
|
|
52
|
+
createRecord(args: {
|
|
53
|
+
source: Source;
|
|
54
|
+
table: string;
|
|
55
|
+
explicitId?: string | Shape;
|
|
56
|
+
guidOverride?: string;
|
|
57
|
+
properties: NonNullable<object>;
|
|
58
|
+
action?: Action;
|
|
59
|
+
installCategory?: InstallCategory;
|
|
60
|
+
}): Record;
|
|
61
|
+
createReference(args: {
|
|
62
|
+
source: Source;
|
|
63
|
+
table: string | StringShape;
|
|
64
|
+
guid?: string | StringShape | undefined;
|
|
65
|
+
keys?: globalThis.Record<string, string | Shape> | ObjectShape | undefined;
|
|
66
|
+
}): RecordId;
|
|
67
|
+
}
|
|
68
|
+
export interface Parser {
|
|
69
|
+
parsePayload(file: File): Record[];
|
|
70
|
+
}
|
|
71
|
+
export type Context = {
|
|
72
|
+
readonly self: Plugin;
|
|
73
|
+
readonly fs: FileSystem;
|
|
74
|
+
readonly logger: Logger;
|
|
75
|
+
readonly packageJson: Package;
|
|
76
|
+
readonly config: NowConfig;
|
|
77
|
+
readonly project: Project;
|
|
78
|
+
readonly compiler: Compiler;
|
|
79
|
+
readonly plugins: Plugins;
|
|
80
|
+
readonly keys: Keys;
|
|
81
|
+
readonly diagnostics: Diagnostics;
|
|
82
|
+
readonly transform: Transform;
|
|
83
|
+
readonly factory: Factory;
|
|
84
|
+
readonly parser: Parser;
|
|
85
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/plugins/context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Record, RecordId } from './shape';
|
|
2
|
+
type Query = {
|
|
3
|
+
[column: string]: unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare class Database implements Iterable<Record> {
|
|
6
|
+
private readonly database;
|
|
7
|
+
constructor(records?: Record[]);
|
|
8
|
+
insert(...records: Record[]): void;
|
|
9
|
+
resolve(id: RecordId): Record | undefined;
|
|
10
|
+
get(table: string, guid: string): Record | undefined;
|
|
11
|
+
get(table: string, query: Query): Record | undefined;
|
|
12
|
+
query(table?: string, query?: Query): Record[];
|
|
13
|
+
compare(other: Database | Record[]): DiffDatabase;
|
|
14
|
+
[Symbol.iterator](): IterableIterator<Record>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The initial set of records passed into the constructor is treated as the baseline. Any record
|
|
18
|
+
* inserted after that will be tracked as "changed" unless it is equal to its baseline counterpart.
|
|
19
|
+
* Useful for getting a diff/delta between two databases.
|
|
20
|
+
*/
|
|
21
|
+
export declare class DiffDatabase extends Database {
|
|
22
|
+
private readonly changedGuids;
|
|
23
|
+
constructor(records?: Record[]);
|
|
24
|
+
insert(...records: Record[]): void;
|
|
25
|
+
isChanged(record: Record): boolean;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiffDatabase = exports.Database = void 0;
|
|
4
|
+
class Database {
|
|
5
|
+
database = {};
|
|
6
|
+
constructor(records = []) {
|
|
7
|
+
this.insert(...records);
|
|
8
|
+
}
|
|
9
|
+
insert(...records) {
|
|
10
|
+
for (const record of records) {
|
|
11
|
+
const table = (this.database[record.getTable()] ??= {});
|
|
12
|
+
const guid = record.getId().getValue();
|
|
13
|
+
table[guid] = record;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
resolve(id) {
|
|
17
|
+
const table = id.getTable();
|
|
18
|
+
const guid = id.getValue();
|
|
19
|
+
const record = this.database[table]?.[guid];
|
|
20
|
+
if (record) {
|
|
21
|
+
return record;
|
|
22
|
+
}
|
|
23
|
+
const keys = id.getKeys();
|
|
24
|
+
if (!keys) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const matches = this.query(table, keys);
|
|
28
|
+
if (matches.length > 1) {
|
|
29
|
+
throw new Error(`Multiple records found for table "${table}" with coalesce keys: ${JSON.stringify(keys)}`);
|
|
30
|
+
}
|
|
31
|
+
return matches[0];
|
|
32
|
+
}
|
|
33
|
+
get(table, guidOrQuery) {
|
|
34
|
+
if (typeof guidOrQuery === 'string') {
|
|
35
|
+
return this.database[table]?.[guidOrQuery];
|
|
36
|
+
}
|
|
37
|
+
const [record, ...rest] = this.query(table, guidOrQuery);
|
|
38
|
+
if (rest.length > 0) {
|
|
39
|
+
throw new Error(`Expected get() to return no more than 1 match, but ${rest.length + 1} matches were found.`);
|
|
40
|
+
}
|
|
41
|
+
return record;
|
|
42
|
+
}
|
|
43
|
+
query(table, query = {}) {
|
|
44
|
+
if (!table) {
|
|
45
|
+
return Object.values(this.database).flatMap((table) => Object.values(table));
|
|
46
|
+
}
|
|
47
|
+
const records = [];
|
|
48
|
+
outer: for (const record of Object.values(this.database[table] ?? {})) {
|
|
49
|
+
for (const [column, value] of Object.entries(query)) {
|
|
50
|
+
if (!record.get(column).equals(value)) {
|
|
51
|
+
continue outer;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
records.push(record);
|
|
55
|
+
}
|
|
56
|
+
return records;
|
|
57
|
+
}
|
|
58
|
+
compare(other) {
|
|
59
|
+
const diff = new DiffDatabase(this.query());
|
|
60
|
+
diff.insert(...(other instanceof Database ? other.query() : other));
|
|
61
|
+
return diff;
|
|
62
|
+
}
|
|
63
|
+
[Symbol.iterator]() {
|
|
64
|
+
return this.query()[Symbol.iterator]();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Database = Database;
|
|
68
|
+
/**
|
|
69
|
+
* The initial set of records passed into the constructor is treated as the baseline. Any record
|
|
70
|
+
* inserted after that will be tracked as "changed" unless it is equal to its baseline counterpart.
|
|
71
|
+
* Useful for getting a diff/delta between two databases.
|
|
72
|
+
*/
|
|
73
|
+
class DiffDatabase extends Database {
|
|
74
|
+
changedGuids = [];
|
|
75
|
+
constructor(records = []) {
|
|
76
|
+
super(records);
|
|
77
|
+
}
|
|
78
|
+
insert(...records) {
|
|
79
|
+
if (!this.changedGuids) {
|
|
80
|
+
// This will happen when called from the super constructor
|
|
81
|
+
super.insert(...records);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
for (const record of records) {
|
|
85
|
+
const id = record.getId();
|
|
86
|
+
const existing = this.resolve(id);
|
|
87
|
+
if (existing && !existing.strictEquals(record)) {
|
|
88
|
+
this.changedGuids.push(id.getValue());
|
|
89
|
+
super.insert(existing.merge(record));
|
|
90
|
+
}
|
|
91
|
+
else if (!existing) {
|
|
92
|
+
this.changedGuids.push(id.getValue());
|
|
93
|
+
super.insert(record);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
isChanged(record) {
|
|
98
|
+
return this.changedGuids.includes(record.getId().getValue());
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.DiffDatabase = DiffDatabase;
|
|
102
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/plugins/database.ts"],"names":[],"mappings":";;;AAIA,MAAa,QAAQ;IACA,QAAQ,GAAoD,EAAE,CAAA;IAE/E,YAAY,UAAoB,EAAE;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM,CAAC,GAAG,OAAiB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YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;IAChE,CAAC;CACJ;AA9BD,oCA8BC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type File = {
|
|
2
|
+
path: string;
|
|
3
|
+
content: string;
|
|
4
|
+
};
|
|
5
|
+
export type InstallCategory = 'dictionary' | 'unload' | 'unload.demo' | 'update' | 'apply_once' | 'scope' | 'author_elective_update';
|
|
6
|
+
export type OutputFile = {
|
|
7
|
+
name: string;
|
|
8
|
+
category: InstallCategory;
|
|
9
|
+
content: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/plugins/file.ts"],"names":[],"mappings":""}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './shape';
|
|
2
|
+
export * from './file';
|
|
3
|
+
export * from './context';
|
|
4
|
+
export * from './plugin';
|
|
5
|
+
export * from './product';
|
|
6
|
+
export * from './project';
|
|
7
|
+
export * from './database';
|
|
8
|
+
export * from './time';
|
|
9
|
+
export * from './usage';
|
package/dist/plugins/index.js
CHANGED
|
@@ -14,10 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./shape"), exports);
|
|
18
|
+
__exportStar(require("./file"), exports);
|
|
19
|
+
__exportStar(require("./context"), exports);
|
|
20
|
+
__exportStar(require("./plugin"), exports);
|
|
21
|
+
__exportStar(require("./product"), exports);
|
|
22
|
+
__exportStar(require("./project"), exports);
|
|
23
|
+
__exportStar(require("./database"), exports);
|
|
24
|
+
__exportStar(require("./time"), exports);
|
|
25
|
+
__exportStar(require("./usage"), exports);
|
|
23
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,yCAAsB;AACtB,4CAAyB;AACzB,2CAAwB;AACxB,4CAAyB;AACzB,4CAAyB;AACzB,6CAA0B;AAC1B,yCAAsB;AACtB,0CAAuB"}
|