@skmtc/core 0.0.785 → 0.0.787

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 (93) hide show
  1. package/esm/dsl/ContentSettings.d.ts +164 -0
  2. package/esm/dsl/ContentSettings.d.ts.map +1 -1
  3. package/esm/dsl/ContentSettings.js +151 -0
  4. package/esm/dsl/Definition.d.ts +199 -0
  5. package/esm/dsl/Definition.d.ts.map +1 -1
  6. package/esm/dsl/Definition.js +189 -0
  7. package/esm/dsl/EntityType.d.ts +83 -0
  8. package/esm/dsl/EntityType.d.ts.map +1 -1
  9. package/esm/dsl/EntityType.js +83 -0
  10. package/esm/dsl/Identifier.d.ts +152 -0
  11. package/esm/dsl/Identifier.d.ts.map +1 -1
  12. package/esm/dsl/Identifier.js +152 -0
  13. package/esm/dsl/Import.d.ts +221 -0
  14. package/esm/dsl/Import.d.ts.map +1 -1
  15. package/esm/dsl/Import.js +202 -0
  16. package/esm/dsl/operation/OperationBase.d.ts +181 -1
  17. package/esm/dsl/operation/OperationBase.d.ts.map +1 -1
  18. package/esm/dsl/operation/OperationBase.js +181 -1
  19. package/esm/oas/array/Array.d.ts +109 -1
  20. package/esm/oas/array/Array.d.ts.map +1 -1
  21. package/esm/oas/array/Array.js +93 -1
  22. package/esm/oas/document/Document.d.ts +155 -1
  23. package/esm/oas/document/Document.d.ts.map +1 -1
  24. package/esm/oas/document/Document.js +141 -2
  25. package/esm/oas/integer/Integer.d.ts +98 -0
  26. package/esm/oas/integer/Integer.d.ts.map +1 -1
  27. package/esm/oas/integer/Integer.js +80 -0
  28. package/esm/oas/object/Object.d.ts +255 -10
  29. package/esm/oas/object/Object.d.ts.map +1 -1
  30. package/esm/oas/object/Object.js +229 -10
  31. package/esm/oas/string/String.d.ts +103 -1
  32. package/esm/oas/string/String.d.ts.map +1 -1
  33. package/esm/oas/string/String.js +87 -1
  34. package/esm/types/Brand.d.ts +74 -0
  35. package/esm/types/Brand.d.ts.map +1 -1
  36. package/esm/types/Brand.js +9 -0
  37. package/esm/types/GeneratorKeys.d.ts +336 -0
  38. package/esm/types/GeneratorKeys.d.ts.map +1 -1
  39. package/esm/types/GeneratorKeys.js +243 -0
  40. package/esm/types/GeneratorType.d.ts +119 -0
  41. package/esm/types/GeneratorType.d.ts.map +1 -1
  42. package/esm/types/Method.d.ts +109 -0
  43. package/esm/types/Method.d.ts.map +1 -1
  44. package/esm/types/Method.js +84 -0
  45. package/esm/types/RefName.d.ts +61 -0
  46. package/esm/types/RefName.d.ts.map +1 -1
  47. package/package.json +1 -1
  48. package/script/dsl/ContentSettings.d.ts +164 -0
  49. package/script/dsl/ContentSettings.d.ts.map +1 -1
  50. package/script/dsl/ContentSettings.js +151 -0
  51. package/script/dsl/Definition.d.ts +199 -0
  52. package/script/dsl/Definition.d.ts.map +1 -1
  53. package/script/dsl/Definition.js +189 -0
  54. package/script/dsl/EntityType.d.ts +83 -0
  55. package/script/dsl/EntityType.d.ts.map +1 -1
  56. package/script/dsl/EntityType.js +83 -0
  57. package/script/dsl/Identifier.d.ts +152 -0
  58. package/script/dsl/Identifier.d.ts.map +1 -1
  59. package/script/dsl/Identifier.js +152 -0
  60. package/script/dsl/Import.d.ts +221 -0
  61. package/script/dsl/Import.d.ts.map +1 -1
  62. package/script/dsl/Import.js +202 -0
  63. package/script/dsl/operation/OperationBase.d.ts +181 -1
  64. package/script/dsl/operation/OperationBase.d.ts.map +1 -1
  65. package/script/dsl/operation/OperationBase.js +181 -1
  66. package/script/oas/array/Array.d.ts +109 -1
  67. package/script/oas/array/Array.d.ts.map +1 -1
  68. package/script/oas/array/Array.js +93 -1
  69. package/script/oas/document/Document.d.ts +155 -1
  70. package/script/oas/document/Document.d.ts.map +1 -1
  71. package/script/oas/document/Document.js +141 -2
  72. package/script/oas/integer/Integer.d.ts +98 -0
  73. package/script/oas/integer/Integer.d.ts.map +1 -1
  74. package/script/oas/integer/Integer.js +80 -0
  75. package/script/oas/object/Object.d.ts +255 -10
  76. package/script/oas/object/Object.d.ts.map +1 -1
  77. package/script/oas/object/Object.js +229 -10
  78. package/script/oas/string/String.d.ts +103 -1
  79. package/script/oas/string/String.d.ts.map +1 -1
  80. package/script/oas/string/String.js +87 -1
  81. package/script/types/Brand.d.ts +74 -0
  82. package/script/types/Brand.d.ts.map +1 -1
  83. package/script/types/Brand.js +9 -0
  84. package/script/types/GeneratorKeys.d.ts +336 -0
  85. package/script/types/GeneratorKeys.d.ts.map +1 -1
  86. package/script/types/GeneratorKeys.js +243 -0
  87. package/script/types/GeneratorType.d.ts +119 -0
  88. package/script/types/GeneratorType.d.ts.map +1 -1
  89. package/script/types/Method.d.ts +109 -0
  90. package/script/types/Method.d.ts.map +1 -1
  91. package/script/types/Method.js +84 -0
  92. package/script/types/RefName.d.ts +61 -0
  93. package/script/types/RefName.d.ts.map +1 -1
@@ -3,48 +3,384 @@ import type { OasOperation } from '../oas/operation/Operation.js';
3
3
  import type { Brand } from './Brand.js';
4
4
  import type { RefName } from './RefName.js';
5
5
  import { type Method } from './Method.js';
6
+ /**
7
+ * Template literal type for operation generator keys before branding.
8
+ * Format: `generatorId|path|method` (e.g., 'api-client|/users|get')
9
+ */
6
10
  export type NakedOperationGeneratorKey = `${string}|${string}|${Method}`;
11
+ /**
12
+ * Template literal type for model generator keys before branding.
13
+ * Format: `generatorId|refName` (e.g., 'typescript-models|User')
14
+ */
7
15
  export type NakedModelGeneratorKey = `${string}|${string}`;
16
+ /**
17
+ * Branded type for operation generator keys.
18
+ *
19
+ * Operation generator keys uniquely identify generators that process
20
+ * OpenAPI operations (HTTP methods on API paths). The key encodes
21
+ * the generator ID, API path, and HTTP method.
22
+ */
8
23
  export type OperationGeneratorKey = Brand<NakedOperationGeneratorKey, 'OperationGeneratorKey'>;
24
+ /**
25
+ * Branded type for model generator keys.
26
+ *
27
+ * Model generator keys uniquely identify generators that process
28
+ * OpenAPI schema models. The key encodes the generator ID and
29
+ * the schema reference name.
30
+ */
9
31
  export type ModelGeneratorKey = Brand<NakedModelGeneratorKey, 'ModelGeneratorKey'>;
32
+ /**
33
+ * Branded type for generator-only keys.
34
+ *
35
+ * Generator-only keys identify generators that don't process specific
36
+ * operations or models, but generate global artifacts like configuration
37
+ * files, base classes, or utility modules.
38
+ */
10
39
  export type GeneratorOnlyKey = Brand<string, 'GeneratorOnlyKey'>;
40
+ /**
41
+ * Union type of all possible generator key types.
42
+ *
43
+ * Generator keys serve as unique identifiers for different types of
44
+ * code generators in the SKMTC system. They enable tracking, caching,
45
+ * and dependency management between generated artifacts.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // Operation generator key
50
+ * const opKey: GeneratorKey = toOperationGeneratorKey({
51
+ * generatorId: 'api-client',
52
+ * path: '/users/{id}',
53
+ * method: 'get'
54
+ * });
55
+ *
56
+ * // Model generator key
57
+ * const modelKey: GeneratorKey = toModelGeneratorKey({
58
+ * generatorId: 'typescript-types',
59
+ * refName: 'User'
60
+ * });
61
+ *
62
+ * // Generator-only key
63
+ * const globalKey: GeneratorKey = toGeneratorOnlyKey({
64
+ * generatorId: 'api-config'
65
+ * });
66
+ * ```
67
+ */
11
68
  export type GeneratorKey = OperationGeneratorKey | ModelGeneratorKey | GeneratorOnlyKey;
69
+ /**
70
+ * Arguments for {@link toOperationGeneratorKey}.
71
+ *
72
+ * Can specify operation details directly or provide an OasOperation
73
+ * object from which the path and method will be extracted.
74
+ */
12
75
  type ToOperationGeneratorKeyArgs = {
76
+ /** Unique identifier for the generator */
13
77
  generatorId: string;
78
+ /** API path (e.g., '/users/{id}') */
14
79
  path: string;
80
+ /** HTTP method */
15
81
  method: Method;
16
82
  } | {
83
+ /** Unique identifier for the generator */
17
84
  generatorId: string;
85
+ /** OpenAPI operation object containing path and method */
18
86
  operation: OasOperation;
19
87
  };
88
+ /**
89
+ * Creates an operation generator key from generator ID and operation details.
90
+ *
91
+ * Operation generator keys uniquely identify generators processing specific
92
+ * API operations. The key format is: `generatorId|path|method`
93
+ *
94
+ * @param args - Operation generator key arguments
95
+ * @returns A branded OperationGeneratorKey
96
+ *
97
+ * @example With explicit path and method
98
+ * ```typescript
99
+ * const key = toOperationGeneratorKey({
100
+ * generatorId: 'api-client',
101
+ * path: '/users/{id}',
102
+ * method: 'get'
103
+ * });
104
+ * // Result: 'api-client|/users/{id}|get' (branded)
105
+ * ```
106
+ *
107
+ * @example With OasOperation object
108
+ * ```typescript
109
+ * const operation = new OasOperation({
110
+ * path: '/posts',
111
+ * method: 'post',
112
+ * // ... other operation details
113
+ * });
114
+ *
115
+ * const key = toOperationGeneratorKey({
116
+ * generatorId: 'rest-client',
117
+ * operation
118
+ * });
119
+ * // Result: 'rest-client|/posts|post' (branded)
120
+ * ```
121
+ */
20
122
  export declare const toOperationGeneratorKey: ({ generatorId, ...rest }: ToOperationGeneratorKeyArgs) => OperationGeneratorKey;
123
+ /**
124
+ * Arguments for {@link toModelGeneratorKey}.
125
+ */
21
126
  type ToModelGeneratorKeyArgs = {
127
+ /** Unique identifier for the generator */
22
128
  generatorId: string;
129
+ /** Reference name of the schema model */
23
130
  refName: RefName;
24
131
  };
132
+ /**
133
+ * Creates a model generator key from generator ID and schema reference name.
134
+ *
135
+ * Model generator keys uniquely identify generators processing specific
136
+ * OpenAPI schema models. The key format is: `generatorId|refName`
137
+ *
138
+ * @param args - Model generator key arguments
139
+ * @returns A branded ModelGeneratorKey
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * const key = toModelGeneratorKey({
144
+ * generatorId: 'typescript-interfaces',
145
+ * refName: 'User'
146
+ * });
147
+ * // Result: 'typescript-interfaces|User' (branded)
148
+ *
149
+ * const validationKey = toModelGeneratorKey({
150
+ * generatorId: 'zod-schemas',
151
+ * refName: 'CreateUserRequest'
152
+ * });
153
+ * // Result: 'zod-schemas|CreateUserRequest' (branded)
154
+ * ```
155
+ */
25
156
  export declare const toModelGeneratorKey: ({ generatorId, refName }: ToModelGeneratorKeyArgs) => ModelGeneratorKey;
157
+ /**
158
+ * Arguments for {@link toGeneratorOnlyKey}.
159
+ */
26
160
  type ToGeneratorOnlyKeyArgs = {
161
+ /** Unique identifier for the generator */
27
162
  generatorId: string;
28
163
  };
164
+ /**
165
+ * Creates a generator-only key for global/utility generators.
166
+ *
167
+ * Generator-only keys identify generators that produce artifacts not tied
168
+ * to specific operations or models, such as configuration files, base classes,
169
+ * utilities, or documentation.
170
+ *
171
+ * @param args - Generator-only key arguments
172
+ * @returns A branded GeneratorOnlyKey
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * const configKey = toGeneratorOnlyKey({
177
+ * generatorId: 'api-config'
178
+ * });
179
+ * // Result: 'api-config' (branded)
180
+ *
181
+ * const utilsKey = toGeneratorOnlyKey({
182
+ * generatorId: 'common-utilities'
183
+ * });
184
+ * // Result: 'common-utilities' (branded)
185
+ * ```
186
+ */
29
187
  export declare const toGeneratorOnlyKey: ({ generatorId }: ToGeneratorOnlyKeyArgs) => GeneratorOnlyKey;
188
+ /**
189
+ * Type guard to check if a value is a valid GeneratorKey.
190
+ *
191
+ * This function validates that the argument is one of the three
192
+ * generator key types: operation, model, or generator-only.
193
+ *
194
+ * @param arg - Value to check
195
+ * @returns True if the value is a valid GeneratorKey
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const key = 'api-client|/users|get';
200
+ *
201
+ * if (isGeneratorKey(key)) {
202
+ * // key is now typed as GeneratorKey
203
+ * const generatorId = toGeneratorId(key);
204
+ * console.log(generatorId); // 'api-client'
205
+ * }
206
+ * ```
207
+ */
30
208
  export declare const isGeneratorKey: (arg: unknown) => arg is GeneratorKey;
209
+ /**
210
+ * Type guard to check if a value is a valid OperationGeneratorKey.
211
+ *
212
+ * Validates that the argument is a string with the correct format:
213
+ * `generatorId|path|method` where each part is non-empty and method
214
+ * is a valid HTTP method.
215
+ *
216
+ * @param arg - Value to check
217
+ * @returns True if the value is a valid OperationGeneratorKey
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const key = 'api-client|/users/{id}|get';
222
+ *
223
+ * if (isOperationGeneratorKey(key)) {
224
+ * // key is now typed as OperationGeneratorKey
225
+ * const obj = fromGeneratorKey(key);
226
+ * console.log(obj.type); // 'operation'
227
+ * console.log(obj.generatorId); // 'api-client'
228
+ * console.log(obj.path); // '/users/{id}'
229
+ * console.log(obj.method); // 'get'
230
+ * }
231
+ * ```
232
+ */
31
233
  export declare const isOperationGeneratorKey: (arg: unknown) => arg is OperationGeneratorKey;
234
+ /**
235
+ * Type guard to check if a value is a valid ModelGeneratorKey.
236
+ *
237
+ * Validates that the argument is a string with the correct format:
238
+ * `generatorId|refName` where both parts are non-empty strings.
239
+ *
240
+ * @param arg - Value to check
241
+ * @returns True if the value is a valid ModelGeneratorKey
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * const key = 'zod-schemas|User';
246
+ *
247
+ * if (isModelGeneratorKey(key)) {
248
+ * // key is now typed as ModelGeneratorKey
249
+ * const obj = fromGeneratorKey(key);
250
+ * console.log(obj.type); // 'model'
251
+ * console.log(obj.generatorId); // 'zod-schemas'
252
+ * console.log(obj.refName); // 'User'
253
+ * }
254
+ * ```
255
+ */
32
256
  export declare const isModelGeneratorKey: (arg: unknown) => arg is ModelGeneratorKey;
257
+ /**
258
+ * Type guard to check if a value is a valid GeneratorOnlyKey.
259
+ *
260
+ * Validates that the argument is a non-empty string. Generator-only keys
261
+ * are simple strings containing just the generator ID.
262
+ *
263
+ * @param arg - Value to check
264
+ * @returns True if the value is a valid GeneratorOnlyKey
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * const key = 'api-config';
269
+ *
270
+ * if (isGeneratorOnlyKey(key)) {
271
+ * // key is now typed as GeneratorOnlyKey
272
+ * const obj = fromGeneratorKey(key);
273
+ * console.log(obj.type); // 'generator-only'
274
+ * console.log(obj.generatorId); // 'api-config'
275
+ * }
276
+ * ```
277
+ */
33
278
  export declare const isGeneratorOnlyKey: (arg: unknown) => arg is GeneratorOnlyKey;
279
+ /**
280
+ * Extracts the generator ID from any type of GeneratorKey.
281
+ *
282
+ * This utility function parses the generator key to extract just the
283
+ * generator identifier, regardless of the key type. For operation and
284
+ * model keys, it extracts the first part before the pipe. For generator-only
285
+ * keys, it returns the entire key since it's just the generator ID.
286
+ *
287
+ * @param generatorKey - Any type of generator key
288
+ * @returns The generator ID string
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * const opKey = toOperationGeneratorKey({
293
+ * generatorId: 'api-client',
294
+ * path: '/users',
295
+ * method: 'get'
296
+ * });
297
+ * console.log(toGeneratorId(opKey)); // 'api-client'
298
+ *
299
+ * const modelKey = toModelGeneratorKey({
300
+ * generatorId: 'typescript-types',
301
+ * refName: 'User'
302
+ * });
303
+ * console.log(toGeneratorId(modelKey)); // 'typescript-types'
304
+ *
305
+ * const globalKey = toGeneratorOnlyKey({
306
+ * generatorId: 'utilities'
307
+ * });
308
+ * console.log(toGeneratorId(globalKey)); // 'utilities'
309
+ * ```
310
+ */
34
311
  export declare const toGeneratorId: (generatorKey: GeneratorKey) => string;
312
+ /**
313
+ * Object representation of a parsed GeneratorKey.
314
+ *
315
+ * This discriminated union type represents the parsed components of any
316
+ * generator key, making it easier to work with key data in a structured way.
317
+ * The `type` field discriminates between the three key types.
318
+ */
35
319
  export type GeneratorKeyObject = {
320
+ /** Discriminator for operation generator keys */
36
321
  type: 'operation';
322
+ /** Generator identifier */
37
323
  generatorId: string;
324
+ /** API path */
38
325
  path: string;
326
+ /** HTTP method */
39
327
  method: Method;
40
328
  } | {
329
+ /** Discriminator for model generator keys */
41
330
  type: 'model';
331
+ /** Generator identifier */
42
332
  generatorId: string;
333
+ /** Schema reference name */
43
334
  refName: string;
44
335
  } | {
336
+ /** Discriminator for generator-only keys */
45
337
  type: 'generator-only';
338
+ /** Generator identifier */
46
339
  generatorId: string;
47
340
  };
341
+ /**
342
+ * Parses a GeneratorKey into its structured object representation.
343
+ *
344
+ * This function decomposes any generator key into a structured object
345
+ * with discriminated union types, making it easier to work with the
346
+ * key components in a type-safe manner.
347
+ *
348
+ * @param generatorKey - Any type of generator key to parse
349
+ * @returns Parsed generator key object with discriminated type
350
+ *
351
+ * @example Operation key parsing
352
+ * ```typescript
353
+ * const opKey = 'api-client|/users/{id}|get' as OperationGeneratorKey;
354
+ * const parsed = fromGeneratorKey(opKey);
355
+ *
356
+ * if (parsed.type === 'operation') {
357
+ * console.log(parsed.generatorId); // 'api-client'
358
+ * console.log(parsed.path); // '/users/{id}'
359
+ * console.log(parsed.method); // 'get'
360
+ * }
361
+ * ```
362
+ *
363
+ * @example Model key parsing
364
+ * ```typescript
365
+ * const modelKey = 'zod-schemas|User' as ModelGeneratorKey;
366
+ * const parsed = fromGeneratorKey(modelKey);
367
+ *
368
+ * if (parsed.type === 'model') {
369
+ * console.log(parsed.generatorId); // 'zod-schemas'
370
+ * console.log(parsed.refName); // 'User'
371
+ * }
372
+ * ```
373
+ *
374
+ * @example Generator-only key parsing
375
+ * ```typescript
376
+ * const globalKey = 'utilities' as GeneratorOnlyKey;
377
+ * const parsed = fromGeneratorKey(globalKey);
378
+ *
379
+ * if (parsed.type === 'generator-only') {
380
+ * console.log(parsed.generatorId); // 'utilities'
381
+ * }
382
+ * ```
383
+ */
48
384
  export declare const fromGeneratorKey: (generatorKey: GeneratorKey) => GeneratorKeyObject;
49
385
  export {};
50
386
  //# sourceMappingURL=GeneratorKeys.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GeneratorKeys.d.ts","sourceRoot":"","sources":["../../src/types/GeneratorKeys.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,KAAK,MAAM,EAAY,MAAM,aAAa,CAAA;AAEnD,MAAM,MAAM,0BAA0B,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,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,qBA0BT,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,iBAsBzD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,gBAMxD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,aAAa,GAAI,cAAc,YAAY,KAAG,MAU1D,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,iDAAiD;IACjD,IAAI,EAAE,WAAW,CAAA;IACjB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAA;CACf,GACD;IACE,6CAA6C;IAC7C,IAAI,EAAE,OAAO,CAAA;IACb,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAA;CAChB,GACD;IACE,4CAA4C;IAC5C,IAAI,EAAE,gBAAgB,CAAA;IACtB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,gBAAgB,GAC3B,cAAc,YAAY,KACzB,kBAYF,CAAA"}
@@ -1,23 +1,148 @@
1
1
  import "../_dnt.polyfills.js";
2
2
  import { isMethod } from './Method.js';
3
+ /**
4
+ * Creates an operation generator key from generator ID and operation details.
5
+ *
6
+ * Operation generator keys uniquely identify generators processing specific
7
+ * API operations. The key format is: `generatorId|path|method`
8
+ *
9
+ * @param args - Operation generator key arguments
10
+ * @returns A branded OperationGeneratorKey
11
+ *
12
+ * @example With explicit path and method
13
+ * ```typescript
14
+ * const key = toOperationGeneratorKey({
15
+ * generatorId: 'api-client',
16
+ * path: '/users/{id}',
17
+ * method: 'get'
18
+ * });
19
+ * // Result: 'api-client|/users/{id}|get' (branded)
20
+ * ```
21
+ *
22
+ * @example With OasOperation object
23
+ * ```typescript
24
+ * const operation = new OasOperation({
25
+ * path: '/posts',
26
+ * method: 'post',
27
+ * // ... other operation details
28
+ * });
29
+ *
30
+ * const key = toOperationGeneratorKey({
31
+ * generatorId: 'rest-client',
32
+ * operation
33
+ * });
34
+ * // Result: 'rest-client|/posts|post' (branded)
35
+ * ```
36
+ */
3
37
  export const toOperationGeneratorKey = ({ generatorId, ...rest }) => {
4
38
  const { path, method } = 'operation' in rest ? rest.operation : rest;
5
39
  const nakedKey = `${generatorId}|${path}|${method}`;
6
40
  return nakedKey;
7
41
  };
42
+ /**
43
+ * Creates a model generator key from generator ID and schema reference name.
44
+ *
45
+ * Model generator keys uniquely identify generators processing specific
46
+ * OpenAPI schema models. The key format is: `generatorId|refName`
47
+ *
48
+ * @param args - Model generator key arguments
49
+ * @returns A branded ModelGeneratorKey
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const key = toModelGeneratorKey({
54
+ * generatorId: 'typescript-interfaces',
55
+ * refName: 'User'
56
+ * });
57
+ * // Result: 'typescript-interfaces|User' (branded)
58
+ *
59
+ * const validationKey = toModelGeneratorKey({
60
+ * generatorId: 'zod-schemas',
61
+ * refName: 'CreateUserRequest'
62
+ * });
63
+ * // Result: 'zod-schemas|CreateUserRequest' (branded)
64
+ * ```
65
+ */
8
66
  export const toModelGeneratorKey = ({ generatorId, refName }) => {
9
67
  const nakedKey = `${generatorId}|${refName}`;
10
68
  return nakedKey;
11
69
  };
70
+ /**
71
+ * Creates a generator-only key for global/utility generators.
72
+ *
73
+ * Generator-only keys identify generators that produce artifacts not tied
74
+ * to specific operations or models, such as configuration files, base classes,
75
+ * utilities, or documentation.
76
+ *
77
+ * @param args - Generator-only key arguments
78
+ * @returns A branded GeneratorOnlyKey
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const configKey = toGeneratorOnlyKey({
83
+ * generatorId: 'api-config'
84
+ * });
85
+ * // Result: 'api-config' (branded)
86
+ *
87
+ * const utilsKey = toGeneratorOnlyKey({
88
+ * generatorId: 'common-utilities'
89
+ * });
90
+ * // Result: 'common-utilities' (branded)
91
+ * ```
92
+ */
12
93
  export const toGeneratorOnlyKey = ({ generatorId }) => {
13
94
  const nakedKey = `${generatorId}`;
14
95
  return nakedKey;
15
96
  };
97
+ /**
98
+ * Type guard to check if a value is a valid GeneratorKey.
99
+ *
100
+ * This function validates that the argument is one of the three
101
+ * generator key types: operation, model, or generator-only.
102
+ *
103
+ * @param arg - Value to check
104
+ * @returns True if the value is a valid GeneratorKey
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const key = 'api-client|/users|get';
109
+ *
110
+ * if (isGeneratorKey(key)) {
111
+ * // key is now typed as GeneratorKey
112
+ * const generatorId = toGeneratorId(key);
113
+ * console.log(generatorId); // 'api-client'
114
+ * }
115
+ * ```
116
+ */
16
117
  export const isGeneratorKey = (arg) => {
17
118
  return (isModelGeneratorKey(arg) ||
18
119
  isOperationGeneratorKey(arg) ||
19
120
  isGeneratorOnlyKey(arg));
20
121
  };
122
+ /**
123
+ * Type guard to check if a value is a valid OperationGeneratorKey.
124
+ *
125
+ * Validates that the argument is a string with the correct format:
126
+ * `generatorId|path|method` where each part is non-empty and method
127
+ * is a valid HTTP method.
128
+ *
129
+ * @param arg - Value to check
130
+ * @returns True if the value is a valid OperationGeneratorKey
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const key = 'api-client|/users/{id}|get';
135
+ *
136
+ * if (isOperationGeneratorKey(key)) {
137
+ * // key is now typed as OperationGeneratorKey
138
+ * const obj = fromGeneratorKey(key);
139
+ * console.log(obj.type); // 'operation'
140
+ * console.log(obj.generatorId); // 'api-client'
141
+ * console.log(obj.path); // '/users/{id}'
142
+ * console.log(obj.method); // 'get'
143
+ * }
144
+ * ```
145
+ */
21
146
  export const isOperationGeneratorKey = (arg) => {
22
147
  if (typeof arg !== 'string') {
23
148
  return false;
@@ -38,6 +163,28 @@ export const isOperationGeneratorKey = (arg) => {
38
163
  }
39
164
  return true;
40
165
  };
166
+ /**
167
+ * Type guard to check if a value is a valid ModelGeneratorKey.
168
+ *
169
+ * Validates that the argument is a string with the correct format:
170
+ * `generatorId|refName` where both parts are non-empty strings.
171
+ *
172
+ * @param arg - Value to check
173
+ * @returns True if the value is a valid ModelGeneratorKey
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const key = 'zod-schemas|User';
178
+ *
179
+ * if (isModelGeneratorKey(key)) {
180
+ * // key is now typed as ModelGeneratorKey
181
+ * const obj = fromGeneratorKey(key);
182
+ * console.log(obj.type); // 'model'
183
+ * console.log(obj.generatorId); // 'zod-schemas'
184
+ * console.log(obj.refName); // 'User'
185
+ * }
186
+ * ```
187
+ */
41
188
  export const isModelGeneratorKey = (arg) => {
42
189
  if (typeof arg !== 'string') {
43
190
  return false;
@@ -55,12 +202,65 @@ export const isModelGeneratorKey = (arg) => {
55
202
  }
56
203
  return true;
57
204
  };
205
+ /**
206
+ * Type guard to check if a value is a valid GeneratorOnlyKey.
207
+ *
208
+ * Validates that the argument is a non-empty string. Generator-only keys
209
+ * are simple strings containing just the generator ID.
210
+ *
211
+ * @param arg - Value to check
212
+ * @returns True if the value is a valid GeneratorOnlyKey
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const key = 'api-config';
217
+ *
218
+ * if (isGeneratorOnlyKey(key)) {
219
+ * // key is now typed as GeneratorOnlyKey
220
+ * const obj = fromGeneratorKey(key);
221
+ * console.log(obj.type); // 'generator-only'
222
+ * console.log(obj.generatorId); // 'api-config'
223
+ * }
224
+ * ```
225
+ */
58
226
  export const isGeneratorOnlyKey = (arg) => {
59
227
  if (typeof arg !== 'string') {
60
228
  return false;
61
229
  }
62
230
  return Boolean(arg.length);
63
231
  };
232
+ /**
233
+ * Extracts the generator ID from any type of GeneratorKey.
234
+ *
235
+ * This utility function parses the generator key to extract just the
236
+ * generator identifier, regardless of the key type. For operation and
237
+ * model keys, it extracts the first part before the pipe. For generator-only
238
+ * keys, it returns the entire key since it's just the generator ID.
239
+ *
240
+ * @param generatorKey - Any type of generator key
241
+ * @returns The generator ID string
242
+ *
243
+ * @example
244
+ * ```typescript
245
+ * const opKey = toOperationGeneratorKey({
246
+ * generatorId: 'api-client',
247
+ * path: '/users',
248
+ * method: 'get'
249
+ * });
250
+ * console.log(toGeneratorId(opKey)); // 'api-client'
251
+ *
252
+ * const modelKey = toModelGeneratorKey({
253
+ * generatorId: 'typescript-types',
254
+ * refName: 'User'
255
+ * });
256
+ * console.log(toGeneratorId(modelKey)); // 'typescript-types'
257
+ *
258
+ * const globalKey = toGeneratorOnlyKey({
259
+ * generatorId: 'utilities'
260
+ * });
261
+ * console.log(toGeneratorId(globalKey)); // 'utilities'
262
+ * ```
263
+ */
64
264
  export const toGeneratorId = (generatorKey) => {
65
265
  if (isOperationGeneratorKey(generatorKey)) {
66
266
  return generatorKey.split('|')[0];
@@ -70,6 +270,49 @@ export const toGeneratorId = (generatorKey) => {
70
270
  }
71
271
  return generatorKey;
72
272
  };
273
+ /**
274
+ * Parses a GeneratorKey into its structured object representation.
275
+ *
276
+ * This function decomposes any generator key into a structured object
277
+ * with discriminated union types, making it easier to work with the
278
+ * key components in a type-safe manner.
279
+ *
280
+ * @param generatorKey - Any type of generator key to parse
281
+ * @returns Parsed generator key object with discriminated type
282
+ *
283
+ * @example Operation key parsing
284
+ * ```typescript
285
+ * const opKey = 'api-client|/users/{id}|get' as OperationGeneratorKey;
286
+ * const parsed = fromGeneratorKey(opKey);
287
+ *
288
+ * if (parsed.type === 'operation') {
289
+ * console.log(parsed.generatorId); // 'api-client'
290
+ * console.log(parsed.path); // '/users/{id}'
291
+ * console.log(parsed.method); // 'get'
292
+ * }
293
+ * ```
294
+ *
295
+ * @example Model key parsing
296
+ * ```typescript
297
+ * const modelKey = 'zod-schemas|User' as ModelGeneratorKey;
298
+ * const parsed = fromGeneratorKey(modelKey);
299
+ *
300
+ * if (parsed.type === 'model') {
301
+ * console.log(parsed.generatorId); // 'zod-schemas'
302
+ * console.log(parsed.refName); // 'User'
303
+ * }
304
+ * ```
305
+ *
306
+ * @example Generator-only key parsing
307
+ * ```typescript
308
+ * const globalKey = 'utilities' as GeneratorOnlyKey;
309
+ * const parsed = fromGeneratorKey(globalKey);
310
+ *
311
+ * if (parsed.type === 'generator-only') {
312
+ * console.log(parsed.generatorId); // 'utilities'
313
+ * }
314
+ * ```
315
+ */
73
316
  export const fromGeneratorKey = (generatorKey) => {
74
317
  if (isOperationGeneratorKey(generatorKey)) {
75
318
  const [generatorId, path, method] = generatorKey.split('|');