@skmtc/core 0.0.799 → 0.0.802
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 -3
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +12 -17
- package/esm/context/GenerateContext.d.ts +35 -3
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +21 -1
- package/esm/context/ParseContext.d.ts +64 -3
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +61 -0
- package/esm/context/RenderContext.d.ts +151 -2
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +185 -11
- package/esm/context/ResultsHandler.d.ts +10 -3
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/context/types.d.ts +30 -0
- package/esm/context/types.d.ts.map +1 -1
- package/esm/dsl/model/ModelBase.d.ts +1 -1
- package/esm/dsl/model/ModelBase.d.ts.map +1 -1
- package/esm/dsl/model/ModelDriver.d.ts +62 -0
- package/esm/dsl/model/ModelDriver.d.ts.map +1 -1
- package/esm/dsl/model/ModelDriver.js +63 -1
- package/esm/dsl/model/toModelBase.d.ts +66 -0
- package/esm/dsl/model/toModelBase.d.ts.map +1 -1
- package/esm/dsl/model/toModelBase.js +46 -0
- package/esm/dsl/model/toModelEntry.d.ts +63 -0
- package/esm/dsl/model/toModelEntry.d.ts.map +1 -1
- package/esm/dsl/model/toModelEntry.js +63 -0
- package/esm/dsl/model/types.d.ts +51 -4
- package/esm/dsl/model/types.d.ts.map +1 -1
- package/esm/dsl/operation/OperationBase.d.ts +3 -3
- package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
- package/esm/dsl/operation/OperationDriver.d.ts +48 -0
- package/esm/dsl/operation/OperationDriver.d.ts.map +1 -1
- package/esm/dsl/operation/OperationDriver.js +49 -1
- package/esm/dsl/operation/types.d.ts +61 -3
- package/esm/dsl/operation/types.d.ts.map +1 -1
- package/esm/helpers/isEmpty.d.ts +1 -1
- package/esm/helpers/isEmpty.d.ts.map +1 -1
- package/esm/helpers/tracer.d.ts +1 -1
- package/esm/helpers/tracer.d.ts.map +1 -1
- package/esm/helpers/tracer.js +1 -1
- package/esm/mod.d.ts +51 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +51 -0
- package/esm/oas/array/array-types.d.ts +20 -11
- package/esm/oas/array/array-types.d.ts.map +1 -1
- package/esm/oas/array/array-types.js +10 -0
- package/esm/oas/array/toArray.d.ts +111 -0
- package/esm/oas/array/toArray.d.ts.map +1 -1
- package/esm/oas/array/toArray.js +115 -3
- package/esm/oas/boolean/boolean-types.d.ts +1 -7
- package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
- package/esm/oas/components/components-types.d.ts +19 -0
- package/esm/oas/components/components-types.d.ts.map +1 -0
- package/esm/oas/components/components-types.js +21 -0
- package/esm/oas/contact/contact-types.d.ts +9 -0
- package/esm/oas/contact/contact-types.d.ts.map +1 -0
- package/esm/oas/contact/contact-types.js +7 -0
- package/esm/oas/discriminator/discriminator-types.d.ts +1 -5
- package/esm/oas/discriminator/discriminator-types.d.ts.map +1 -1
- package/esm/oas/document/document-types.d.ts +16 -0
- package/esm/oas/document/document-types.d.ts.map +1 -0
- package/esm/oas/document/document-types.js +18 -0
- package/esm/oas/example/example-types.d.ts +1 -6
- package/esm/oas/example/example-types.d.ts.map +1 -1
- package/esm/oas/header/header-types.d.ts +50 -0
- package/esm/oas/header/header-types.d.ts.map +1 -0
- package/esm/oas/header/header-types.js +30 -0
- package/esm/oas/info/info-types.d.ts +14 -0
- package/esm/oas/info/info-types.d.ts.map +1 -0
- package/esm/oas/info/info-types.js +13 -0
- package/esm/oas/integer/integer-types.d.ts +3 -17
- package/esm/oas/integer/integer-types.d.ts.map +1 -1
- package/esm/oas/license/license-types.d.ts +9 -0
- package/esm/oas/license/license-types.d.ts.map +1 -0
- package/esm/oas/license/license-types.js +7 -0
- package/esm/oas/mediaType/mediaType-types.d.ts +1 -11
- package/esm/oas/mediaType/mediaType-types.d.ts.map +1 -1
- package/esm/oas/number/number-types.d.ts +2 -16
- package/esm/oas/number/number-types.d.ts.map +1 -1
- package/esm/oas/operation/Operation.d.ts +47 -2
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +43 -0
- package/esm/oas/operation/operation-types.d.ts +22 -0
- package/esm/oas/operation/operation-types.d.ts.map +1 -0
- package/esm/oas/operation/operation-types.js +35 -0
- package/esm/oas/parameter/parameter-types.d.ts +3 -58
- package/esm/oas/parameter/parameter-types.d.ts.map +1 -1
- package/esm/oas/pathItem/pathItem-types.d.ts +12 -0
- package/esm/oas/pathItem/pathItem-types.d.ts.map +1 -0
- package/esm/oas/pathItem/pathItem-types.js +12 -0
- package/esm/oas/ref/Ref.d.ts +49 -2
- package/esm/oas/ref/Ref.d.ts.map +1 -1
- package/esm/oas/ref/Ref.js +28 -0
- package/esm/oas/requestBody/requestBody-types.d.ts +10 -0
- package/esm/oas/requestBody/requestBody-types.d.ts.map +1 -0
- package/esm/oas/requestBody/requestBody-types.js +9 -0
- package/esm/oas/response/response-types.d.ts +12 -0
- package/esm/oas/response/response-types.d.ts.map +1 -0
- package/esm/oas/response/response-types.js +11 -0
- package/esm/oas/schema/toSchemasV3.js +2 -2
- package/esm/oas/server/toServerV3.d.ts.map +1 -1
- package/esm/oas/string/string-types.d.ts +2 -29
- package/esm/oas/string/string-types.d.ts.map +1 -1
- package/esm/oas/string/toString.d.ts +125 -1
- package/esm/oas/string/toString.d.ts.map +1 -1
- package/esm/oas/string/toString.js +119 -0
- package/esm/oas/tag/tag-types.d.ts +8 -0
- package/esm/oas/tag/tag-types.d.ts.map +1 -0
- package/esm/oas/tag/tag-types.js +8 -0
- package/esm/oas/union/union-types.d.ts +1 -12
- package/esm/oas/union/union-types.d.ts.map +1 -1
- package/esm/oas/unknown/unknown-types.d.ts +1 -7
- package/esm/oas/unknown/unknown-types.d.ts.map +1 -1
- package/esm/types/Preview.d.ts +37 -0
- package/esm/types/Preview.d.ts.map +1 -1
- package/esm/types/Preview.js +37 -0
- package/esm/types/Settings.d.ts +35 -0
- package/esm/types/Settings.d.ts.map +1 -1
- package/esm/types/Settings.js +27 -0
- package/esm/typescript/FunctionParameter.d.ts +4 -4
- package/esm/typescript/FunctionParameter.d.ts.map +1 -1
- package/esm/typescript/List.d.ts +104 -5
- package/esm/typescript/List.d.ts.map +1 -1
- package/esm/typescript/List.js +75 -0
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +0 -3
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +12 -17
- package/script/context/GenerateContext.d.ts +35 -3
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +21 -1
- package/script/context/ParseContext.d.ts +64 -3
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +61 -0
- package/script/context/RenderContext.d.ts +151 -2
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +185 -11
- package/script/context/ResultsHandler.d.ts +10 -3
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/context/types.d.ts +30 -0
- package/script/context/types.d.ts.map +1 -1
- package/script/dsl/model/ModelBase.d.ts +1 -1
- package/script/dsl/model/ModelBase.d.ts.map +1 -1
- package/script/dsl/model/ModelDriver.d.ts +62 -0
- package/script/dsl/model/ModelDriver.d.ts.map +1 -1
- package/script/dsl/model/ModelDriver.js +63 -1
- package/script/dsl/model/toModelBase.d.ts +66 -0
- package/script/dsl/model/toModelBase.d.ts.map +1 -1
- package/script/dsl/model/toModelBase.js +46 -0
- package/script/dsl/model/toModelEntry.d.ts +63 -0
- package/script/dsl/model/toModelEntry.d.ts.map +1 -1
- package/script/dsl/model/toModelEntry.js +63 -0
- package/script/dsl/model/types.d.ts +51 -4
- package/script/dsl/model/types.d.ts.map +1 -1
- package/script/dsl/operation/OperationBase.d.ts +3 -3
- package/script/dsl/operation/OperationBase.d.ts.map +1 -1
- package/script/dsl/operation/OperationDriver.d.ts +48 -0
- package/script/dsl/operation/OperationDriver.d.ts.map +1 -1
- package/script/dsl/operation/OperationDriver.js +49 -1
- package/script/dsl/operation/types.d.ts +61 -3
- package/script/dsl/operation/types.d.ts.map +1 -1
- package/script/helpers/isEmpty.d.ts +1 -1
- package/script/helpers/isEmpty.d.ts.map +1 -1
- package/script/helpers/tracer.d.ts +1 -1
- package/script/helpers/tracer.d.ts.map +1 -1
- package/script/helpers/tracer.js +1 -1
- package/script/mod.d.ts +51 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +51 -0
- package/script/oas/array/array-types.d.ts +20 -11
- package/script/oas/array/array-types.d.ts.map +1 -1
- package/script/oas/array/array-types.js +11 -1
- package/script/oas/array/toArray.d.ts +111 -0
- package/script/oas/array/toArray.d.ts.map +1 -1
- package/script/oas/array/toArray.js +114 -2
- package/script/oas/boolean/boolean-types.d.ts +1 -7
- package/script/oas/boolean/boolean-types.d.ts.map +1 -1
- package/script/oas/components/components-types.d.ts +19 -0
- package/script/oas/components/components-types.d.ts.map +1 -0
- package/script/oas/components/components-types.js +57 -0
- package/script/oas/contact/contact-types.d.ts +9 -0
- package/script/oas/contact/contact-types.d.ts.map +1 -0
- package/script/oas/contact/contact-types.js +43 -0
- package/script/oas/discriminator/discriminator-types.d.ts +1 -5
- package/script/oas/discriminator/discriminator-types.d.ts.map +1 -1
- package/script/oas/document/document-types.d.ts +16 -0
- package/script/oas/document/document-types.d.ts.map +1 -0
- package/script/oas/document/document-types.js +54 -0
- package/script/oas/example/example-types.d.ts +1 -6
- package/script/oas/example/example-types.d.ts.map +1 -1
- package/script/oas/header/header-types.d.ts +50 -0
- package/script/oas/header/header-types.d.ts.map +1 -0
- package/script/oas/header/header-types.js +66 -0
- package/script/oas/info/info-types.d.ts +14 -0
- package/script/oas/info/info-types.d.ts.map +1 -0
- package/script/oas/info/info-types.js +49 -0
- package/script/oas/integer/integer-types.d.ts +3 -17
- package/script/oas/integer/integer-types.d.ts.map +1 -1
- package/script/oas/license/license-types.d.ts +9 -0
- package/script/oas/license/license-types.d.ts.map +1 -0
- package/script/oas/license/license-types.js +43 -0
- package/script/oas/mediaType/mediaType-types.d.ts +1 -11
- package/script/oas/mediaType/mediaType-types.d.ts.map +1 -1
- package/script/oas/number/number-types.d.ts +2 -16
- package/script/oas/number/number-types.d.ts.map +1 -1
- package/script/oas/operation/Operation.d.ts +47 -2
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +43 -0
- package/script/oas/operation/operation-types.d.ts +22 -0
- package/script/oas/operation/operation-types.d.ts.map +1 -0
- package/script/oas/operation/operation-types.js +71 -0
- package/script/oas/parameter/parameter-types.d.ts +3 -58
- package/script/oas/parameter/parameter-types.d.ts.map +1 -1
- package/script/oas/pathItem/pathItem-types.d.ts +12 -0
- package/script/oas/pathItem/pathItem-types.d.ts.map +1 -0
- package/script/oas/pathItem/pathItem-types.js +48 -0
- package/script/oas/ref/Ref.d.ts +49 -2
- package/script/oas/ref/Ref.d.ts.map +1 -1
- package/script/oas/ref/Ref.js +28 -0
- package/script/oas/requestBody/requestBody-types.d.ts +10 -0
- package/script/oas/requestBody/requestBody-types.d.ts.map +1 -0
- package/script/oas/requestBody/requestBody-types.js +45 -0
- package/script/oas/response/response-types.d.ts +12 -0
- package/script/oas/response/response-types.d.ts.map +1 -0
- package/script/oas/response/response-types.js +47 -0
- package/script/oas/schema/toSchemasV3.js +2 -2
- package/script/oas/server/toServerV3.d.ts.map +1 -1
- package/script/oas/string/string-types.d.ts +2 -29
- package/script/oas/string/string-types.d.ts.map +1 -1
- package/script/oas/string/toString.d.ts +125 -1
- package/script/oas/string/toString.d.ts.map +1 -1
- package/script/oas/string/toString.js +119 -0
- package/script/oas/tag/tag-types.d.ts +8 -0
- package/script/oas/tag/tag-types.d.ts.map +1 -0
- package/script/oas/tag/tag-types.js +44 -0
- package/script/oas/union/union-types.d.ts +1 -12
- package/script/oas/union/union-types.d.ts.map +1 -1
- package/script/oas/unknown/unknown-types.d.ts +1 -7
- package/script/oas/unknown/unknown-types.d.ts.map +1 -1
- package/script/types/Preview.d.ts +37 -0
- package/script/types/Preview.d.ts.map +1 -1
- package/script/types/Preview.js +37 -0
- package/script/types/Settings.d.ts +35 -0
- package/script/types/Settings.d.ts.map +1 -1
- package/script/types/Settings.js +27 -0
- package/script/typescript/FunctionParameter.d.ts +4 -4
- package/script/typescript/FunctionParameter.d.ts.map +1 -1
- package/script/typescript/List.d.ts +104 -5
- package/script/typescript/List.d.ts.map +1 -1
- package/script/typescript/List.js +75 -0
|
@@ -255,6 +255,13 @@ class GenerateContext {
|
|
|
255
255
|
mappings: __classPrivateFieldGet(this, _GenerateContext_mappings, "f")
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Executes a function within a traced context for debugging and monitoring.
|
|
260
|
+
*
|
|
261
|
+
* @param token - Trace identifier or path segments
|
|
262
|
+
* @param fn - Function to execute within the trace context
|
|
263
|
+
* @returns The result of the traced function execution
|
|
264
|
+
*/
|
|
258
265
|
trace(token, fn) {
|
|
259
266
|
return (0, tracer_js_1.tracer)(this.stackTrail, token, fn, this.logger);
|
|
260
267
|
}
|
|
@@ -283,7 +290,12 @@ class GenerateContext {
|
|
|
283
290
|
noExport
|
|
284
291
|
});
|
|
285
292
|
}
|
|
286
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* Registers JSON content for output to a file.
|
|
295
|
+
*
|
|
296
|
+
* @experimental This method is experimental and may change in future versions
|
|
297
|
+
* @param args - Registration arguments with destination path and JSON content
|
|
298
|
+
*/
|
|
287
299
|
registerJson({ destinationPath, json }) {
|
|
288
300
|
const currentFile = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_getFile).call(this, destinationPath);
|
|
289
301
|
(0, tiny_invariant_1.default)(currentFile instanceof JsonFile_js_1.JsonFile, `File at "${destinationPath}" is not a "JsonFile" type`);
|
|
@@ -363,6 +375,14 @@ class GenerateContext {
|
|
|
363
375
|
});
|
|
364
376
|
return new Inserted_js_1.Inserted({ settings, definition });
|
|
365
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Inserts a normalized model definition into the generation context.
|
|
380
|
+
*
|
|
381
|
+
* @param insertable - Model insertable configuration with prototype and transform functions
|
|
382
|
+
* @param schema - OAS schema, reference, or void type to generate model from
|
|
383
|
+
* @param options - Insertion options including generation type and destination
|
|
384
|
+
* @returns Inserted model instance with settings and definition
|
|
385
|
+
*/
|
|
366
386
|
insertNormalisedModel(insertable, { schema, fallbackName, destinationPath }, { noExport = false } = {}) {
|
|
367
387
|
if (schema.isRef()) {
|
|
368
388
|
const { definition } = this.insertModel(insertable, schema.toRefName(), {
|
|
@@ -30,7 +30,7 @@ export type ParseReturn = {
|
|
|
30
30
|
/**
|
|
31
31
|
* Base type for parse warning messages.
|
|
32
32
|
*/
|
|
33
|
-
type ParseWarningBase = {
|
|
33
|
+
export type ParseWarningBase = {
|
|
34
34
|
/** Issue severity level */
|
|
35
35
|
level: 'warning';
|
|
36
36
|
/** Warning message */
|
|
@@ -39,7 +39,7 @@ type ParseWarningBase = {
|
|
|
39
39
|
/**
|
|
40
40
|
* Base type for parse error messages.
|
|
41
41
|
*/
|
|
42
|
-
type ParseErrorBase = {
|
|
42
|
+
export type ParseErrorBase = {
|
|
43
43
|
/** Issue severity level */
|
|
44
44
|
level: 'error';
|
|
45
45
|
/** The error that occurred */
|
|
@@ -48,7 +48,7 @@ type ParseErrorBase = {
|
|
|
48
48
|
/**
|
|
49
49
|
* Base union type for parse issues.
|
|
50
50
|
*/
|
|
51
|
-
type ParseIssueBase = ParseErrorBase | ParseWarningBase;
|
|
51
|
+
export type ParseIssueBase = ParseErrorBase | ParseWarningBase;
|
|
52
52
|
/**
|
|
53
53
|
* Arguments for logging issues with a specific key.
|
|
54
54
|
*/
|
|
@@ -253,17 +253,78 @@ export declare class ParseContext {
|
|
|
253
253
|
issues: ParseIssue[];
|
|
254
254
|
/** Whether to suppress console output during parsing */
|
|
255
255
|
silent: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Creates a new ParseContext instance for the parsing phase.
|
|
258
|
+
*
|
|
259
|
+
* @param args - Constructor arguments including document object, logger, and options
|
|
260
|
+
*/
|
|
256
261
|
constructor({ documentObject, logger, stackTrail, silent }: ConstructorArgs);
|
|
262
|
+
/**
|
|
263
|
+
* Parses the OpenAPI v3 document and returns the internal OAS document representation.
|
|
264
|
+
*
|
|
265
|
+
* @returns Parsed OAS document with all components and operations
|
|
266
|
+
*/
|
|
257
267
|
parse(): OasDocument;
|
|
268
|
+
/**
|
|
269
|
+
* Removes items from the parsed document that encountered errors during parsing.
|
|
270
|
+
*/
|
|
258
271
|
removeErroredItems(): void;
|
|
272
|
+
/**
|
|
273
|
+
* Registers a reference ($ref) with its associated stack trail for error tracking.
|
|
274
|
+
*
|
|
275
|
+
* @param stackTrail - Current processing context stack trail
|
|
276
|
+
* @param $ref - OpenAPI reference string to register
|
|
277
|
+
*/
|
|
259
278
|
registerRef(stackTrail: StackTrail, $ref: string): void;
|
|
279
|
+
/**
|
|
280
|
+
* Registers an error that occurred while processing a reference.
|
|
281
|
+
*
|
|
282
|
+
* @param error - Error that occurred during reference processing
|
|
283
|
+
* @param $ref - Reference string that caused the error (if available)
|
|
284
|
+
*/
|
|
260
285
|
registerRefError(error: Error, $ref: string | undefined): void;
|
|
286
|
+
/**
|
|
287
|
+
* Executes a function within a traced context for debugging and monitoring.
|
|
288
|
+
*
|
|
289
|
+
* @param token - Trace identifier or path segments
|
|
290
|
+
* @param fn - Function to execute within the trace context
|
|
291
|
+
* @returns The result of the traced function execution
|
|
292
|
+
*/
|
|
261
293
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
294
|
+
/**
|
|
295
|
+
* Logs warnings for fields that were skipped during parsing.
|
|
296
|
+
*
|
|
297
|
+
* @param args - Arguments containing skipped fields and parent context
|
|
298
|
+
*/
|
|
262
299
|
logSkippedFields({ skipped, parent, parentType }: LogSkippedValuesArgs): void;
|
|
300
|
+
/**
|
|
301
|
+
* Attempts to parse a value with optional error handling and logging.
|
|
302
|
+
*
|
|
303
|
+
* @param args - Parsing arguments including schema and error handling
|
|
304
|
+
* @returns Parsed value or undefined if parsing fails
|
|
305
|
+
*/
|
|
263
306
|
provisionalParse<T>({ key, value, parent, schema, toMessage, type }: ProvisionalParseArgs<T>): T | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* Logs a parsing issue with associated key context.
|
|
309
|
+
*
|
|
310
|
+
* @param args - Issue arguments including key, parent object, and issue details
|
|
311
|
+
*/
|
|
264
312
|
logIssue({ key, parent, type, ...issue }: LogIssueArgs): void;
|
|
313
|
+
/**
|
|
314
|
+
* Logs a parsing issue without specific key context.
|
|
315
|
+
*
|
|
316
|
+
* @param args - Issue arguments including parent object and issue details
|
|
317
|
+
*/
|
|
265
318
|
logIssueNoKey({ parent, type, ...issue }: LogIssueNoKeyArgs): void;
|
|
266
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Parses an OpenAPI v3 schema from string format (JSON or YAML).
|
|
322
|
+
*
|
|
323
|
+
* Automatically detects the format based on content and parses accordingly.
|
|
324
|
+
*
|
|
325
|
+
* @param schema - Schema string in JSON or YAML format
|
|
326
|
+
* @returns Parsed OpenAPI v3 document object
|
|
327
|
+
*/
|
|
267
328
|
export declare const parseSchema: (schema: string) => OpenAPIV3.Document;
|
|
268
329
|
export {};
|
|
269
330
|
//# sourceMappingURL=ParseContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,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
|
162
162
|
*/
|
|
163
163
|
class ParseContext {
|
|
164
|
+
/**
|
|
165
|
+
* Creates a new ParseContext instance for the parsing phase.
|
|
166
|
+
*
|
|
167
|
+
* @param args - Constructor arguments including document object, logger, and options
|
|
168
|
+
*/
|
|
164
169
|
constructor({ documentObject, logger, stackTrail, silent = true }) {
|
|
165
170
|
/** The original OpenAPI v3 document being parsed */
|
|
166
171
|
Object.defineProperty(this, "documentObject", {
|
|
@@ -215,6 +220,11 @@ class ParseContext {
|
|
|
215
220
|
__classPrivateFieldSet(this, _ParseContext_refStackTrails, {}, "f");
|
|
216
221
|
__classPrivateFieldSet(this, _ParseContext_refErrors, {}, "f");
|
|
217
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Parses the OpenAPI v3 document and returns the internal OAS document representation.
|
|
225
|
+
*
|
|
226
|
+
* @returns Parsed OAS document with all components and operations
|
|
227
|
+
*/
|
|
218
228
|
parse() {
|
|
219
229
|
this.oasDocument.fields = (0, toDocumentFieldsV3_js_1.toDocumentFieldsV3)({
|
|
220
230
|
documentObject: this.documentObject,
|
|
@@ -223,6 +233,9 @@ class ParseContext {
|
|
|
223
233
|
this.removeErroredItems();
|
|
224
234
|
return this.oasDocument;
|
|
225
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Removes items from the parsed document that encountered errors during parsing.
|
|
238
|
+
*/
|
|
226
239
|
removeErroredItems() {
|
|
227
240
|
Object.entries(__classPrivateFieldGet(this, _ParseContext_refErrors, "f")).forEach(([$ref, errors]) => {
|
|
228
241
|
errors.forEach(error => {
|
|
@@ -241,19 +254,43 @@ class ParseContext {
|
|
|
241
254
|
});
|
|
242
255
|
});
|
|
243
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Registers a reference ($ref) with its associated stack trail for error tracking.
|
|
259
|
+
*
|
|
260
|
+
* @param stackTrail - Current processing context stack trail
|
|
261
|
+
* @param $ref - OpenAPI reference string to register
|
|
262
|
+
*/
|
|
244
263
|
registerRef(stackTrail, $ref) {
|
|
245
264
|
const refStackTrails = __classPrivateFieldGet(this, _ParseContext_refStackTrails, "f")[$ref];
|
|
246
265
|
refStackTrails ? refStackTrails.push(stackTrail) : (__classPrivateFieldGet(this, _ParseContext_refStackTrails, "f")[$ref] = [stackTrail]);
|
|
247
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Registers an error that occurred while processing a reference.
|
|
269
|
+
*
|
|
270
|
+
* @param error - Error that occurred during reference processing
|
|
271
|
+
* @param $ref - Reference string that caused the error (if available)
|
|
272
|
+
*/
|
|
248
273
|
registerRefError(error, $ref) {
|
|
249
274
|
if ($ref) {
|
|
250
275
|
const refErrors = __classPrivateFieldGet(this, _ParseContext_refErrors, "f")[$ref];
|
|
251
276
|
refErrors ? refErrors.push(error) : (__classPrivateFieldGet(this, _ParseContext_refErrors, "f")[$ref] = [error]);
|
|
252
277
|
}
|
|
253
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Executes a function within a traced context for debugging and monitoring.
|
|
281
|
+
*
|
|
282
|
+
* @param token - Trace identifier or path segments
|
|
283
|
+
* @param fn - Function to execute within the trace context
|
|
284
|
+
* @returns The result of the traced function execution
|
|
285
|
+
*/
|
|
254
286
|
trace(token, fn) {
|
|
255
287
|
return (0, tracer_js_1.tracer)(this.stackTrail, token, fn, this.logger);
|
|
256
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Logs warnings for fields that were skipped during parsing.
|
|
291
|
+
*
|
|
292
|
+
* @param args - Arguments containing skipped fields and parent context
|
|
293
|
+
*/
|
|
257
294
|
logSkippedFields({ skipped, parent, parentType }) {
|
|
258
295
|
Object.keys(skipped).forEach(key => {
|
|
259
296
|
this.logIssue({
|
|
@@ -265,6 +302,12 @@ class ParseContext {
|
|
|
265
302
|
});
|
|
266
303
|
});
|
|
267
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Attempts to parse a value with optional error handling and logging.
|
|
307
|
+
*
|
|
308
|
+
* @param args - Parsing arguments including schema and error handling
|
|
309
|
+
* @returns Parsed value or undefined if parsing fails
|
|
310
|
+
*/
|
|
268
311
|
provisionalParse({ key, value, parent, schema, toMessage, type }) {
|
|
269
312
|
const parsed = v.safeParse(v.optional(schema), value);
|
|
270
313
|
if (parsed.success) {
|
|
@@ -278,9 +321,19 @@ class ParseContext {
|
|
|
278
321
|
type
|
|
279
322
|
});
|
|
280
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Logs a parsing issue with associated key context.
|
|
326
|
+
*
|
|
327
|
+
* @param args - Issue arguments including key, parent object, and issue details
|
|
328
|
+
*/
|
|
281
329
|
logIssue({ key, parent, type, ...issue }) {
|
|
282
330
|
this.trace(key, () => this.logIssueNoKey({ parent, type, ...issue }));
|
|
283
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Logs a parsing issue without specific key context.
|
|
334
|
+
*
|
|
335
|
+
* @param args - Issue arguments including parent object and issue details
|
|
336
|
+
*/
|
|
284
337
|
logIssueNoKey({ parent, type, ...issue }) {
|
|
285
338
|
if (issue.level === 'error') {
|
|
286
339
|
this.registerRefError(issue.error, this.stackTrail.toStackRef());
|
|
@@ -303,6 +356,14 @@ class ParseContext {
|
|
|
303
356
|
}
|
|
304
357
|
exports.ParseContext = ParseContext;
|
|
305
358
|
_ParseContext_refStackTrails = new WeakMap(), _ParseContext_refErrors = new WeakMap();
|
|
359
|
+
/**
|
|
360
|
+
* Parses an OpenAPI v3 schema from string format (JSON or YAML).
|
|
361
|
+
*
|
|
362
|
+
* Automatically detects the format based on content and parses accordingly.
|
|
363
|
+
*
|
|
364
|
+
* @param schema - Schema string in JSON or YAML format
|
|
365
|
+
* @returns Parsed OpenAPI v3 document object
|
|
366
|
+
*/
|
|
306
367
|
const parseSchema = (schema) => {
|
|
307
368
|
if (schema.trimStart().startsWith('{')) {
|
|
308
369
|
return JSON.parse(schema);
|
|
@@ -150,7 +150,7 @@ type ConstructorArgs = {
|
|
|
150
150
|
* prettierConfig: this.prettierConfig,
|
|
151
151
|
* basePath: this.settings?.basePath,
|
|
152
152
|
* stackTrail: this.stackTrail,
|
|
153
|
-
* logger: this
|
|
153
|
+
* logger: this.#logger,
|
|
154
154
|
* captureCurrentResult: this.captureCurrentResult.bind(this)
|
|
155
155
|
* });
|
|
156
156
|
*
|
|
@@ -210,17 +210,166 @@ type ConstructorArgs = {
|
|
|
210
210
|
*/
|
|
211
211
|
export declare class RenderContext {
|
|
212
212
|
#private;
|
|
213
|
+
/** Map of generated files to render */
|
|
213
214
|
files: Map<string, File | JsonFile>;
|
|
215
|
+
/** Preview data for generated content */
|
|
214
216
|
previews: Record<string, Record<string, Preview>>;
|
|
217
|
+
/** Mapping data for file relationships */
|
|
215
218
|
mappings: Record<string, Record<string, Mapping>>;
|
|
219
|
+
/** Base path for resolving file paths */
|
|
216
220
|
basePath: string | undefined;
|
|
217
|
-
|
|
221
|
+
/** Function to capture result status */
|
|
218
222
|
captureCurrentResult: (result: ResultType) => void;
|
|
223
|
+
/**
|
|
224
|
+
* Creates a new RenderContext instance with the specified configuration.
|
|
225
|
+
*
|
|
226
|
+
* Initializes the rendering context with files to render, preview data,
|
|
227
|
+
* formatting configuration, and logging/tracing infrastructure.
|
|
228
|
+
*
|
|
229
|
+
* @param args - Constructor arguments containing all required configuration
|
|
230
|
+
*/
|
|
219
231
|
constructor({ files, previews, mappings, prettierConfig, basePath, logger, stackTrail, captureCurrentResult }: ConstructorArgs);
|
|
232
|
+
/**
|
|
233
|
+
* Renders all files in the context to their final formatted form.
|
|
234
|
+
*
|
|
235
|
+
* This is the main rendering method that orchestrates the collation and
|
|
236
|
+
* formatting of all generated files. It processes files through Prettier
|
|
237
|
+
* formatting (if configured), resolves paths, and produces the final
|
|
238
|
+
* artifacts ready for writing to the filesystem.
|
|
239
|
+
*
|
|
240
|
+
* The method is wrapped in Sentry tracing spans for performance monitoring
|
|
241
|
+
* and includes both collation and artifact preparation phases.
|
|
242
|
+
*
|
|
243
|
+
* @returns Promise resolving to render result containing artifacts, file metadata, previews, and mappings
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const renderContext = new RenderContext({
|
|
248
|
+
* files: generatedFiles,
|
|
249
|
+
* previews: previewData,
|
|
250
|
+
* mappings: mappingData,
|
|
251
|
+
* prettierConfig: { semi: false, singleQuote: true },
|
|
252
|
+
* basePath: './src/generated',
|
|
253
|
+
* stackTrail: traceStack,
|
|
254
|
+
* logger: logger,
|
|
255
|
+
* captureCurrentResult: resultHandler
|
|
256
|
+
* });
|
|
257
|
+
*
|
|
258
|
+
* const result = await renderContext.render();
|
|
259
|
+
*
|
|
260
|
+
* // Access rendered files
|
|
261
|
+
* Object.entries(result.artifacts).forEach(([path, content]) => {
|
|
262
|
+
* console.log(`Rendered ${path}: ${result.files[path].lines} lines`);
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
220
266
|
render(): Promise<Omit<RenderResult, 'results'>>;
|
|
267
|
+
/**
|
|
268
|
+
* Collates all files in the context into a unified render result.
|
|
269
|
+
*
|
|
270
|
+
* This method processes each file in the context through the rendering pipeline,
|
|
271
|
+
* applying Prettier formatting and path resolution. It coordinates the parallel
|
|
272
|
+
* processing of all files and aggregates the results into a single output structure.
|
|
273
|
+
*
|
|
274
|
+
* The collation process includes:
|
|
275
|
+
* - File content rendering with optional Prettier formatting
|
|
276
|
+
* - Path resolution using base path configuration
|
|
277
|
+
* - Metadata calculation (line count, character count)
|
|
278
|
+
* - Result aggregation into artifacts and file metadata maps
|
|
279
|
+
*
|
|
280
|
+
* @returns Promise resolving to collated files with artifacts and metadata
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const collated = await renderContext.collate();
|
|
285
|
+
*
|
|
286
|
+
* // Access rendered file content
|
|
287
|
+
* console.log(collated.artifacts['/path/to/file.ts']);
|
|
288
|
+
*
|
|
289
|
+
* // Access file metadata
|
|
290
|
+
* console.log(collated.files['/path/to/file.ts'].lines);
|
|
291
|
+
* console.log(collated.files['/path/to/file.ts'].characters);
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
221
294
|
collate(): Promise<FilesRenderResult>;
|
|
295
|
+
/**
|
|
296
|
+
* Executes a function within a tracing context for performance monitoring.
|
|
297
|
+
*
|
|
298
|
+
* This method wraps function execution with distributed tracing capabilities,
|
|
299
|
+
* allowing performance monitoring and debugging of the rendering pipeline.
|
|
300
|
+
* It integrates with the stack trail to provide hierarchical tracing.
|
|
301
|
+
*
|
|
302
|
+
* @template T - The return type of the traced function
|
|
303
|
+
* @param token - Trace identifier (string or array of strings)
|
|
304
|
+
* @param fn - Function to execute within the trace context
|
|
305
|
+
* @returns The result of executing the traced function
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* const result = renderContext.trace('format-file', () => {
|
|
310
|
+
* return prettier.format(content, prettierConfig);
|
|
311
|
+
* });
|
|
312
|
+
*
|
|
313
|
+
* // With hierarchical tracing
|
|
314
|
+
* const result = renderContext.trace(['render', 'format'], () => {
|
|
315
|
+
* return complexFormattingOperation();
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
222
319
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
320
|
+
/**
|
|
321
|
+
* Retrieves a file from the context by its normalized path.
|
|
322
|
+
*
|
|
323
|
+
* This method looks up a file in the context's file map using path normalization
|
|
324
|
+
* to ensure consistent path resolution. It validates that the requested file
|
|
325
|
+
* exists and throws an error if not found.
|
|
326
|
+
*
|
|
327
|
+
* @param filePath - The file path to retrieve (will be normalized)
|
|
328
|
+
* @returns The File or JsonFile instance
|
|
329
|
+
* @throws {Error} When the file is not found in the context
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* const file = renderContext.getFile('./src/models/User.ts');
|
|
334
|
+
* console.log(file.toString()); // Access file content
|
|
335
|
+
*
|
|
336
|
+
* // Works with various path formats
|
|
337
|
+
* const sameFile = renderContext.getFile('src/models/User.ts');
|
|
338
|
+
* const alsoSameFile = renderContext.getFile('/absolute/path/src/models/User.ts');
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
223
341
|
getFile(filePath: string): File | JsonFile;
|
|
342
|
+
/**
|
|
343
|
+
* Picks a specific definition from a file in the context.
|
|
344
|
+
*
|
|
345
|
+
* This method retrieves a named definition (type, interface, etc.) from
|
|
346
|
+
* a specific file in the context. It validates that the target file is
|
|
347
|
+
* a File type (not JsonFile) and returns the requested definition if found.
|
|
348
|
+
*
|
|
349
|
+
* @param args - Object containing the definition name and export path
|
|
350
|
+
* @param args.name - The name of the definition to retrieve
|
|
351
|
+
* @param args.exportPath - The path to the file containing the definition
|
|
352
|
+
* @returns The Definition instance if found, undefined otherwise
|
|
353
|
+
* @throws {Error} When the file is not found or is not a File type
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* const userDefinition = renderContext.pick({
|
|
358
|
+
* name: 'User',
|
|
359
|
+
* exportPath: './src/models/User.ts'
|
|
360
|
+
* });
|
|
361
|
+
*
|
|
362
|
+
* if (userDefinition) {
|
|
363
|
+
* console.log(userDefinition.identifier); // Access definition details
|
|
364
|
+
* }
|
|
365
|
+
*
|
|
366
|
+
* // Pick interface definition
|
|
367
|
+
* const apiInterface = renderContext.pick({
|
|
368
|
+
* name: 'ApiResponse',
|
|
369
|
+
* exportPath: './src/types/api.ts'
|
|
370
|
+
* });
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
224
373
|
pick({ name, exportPath }: PickArgs): Definition | undefined;
|
|
225
374
|
}
|
|
226
375
|
export {};
|
|
@@ -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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