@skmtc/core 0.0.666 → 0.0.668
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 +0 -2
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +2 -5
- package/esm/context/GenerateContext.d.ts +12 -11
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +30 -38
- package/esm/context/RenderContext.d.ts +1 -4
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +2 -10
- package/esm/context/types.d.ts +0 -2
- package/esm/context/types.d.ts.map +1 -1
- package/esm/dsl/model/ModelBase.d.ts.map +1 -1
- package/esm/dsl/model/ModelBase.js +0 -15
- package/esm/dsl/model/toModelEntry.d.ts +5 -5
- package/esm/dsl/model/toModelEntry.d.ts.map +1 -1
- package/esm/dsl/model/toModelEntry.js +2 -2
- package/esm/dsl/model/types.d.ts +6 -2
- package/esm/dsl/model/types.d.ts.map +1 -1
- package/esm/dsl/operation/OperationBase.d.ts +1 -1
- package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
- package/esm/dsl/operation/OperationBase.js +0 -16
- package/esm/dsl/operation/toOperationEntry.d.ts +5 -5
- package/esm/dsl/operation/toOperationEntry.d.ts.map +1 -1
- package/esm/dsl/operation/toOperationEntry.js +2 -2
- package/esm/dsl/operation/types.d.ts +6 -2
- package/esm/dsl/operation/types.d.ts.map +1 -1
- package/esm/mod.d.ts +0 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +0 -1
- package/esm/run/toArtifacts.d.ts.map +1 -1
- package/esm/run/toArtifacts.js +1 -8
- package/esm/types/DenoJson.d.ts +12 -0
- package/esm/types/DenoJson.d.ts.map +1 -1
- package/esm/types/DenoJson.js +6 -0
- package/esm/types/Manifest.d.ts +5 -14
- package/esm/types/Manifest.d.ts.map +1 -1
- package/esm/types/Manifest.js +1 -3
- package/esm/types/Preview.d.ts +21 -9
- package/esm/types/Preview.d.ts.map +1 -1
- package/esm/types/Preview.js +9 -5
- package/package.json +1 -5
- package/script/context/CoreContext.d.ts +0 -2
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +2 -5
- package/script/context/GenerateContext.d.ts +12 -11
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +33 -39
- package/script/context/RenderContext.d.ts +1 -4
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +2 -10
- package/script/context/types.d.ts +0 -2
- package/script/context/types.d.ts.map +1 -1
- package/script/dsl/model/ModelBase.d.ts.map +1 -1
- package/script/dsl/model/ModelBase.js +0 -15
- package/script/dsl/model/toModelEntry.d.ts +5 -5
- package/script/dsl/model/toModelEntry.d.ts.map +1 -1
- package/script/dsl/model/toModelEntry.js +2 -2
- package/script/dsl/model/types.d.ts +6 -2
- package/script/dsl/model/types.d.ts.map +1 -1
- package/script/dsl/operation/OperationBase.d.ts +1 -1
- package/script/dsl/operation/OperationBase.d.ts.map +1 -1
- package/script/dsl/operation/OperationBase.js +0 -16
- package/script/dsl/operation/toOperationEntry.d.ts +5 -5
- package/script/dsl/operation/toOperationEntry.d.ts.map +1 -1
- package/script/dsl/operation/toOperationEntry.js +2 -2
- package/script/dsl/operation/types.d.ts +6 -2
- package/script/dsl/operation/types.d.ts.map +1 -1
- package/script/mod.d.ts +0 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +0 -1
- package/script/run/toArtifacts.d.ts.map +1 -1
- package/script/run/toArtifacts.js +1 -8
- package/script/types/DenoJson.d.ts +12 -0
- package/script/types/DenoJson.d.ts.map +1 -1
- package/script/types/DenoJson.js +7 -1
- package/script/types/Manifest.d.ts +5 -14
- package/script/types/Manifest.d.ts.map +1 -1
- package/script/types/Manifest.js +1 -3
- package/script/types/Preview.d.ts +21 -9
- package/script/types/Preview.d.ts.map +1 -1
- package/script/types/Preview.js +10 -6
- package/esm/types/SchemaOptions.d.ts +0 -58
- package/esm/types/SchemaOptions.d.ts.map +0 -1
- package/esm/types/SchemaOptions.js +0 -45
- package/script/types/SchemaOptions.d.ts +0 -58
- package/script/types/SchemaOptions.d.ts.map +0 -1
- package/script/types/SchemaOptions.js +0 -71
|
@@ -9,7 +9,6 @@ import * as log from '../deps/jsr.io/@std/log/0.224.6/mod.js';
|
|
|
9
9
|
import type { GeneratorsMapContainer } from '../types/GeneratorType.js';
|
|
10
10
|
import type { Preview } from '../types/Preview.js';
|
|
11
11
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
12
|
-
import type { SchemaOption } from '../types/SchemaOptions.js';
|
|
13
12
|
export type ParsePhase = {
|
|
14
13
|
type: 'parse';
|
|
15
14
|
context: ParseContext;
|
|
@@ -54,7 +53,6 @@ export declare class CoreContext {
|
|
|
54
53
|
results: import("../types/Results.js").ResultsItem;
|
|
55
54
|
files: Record<string, import("../types/Manifest.js").ManifestEntry>;
|
|
56
55
|
previews: Record<string, Record<string, Preview>>;
|
|
57
|
-
schemaOptions: SchemaOption[];
|
|
58
56
|
artifacts: Record<string, string>;
|
|
59
57
|
}>;
|
|
60
58
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreContext.d.ts","sourceRoot":"","sources":["../../src/context/CoreContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAA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AE,MAAM,CAAC,GAAG,CAAC;IAgClD,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"}
|
|
@@ -78,7 +78,7 @@ export class CoreContext {
|
|
|
78
78
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, documentObject), "f");
|
|
79
79
|
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
80
80
|
});
|
|
81
|
-
const { files, previews
|
|
81
|
+
const { files, previews } = this.trace('generate', () => {
|
|
82
82
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
83
83
|
toGeneratorConfigMap,
|
|
84
84
|
oasDocument,
|
|
@@ -91,7 +91,6 @@ export class CoreContext {
|
|
|
91
91
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupRenderPhase).call(this, {
|
|
92
92
|
files,
|
|
93
93
|
previews,
|
|
94
|
-
schemaOptions,
|
|
95
94
|
prettier,
|
|
96
95
|
basePath: settings?.basePath
|
|
97
96
|
}), "f");
|
|
@@ -110,7 +109,6 @@ export class CoreContext {
|
|
|
110
109
|
artifacts: {},
|
|
111
110
|
files: {},
|
|
112
111
|
previews: {},
|
|
113
|
-
schemaOptions: [],
|
|
114
112
|
results: __classPrivateFieldGet(this, _CoreContext_results, "f").toTree()
|
|
115
113
|
};
|
|
116
114
|
}
|
|
@@ -183,11 +181,10 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
183
181
|
toGeneratorConfigMap
|
|
184
182
|
});
|
|
185
183
|
return { type: 'generate', context: generateContext };
|
|
186
|
-
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({ files, previews,
|
|
184
|
+
}, _CoreContext_setupRenderPhase = function _CoreContext_setupRenderPhase({ files, previews, prettier, basePath }) {
|
|
187
185
|
const renderContext = new RenderContext({
|
|
188
186
|
files,
|
|
189
187
|
previews,
|
|
190
|
-
schemaOptions,
|
|
191
188
|
prettierConfig: prettier,
|
|
192
189
|
basePath,
|
|
193
190
|
logger: this.logger,
|
|
@@ -20,8 +20,7 @@ import { Inserted } from '../dsl/Inserted.js';
|
|
|
20
20
|
import { File } from '../dsl/File.js';
|
|
21
21
|
import { JsonFile } from '../dsl/JsonFile.js';
|
|
22
22
|
import type { GeneratorsMapContainer } from '../types/GeneratorType.js';
|
|
23
|
-
import type { Preview } from '../types/Preview.js';
|
|
24
|
-
import type { SchemaOption } from '../types/SchemaOptions.js';
|
|
23
|
+
import type { OperationSource, ModelSource, Preview } from '../types/Preview.js';
|
|
25
24
|
type ConstructorArgs = {
|
|
26
25
|
oasDocument: OasDocument;
|
|
27
26
|
settings: ClientSettings | undefined;
|
|
@@ -46,18 +45,11 @@ export type BaseRegisterArgs = {
|
|
|
46
45
|
imports?: Record<string, ImportNameArg[]>;
|
|
47
46
|
reExports?: Record<string, Identifier[]>;
|
|
48
47
|
definitions?: (Definition | undefined)[];
|
|
49
|
-
preview?: {
|
|
50
|
-
[group: string]: Omit<Preview, 'group' | 'exportPath' | 'source'>;
|
|
51
|
-
};
|
|
52
48
|
};
|
|
53
49
|
export type RegisterArgs = {
|
|
54
50
|
imports?: Record<string, ImportNameArg[]>;
|
|
55
51
|
reExports?: Record<string, Identifier[]>;
|
|
56
52
|
definitions?: (Definition | undefined)[];
|
|
57
|
-
preview?: {
|
|
58
|
-
[group: string]: Omit<Preview, 'group' | 'exportPath'>;
|
|
59
|
-
};
|
|
60
|
-
schemaOptions?: Omit<SchemaOption, 'exportPath'>[];
|
|
61
53
|
destinationPath: string;
|
|
62
54
|
};
|
|
63
55
|
export type CreateAndRegisterDefinition<Schema extends SchemaType> = {
|
|
@@ -106,7 +98,6 @@ type BuildModelSettingsArgs<V, EnrichmentType = undefined> = {
|
|
|
106
98
|
type GenerateResult = {
|
|
107
99
|
files: Map<string, File | JsonFile>;
|
|
108
100
|
previews: Record<string, Record<string, Preview>>;
|
|
109
|
-
schemaOptions: SchemaOption[];
|
|
110
101
|
};
|
|
111
102
|
type ToSettingsArgs = {
|
|
112
103
|
defaultSelected: boolean;
|
|
@@ -164,7 +155,7 @@ export declare class GenerateContext {
|
|
|
164
155
|
*
|
|
165
156
|
* @mutates this.files
|
|
166
157
|
*/
|
|
167
|
-
register({ imports, definitions, destinationPath, reExports
|
|
158
|
+
register({ imports, definitions, destinationPath, reExports }: RegisterArgs): void;
|
|
168
159
|
/**
|
|
169
160
|
* Insert operation into the output file with path `destinationPath`.
|
|
170
161
|
*
|
|
@@ -239,5 +230,15 @@ export declare class GenerateContext {
|
|
|
239
230
|
*/
|
|
240
231
|
findDefinition({ name, exportPath }: PickArgs): Definition | undefined;
|
|
241
232
|
}
|
|
233
|
+
type ToOperationSourceArgs = {
|
|
234
|
+
operation: OasOperation;
|
|
235
|
+
generatorId: string;
|
|
236
|
+
};
|
|
237
|
+
export declare const toOperationSource: ({ operation, generatorId }: ToOperationSourceArgs) => OperationSource;
|
|
238
|
+
type ToModelSourceArgs = {
|
|
239
|
+
refName: RefName;
|
|
240
|
+
generatorId: string;
|
|
241
|
+
};
|
|
242
|
+
export declare const toModelSource: ({ refName, generatorId }: ToModelSourceArgs) => ModelSource;
|
|
242
243
|
export {};
|
|
243
244
|
//# sourceMappingURL=GenerateContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK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EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,aAAa,6BAA8B,iBAAiB,KAAG,WAI1E,CAAA"}
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
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
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_previews,
|
|
12
|
+
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_previews, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_addPreview, _GenerateContext_getFile, _GenerateContext_addFile;
|
|
13
13
|
import { normalize } from '../deps/jsr.io/@std/path/1.0.6/mod.js';
|
|
14
14
|
import { Import } from '../dsl/Import.js';
|
|
15
15
|
import { Definition } from '../dsl/Definition.js';
|
|
@@ -29,7 +29,6 @@ export class GenerateContext {
|
|
|
29
29
|
_GenerateContext_instances.add(this);
|
|
30
30
|
_GenerateContext_files.set(this, void 0);
|
|
31
31
|
_GenerateContext_previews.set(this, void 0);
|
|
32
|
-
_GenerateContext_schemaOptions.set(this, void 0);
|
|
33
32
|
Object.defineProperty(this, "oasDocument", {
|
|
34
33
|
enumerable: true,
|
|
35
34
|
configurable: true,
|
|
@@ -75,7 +74,6 @@ export class GenerateContext {
|
|
|
75
74
|
this.logger = logger;
|
|
76
75
|
__classPrivateFieldSet(this, _GenerateContext_files, new Map(), "f");
|
|
77
76
|
__classPrivateFieldSet(this, _GenerateContext_previews, {}, "f");
|
|
78
|
-
__classPrivateFieldSet(this, _GenerateContext_schemaOptions, [], "f");
|
|
79
77
|
this.oasDocument = oasDocument;
|
|
80
78
|
this.settings = settings;
|
|
81
79
|
this.stackTrail = stackTrail;
|
|
@@ -100,8 +98,7 @@ export class GenerateContext {
|
|
|
100
98
|
}));
|
|
101
99
|
return {
|
|
102
100
|
files: __classPrivateFieldGet(this, _GenerateContext_files, "f"),
|
|
103
|
-
previews: __classPrivateFieldGet(this, _GenerateContext_previews, "f")
|
|
104
|
-
schemaOptions: __classPrivateFieldGet(this, _GenerateContext_schemaOptions, "f")
|
|
101
|
+
previews: __classPrivateFieldGet(this, _GenerateContext_previews, "f")
|
|
105
102
|
};
|
|
106
103
|
}
|
|
107
104
|
toSettings({ defaultSelected }) {
|
|
@@ -254,7 +251,7 @@ export class GenerateContext {
|
|
|
254
251
|
*
|
|
255
252
|
* @mutates this.files
|
|
256
253
|
*/
|
|
257
|
-
register({ imports = {}, definitions, destinationPath, reExports
|
|
254
|
+
register({ imports = {}, definitions, destinationPath, reExports }) {
|
|
258
255
|
// TODO deduplicate import names and definition names against each other
|
|
259
256
|
const currentFile = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_getFile).call(this, destinationPath);
|
|
260
257
|
invariant(currentFile instanceof File, `File at "${destinationPath}" is not a "File" type`);
|
|
@@ -291,23 +288,6 @@ export class GenerateContext {
|
|
|
291
288
|
currentFile.definitions.set(name, definition);
|
|
292
289
|
}
|
|
293
290
|
});
|
|
294
|
-
schemaOptions?.forEach(schemaOption => {
|
|
295
|
-
const existingSchemaOption = __classPrivateFieldGet(this, _GenerateContext_schemaOptions, "f").find(({ name, exportPath }) => name === schemaOption.name && exportPath === destinationPath);
|
|
296
|
-
if (!existingSchemaOption) {
|
|
297
|
-
__classPrivateFieldGet(this, _GenerateContext_schemaOptions, "f").push({ ...schemaOption, exportPath: destinationPath });
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
Object.entries(preview ?? {}).forEach(([group, { name, source }]) => {
|
|
301
|
-
if (!__classPrivateFieldGet(this, _GenerateContext_previews, "f")[group]) {
|
|
302
|
-
__classPrivateFieldGet(this, _GenerateContext_previews, "f")[group] = {};
|
|
303
|
-
}
|
|
304
|
-
__classPrivateFieldGet(this, _GenerateContext_previews, "f")[group][name] = {
|
|
305
|
-
name,
|
|
306
|
-
exportPath: destinationPath,
|
|
307
|
-
group,
|
|
308
|
-
source
|
|
309
|
-
};
|
|
310
|
-
});
|
|
311
291
|
}
|
|
312
292
|
/**
|
|
313
293
|
* Insert operation into the output file with path `destinationPath`.
|
|
@@ -450,14 +430,7 @@ export class GenerateContext {
|
|
|
450
430
|
return file.definitions.get(name);
|
|
451
431
|
}
|
|
452
432
|
}
|
|
453
|
-
_GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(),
|
|
454
|
-
const schemaOptions = generatorConfig.toSchemaOptions?.() ?? [];
|
|
455
|
-
schemaOptions.forEach(schemaOption => {
|
|
456
|
-
const existingSchemaOption = __classPrivateFieldGet(this, _GenerateContext_schemaOptions, "f").find(({ name, exportPath }) => name === schemaOption.name && exportPath === schemaOption.exportPath);
|
|
457
|
-
if (!existingSchemaOption) {
|
|
458
|
-
__classPrivateFieldGet(this, _GenerateContext_schemaOptions, "f").push(schemaOption);
|
|
459
|
-
}
|
|
460
|
-
});
|
|
433
|
+
_GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_runOperationGenerator = function _GenerateContext_runOperationGenerator({ oasDocument, generatorConfig }) {
|
|
461
434
|
oasDocument.operations.reduce((acc, operation) => {
|
|
462
435
|
return this.trace([operation.path, operation.method], () => {
|
|
463
436
|
if (typeof generatorConfig?.isSupported === 'function' &&
|
|
@@ -475,6 +448,7 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
475
448
|
return acc;
|
|
476
449
|
}
|
|
477
450
|
try {
|
|
451
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addPreview).call(this, toOperationSource({ operation, generatorId: generatorConfig.id }), generatorConfig.toPreviewModule?.({ context: this, operation }));
|
|
478
452
|
const result = generatorConfig.transform({ context: this, operation, acc });
|
|
479
453
|
this.captureCurrentResult('success');
|
|
480
454
|
return result;
|
|
@@ -486,13 +460,6 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
486
460
|
});
|
|
487
461
|
}, undefined);
|
|
488
462
|
}, _GenerateContext_runModelGenerator = function _GenerateContext_runModelGenerator({ oasDocument, generatorConfig }) {
|
|
489
|
-
const schemaOptions = generatorConfig.toSchemaOptions?.() ?? [];
|
|
490
|
-
schemaOptions.forEach(schemaOption => {
|
|
491
|
-
const existingSchemaOption = __classPrivateFieldGet(this, _GenerateContext_schemaOptions, "f").find(({ name, exportPath }) => name === schemaOption.name && exportPath === schemaOption.exportPath);
|
|
492
|
-
if (!existingSchemaOption) {
|
|
493
|
-
__classPrivateFieldGet(this, _GenerateContext_schemaOptions, "f").push(schemaOption);
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
463
|
const refNames = oasDocument.components?.toSchemasRefNames() ?? [];
|
|
497
464
|
return refNames.reduce((acc, refName) => {
|
|
498
465
|
return this.trace(refName, () => {
|
|
@@ -515,6 +482,20 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
515
482
|
}
|
|
516
483
|
});
|
|
517
484
|
}, undefined);
|
|
485
|
+
}, _GenerateContext_addPreview = function _GenerateContext_addPreview(source, module) {
|
|
486
|
+
if (!module) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if (!__classPrivateFieldGet(this, _GenerateContext_previews, "f")[module.group]) {
|
|
490
|
+
__classPrivateFieldGet(this, _GenerateContext_previews, "f")[module.group] = {};
|
|
491
|
+
}
|
|
492
|
+
if (__classPrivateFieldGet(this, _GenerateContext_previews, "f")[module.group][module.name]) {
|
|
493
|
+
throw new Error(`Cannot override preview module "${module.name}" in group "${module.group}"`);
|
|
494
|
+
}
|
|
495
|
+
__classPrivateFieldGet(this, _GenerateContext_previews, "f")[module.group][module.name] = {
|
|
496
|
+
module,
|
|
497
|
+
source
|
|
498
|
+
};
|
|
518
499
|
}, _GenerateContext_getFile = function _GenerateContext_getFile(filePath, { throwIfNotFound = false } = {}) {
|
|
519
500
|
const normalisedPath = normalize(filePath);
|
|
520
501
|
const currentFile = __classPrivateFieldGet(this, _GenerateContext_files, "f").get(normalisedPath);
|
|
@@ -538,3 +519,14 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
538
519
|
__classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalisedPath, newFile);
|
|
539
520
|
return newFile;
|
|
540
521
|
};
|
|
522
|
+
export const toOperationSource = ({ operation, generatorId }) => ({
|
|
523
|
+
type: 'operation',
|
|
524
|
+
generatorId,
|
|
525
|
+
operationPath: operation.path,
|
|
526
|
+
operationMethod: operation.method
|
|
527
|
+
});
|
|
528
|
+
export const toModelSource = ({ refName, generatorId }) => ({
|
|
529
|
+
type: 'model',
|
|
530
|
+
generatorId,
|
|
531
|
+
refName
|
|
532
|
+
});
|
|
@@ -7,12 +7,10 @@ import type { StackTrail } from './StackTrail.js';
|
|
|
7
7
|
import type * as log from '../deps/jsr.io/@std/log/0.224.6/mod.js';
|
|
8
8
|
import { File } from '../dsl/File.js';
|
|
9
9
|
import type { Preview } from '../types/Preview.js';
|
|
10
|
-
import type { SchemaOption } from '../types/SchemaOptions.js';
|
|
11
10
|
import type { JsonFile } from '../dsl/JsonFile.js';
|
|
12
11
|
type ConstructorArgs = {
|
|
13
12
|
files: Map<string, File | JsonFile>;
|
|
14
13
|
previews: Record<string, Record<string, Preview>>;
|
|
15
|
-
schemaOptions: SchemaOption[];
|
|
16
14
|
prettierConfig?: PrettierConfigType;
|
|
17
15
|
basePath: string | undefined;
|
|
18
16
|
stackTrail: StackTrail;
|
|
@@ -23,11 +21,10 @@ export declare class RenderContext {
|
|
|
23
21
|
#private;
|
|
24
22
|
files: Map<string, File | JsonFile>;
|
|
25
23
|
previews: Record<string, Record<string, Preview>>;
|
|
26
|
-
schemaOptions: SchemaOption[];
|
|
27
24
|
basePath: string | undefined;
|
|
28
25
|
logger: log.Logger;
|
|
29
26
|
captureCurrentResult: (result: ResultType) => void;
|
|
30
|
-
constructor({ files, previews,
|
|
27
|
+
constructor({ files, previews, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }: ConstructorArgs);
|
|
31
28
|
render(): Promise<Omit<RenderResult, 'results'>>;
|
|
32
29
|
collate(): Promise<FilesRenderResult>;
|
|
33
30
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
@@ -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;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,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,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,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,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OA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AAE,SAAS,CAAC,CAAC;IAgBhD,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA2C3C,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,GAAG,QAAQ;IAU1C,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAO7D"}
|
|
@@ -18,7 +18,7 @@ import { tracer } from '../helpers/tracer.js';
|
|
|
18
18
|
import { File } from '../dsl/File.js';
|
|
19
19
|
import * as prettier from 'prettier';
|
|
20
20
|
export class RenderContext {
|
|
21
|
-
constructor({ files, previews,
|
|
21
|
+
constructor({ files, previews, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }) {
|
|
22
22
|
Object.defineProperty(this, "files", {
|
|
23
23
|
enumerable: true,
|
|
24
24
|
configurable: true,
|
|
@@ -31,12 +31,6 @@ export class RenderContext {
|
|
|
31
31
|
writable: true,
|
|
32
32
|
value: void 0
|
|
33
33
|
});
|
|
34
|
-
Object.defineProperty(this, "schemaOptions", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: true,
|
|
37
|
-
writable: true,
|
|
38
|
-
value: void 0
|
|
39
|
-
});
|
|
40
34
|
_RenderContext_prettierConfig.set(this, void 0);
|
|
41
35
|
Object.defineProperty(this, "basePath", {
|
|
42
36
|
enumerable: true,
|
|
@@ -59,7 +53,6 @@ export class RenderContext {
|
|
|
59
53
|
});
|
|
60
54
|
this.files = files;
|
|
61
55
|
this.previews = previews;
|
|
62
|
-
this.schemaOptions = schemaOptions;
|
|
63
56
|
__classPrivateFieldSet(this, _RenderContext_prettierConfig, prettierConfig, "f");
|
|
64
57
|
this.basePath = basePath;
|
|
65
58
|
this.logger = logger;
|
|
@@ -74,8 +67,7 @@ export class RenderContext {
|
|
|
74
67
|
const rendered = {
|
|
75
68
|
artifacts: result.artifacts,
|
|
76
69
|
files: result.files,
|
|
77
|
-
previews: this.previews
|
|
78
|
-
schemaOptions: this.schemaOptions
|
|
70
|
+
previews: this.previews
|
|
79
71
|
};
|
|
80
72
|
return rendered;
|
|
81
73
|
});
|
package/esm/context/types.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { ManifestEntry } from '../types/Manifest.js';
|
|
|
3
3
|
import type { Preview } from '../types/Preview.js';
|
|
4
4
|
import type { ResultType } from '../types/Results.js';
|
|
5
5
|
import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
6
|
-
import type { SchemaOption } from '../types/SchemaOptions.js';
|
|
7
6
|
export type PhaseType = 'parse' | 'generate' | 'render';
|
|
8
7
|
export type GetFileOptions = {
|
|
9
8
|
throwIfNotFound?: boolean;
|
|
@@ -19,7 +18,6 @@ export type RenderResult = {
|
|
|
19
18
|
artifacts: Record<string, string>;
|
|
20
19
|
files: Record<string, ManifestEntry>;
|
|
21
20
|
previews: Record<string, Record<string, Preview>>;
|
|
22
|
-
schemaOptions: SchemaOption[];
|
|
23
21
|
results: Record<string, ResultType>;
|
|
24
22
|
};
|
|
25
23
|
export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
@@ -1 +1 @@
|
|
|
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,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;
|
|
1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E,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,aAAa,CAAC,cAAc,CAAC;IAQvF,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,cAAc,GAAG,SAAS,EAC9D,UAAU,EAAE,eAAe,CAAC,CAAC,EAAE,cAAc,CAAC,EAC9C,OAAO,EAAE,OAAO,GACf,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC;IAO9B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;CAMhD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ContentBase } from '../ContentBase.js';
|
|
2
|
-
import { toGeneratorId } from '../../types/GeneratorKeys.js';
|
|
3
2
|
export class ModelBase extends ContentBase {
|
|
4
3
|
constructor({ context, settings, generatorKey, refName }) {
|
|
5
4
|
super({ context });
|
|
@@ -32,22 +31,8 @@ export class ModelBase extends ContentBase {
|
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
register(args) {
|
|
35
|
-
const preview = Object.keys(args.preview ?? {}).length
|
|
36
|
-
? Object.fromEntries(Object.entries(args.preview ?? {}).map(([group, preview]) => {
|
|
37
|
-
const previewWithSource = {
|
|
38
|
-
...preview,
|
|
39
|
-
source: {
|
|
40
|
-
type: 'model',
|
|
41
|
-
generatorId: toGeneratorId(this.generatorKey),
|
|
42
|
-
refName: this.refName
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
return [group, previewWithSource];
|
|
46
|
-
}))
|
|
47
|
-
: undefined;
|
|
48
34
|
this.context.register({
|
|
49
35
|
...args,
|
|
50
|
-
preview,
|
|
51
36
|
destinationPath: this.settings.exportPath
|
|
52
37
|
});
|
|
53
38
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { RefName } from '../../types/RefName.js';
|
|
2
2
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
3
|
-
import type { TransformModelArgs } from './types.js';
|
|
3
|
+
import type { TransformModelArgs, ToModelPreviewModuleArgs } from './types.js';
|
|
4
4
|
import type * as v from 'valibot';
|
|
5
|
-
import type {
|
|
5
|
+
import type { PreviewModule } from '../../types/Preview.js';
|
|
6
6
|
type ToModelEntryArgs<EnrichmentType = undefined, Acc = void> = {
|
|
7
7
|
id: string;
|
|
8
8
|
transform: ({ context, refName, acc }: TransformModelArgs<Acc>) => Acc;
|
|
9
9
|
toEnrichmentSchema?: () => v.GenericSchema<EnrichmentType>;
|
|
10
|
-
|
|
10
|
+
toPreviewModule?: ({ context, refName }: ToModelPreviewModuleArgs) => PreviewModule;
|
|
11
11
|
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(refName: RefName) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
12
12
|
};
|
|
13
|
-
export declare const toModelEntry: <EnrichmentType = undefined, Acc = void>({ id, transform,
|
|
13
|
+
export declare const toModelEntry: <EnrichmentType = undefined, Acc = void>({ id, transform, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest }: ToModelEntryArgs<EnrichmentType, Acc>) => {
|
|
14
14
|
id: string;
|
|
15
15
|
type: string;
|
|
16
16
|
transform: ({ context, refName, acc }: TransformModelArgs<Acc>) => Acc;
|
|
17
|
+
toPreviewModule: (({ context, refName }: ToModelPreviewModuleArgs) => PreviewModule) | undefined;
|
|
17
18
|
toEnrichmentSchema: (() => v.GenericSchema<EnrichmentType>) | undefined;
|
|
18
|
-
toSchemaOptions: (() => SchemaOption[]) | undefined;
|
|
19
19
|
toEnrichmentRequest: (<RequestedEnrichment extends EnrichmentType>(refName: RefName) => EnrichmentRequest<RequestedEnrichment> | undefined) | undefined;
|
|
20
20
|
};
|
|
21
21
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toModelEntry.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/toModelEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAA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
export const toModelEntry = ({ id, transform,
|
|
1
|
+
export const toModelEntry = ({ id, transform, toPreviewModule, toEnrichmentSchema, toEnrichmentRequest }) => {
|
|
2
2
|
return {
|
|
3
3
|
id,
|
|
4
4
|
type: 'model',
|
|
5
5
|
transform,
|
|
6
|
+
toPreviewModule,
|
|
6
7
|
toEnrichmentSchema,
|
|
7
|
-
toSchemaOptions,
|
|
8
8
|
toEnrichmentRequest
|
|
9
9
|
};
|
|
10
10
|
};
|
package/esm/dsl/model/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { RefName } from '../../types/RefName.js';
|
|
|
4
4
|
import type { Identifier } from '../Identifier.js';
|
|
5
5
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
6
6
|
import type * as v from 'valibot';
|
|
7
|
-
import type {
|
|
7
|
+
import type { PreviewModule } from '../../types/Preview.js';
|
|
8
8
|
type ModelInsertableConstructorArgs<EnrichmentType = undefined> = {
|
|
9
9
|
context: GenerateContext;
|
|
10
10
|
refName: RefName;
|
|
@@ -24,6 +24,10 @@ export type TransformModelArgs<Acc> = {
|
|
|
24
24
|
refName: RefName;
|
|
25
25
|
acc: Acc | undefined;
|
|
26
26
|
};
|
|
27
|
+
export type ToModelPreviewModuleArgs = {
|
|
28
|
+
context: GenerateContext;
|
|
29
|
+
refName: RefName;
|
|
30
|
+
};
|
|
27
31
|
export type ModelInsertable<V, EnrichmentType = undefined> = {
|
|
28
32
|
prototype: V;
|
|
29
33
|
} & {
|
|
@@ -38,8 +42,8 @@ export type ModelConfig<EnrichmentType = undefined> = {
|
|
|
38
42
|
id: string;
|
|
39
43
|
type: 'model';
|
|
40
44
|
transform: <Acc = void>({ context, refName, acc }: TransformModelArgs<Acc>) => Acc;
|
|
45
|
+
toPreviewModule?: ({ context, refName }: ToModelPreviewModuleArgs) => PreviewModule;
|
|
41
46
|
toEnrichmentSchema?: () => v.BaseSchema<EnrichmentType, EnrichmentType, v.BaseIssue<unknown>>;
|
|
42
|
-
toSchemaOptions?: () => SchemaOption[];
|
|
43
47
|
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(refName: RefName) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
44
48
|
};
|
|
45
49
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE3D,KAAK,8BAA8B,CAAC,cAAc,GAAG,SAAS,IAAI;IAChE,OAAO,EAAE,eAAe,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,eAAe,CAAC,cAA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AAE,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,kBAAkB,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IAClF,eAAe,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,wBAAwB,KAAK,aAAa,CAAA;IACnF,kBAAkB,CAAC,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,cAAc,EAAE,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7F,mBAAmB,CAAC,EAAE,CAAC,mBAAmB,SAAS,cAAc,EAC/D,OAAO,EAAE,OAAO,KACb,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAA;CACxD,CAAA"}
|
|
@@ -3,7 +3,7 @@ import type { OasOperation } from '../../oas/operation/Operation.js';
|
|
|
3
3
|
import type { ContentSettings } from '../ContentSettings.js';
|
|
4
4
|
import type { BaseRegisterArgs, GenerateContext } from '../../context/GenerateContext.js';
|
|
5
5
|
import type { GeneratedValue } from '../../types/GeneratedValue.js';
|
|
6
|
-
import {
|
|
6
|
+
import type { GeneratorKey } from '../../types/GeneratorKeys.js';
|
|
7
7
|
import { ContentBase } from '../ContentBase.js';
|
|
8
8
|
import type { Definition } from '../Definition.js';
|
|
9
9
|
import type { Identifier } from '../Identifier.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationBase.d.ts","sourceRoot":"","sources":["../../../src/dsl/operation/OperationBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BA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AAe,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,qBAAa,aAAa,CAAC,cAAc,GAAG,SAAS,CAAE,SAAQ,WAAW;IACxE,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;IACzC,SAAS,EAAE,YAAY,CAAA;IACd,YAAY,EAAE,YAAY,CAAA;gBAEvB,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,iBAAiB,CAAC,cAAc,CAAC;IAQ7F,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,cAAc,GAAG,SAAS,EAClE,UAAU,EAAE,mBAAmB,CAAC,CAAC,EAAE,cAAc,CAAC,EAClD,SAAS,EAAE,YAAY,GACtB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC;IAOvC,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,cAAc,GAAG,SAAS,EAC9D,UAAU,EAAE,eAAe,CAAC,CAAC,EAAE,cAAc,CAAC,EAC9C,OAAO,EAAE,OAAO,GACf,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC;IAOvC,2BAA2B,CAAC,MAAM,SAAS,UAAU,EAAE,EACrD,MAAM,EACN,UAAU,EACV,eAAe,EACf,OAAO,EACR,EAAE,2BAA2B,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAU5E,QAAQ,CAAC,IAAI,EAAE,gBAAgB;CAMzC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { toGeneratorId } from '../../types/GeneratorKeys.js';
|
|
2
1
|
import { ContentBase } from '../ContentBase.js';
|
|
3
2
|
export class OperationBase extends ContentBase {
|
|
4
3
|
constructor({ context, generatorKey, settings, operation }) {
|
|
@@ -47,23 +46,8 @@ export class OperationBase extends ContentBase {
|
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
register(args) {
|
|
50
|
-
const preview = Object.keys(args.preview ?? {}).length
|
|
51
|
-
? Object.fromEntries(Object.entries(args.preview ?? {}).map(([group, preview]) => {
|
|
52
|
-
const previewWithSource = {
|
|
53
|
-
...preview,
|
|
54
|
-
source: {
|
|
55
|
-
type: 'operation',
|
|
56
|
-
generatorId: toGeneratorId(this.generatorKey),
|
|
57
|
-
operationPath: this.operation.path,
|
|
58
|
-
operationMethod: this.operation.method
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
return [group, previewWithSource];
|
|
62
|
-
}))
|
|
63
|
-
: undefined;
|
|
64
49
|
this.context.register({
|
|
65
50
|
...args,
|
|
66
|
-
preview,
|
|
67
51
|
destinationPath: this.settings.exportPath
|
|
68
52
|
});
|
|
69
53
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import type { OasOperation } from '../../oas/operation/Operation.js';
|
|
3
3
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
4
|
-
import type { IsSupportedArgs, TransformOperationArgs } from './types.js';
|
|
4
|
+
import type { IsSupportedArgs, ToOperationPreviewModuleArgs, TransformOperationArgs } from './types.js';
|
|
5
5
|
import type { IsSupportedOperationConfigArgs } from './types.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { PreviewModule } from '../../types/Preview.js';
|
|
7
7
|
export type ToOperationConfigArgs<EnrichmentType = undefined, Acc = void> = {
|
|
8
8
|
id: string;
|
|
9
9
|
transform: ({ context, operation, acc }: TransformOperationArgs<Acc>) => Acc;
|
|
10
10
|
toEnrichmentSchema?: () => v.GenericSchema<EnrichmentType>;
|
|
11
11
|
isSupported?: ({ context, operation }: IsSupportedOperationConfigArgs<EnrichmentType>) => boolean;
|
|
12
|
-
|
|
12
|
+
toPreviewModule?: ({ context, operation }: ToOperationPreviewModuleArgs) => PreviewModule;
|
|
13
13
|
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(operation: OasOperation) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
14
14
|
};
|
|
15
|
-
export declare const toOperationEntry: <EnrichmentType = undefined, Acc = void>({ id, transform, toEnrichmentSchema, isSupported,
|
|
15
|
+
export declare const toOperationEntry: <EnrichmentType = undefined, Acc = void>({ id, transform, toEnrichmentSchema, isSupported, toPreviewModule, toEnrichmentRequest }: ToOperationConfigArgs<EnrichmentType, Acc>) => {
|
|
16
16
|
id: string;
|
|
17
17
|
type: string;
|
|
18
18
|
transform: ({ context, operation, acc }: TransformOperationArgs<Acc>) => Acc;
|
|
19
|
-
toSchemaOptions: (() => SchemaOption[]) | undefined;
|
|
20
19
|
toEnrichmentSchema: (() => v.GenericSchema<EnrichmentType>) | undefined;
|
|
21
20
|
isSupported: ({ context, operation }: IsSupportedArgs) => boolean;
|
|
21
|
+
toPreviewModule: (({ context, operation }: ToOperationPreviewModuleArgs) => PreviewModule) | undefined;
|
|
22
22
|
toEnrichmentRequest: (<RequestedEnrichment extends EnrichmentType>(operation: OasOperation) => EnrichmentRequest<RequestedEnrichment> | undefined) | undefined;
|
|
23
23
|
};
|
|
24
24
|
//# sourceMappingURL=toOperationEntry.d.ts.map
|