@skmtc/core 0.0.793 → 0.0.795
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/StackTrail.d.ts +293 -0
- package/esm/context/StackTrail.d.ts.map +1 -1
- package/esm/context/StackTrail.js +294 -0
- package/esm/helpers/ResultsLog.d.ts +193 -0
- package/esm/helpers/ResultsLog.d.ts.map +1 -1
- package/esm/helpers/ResultsLog.js +213 -0
- package/esm/helpers/tracer.d.ts +124 -0
- package/esm/helpers/tracer.d.ts.map +1 -1
- package/esm/helpers/tracer.js +124 -0
- package/esm/types/Modifiers.d.ts +68 -0
- package/esm/types/Modifiers.d.ts.map +1 -1
- package/esm/types/TypeSystem.d.ts +419 -0
- package/esm/types/TypeSystem.d.ts.map +1 -1
- package/esm/typescript/FunctionParameter.d.ts +313 -0
- package/esm/typescript/FunctionParameter.d.ts.map +1 -1
- package/esm/typescript/FunctionParameter.js +328 -0
- package/esm/typescript/PathParams.d.ts +198 -0
- package/esm/typescript/PathParams.d.ts.map +1 -1
- package/esm/typescript/PathParams.js +190 -0
- package/esm/typescript/ReactRouterPathParams.d.ts +190 -0
- package/esm/typescript/ReactRouterPathParams.d.ts.map +1 -1
- package/esm/typescript/ReactRouterPathParams.js +183 -0
- package/esm/typescript/keyValues.d.ts +125 -0
- package/esm/typescript/keyValues.d.ts.map +1 -1
- package/esm/typescript/keyValues.js +125 -1
- package/esm/typescript/toPathParams.d.ts +179 -0
- package/esm/typescript/toPathParams.d.ts.map +1 -1
- package/esm/typescript/toPathParams.js +179 -0
- package/esm/typescript/toPathTemplate.d.ts +114 -0
- package/esm/typescript/toPathTemplate.d.ts.map +1 -1
- package/esm/typescript/toPathTemplate.js +114 -0
- package/package.json +1 -1
- package/script/context/StackTrail.d.ts +293 -0
- package/script/context/StackTrail.d.ts.map +1 -1
- package/script/context/StackTrail.js +294 -0
- package/script/helpers/ResultsLog.d.ts +193 -0
- package/script/helpers/ResultsLog.d.ts.map +1 -1
- package/script/helpers/ResultsLog.js +213 -0
- package/script/helpers/tracer.d.ts +124 -0
- package/script/helpers/tracer.d.ts.map +1 -1
- package/script/helpers/tracer.js +124 -0
- package/script/types/Modifiers.d.ts +68 -0
- package/script/types/Modifiers.d.ts.map +1 -1
- package/script/types/TypeSystem.d.ts +419 -0
- package/script/types/TypeSystem.d.ts.map +1 -1
- package/script/typescript/FunctionParameter.d.ts +313 -0
- package/script/typescript/FunctionParameter.d.ts.map +1 -1
- package/script/typescript/FunctionParameter.js +328 -0
- package/script/typescript/PathParams.d.ts +198 -0
- package/script/typescript/PathParams.d.ts.map +1 -1
- package/script/typescript/PathParams.js +190 -0
- package/script/typescript/ReactRouterPathParams.d.ts +190 -0
- package/script/typescript/ReactRouterPathParams.d.ts.map +1 -1
- package/script/typescript/ReactRouterPathParams.js +183 -0
- package/script/typescript/keyValues.d.ts +125 -0
- package/script/typescript/keyValues.d.ts.map +1 -1
- package/script/typescript/keyValues.js +125 -1
- package/script/typescript/toPathParams.d.ts +179 -0
- package/script/typescript/toPathParams.d.ts.map +1 -1
- package/script/typescript/toPathParams.js +179 -0
- package/script/typescript/toPathTemplate.d.ts +114 -0
- package/script/typescript/toPathTemplate.d.ts.map +1 -1
- package/script/typescript/toPathTemplate.js +114 -0
package/esm/helpers/tracer.js
CHANGED
|
@@ -1,3 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes a function with distributed tracing support and stack trail management.
|
|
3
|
+
*
|
|
4
|
+
* This utility function provides distributed tracing capabilities for the SKMTC
|
|
5
|
+
* generation pipeline. It manages stack trail tokens that help track execution
|
|
6
|
+
* context across complex nested operations, making debugging and performance
|
|
7
|
+
* analysis much easier.
|
|
8
|
+
*
|
|
9
|
+
* The tracer ensures proper cleanup of stack trail tokens even if the wrapped
|
|
10
|
+
* function throws an error, maintaining the integrity of the tracing system.
|
|
11
|
+
* This is essential for accurate debugging and performance monitoring in
|
|
12
|
+
* complex code generation scenarios.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The return type of the traced function
|
|
15
|
+
* @param stackTrail - The stack trail instance for tracking execution context
|
|
16
|
+
* @param token - Token(s) to identify this execution step in traces
|
|
17
|
+
* @param fn - The function to execute with tracing
|
|
18
|
+
* @param log - Logger instance for error reporting
|
|
19
|
+
* @returns The result of the wrapped function execution
|
|
20
|
+
*
|
|
21
|
+
* @throws Re-throws any error from the wrapped function after cleanup
|
|
22
|
+
*
|
|
23
|
+
* @example Basic tracing usage
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { tracer } from '@skmtc/core';
|
|
26
|
+
*
|
|
27
|
+
* class ModelGenerator {
|
|
28
|
+
* generateModel(stackTrail: StackTrail, logger: Logger) {
|
|
29
|
+
* return tracer(stackTrail, 'generate-model', () => {
|
|
30
|
+
* // Complex model generation logic here
|
|
31
|
+
* return this.createModelDefinition();
|
|
32
|
+
* }, logger);
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example Nested tracing
|
|
38
|
+
* ```typescript
|
|
39
|
+
* class ComplexProcessor {
|
|
40
|
+
* processSchema(stackTrail: StackTrail, logger: Logger) {
|
|
41
|
+
* return tracer(stackTrail, 'process-schema', () => {
|
|
42
|
+
* const parsed = tracer(stackTrail, 'parse', () => {
|
|
43
|
+
* return this.parseSchema();
|
|
44
|
+
* }, logger);
|
|
45
|
+
*
|
|
46
|
+
* const validated = tracer(stackTrail, 'validate', () => {
|
|
47
|
+
* return this.validateSchema(parsed);
|
|
48
|
+
* }, logger);
|
|
49
|
+
*
|
|
50
|
+
* return tracer(stackTrail, 'transform', () => {
|
|
51
|
+
* return this.transformSchema(validated);
|
|
52
|
+
* }, logger);
|
|
53
|
+
* }, logger);
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* // Stack trail will show: ['process-schema', 'parse'] -> ['process-schema', 'validate'] -> ['process-schema', 'transform']
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example Multiple token tracing
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const result = tracer(
|
|
63
|
+
* stackTrail,
|
|
64
|
+
* ['file-generation', 'models.ts'], // Multiple tokens for detailed context
|
|
65
|
+
* () => {
|
|
66
|
+
* return generateModelsFile();
|
|
67
|
+
* },
|
|
68
|
+
* logger
|
|
69
|
+
* );
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example Error handling with tracing
|
|
73
|
+
* ```typescript
|
|
74
|
+
* class SafeGenerator {
|
|
75
|
+
* generateWithTracing(stackTrail: StackTrail, logger: Logger) {
|
|
76
|
+
* try {
|
|
77
|
+
* return tracer(stackTrail, 'risky-operation', () => {
|
|
78
|
+
* // This might throw an error
|
|
79
|
+
* return this.complexGeneration();
|
|
80
|
+
* }, logger);
|
|
81
|
+
* } catch (error) {
|
|
82
|
+
* // Stack trail is automatically cleaned up
|
|
83
|
+
* logger.error(`Generation failed: ${error.message}`);
|
|
84
|
+
* return this.fallbackGeneration();
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @example Performance monitoring
|
|
91
|
+
* ```typescript
|
|
92
|
+
* class PerformanceAwareGenerator {
|
|
93
|
+
* timedGeneration(stackTrail: StackTrail, logger: Logger) {
|
|
94
|
+
* const startTime = Date.now();
|
|
95
|
+
*
|
|
96
|
+
* const result = tracer(stackTrail, 'timed-generation', () => {
|
|
97
|
+
* return this.heavyComputation();
|
|
98
|
+
* }, logger);
|
|
99
|
+
*
|
|
100
|
+
* const duration = Date.now() - startTime;
|
|
101
|
+
* logger.info(`Generation completed in ${duration}ms`);
|
|
102
|
+
*
|
|
103
|
+
* return result;
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example Integration with context classes
|
|
109
|
+
* ```typescript
|
|
110
|
+
* // Typically used within context classes like this:
|
|
111
|
+
* class GenerateContext {
|
|
112
|
+
* trace<T>(token: string | string[], fn: () => T): T {
|
|
113
|
+
* return tracer(this.stackTrail, token, fn, this.logger);
|
|
114
|
+
* }
|
|
115
|
+
*
|
|
116
|
+
* processModel(schema: OasSchema) {
|
|
117
|
+
* return this.trace(['model', schema.type], () => {
|
|
118
|
+
* // Model processing logic
|
|
119
|
+
* return this.createModel(schema);
|
|
120
|
+
* });
|
|
121
|
+
* }
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
1
125
|
export const tracer = (stackTrail, token, fn, log) => {
|
|
2
126
|
stackTrail.append(token);
|
|
3
127
|
try {
|
package/esm/types/Modifiers.d.ts
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type modifiers used throughout the SKMTC type system.
|
|
3
|
+
*
|
|
4
|
+
* `Modifiers` represent additional metadata and constraints that can be
|
|
5
|
+
* applied to type system values. These modifiers affect how types are
|
|
6
|
+
* generated and used in the target language output.
|
|
7
|
+
*
|
|
8
|
+
* @example Basic usage
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { Modifiers } from '@skmtc/core';
|
|
11
|
+
*
|
|
12
|
+
* const stringModifiers: Modifiers = {
|
|
13
|
+
* required: true,
|
|
14
|
+
* nullable: false,
|
|
15
|
+
* description: 'User email address'
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* const optionalModifiers: Modifiers = {
|
|
19
|
+
* required: false,
|
|
20
|
+
* nullable: true,
|
|
21
|
+
* description: 'Optional user profile image URL'
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example In type system values
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const emailField: TypeSystemString = {
|
|
28
|
+
* type: 'string',
|
|
29
|
+
* format: 'email',
|
|
30
|
+
* enums: undefined,
|
|
31
|
+
* modifiers: {
|
|
32
|
+
* required: true,
|
|
33
|
+
* nullable: false,
|
|
34
|
+
* description: 'Valid email address for account registration'
|
|
35
|
+
* }
|
|
36
|
+
* };
|
|
37
|
+
*
|
|
38
|
+
* const optionalNote: TypeSystemString = {
|
|
39
|
+
* type: 'string',
|
|
40
|
+
* format: undefined,
|
|
41
|
+
* enums: undefined,
|
|
42
|
+
* modifiers: {
|
|
43
|
+
* required: false,
|
|
44
|
+
* nullable: true,
|
|
45
|
+
* description: 'Optional user note or comment'
|
|
46
|
+
* }
|
|
47
|
+
* };
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example TypeScript generation
|
|
51
|
+
* ```typescript
|
|
52
|
+
* function generateTypeScript(type: TypeSystemValue): string {
|
|
53
|
+
* const baseType = generateBaseType(type);
|
|
54
|
+
* const optional = !type.modifiers.required ? '?' : '';
|
|
55
|
+
* const nullable = type.modifiers.nullable ? ' | null' : '';
|
|
56
|
+
*
|
|
57
|
+
* return `${baseType}${nullable}${optional}`;
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* // Required non-null string: 'string'
|
|
61
|
+
* // Optional non-null string: 'string?'
|
|
62
|
+
* // Required nullable string: 'string | null'
|
|
63
|
+
* // Optional nullable string: 'string | null?'
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
1
66
|
export type Modifiers = {
|
|
67
|
+
/** Whether the field is required (affects optional markers in generated types) */
|
|
2
68
|
required?: boolean;
|
|
69
|
+
/** Human-readable description of the field (used in documentation) */
|
|
3
70
|
description?: string;
|
|
71
|
+
/** Whether the field can be null (affects null union types) */
|
|
4
72
|
nullable?: boolean;
|
|
5
73
|
};
|
|
6
74
|
//# sourceMappingURL=Modifiers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modifiers.d.ts","sourceRoot":"","sources":["../../src/types/Modifiers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA"}
|
|
1
|
+
{"version":3,"file":"Modifiers.d.ts","sourceRoot":"","sources":["../../src/types/Modifiers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA"}
|