@skmtc/core 0.0.384 → 0.0.385
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/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.d.ts +2 -2
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +6 -13
- package/esm/context/RenderContext.d.ts +5 -4
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +4 -10
- package/esm/context/types.d.ts +0 -6
- package/esm/context/types.d.ts.map +1 -1
- package/esm/dsl/File.d.ts +12 -0
- package/esm/dsl/File.d.ts.map +1 -0
- package/esm/dsl/File.js +52 -0
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/GenerateContext.d.ts +2 -2
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +6 -13
- package/script/context/RenderContext.d.ts +5 -4
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +4 -10
- package/script/context/types.d.ts +0 -6
- package/script/context/types.d.ts.map +1 -1
- package/script/dsl/File.d.ts +12 -0
- package/script/dsl/File.d.ts.map +1 -0
- package/script/dsl/File.js +56 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreContext.d.ts","sourceRoot":"","sources":["../../src/context/CoreContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoreContext.d.ts","sourceRoot":"","sources":["../../src/context/CoreContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AACpG,OAAO,KA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AAE,SAAS,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAQnF"}
|
|
@@ -3,7 +3,6 @@ import { Definition } from '../dsl/Definition.js';
|
|
|
3
3
|
import type { OasDocument } from '../oas/document/Document.js';
|
|
4
4
|
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
5
5
|
import type { OasRef } from '../oas/ref/Ref.js';
|
|
6
|
-
import type { FileContents } from './types.js';
|
|
7
6
|
import type { ClientSettings } from '../types/Settings.js';
|
|
8
7
|
import type { Method } from '../types/Method.js';
|
|
9
8
|
import type { OperationInsertable, OperationGateway } from '../dsl/operation/OperationInsertable.js';
|
|
@@ -19,6 +18,7 @@ import type { StackTrail } from './StackTrail.js';
|
|
|
19
18
|
import type { Identifier } from '../dsl/Identifier.js';
|
|
20
19
|
import type { SchemaToValueFn, SchemaType, TypeSystemOutput } from '../types/TypeSystem.js';
|
|
21
20
|
import { Inserted } from '../dsl/Inserted.js';
|
|
21
|
+
import { File } from '../dsl/File.js';
|
|
22
22
|
type ConstructorArgs = {
|
|
23
23
|
oasDocument: OasDocument;
|
|
24
24
|
settings: ClientSettings | undefined;
|
|
@@ -93,7 +93,7 @@ export declare class GenerateContext {
|
|
|
93
93
|
/**
|
|
94
94
|
* @internal
|
|
95
95
|
*/
|
|
96
|
-
generate(generatorsMap: Record<string, OperationGateway | ModelGateway | OperationInsertable<GeneratedValue> | ModelInsertable<GeneratedValue>>): Map<string,
|
|
96
|
+
generate(generatorsMap: Record<string, OperationGateway | ModelGateway | OperationInsertable<GeneratedValue> | ModelInsertable<GeneratedValue>>): Map<string, File>;
|
|
97
97
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
98
98
|
/**
|
|
99
99
|
* Converts schema to value using `schemaToValueFn` and creates definition
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EA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6BrE;;;;;;;;;;;;;OAaG;IACH,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,cAAc,EAAE,EAClE,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,EAChB,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IAY7C;;;;;;;;;;;;;OAaG;IAEH,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,cAAc,EAAE,EAC9D,UAAU,EACV,OAAO,EACP,UAAU,EACV,eAAe,EAChB,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IAYzC;;;;;;;;;OASG;IACH,0BAA0B,CAAC,CAAC,EAAE,EAC5B,SAAS,EACT,UAAU,EACX,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,eAAe;IAiB/C;;;;;;;;OAQG;IACH,sBAAsB,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,eAAe;IAgB9F;;;;;;;OAOG;IACH,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,GAAG,YAAY,GAAG,eAAe;IAgFlF;;;;;OAKG;IACH,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;IAUpE;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAGvE"}
|
|
@@ -19,6 +19,7 @@ import { ContentSettings } from '../dsl/ContentSettings.js';
|
|
|
19
19
|
import * as Sentry from '@sentry/deno';
|
|
20
20
|
import { tracer } from '../helpers/tracer.js';
|
|
21
21
|
import { Inserted } from '../dsl/Inserted.js';
|
|
22
|
+
import { File } from '../dsl/File.js';
|
|
22
23
|
export class GenerateContext {
|
|
23
24
|
constructor({ oasDocument, settings, logger, callback, captureCurrentResult, stackTrail }) {
|
|
24
25
|
_GenerateContext_instances.add(this);
|
|
@@ -69,20 +70,16 @@ export class GenerateContext {
|
|
|
69
70
|
Sentry.startSpan({ name: 'Generate operations' }, () => Object.values(generatorsMap)
|
|
70
71
|
.filter(generator => generator.type === 'operation')
|
|
71
72
|
.forEach(generator => {
|
|
72
|
-
this.trace(generator.id, () =>
|
|
73
|
-
oasDocument: this.oasDocument,
|
|
74
|
-
|
|
75
|
-
}));
|
|
73
|
+
this.trace(generator.id, () => {
|
|
74
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOperationGenerator).call(this, { oasDocument: this.oasDocument, generator });
|
|
75
|
+
});
|
|
76
76
|
}));
|
|
77
77
|
Sentry.startSpan({ name: 'Generate models' }, () => {
|
|
78
78
|
Object.values(generatorsMap)
|
|
79
79
|
.filter(generator => generator.type === 'model')
|
|
80
80
|
.forEach(generator => {
|
|
81
81
|
this.trace(generator.id, () => {
|
|
82
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, {
|
|
83
|
-
oasDocument: this.oasDocument,
|
|
84
|
-
generator
|
|
85
|
-
});
|
|
82
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, { oasDocument: this.oasDocument, generator });
|
|
86
83
|
});
|
|
87
84
|
});
|
|
88
85
|
});
|
|
@@ -495,11 +492,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
|
|
|
495
492
|
if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalisedPath)) {
|
|
496
493
|
throw new Error(`File already exists: ${normalisedPath}`);
|
|
497
494
|
}
|
|
498
|
-
const newFile =
|
|
499
|
-
imports: new Map(),
|
|
500
|
-
definitions: new Map(),
|
|
501
|
-
generatorKeys: new Set()
|
|
502
|
-
};
|
|
495
|
+
const newFile = new File(normalisedPath);
|
|
503
496
|
__classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalisedPath, newFile);
|
|
504
497
|
return newFile;
|
|
505
498
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { PrettierConfigType } from '../types/prettierConfig.js';
|
|
2
|
-
import type { AddGeneratorKeyArgs,
|
|
2
|
+
import type { AddGeneratorKeyArgs, RenderResult } from './types.js';
|
|
3
3
|
import type { Definition } from '../dsl/Definition.js';
|
|
4
4
|
import type { PickArgs } from './GenerateContext.js';
|
|
5
5
|
import type { ResultType } from '../types/Results.js';
|
|
6
6
|
import type { StackTrail } from './StackTrail.js';
|
|
7
7
|
import type * as log from '../deps/jsr.io/@std/log/0.224.7/mod.js';
|
|
8
|
+
import type { File } from '../dsl/File.js';
|
|
8
9
|
type ConstructorArgs = {
|
|
9
|
-
files: Map<string,
|
|
10
|
+
files: Map<string, File>;
|
|
10
11
|
prettier?: PrettierConfigType;
|
|
11
12
|
basePath: string | undefined;
|
|
12
13
|
pinnableGenerators: string[];
|
|
@@ -16,7 +17,7 @@ type ConstructorArgs = {
|
|
|
16
17
|
};
|
|
17
18
|
export declare class RenderContext {
|
|
18
19
|
#private;
|
|
19
|
-
files: Map<string,
|
|
20
|
+
files: Map<string, File>;
|
|
20
21
|
private prettier?;
|
|
21
22
|
basePath: string | undefined;
|
|
22
23
|
currentDestinationPath: string | 'PRE_RENDER' | 'POST_RENDER';
|
|
@@ -27,7 +28,7 @@ export declare class RenderContext {
|
|
|
27
28
|
render(): Omit<RenderResult, 'results'>;
|
|
28
29
|
private collate;
|
|
29
30
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
30
|
-
getFile(filePath: string):
|
|
31
|
+
getFile(filePath: string): File;
|
|
31
32
|
addGeneratorKey({ generatorKey }: AddGeneratorKeyArgs): void;
|
|
32
33
|
pick({ name, exportPath }: PickArgs): Definition | undefined;
|
|
33
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAqB,YAAY,EAAE,MAAM,YAAY,CAAA;AAEtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAE1C,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACxB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,oBAAoB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;CACnD,CAAA;AAYD,qBAAa,aAAa;;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAoB;IACrC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,sBAAsB,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa,CAAA;IAC7D,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAElB,oBAAoB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;gBACtC,EACV,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,MAAM,EACN,UAAU,EACV,oBAAoB,EACrB,EAAE,eAAe;IAWlB,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC;IAuBvC,OAAO,CAAC,OAAO;IAoDf,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIlD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAU/B,eAAe,CAAC,EAAE,YAAY,EAAE,EAAE,mBAAmB;IAarD,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAG7D"}
|
|
@@ -11,7 +11,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _RenderContext_stackTrail;
|
|
13
13
|
import * as Sentry from '@sentry/deno';
|
|
14
|
-
import { Import } from '../dsl/Import.js';
|
|
15
14
|
import invariant from 'tiny-invariant';
|
|
16
15
|
import { normalize } from '../deps/jsr.io/@std/path/1.0.0/mod.js';
|
|
17
16
|
import { toResolvedArtifactPath } from '../helpers/toResolvedArtifactPath.js';
|
|
@@ -100,7 +99,8 @@ export class RenderContext {
|
|
|
100
99
|
// @TODO: Could this be combined with the tracer call above?
|
|
101
100
|
this.currentDestinationPath = destinationPath;
|
|
102
101
|
const renderedFile = renderFile({
|
|
103
|
-
file,
|
|
102
|
+
content: file.toString(),
|
|
103
|
+
generatorKeys: Array.from(file.generatorKeys).filter(Boolean),
|
|
104
104
|
destinationPath,
|
|
105
105
|
basePath: this.basePath,
|
|
106
106
|
prettier: this.prettier
|
|
@@ -149,20 +149,14 @@ export class RenderContext {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
_RenderContext_stackTrail = new WeakMap();
|
|
152
|
-
const renderFile = ({
|
|
153
|
-
const imports = Array.from(file.imports.entries()).map(([module, importItems]) => new Import({ module, importNames: Array.from(importItems) }));
|
|
154
|
-
const definitions = Array.from(file.definitions.values());
|
|
155
|
-
const content = [imports, definitions]
|
|
156
|
-
.filter(section => Boolean(section.length))
|
|
157
|
-
.map(section => section.join('\n'))
|
|
158
|
-
.join('\n\n');
|
|
152
|
+
const renderFile = ({ content, generatorKeys, destinationPath, basePath }) => {
|
|
159
153
|
return {
|
|
160
154
|
content,
|
|
161
155
|
path: toResolvedArtifactPath({ basePath, destinationPath }),
|
|
162
156
|
destinationPath,
|
|
163
157
|
numberOfLines: content.split('\n').length,
|
|
164
158
|
numberOfCharacters: content.length,
|
|
165
|
-
generatorKeys
|
|
159
|
+
generatorKeys,
|
|
166
160
|
hash: 'PLACEHOLDER'
|
|
167
161
|
};
|
|
168
162
|
};
|
package/esm/context/types.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import type { Definition } from '../dsl/Definition.js';
|
|
2
1
|
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
3
2
|
import type { ManifestEntry } from '../types/Manifest.js';
|
|
4
3
|
import type { ResultType } from '../types/Results.js';
|
|
5
4
|
export type PhaseType = 'parse' | 'generate' | 'render';
|
|
6
|
-
export type FileContents = {
|
|
7
|
-
imports: Map<string, Set<string>>;
|
|
8
|
-
definitions: Map<string, Definition>;
|
|
9
|
-
generatorKeys: Set<GeneratorKey>;
|
|
10
|
-
};
|
|
11
5
|
export type GetFileOptions = {
|
|
12
6
|
throwIfNotFound?: boolean;
|
|
13
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;CAChD,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CACpC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Definition } from './Definition.js';
|
|
2
|
+
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
3
|
+
export declare class File {
|
|
4
|
+
#private;
|
|
5
|
+
path: string;
|
|
6
|
+
imports: Map<string, Set<string>>;
|
|
7
|
+
definitions: Map<string, Definition>;
|
|
8
|
+
constructor(path: string);
|
|
9
|
+
get generatorKeys(): Set<GeneratorKey>;
|
|
10
|
+
toString(): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=File.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../src/dsl/File.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D,qBAAa,IAAI;;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;gBAGxB,IAAI,EAAE,MAAM;IAOxB,IAAI,aAAa,sBAEhB;IAED,QAAQ;CAYT"}
|
package/esm/dsl/File.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _File_generatorKeys;
|
|
13
|
+
import { Import } from './Import.js';
|
|
14
|
+
export class File {
|
|
15
|
+
constructor(path) {
|
|
16
|
+
Object.defineProperty(this, "path", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "imports", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "definitions", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: void 0
|
|
33
|
+
});
|
|
34
|
+
_File_generatorKeys.set(this, void 0);
|
|
35
|
+
this.path = path;
|
|
36
|
+
this.imports = new Map();
|
|
37
|
+
this.definitions = new Map();
|
|
38
|
+
__classPrivateFieldSet(this, _File_generatorKeys, new Set(), "f");
|
|
39
|
+
}
|
|
40
|
+
get generatorKeys() {
|
|
41
|
+
return __classPrivateFieldGet(this, _File_generatorKeys, "f");
|
|
42
|
+
}
|
|
43
|
+
toString() {
|
|
44
|
+
const imports = Array.from(this.imports.entries()).map(([module, importItems]) => new Import({ module, importNames: Array.from(importItems) }));
|
|
45
|
+
const definitions = Array.from(this.definitions.values());
|
|
46
|
+
return [imports, definitions]
|
|
47
|
+
.filter(section => Boolean(section.length))
|
|
48
|
+
.map(section => section.join('\n'))
|
|
49
|
+
.join('\n\n');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
_File_generatorKeys = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreContext.d.ts","sourceRoot":"","sources":["../../src/context/CoreContext.ts"],"names":[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AAa,EAAE,QAAQ,EAAE,EAAE,aAAa;;;;;;IAmEtE,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IA2BlD,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAiB/C;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,GAAG,CAAC,SAAS,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAQnF"}
|
|
@@ -3,7 +3,6 @@ import { Definition } from '../dsl/Definition.js';
|
|
|
3
3
|
import type { OasDocument } from '../oas/document/Document.js';
|
|
4
4
|
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
5
5
|
import type { OasRef } from '../oas/ref/Ref.js';
|
|
6
|
-
import type { FileContents } from './types.js';
|
|
7
6
|
import type { ClientSettings } from '../types/Settings.js';
|
|
8
7
|
import type { Method } from '../types/Method.js';
|
|
9
8
|
import type { OperationInsertable, OperationGateway } from '../dsl/operation/OperationInsertable.js';
|
|
@@ -19,6 +18,7 @@ import type { StackTrail } from './StackTrail.js';
|
|
|
19
18
|
import type { Identifier } from '../dsl/Identifier.js';
|
|
20
19
|
import type { SchemaToValueFn, SchemaType, TypeSystemOutput } from '../types/TypeSystem.js';
|
|
21
20
|
import { Inserted } from '../dsl/Inserted.js';
|
|
21
|
+
import { File } from '../dsl/File.js';
|
|
22
22
|
type ConstructorArgs = {
|
|
23
23
|
oasDocument: OasDocument;
|
|
24
24
|
settings: ClientSettings | undefined;
|
|
@@ -93,7 +93,7 @@ export declare class GenerateContext {
|
|
|
93
93
|
/**
|
|
94
94
|
* @internal
|
|
95
95
|
*/
|
|
96
|
-
generate(generatorsMap: Record<string, OperationGateway | ModelGateway | OperationInsertable<GeneratedValue> | ModelInsertable<GeneratedValue>>): Map<string,
|
|
96
|
+
generate(generatorsMap: Record<string, OperationGateway | ModelGateway | OperationInsertable<GeneratedValue> | ModelInsertable<GeneratedValue>>): Map<string, File>;
|
|
97
97
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
98
98
|
/**
|
|
99
99
|
* Converts schema to value using `schemaToValueFn` and creates definition
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,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,MAAM,CAAC,QAAQ,CAAC;IAUpE;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAGvE"}
|
|
@@ -45,6 +45,7 @@ const ContentSettings_js_1 = require("../dsl/ContentSettings.js");
|
|
|
45
45
|
const Sentry = __importStar(require("@sentry/deno"));
|
|
46
46
|
const tracer_js_1 = require("../helpers/tracer.js");
|
|
47
47
|
const Inserted_js_1 = require("../dsl/Inserted.js");
|
|
48
|
+
const File_js_1 = require("../dsl/File.js");
|
|
48
49
|
class GenerateContext {
|
|
49
50
|
constructor({ oasDocument, settings, logger, callback, captureCurrentResult, stackTrail }) {
|
|
50
51
|
_GenerateContext_instances.add(this);
|
|
@@ -95,20 +96,16 @@ class GenerateContext {
|
|
|
95
96
|
Sentry.startSpan({ name: 'Generate operations' }, () => Object.values(generatorsMap)
|
|
96
97
|
.filter(generator => generator.type === 'operation')
|
|
97
98
|
.forEach(generator => {
|
|
98
|
-
this.trace(generator.id, () =>
|
|
99
|
-
oasDocument: this.oasDocument,
|
|
100
|
-
|
|
101
|
-
}));
|
|
99
|
+
this.trace(generator.id, () => {
|
|
100
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOperationGenerator).call(this, { oasDocument: this.oasDocument, generator });
|
|
101
|
+
});
|
|
102
102
|
}));
|
|
103
103
|
Sentry.startSpan({ name: 'Generate models' }, () => {
|
|
104
104
|
Object.values(generatorsMap)
|
|
105
105
|
.filter(generator => generator.type === 'model')
|
|
106
106
|
.forEach(generator => {
|
|
107
107
|
this.trace(generator.id, () => {
|
|
108
|
-
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, {
|
|
109
|
-
oasDocument: this.oasDocument,
|
|
110
|
-
generator
|
|
111
|
-
});
|
|
108
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, { oasDocument: this.oasDocument, generator });
|
|
112
109
|
});
|
|
113
110
|
});
|
|
114
111
|
});
|
|
@@ -522,11 +519,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
|
|
|
522
519
|
if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalisedPath)) {
|
|
523
520
|
throw new Error(`File already exists: ${normalisedPath}`);
|
|
524
521
|
}
|
|
525
|
-
const newFile =
|
|
526
|
-
imports: new Map(),
|
|
527
|
-
definitions: new Map(),
|
|
528
|
-
generatorKeys: new Set()
|
|
529
|
-
};
|
|
522
|
+
const newFile = new File_js_1.File(normalisedPath);
|
|
530
523
|
__classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalisedPath, newFile);
|
|
531
524
|
return newFile;
|
|
532
525
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { PrettierConfigType } from '../types/prettierConfig.js';
|
|
2
|
-
import type { AddGeneratorKeyArgs,
|
|
2
|
+
import type { AddGeneratorKeyArgs, RenderResult } from './types.js';
|
|
3
3
|
import type { Definition } from '../dsl/Definition.js';
|
|
4
4
|
import type { PickArgs } from './GenerateContext.js';
|
|
5
5
|
import type { ResultType } from '../types/Results.js';
|
|
6
6
|
import type { StackTrail } from './StackTrail.js';
|
|
7
7
|
import type * as log from '../deps/jsr.io/@std/log/0.224.7/mod.js';
|
|
8
|
+
import type { File } from '../dsl/File.js';
|
|
8
9
|
type ConstructorArgs = {
|
|
9
|
-
files: Map<string,
|
|
10
|
+
files: Map<string, File>;
|
|
10
11
|
prettier?: PrettierConfigType;
|
|
11
12
|
basePath: string | undefined;
|
|
12
13
|
pinnableGenerators: string[];
|
|
@@ -16,7 +17,7 @@ type ConstructorArgs = {
|
|
|
16
17
|
};
|
|
17
18
|
export declare class RenderContext {
|
|
18
19
|
#private;
|
|
19
|
-
files: Map<string,
|
|
20
|
+
files: Map<string, File>;
|
|
20
21
|
private prettier?;
|
|
21
22
|
basePath: string | undefined;
|
|
22
23
|
currentDestinationPath: string | 'PRE_RENDER' | 'POST_RENDER';
|
|
@@ -27,7 +28,7 @@ export declare class RenderContext {
|
|
|
27
28
|
render(): Omit<RenderResult, 'results'>;
|
|
28
29
|
private collate;
|
|
29
30
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
30
|
-
getFile(filePath: string):
|
|
31
|
+
getFile(filePath: string): File;
|
|
31
32
|
addGeneratorKey({ generatorKey }: AddGeneratorKeyArgs): void;
|
|
32
33
|
pick({ name, exportPath }: PickArgs): Definition | undefined;
|
|
33
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"RenderContext.d.ts","sourceRoot":"","sources":["../../src/context/RenderContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAqB,YAAY,EAAE,MAAM,YAAY,CAAA;AAEtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAE1C,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACxB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,oBAAoB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;CACnD,CAAA;AAYD,qBAAa,aAAa;;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAoB;IACrC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,sBAAsB,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa,CAAA;IAC7D,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAElB,oBAAoB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;gBACtC,EACV,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,MAAM,EACN,UAAU,EACV,oBAAoB,EACrB,EAAE,eAAe;IAWlB,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC;IAuBvC,OAAO,CAAC,OAAO;IAoDf,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIlD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAU/B,eAAe,CAAC,EAAE,YAAY,EAAE,EAAE,mBAAmB;IAarD,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAG7D"}
|
|
@@ -40,7 +40,6 @@ var _RenderContext_stackTrail;
|
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.RenderContext = void 0;
|
|
42
42
|
const Sentry = __importStar(require("@sentry/deno"));
|
|
43
|
-
const Import_js_1 = require("../dsl/Import.js");
|
|
44
43
|
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
45
44
|
const mod_js_1 = require("../deps/jsr.io/@std/path/1.0.0/mod.js");
|
|
46
45
|
const toResolvedArtifactPath_js_1 = require("../helpers/toResolvedArtifactPath.js");
|
|
@@ -129,7 +128,8 @@ class RenderContext {
|
|
|
129
128
|
// @TODO: Could this be combined with the tracer call above?
|
|
130
129
|
this.currentDestinationPath = destinationPath;
|
|
131
130
|
const renderedFile = renderFile({
|
|
132
|
-
file,
|
|
131
|
+
content: file.toString(),
|
|
132
|
+
generatorKeys: Array.from(file.generatorKeys).filter(Boolean),
|
|
133
133
|
destinationPath,
|
|
134
134
|
basePath: this.basePath,
|
|
135
135
|
prettier: this.prettier
|
|
@@ -179,20 +179,14 @@ class RenderContext {
|
|
|
179
179
|
}
|
|
180
180
|
exports.RenderContext = RenderContext;
|
|
181
181
|
_RenderContext_stackTrail = new WeakMap();
|
|
182
|
-
const renderFile = ({
|
|
183
|
-
const imports = Array.from(file.imports.entries()).map(([module, importItems]) => new Import_js_1.Import({ module, importNames: Array.from(importItems) }));
|
|
184
|
-
const definitions = Array.from(file.definitions.values());
|
|
185
|
-
const content = [imports, definitions]
|
|
186
|
-
.filter(section => Boolean(section.length))
|
|
187
|
-
.map(section => section.join('\n'))
|
|
188
|
-
.join('\n\n');
|
|
182
|
+
const renderFile = ({ content, generatorKeys, destinationPath, basePath }) => {
|
|
189
183
|
return {
|
|
190
184
|
content,
|
|
191
185
|
path: (0, toResolvedArtifactPath_js_1.toResolvedArtifactPath)({ basePath, destinationPath }),
|
|
192
186
|
destinationPath,
|
|
193
187
|
numberOfLines: content.split('\n').length,
|
|
194
188
|
numberOfCharacters: content.length,
|
|
195
|
-
generatorKeys
|
|
189
|
+
generatorKeys,
|
|
196
190
|
hash: 'PLACEHOLDER'
|
|
197
191
|
};
|
|
198
192
|
};
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import type { Definition } from '../dsl/Definition.js';
|
|
2
1
|
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
3
2
|
import type { ManifestEntry } from '../types/Manifest.js';
|
|
4
3
|
import type { ResultType } from '../types/Results.js';
|
|
5
4
|
export type PhaseType = 'parse' | 'generate' | 'render';
|
|
6
|
-
export type FileContents = {
|
|
7
|
-
imports: Map<string, Set<string>>;
|
|
8
|
-
definitions: Map<string, Definition>;
|
|
9
|
-
generatorKeys: Set<GeneratorKey>;
|
|
10
|
-
};
|
|
11
5
|
export type GetFileOptions = {
|
|
12
6
|
throwIfNotFound?: boolean;
|
|
13
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;CAChD,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CACpC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Definition } from './Definition.js';
|
|
2
|
+
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
3
|
+
export declare class File {
|
|
4
|
+
#private;
|
|
5
|
+
path: string;
|
|
6
|
+
imports: Map<string, Set<string>>;
|
|
7
|
+
definitions: Map<string, Definition>;
|
|
8
|
+
constructor(path: string);
|
|
9
|
+
get generatorKeys(): Set<GeneratorKey>;
|
|
10
|
+
toString(): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=File.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../../src/dsl/File.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE7D,qBAAa,IAAI;;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;gBAGxB,IAAI,EAAE,MAAM;IAOxB,IAAI,aAAa,sBAEhB;IAED,QAAQ;CAYT"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _File_generatorKeys;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.File = void 0;
|
|
16
|
+
const Import_js_1 = require("./Import.js");
|
|
17
|
+
class File {
|
|
18
|
+
constructor(path) {
|
|
19
|
+
Object.defineProperty(this, "path", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "imports", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(this, "definitions", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
_File_generatorKeys.set(this, void 0);
|
|
38
|
+
this.path = path;
|
|
39
|
+
this.imports = new Map();
|
|
40
|
+
this.definitions = new Map();
|
|
41
|
+
__classPrivateFieldSet(this, _File_generatorKeys, new Set(), "f");
|
|
42
|
+
}
|
|
43
|
+
get generatorKeys() {
|
|
44
|
+
return __classPrivateFieldGet(this, _File_generatorKeys, "f");
|
|
45
|
+
}
|
|
46
|
+
toString() {
|
|
47
|
+
const imports = Array.from(this.imports.entries()).map(([module, importItems]) => new Import_js_1.Import({ module, importNames: Array.from(importItems) }));
|
|
48
|
+
const definitions = Array.from(this.definitions.values());
|
|
49
|
+
return [imports, definitions]
|
|
50
|
+
.filter(section => Boolean(section.length))
|
|
51
|
+
.map(section => section.join('\n'))
|
|
52
|
+
.join('\n\n');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.File = File;
|
|
56
|
+
_File_generatorKeys = new WeakMap();
|