@skmtc/core 0.0.312 → 0.0.313
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 +6 -5
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +51 -51
- package/esm/context/GenerateContext.d.ts +5 -4
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +25 -23
- package/esm/context/ParseContext.d.ts +5 -4
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +22 -30
- package/esm/context/RenderContext.d.ts +5 -5
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +28 -35
- package/esm/context/StackTrail.js +1 -1
- package/esm/generate/generate.d.ts.map +1 -1
- package/esm/generate/generate.js +3 -2
- package/esm/helpers/tracer.d.ts +3 -3
- package/esm/helpers/tracer.d.ts.map +1 -1
- package/esm/helpers/tracer.js +3 -3
- package/esm/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/esm/oas/parameter/toParameterV3.js +0 -1
- package/esm/server/createServer.js +2 -2
- package/esm/types/GeneratorKeys.js +6 -6
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +6 -5
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +51 -51
- package/script/context/GenerateContext.d.ts +5 -4
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +25 -23
- package/script/context/ParseContext.d.ts +5 -4
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +22 -30
- package/script/context/RenderContext.d.ts +5 -5
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +28 -35
- package/script/context/StackTrail.js +1 -1
- package/script/generate/generate.d.ts.map +1 -1
- package/script/generate/generate.js +3 -2
- package/script/helpers/tracer.d.ts +3 -3
- package/script/helpers/tracer.d.ts.map +1 -1
- package/script/helpers/tracer.js +3 -3
- package/script/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/script/oas/parameter/toParameterV3.js +0 -1
- package/script/server/createServer.js +2 -2
- package/script/types/GeneratorKeys.js +6 -6
|
@@ -1,23 +1,11 @@
|
|
|
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 _RenderContext_stackTrail;
|
|
13
1
|
import * as Sentry from '@sentry/deno';
|
|
14
2
|
import { Import } from '../dsl/Import.js';
|
|
15
3
|
import invariant from 'tiny-invariant';
|
|
16
4
|
import { normalize } from '../deps/jsr.io/@std/path/1.0.0/mod.js';
|
|
17
5
|
import { toResolvedArtifactPath } from '../helpers/toResolvedArtifactPath.js';
|
|
18
|
-
import {
|
|
6
|
+
import { tracer } from '../helpers/tracer.js';
|
|
19
7
|
export class RenderContext {
|
|
20
|
-
constructor({ files, prettier, basePath, pinnableGenerators }) {
|
|
8
|
+
constructor({ files, prettier, basePath, pinnableGenerators, appendToStackTrail, removeFromStackTrail }) {
|
|
21
9
|
Object.defineProperty(this, "files", {
|
|
22
10
|
enumerable: true,
|
|
23
11
|
configurable: true,
|
|
@@ -48,22 +36,25 @@ export class RenderContext {
|
|
|
48
36
|
writable: true,
|
|
49
37
|
value: void 0
|
|
50
38
|
});
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
Object.defineProperty(this, "appendToStackTrail", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(this, "removeFromStackTrail", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: void 0
|
|
50
|
+
});
|
|
53
51
|
this.currentDestinationPath = 'PRE_RENDER';
|
|
54
52
|
this.files = files;
|
|
55
53
|
this.prettier = prettier;
|
|
56
54
|
this.basePath = basePath;
|
|
57
55
|
this.pinnableGenerators = pinnableGenerators;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
__classPrivateFieldGet(this, _RenderContext_stackTrail, "f").append(chunk);
|
|
61
|
-
}
|
|
62
|
-
removeStackTrailChunk(chunk) {
|
|
63
|
-
__classPrivateFieldGet(this, _RenderContext_stackTrail, "f").remove(chunk);
|
|
64
|
-
}
|
|
65
|
-
get stackTrail() {
|
|
66
|
-
return __classPrivateFieldGet(this, _RenderContext_stackTrail, "f").toString();
|
|
56
|
+
this.appendToStackTrail = appendToStackTrail;
|
|
57
|
+
this.removeFromStackTrail = removeFromStackTrail;
|
|
67
58
|
}
|
|
68
59
|
render() {
|
|
69
60
|
return Sentry.startSpan({ name: 'Render artifacts' }, () => {
|
|
@@ -87,15 +78,18 @@ export class RenderContext {
|
|
|
87
78
|
collate() {
|
|
88
79
|
const fileEntries = Array.from(this.files.entries());
|
|
89
80
|
const fileObjects = fileEntries.map(([destinationPath, file]) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
return tracer(this, destinationPath, () => {
|
|
82
|
+
// Set the current destination path to be used by
|
|
83
|
+
// addGeneratorKey method to apply generator keys
|
|
84
|
+
// to Correct file
|
|
85
|
+
// @TODO: Could this be combined with the tracer call above?
|
|
86
|
+
this.currentDestinationPath = destinationPath;
|
|
87
|
+
return renderFile({
|
|
88
|
+
file,
|
|
89
|
+
destinationPath,
|
|
90
|
+
basePath: this.basePath,
|
|
91
|
+
prettier: this.prettier
|
|
92
|
+
});
|
|
99
93
|
});
|
|
100
94
|
});
|
|
101
95
|
this.currentDestinationPath = 'POST_RENDER';
|
|
@@ -144,7 +138,6 @@ export class RenderContext {
|
|
|
144
138
|
return this.getFile(exportPath).definitions.get(name);
|
|
145
139
|
}
|
|
146
140
|
}
|
|
147
|
-
_RenderContext_stackTrail = new WeakMap();
|
|
148
141
|
const renderFile = ({ file, destinationPath, basePath }) => {
|
|
149
142
|
const imports = Array.from(file.imports.entries()).map(([module, importItems]) => new Import({ module, importNames: Array.from(importItems) }));
|
|
150
143
|
const definitions = Array.from(file.definitions.values());
|
|
@@ -50,7 +50,7 @@ export class StackTrail {
|
|
|
50
50
|
static parse(value) {
|
|
51
51
|
const stack = value.split(':').map(item => {
|
|
52
52
|
if (!item) {
|
|
53
|
-
throw new Error(`Empty stack trail
|
|
53
|
+
throw new Error(`Empty stack trail token in: ${value}`);
|
|
54
54
|
}
|
|
55
55
|
return item.replaceAll('%3A', ':');
|
|
56
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/generate/generate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,cAAc,CAAC,CAAA;IAClE,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,QAAQ,4EAQlB,YAAY;;;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/generate/generate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,cAAc,CAAC,CAAA;IAClE,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,QAAQ,4EAQlB,YAAY;;;CAuBd,CAAA"}
|
package/esm/generate/generate.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
2
|
import { CoreContext } from '../context/CoreContext.js';
|
|
3
3
|
export const generate = ({ traceId, spanId, schema, settings, prettier, generatorsMap, startAt }) => {
|
|
4
|
-
const context = new CoreContext({ spanId
|
|
4
|
+
const context = new CoreContext({ spanId });
|
|
5
5
|
const { artifacts, files, pinnable, results } = context.transform({
|
|
6
6
|
settings,
|
|
7
7
|
generatorsMap,
|
|
8
|
-
prettier
|
|
8
|
+
prettier,
|
|
9
|
+
schema
|
|
9
10
|
});
|
|
10
11
|
const manifest = {
|
|
11
12
|
files,
|
package/esm/helpers/tracer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type StackTrailHandler = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
appendToStackTrail: (token: string | string[]) => void;
|
|
3
|
+
removeFromStackTrail: (token: string | string[]) => void;
|
|
4
4
|
};
|
|
5
|
-
export declare const tracer: <T>(context: StackTrailHandler,
|
|
5
|
+
export declare const tracer: <T>(context: StackTrailHandler, token: string | string[], fn: () => T) => T;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=tracer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/helpers/tracer.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,
|
|
1
|
+
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/helpers/tracer.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAA;IACtD,oBAAoB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAA;CACzD,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,CAAC,WACb,iBAAiB,SACnB,MAAM,GAAG,MAAM,EAAE,MACpB,MAAM,CAAC,MASZ,CAAA"}
|
package/esm/helpers/tracer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const tracer = (context,
|
|
2
|
-
context.
|
|
1
|
+
export const tracer = (context, token, fn) => {
|
|
2
|
+
context.appendToStackTrail(token);
|
|
3
3
|
const result = fn();
|
|
4
|
-
context.
|
|
4
|
+
context.removeFromStackTrail(token);
|
|
5
5
|
return result;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toParameterV3.d.ts","sourceRoot":"","sources":["../../../src/oas/parameter/toParameterV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAQjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAK9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAI3C,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EACN,CAAC,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC,EAAE,GACzD,SAAS,CAAA;IACb,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,iBAAiB,4BAG3B,qBAAqB,KACpB,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,GACtC,
|
|
1
|
+
{"version":3,"file":"toParameterV3.d.ts","sourceRoot":"","sources":["../../../src/oas/parameter/toParameterV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAQjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAK9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAI3C,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EACN,CAAC,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC,EAAE,GACzD,SAAS,CAAA;IACb,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,iBAAiB,4BAG3B,qBAAqB,KACpB,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,GACtC,SAUH,CAAA;AAED,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,MAAM,CAChB,MAAM,EACN,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CACtD,CAAA;IACD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CASxE,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,UAAU,EACN,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC,GACrE,SAAS,CAAA;IACb,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,sBAAsB,4BAGhC,0BAA0B,KACzB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,GAClD,SAMH,CAAA"}
|
|
@@ -12,7 +12,6 @@ export const toParameterListV3 = ({ parameters, context }) => {
|
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
14
|
return parameters.map((parameter, index) => {
|
|
15
|
-
console.log('parameter index', index);
|
|
16
15
|
return tracer(context, `${index}`, () => toParameterV3({ parameter, context }));
|
|
17
16
|
});
|
|
18
17
|
};
|
|
@@ -104,6 +104,6 @@ const toOperations = ({ generator, oasDocument, operationsSettings }) => {
|
|
|
104
104
|
}, {});
|
|
105
105
|
};
|
|
106
106
|
const toOasDocument = ({ schema, spanId }) => {
|
|
107
|
-
const context = new CoreContext({ spanId
|
|
108
|
-
return context.parse();
|
|
107
|
+
const context = new CoreContext({ spanId });
|
|
108
|
+
return context.parse(schema);
|
|
109
109
|
};
|
|
@@ -22,11 +22,11 @@ export const isOperationGeneratorKey = (arg) => {
|
|
|
22
22
|
if (typeof arg !== 'string') {
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
25
|
+
const keyTokens = arg.split('|');
|
|
26
|
+
if (keyTokens.length !== 3) {
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
|
-
const [generatorId, path, method] =
|
|
29
|
+
const [generatorId, path, method] = keyTokens;
|
|
30
30
|
if (typeof generatorId !== 'string' || !generatorId.length) {
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
@@ -42,11 +42,11 @@ export const isModelGeneratorKey = (arg) => {
|
|
|
42
42
|
if (typeof arg !== 'string') {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
45
|
+
const keyTokens = arg.split('|');
|
|
46
|
+
if (keyTokens.length !== 2) {
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
|
-
const [generatorId, refName] =
|
|
49
|
+
const [generatorId, refName] = keyTokens;
|
|
50
50
|
if (typeof generatorId !== 'string' || !generatorId.length) {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
package/package.json
CHANGED
|
@@ -8,9 +8,9 @@ import * as log from '../deps/jsr.io/@std/log/0.224.6/mod.js';
|
|
|
8
8
|
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
9
9
|
type CoreContextArgs = {
|
|
10
10
|
spanId: string;
|
|
11
|
-
schema: string;
|
|
12
11
|
};
|
|
13
12
|
type TransformArgs = {
|
|
13
|
+
schema: string;
|
|
14
14
|
settings: ClientSettings | undefined;
|
|
15
15
|
generatorsMap: Record<string, OperationGenerator | ModelGenerator>;
|
|
16
16
|
prettier?: PrettierConfigType;
|
|
@@ -18,16 +18,17 @@ type TransformArgs = {
|
|
|
18
18
|
export declare class CoreContext {
|
|
19
19
|
#private;
|
|
20
20
|
logger: log.Logger;
|
|
21
|
-
constructor({
|
|
22
|
-
parse(): OasDocument;
|
|
23
|
-
|
|
21
|
+
constructor({ spanId }: CoreContextArgs);
|
|
22
|
+
parse(schema: string): OasDocument;
|
|
23
|
+
appendToStackTrail(token: string | string[]): void;
|
|
24
|
+
removeFromStackTrail(token: string | string[]): void;
|
|
25
|
+
transform({ schema, settings, generatorsMap, prettier }: TransformArgs): {
|
|
24
26
|
results: Record<string, SuccessWarningError>;
|
|
25
27
|
files: Record<string, import("../types/Manifest.js").ManifestEntry>;
|
|
26
28
|
pinnable: Partial<Record<GeneratorKey, string>>;
|
|
27
29
|
artifacts: Record<string, string>;
|
|
28
30
|
};
|
|
29
31
|
captureCurrentResult(result: SuccessWarningError): void;
|
|
30
|
-
get phaseType(): 'parse' | 'generate' | 'render';
|
|
31
32
|
}
|
|
32
33
|
export type JsonFormatterArgs = {
|
|
33
34
|
logRecord: log.LogRecord;
|
|
@@ -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":"AAIA,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,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AA2B7D,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AASD,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;IACpC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,cAAc,CAAC,CAAA;IAClE,QAAQ,CAAC,EAAE,kBAAkB,CAAA;CAC9B,CAAA;AAED,qBAAa,WAAW;;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;gBAKN,EAAE,MAAM,EAAE,EAAE,eAAe;IAmCvC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW;IAMlC,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAIlD,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAIpD,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,aAAa;;;;;;IA4EtE,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;CA8BxD;AAkBD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,GAAG,CAAC,SAAS,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,UAAU,EACX,EAAE,iBAAiB,GAAG,MAAM,CAQ5B"}
|
|
@@ -33,19 +33,19 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
33
33
|
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");
|
|
34
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
35
|
};
|
|
36
|
-
var _CoreContext_instances, _CoreContext_phase, _CoreContext_results, _CoreContext_stackTrail, _CoreContext_setupLogger,
|
|
36
|
+
var _CoreContext_instances, _CoreContext_phase, _CoreContext_results, _CoreContext_stackTrail, _CoreContext_setupLogger, _CoreContext_setupParsePhase, _CoreContext_setupGeneratePhase, _CoreContext_setupRenderPhase;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.CoreContext = void 0;
|
|
39
39
|
exports.skmtcFormatter = skmtcFormatter;
|
|
40
40
|
const GenerateContext_js_1 = require("./GenerateContext.js");
|
|
41
|
-
const ts_pattern_1 = require("ts-pattern");
|
|
42
41
|
const RenderContext_js_1 = require("./RenderContext.js");
|
|
43
42
|
const ParseContext_js_1 = require("./ParseContext.js");
|
|
44
43
|
const log = __importStar(require("../deps/jsr.io/@std/log/0.224.6/mod.js"));
|
|
45
44
|
const ResultsHandler_js_1 = require("./ResultsHandler.js");
|
|
46
45
|
const StackTrail_js_1 = require("./StackTrail.js");
|
|
46
|
+
const tracer_js_1 = require("../helpers/tracer.js");
|
|
47
47
|
class CoreContext {
|
|
48
|
-
constructor({
|
|
48
|
+
constructor({ spanId }) {
|
|
49
49
|
_CoreContext_instances.add(this);
|
|
50
50
|
Object.defineProperty(this, "logger", {
|
|
51
51
|
enumerable: true,
|
|
@@ -59,49 +59,55 @@ class CoreContext {
|
|
|
59
59
|
__classPrivateFieldSet(this, _CoreContext_stackTrail, new StackTrail_js_1.StackTrail([spanId]), "f");
|
|
60
60
|
__classPrivateFieldSet(this, _CoreContext_results, {}, "f");
|
|
61
61
|
this.logger = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupLogger).call(this, spanId);
|
|
62
|
-
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, schema), "f");
|
|
63
62
|
}
|
|
64
|
-
parse() {
|
|
65
|
-
|
|
66
|
-
throw new Error(`Expected 'parse' phase, got '${__classPrivateFieldGet(this, _CoreContext_phase, "f").type}'`);
|
|
67
|
-
}
|
|
63
|
+
parse(schema) {
|
|
64
|
+
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, schema), "f");
|
|
68
65
|
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
69
66
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
appendToStackTrail(token) {
|
|
68
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append(token);
|
|
69
|
+
}
|
|
70
|
+
removeFromStackTrail(token) {
|
|
71
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove(token);
|
|
72
|
+
}
|
|
73
|
+
transform({ schema, settings, generatorsMap, prettier }) {
|
|
74
74
|
const callback = (generatorKey) => {
|
|
75
|
-
if (__classPrivateFieldGet(this, _CoreContext_phase, "f")
|
|
75
|
+
if (__classPrivateFieldGet(this, _CoreContext_phase, "f")?.type === 'render') {
|
|
76
76
|
__classPrivateFieldGet(this, _CoreContext_phase, "f").context.addGeneratorKey({ generatorKey });
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
const schemaModel =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
const schemaModel = (0, tracer_js_1.tracer)(this, 'parse', () => {
|
|
80
|
+
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, schema), "f");
|
|
81
|
+
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
82
|
+
});
|
|
83
|
+
const files = (0, tracer_js_1.tracer)(this, 'generate', () => {
|
|
84
|
+
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
85
|
+
schemaModel,
|
|
86
|
+
settings,
|
|
87
|
+
generatorsMap,
|
|
88
|
+
callback
|
|
89
|
+
}), "f");
|
|
90
|
+
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.generate(generatorsMap);
|
|
91
|
+
});
|
|
87
92
|
this.logger.debug(`${files.size} files generated`);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
const renderOutput = (0, tracer_js_1.tracer)(this, 'render', () => {
|
|
94
|
+
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupRenderPhase).call(this, {
|
|
95
|
+
files,
|
|
96
|
+
pinnableGenerators: Object.values(generatorsMap)
|
|
97
|
+
.map(({ id, pinnable }) => (pinnable ? id : null))
|
|
98
|
+
.filter(generatorId => generatorId !== null),
|
|
99
|
+
prettier,
|
|
100
|
+
basePath: settings?.basePath
|
|
101
|
+
}), "f");
|
|
102
|
+
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.render();
|
|
103
|
+
});
|
|
98
104
|
return {
|
|
99
105
|
...renderOutput,
|
|
100
106
|
results: __classPrivateFieldGet(this, _CoreContext_results, "f")
|
|
101
107
|
};
|
|
102
108
|
}
|
|
103
109
|
captureCurrentResult(result) {
|
|
104
|
-
const stackTrail = __classPrivateFieldGet(this,
|
|
110
|
+
const stackTrail = __classPrivateFieldGet(this, _CoreContext_stackTrail, "f").toString();
|
|
105
111
|
if (incomingResultIsWorse({
|
|
106
112
|
current: __classPrivateFieldGet(this, _CoreContext_results, "f")[stackTrail],
|
|
107
113
|
incoming: result
|
|
@@ -109,9 +115,6 @@ class CoreContext {
|
|
|
109
115
|
__classPrivateFieldGet(this, _CoreContext_results, "f")[stackTrail] = result;
|
|
110
116
|
}
|
|
111
117
|
}
|
|
112
|
-
get phaseType() {
|
|
113
|
-
return __classPrivateFieldGet(this, _CoreContext_phase, "f").type;
|
|
114
|
-
}
|
|
115
118
|
}
|
|
116
119
|
exports.CoreContext = CoreContext;
|
|
117
120
|
_CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_stackTrail = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger(spanId) {
|
|
@@ -120,7 +123,7 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
120
123
|
[`${spanId}-logs`]: new log.ConsoleHandler('DEBUG', {
|
|
121
124
|
formatter: logRecord => skmtcFormatter({
|
|
122
125
|
logRecord,
|
|
123
|
-
stackTrail: __classPrivateFieldGet(this,
|
|
126
|
+
stackTrail: __classPrivateFieldGet(this, _CoreContext_stackTrail, "f").toString()
|
|
124
127
|
}),
|
|
125
128
|
useColors: false
|
|
126
129
|
}),
|
|
@@ -137,37 +140,34 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
137
140
|
}
|
|
138
141
|
});
|
|
139
142
|
return log.getLogger(spanId);
|
|
140
|
-
}, _CoreContext_getStackTrailString = function _CoreContext_getStackTrailString() {
|
|
141
|
-
const substack = (0, ts_pattern_1.match)(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
142
|
-
.with({ type: 'parse' }, ({ context }) => context.stackTrail)
|
|
143
|
-
.with({ type: 'generate' }, ({ context }) => context.stackTrail)
|
|
144
|
-
.with({ type: 'render' }, ({ context }) => context.stackTrail)
|
|
145
|
-
.exhaustive();
|
|
146
|
-
return StackTrail_js_1.StackTrail.join(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f"), substack);
|
|
147
143
|
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(schema) {
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
const parseContext = new ParseContext_js_1.ParseContext({
|
|
145
|
+
schema,
|
|
146
|
+
logger: this.logger,
|
|
147
|
+
appendToStackTrail: this.appendToStackTrail.bind(this),
|
|
148
|
+
removeFromStackTrail: this.appendToStackTrail.bind(this)
|
|
149
|
+
});
|
|
150
150
|
return { type: 'parse', context: parseContext };
|
|
151
151
|
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ schemaModel, settings, generatorsMap, callback }) {
|
|
152
|
-
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('parse');
|
|
153
|
-
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('generate');
|
|
154
152
|
const generateContext = new GenerateContext_js_1.GenerateContext({
|
|
155
153
|
schemaModel,
|
|
156
154
|
settings,
|
|
157
155
|
generatorsMap,
|
|
158
156
|
logger: this.logger,
|
|
159
157
|
callback,
|
|
160
|
-
captureCurrentResult: this.captureCurrentResult.bind(this)
|
|
158
|
+
captureCurrentResult: this.captureCurrentResult.bind(this),
|
|
159
|
+
appendToStackTrail: this.appendToStackTrail.bind(this),
|
|
160
|
+
removeFromStackTrail: this.removeFromStackTrail.bind(this)
|
|
161
161
|
});
|
|
162
162
|
return { type: 'generate', context: generateContext };
|
|
163
163
|
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({ files, prettier, basePath, pinnableGenerators }) {
|
|
164
|
-
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('generate');
|
|
165
|
-
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('render');
|
|
166
164
|
const renderContext = new RenderContext_js_1.RenderContext({
|
|
167
165
|
files,
|
|
168
166
|
prettier,
|
|
169
167
|
basePath,
|
|
170
|
-
pinnableGenerators
|
|
168
|
+
pinnableGenerators,
|
|
169
|
+
appendToStackTrail: this.appendToStackTrail.bind(this),
|
|
170
|
+
removeFromStackTrail: this.removeFromStackTrail.bind(this)
|
|
171
171
|
});
|
|
172
172
|
return { type: 'render', context: renderContext };
|
|
173
173
|
};
|
|
@@ -22,6 +22,8 @@ type ConstructorArgs = {
|
|
|
22
22
|
logger: log.Logger;
|
|
23
23
|
callback: (generatorKey: GeneratorKey) => void;
|
|
24
24
|
captureCurrentResult: (result: SuccessWarningError) => void;
|
|
25
|
+
appendToStackTrail: (token: string | string[]) => void;
|
|
26
|
+
removeFromStackTrail: (token: string | string[]) => void;
|
|
25
27
|
};
|
|
26
28
|
export type PickArgs = {
|
|
27
29
|
name: string;
|
|
@@ -68,11 +70,10 @@ export declare class GenerateContext {
|
|
|
68
70
|
logger: log.Logger;
|
|
69
71
|
callback: (generatorKey: GeneratorKey) => void;
|
|
70
72
|
captureCurrentResult: (result: SuccessWarningError) => void;
|
|
71
|
-
|
|
73
|
+
appendToStackTrail: (token: string | string[]) => void;
|
|
74
|
+
removeFromStackTrail: (token: string | string[]) => void;
|
|
75
|
+
constructor({ schemaModel, settings, logger, callback, captureCurrentResult, appendToStackTrail, removeFromStackTrail }: ConstructorArgs);
|
|
72
76
|
generate(generatorsMap: Record<string, OperationGenerator | ModelGenerator>): Map<string, FileContents>;
|
|
73
|
-
appendStackTrailChunk(chunk: string | string[]): void;
|
|
74
|
-
removeStackTrailChunk(chunk: string | string[]): void;
|
|
75
|
-
get stackTrail(): string;
|
|
76
77
|
getFile(filePath: string, { throwIfNotFound }?: GetFileOptions): FileContents;
|
|
77
78
|
register({ imports, definitions, destinationPath }: RegisterArgs): void;
|
|
78
79
|
insert<V extends GeneratedValue, T extends GenerationType>({ generation, destinationPath, ...rest }: InsertArgs<V, T>): InsertReturn<V, T>;
|
|
@@ -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,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB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E,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAGvE"}
|
|
@@ -33,17 +33,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
33
33
|
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");
|
|
34
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
35
|
};
|
|
36
|
-
var _GenerateContext_instances, _GenerateContext_files,
|
|
36
|
+
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_generateModel, _GenerateContext_generateOperation;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.GenerateContext = void 0;
|
|
39
39
|
const mod_js_1 = require("../deps/jsr.io/@std/path/1.0.0/mod.js");
|
|
40
40
|
const Import_js_1 = require("../dsl/Import.js");
|
|
41
41
|
const OperationDriver_js_1 = require("../dsl/OperationDriver.js");
|
|
42
42
|
const ModelDriver_js_1 = require("../dsl/ModelDriver.js");
|
|
43
|
-
const StackTrail_js_1 = require("./StackTrail.js");
|
|
44
43
|
const Sentry = __importStar(require("@sentry/deno"));
|
|
45
44
|
class GenerateContext {
|
|
46
|
-
constructor({ schemaModel, settings, logger, callback, captureCurrentResult }) {
|
|
45
|
+
constructor({ schemaModel, settings, logger, callback, captureCurrentResult, appendToStackTrail, removeFromStackTrail }) {
|
|
47
46
|
_GenerateContext_instances.add(this);
|
|
48
47
|
_GenerateContext_files.set(this, void 0);
|
|
49
48
|
Object.defineProperty(this, "schemaModel", {
|
|
@@ -58,7 +57,6 @@ class GenerateContext {
|
|
|
58
57
|
writable: true,
|
|
59
58
|
value: void 0
|
|
60
59
|
});
|
|
61
|
-
_GenerateContext_stackTrail.set(this, void 0);
|
|
62
60
|
Object.defineProperty(this, "logger", {
|
|
63
61
|
enumerable: true,
|
|
64
62
|
configurable: true,
|
|
@@ -77,45 +75,49 @@ class GenerateContext {
|
|
|
77
75
|
writable: true,
|
|
78
76
|
value: void 0
|
|
79
77
|
});
|
|
78
|
+
Object.defineProperty(this, "appendToStackTrail", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
configurable: true,
|
|
81
|
+
writable: true,
|
|
82
|
+
value: void 0
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(this, "removeFromStackTrail", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true,
|
|
88
|
+
value: void 0
|
|
89
|
+
});
|
|
80
90
|
this.logger = logger;
|
|
81
|
-
__classPrivateFieldSet(this, _GenerateContext_stackTrail, new StackTrail_js_1.StackTrail(), "f");
|
|
82
91
|
__classPrivateFieldSet(this, _GenerateContext_files, new Map(), "f");
|
|
83
92
|
this.schemaModel = schemaModel;
|
|
84
93
|
this.settings = settings;
|
|
85
94
|
this.callback = callback;
|
|
86
95
|
this.captureCurrentResult = captureCurrentResult;
|
|
96
|
+
this.appendToStackTrail = appendToStackTrail;
|
|
97
|
+
this.removeFromStackTrail = removeFromStackTrail;
|
|
87
98
|
}
|
|
88
99
|
generate(generatorsMap) {
|
|
89
100
|
Sentry.startSpan({ name: 'Generate operations' }, () => Object.values(generatorsMap)
|
|
90
101
|
.filter(generator => generator.type === 'operation')
|
|
91
102
|
.forEach(generator => {
|
|
92
|
-
this.
|
|
103
|
+
this.appendToStackTrail(generator.id);
|
|
93
104
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runOperationGenerator).call(this, {
|
|
94
105
|
schemaModel: this.schemaModel,
|
|
95
106
|
generator
|
|
96
107
|
});
|
|
97
|
-
this.
|
|
108
|
+
this.removeFromStackTrail(generator.id);
|
|
98
109
|
}));
|
|
99
110
|
Sentry.startSpan({ name: 'Generate models' }, () => {
|
|
100
111
|
Object.values(generatorsMap)
|
|
101
112
|
.filter(generator => generator.type === 'model')
|
|
102
113
|
.forEach(generator => {
|
|
103
|
-
this.
|
|
114
|
+
this.appendToStackTrail(generator.id);
|
|
104
115
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runModelGenerator).call(this, { schemaModel: this.schemaModel, generator });
|
|
105
|
-
this.
|
|
116
|
+
this.removeFromStackTrail(generator.id);
|
|
106
117
|
});
|
|
107
118
|
});
|
|
108
119
|
return __classPrivateFieldGet(this, _GenerateContext_files, "f");
|
|
109
120
|
}
|
|
110
|
-
appendStackTrailChunk(chunk) {
|
|
111
|
-
__classPrivateFieldGet(this, _GenerateContext_stackTrail, "f").append(chunk);
|
|
112
|
-
}
|
|
113
|
-
removeStackTrailChunk(chunk) {
|
|
114
|
-
__classPrivateFieldGet(this, _GenerateContext_stackTrail, "f").remove(chunk);
|
|
115
|
-
}
|
|
116
|
-
get stackTrail() {
|
|
117
|
-
return __classPrivateFieldGet(this, _GenerateContext_stackTrail, "f").toString();
|
|
118
|
-
}
|
|
119
121
|
getFile(filePath, { throwIfNotFound = false } = {}) {
|
|
120
122
|
const normalisedPath = (0, mod_js_1.normalize)(filePath);
|
|
121
123
|
const currentFile = __classPrivateFieldGet(this, _GenerateContext_files, "f").get(normalisedPath);
|
|
@@ -228,7 +230,7 @@ class GenerateContext {
|
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
exports.GenerateContext = GenerateContext;
|
|
231
|
-
_GenerateContext_files = new WeakMap(),
|
|
233
|
+
_GenerateContext_files = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_runOperationGenerator = function _GenerateContext_runOperationGenerator({ schemaModel, generator }) {
|
|
232
234
|
const generatorInstance = new generator(this);
|
|
233
235
|
schemaModel.operations.forEach(operation => {
|
|
234
236
|
// TODO If we make OasOperation generic, for example by
|
|
@@ -240,21 +242,21 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
|
|
|
240
242
|
// https://linear.app/skmtc/issue/SKM-32/generic-models-operations
|
|
241
243
|
const { path, method } = operation;
|
|
242
244
|
if (generator.isSupported(operation)) {
|
|
243
|
-
this.
|
|
245
|
+
this.appendToStackTrail([path, method]);
|
|
244
246
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_generateOperation).call(this, { operation, generatorInstance });
|
|
245
|
-
this.
|
|
247
|
+
this.removeFromStackTrail([path, method]);
|
|
246
248
|
}
|
|
247
249
|
});
|
|
248
250
|
}, _GenerateContext_runModelGenerator = function _GenerateContext_runModelGenerator({ schemaModel, generator }) {
|
|
249
251
|
const generatorInstance = new generator(this);
|
|
250
252
|
const refNames = Object.keys(schemaModel.components?.schemas ?? {});
|
|
251
253
|
refNames.forEach(rn => {
|
|
252
|
-
this.
|
|
254
|
+
this.appendToStackTrail(rn);
|
|
253
255
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_generateModel).call(this, {
|
|
254
256
|
refName: rn,
|
|
255
257
|
generatorInstance
|
|
256
258
|
});
|
|
257
|
-
this.
|
|
259
|
+
this.removeFromStackTrail(rn);
|
|
258
260
|
});
|
|
259
261
|
}, _GenerateContext_generateModel = function _GenerateContext_generateModel({ refName, generatorInstance }) {
|
|
260
262
|
try {
|