@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.
Files changed (113) hide show
  1. package/esm/dsl/GeneratedValueList.d.ts +158 -0
  2. package/esm/dsl/GeneratedValueList.d.ts.map +1 -1
  3. package/esm/dsl/GeneratedValueList.js +158 -0
  4. package/esm/dsl/Stringable.d.ts +76 -0
  5. package/esm/dsl/Stringable.d.ts.map +1 -1
  6. package/esm/dsl/Stringable.js +75 -0
  7. package/esm/helpers/ResultsLog.d.ts +193 -0
  8. package/esm/helpers/ResultsLog.d.ts.map +1 -1
  9. package/esm/helpers/ResultsLog.js +213 -0
  10. package/esm/helpers/collateExamples.d.ts +150 -0
  11. package/esm/helpers/collateExamples.d.ts.map +1 -1
  12. package/esm/helpers/collateExamples.js +145 -0
  13. package/esm/helpers/formatNumber.d.ts +95 -0
  14. package/esm/helpers/formatNumber.d.ts.map +1 -1
  15. package/esm/helpers/formatNumber.js +95 -0
  16. package/esm/helpers/generationStats.d.ts +287 -1
  17. package/esm/helpers/generationStats.d.ts.map +1 -1
  18. package/esm/helpers/generationStats.js +266 -0
  19. package/esm/helpers/isEmpty.d.ts +62 -0
  20. package/esm/helpers/isEmpty.d.ts.map +1 -1
  21. package/esm/helpers/isEmpty.js +62 -0
  22. package/esm/helpers/isImported.d.ts +80 -0
  23. package/esm/helpers/isImported.d.ts.map +1 -1
  24. package/esm/helpers/isImported.js +80 -0
  25. package/esm/helpers/parseModuleName.d.ts +175 -0
  26. package/esm/helpers/parseModuleName.d.ts.map +1 -1
  27. package/esm/helpers/parseModuleName.js +153 -0
  28. package/esm/helpers/toResolvedArtifactPath.d.ts +145 -0
  29. package/esm/helpers/toResolvedArtifactPath.d.ts.map +1 -1
  30. package/esm/helpers/toResolvedArtifactPath.js +140 -0
  31. package/esm/helpers/tracer.d.ts +124 -0
  32. package/esm/helpers/tracer.d.ts.map +1 -1
  33. package/esm/helpers/tracer.js +124 -0
  34. package/esm/oas/schema/Schema.d.ts +117 -0
  35. package/esm/oas/schema/Schema.d.ts.map +1 -1
  36. package/esm/typescript/PathParams.d.ts +198 -0
  37. package/esm/typescript/PathParams.d.ts.map +1 -1
  38. package/esm/typescript/PathParams.js +190 -0
  39. package/esm/typescript/ReactRouterPathParams.d.ts +190 -0
  40. package/esm/typescript/ReactRouterPathParams.d.ts.map +1 -1
  41. package/esm/typescript/ReactRouterPathParams.js +183 -0
  42. package/esm/typescript/identifiers.d.ts +159 -0
  43. package/esm/typescript/identifiers.d.ts.map +1 -1
  44. package/esm/typescript/identifiers.js +159 -0
  45. package/esm/typescript/keyValues.d.ts +125 -0
  46. package/esm/typescript/keyValues.d.ts.map +1 -1
  47. package/esm/typescript/keyValues.js +125 -1
  48. package/esm/typescript/toPathParams.d.ts +179 -0
  49. package/esm/typescript/toPathParams.d.ts.map +1 -1
  50. package/esm/typescript/toPathParams.js +179 -0
  51. package/esm/typescript/toPathTemplate.d.ts +114 -0
  52. package/esm/typescript/toPathTemplate.d.ts.map +1 -1
  53. package/esm/typescript/toPathTemplate.js +114 -0
  54. package/esm/typescript/withDescription.d.ts +119 -0
  55. package/esm/typescript/withDescription.d.ts.map +1 -1
  56. package/esm/typescript/withDescription.js +119 -0
  57. package/package.json +1 -1
  58. package/script/dsl/GeneratedValueList.d.ts +158 -0
  59. package/script/dsl/GeneratedValueList.d.ts.map +1 -1
  60. package/script/dsl/GeneratedValueList.js +158 -0
  61. package/script/dsl/Stringable.d.ts +76 -0
  62. package/script/dsl/Stringable.d.ts.map +1 -1
  63. package/script/dsl/Stringable.js +75 -0
  64. package/script/helpers/ResultsLog.d.ts +193 -0
  65. package/script/helpers/ResultsLog.d.ts.map +1 -1
  66. package/script/helpers/ResultsLog.js +213 -0
  67. package/script/helpers/collateExamples.d.ts +150 -0
  68. package/script/helpers/collateExamples.d.ts.map +1 -1
  69. package/script/helpers/collateExamples.js +145 -0
  70. package/script/helpers/formatNumber.d.ts +95 -0
  71. package/script/helpers/formatNumber.d.ts.map +1 -1
  72. package/script/helpers/formatNumber.js +95 -0
  73. package/script/helpers/generationStats.d.ts +287 -1
  74. package/script/helpers/generationStats.d.ts.map +1 -1
  75. package/script/helpers/generationStats.js +266 -0
  76. package/script/helpers/isEmpty.d.ts +62 -0
  77. package/script/helpers/isEmpty.d.ts.map +1 -1
  78. package/script/helpers/isEmpty.js +62 -0
  79. package/script/helpers/isImported.d.ts +80 -0
  80. package/script/helpers/isImported.d.ts.map +1 -1
  81. package/script/helpers/isImported.js +80 -0
  82. package/script/helpers/parseModuleName.d.ts +175 -0
  83. package/script/helpers/parseModuleName.d.ts.map +1 -1
  84. package/script/helpers/parseModuleName.js +153 -0
  85. package/script/helpers/toResolvedArtifactPath.d.ts +145 -0
  86. package/script/helpers/toResolvedArtifactPath.d.ts.map +1 -1
  87. package/script/helpers/toResolvedArtifactPath.js +140 -0
  88. package/script/helpers/tracer.d.ts +124 -0
  89. package/script/helpers/tracer.d.ts.map +1 -1
  90. package/script/helpers/tracer.js +124 -0
  91. package/script/oas/schema/Schema.d.ts +117 -0
  92. package/script/oas/schema/Schema.d.ts.map +1 -1
  93. package/script/typescript/PathParams.d.ts +198 -0
  94. package/script/typescript/PathParams.d.ts.map +1 -1
  95. package/script/typescript/PathParams.js +190 -0
  96. package/script/typescript/ReactRouterPathParams.d.ts +190 -0
  97. package/script/typescript/ReactRouterPathParams.d.ts.map +1 -1
  98. package/script/typescript/ReactRouterPathParams.js +183 -0
  99. package/script/typescript/identifiers.d.ts +159 -0
  100. package/script/typescript/identifiers.d.ts.map +1 -1
  101. package/script/typescript/identifiers.js +159 -0
  102. package/script/typescript/keyValues.d.ts +125 -0
  103. package/script/typescript/keyValues.d.ts.map +1 -1
  104. package/script/typescript/keyValues.js +125 -1
  105. package/script/typescript/toPathParams.d.ts +179 -0
  106. package/script/typescript/toPathParams.d.ts.map +1 -1
  107. package/script/typescript/toPathParams.js +179 -0
  108. package/script/typescript/toPathTemplate.d.ts +114 -0
  109. package/script/typescript/toPathTemplate.d.ts.map +1 -1
  110. package/script/typescript/toPathTemplate.js +114 -0
  111. package/script/typescript/withDescription.d.ts +119 -0
  112. package/script/typescript/withDescription.d.ts.map +1 -1
  113. package/script/typescript/withDescription.js +119 -0
@@ -1,9 +1,167 @@
1
1
  import type { GeneratedValue } from '../types/GeneratedValue.js';
2
+ /**
3
+ * A utility class for managing lists of generated values with customizable separators.
4
+ *
5
+ * `GeneratedValueList` provides a way to collect multiple generated values and combine
6
+ * them into a single string with a specified separator. It automatically filters out
7
+ * empty values to prevent generating unnecessary whitespace or malformed output.
8
+ *
9
+ * This class is useful for building lists of code elements like function parameters,
10
+ * import statements, or any other comma-separated (or otherwise separated) constructs
11
+ * where individual items might sometimes be empty.
12
+ *
13
+ * ## Key Features
14
+ *
15
+ * - **Custom Separators**: Support for any string separator (commas, newlines, spaces, etc.)
16
+ * - **Empty Filtering**: Automatically removes empty values from output
17
+ * - **Type Safety**: Works with any GeneratedValue type
18
+ * - **Incremental Building**: Values can be added one at a time
19
+ *
20
+ * @example Basic usage with comma separation
21
+ * ```typescript
22
+ * import { GeneratedValueList } from '@skmtc/core';
23
+ *
24
+ * const parameterList = new GeneratedValueList(', ');
25
+ * parameterList.add({ toString: () => 'id: string' });
26
+ * parameterList.add({ toString: () => 'name: string' });
27
+ * parameterList.add({ toString: () => 'email?: string' });
28
+ *
29
+ * console.log(parameterList.toString());
30
+ * // 'id: string, name: string, email?: string'
31
+ * ```
32
+ *
33
+ * @example With newline separation for code blocks
34
+ * ```typescript
35
+ * const codeLines = new GeneratedValueList('\n');
36
+ * codeLines.add({ toString: () => 'import { User } from "./types";' });
37
+ * codeLines.add({ toString: () => 'import { validate } from "./utils";' });
38
+ * codeLines.add({ toString: () => '' }); // Empty line will be filtered
39
+ * codeLines.add({ toString: () => 'export class UserService {' });
40
+ * codeLines.add({ toString: () => ' // Implementation' });
41
+ * codeLines.add({ toString: () => '}' });
42
+ *
43
+ * console.log(codeLines.toString());
44
+ * // import { User } from "./types";
45
+ * // import { validate } from "./utils";
46
+ * // export class UserService {
47
+ * // // Implementation
48
+ * // }
49
+ * ```
50
+ *
51
+ * @example Empty value filtering
52
+ * ```typescript
53
+ * const mixedList = new GeneratedValueList(' | ');
54
+ * mixedList.add({ toString: () => "'active'" });
55
+ * mixedList.add({ toString: () => '' }); // This will be filtered out
56
+ * mixedList.add({ toString: () => "'inactive'" });
57
+ * mixedList.add({ toString: () => "'pending'" });
58
+ *
59
+ * console.log(mixedList.toString());
60
+ * // "'active' | 'inactive' | 'pending'"
61
+ * ```
62
+ *
63
+ * @example Using in code generation
64
+ * ```typescript
65
+ * class InterfaceGenerator {
66
+ * generateInterface(name: string, properties: Array<{name: string, type: string}>) {
67
+ * const propertyList = new GeneratedValueList(';\n ');
68
+ *
69
+ * properties.forEach(prop => {
70
+ * if (prop.type) { // Only add properties that have types
71
+ * propertyList.add({
72
+ * toString: () => `${prop.name}: ${prop.type}`
73
+ * });
74
+ * }
75
+ * });
76
+ *
77
+ * return `interface ${name} {\n ${propertyList.toString()};\n}`;
78
+ * }
79
+ * }
80
+ *
81
+ * const generator = new InterfaceGenerator();
82
+ * const userInterface = generator.generateInterface('User', [
83
+ * { name: 'id', type: 'string' },
84
+ * { name: 'name', type: 'string' },
85
+ * { name: 'invalid', type: '' }, // Will be filtered out
86
+ * { name: 'email', type: 'string | null' }
87
+ * ]);
88
+ *
89
+ * console.log(userInterface);
90
+ * // interface User {
91
+ * // id: string;
92
+ * // name: string;
93
+ * // email: string | null;
94
+ * // }
95
+ * ```
96
+ */
2
97
  export declare class GeneratedValueList {
98
+ /** The separator string used to join values */
3
99
  separator: string;
100
+ /** Internal array of generated values */
4
101
  private items;
102
+ /**
103
+ * Creates a new GeneratedValueList with the specified separator.
104
+ *
105
+ * @param separator - The string to use when joining values (e.g., ', ', '\n', ' | ')
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * // For comma-separated lists
110
+ * const commaList = new GeneratedValueList(', ');
111
+ *
112
+ * // For line-separated content
113
+ * const lineList = new GeneratedValueList('\n');
114
+ *
115
+ * // For union types
116
+ * const unionList = new GeneratedValueList(' | ');
117
+ * ```
118
+ */
5
119
  constructor(separator: string);
120
+ /**
121
+ * Adds a generated value to the list.
122
+ *
123
+ * The value will be included in the output string when `toString()` is called,
124
+ * unless the value's `toString()` method returns an empty string, in which case
125
+ * it will be automatically filtered out.
126
+ *
127
+ * @param str - The generated value to add to the list
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const list = new GeneratedValueList(', ');
132
+ *
133
+ * // Add simple values
134
+ * list.add({ toString: () => 'value1' });
135
+ * list.add({ toString: () => 'value2' });
136
+ *
137
+ * // Add conditional values
138
+ * const conditionalValue = shouldInclude ? 'conditional' : '';
139
+ * list.add({ toString: () => conditionalValue });
140
+ *
141
+ * console.log(list.toString()); // 'value1, value2' (conditional filtered if empty)
142
+ * ```
143
+ */
6
144
  add(str: GeneratedValue): void;
145
+ /**
146
+ * Converts the list to a string representation with values joined by the separator.
147
+ *
148
+ * This method processes all added values by calling their `toString()` methods,
149
+ * filters out any empty strings (matching the {@link EMPTY} constant), and joins
150
+ * the remaining values with the configured separator.
151
+ *
152
+ * @returns The joined string representation of all non-empty values
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const list = new GeneratedValueList(' -> ');
157
+ * list.add({ toString: () => 'start' });
158
+ * list.add({ toString: () => '' }); // Will be filtered out
159
+ * list.add({ toString: () => 'middle' });
160
+ * list.add({ toString: () => 'end' });
161
+ *
162
+ * console.log(list.toString()); // 'start -> middle -> end'
163
+ * ```
164
+ */
7
165
  toString(): string;
8
166
  }
9
167
  //# sourceMappingURL=GeneratedValueList.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GeneratedValueList.d.ts","sourceRoot":"","sources":["../../src/dsl/GeneratedValueList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE,qBAAa,kBAAkB;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,KAAK,CAAuB;gBAExB,SAAS,EAAE,MAAM;IAI7B,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI;IAI9B,QAAQ,IAAI,MAAM;CAMnB"}
1
+ {"version":3,"file":"GeneratedValueList.d.ts","sourceRoot":"","sources":["../../src/dsl/GeneratedValueList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,qBAAa,kBAAkB;IAC7B,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAA;IAEjB,yCAAyC;IACzC,OAAO,CAAC,KAAK,CAAuB;IAEpC;;;;;;;;;;;;;;;;OAgBG;gBACS,SAAS,EAAE,MAAM;IAI7B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI;IAI9B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,IAAI,MAAM;CAMnB"}
@@ -1,12 +1,126 @@
1
1
  import { EMPTY } from './constants.js';
2
+ /**
3
+ * A utility class for managing lists of generated values with customizable separators.
4
+ *
5
+ * `GeneratedValueList` provides a way to collect multiple generated values and combine
6
+ * them into a single string with a specified separator. It automatically filters out
7
+ * empty values to prevent generating unnecessary whitespace or malformed output.
8
+ *
9
+ * This class is useful for building lists of code elements like function parameters,
10
+ * import statements, or any other comma-separated (or otherwise separated) constructs
11
+ * where individual items might sometimes be empty.
12
+ *
13
+ * ## Key Features
14
+ *
15
+ * - **Custom Separators**: Support for any string separator (commas, newlines, spaces, etc.)
16
+ * - **Empty Filtering**: Automatically removes empty values from output
17
+ * - **Type Safety**: Works with any GeneratedValue type
18
+ * - **Incremental Building**: Values can be added one at a time
19
+ *
20
+ * @example Basic usage with comma separation
21
+ * ```typescript
22
+ * import { GeneratedValueList } from '@skmtc/core';
23
+ *
24
+ * const parameterList = new GeneratedValueList(', ');
25
+ * parameterList.add({ toString: () => 'id: string' });
26
+ * parameterList.add({ toString: () => 'name: string' });
27
+ * parameterList.add({ toString: () => 'email?: string' });
28
+ *
29
+ * console.log(parameterList.toString());
30
+ * // 'id: string, name: string, email?: string'
31
+ * ```
32
+ *
33
+ * @example With newline separation for code blocks
34
+ * ```typescript
35
+ * const codeLines = new GeneratedValueList('\n');
36
+ * codeLines.add({ toString: () => 'import { User } from "./types";' });
37
+ * codeLines.add({ toString: () => 'import { validate } from "./utils";' });
38
+ * codeLines.add({ toString: () => '' }); // Empty line will be filtered
39
+ * codeLines.add({ toString: () => 'export class UserService {' });
40
+ * codeLines.add({ toString: () => ' // Implementation' });
41
+ * codeLines.add({ toString: () => '}' });
42
+ *
43
+ * console.log(codeLines.toString());
44
+ * // import { User } from "./types";
45
+ * // import { validate } from "./utils";
46
+ * // export class UserService {
47
+ * // // Implementation
48
+ * // }
49
+ * ```
50
+ *
51
+ * @example Empty value filtering
52
+ * ```typescript
53
+ * const mixedList = new GeneratedValueList(' | ');
54
+ * mixedList.add({ toString: () => "'active'" });
55
+ * mixedList.add({ toString: () => '' }); // This will be filtered out
56
+ * mixedList.add({ toString: () => "'inactive'" });
57
+ * mixedList.add({ toString: () => "'pending'" });
58
+ *
59
+ * console.log(mixedList.toString());
60
+ * // "'active' | 'inactive' | 'pending'"
61
+ * ```
62
+ *
63
+ * @example Using in code generation
64
+ * ```typescript
65
+ * class InterfaceGenerator {
66
+ * generateInterface(name: string, properties: Array<{name: string, type: string}>) {
67
+ * const propertyList = new GeneratedValueList(';\n ');
68
+ *
69
+ * properties.forEach(prop => {
70
+ * if (prop.type) { // Only add properties that have types
71
+ * propertyList.add({
72
+ * toString: () => `${prop.name}: ${prop.type}`
73
+ * });
74
+ * }
75
+ * });
76
+ *
77
+ * return `interface ${name} {\n ${propertyList.toString()};\n}`;
78
+ * }
79
+ * }
80
+ *
81
+ * const generator = new InterfaceGenerator();
82
+ * const userInterface = generator.generateInterface('User', [
83
+ * { name: 'id', type: 'string' },
84
+ * { name: 'name', type: 'string' },
85
+ * { name: 'invalid', type: '' }, // Will be filtered out
86
+ * { name: 'email', type: 'string | null' }
87
+ * ]);
88
+ *
89
+ * console.log(userInterface);
90
+ * // interface User {
91
+ * // id: string;
92
+ * // name: string;
93
+ * // email: string | null;
94
+ * // }
95
+ * ```
96
+ */
2
97
  export class GeneratedValueList {
98
+ /**
99
+ * Creates a new GeneratedValueList with the specified separator.
100
+ *
101
+ * @param separator - The string to use when joining values (e.g., ', ', '\n', ' | ')
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * // For comma-separated lists
106
+ * const commaList = new GeneratedValueList(', ');
107
+ *
108
+ * // For line-separated content
109
+ * const lineList = new GeneratedValueList('\n');
110
+ *
111
+ * // For union types
112
+ * const unionList = new GeneratedValueList(' | ');
113
+ * ```
114
+ */
3
115
  constructor(separator) {
116
+ /** The separator string used to join values */
4
117
  Object.defineProperty(this, "separator", {
5
118
  enumerable: true,
6
119
  configurable: true,
7
120
  writable: true,
8
121
  value: void 0
9
122
  });
123
+ /** Internal array of generated values */
10
124
  Object.defineProperty(this, "items", {
11
125
  enumerable: true,
12
126
  configurable: true,
@@ -15,9 +129,53 @@ export class GeneratedValueList {
15
129
  });
16
130
  this.separator = separator;
17
131
  }
132
+ /**
133
+ * Adds a generated value to the list.
134
+ *
135
+ * The value will be included in the output string when `toString()` is called,
136
+ * unless the value's `toString()` method returns an empty string, in which case
137
+ * it will be automatically filtered out.
138
+ *
139
+ * @param str - The generated value to add to the list
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const list = new GeneratedValueList(', ');
144
+ *
145
+ * // Add simple values
146
+ * list.add({ toString: () => 'value1' });
147
+ * list.add({ toString: () => 'value2' });
148
+ *
149
+ * // Add conditional values
150
+ * const conditionalValue = shouldInclude ? 'conditional' : '';
151
+ * list.add({ toString: () => conditionalValue });
152
+ *
153
+ * console.log(list.toString()); // 'value1, value2' (conditional filtered if empty)
154
+ * ```
155
+ */
18
156
  add(str) {
19
157
  this.items.push(str);
20
158
  }
159
+ /**
160
+ * Converts the list to a string representation with values joined by the separator.
161
+ *
162
+ * This method processes all added values by calling their `toString()` methods,
163
+ * filters out any empty strings (matching the {@link EMPTY} constant), and joins
164
+ * the remaining values with the configured separator.
165
+ *
166
+ * @returns The joined string representation of all non-empty values
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * const list = new GeneratedValueList(' -> ');
171
+ * list.add({ toString: () => 'start' });
172
+ * list.add({ toString: () => '' }); // Will be filtered out
173
+ * list.add({ toString: () => 'middle' });
174
+ * list.add({ toString: () => 'end' });
175
+ *
176
+ * console.log(list.toString()); // 'start -> middle -> end'
177
+ * ```
178
+ */
21
179
  toString() {
22
180
  return this.items
23
181
  .map(item => item.toString())
@@ -1,5 +1,81 @@
1
+ /**
2
+ * Represents any object that can be converted to a string representation.
3
+ *
4
+ * The `Stringable` interface is a fundamental type used throughout the SKMTC DSL
5
+ * system to ensure that objects can be converted to strings for code generation.
6
+ * This interface matches JavaScript's built-in `toString()` contract and is used
7
+ * extensively by the {@link List} class and other string-building utilities.
8
+ *
9
+ * ## Usage in SKMTC
10
+ *
11
+ * This type is used as a constraint in generic classes and functions that need
12
+ * to output string representations. It allows for type-safe string building
13
+ * while accommodating both primitive types and custom objects.
14
+ *
15
+ * @example Built-in types are stringable
16
+ * ```typescript
17
+ * import type { Stringable } from '@skmtc/core';
18
+ *
19
+ * // All these types implement Stringable
20
+ * const str: Stringable = 'hello'; // string
21
+ * const num: Stringable = 42; // number
22
+ * const bool: Stringable = true; // boolean
23
+ * const obj: Stringable = { toString: () => 'custom' }; // custom object
24
+ * ```
25
+ *
26
+ * @example Custom classes implementing Stringable
27
+ * ```typescript
28
+ * class CodeBlock implements Stringable {
29
+ * constructor(private code: string) {}
30
+ *
31
+ * toString(): string {
32
+ * return `{\n ${this.code}\n}`;
33
+ * }
34
+ * }
35
+ *
36
+ * const block = new CodeBlock('console.log("hello");');
37
+ * console.log(block.toString());
38
+ * // {
39
+ * // console.log("hello");
40
+ * // }
41
+ * ```
42
+ *
43
+ * @example Using with List class
44
+ * ```typescript
45
+ * import { List } from '@skmtc/core';
46
+ *
47
+ * // List accepts any Stringable items
48
+ * const stringables: Stringable[] = [
49
+ * 'string literal',
50
+ * 42,
51
+ * true,
52
+ * { toString: () => 'custom object' },
53
+ * new CodeBlock('return value;')
54
+ * ];
55
+ *
56
+ * const list = new List(stringables);
57
+ * console.log(list.toString());
58
+ * // string literal, 42, true, custom object, {
59
+ * // return value;
60
+ * // }
61
+ * ```
62
+ *
63
+ * @example Type constraints in generics
64
+ * ```typescript
65
+ * function joinWithCommas<T extends Stringable>(items: T[]): string {
66
+ * return items.map(item => item.toString()).join(', ');
67
+ * }
68
+ *
69
+ * const result = joinWithCommas([1, 2, 3]); // "1, 2, 3"
70
+ * const identifiers = joinWithCommas([
71
+ * Identifier.createVariable('user'),
72
+ * Identifier.createType('User')
73
+ * ]); // "user, User"
74
+ * ```
75
+ */
1
76
  import "../_dnt.polyfills.js";
2
77
  export type Stringable = {
78
+ /** Converts the object to its string representation */
3
79
  toString: () => string;
4
80
  };
5
81
  //# sourceMappingURL=Stringable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Stringable.d.ts","sourceRoot":"","sources":["../../src/dsl/Stringable.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,MAAM,CAAA;CACvB,CAAA"}
1
+ {"version":3,"file":"Stringable.d.ts","sourceRoot":"","sources":["../../src/dsl/Stringable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,OAAO,sBAAsB,CAAC;AAE9B,MAAM,MAAM,UAAU,GAAG;IACvB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,MAAM,CAAA;CACvB,CAAA"}
@@ -1 +1,76 @@
1
+ /**
2
+ * Represents any object that can be converted to a string representation.
3
+ *
4
+ * The `Stringable` interface is a fundamental type used throughout the SKMTC DSL
5
+ * system to ensure that objects can be converted to strings for code generation.
6
+ * This interface matches JavaScript's built-in `toString()` contract and is used
7
+ * extensively by the {@link List} class and other string-building utilities.
8
+ *
9
+ * ## Usage in SKMTC
10
+ *
11
+ * This type is used as a constraint in generic classes and functions that need
12
+ * to output string representations. It allows for type-safe string building
13
+ * while accommodating both primitive types and custom objects.
14
+ *
15
+ * @example Built-in types are stringable
16
+ * ```typescript
17
+ * import type { Stringable } from '@skmtc/core';
18
+ *
19
+ * // All these types implement Stringable
20
+ * const str: Stringable = 'hello'; // string
21
+ * const num: Stringable = 42; // number
22
+ * const bool: Stringable = true; // boolean
23
+ * const obj: Stringable = { toString: () => 'custom' }; // custom object
24
+ * ```
25
+ *
26
+ * @example Custom classes implementing Stringable
27
+ * ```typescript
28
+ * class CodeBlock implements Stringable {
29
+ * constructor(private code: string) {}
30
+ *
31
+ * toString(): string {
32
+ * return `{\n ${this.code}\n}`;
33
+ * }
34
+ * }
35
+ *
36
+ * const block = new CodeBlock('console.log("hello");');
37
+ * console.log(block.toString());
38
+ * // {
39
+ * // console.log("hello");
40
+ * // }
41
+ * ```
42
+ *
43
+ * @example Using with List class
44
+ * ```typescript
45
+ * import { List } from '@skmtc/core';
46
+ *
47
+ * // List accepts any Stringable items
48
+ * const stringables: Stringable[] = [
49
+ * 'string literal',
50
+ * 42,
51
+ * true,
52
+ * { toString: () => 'custom object' },
53
+ * new CodeBlock('return value;')
54
+ * ];
55
+ *
56
+ * const list = new List(stringables);
57
+ * console.log(list.toString());
58
+ * // string literal, 42, true, custom object, {
59
+ * // return value;
60
+ * // }
61
+ * ```
62
+ *
63
+ * @example Type constraints in generics
64
+ * ```typescript
65
+ * function joinWithCommas<T extends Stringable>(items: T[]): string {
66
+ * return items.map(item => item.toString()).join(', ');
67
+ * }
68
+ *
69
+ * const result = joinWithCommas([1, 2, 3]); // "1, 2, 3"
70
+ * const identifiers = joinWithCommas([
71
+ * Identifier.createVariable('user'),
72
+ * Identifier.createType('User')
73
+ * ]); // "user, User"
74
+ * ```
75
+ */
1
76
  import "../_dnt.polyfills.js";