@skmtc/core 0.0.796 → 0.0.798
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/app/validate.d.ts +32 -0
- package/esm/app/validate.d.ts.map +1 -1
- package/esm/app/validate.js +32 -0
- package/esm/context/CoreContext.d.ts +147 -2
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +87 -0
- package/esm/context/GenerateContext.d.ts +180 -0
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +25 -0
- package/esm/context/ParseContext.d.ts +6 -0
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +6 -0
- package/esm/dsl/constants.d.ts +28 -0
- package/esm/dsl/constants.d.ts.map +1 -1
- package/esm/dsl/constants.js +28 -0
- package/esm/oas/_helpers/parseDefault.d.ts +148 -0
- package/esm/oas/_helpers/parseDefault.d.ts.map +1 -1
- package/esm/oas/_helpers/parseDefault.js +128 -0
- package/esm/oas/_helpers/parseEnum.d.ts +124 -0
- package/esm/oas/_helpers/parseEnum.d.ts.map +1 -1
- package/esm/oas/_helpers/parseEnum.js +104 -0
- package/esm/oas/_helpers/parseExample.d.ts +107 -0
- package/esm/oas/_helpers/parseExample.d.ts.map +1 -1
- package/esm/oas/_helpers/parseExample.js +87 -0
- package/esm/oas/_helpers/parseFormat.d.ts +154 -0
- package/esm/oas/_helpers/parseFormat.d.ts.map +1 -1
- package/esm/oas/_helpers/parseFormat.js +138 -0
- package/esm/oas/_helpers/parseNullable.d.ts +127 -0
- package/esm/oas/_helpers/parseNullable.d.ts.map +1 -1
- package/esm/oas/_helpers/parseNullable.js +113 -0
- package/esm/oas/example/toExamplesV3.d.ts +39 -0
- package/esm/oas/example/toExamplesV3.d.ts.map +1 -1
- package/esm/oas/example/toExamplesV3.js +29 -0
- package/esm/oas/object/Object.d.ts +6 -0
- package/esm/oas/object/Object.d.ts.map +1 -1
- package/esm/oas/object/Object.js +6 -0
- package/esm/oas/operation/Operation.d.ts +34 -0
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +14 -0
- package/esm/oas/parameter/Parameter.d.ts +3 -0
- package/esm/oas/parameter/Parameter.d.ts.map +1 -1
- package/esm/oas/parameter/Parameter.js +3 -0
- package/esm/oas/ref/ref-types.d.ts +42 -0
- package/esm/oas/ref/ref-types.d.ts.map +1 -1
- package/esm/oas/ref/ref-types.js +9 -0
- package/esm/oas/securitySchemes/security-scheme-types.d.ts +63 -0
- package/esm/oas/securitySchemes/security-scheme-types.d.ts.map +1 -1
- package/esm/oas/securitySchemes/security-scheme-types.js +15 -0
- package/esm/run/toV3JsonDocument.d.ts +90 -0
- package/esm/run/toV3JsonDocument.d.ts.map +1 -1
- package/esm/run/toV3JsonDocument.js +84 -0
- package/esm/types/Results.d.ts +32 -0
- package/esm/types/Results.d.ts.map +1 -1
- package/esm/types/Results.js +12 -0
- package/package.json +1 -1
- package/script/app/validate.d.ts +32 -0
- package/script/app/validate.d.ts.map +1 -1
- package/script/app/validate.js +32 -0
- package/script/context/CoreContext.d.ts +147 -2
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +87 -0
- package/script/context/GenerateContext.d.ts +180 -0
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +25 -0
- package/script/context/ParseContext.d.ts +6 -0
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +6 -0
- package/script/dsl/constants.d.ts +28 -0
- package/script/dsl/constants.d.ts.map +1 -1
- package/script/dsl/constants.js +28 -0
- package/script/oas/_helpers/parseDefault.d.ts +148 -0
- package/script/oas/_helpers/parseDefault.d.ts.map +1 -1
- package/script/oas/_helpers/parseDefault.js +128 -0
- package/script/oas/_helpers/parseEnum.d.ts +124 -0
- package/script/oas/_helpers/parseEnum.d.ts.map +1 -1
- package/script/oas/_helpers/parseEnum.js +104 -0
- package/script/oas/_helpers/parseExample.d.ts +107 -0
- package/script/oas/_helpers/parseExample.d.ts.map +1 -1
- package/script/oas/_helpers/parseExample.js +87 -0
- package/script/oas/_helpers/parseFormat.d.ts +154 -0
- package/script/oas/_helpers/parseFormat.d.ts.map +1 -1
- package/script/oas/_helpers/parseFormat.js +138 -0
- package/script/oas/_helpers/parseNullable.d.ts +127 -0
- package/script/oas/_helpers/parseNullable.d.ts.map +1 -1
- package/script/oas/_helpers/parseNullable.js +113 -0
- package/script/oas/example/toExamplesV3.d.ts +39 -0
- package/script/oas/example/toExamplesV3.d.ts.map +1 -1
- package/script/oas/example/toExamplesV3.js +29 -0
- package/script/oas/object/Object.d.ts +6 -0
- package/script/oas/object/Object.d.ts.map +1 -1
- package/script/oas/object/Object.js +6 -0
- package/script/oas/operation/Operation.d.ts +34 -0
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +14 -0
- package/script/oas/parameter/Parameter.d.ts +3 -0
- package/script/oas/parameter/Parameter.d.ts.map +1 -1
- package/script/oas/parameter/Parameter.js +3 -0
- package/script/oas/ref/ref-types.d.ts +42 -0
- package/script/oas/ref/ref-types.d.ts.map +1 -1
- package/script/oas/ref/ref-types.js +9 -0
- package/script/oas/securitySchemes/security-scheme-types.d.ts +63 -0
- package/script/oas/securitySchemes/security-scheme-types.d.ts.map +1 -1
- package/script/oas/securitySchemes/security-scheme-types.js +15 -0
- package/script/run/toV3JsonDocument.d.ts +90 -0
- package/script/run/toV3JsonDocument.d.ts.map +1 -1
- package/script/run/toV3JsonDocument.js +84 -0
- package/script/types/Results.d.ts +32 -0
- package/script/types/Results.d.ts.map +1 -1
- package/script/types/Results.js +12 -0
package/esm/types/Results.d.ts
CHANGED
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
/**
|
|
4
|
+
* Type representing the possible outcomes of SKMTC processing operations.
|
|
5
|
+
*
|
|
6
|
+
* Used throughout the SKMTC pipeline to track and categorize the results
|
|
7
|
+
* of parsing, generation, and rendering operations.
|
|
8
|
+
*/
|
|
3
9
|
export type ResultType = 'success' | 'warning' | 'error' | 'skipped' | 'notSupported';
|
|
10
|
+
/**
|
|
11
|
+
* Type representing result types that indicate issues or problems.
|
|
12
|
+
*
|
|
13
|
+
* Used for filtering and handling results that require attention,
|
|
14
|
+
* excluding successful, skipped, or unsupported operations.
|
|
15
|
+
*/
|
|
4
16
|
export type WarningError = 'warning' | 'error';
|
|
17
|
+
/**
|
|
18
|
+
* Valibot schema for validating ResultType values.
|
|
19
|
+
*
|
|
20
|
+
* Used for runtime validation of result type values throughout
|
|
21
|
+
* the SKMTC pipeline to ensure type safety and data integrity.
|
|
22
|
+
*/
|
|
5
23
|
export declare const resultType: v.GenericSchema<ResultType>;
|
|
24
|
+
/**
|
|
25
|
+
* Interface representing a hierarchical results structure.
|
|
26
|
+
*
|
|
27
|
+
* Allows for nested result tracking where each key can contain
|
|
28
|
+
* a result type, another results item (for nesting), or an array
|
|
29
|
+
* of results items for collections.
|
|
30
|
+
*/
|
|
6
31
|
export interface ResultsItem {
|
|
32
|
+
/** Dynamic key-value pairs for hierarchical result tracking */
|
|
7
33
|
[key: string]: ResultType | ResultsItem | Array<ResultsItem | null>;
|
|
8
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Valibot schema for validating ResultsItem structures.
|
|
37
|
+
*
|
|
38
|
+
* Uses lazy evaluation to handle recursive result item validation,
|
|
39
|
+
* supporting nested hierarchical result structures.
|
|
40
|
+
*/
|
|
9
41
|
export declare const resultsItem: v.GenericSchema<ResultsItem>;
|
|
10
42
|
//# sourceMappingURL=Results.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Results.d.ts","sourceRoot":"","sources":["../../src/types/Results.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAA;AAErF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAE9C,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,CAMjD,CAAA;AAEF,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;CACpE;AAED,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,aAAa,CAAC,WAAW,CAGpD,CAAA"}
|
|
1
|
+
{"version":3,"file":"Results.d.ts","sourceRoot":"","sources":["../../src/types/Results.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAA;AAErF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,CAMjD,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;CACpE;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,aAAa,CAAC,WAAW,CAGpD,CAAA"}
|
package/esm/types/Results.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
/**
|
|
4
|
+
* Valibot schema for validating ResultType values.
|
|
5
|
+
*
|
|
6
|
+
* Used for runtime validation of result type values throughout
|
|
7
|
+
* the SKMTC pipeline to ensure type safety and data integrity.
|
|
8
|
+
*/
|
|
3
9
|
export const resultType = v.union([
|
|
4
10
|
v.literal('success'),
|
|
5
11
|
v.literal('warning'),
|
|
@@ -7,4 +13,10 @@ export const resultType = v.union([
|
|
|
7
13
|
v.literal('skipped'),
|
|
8
14
|
v.literal('notSupported')
|
|
9
15
|
]);
|
|
16
|
+
/**
|
|
17
|
+
* Valibot schema for validating ResultsItem structures.
|
|
18
|
+
*
|
|
19
|
+
* Uses lazy evaluation to handle recursive result item validation,
|
|
20
|
+
* supporting nested hierarchical result structures.
|
|
21
|
+
*/
|
|
10
22
|
export const resultsItem = v.record(v.string(), v.lazy(() => v.union([resultsItem, resultType, v.array(v.lazy(() => resultsItem))])));
|
package/package.json
CHANGED
package/script/app/validate.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a project name against SKMTC naming conventions.
|
|
3
|
+
*
|
|
4
|
+
* Ensures project names follow standard naming patterns suitable for package
|
|
5
|
+
* managers and file systems. Names must be lowercase, contain only letters,
|
|
6
|
+
* numbers, and hyphens, with specific length and format requirements.
|
|
7
|
+
*
|
|
8
|
+
* @param name - The project name to validate
|
|
9
|
+
* @returns An error message string if validation fails, undefined if valid
|
|
10
|
+
*
|
|
11
|
+
* @example Valid project names
|
|
12
|
+
* ```typescript
|
|
13
|
+
* checkProjectName('my-api-client'); // undefined (valid)
|
|
14
|
+
* checkProjectName('user-service'); // undefined (valid)
|
|
15
|
+
* checkProjectName('api2'); // undefined (valid)
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example Invalid project names
|
|
19
|
+
* ```typescript
|
|
20
|
+
* checkProjectName('A'); // 'Name must be at least 2 characters long'
|
|
21
|
+
* checkProjectName('My-API-Client'); // 'Name must only contain lowercase letters, numbers and hyphens'
|
|
22
|
+
* checkProjectName('-api-client'); // 'Name cannot start with a hyphen'
|
|
23
|
+
* checkProjectName('api-client-'); // 'Name cannot end with a hyphen'
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Validation rules
|
|
27
|
+
* - Minimum length: 2 characters
|
|
28
|
+
* - Maximum length: 20 characters
|
|
29
|
+
* - Allowed characters: a-z, 0-9, hyphens (-)
|
|
30
|
+
* - Cannot start or end with hyphen
|
|
31
|
+
* - Must be lowercase only
|
|
32
|
+
*/
|
|
1
33
|
import "../_dnt.polyfills.js";
|
|
2
34
|
export declare const checkProjectName: (name: string) => string | undefined;
|
|
3
35
|
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/app/validate.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/app/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,sBAAsB,CAAC;AAE9B,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SAoBxD,CAAA"}
|
package/script/app/validate.js
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkProjectName = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Validates a project name against SKMTC naming conventions.
|
|
6
|
+
*
|
|
7
|
+
* Ensures project names follow standard naming patterns suitable for package
|
|
8
|
+
* managers and file systems. Names must be lowercase, contain only letters,
|
|
9
|
+
* numbers, and hyphens, with specific length and format requirements.
|
|
10
|
+
*
|
|
11
|
+
* @param name - The project name to validate
|
|
12
|
+
* @returns An error message string if validation fails, undefined if valid
|
|
13
|
+
*
|
|
14
|
+
* @example Valid project names
|
|
15
|
+
* ```typescript
|
|
16
|
+
* checkProjectName('my-api-client'); // undefined (valid)
|
|
17
|
+
* checkProjectName('user-service'); // undefined (valid)
|
|
18
|
+
* checkProjectName('api2'); // undefined (valid)
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example Invalid project names
|
|
22
|
+
* ```typescript
|
|
23
|
+
* checkProjectName('A'); // 'Name must be at least 2 characters long'
|
|
24
|
+
* checkProjectName('My-API-Client'); // 'Name must only contain lowercase letters, numbers and hyphens'
|
|
25
|
+
* checkProjectName('-api-client'); // 'Name cannot start with a hyphen'
|
|
26
|
+
* checkProjectName('api-client-'); // 'Name cannot end with a hyphen'
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example Validation rules
|
|
30
|
+
* - Minimum length: 2 characters
|
|
31
|
+
* - Maximum length: 20 characters
|
|
32
|
+
* - Allowed characters: a-z, 0-9, hyphens (-)
|
|
33
|
+
* - Cannot start or end with hyphen
|
|
34
|
+
* - Must be lowercase only
|
|
35
|
+
*/
|
|
4
36
|
require("../_dnt.polyfills.js");
|
|
5
37
|
const checkProjectName = (name) => {
|
|
6
38
|
if (name.length < 2) {
|
|
@@ -9,29 +9,70 @@ import * as log from '../deps/jsr.io/@std/log/0.224.14/mod.js';
|
|
|
9
9
|
import type { GeneratorsMapContainer } from '../types/GeneratorType.js';
|
|
10
10
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
11
11
|
import type { RenderResult } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Represents the parse phase of the SKMTC pipeline.
|
|
14
|
+
*
|
|
15
|
+
* The parse phase converts OpenAPI v3 JSON documents into internal OAS objects,
|
|
16
|
+
* handling schema validation, reference resolution, and data transformation.
|
|
17
|
+
*/
|
|
12
18
|
export type ParsePhase = {
|
|
19
|
+
/** Identifies this as the parse phase */
|
|
13
20
|
type: 'parse';
|
|
21
|
+
/** The parse context containing parsed document and utilities */
|
|
14
22
|
context: ParseContext;
|
|
15
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Represents the generate phase of the SKMTC pipeline.
|
|
26
|
+
*
|
|
27
|
+
* The generate phase transforms parsed OAS objects into generator-specific artifacts,
|
|
28
|
+
* applying templates, handling references, and preparing output files.
|
|
29
|
+
*/
|
|
16
30
|
export type GeneratePhase = {
|
|
31
|
+
/** Identifies this as the generate phase */
|
|
17
32
|
type: 'generate';
|
|
33
|
+
/** The generate context for artifact creation and processing */
|
|
18
34
|
context: GenerateContext;
|
|
19
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Represents the render phase of the SKMTC pipeline.
|
|
38
|
+
*
|
|
39
|
+
* The render phase takes generator artifacts and renders them to formatted files,
|
|
40
|
+
* applying code formatting, file system operations, and final output generation.
|
|
41
|
+
*/
|
|
20
42
|
export type RenderPhase = {
|
|
43
|
+
/** Identifies this as the render phase */
|
|
21
44
|
type: 'render';
|
|
45
|
+
/** The render context for file output and formatting */
|
|
22
46
|
context: RenderContext;
|
|
23
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Union type representing any phase of the SKMTC pipeline execution.
|
|
50
|
+
*
|
|
51
|
+
* Each execution phase contains its type identifier and associated context,
|
|
52
|
+
* allowing for type-safe phase handling and context access throughout the pipeline.
|
|
53
|
+
*/
|
|
24
54
|
export type ExecutionPhase = ParsePhase | GeneratePhase | RenderPhase;
|
|
25
55
|
type CoreContextArgs = {
|
|
26
56
|
spanId: string;
|
|
27
57
|
logsPath?: string;
|
|
28
58
|
silent: boolean;
|
|
29
59
|
};
|
|
30
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Arguments for the `toArtifacts` method of CoreContext.
|
|
62
|
+
*
|
|
63
|
+
* Contains all the necessary configuration for transforming an OpenAPI document
|
|
64
|
+
* into code artifacts through the SKMTC pipeline.
|
|
65
|
+
*/
|
|
66
|
+
export type ToArtifactsArgs = {
|
|
67
|
+
/** The OpenAPI v3 document to process */
|
|
31
68
|
documentObject: OpenAPIV3.Document;
|
|
69
|
+
/** Client settings for customization (optional) */
|
|
32
70
|
settings: ClientSettings | undefined;
|
|
71
|
+
/** Function that returns the generator configuration map */
|
|
33
72
|
toGeneratorConfigMap: <EnrichmentType = undefined>() => GeneratorsMapContainer<EnrichmentType>;
|
|
73
|
+
/** Prettier configuration for code formatting (optional) */
|
|
34
74
|
prettier?: PrettierConfigType;
|
|
75
|
+
/** Whether to suppress console output */
|
|
35
76
|
silent: boolean;
|
|
36
77
|
};
|
|
37
78
|
/**
|
|
@@ -218,13 +259,117 @@ export declare class CoreContext {
|
|
|
218
259
|
* @throws Will throw an error if any phase of the pipeline fails
|
|
219
260
|
*/
|
|
220
261
|
toArtifacts({ documentObject, settings, toGeneratorConfigMap, prettier }: ToArtifactsArgs): Promise<RenderResult>;
|
|
262
|
+
/**
|
|
263
|
+
* Executes a function with distributed tracing and logging.
|
|
264
|
+
*
|
|
265
|
+
* This method wraps function execution with tracing capabilities, updating the
|
|
266
|
+
* stack trail for context tracking and logging execution details. It's used
|
|
267
|
+
* throughout the SKMTC pipeline to maintain execution context and debugging information.
|
|
268
|
+
*
|
|
269
|
+
* @template T - The return type of the traced function
|
|
270
|
+
* @param token - Single token or array of tokens to add to the trace stack
|
|
271
|
+
* @param fn - The function to execute within the trace context
|
|
272
|
+
* @returns The result of executing the traced function
|
|
273
|
+
*
|
|
274
|
+
* @example Single token tracing
|
|
275
|
+
* ```typescript
|
|
276
|
+
* const result = context.trace('parse-schema', () => {
|
|
277
|
+
* // Schema parsing logic here
|
|
278
|
+
* return parsedSchema;
|
|
279
|
+
* });
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* @example Multiple token tracing (nested context)
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const result = context.trace(['components', 'schemas', 'User'], () => {
|
|
285
|
+
* // Process User schema
|
|
286
|
+
* return processedUserSchema;
|
|
287
|
+
* });
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
221
290
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
291
|
+
/**
|
|
292
|
+
* Captures a result at the current execution position in the stack trail.
|
|
293
|
+
*
|
|
294
|
+
* This method records processing results (success, warning, error, etc.) at the
|
|
295
|
+
* current location in the document traversal stack. Results are associated with
|
|
296
|
+
* the current stack trail position, enabling detailed error reporting and
|
|
297
|
+
* debugging of OpenAPI processing issues.
|
|
298
|
+
*
|
|
299
|
+
* @param result - The type of result to capture (success, warning, error, etc.)
|
|
300
|
+
*
|
|
301
|
+
* @example Capturing a warning result
|
|
302
|
+
* ```typescript
|
|
303
|
+
* context.captureCurrentResult('warning');
|
|
304
|
+
* // Result captured at current stack position like: "components.schemas.User.properties.email"
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @example Usage during schema processing
|
|
308
|
+
* ```typescript
|
|
309
|
+
* context.trace(['components', 'schemas', 'User'], () => {
|
|
310
|
+
* try {
|
|
311
|
+
* processUserSchema();
|
|
312
|
+
* context.captureCurrentResult('success');
|
|
313
|
+
* } catch (error) {
|
|
314
|
+
* context.captureCurrentResult('error');
|
|
315
|
+
* }
|
|
316
|
+
* });
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
222
319
|
captureCurrentResult(result: ResultType): void;
|
|
223
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Arguments for the SKMTC JSON log formatter.
|
|
323
|
+
*
|
|
324
|
+
* Contains the log record and stack trail information needed to format
|
|
325
|
+
* structured JSON log entries for the SKMTC processing pipeline.
|
|
326
|
+
*/
|
|
224
327
|
export type JsonFormatterArgs = {
|
|
225
|
-
|
|
328
|
+
/** The Deno log record containing log level, message, and metadata */
|
|
329
|
+
logRecord: {
|
|
330
|
+
/** The log level name */
|
|
331
|
+
levelName: string;
|
|
332
|
+
/** The timestamp when the log was created */
|
|
333
|
+
datetime: Date;
|
|
334
|
+
/** The log message */
|
|
335
|
+
msg: string;
|
|
336
|
+
/** Additional log arguments */
|
|
337
|
+
args: unknown[];
|
|
338
|
+
};
|
|
339
|
+
/** String representation of the current stack trail position */
|
|
226
340
|
stackTrail: string;
|
|
227
341
|
};
|
|
342
|
+
/**
|
|
343
|
+
* Custom JSON formatter for SKMTC log entries.
|
|
344
|
+
*
|
|
345
|
+
* Formats log records into structured JSON that includes stack trail context,
|
|
346
|
+
* making it easier to trace execution and debug issues in the SKMTC pipeline.
|
|
347
|
+
* The formatter flattens log arguments and includes execution context.
|
|
348
|
+
*
|
|
349
|
+
* @param args - Formatter arguments containing log record and stack trail
|
|
350
|
+
* @returns Formatted JSON string for the log entry
|
|
351
|
+
*
|
|
352
|
+
* @example Usage in logger setup
|
|
353
|
+
* ```typescript
|
|
354
|
+
* const handler = new ConsoleHandler("DEBUG", {
|
|
355
|
+
* formatter: (logRecord) => skmtcFormatter({
|
|
356
|
+
* logRecord,
|
|
357
|
+
* stackTrail: context.stackTrail.toString()
|
|
358
|
+
* })
|
|
359
|
+
* });
|
|
360
|
+
* ```
|
|
361
|
+
*
|
|
362
|
+
* @example Output format
|
|
363
|
+
* ```json
|
|
364
|
+
* {
|
|
365
|
+
* "stackTrail": "components.schemas.User.properties.email",
|
|
366
|
+
* "level": "INFO",
|
|
367
|
+
* "datetime": 1645123456789,
|
|
368
|
+
* "message": "Processing email property",
|
|
369
|
+
* "args": { "format": "email", "required": true }
|
|
370
|
+
* }
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
228
373
|
export declare function skmtcFormatter({ logRecord, stackTrail }: JsonFormatterArgs): string;
|
|
229
374
|
export {};
|
|
230
375
|
//# sourceMappingURL=CoreContext.d.ts.map
|
|
@@ -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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sBAAsB;QACtB,GAAG,EAAE,MAAM,CAAA;QACX,+BAA+B;QAC/B,IAAI,EAAE,OAAO,EAAE,CAAA;KAChB,CAAA;IACD,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAQnF"}
|
|
@@ -315,11 +315,67 @@ class CoreContext {
|
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Executes a function with distributed tracing and logging.
|
|
320
|
+
*
|
|
321
|
+
* This method wraps function execution with tracing capabilities, updating the
|
|
322
|
+
* stack trail for context tracking and logging execution details. It's used
|
|
323
|
+
* throughout the SKMTC pipeline to maintain execution context and debugging information.
|
|
324
|
+
*
|
|
325
|
+
* @template T - The return type of the traced function
|
|
326
|
+
* @param token - Single token or array of tokens to add to the trace stack
|
|
327
|
+
* @param fn - The function to execute within the trace context
|
|
328
|
+
* @returns The result of executing the traced function
|
|
329
|
+
*
|
|
330
|
+
* @example Single token tracing
|
|
331
|
+
* ```typescript
|
|
332
|
+
* const result = context.trace('parse-schema', () => {
|
|
333
|
+
* // Schema parsing logic here
|
|
334
|
+
* return parsedSchema;
|
|
335
|
+
* });
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @example Multiple token tracing (nested context)
|
|
339
|
+
* ```typescript
|
|
340
|
+
* const result = context.trace(['components', 'schemas', 'User'], () => {
|
|
341
|
+
* // Process User schema
|
|
342
|
+
* return processedUserSchema;
|
|
343
|
+
* });
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
318
346
|
trace(token, fn) {
|
|
319
347
|
console.log('trace', token);
|
|
320
348
|
this.logger.info('trace', token);
|
|
321
349
|
return (0, tracer_js_1.tracer)(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f"), token, fn, this.logger);
|
|
322
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Captures a result at the current execution position in the stack trail.
|
|
353
|
+
*
|
|
354
|
+
* This method records processing results (success, warning, error, etc.) at the
|
|
355
|
+
* current location in the document traversal stack. Results are associated with
|
|
356
|
+
* the current stack trail position, enabling detailed error reporting and
|
|
357
|
+
* debugging of OpenAPI processing issues.
|
|
358
|
+
*
|
|
359
|
+
* @param result - The type of result to capture (success, warning, error, etc.)
|
|
360
|
+
*
|
|
361
|
+
* @example Capturing a warning result
|
|
362
|
+
* ```typescript
|
|
363
|
+
* context.captureCurrentResult('warning');
|
|
364
|
+
* // Result captured at current stack position like: "components.schemas.User.properties.email"
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* @example Usage during schema processing
|
|
368
|
+
* ```typescript
|
|
369
|
+
* context.trace(['components', 'schemas', 'User'], () => {
|
|
370
|
+
* try {
|
|
371
|
+
* processUserSchema();
|
|
372
|
+
* context.captureCurrentResult('success');
|
|
373
|
+
* } catch (error) {
|
|
374
|
+
* context.captureCurrentResult('error');
|
|
375
|
+
* }
|
|
376
|
+
* });
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
323
379
|
captureCurrentResult(result) {
|
|
324
380
|
__classPrivateFieldGet(this, _CoreContext_results, "f").capture(__classPrivateFieldGet(this, _CoreContext_stackTrail, "f").toString(), result);
|
|
325
381
|
}
|
|
@@ -392,6 +448,37 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
392
448
|
});
|
|
393
449
|
return { type: 'render', context: renderContext };
|
|
394
450
|
};
|
|
451
|
+
/**
|
|
452
|
+
* Custom JSON formatter for SKMTC log entries.
|
|
453
|
+
*
|
|
454
|
+
* Formats log records into structured JSON that includes stack trail context,
|
|
455
|
+
* making it easier to trace execution and debug issues in the SKMTC pipeline.
|
|
456
|
+
* The formatter flattens log arguments and includes execution context.
|
|
457
|
+
*
|
|
458
|
+
* @param args - Formatter arguments containing log record and stack trail
|
|
459
|
+
* @returns Formatted JSON string for the log entry
|
|
460
|
+
*
|
|
461
|
+
* @example Usage in logger setup
|
|
462
|
+
* ```typescript
|
|
463
|
+
* const handler = new ConsoleHandler("DEBUG", {
|
|
464
|
+
* formatter: (logRecord) => skmtcFormatter({
|
|
465
|
+
* logRecord,
|
|
466
|
+
* stackTrail: context.stackTrail.toString()
|
|
467
|
+
* })
|
|
468
|
+
* });
|
|
469
|
+
* ```
|
|
470
|
+
*
|
|
471
|
+
* @example Output format
|
|
472
|
+
* ```json
|
|
473
|
+
* {
|
|
474
|
+
* "stackTrail": "components.schemas.User.properties.email",
|
|
475
|
+
* "level": "INFO",
|
|
476
|
+
* "datetime": 1645123456789,
|
|
477
|
+
* "message": "Processing email property",
|
|
478
|
+
* "args": { "format": "email", "required": true }
|
|
479
|
+
* }
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
395
482
|
function skmtcFormatter({ logRecord, stackTrail }) {
|
|
396
483
|
return JSON.stringify({
|
|
397
484
|
stackTrail,
|