@skmtc/core 0.0.307 → 0.0.309
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 +20 -201
- package/esm/context/GenerateContext.d.ts +11 -14
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +48 -64
- package/esm/context/RenderContext.d.ts +5 -11
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +7 -38
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/context/ResultsHandler.js +0 -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/mod.d.ts +1 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -0
- 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 +20 -201
- package/script/context/GenerateContext.d.ts +11 -14
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +48 -64
- package/script/context/RenderContext.d.ts +5 -11
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +7 -38
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/context/ResultsHandler.js +0 -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/mod.d.ts +1 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -0
- 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,29 @@ 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();
|
|
65
70
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('render');
|
|
66
71
|
return {
|
|
67
72
|
...renderOutput,
|
|
@@ -88,192 +93,6 @@ export class CoreContext {
|
|
|
88
93
|
removeStackTrailChunk(chunk) {
|
|
89
94
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove(chunk);
|
|
90
95
|
}
|
|
91
|
-
register({ destinationPath, ...args }) {
|
|
92
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
93
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
94
|
-
return context.register({ destinationPath, ...args });
|
|
95
|
-
})
|
|
96
|
-
.with({ type: 'parse' }, () => {
|
|
97
|
-
throw new Error(`Cannot register during parse phase`);
|
|
98
|
-
})
|
|
99
|
-
.with({ type: 'render' }, () => {
|
|
100
|
-
throw new Error(`Cannot register during render phase`);
|
|
101
|
-
})
|
|
102
|
-
.exhaustive();
|
|
103
|
-
}
|
|
104
|
-
addGeneratorKey({ generatorKey }) {
|
|
105
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
106
|
-
.with({ type: 'generate' }, () => {
|
|
107
|
-
this.logger.info('trying to add generator key during generate phase');
|
|
108
|
-
})
|
|
109
|
-
.with({ type: 'parse' }, () => {
|
|
110
|
-
throw new Error(`Cannot add generator key during parse phase`);
|
|
111
|
-
})
|
|
112
|
-
.with({ type: 'render' }, ({ context }) => {
|
|
113
|
-
return context.addGeneratorKey({ generatorKey });
|
|
114
|
-
})
|
|
115
|
-
.exhaustive();
|
|
116
|
-
}
|
|
117
|
-
resolveSchemaRefOnce(refName) {
|
|
118
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
119
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
120
|
-
return context.resolveSchemaRefOnce(refName);
|
|
121
|
-
})
|
|
122
|
-
.with({ type: 'parse' }, () => {
|
|
123
|
-
throw new Error(`Cannot resolve schema during parse phase`);
|
|
124
|
-
})
|
|
125
|
-
.with({ type: 'render' }, () => {
|
|
126
|
-
throw new Error(`Cannot resolve schema during render phase`);
|
|
127
|
-
})
|
|
128
|
-
.exhaustive();
|
|
129
|
-
}
|
|
130
|
-
addRenderDependency(args) {
|
|
131
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
132
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
133
|
-
return context.addRenderDependency(args);
|
|
134
|
-
})
|
|
135
|
-
.with({ type: 'parse' }, () => {
|
|
136
|
-
throw new Error(`Cannot add render dependency during parse phase`);
|
|
137
|
-
})
|
|
138
|
-
.with({ type: 'render' }, () => {
|
|
139
|
-
throw new Error(`Cannot add render dependency during render phase`);
|
|
140
|
-
})
|
|
141
|
-
.exhaustive();
|
|
142
|
-
}
|
|
143
|
-
getFile(filePath) {
|
|
144
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
145
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
146
|
-
return context.getFile(filePath);
|
|
147
|
-
})
|
|
148
|
-
.with({ type: 'parse' }, () => {
|
|
149
|
-
throw new Error(`Cannot get file during parse phase`);
|
|
150
|
-
})
|
|
151
|
-
.with({ type: 'render' }, () => {
|
|
152
|
-
throw new Error(`Cannot get file during render phase`);
|
|
153
|
-
})
|
|
154
|
-
.exhaustive();
|
|
155
|
-
}
|
|
156
|
-
findDefinition(args) {
|
|
157
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
158
|
-
.with({ type: 'generate' }, ({ context }) => context.findDefinition(args))
|
|
159
|
-
.with({ type: 'parse' }, () => {
|
|
160
|
-
throw new Error(`Cannot pick during parse phase`);
|
|
161
|
-
})
|
|
162
|
-
.with({ type: 'render' }, ({ context }) => context.pick(args))
|
|
163
|
-
.exhaustive();
|
|
164
|
-
}
|
|
165
|
-
addFile(normalisedPath) {
|
|
166
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
167
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
168
|
-
return context.addFile(normalisedPath);
|
|
169
|
-
})
|
|
170
|
-
.with({ type: 'parse' }, () => {
|
|
171
|
-
throw new Error(`Cannot add file during parse phase`);
|
|
172
|
-
})
|
|
173
|
-
.with({ type: 'render' }, () => {
|
|
174
|
-
throw new Error(`Cannot add file during render phase`);
|
|
175
|
-
})
|
|
176
|
-
.exhaustive();
|
|
177
|
-
}
|
|
178
|
-
getOperationBaseSettings(args) {
|
|
179
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
180
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
181
|
-
return context.getOperationBaseSettings(args);
|
|
182
|
-
})
|
|
183
|
-
.with({ type: 'parse' }, () => {
|
|
184
|
-
throw new Error(`Cannot access operation settings during parse phase`);
|
|
185
|
-
})
|
|
186
|
-
.with({ type: 'render' }, () => {
|
|
187
|
-
throw new Error(`Cannot access operation settings during render phase`);
|
|
188
|
-
})
|
|
189
|
-
.exhaustive();
|
|
190
|
-
}
|
|
191
|
-
insert(args) {
|
|
192
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
193
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
194
|
-
return context.insert({ ...args, coreContext: this });
|
|
195
|
-
})
|
|
196
|
-
.with({ type: 'parse' }, () => {
|
|
197
|
-
throw new Error(`Cannot run 'transform' during parse phase`);
|
|
198
|
-
})
|
|
199
|
-
.with({ type: 'render' }, () => {
|
|
200
|
-
throw new Error(`Cannot run 'transform' during render phase`);
|
|
201
|
-
})
|
|
202
|
-
.exhaustive();
|
|
203
|
-
}
|
|
204
|
-
getModelBaseSettings(args) {
|
|
205
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
206
|
-
.with({ type: 'generate' }, ({ context }) => {
|
|
207
|
-
return context.getModelBaseSettings(args);
|
|
208
|
-
})
|
|
209
|
-
.with({ type: 'parse' }, () => {
|
|
210
|
-
throw new Error(`Cannot access model settings during parse phase`);
|
|
211
|
-
})
|
|
212
|
-
.with({ type: 'render' }, () => {
|
|
213
|
-
throw new Error(`Cannot access model settings during render phase`);
|
|
214
|
-
})
|
|
215
|
-
.exhaustive();
|
|
216
|
-
}
|
|
217
|
-
get files() {
|
|
218
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
219
|
-
.with({ type: 'generate' }, ({ context }) => context.files)
|
|
220
|
-
.with({ type: 'parse' }, () => {
|
|
221
|
-
throw new Error(`Cannot access files during parse phase`);
|
|
222
|
-
})
|
|
223
|
-
.with({ type: 'render' }, ({ context }) => context.files)
|
|
224
|
-
.exhaustive();
|
|
225
|
-
}
|
|
226
|
-
get renderDependencies() {
|
|
227
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
228
|
-
.with({ type: 'generate' }, ({ context }) => context.renderDependencies)
|
|
229
|
-
.with({ type: 'parse' }, () => {
|
|
230
|
-
throw new Error(`Cannot access files during parse phase`);
|
|
231
|
-
})
|
|
232
|
-
.with({ type: 'render' }, ({ context }) => context.renderDependencies)
|
|
233
|
-
.exhaustive();
|
|
234
|
-
}
|
|
235
|
-
get packageDependencies() {
|
|
236
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
237
|
-
.with({ type: 'generate' }, ({ context }) => context.packageDependencies)
|
|
238
|
-
.with({ type: 'parse' }, () => {
|
|
239
|
-
throw new Error(`Cannot access package dependencies during parse phase`);
|
|
240
|
-
})
|
|
241
|
-
.with({ type: 'render' }, ({ context }) => context.packageDependencies)
|
|
242
|
-
.exhaustive();
|
|
243
|
-
}
|
|
244
|
-
get schemaModel() {
|
|
245
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
246
|
-
.with({ type: 'generate' }, ({ context }) => context.schemaModel)
|
|
247
|
-
.with({ type: 'parse' }, () => {
|
|
248
|
-
throw new Error(`Cannot access schema model during parse phase`);
|
|
249
|
-
})
|
|
250
|
-
.with({ type: 'render' }, () => {
|
|
251
|
-
throw new Error(`Cannot access schema model during render phase`);
|
|
252
|
-
})
|
|
253
|
-
.exhaustive();
|
|
254
|
-
}
|
|
255
|
-
get generatorsMap() {
|
|
256
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
257
|
-
.with({ type: 'generate' }, ({ context }) => context.generatorsMap)
|
|
258
|
-
.with({ type: 'parse' }, () => {
|
|
259
|
-
throw new Error(`Cannot access schema model during parse phase`);
|
|
260
|
-
})
|
|
261
|
-
.with({ type: 'render' }, () => {
|
|
262
|
-
throw new Error(`Cannot access schema model during render phase`);
|
|
263
|
-
})
|
|
264
|
-
.exhaustive();
|
|
265
|
-
}
|
|
266
|
-
get settings() {
|
|
267
|
-
return match(__classPrivateFieldGet(this, _CoreContext_phase, "f"))
|
|
268
|
-
.with({ type: 'generate' }, ({ context }) => context.settings)
|
|
269
|
-
.with({ type: 'parse' }, () => {
|
|
270
|
-
throw new Error(`Cannot access settings during parse phase`);
|
|
271
|
-
})
|
|
272
|
-
.with({ type: 'render' }, () => {
|
|
273
|
-
throw new Error(`Cannot access settings during render phase`);
|
|
274
|
-
})
|
|
275
|
-
.exhaustive();
|
|
276
|
-
}
|
|
277
96
|
}
|
|
278
97
|
_CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreContext_stackTrail = new WeakMap(), _CoreContext_instances = new WeakSet(), _CoreContext_setupLogger = function _CoreContext_setupLogger(spanId) {
|
|
279
98
|
log.setup({
|
|
@@ -312,24 +131,24 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
312
131
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('parse');
|
|
313
132
|
const parseContext = new ParseContext({ schema, logger: this.logger });
|
|
314
133
|
return { type: 'parse', context: parseContext };
|
|
315
|
-
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ schemaModel, settings, generatorsMap }) {
|
|
134
|
+
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ schemaModel, settings, generatorsMap, callback }) {
|
|
316
135
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('parse');
|
|
317
136
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('generate');
|
|
318
137
|
const generateContext = new GenerateContext({
|
|
319
138
|
schemaModel,
|
|
320
139
|
settings,
|
|
321
|
-
generatorsMap
|
|
140
|
+
generatorsMap,
|
|
141
|
+
logger: this.logger,
|
|
142
|
+
callback
|
|
322
143
|
});
|
|
323
144
|
return { type: 'generate', context: generateContext };
|
|
324
|
-
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({
|
|
145
|
+
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({ files, prettier, basePath, pinnableGenerators }) {
|
|
325
146
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").remove('generate');
|
|
326
147
|
__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").append('render');
|
|
327
148
|
const renderContext = new RenderContext({
|
|
328
|
-
files
|
|
329
|
-
renderDependencies,
|
|
330
|
-
packageDependencies,
|
|
149
|
+
files,
|
|
331
150
|
prettier,
|
|
332
|
-
|
|
151
|
+
basePath,
|
|
333
152
|
pinnableGenerators
|
|
334
153
|
});
|
|
335
154
|
return { type: 'render', context: renderContext };
|
|
@@ -3,20 +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';
|
|
15
|
+
import type * as log from '../deps/jsr.io/@std/log/0.224.6/mod.js';
|
|
16
|
+
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
16
17
|
type ConstructorArgs = {
|
|
17
18
|
schemaModel: OasDocument;
|
|
18
19
|
settings: ClientSettings | undefined;
|
|
19
20
|
generatorsMap: Record<string, OperationGenerator | ModelGenerator>;
|
|
21
|
+
logger: log.Logger;
|
|
22
|
+
callback: (generatorKey: GeneratorKey) => void;
|
|
20
23
|
};
|
|
21
24
|
export type PickArgs = {
|
|
22
25
|
name: string;
|
|
@@ -24,7 +27,6 @@ export type PickArgs = {
|
|
|
24
27
|
};
|
|
25
28
|
export type RegisterArgs = {
|
|
26
29
|
imports?: Record<string, ImportNameArg[]>;
|
|
27
|
-
packageDependencies?: Record<string, string>;
|
|
28
30
|
definitions?: (Definition | undefined)[];
|
|
29
31
|
destinationPath: string;
|
|
30
32
|
};
|
|
@@ -59,27 +61,22 @@ export type InsertReturn<V extends GeneratedValue, T extends GenerationType> = {
|
|
|
59
61
|
};
|
|
60
62
|
export declare class GenerateContext {
|
|
61
63
|
#private;
|
|
62
|
-
files: Map<string, FileContents>;
|
|
63
|
-
renderDependencies: RenderDependencies;
|
|
64
|
-
packageDependencies: Map<string, string>;
|
|
65
64
|
schemaModel: OasDocument;
|
|
66
65
|
settings: ClientSettings | undefined;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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>;
|
|
70
70
|
appendStackTrailChunk(chunk: string | string[]): void;
|
|
71
71
|
removeStackTrailChunk(chunk: string | string[]): void;
|
|
72
72
|
get stackTrail(): string;
|
|
73
73
|
getFile(filePath: string, { throwIfNotFound }?: GetFileOptions): FileContents;
|
|
74
|
-
register({ imports,
|
|
75
|
-
insert<V extends GeneratedValue, T extends GenerationType>({
|
|
76
|
-
coreContext: CoreContext;
|
|
77
|
-
}): 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>;
|
|
78
76
|
getOperationBaseSettings({ generatorId, path, method }: GetOperationSettingsArgs): BaseSettings;
|
|
79
77
|
getModelBaseSettings({ generatorId, refName }: GetModelSettingsArgs): BaseSettings;
|
|
80
78
|
addFile(normalisedPath: string): FileContents;
|
|
81
79
|
resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
82
|
-
addRenderDependency({ generatorId, dependencies, operation }: AddRenderDependencyArgs): void;
|
|
83
80
|
/** Produce external instance and return its name */
|
|
84
81
|
findDefinition({ name, exportPath }: PickArgs): Definition | undefined;
|
|
85
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;AAC/C,OAAO,KAAK,
|
|
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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