@skmtc/core 0.0.792 → 0.0.794
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/dsl/GeneratedValueList.d.ts +158 -0
- package/esm/dsl/GeneratedValueList.d.ts.map +1 -1
- package/esm/dsl/GeneratedValueList.js +158 -0
- package/esm/dsl/Stringable.d.ts +76 -0
- package/esm/dsl/Stringable.d.ts.map +1 -1
- package/esm/dsl/Stringable.js +75 -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/collateExamples.d.ts +150 -0
- package/esm/helpers/collateExamples.d.ts.map +1 -1
- package/esm/helpers/collateExamples.js +145 -0
- package/esm/helpers/formatNumber.d.ts +95 -0
- package/esm/helpers/formatNumber.d.ts.map +1 -1
- package/esm/helpers/formatNumber.js +95 -0
- package/esm/helpers/generationStats.d.ts +287 -1
- package/esm/helpers/generationStats.d.ts.map +1 -1
- package/esm/helpers/generationStats.js +266 -0
- package/esm/helpers/isEmpty.d.ts +62 -0
- package/esm/helpers/isEmpty.d.ts.map +1 -1
- package/esm/helpers/isEmpty.js +62 -0
- package/esm/helpers/isImported.d.ts +80 -0
- package/esm/helpers/isImported.d.ts.map +1 -1
- package/esm/helpers/isImported.js +80 -0
- package/esm/helpers/parseModuleName.d.ts +175 -0
- package/esm/helpers/parseModuleName.d.ts.map +1 -1
- package/esm/helpers/parseModuleName.js +153 -0
- package/esm/helpers/toResolvedArtifactPath.d.ts +145 -0
- package/esm/helpers/toResolvedArtifactPath.d.ts.map +1 -1
- package/esm/helpers/toResolvedArtifactPath.js +140 -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/oas/schema/Schema.d.ts +117 -0
- package/esm/oas/schema/Schema.d.ts.map +1 -1
- 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/identifiers.d.ts +159 -0
- package/esm/typescript/identifiers.d.ts.map +1 -1
- package/esm/typescript/identifiers.js +159 -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/esm/typescript/withDescription.d.ts +119 -0
- package/esm/typescript/withDescription.d.ts.map +1 -1
- package/esm/typescript/withDescription.js +119 -0
- package/package.json +1 -1
- package/script/dsl/GeneratedValueList.d.ts +158 -0
- package/script/dsl/GeneratedValueList.d.ts.map +1 -1
- package/script/dsl/GeneratedValueList.js +158 -0
- package/script/dsl/Stringable.d.ts +76 -0
- package/script/dsl/Stringable.d.ts.map +1 -1
- package/script/dsl/Stringable.js +75 -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/collateExamples.d.ts +150 -0
- package/script/helpers/collateExamples.d.ts.map +1 -1
- package/script/helpers/collateExamples.js +145 -0
- package/script/helpers/formatNumber.d.ts +95 -0
- package/script/helpers/formatNumber.d.ts.map +1 -1
- package/script/helpers/formatNumber.js +95 -0
- package/script/helpers/generationStats.d.ts +287 -1
- package/script/helpers/generationStats.d.ts.map +1 -1
- package/script/helpers/generationStats.js +266 -0
- package/script/helpers/isEmpty.d.ts +62 -0
- package/script/helpers/isEmpty.d.ts.map +1 -1
- package/script/helpers/isEmpty.js +62 -0
- package/script/helpers/isImported.d.ts +80 -0
- package/script/helpers/isImported.d.ts.map +1 -1
- package/script/helpers/isImported.js +80 -0
- package/script/helpers/parseModuleName.d.ts +175 -0
- package/script/helpers/parseModuleName.d.ts.map +1 -1
- package/script/helpers/parseModuleName.js +153 -0
- package/script/helpers/toResolvedArtifactPath.d.ts +145 -0
- package/script/helpers/toResolvedArtifactPath.d.ts.map +1 -1
- package/script/helpers/toResolvedArtifactPath.js +140 -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/oas/schema/Schema.d.ts +117 -0
- package/script/oas/schema/Schema.d.ts.map +1 -1
- 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/identifiers.d.ts +159 -0
- package/script/typescript/identifiers.d.ts.map +1 -1
- package/script/typescript/identifiers.js +159 -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/script/typescript/withDescription.d.ts +119 -0
- package/script/typescript/withDescription.d.ts.map +1 -1
- package/script/typescript/withDescription.js +119 -0
|
@@ -1,4 +1,123 @@
|
|
|
1
1
|
import type { Stringable } from '../dsl/Stringable.js';
|
|
2
2
|
import type { Modifiers } from '../types/Modifiers.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a value with a JSDoc comment if a description is provided.
|
|
5
|
+
*
|
|
6
|
+
* This utility function is used throughout the SKMTC code generation system to
|
|
7
|
+
* add JSDoc documentation comments to generated TypeScript code. If a description
|
|
8
|
+
* is provided, it formats it as a single-line JSDoc comment above the value.
|
|
9
|
+
* If no description is provided, the value is returned unchanged.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The code value to potentially wrap with documentation
|
|
12
|
+
* @param modifiers - Modifiers object containing optional description
|
|
13
|
+
* @param modifiers.description - Optional description text for the JSDoc comment
|
|
14
|
+
* @returns The value with JSDoc comment prepended if description exists, otherwise just the value
|
|
15
|
+
*
|
|
16
|
+
* @example With description
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { withDescription } from '@skmtc/core';
|
|
19
|
+
*
|
|
20
|
+
* const result = withDescription(
|
|
21
|
+
* 'export const API_URL = "https://api.example.com";',
|
|
22
|
+
* { description: 'Base URL for all API requests' }
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
* console.log(result);
|
|
26
|
+
* // /** Base URL for all API requests *\/
|
|
27
|
+
* // export const API_URL = "https://api.example.com";
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example Without description
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const result = withDescription(
|
|
33
|
+
* 'export const API_URL = "https://api.example.com";',
|
|
34
|
+
* { description: undefined }
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* console.log(result);
|
|
38
|
+
* // export const API_URL = "https://api.example.com";
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example Using with Definition class
|
|
42
|
+
* ```typescript
|
|
43
|
+
* class ModelGenerator {
|
|
44
|
+
* generateInterface(name: string, description?: string) {
|
|
45
|
+
* const interfaceCode = `interface ${name} {
|
|
46
|
+
* id: string;
|
|
47
|
+
* name: string;
|
|
48
|
+
* }`;
|
|
49
|
+
*
|
|
50
|
+
* return withDescription(interfaceCode, { description });
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* const generator = new ModelGenerator();
|
|
55
|
+
* const documented = generator.generateInterface('User', 'Represents a user in the system');
|
|
56
|
+
*
|
|
57
|
+
* console.log(documented);
|
|
58
|
+
* // /** Represents a user in the system *\/
|
|
59
|
+
* // interface User {
|
|
60
|
+
* // id: string;
|
|
61
|
+
* // name: string;
|
|
62
|
+
* // }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example Integration with generated definitions
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import { Definition, Identifier, withDescription } from '@skmtc/core';
|
|
68
|
+
*
|
|
69
|
+
* class DocumentedGenerator {
|
|
70
|
+
* createDefinition(name: string, value: string, docs?: string) {
|
|
71
|
+
* return new Definition({
|
|
72
|
+
* context: this.context,
|
|
73
|
+
* identifier: Identifier.createVariable(name),
|
|
74
|
+
* description: docs, // This gets processed by withDescription internally
|
|
75
|
+
* value: {
|
|
76
|
+
* generatorKey: 'documented',
|
|
77
|
+
* content: value
|
|
78
|
+
* }
|
|
79
|
+
* });
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example Complex documentation
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const complexDoc = withDescription(
|
|
87
|
+
* `export type Status = 'active' | 'inactive' | 'pending';`,
|
|
88
|
+
* {
|
|
89
|
+
* description: 'User account status - active users can access all features'
|
|
90
|
+
* }
|
|
91
|
+
* );
|
|
92
|
+
*
|
|
93
|
+
* console.log(complexDoc);
|
|
94
|
+
* // /** User account status - active users can access all features *\/
|
|
95
|
+
* // export type Status = 'active' | 'inactive' | 'pending';
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example Conditional documentation
|
|
99
|
+
* ```typescript
|
|
100
|
+
* function generateWithOptionalDocs(
|
|
101
|
+
* code: string,
|
|
102
|
+
* includeDescription: boolean
|
|
103
|
+
* ) {
|
|
104
|
+
* return withDescription(code, {
|
|
105
|
+
* description: includeDescription
|
|
106
|
+
* ? 'This is an auto-generated definition'
|
|
107
|
+
* : undefined
|
|
108
|
+
* });
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* const withDocs = generateWithOptionalDocs('export const VALUE = 42;', true);
|
|
112
|
+
* const withoutDocs = generateWithOptionalDocs('export const VALUE = 42;', false);
|
|
113
|
+
*
|
|
114
|
+
* console.log(withDocs);
|
|
115
|
+
* // /** This is an auto-generated definition *\/
|
|
116
|
+
* // export const VALUE = 42;
|
|
117
|
+
*
|
|
118
|
+
* console.log(withoutDocs);
|
|
119
|
+
* // export const VALUE = 42;
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
3
122
|
export declare const withDescription: (value: Stringable, { description }: Modifiers) => string;
|
|
4
123
|
//# sourceMappingURL=withDescription.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withDescription.d.ts","sourceRoot":"","sources":["../../src/typescript/withDescription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,eAAO,MAAM,eAAe,GAC1B,OAAO,UAAU,EACjB,iBAAiB,SAAS,KACzB,MAEF,CAAA"}
|
|
1
|
+
{"version":3,"file":"withDescription.d.ts","sourceRoot":"","sources":["../../src/typescript/withDescription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsHG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,UAAU,EACjB,iBAAiB,SAAS,KACzB,MAEF,CAAA"}
|
|
@@ -1,6 +1,125 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withDescription = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Wraps a value with a JSDoc comment if a description is provided.
|
|
6
|
+
*
|
|
7
|
+
* This utility function is used throughout the SKMTC code generation system to
|
|
8
|
+
* add JSDoc documentation comments to generated TypeScript code. If a description
|
|
9
|
+
* is provided, it formats it as a single-line JSDoc comment above the value.
|
|
10
|
+
* If no description is provided, the value is returned unchanged.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The code value to potentially wrap with documentation
|
|
13
|
+
* @param modifiers - Modifiers object containing optional description
|
|
14
|
+
* @param modifiers.description - Optional description text for the JSDoc comment
|
|
15
|
+
* @returns The value with JSDoc comment prepended if description exists, otherwise just the value
|
|
16
|
+
*
|
|
17
|
+
* @example With description
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { withDescription } from '@skmtc/core';
|
|
20
|
+
*
|
|
21
|
+
* const result = withDescription(
|
|
22
|
+
* 'export const API_URL = "https://api.example.com";',
|
|
23
|
+
* { description: 'Base URL for all API requests' }
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* console.log(result);
|
|
27
|
+
* // /** Base URL for all API requests *\/
|
|
28
|
+
* // export const API_URL = "https://api.example.com";
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example Without description
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const result = withDescription(
|
|
34
|
+
* 'export const API_URL = "https://api.example.com";',
|
|
35
|
+
* { description: undefined }
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* console.log(result);
|
|
39
|
+
* // export const API_URL = "https://api.example.com";
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example Using with Definition class
|
|
43
|
+
* ```typescript
|
|
44
|
+
* class ModelGenerator {
|
|
45
|
+
* generateInterface(name: string, description?: string) {
|
|
46
|
+
* const interfaceCode = `interface ${name} {
|
|
47
|
+
* id: string;
|
|
48
|
+
* name: string;
|
|
49
|
+
* }`;
|
|
50
|
+
*
|
|
51
|
+
* return withDescription(interfaceCode, { description });
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* const generator = new ModelGenerator();
|
|
56
|
+
* const documented = generator.generateInterface('User', 'Represents a user in the system');
|
|
57
|
+
*
|
|
58
|
+
* console.log(documented);
|
|
59
|
+
* // /** Represents a user in the system *\/
|
|
60
|
+
* // interface User {
|
|
61
|
+
* // id: string;
|
|
62
|
+
* // name: string;
|
|
63
|
+
* // }
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @example Integration with generated definitions
|
|
67
|
+
* ```typescript
|
|
68
|
+
* import { Definition, Identifier, withDescription } from '@skmtc/core';
|
|
69
|
+
*
|
|
70
|
+
* class DocumentedGenerator {
|
|
71
|
+
* createDefinition(name: string, value: string, docs?: string) {
|
|
72
|
+
* return new Definition({
|
|
73
|
+
* context: this.context,
|
|
74
|
+
* identifier: Identifier.createVariable(name),
|
|
75
|
+
* description: docs, // This gets processed by withDescription internally
|
|
76
|
+
* value: {
|
|
77
|
+
* generatorKey: 'documented',
|
|
78
|
+
* content: value
|
|
79
|
+
* }
|
|
80
|
+
* });
|
|
81
|
+
* }
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example Complex documentation
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const complexDoc = withDescription(
|
|
88
|
+
* `export type Status = 'active' | 'inactive' | 'pending';`,
|
|
89
|
+
* {
|
|
90
|
+
* description: 'User account status - active users can access all features'
|
|
91
|
+
* }
|
|
92
|
+
* );
|
|
93
|
+
*
|
|
94
|
+
* console.log(complexDoc);
|
|
95
|
+
* // /** User account status - active users can access all features *\/
|
|
96
|
+
* // export type Status = 'active' | 'inactive' | 'pending';
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example Conditional documentation
|
|
100
|
+
* ```typescript
|
|
101
|
+
* function generateWithOptionalDocs(
|
|
102
|
+
* code: string,
|
|
103
|
+
* includeDescription: boolean
|
|
104
|
+
* ) {
|
|
105
|
+
* return withDescription(code, {
|
|
106
|
+
* description: includeDescription
|
|
107
|
+
* ? 'This is an auto-generated definition'
|
|
108
|
+
* : undefined
|
|
109
|
+
* });
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* const withDocs = generateWithOptionalDocs('export const VALUE = 42;', true);
|
|
113
|
+
* const withoutDocs = generateWithOptionalDocs('export const VALUE = 42;', false);
|
|
114
|
+
*
|
|
115
|
+
* console.log(withDocs);
|
|
116
|
+
* // /** This is an auto-generated definition *\/
|
|
117
|
+
* // export const VALUE = 42;
|
|
118
|
+
*
|
|
119
|
+
* console.log(withoutDocs);
|
|
120
|
+
* // export const VALUE = 42;
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
4
123
|
const withDescription = (value, { description }) => {
|
|
5
124
|
return description ? `/** ${description} */\n${value}` : `${value}`;
|
|
6
125
|
};
|