@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"}
@@ -3,28 +3,153 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fromGeneratorKey = exports.toGeneratorId = exports.isGeneratorOnlyKey = exports.isModelGeneratorKey = exports.isOperationGeneratorKey = exports.isGeneratorKey = exports.toGeneratorOnlyKey = exports.toModelGeneratorKey = exports.toOperationGeneratorKey = void 0;
4
4
  require("../_dnt.polyfills.js");
5
5
  const Method_js_1 = require("./Method.js");
6
+ /**
7
+ * Creates an operation generator key from generator ID and operation details.
8
+ *
9
+ * Operation generator keys uniquely identify generators processing specific
10
+ * API operations. The key format is: `generatorId|path|method`
11
+ *
12
+ * @param args - Operation generator key arguments
13
+ * @returns A branded OperationGeneratorKey
14
+ *
15
+ * @example With explicit path and method
16
+ * ```typescript
17
+ * const key = toOperationGeneratorKey({
18
+ * generatorId: 'api-client',
19
+ * path: '/users/{id}',
20
+ * method: 'get'
21
+ * });
22
+ * // Result: 'api-client|/users/{id}|get' (branded)
23
+ * ```
24
+ *
25
+ * @example With OasOperation object
26
+ * ```typescript
27
+ * const operation = new OasOperation({
28
+ * path: '/posts',
29
+ * method: 'post',
30
+ * // ... other operation details
31
+ * });
32
+ *
33
+ * const key = toOperationGeneratorKey({
34
+ * generatorId: 'rest-client',
35
+ * operation
36
+ * });
37
+ * // Result: 'rest-client|/posts|post' (branded)
38
+ * ```
39
+ */
6
40
  const toOperationGeneratorKey = ({ generatorId, ...rest }) => {
7
41
  const { path, method } = 'operation' in rest ? rest.operation : rest;
8
42
  const nakedKey = `${generatorId}|${path}|${method}`;
9
43
  return nakedKey;
10
44
  };
11
45
  exports.toOperationGeneratorKey = toOperationGeneratorKey;
46
+ /**
47
+ * Creates a model generator key from generator ID and schema reference name.
48
+ *
49
+ * Model generator keys uniquely identify generators processing specific
50
+ * OpenAPI schema models. The key format is: `generatorId|refName`
51
+ *
52
+ * @param args - Model generator key arguments
53
+ * @returns A branded ModelGeneratorKey
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const key = toModelGeneratorKey({
58
+ * generatorId: 'typescript-interfaces',
59
+ * refName: 'User'
60
+ * });
61
+ * // Result: 'typescript-interfaces|User' (branded)
62
+ *
63
+ * const validationKey = toModelGeneratorKey({
64
+ * generatorId: 'zod-schemas',
65
+ * refName: 'CreateUserRequest'
66
+ * });
67
+ * // Result: 'zod-schemas|CreateUserRequest' (branded)
68
+ * ```
69
+ */
12
70
  const toModelGeneratorKey = ({ generatorId, refName }) => {
13
71
  const nakedKey = `${generatorId}|${refName}`;
14
72
  return nakedKey;
15
73
  };
16
74
  exports.toModelGeneratorKey = toModelGeneratorKey;
75
+ /**
76
+ * Creates a generator-only key for global/utility generators.
77
+ *
78
+ * Generator-only keys identify generators that produce artifacts not tied
79
+ * to specific operations or models, such as configuration files, base classes,
80
+ * utilities, or documentation.
81
+ *
82
+ * @param args - Generator-only key arguments
83
+ * @returns A branded GeneratorOnlyKey
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const configKey = toGeneratorOnlyKey({
88
+ * generatorId: 'api-config'
89
+ * });
90
+ * // Result: 'api-config' (branded)
91
+ *
92
+ * const utilsKey = toGeneratorOnlyKey({
93
+ * generatorId: 'common-utilities'
94
+ * });
95
+ * // Result: 'common-utilities' (branded)
96
+ * ```
97
+ */
17
98
  const toGeneratorOnlyKey = ({ generatorId }) => {
18
99
  const nakedKey = `${generatorId}`;
19
100
  return nakedKey;
20
101
  };
21
102
  exports.toGeneratorOnlyKey = toGeneratorOnlyKey;
103
+ /**
104
+ * Type guard to check if a value is a valid GeneratorKey.
105
+ *
106
+ * This function validates that the argument is one of the three
107
+ * generator key types: operation, model, or generator-only.
108
+ *
109
+ * @param arg - Value to check
110
+ * @returns True if the value is a valid GeneratorKey
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const key = 'api-client|/users|get';
115
+ *
116
+ * if (isGeneratorKey(key)) {
117
+ * // key is now typed as GeneratorKey
118
+ * const generatorId = toGeneratorId(key);
119
+ * console.log(generatorId); // 'api-client'
120
+ * }
121
+ * ```
122
+ */
22
123
  const isGeneratorKey = (arg) => {
23
124
  return ((0, exports.isModelGeneratorKey)(arg) ||
24
125
  (0, exports.isOperationGeneratorKey)(arg) ||
25
126
  (0, exports.isGeneratorOnlyKey)(arg));
26
127
  };
27
128
  exports.isGeneratorKey = isGeneratorKey;
129
+ /**
130
+ * Type guard to check if a value is a valid OperationGeneratorKey.
131
+ *
132
+ * Validates that the argument is a string with the correct format:
133
+ * `generatorId|path|method` where each part is non-empty and method
134
+ * is a valid HTTP method.
135
+ *
136
+ * @param arg - Value to check
137
+ * @returns True if the value is a valid OperationGeneratorKey
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * const key = 'api-client|/users/{id}|get';
142
+ *
143
+ * if (isOperationGeneratorKey(key)) {
144
+ * // key is now typed as OperationGeneratorKey
145
+ * const obj = fromGeneratorKey(key);
146
+ * console.log(obj.type); // 'operation'
147
+ * console.log(obj.generatorId); // 'api-client'
148
+ * console.log(obj.path); // '/users/{id}'
149
+ * console.log(obj.method); // 'get'
150
+ * }
151
+ * ```
152
+ */
28
153
  const isOperationGeneratorKey = (arg) => {
29
154
  if (typeof arg !== 'string') {
30
155
  return false;
@@ -46,6 +171,28 @@ const isOperationGeneratorKey = (arg) => {
46
171
  return true;
47
172
  };
48
173
  exports.isOperationGeneratorKey = isOperationGeneratorKey;
174
+ /**
175
+ * Type guard to check if a value is a valid ModelGeneratorKey.
176
+ *
177
+ * Validates that the argument is a string with the correct format:
178
+ * `generatorId|refName` where both parts are non-empty strings.
179
+ *
180
+ * @param arg - Value to check
181
+ * @returns True if the value is a valid ModelGeneratorKey
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const key = 'zod-schemas|User';
186
+ *
187
+ * if (isModelGeneratorKey(key)) {
188
+ * // key is now typed as ModelGeneratorKey
189
+ * const obj = fromGeneratorKey(key);
190
+ * console.log(obj.type); // 'model'
191
+ * console.log(obj.generatorId); // 'zod-schemas'
192
+ * console.log(obj.refName); // 'User'
193
+ * }
194
+ * ```
195
+ */
49
196
  const isModelGeneratorKey = (arg) => {
50
197
  if (typeof arg !== 'string') {
51
198
  return false;
@@ -64,6 +211,27 @@ const isModelGeneratorKey = (arg) => {
64
211
  return true;
65
212
  };
66
213
  exports.isModelGeneratorKey = isModelGeneratorKey;
214
+ /**
215
+ * Type guard to check if a value is a valid GeneratorOnlyKey.
216
+ *
217
+ * Validates that the argument is a non-empty string. Generator-only keys
218
+ * are simple strings containing just the generator ID.
219
+ *
220
+ * @param arg - Value to check
221
+ * @returns True if the value is a valid GeneratorOnlyKey
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * const key = 'api-config';
226
+ *
227
+ * if (isGeneratorOnlyKey(key)) {
228
+ * // key is now typed as GeneratorOnlyKey
229
+ * const obj = fromGeneratorKey(key);
230
+ * console.log(obj.type); // 'generator-only'
231
+ * console.log(obj.generatorId); // 'api-config'
232
+ * }
233
+ * ```
234
+ */
67
235
  const isGeneratorOnlyKey = (arg) => {
68
236
  if (typeof arg !== 'string') {
69
237
  return false;
@@ -71,6 +239,38 @@ const isGeneratorOnlyKey = (arg) => {
71
239
  return Boolean(arg.length);
72
240
  };
73
241
  exports.isGeneratorOnlyKey = isGeneratorOnlyKey;
242
+ /**
243
+ * Extracts the generator ID from any type of GeneratorKey.
244
+ *
245
+ * This utility function parses the generator key to extract just the
246
+ * generator identifier, regardless of the key type. For operation and
247
+ * model keys, it extracts the first part before the pipe. For generator-only
248
+ * keys, it returns the entire key since it's just the generator ID.
249
+ *
250
+ * @param generatorKey - Any type of generator key
251
+ * @returns The generator ID string
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * const opKey = toOperationGeneratorKey({
256
+ * generatorId: 'api-client',
257
+ * path: '/users',
258
+ * method: 'get'
259
+ * });
260
+ * console.log(toGeneratorId(opKey)); // 'api-client'
261
+ *
262
+ * const modelKey = toModelGeneratorKey({
263
+ * generatorId: 'typescript-types',
264
+ * refName: 'User'
265
+ * });
266
+ * console.log(toGeneratorId(modelKey)); // 'typescript-types'
267
+ *
268
+ * const globalKey = toGeneratorOnlyKey({
269
+ * generatorId: 'utilities'
270
+ * });
271
+ * console.log(toGeneratorId(globalKey)); // 'utilities'
272
+ * ```
273
+ */
74
274
  const toGeneratorId = (generatorKey) => {
75
275
  if ((0, exports.isOperationGeneratorKey)(generatorKey)) {
76
276
  return generatorKey.split('|')[0];
@@ -81,6 +281,49 @@ const toGeneratorId = (generatorKey) => {
81
281
  return generatorKey;
82
282
  };
83
283
  exports.toGeneratorId = toGeneratorId;
284
+ /**
285
+ * Parses a GeneratorKey into its structured object representation.
286
+ *
287
+ * This function decomposes any generator key into a structured object
288
+ * with discriminated union types, making it easier to work with the
289
+ * key components in a type-safe manner.
290
+ *
291
+ * @param generatorKey - Any type of generator key to parse
292
+ * @returns Parsed generator key object with discriminated type
293
+ *
294
+ * @example Operation key parsing
295
+ * ```typescript
296
+ * const opKey = 'api-client|/users/{id}|get' as OperationGeneratorKey;
297
+ * const parsed = fromGeneratorKey(opKey);
298
+ *
299
+ * if (parsed.type === 'operation') {
300
+ * console.log(parsed.generatorId); // 'api-client'
301
+ * console.log(parsed.path); // '/users/{id}'
302
+ * console.log(parsed.method); // 'get'
303
+ * }
304
+ * ```
305
+ *
306
+ * @example Model key parsing
307
+ * ```typescript
308
+ * const modelKey = 'zod-schemas|User' as ModelGeneratorKey;
309
+ * const parsed = fromGeneratorKey(modelKey);
310
+ *
311
+ * if (parsed.type === 'model') {
312
+ * console.log(parsed.generatorId); // 'zod-schemas'
313
+ * console.log(parsed.refName); // 'User'
314
+ * }
315
+ * ```
316
+ *
317
+ * @example Generator-only key parsing
318
+ * ```typescript
319
+ * const globalKey = 'utilities' as GeneratorOnlyKey;
320
+ * const parsed = fromGeneratorKey(globalKey);
321
+ *
322
+ * if (parsed.type === 'generator-only') {
323
+ * console.log(parsed.generatorId); // 'utilities'
324
+ * }
325
+ * ```
326
+ */
84
327
  const fromGeneratorKey = (generatorKey) => {
85
328
  if ((0, exports.isOperationGeneratorKey)(generatorKey)) {
86
329
  const [generatorId, path, method] = generatorKey.split('|');