@skmtc/core 0.0.306 → 0.0.308
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 +3 -27
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +26 -201
- package/esm/context/GenerateContext.d.ts +12 -16
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +58 -70
- package/esm/context/ParseContext.d.ts +1 -2
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +18 -12
- package/esm/context/RenderContext.d.ts +7 -13
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +26 -46
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/context/ResultsHandler.js +0 -1
- package/esm/context/StackTrail.d.ts +1 -1
- package/esm/context/StackTrail.d.ts.map +1 -1
- package/esm/context/types.d.ts +0 -5
- package/esm/context/types.d.ts.map +1 -1
- package/esm/dsl/Definition.d.ts +2 -2
- package/esm/dsl/Definition.d.ts.map +1 -1
- package/esm/dsl/ModelDriver.d.ts +3 -3
- package/esm/dsl/ModelDriver.d.ts.map +1 -1
- package/esm/dsl/ModelInsertable.d.ts +3 -3
- package/esm/dsl/ModelInsertable.d.ts.map +1 -1
- package/esm/dsl/OperationDriver.d.ts +3 -3
- package/esm/dsl/OperationDriver.d.ts.map +1 -1
- package/esm/dsl/OperationInsertable.d.ts +3 -3
- package/esm/dsl/OperationInsertable.d.ts.map +1 -1
- package/esm/dsl/ValueBase.d.ts +3 -3
- package/esm/dsl/ValueBase.d.ts.map +1 -1
- package/esm/dsl/ValueBase.js +1 -3
- package/esm/dsl/base.d.ts +3 -4
- package/esm/dsl/base.d.ts.map +1 -1
- package/esm/dsl/withConfig.d.ts +7 -7
- package/esm/dsl/withConfig.d.ts.map +1 -1
- package/esm/generate/generate.d.ts +0 -1
- package/esm/generate/generate.d.ts.map +1 -1
- package/esm/generate/generate.js +6 -6
- package/esm/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/esm/oas/parameter/toParameterV3.js +1 -0
- package/esm/server/createServer.d.ts.map +1 -1
- package/esm/server/createServer.js +3 -7
- package/esm/types/CustomValue.d.ts +2 -2
- package/esm/types/CustomValue.d.ts.map +1 -1
- package/esm/typescript/PathParams.d.ts +3 -3
- package/esm/typescript/PathParams.d.ts.map +1 -1
- package/esm/typescript/ReactRouterPathParams.d.ts +2 -2
- package/esm/typescript/ReactRouterPathParams.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +3 -27
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +26 -201
- package/script/context/GenerateContext.d.ts +12 -16
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +58 -70
- package/script/context/ParseContext.d.ts +1 -2
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +18 -12
- package/script/context/RenderContext.d.ts +7 -13
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +26 -46
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/context/ResultsHandler.js +0 -1
- package/script/context/StackTrail.d.ts +1 -1
- package/script/context/StackTrail.d.ts.map +1 -1
- package/script/context/types.d.ts +0 -5
- package/script/context/types.d.ts.map +1 -1
- package/script/dsl/Definition.d.ts +2 -2
- package/script/dsl/Definition.d.ts.map +1 -1
- package/script/dsl/ModelDriver.d.ts +3 -3
- package/script/dsl/ModelDriver.d.ts.map +1 -1
- package/script/dsl/ModelInsertable.d.ts +3 -3
- package/script/dsl/ModelInsertable.d.ts.map +1 -1
- package/script/dsl/OperationDriver.d.ts +3 -3
- package/script/dsl/OperationDriver.d.ts.map +1 -1
- package/script/dsl/OperationInsertable.d.ts +3 -3
- package/script/dsl/OperationInsertable.d.ts.map +1 -1
- package/script/dsl/ValueBase.d.ts +3 -3
- package/script/dsl/ValueBase.d.ts.map +1 -1
- package/script/dsl/ValueBase.js +1 -3
- package/script/dsl/base.d.ts +3 -4
- package/script/dsl/base.d.ts.map +1 -1
- package/script/dsl/withConfig.d.ts +7 -7
- package/script/dsl/withConfig.d.ts.map +1 -1
- package/script/generate/generate.d.ts +0 -1
- package/script/generate/generate.d.ts.map +1 -1
- package/script/generate/generate.js +6 -6
- package/script/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/script/oas/parameter/toParameterV3.js +1 -0
- package/script/server/createServer.d.ts.map +1 -1
- package/script/server/createServer.js +3 -7
- package/script/types/CustomValue.d.ts +2 -2
- package/script/types/CustomValue.d.ts.map +1 -1
- package/script/typescript/PathParams.d.ts +3 -3
- package/script/typescript/PathParams.d.ts.map +1 -1
- package/script/typescript/ReactRouterPathParams.d.ts +2 -2
- package/script/typescript/ReactRouterPathParams.d.ts.map +1 -1
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import type { AddRenderDependencyArgs, GetModelSettingsArgs, GetOperationSettingsArgs, PickArgs, RegisterArgs, InsertReturn, InsertArgs } from './GenerateContext.js';
|
|
2
|
-
import type { AddGeneratorKeyArgs, FileContents, RenderDependencies } from './types.js';
|
|
3
1
|
import type { PrettierConfigType } from '../types/prettierConfig.js';
|
|
4
2
|
import type { OasDocument } from '../oas/document/Document.js';
|
|
5
|
-
import type {
|
|
6
|
-
import type { Definition } from '../dsl/Definition.js';
|
|
3
|
+
import type { ClientSettings } from '../types/Settings.js';
|
|
7
4
|
import type { OperationGenerator } from '../dsl/OperationInsertable.js';
|
|
8
5
|
import type { ModelGenerator } from '../dsl/ModelInsertable.js';
|
|
9
|
-
import type { GeneratedValue } from '../types/GeneratedValue.js';
|
|
10
|
-
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
11
|
-
import type { OasRef } from '../oas/ref/Ref.js';
|
|
12
|
-
import type { GenerationType } from '../types/GeneratedValue.js';
|
|
13
|
-
import type { RefName } from '../types/RefName.js';
|
|
14
6
|
import type { SuccessWarningError } from '../types/Manifest.js';
|
|
15
7
|
import * as log from '../deps/jsr.io/@std/log/0.224.6/mod.js';
|
|
8
|
+
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
16
9
|
type CoreContextArgs = {
|
|
17
10
|
spanId: string;
|
|
18
11
|
schema: string;
|
|
@@ -34,8 +27,7 @@ export declare class CoreContext {
|
|
|
34
27
|
transform({ settings, generatorsMap, prettier }: TransformArgs): {
|
|
35
28
|
results: Record<string, SuccessWarningError>;
|
|
36
29
|
files: Record<string, import("../types/Manifest.js").ManifestEntry>;
|
|
37
|
-
pinnable: Partial<Record<
|
|
38
|
-
renderDependencies: Record<string, string[]>;
|
|
30
|
+
pinnable: Partial<Record<GeneratorKey, string>>;
|
|
39
31
|
artifacts: Record<string, string>;
|
|
40
32
|
};
|
|
41
33
|
captureResult({ stackTrail, result }: CaptureResultArgs): void;
|
|
@@ -43,22 +35,6 @@ export declare class CoreContext {
|
|
|
43
35
|
get phaseType(): 'parse' | 'generate' | 'render';
|
|
44
36
|
appendStackTrailChunk(chunk: string | string[]): void;
|
|
45
37
|
removeStackTrailChunk(chunk: string | string[]): void;
|
|
46
|
-
register({ destinationPath, ...args }: RegisterArgs): void;
|
|
47
|
-
addGeneratorKey({ generatorKey }: AddGeneratorKeyArgs): void;
|
|
48
|
-
resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
49
|
-
addRenderDependency(args: AddRenderDependencyArgs): void;
|
|
50
|
-
getFile(filePath: string): FileContents;
|
|
51
|
-
findDefinition(args: PickArgs): Definition<GeneratedValue> | undefined;
|
|
52
|
-
addFile(normalisedPath: string): FileContents;
|
|
53
|
-
getOperationBaseSettings(args: GetOperationSettingsArgs): BaseSettings;
|
|
54
|
-
insert<V extends GeneratedValue, T extends GenerationType>(args: InsertArgs<V, T>): InsertReturn<V, T>;
|
|
55
|
-
getModelBaseSettings(args: GetModelSettingsArgs): BaseSettings;
|
|
56
|
-
get files(): Map<string, FileContents>;
|
|
57
|
-
get renderDependencies(): RenderDependencies;
|
|
58
|
-
get packageDependencies(): Map<string, string>;
|
|
59
|
-
get schemaModel(): OasDocument;
|
|
60
|
-
get generatorsMap(): Record<string, OperationGenerator | ModelGenerator>;
|
|
61
|
-
get settings(): ClientSettings | undefined;
|
|
62
38
|
}
|
|
63
39
|
export type JsonFormatterArgs = {
|
|
64
40
|
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":"AAKA,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;AA0B7D,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AASD,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,mBAAmB,CAAA;CAC5B,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,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,MAAM,EAAE,EAAE,eAAe;IAmD/C,KAAK,IAAI,WAAW;IAQpB,SAAS,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,aAAa;;;;;;IAsE9D,aAAa,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,iBAAiB,GAAG,IAAI;IAM9D,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IA2BvD,IAAI,SAAS,IAAI,OAAO,GAAG,UAAU,GAAG,QAAQ,CAE/C;IAED,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAI9C,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAG/C;AAeD,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;AAUD,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,UAAU,EACX,EAAE,iBAAiB,GAAG,MAAM,CAE5B"}
|
|
@@ -44,24 +44,30 @@ export class CoreContext {
|
|
|
44
44
|
if (__classPrivateFieldGet(this, _CoreContext_phase, "f").type !== 'parse') {
|
|
45
45
|
throw new Error(`Expected 'parse' phase, got '${__classPrivateFieldGet(this, _CoreContext_phase, "f").type}'`);
|
|
46
46
|
}
|
|
47
|
+
const callback = (generatorKey) => {
|
|
48
|
+
if (__classPrivateFieldGet(this, _CoreContext_phase, "f").type === 'render') {
|
|
49
|
+
__classPrivateFieldGet(this, _CoreContext_phase, "f").context.addGeneratorKey({ generatorKey });
|
|
50
|
+
}
|
|
51
|
+
};
|
|
47
52
|
const schemaModel = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
48
53
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
49
54
|
schemaModel,
|
|
50
55
|
settings,
|
|
51
|
-
generatorsMap
|
|
56
|
+
generatorsMap,
|
|
57
|
+
callback
|
|
52
58
|
}), "f");
|
|
53
|
-
__classPrivateFieldGet(this, _CoreContext_phase, "f").context.generate(
|
|
54
|
-
this.logger.debug(`${
|
|
59
|
+
const files = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.generate(generatorsMap);
|
|
60
|
+
this.logger.debug(`${files.size} files generated`);
|
|
55
61
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupRenderPhase).call(this, {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
pinnableGenerators: Object.values(this.generatorsMap)
|
|
62
|
+
files,
|
|
63
|
+
pinnableGenerators: Object.values(generatorsMap)
|
|
59
64
|
.map(({ id, pinnable }) => (pinnable ? id : null))
|
|
60
65
|
.filter(generatorId => generatorId !== null),
|
|
61
66
|
prettier,
|
|
62
|
-
settings
|
|
67
|
+
basePath: settings?.basePath
|
|
63
68
|
}), "f");
|
|
64
|
-
const renderOutput = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.render(
|
|
69
|
+
const renderOutput = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.render();
|
|
70
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('render');
|
|
65
71
|
return {
|
|
66
72
|
...renderOutput,
|
|
67
73
|
results: __classPrivateFieldGet(this, _CoreContext_results, "f")
|
|
@@ -87,192 +93,6 @@ export class CoreContext {
|
|
|
87
93
|
removeStackTrailChunk(chunk) {
|
|
88
94
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove(chunk);
|
|
89
95
|
}
|
|
90
|
-
register({ destinationPath, ...args }) {
|
|
91
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
92
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
93
|
-
return context.register({ destinationPath, ...args });
|
|
94
|
-
})
|
|
95
|
-
.with({ type: 'parse' }, () => {
|
|
96
|
-
throw new Error(`Cannot register during parse phase`);
|
|
97
|
-
})
|
|
98
|
-
.with({ type: 'render' }, () => {
|
|
99
|
-
throw new Error(`Cannot register during render phase`);
|
|
100
|
-
})
|
|
101
|
-
.exhaustive();
|
|
102
|
-
}
|
|
103
|
-
addGeneratorKey({ generatorKey }) {
|
|
104
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
105
|
-
.with({ type: 'generate' }, () => {
|
|
106
|
-
this.logger.info('trying to add generator key during generate phase');
|
|
107
|
-
})
|
|
108
|
-
.with({ type: 'parse' }, () => {
|
|
109
|
-
throw new Error(`Cannot add generator key during parse phase`);
|
|
110
|
-
})
|
|
111
|
-
.with({ type: 'render' }, ({ context }) => {
|
|
112
|
-
return context.addGeneratorKey({ generatorKey });
|
|
113
|
-
})
|
|
114
|
-
.exhaustive();
|
|
115
|
-
}
|
|
116
|
-
resolveSchemaRefOnce(refName) {
|
|
117
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
118
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
119
|
-
return context.resolveSchemaRefOnce(refName);
|
|
120
|
-
})
|
|
121
|
-
.with({ type: 'parse' }, () => {
|
|
122
|
-
throw new Error(`Cannot resolve schema during parse phase`);
|
|
123
|
-
})
|
|
124
|
-
.with({ type: 'render' }, () => {
|
|
125
|
-
throw new Error(`Cannot resolve schema during render phase`);
|
|
126
|
-
})
|
|
127
|
-
.exhaustive();
|
|
128
|
-
}
|
|
129
|
-
addRenderDependency(args) {
|
|
130
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
131
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
132
|
-
return context.addRenderDependency(args);
|
|
133
|
-
})
|
|
134
|
-
.with({ type: 'parse' }, () => {
|
|
135
|
-
throw new Error(`Cannot add render dependency during parse phase`);
|
|
136
|
-
})
|
|
137
|
-
.with({ type: 'render' }, () => {
|
|
138
|
-
throw new Error(`Cannot add render dependency during render phase`);
|
|
139
|
-
})
|
|
140
|
-
.exhaustive();
|
|
141
|
-
}
|
|
142
|
-
getFile(filePath) {
|
|
143
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
144
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
145
|
-
return context.getFile(filePath);
|
|
146
|
-
})
|
|
147
|
-
.with({ type: 'parse' }, () => {
|
|
148
|
-
throw new Error(`Cannot get file during parse phase`);
|
|
149
|
-
})
|
|
150
|
-
.with({ type: 'render' }, () => {
|
|
151
|
-
throw new Error(`Cannot get file during render phase`);
|
|
152
|
-
})
|
|
153
|
-
.exhaustive();
|
|
154
|
-
}
|
|
155
|
-
findDefinition(args) {
|
|
156
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
157
|
-
.with({ type: 'generate' }, ({ context }) => context.findDefinition(args))
|
|
158
|
-
.with({ type: 'parse' }, () => {
|
|
159
|
-
throw new Error(`Cannot pick during parse phase`);
|
|
160
|
-
})
|
|
161
|
-
.with({ type: 'render' }, ({ context }) => context.pick(args))
|
|
162
|
-
.exhaustive();
|
|
163
|
-
}
|
|
164
|
-
addFile(normalisedPath) {
|
|
165
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
166
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
167
|
-
return context.addFile(normalisedPath);
|
|
168
|
-
})
|
|
169
|
-
.with({ type: 'parse' }, () => {
|
|
170
|
-
throw new Error(`Cannot add file during parse phase`);
|
|
171
|
-
})
|
|
172
|
-
.with({ type: 'render' }, () => {
|
|
173
|
-
throw new Error(`Cannot add file during render phase`);
|
|
174
|
-
})
|
|
175
|
-
.exhaustive();
|
|
176
|
-
}
|
|
177
|
-
getOperationBaseSettings(args) {
|
|
178
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
179
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
180
|
-
return context.getOperationBaseSettings(args);
|
|
181
|
-
})
|
|
182
|
-
.with({ type: 'parse' }, () => {
|
|
183
|
-
throw new Error(`Cannot access operation settings during parse phase`);
|
|
184
|
-
})
|
|
185
|
-
.with({ type: 'render' }, () => {
|
|
186
|
-
throw new Error(`Cannot access operation settings during render phase`);
|
|
187
|
-
})
|
|
188
|
-
.exhaustive();
|
|
189
|
-
}
|
|
190
|
-
insert(args) {
|
|
191
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
192
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
193
|
-
return context.insert({ ...args, coreContext: this });
|
|
194
|
-
})
|
|
195
|
-
.with({ type: 'parse' }, () => {
|
|
196
|
-
throw new Error(`Cannot run 'transform' during parse phase`);
|
|
197
|
-
})
|
|
198
|
-
.with({ type: 'render' }, () => {
|
|
199
|
-
throw new Error(`Cannot run 'transform' during render phase`);
|
|
200
|
-
})
|
|
201
|
-
.exhaustive();
|
|
202
|
-
}
|
|
203
|
-
getModelBaseSettings(args) {
|
|
204
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
205
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
206
|
-
return context.getModelBaseSettings(args);
|
|
207
|
-
})
|
|
208
|
-
.with({ type: 'parse' }, () => {
|
|
209
|
-
throw new Error(`Cannot access model settings during parse phase`);
|
|
210
|
-
})
|
|
211
|
-
.with({ type: 'render' }, () => {
|
|
212
|
-
throw new Error(`Cannot access model settings during render phase`);
|
|
213
|
-
})
|
|
214
|
-
.exhaustive();
|
|
215
|
-
}
|
|
216
|
-
get files() {
|
|
217
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
218
|
-
.with({ type: 'generate' }, ({ context }) => context.files)
|
|
219
|
-
.with({ type: 'parse' }, () => {
|
|
220
|
-
throw new Error(`Cannot access files during parse phase`);
|
|
221
|
-
})
|
|
222
|
-
.with({ type: 'render' }, ({ context }) => context.files)
|
|
223
|
-
.exhaustive();
|
|
224
|
-
}
|
|
225
|
-
get renderDependencies() {
|
|
226
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
227
|
-
.with({ type: 'generate' }, ({ context }) => context.renderDependencies)
|
|
228
|
-
.with({ type: 'parse' }, () => {
|
|
229
|
-
throw new Error(`Cannot access files during parse phase`);
|
|
230
|
-
})
|
|
231
|
-
.with({ type: 'render' }, ({ context }) => context.renderDependencies)
|
|
232
|
-
.exhaustive();
|
|
233
|
-
}
|
|
234
|
-
get packageDependencies() {
|
|
235
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
236
|
-
.with({ type: 'generate' }, ({ context }) => context.packageDependencies)
|
|
237
|
-
.with({ type: 'parse' }, () => {
|
|
238
|
-
throw new Error(`Cannot access package dependencies during parse phase`);
|
|
239
|
-
})
|
|
240
|
-
.with({ type: 'render' }, ({ context }) => context.packageDependencies)
|
|
241
|
-
.exhaustive();
|
|
242
|
-
}
|
|
243
|
-
get schemaModel() {
|
|
244
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
245
|
-
.with({ type: 'generate' }, ({ context }) => context.schemaModel)
|
|
246
|
-
.with({ type: 'parse' }, () => {
|
|
247
|
-
throw new Error(`Cannot access schema model during parse phase`);
|
|
248
|
-
})
|
|
249
|
-
.with({ type: 'render' }, () => {
|
|
250
|
-
throw new Error(`Cannot access schema model during render phase`);
|
|
251
|
-
})
|
|
252
|
-
.exhaustive();
|
|
253
|
-
}
|
|
254
|
-
get generatorsMap() {
|
|
255
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
256
|
-
.with({ type: 'generate' }, ({ context }) => context.generatorsMap)
|
|
257
|
-
.with({ type: 'parse' }, () => {
|
|
258
|
-
throw new Error(`Cannot access schema model during parse phase`);
|
|
259
|
-
})
|
|
260
|
-
.with({ type: 'render' }, () => {
|
|
261
|
-
throw new Error(`Cannot access schema model during render phase`);
|
|
262
|
-
})
|
|
263
|
-
.exhaustive();
|
|
264
|
-
}
|
|
265
|
-
get settings() {
|
|
266
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
267
|
-
.with({ type: 'generate' }, ({ context }) => context.settings)
|
|
268
|
-
.with({ type: 'parse' }, () => {
|
|
269
|
-
throw new Error(`Cannot access settings during parse phase`);
|
|
270
|
-
})
|
|
271
|
-
.with({ type: 'render' }, () => {
|
|
272
|
-
throw new Error(`Cannot access settings during render phase`);
|
|
273
|
-
})
|
|
274
|
-
.exhaustive();
|
|
275
|
-
}
|
|
276
96
|
}
|
|
277
97
|
_CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_stackTrail = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger(spanId) {
|
|
278
98
|
log.setup({
|
|
@@ -308,22 +128,27 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
308
128
|
.exhaustive();
|
|
309
129
|
return StackTrail.join(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f"), substack);
|
|
310
130
|
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(schema) {
|
|
131
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('parse');
|
|
311
132
|
const parseContext = new ParseContext({ schema, logger: this.logger });
|
|
312
133
|
return { type: 'parse', context: parseContext };
|
|
313
|
-
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ schemaModel, settings, generatorsMap }) {
|
|
134
|
+
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ schemaModel, settings, generatorsMap, callback }) {
|
|
135
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('parse');
|
|
136
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('generate');
|
|
314
137
|
const generateContext = new GenerateContext({
|
|
315
138
|
schemaModel,
|
|
316
139
|
settings,
|
|
317
|
-
generatorsMap
|
|
140
|
+
generatorsMap,
|
|
141
|
+
logger: this.logger,
|
|
142
|
+
callback
|
|
318
143
|
});
|
|
319
144
|
return { type: 'generate', context: generateContext };
|
|
320
|
-
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({
|
|
145
|
+
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({ files, prettier, basePath, pinnableGenerators }) {
|
|
146
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('generate');
|
|
147
|
+
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('render');
|
|
321
148
|
const renderContext = new RenderContext({
|
|
322
|
-
files
|
|
323
|
-
renderDependencies,
|
|
324
|
-
packageDependencies,
|
|
149
|
+
files,
|
|
325
150
|
prettier,
|
|
326
|
-
|
|
151
|
+
basePath,
|
|
327
152
|
pinnableGenerators
|
|
328
153
|
});
|
|
329
154
|
return { type: 'render', context: renderContext };
|
|
@@ -3,21 +3,23 @@ import type { 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, GetFileOptions
|
|
6
|
+
import type { FileContents, GetFileOptions } from './types.js';
|
|
7
7
|
import type { BaseSettings, ClientSettings } from '../types/Settings.js';
|
|
8
8
|
import type { Method } from '../types/Method.js';
|
|
9
9
|
import type { OperationInsertable, OperationGenerator } from '../dsl/OperationInsertable.js';
|
|
10
10
|
import type { OasOperation } from '../oas/operation/Operation.js';
|
|
11
|
-
import type { CoreContext } from './CoreContext.js';
|
|
12
11
|
import type { ModelInsertable, ModelGenerator } from '../dsl/ModelInsertable.js';
|
|
13
12
|
import type { GenerationType, GeneratedDefintion, GeneratedValue } from '../types/GeneratedValue.js';
|
|
14
13
|
import type { ContentSettings } from '../dsl/ContentSettings.js';
|
|
15
14
|
import type { RefName } from '../types/RefName.js';
|
|
16
|
-
import
|
|
15
|
+
import type * as log from '../deps/jsr.io/@std/log/0.224.6/mod.js';
|
|
16
|
+
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
17
17
|
type ConstructorArgs = {
|
|
18
18
|
schemaModel: OasDocument;
|
|
19
19
|
settings: ClientSettings | undefined;
|
|
20
20
|
generatorsMap: Record<string, OperationGenerator | ModelGenerator>;
|
|
21
|
+
logger: log.Logger;
|
|
22
|
+
callback: (generatorKey: GeneratorKey) => void;
|
|
21
23
|
};
|
|
22
24
|
export type PickArgs = {
|
|
23
25
|
name: string;
|
|
@@ -25,7 +27,6 @@ export type PickArgs = {
|
|
|
25
27
|
};
|
|
26
28
|
export type RegisterArgs = {
|
|
27
29
|
imports?: Record<string, ImportNameArg[]>;
|
|
28
|
-
packageDependencies?: Record<string, string>;
|
|
29
30
|
definitions?: (Definition | undefined)[];
|
|
30
31
|
destinationPath: string;
|
|
31
32
|
};
|
|
@@ -60,27 +61,22 @@ export type InsertReturn<V extends GeneratedValue, T extends GenerationType> = {
|
|
|
60
61
|
};
|
|
61
62
|
export declare class GenerateContext {
|
|
62
63
|
#private;
|
|
63
|
-
files: Map<string, FileContents>;
|
|
64
|
-
renderDependencies: RenderDependencies;
|
|
65
|
-
packageDependencies: Map<string, string>;
|
|
66
64
|
schemaModel: OasDocument;
|
|
67
65
|
settings: ClientSettings | undefined;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
constructor({ schemaModel,
|
|
71
|
-
generate(
|
|
66
|
+
logger: log.Logger;
|
|
67
|
+
callback: (generatorKey: GeneratorKey) => void;
|
|
68
|
+
constructor({ schemaModel, settings, logger, callback }: ConstructorArgs);
|
|
69
|
+
generate(generatorsMap: Record<string, OperationGenerator | ModelGenerator>): Map<string, FileContents>;
|
|
72
70
|
appendStackTrailChunk(chunk: string | string[]): void;
|
|
73
71
|
removeStackTrailChunk(chunk: string | string[]): void;
|
|
72
|
+
get stackTrail(): string;
|
|
74
73
|
getFile(filePath: string, { throwIfNotFound }?: GetFileOptions): FileContents;
|
|
75
|
-
register({ imports,
|
|
76
|
-
insert<V extends GeneratedValue, T extends GenerationType>({
|
|
77
|
-
coreContext: CoreContext;
|
|
78
|
-
}): InsertReturn<V, T>;
|
|
74
|
+
register({ imports, definitions, destinationPath }: RegisterArgs): void;
|
|
75
|
+
insert<V extends GeneratedValue, T extends GenerationType>({ generation, destinationPath, ...rest }: InsertArgs<V, T>): InsertReturn<V, T>;
|
|
79
76
|
getOperationBaseSettings({ generatorId, path, method }: GetOperationSettingsArgs): BaseSettings;
|
|
80
77
|
getModelBaseSettings({ generatorId, refName }: GetModelSettingsArgs): BaseSettings;
|
|
81
78
|
addFile(normalisedPath: string): FileContents;
|
|
82
79
|
resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
83
|
-
addRenderDependency({ generatorId, dependencies, operation }: AddRenderDependencyArgs): void;
|
|
84
80
|
/** Produce external instance and return its name */
|
|
85
81
|
findDefinition({ name, exportPath }: PickArgs): Definition | undefined;
|
|
86
82
|
}
|
|
@@ -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,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA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