@kubb/core 4.3.1 → 4.4.1

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 (147) hide show
  1. package/dist/{URLPath-BYceu_vY.js → URLPath-DbWtfVa1.js} +2 -3
  2. package/dist/{URLPath-BYceu_vY.js.map → URLPath-DbWtfVa1.js.map} +1 -1
  3. package/dist/{URLPath-8WVzHBnA.cjs → URLPath-Dir2mxRT.cjs} +6 -7
  4. package/dist/{URLPath-8WVzHBnA.cjs.map → URLPath-Dir2mxRT.cjs.map} +1 -1
  5. package/dist/{chunk-CZg_9w7l.cjs → chunk-CUT6urMc.cjs} +0 -23
  6. package/dist/hooks.cjs +6 -6
  7. package/dist/hooks.cjs.map +1 -1
  8. package/dist/hooks.d.cts +5 -5
  9. package/dist/hooks.d.ts +5 -5
  10. package/dist/hooks.js +1 -1
  11. package/dist/hooks.js.map +1 -1
  12. package/dist/index.cjs +128 -62
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +22 -18
  15. package/dist/index.d.ts +22 -18
  16. package/dist/index.js +116 -53
  17. package/dist/index.js.map +1 -1
  18. package/dist/{logger-BXL0YCrv.cjs → logger-BIzTtBYJ.cjs} +48 -5
  19. package/dist/logger-BIzTtBYJ.cjs.map +1 -0
  20. package/dist/{logger-DpoDtxfo.d.cts → logger-BjfDkvkn.d.cts} +1 -1
  21. package/dist/{logger-BA-za85-.d.ts → logger-BwhJWK-H.d.ts} +1 -1
  22. package/dist/{logger-CDxSrFkR.js → logger-Bxe022ug.js} +39 -4
  23. package/dist/logger-Bxe022ug.js.map +1 -0
  24. package/dist/logger.cjs +1 -2
  25. package/dist/logger.d.cts +1 -1
  26. package/dist/logger.d.ts +1 -1
  27. package/dist/logger.js +1 -2
  28. package/dist/{prompt-DgONOpPH.cjs → prompt-D5DZPtWc.cjs} +2 -2
  29. package/dist/{prompt-DgONOpPH.cjs.map → prompt-D5DZPtWc.cjs.map} +1 -1
  30. package/dist/{prompt-DBVnG4Me.js → prompt-xM0onfy8.js} +1 -1
  31. package/dist/{prompt-DBVnG4Me.js.map → prompt-xM0onfy8.js.map} +1 -1
  32. package/dist/transformers-CeNW0G32.js +339 -0
  33. package/dist/transformers-CeNW0G32.js.map +1 -0
  34. package/dist/transformers-DWLXDYKb.cjs +443 -0
  35. package/dist/transformers-DWLXDYKb.cjs.map +1 -0
  36. package/dist/transformers.cjs +7 -6
  37. package/dist/transformers.js +1 -3
  38. package/dist/{types-DPeNK0FO.d.ts → types-CVONMhN_.d.cts} +51 -53
  39. package/dist/{types-DNxlynJr.d.cts → types-CyDeSlGF.d.ts} +51 -53
  40. package/dist/{types-BzI9JlV8.d.ts → types-DCR_QgGt.d.ts} +1 -1
  41. package/dist/{types-C3ea5qNG.d.cts → types-DueAg3XP.d.cts} +1 -1
  42. package/dist/utils.cjs +7 -7
  43. package/dist/utils.cjs.map +1 -1
  44. package/dist/utils.d.cts +1 -1
  45. package/dist/utils.d.ts +1 -1
  46. package/dist/utils.js +4 -6
  47. package/dist/utils.js.map +1 -1
  48. package/package.json +15 -20
  49. package/src/BarrelManager.ts +1 -1
  50. package/src/FileManager.ts +5 -2
  51. package/src/PluginManager.ts +4 -8
  52. package/src/build.ts +39 -42
  53. package/src/fs/index.ts +0 -7
  54. package/src/hooks/useMode.ts +2 -2
  55. package/src/hooks/usePlugin.ts +1 -1
  56. package/src/hooks/usePluginManager.ts +1 -1
  57. package/src/plugin.ts +10 -5
  58. package/src/types.ts +3 -2
  59. package/src/utils/TreeNode.ts +1 -1
  60. package/dist/acorn-BAVXZMtK.cjs +0 -5082
  61. package/dist/acorn-BAVXZMtK.cjs.map +0 -1
  62. package/dist/acorn-D-VhIOLw.js +0 -5080
  63. package/dist/acorn-D-VhIOLw.js.map +0 -1
  64. package/dist/angular-Bp0XO9db.cjs +0 -3631
  65. package/dist/angular-Bp0XO9db.cjs.map +0 -1
  66. package/dist/angular-Czhp4eq5.js +0 -3629
  67. package/dist/angular-Czhp4eq5.js.map +0 -1
  68. package/dist/babel-DCR_B4Qn.js +0 -10033
  69. package/dist/babel-DCR_B4Qn.js.map +0 -1
  70. package/dist/babel-NI0v59ga.cjs +0 -10035
  71. package/dist/babel-NI0v59ga.cjs.map +0 -1
  72. package/dist/casing-BSeq_teY.js +0 -100
  73. package/dist/casing-BSeq_teY.js.map +0 -1
  74. package/dist/casing-CP-9GGdK.cjs +0 -112
  75. package/dist/casing-CP-9GGdK.cjs.map +0 -1
  76. package/dist/chunk-1SJ2vVWa.js +0 -35
  77. package/dist/estree-C3BZPlpU.cjs +0 -6930
  78. package/dist/estree-C3BZPlpU.cjs.map +0 -1
  79. package/dist/estree-DU2NummP.js +0 -6926
  80. package/dist/estree-DU2NummP.js.map +0 -1
  81. package/dist/flow-CWUBUkoi.cjs +0 -52252
  82. package/dist/flow-CWUBUkoi.cjs.map +0 -1
  83. package/dist/flow-JiEbweKj.js +0 -52250
  84. package/dist/flow-JiEbweKj.js.map +0 -1
  85. package/dist/fs-BIPMUfpW.js +0 -90
  86. package/dist/fs-BIPMUfpW.js.map +0 -1
  87. package/dist/fs-RSVoUw3S.cjs +0 -141
  88. package/dist/fs-RSVoUw3S.cjs.map +0 -1
  89. package/dist/fs.cjs +0 -17
  90. package/dist/fs.d.cts +0 -2
  91. package/dist/fs.d.ts +0 -2
  92. package/dist/fs.js +0 -4
  93. package/dist/glimmer-CX9OqG1j.cjs +0 -7275
  94. package/dist/glimmer-CX9OqG1j.cjs.map +0 -1
  95. package/dist/glimmer-t9nWn9aE.js +0 -7271
  96. package/dist/glimmer-t9nWn9aE.js.map +0 -1
  97. package/dist/graphql-DjErlIi5.js +0 -1897
  98. package/dist/graphql-DjErlIi5.js.map +0 -1
  99. package/dist/graphql-GOxQAKxM.cjs +0 -1902
  100. package/dist/graphql-GOxQAKxM.cjs.map +0 -1
  101. package/dist/html-CWrdYAhQ.cjs +0 -6560
  102. package/dist/html-CWrdYAhQ.cjs.map +0 -1
  103. package/dist/html-_apcbx34.js +0 -6555
  104. package/dist/html-_apcbx34.js.map +0 -1
  105. package/dist/index-BTe91LHd.d.ts +0 -145
  106. package/dist/index-BmQIxvw0.d.cts +0 -144
  107. package/dist/logger-BXL0YCrv.cjs.map +0 -1
  108. package/dist/logger-CDxSrFkR.js.map +0 -1
  109. package/dist/markdown-ckUc3Q6q.js +0 -6750
  110. package/dist/markdown-ckUc3Q6q.js.map +0 -1
  111. package/dist/markdown-pzqiRmft.cjs +0 -6755
  112. package/dist/markdown-pzqiRmft.cjs.map +0 -1
  113. package/dist/meriyah-BjnGqpUs.js +0 -8928
  114. package/dist/meriyah-BjnGqpUs.js.map +0 -1
  115. package/dist/meriyah-D_x7itbT.cjs +0 -8930
  116. package/dist/meriyah-D_x7itbT.cjs.map +0 -1
  117. package/dist/mocks.cjs +0 -16830
  118. package/dist/mocks.cjs.map +0 -1
  119. package/dist/mocks.d.cts +0 -13
  120. package/dist/mocks.d.ts +0 -13
  121. package/dist/mocks.js +0 -16818
  122. package/dist/mocks.js.map +0 -1
  123. package/dist/postcss-B_c2wbFu.cjs +0 -6689
  124. package/dist/postcss-B_c2wbFu.cjs.map +0 -1
  125. package/dist/postcss-v7BP6SZ-.js +0 -6684
  126. package/dist/postcss-v7BP6SZ-.js.map +0 -1
  127. package/dist/transformers-BH0KLJJP.cjs +0 -804
  128. package/dist/transformers-BH0KLJJP.cjs.map +0 -1
  129. package/dist/transformers-DzHGqYO2.js +0 -702
  130. package/dist/transformers-DzHGqYO2.js.map +0 -1
  131. package/dist/typescript-6kMN6Wqz.cjs +0 -23014
  132. package/dist/typescript-6kMN6Wqz.cjs.map +0 -1
  133. package/dist/typescript-B_IBfKSe.js +0 -23002
  134. package/dist/typescript-B_IBfKSe.js.map +0 -1
  135. package/dist/typescript-C5hce4HG.cjs +0 -4
  136. package/dist/typescript-Cas1XcNz.js +0 -3
  137. package/dist/write-BJfM7G1_.cjs +0 -49
  138. package/dist/write-BJfM7G1_.cjs.map +0 -1
  139. package/dist/write-CxO1CDML.js +0 -40
  140. package/dist/write-CxO1CDML.js.map +0 -1
  141. package/dist/yaml-BfWM_B73.js +0 -5209
  142. package/dist/yaml-BfWM_B73.js.map +0 -1
  143. package/dist/yaml-DZs6MhV1.cjs +0 -5215
  144. package/dist/yaml-DZs6MhV1.cjs.map +0 -1
  145. package/src/fs/types.ts +0 -132
  146. package/src/fs/unlink.ts +0 -5
  147. package/src/mocks/index.ts +0 -82
@@ -1,25 +1,26 @@
1
- import { a as Mode, i as File, n as BaseName, o as OptionalPath, r as Extname, s as ResolvedFile } from "./index-BTe91LHd.js";
2
- import { n as Logger, o as EventEmitter } from "./logger-BA-za85-.js";
3
- import { t as PossiblePromise } from "./types-BzI9JlV8.js";
4
- import { FileManager } from "@kubb/fabric-core";
1
+ import { n as Logger, o as EventEmitter } from "./logger-BjfDkvkn.cjs";
2
+ import { t as PossiblePromise } from "./types-DueAg3XP.cjs";
3
+ import { KubbFile } from "@kubb/fabric-core/types";
4
+ import { Fabric, FileManager } from "@kubb/react-fabric";
5
5
 
6
6
  //#region src/PluginManager.d.ts
7
7
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
8
8
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
9
- type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
9
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
10
10
  message: string;
11
11
  strategy: Strategy;
12
- hookName: H$1;
12
+ hookName: H;
13
13
  plugin: Plugin;
14
14
  parameters?: unknown[] | undefined;
15
15
  output?: unknown;
16
16
  };
17
- type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
18
- type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
17
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
18
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
19
19
  result: Result;
20
20
  plugin: Plugin;
21
21
  };
22
22
  type Options = {
23
+ fabric: Fabric;
23
24
  logger: Logger;
24
25
  /**
25
26
  * @default Number.POSITIVE_INFINITY
@@ -31,20 +32,16 @@ type Events = {
31
32
  executed: [executer: Executer];
32
33
  error: [error: Error];
33
34
  };
34
- type GetFileProps<TOptions$1 = object> = {
35
+ type GetFileProps<TOptions = object> = {
35
36
  name: string;
36
- mode?: Mode;
37
- extname: Extname;
37
+ mode?: KubbFile.Mode;
38
+ extname: KubbFile.Extname;
38
39
  pluginKey: Plugin['key'];
39
- options?: TOptions$1;
40
+ options?: TOptions;
40
41
  };
41
42
  declare class PluginManager {
42
43
  #private;
43
44
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
44
- /**
45
- * @deprecated do not use from pluginManager
46
- */
47
- readonly fileManager: FileManager;
48
45
  readonly events: EventEmitter<Events>;
49
46
  readonly config: Config;
50
47
  readonly executed: Array<Executer>;
@@ -57,10 +54,10 @@ declare class PluginManager {
57
54
  extname,
58
55
  pluginKey,
59
56
  options
60
- }: GetFileProps<TOptions>): File<{
57
+ }: GetFileProps<TOptions>): KubbFile.File<{
61
58
  pluginKey: Plugin['key'];
62
59
  }>;
63
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
60
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
64
61
  resolveName: (params: ResolveNameParams) => string;
65
62
  /**
66
63
  * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
@@ -244,7 +241,7 @@ type Config<TInput = Input> = {
244
241
  * Override the extension to the generated imports and exports, by default each plugin will add an extension
245
242
  * @default { '.ts': '.ts'}
246
243
  */
247
- extension?: Record<Extname, Extname | ''>;
244
+ extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
248
245
  /**
249
246
  * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
250
247
  * @default 'named'
@@ -283,11 +280,11 @@ TName extends string = string,
283
280
  /**
284
281
  * Options of the plugin.
285
282
  */
286
- TOptions$1 extends object = object,
283
+ TOptions extends object = object,
287
284
  /**
288
285
  * Options of the plugin that can be used later on, see `options` inside your plugin config.
289
286
  */
290
- TResolvedOptions extends object = TOptions$1,
287
+ TResolvedOptions extends object = TOptions,
291
288
  /**
292
289
  * Context that you want to expose to other plugins.
293
290
  */
@@ -301,24 +298,24 @@ TResolvePathOptions extends object = object> = {
301
298
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
302
299
  */
303
300
  key: PluginKey<TName | string>;
304
- options: TOptions$1;
301
+ options: TOptions;
305
302
  resolvedOptions: TResolvedOptions;
306
303
  context: TContext;
307
304
  resolvePathOptions: TResolvePathOptions;
308
305
  };
309
306
  type PluginKey<TName> = [name: TName, identifier?: string | number];
310
307
  type GetPluginFactoryOptions<TPlugin extends UserPlugin> = TPlugin extends UserPlugin<infer X> ? X : never;
311
- type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
308
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
312
309
  /**
313
310
  * Unique name used for the plugin
314
311
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
315
312
  * @example @kubb/typescript
316
313
  */
317
- name: TOptions$1['name'];
314
+ name: TOptions['name'];
318
315
  /**
319
316
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
320
317
  */
321
- options: TOptions$1['resolvedOptions'];
318
+ options: TOptions['resolvedOptions'];
322
319
  /**
323
320
  * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
324
321
  * Can be used to validate dependent plugins.
@@ -328,24 +325,24 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
328
325
  * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
329
326
  */
330
327
  post?: Array<string>;
331
- } & (TOptions$1['context'] extends never ? {
328
+ } & (TOptions['context'] extends never ? {
332
329
  context?: never;
333
330
  } : {
334
- context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
331
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
335
332
  });
336
- type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
333
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
337
334
  type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
338
- type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
335
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
339
336
  /**
340
337
  * Unique name used for the plugin
341
338
  * @example @kubb/typescript
342
339
  */
343
- name: TOptions$1['name'];
340
+ name: TOptions['name'];
344
341
  /**
345
342
  * Internal key used when a developer uses more than one of the same plugin
346
343
  * @private
347
344
  */
348
- key: TOptions$1['key'];
345
+ key: TOptions['key'];
349
346
  /**
350
347
  * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
351
348
  * Can be used to validate dependent plugins.
@@ -358,49 +355,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
358
355
  /**
359
356
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
360
357
  */
361
- options: TOptions$1['resolvedOptions'];
362
- } & (TOptions$1['context'] extends never ? {
358
+ options: TOptions['resolvedOptions'];
359
+ } & (TOptions['context'] extends never ? {
363
360
  context?: never;
364
361
  } : {
365
- context: TOptions$1['context'];
362
+ context: TOptions['context'];
366
363
  });
367
- type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
368
- type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
364
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
365
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
369
366
  /**
370
367
  * Start of the lifecycle of a plugin.
371
368
  * @type hookParallel
372
369
  */
373
- buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
370
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
374
371
  /**
375
372
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
376
373
  * Options can als be included.
377
374
  * @type hookFirst
378
375
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
379
376
  */
380
- resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
377
+ resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
381
378
  /**
382
379
  * Resolve to a name based on a string.
383
380
  * Useful when converting to PascalCase or camelCase.
384
381
  * @type hookFirst
385
382
  * @example ('pet') => 'Pet'
386
383
  */
387
- resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
384
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
388
385
  /**
389
386
  * End of the plugin lifecycle.
390
387
  * @type hookParallel
391
388
  */
392
- buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
389
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
393
390
  };
394
391
  type PluginLifecycleHooks = keyof PluginLifecycle;
395
- type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
396
- type ResolvePathParams<TOptions$1 = object> = {
392
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
393
+ type ResolvePathParams<TOptions = object> = {
397
394
  pluginKey?: Plugin['key'];
398
- baseName: BaseName;
399
- mode?: Mode;
395
+ baseName: KubbFile.BaseName;
396
+ mode?: KubbFile.Mode;
400
397
  /**
401
398
  * Options to be passed to 'resolvePath' 3th parameter
402
399
  */
403
- options?: TOptions$1;
400
+ options?: TOptions;
404
401
  };
405
402
  type ResolveNameParams = {
406
403
  name: string;
@@ -413,15 +410,16 @@ type ResolveNameParams = {
413
410
  */
414
411
  type?: 'file' | 'function' | 'type' | 'const';
415
412
  };
416
- type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
413
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
414
+ fabric: Fabric;
417
415
  config: Config;
418
416
  /**
419
417
  * @deprecated
420
418
  */
421
419
  fileManager: FileManager;
422
420
  pluginManager: PluginManager;
423
- addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
424
- resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
421
+ addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
422
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
425
423
  resolveName: (params: ResolveNameParams) => string;
426
424
  logger: Logger;
427
425
  /**
@@ -431,12 +429,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
431
429
  /**
432
430
  * Current plugin
433
431
  */
434
- plugin: Plugin<TOptions$1>;
432
+ plugin: Plugin<TOptions>;
435
433
  };
436
434
  /**
437
435
  * Specify the export location for the files and define the behavior of the output
438
436
  */
439
- type Output<TOptions$1> = {
437
+ type Output<TOptions> = {
440
438
  /**
441
439
  * Path to the output folder or file that will contain the generated code
442
440
  */
@@ -449,11 +447,11 @@ type Output<TOptions$1> = {
449
447
  /**
450
448
  * Add a banner text in the beginning of every file
451
449
  */
452
- banner?: string | ((options: TOptions$1) => string);
450
+ banner?: string | ((options: TOptions) => string);
453
451
  /**
454
452
  * Add a footer text in the beginning of every file
455
453
  */
456
- footer?: string | ((options: TOptions$1) => string);
454
+ footer?: string | ((options: TOptions) => string);
457
455
  };
458
456
  type GroupContext = {
459
457
  group: string;
@@ -470,4 +468,4 @@ type Group = {
470
468
  };
471
469
  //#endregion
472
470
  export { ResolvePathParams as _, InputData as a, UserPluginWithLifeCycle as b, Plugin as c, PluginKey as d, PluginLifecycle as f, ResolveNameParams as g, PluginWithLifeCycle as h, Group as i, PluginContext as l, PluginParameter as m, Config as n, InputPath as o, PluginLifecycleHooks as p, GetPluginFactoryOptions as r, Output as s, BarrelType as t, PluginFactoryOptions as u, UserConfig as v, PluginManager as x, UserPlugin as y };
473
- //# sourceMappingURL=types-DPeNK0FO.d.ts.map
471
+ //# sourceMappingURL=types-CVONMhN_.d.cts.map
@@ -1,25 +1,26 @@
1
- import { a as Mode, i as File, n as BaseName, o as OptionalPath, r as Extname, s as ResolvedFile } from "./index-BmQIxvw0.cjs";
2
- import { n as Logger, o as EventEmitter } from "./logger-DpoDtxfo.cjs";
3
- import { t as PossiblePromise } from "./types-C3ea5qNG.cjs";
4
- import { FileManager } from "@kubb/fabric-core";
1
+ import { n as Logger, o as EventEmitter } from "./logger-BwhJWK-H.js";
2
+ import { t as PossiblePromise } from "./types-DCR_QgGt.js";
3
+ import { Fabric, FileManager } from "@kubb/react-fabric";
4
+ import { KubbFile } from "@kubb/fabric-core/types";
5
5
 
6
6
  //#region src/PluginManager.d.ts
7
7
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
8
8
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
9
- type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
9
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
10
10
  message: string;
11
11
  strategy: Strategy;
12
- hookName: H$1;
12
+ hookName: H;
13
13
  plugin: Plugin;
14
14
  parameters?: unknown[] | undefined;
15
15
  output?: unknown;
16
16
  };
17
- type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
18
- type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
17
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
18
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
19
19
  result: Result;
20
20
  plugin: Plugin;
21
21
  };
22
22
  type Options = {
23
+ fabric: Fabric;
23
24
  logger: Logger;
24
25
  /**
25
26
  * @default Number.POSITIVE_INFINITY
@@ -31,20 +32,16 @@ type Events = {
31
32
  executed: [executer: Executer];
32
33
  error: [error: Error];
33
34
  };
34
- type GetFileProps<TOptions$1 = object> = {
35
+ type GetFileProps<TOptions = object> = {
35
36
  name: string;
36
- mode?: Mode;
37
- extname: Extname;
37
+ mode?: KubbFile.Mode;
38
+ extname: KubbFile.Extname;
38
39
  pluginKey: Plugin['key'];
39
- options?: TOptions$1;
40
+ options?: TOptions;
40
41
  };
41
42
  declare class PluginManager {
42
43
  #private;
43
44
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
44
- /**
45
- * @deprecated do not use from pluginManager
46
- */
47
- readonly fileManager: FileManager;
48
45
  readonly events: EventEmitter<Events>;
49
46
  readonly config: Config;
50
47
  readonly executed: Array<Executer>;
@@ -57,10 +54,10 @@ declare class PluginManager {
57
54
  extname,
58
55
  pluginKey,
59
56
  options
60
- }: GetFileProps<TOptions>): File<{
57
+ }: GetFileProps<TOptions>): KubbFile.File<{
61
58
  pluginKey: Plugin['key'];
62
59
  }>;
63
- resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
60
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.OptionalPath;
64
61
  resolveName: (params: ResolveNameParams) => string;
65
62
  /**
66
63
  * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
@@ -244,7 +241,7 @@ type Config<TInput = Input> = {
244
241
  * Override the extension to the generated imports and exports, by default each plugin will add an extension
245
242
  * @default { '.ts': '.ts'}
246
243
  */
247
- extension?: Record<Extname, Extname | ''>;
244
+ extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
248
245
  /**
249
246
  * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
250
247
  * @default 'named'
@@ -283,11 +280,11 @@ TName extends string = string,
283
280
  /**
284
281
  * Options of the plugin.
285
282
  */
286
- TOptions$1 extends object = object,
283
+ TOptions extends object = object,
287
284
  /**
288
285
  * Options of the plugin that can be used later on, see `options` inside your plugin config.
289
286
  */
290
- TResolvedOptions extends object = TOptions$1,
287
+ TResolvedOptions extends object = TOptions,
291
288
  /**
292
289
  * Context that you want to expose to other plugins.
293
290
  */
@@ -301,24 +298,24 @@ TResolvePathOptions extends object = object> = {
301
298
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
302
299
  */
303
300
  key: PluginKey<TName | string>;
304
- options: TOptions$1;
301
+ options: TOptions;
305
302
  resolvedOptions: TResolvedOptions;
306
303
  context: TContext;
307
304
  resolvePathOptions: TResolvePathOptions;
308
305
  };
309
306
  type PluginKey<TName> = [name: TName, identifier?: string | number];
310
307
  type GetPluginFactoryOptions<TPlugin extends UserPlugin> = TPlugin extends UserPlugin<infer X> ? X : never;
311
- type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
308
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
312
309
  /**
313
310
  * Unique name used for the plugin
314
311
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
315
312
  * @example @kubb/typescript
316
313
  */
317
- name: TOptions$1['name'];
314
+ name: TOptions['name'];
318
315
  /**
319
316
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
320
317
  */
321
- options: TOptions$1['resolvedOptions'];
318
+ options: TOptions['resolvedOptions'];
322
319
  /**
323
320
  * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
324
321
  * Can be used to validate dependent plugins.
@@ -328,24 +325,24 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
328
325
  * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
329
326
  */
330
327
  post?: Array<string>;
331
- } & (TOptions$1['context'] extends never ? {
328
+ } & (TOptions['context'] extends never ? {
332
329
  context?: never;
333
330
  } : {
334
- context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
331
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
335
332
  });
336
- type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
333
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
337
334
  type UnknownUserPlugin = UserPlugin<PluginFactoryOptions<any, any, any, any, any>>;
338
- type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
335
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
339
336
  /**
340
337
  * Unique name used for the plugin
341
338
  * @example @kubb/typescript
342
339
  */
343
- name: TOptions$1['name'];
340
+ name: TOptions['name'];
344
341
  /**
345
342
  * Internal key used when a developer uses more than one of the same plugin
346
343
  * @private
347
344
  */
348
- key: TOptions$1['key'];
345
+ key: TOptions['key'];
349
346
  /**
350
347
  * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
351
348
  * Can be used to validate dependent plugins.
@@ -358,49 +355,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
358
355
  /**
359
356
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
360
357
  */
361
- options: TOptions$1['resolvedOptions'];
362
- } & (TOptions$1['context'] extends never ? {
358
+ options: TOptions['resolvedOptions'];
359
+ } & (TOptions['context'] extends never ? {
363
360
  context?: never;
364
361
  } : {
365
- context: TOptions$1['context'];
362
+ context: TOptions['context'];
366
363
  });
367
- type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
368
- type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
364
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
365
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
369
366
  /**
370
367
  * Start of the lifecycle of a plugin.
371
368
  * @type hookParallel
372
369
  */
373
- buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
370
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
374
371
  /**
375
372
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
376
373
  * Options can als be included.
377
374
  * @type hookFirst
378
375
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
379
376
  */
380
- resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
377
+ resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.OptionalPath;
381
378
  /**
382
379
  * Resolve to a name based on a string.
383
380
  * Useful when converting to PascalCase or camelCase.
384
381
  * @type hookFirst
385
382
  * @example ('pet') => 'Pet'
386
383
  */
387
- resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
384
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
388
385
  /**
389
386
  * End of the plugin lifecycle.
390
387
  * @type hookParallel
391
388
  */
392
- buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
389
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
393
390
  };
394
391
  type PluginLifecycleHooks = keyof PluginLifecycle;
395
- type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
396
- type ResolvePathParams<TOptions$1 = object> = {
392
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
393
+ type ResolvePathParams<TOptions = object> = {
397
394
  pluginKey?: Plugin['key'];
398
- baseName: BaseName;
399
- mode?: Mode;
395
+ baseName: KubbFile.BaseName;
396
+ mode?: KubbFile.Mode;
400
397
  /**
401
398
  * Options to be passed to 'resolvePath' 3th parameter
402
399
  */
403
- options?: TOptions$1;
400
+ options?: TOptions;
404
401
  };
405
402
  type ResolveNameParams = {
406
403
  name: string;
@@ -413,15 +410,16 @@ type ResolveNameParams = {
413
410
  */
414
411
  type?: 'file' | 'function' | 'type' | 'const';
415
412
  };
416
- type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
413
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
414
+ fabric: Fabric;
417
415
  config: Config;
418
416
  /**
419
417
  * @deprecated
420
418
  */
421
419
  fileManager: FileManager;
422
420
  pluginManager: PluginManager;
423
- addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
424
- resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
421
+ addFile: (...file: Array<KubbFile.File>) => Promise<Array<KubbFile.ResolvedFile>>;
422
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
425
423
  resolveName: (params: ResolveNameParams) => string;
426
424
  logger: Logger;
427
425
  /**
@@ -431,12 +429,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
431
429
  /**
432
430
  * Current plugin
433
431
  */
434
- plugin: Plugin<TOptions$1>;
432
+ plugin: Plugin<TOptions>;
435
433
  };
436
434
  /**
437
435
  * Specify the export location for the files and define the behavior of the output
438
436
  */
439
- type Output<TOptions$1> = {
437
+ type Output<TOptions> = {
440
438
  /**
441
439
  * Path to the output folder or file that will contain the generated code
442
440
  */
@@ -449,11 +447,11 @@ type Output<TOptions$1> = {
449
447
  /**
450
448
  * Add a banner text in the beginning of every file
451
449
  */
452
- banner?: string | ((options: TOptions$1) => string);
450
+ banner?: string | ((options: TOptions) => string);
453
451
  /**
454
452
  * Add a footer text in the beginning of every file
455
453
  */
456
- footer?: string | ((options: TOptions$1) => string);
454
+ footer?: string | ((options: TOptions) => string);
457
455
  };
458
456
  type GroupContext = {
459
457
  group: string;
@@ -470,4 +468,4 @@ type Group = {
470
468
  };
471
469
  //#endregion
472
470
  export { ResolvePathParams as _, InputData as a, UserPluginWithLifeCycle as b, Plugin as c, PluginKey as d, PluginLifecycle as f, ResolveNameParams as g, PluginWithLifeCycle as h, Group as i, PluginContext as l, PluginParameter as m, Config as n, InputPath as o, PluginLifecycleHooks as p, GetPluginFactoryOptions as r, Output as s, BarrelType as t, PluginFactoryOptions as u, UserConfig as v, PluginManager as x, UserPlugin as y };
473
- //# sourceMappingURL=types-DNxlynJr.d.cts.map
471
+ //# sourceMappingURL=types-CyDeSlGF.d.ts.map
@@ -2,4 +2,4 @@
2
2
  type PossiblePromise<T> = Promise<T> | T;
3
3
  //#endregion
4
4
  export { PossiblePromise as t };
5
- //# sourceMappingURL=types-BzI9JlV8.d.ts.map
5
+ //# sourceMappingURL=types-DCR_QgGt.d.ts.map
@@ -2,4 +2,4 @@
2
2
  type PossiblePromise<T> = Promise<T> | T;
3
3
  //#endregion
4
4
  export { PossiblePromise as t };
5
- //# sourceMappingURL=types-C3ea5qNG.d.cts.map
5
+ //# sourceMappingURL=types-DueAg3XP.d.cts.map
package/dist/utils.cjs CHANGED
@@ -1,7 +1,8 @@
1
- const require_chunk = require('./chunk-CZg_9w7l.cjs');
2
- const require_transformers = require('./transformers-BH0KLJJP.cjs');
3
- const require_URLPath = require('./URLPath-8WVzHBnA.cjs');
4
- const require_casing = require('./casing-CP-9GGdK.cjs');
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ const require_transformers = require('./transformers-DWLXDYKb.cjs');
3
+ const require_URLPath = require('./URLPath-Dir2mxRT.cjs');
4
+ let natural_orderby = require("natural-orderby");
5
+ natural_orderby = require_chunk.__toESM(natural_orderby);
5
6
 
6
7
  //#region src/utils/Cache.ts
7
8
  var Cache = class {
@@ -29,7 +30,6 @@ var Cache = class {
29
30
 
30
31
  //#endregion
31
32
  //#region src/utils/FunctionParams.ts
32
- var import_main = /* @__PURE__ */ require_chunk.__toESM(require_transformers.require_main(), 1);
33
33
  /**
34
34
  * @deprecated
35
35
  */
@@ -53,7 +53,7 @@ var FunctionParams = class FunctionParams {
53
53
  return this;
54
54
  }
55
55
  static #orderItems(items) {
56
- return (0, import_main.orderBy)(items.filter(Boolean), [(v) => {
56
+ return (0, natural_orderby.orderBy)(items.filter(Boolean), [(v) => {
57
57
  if (Array.isArray(v)) return;
58
58
  return !v.default;
59
59
  }, (v) => {
@@ -68,7 +68,7 @@ var FunctionParams = class FunctionParams {
68
68
  acc.push(`${type}${rest.default ? ` = ${rest.default}` : ""}`);
69
69
  return acc;
70
70
  }
71
- const parameterName = name.startsWith("{") ? name : require_casing.camelCase(name);
71
+ const parameterName = name.startsWith("{") ? name : require_transformers.camelCase(name);
72
72
  if (type) if (required) acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ""}`);
73
73
  else acc.push(`${parameterName}?: ${type}`);
74
74
  else acc.push(`${parameterName}`);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["#buffer","#items","#orderItems","#addParams","camelCase","type: string[]","name: string[]","item"],"sources":["../src/utils/Cache.ts","../src/utils/FunctionParams.ts","../src/utils/promise.ts","../src/utils/renderTemplate.ts","../src/utils/timeout.ts"],"sourcesContent":["export class Cache<T> {\n #buffer = new Map<string, T>()\n\n async get(key: string): Promise<T | null> {\n return this.#buffer.get(key) ?? null\n }\n\n async set(key: string, value: T): Promise<void> {\n this.#buffer.set(key, value)\n }\n\n async delete(key: string): Promise<void> {\n this.#buffer.delete(key)\n }\n\n async clear(): Promise<void> {\n this.#buffer.clear()\n }\n\n async keys(): Promise<string[]> {\n return [...this.#buffer.keys()]\n }\n\n async values(): Promise<T[]> {\n return [...this.#buffer.values()]\n }\n\n async flush(): Promise<void> {\n // No-op for base cache\n }\n}\n","import { orderBy } from 'natural-orderby'\n\nimport { camelCase } from '../transformers/casing.ts'\n\ntype FunctionParamsASTWithoutType = {\n name?: string\n type?: string\n /**\n * @default true\n */\n required?: boolean\n /**\n * @default true\n */\n enabled?: boolean\n default?: string\n}\n\ntype FunctionParamsASTWithType = {\n name?: never\n type: string\n /**\n * @default true\n */\n required?: boolean\n /**\n * @default true\n */\n enabled?: boolean\n default?: string\n}\n/**\n * @deprecated\n */\nexport type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType\n\n/**\n * @deprecated\n */\nexport class FunctionParams {\n #items: Array<FunctionParamsAST | FunctionParamsAST[]> = []\n constructor() {\n return this\n }\n\n get items(): FunctionParamsAST[] {\n return this.#items.flat()\n }\n\n add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams {\n if (!item) {\n return this\n }\n\n if (Array.isArray(item)) {\n item.filter(Boolean).forEach((it) => {\n this.#items.push(it)\n })\n return this\n }\n this.#items.push(item)\n\n return this\n }\n static #orderItems(items: Array<FunctionParamsAST | FunctionParamsAST[]>) {\n return orderBy(\n items.filter(Boolean),\n [\n (v) => {\n if (Array.isArray(v)) {\n return undefined\n }\n return !v.default\n },\n (v) => {\n if (Array.isArray(v)) {\n return undefined\n }\n return v.required ?? true\n },\n ],\n ['desc', 'desc'],\n )\n }\n\n static #addParams(acc: string[], item: FunctionParamsAST) {\n const { enabled = true, name, type, required = true, ...rest } = item\n\n if (!enabled) {\n return acc\n }\n\n if (!name) {\n // when name is not se we will use TypeScript generics\n acc.push(`${type}${rest.default ? ` = ${rest.default}` : ''}`)\n\n return acc\n }\n // TODO check whey we still need the camelcase here\n const parameterName = name.startsWith('{') ? name : camelCase(name)\n\n if (type) {\n if (required) {\n acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ''}`)\n } else {\n acc.push(`${parameterName}?: ${type}`)\n }\n } else {\n acc.push(`${parameterName}`)\n }\n\n return acc\n }\n\n static toObject(items: FunctionParamsAST[]): FunctionParamsAST {\n let type: string[] = []\n let name: string[] = []\n\n const enabled = items.every((item) => item.enabled) ? items.at(0)?.enabled : true\n const required = items.every((item) => item.required) ?? true\n\n items.forEach((item) => {\n name = FunctionParams.#addParams(name, { ...item, type: undefined })\n if (items.some((item) => item.type)) {\n type = FunctionParams.#addParams(type, item)\n }\n })\n\n return {\n name: `{ ${name.join(', ')} }`,\n type: type.length ? `{ ${type.join('; ')} }` : undefined,\n enabled,\n required,\n }\n }\n\n static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string {\n const sortedData = FunctionParams.#orderItems(items)\n\n return sortedData\n .reduce((acc, item) => {\n if (Array.isArray(item)) {\n if (item.length <= 0) {\n return acc\n }\n const subItems = FunctionParams.#orderItems(item) as FunctionParamsAST[]\n const objectItem = FunctionParams.toObject(subItems)\n\n return FunctionParams.#addParams(acc, objectItem)\n }\n\n return FunctionParams.#addParams(acc, item)\n }, [] as string[])\n .join(', ')\n }\n\n toObject(): FunctionParamsAST {\n const items = FunctionParams.#orderItems(this.#items).flat()\n\n return FunctionParams.toObject(items)\n }\n\n toString(): string {\n const items = FunctionParams.#orderItems(this.#items)\n\n return FunctionParams.toString(items)\n }\n}\n","import type { PossiblePromise } from './types.ts'\n\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return !!result && typeof (result as Promise<unknown>)?.then === 'function'\n}\n\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","export function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data: TData | undefined = undefined): string {\n if (!data || !Object.keys(data).length) {\n return template.replace(/{{(.*?)}}/g, '')\n }\n\n const matches = template.match(/{{(.*?)}}/g)\n\n return (\n matches?.reduce((prev, curr) => {\n const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim()\n if (index === undefined) {\n return prev\n }\n const value = data[index]\n\n if (value === undefined) {\n return prev\n }\n\n return prev\n .replace(curr, () => {\n if (typeof value === 'boolean') {\n return `${value.toString()}` || 'false'\n }\n\n return (value as string) || ''\n })\n .trim()\n }, template) || ''\n )\n}\n","export async function timeout(ms: number): Promise<unknown> {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(true)\n }, ms)\n })\n}\n"],"mappings":";;;;;;AAAA,IAAa,QAAb,MAAsB;CACpB,0BAAU,IAAI,KAAgB;CAE9B,MAAM,IAAI,KAAgC;AACxC,SAAO,MAAKA,OAAQ,IAAI,IAAI,IAAI;;CAGlC,MAAM,IAAI,KAAa,OAAyB;AAC9C,QAAKA,OAAQ,IAAI,KAAK,MAAM;;CAG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;ACnKzC,SAAgB,UAAa,QAAkD;AAC7E,QAAO,CAAC,CAAC,UAAU,OAAQ,QAA6B,SAAS;;AAGnE,SAAgB,yBAAsC,QAA4E;AAChI,QAAO,OAAO,WAAW;;AAG3B,SAAgB,wBAA2B,QAAwG;AACjJ,QAAO,OAAO,WAAW;;;;;ACX3B,SAAgB,eAAgF,UAAkB,OAA0B,QAAmB;AAC7J,KAAI,CAAC,QAAQ,CAAC,OAAO,KAAK,KAAK,CAAC,OAC9B,QAAO,SAAS,QAAQ,cAAc,GAAG;AAK3C,QAFgB,SAAS,MAAM,aAAa,EAGjC,QAAQ,MAAM,SAAS;EAC9B,MAAM,QAAQ,KAAK,MAAM,QAAQ,CAAC,OAAO,QAAQ,CAAC,IAAI,MAAM;AAC5D,MAAI,UAAU,OACZ,QAAO;EAET,MAAM,QAAQ,KAAK;AAEnB,MAAI,UAAU,OACZ,QAAO;AAGT,SAAO,KACJ,QAAQ,YAAY;AACnB,OAAI,OAAO,UAAU,UACnB,QAAO,GAAG,MAAM,UAAU,MAAM;AAGlC,UAAQ,SAAoB;IAC5B,CACD,MAAM;IACR,SAAS,IAAI;;;;;AC5BpB,eAAsB,QAAQ,IAA8B;AAC1D,QAAO,IAAI,SAAS,YAAY;AAC9B,mBAAiB;AACf,WAAQ,KAAK;KACZ,GAAG;GACN"}
1
+ {"version":3,"file":"utils.cjs","names":["#buffer","#items","#orderItems","#addParams","camelCase","type: string[]","name: string[]","item"],"sources":["../src/utils/Cache.ts","../src/utils/FunctionParams.ts","../src/utils/promise.ts","../src/utils/renderTemplate.ts","../src/utils/timeout.ts"],"sourcesContent":["export class Cache<T> {\n #buffer = new Map<string, T>()\n\n async get(key: string): Promise<T | null> {\n return this.#buffer.get(key) ?? null\n }\n\n async set(key: string, value: T): Promise<void> {\n this.#buffer.set(key, value)\n }\n\n async delete(key: string): Promise<void> {\n this.#buffer.delete(key)\n }\n\n async clear(): Promise<void> {\n this.#buffer.clear()\n }\n\n async keys(): Promise<string[]> {\n return [...this.#buffer.keys()]\n }\n\n async values(): Promise<T[]> {\n return [...this.#buffer.values()]\n }\n\n async flush(): Promise<void> {\n // No-op for base cache\n }\n}\n","import { orderBy } from 'natural-orderby'\n\nimport { camelCase } from '../transformers/casing.ts'\n\ntype FunctionParamsASTWithoutType = {\n name?: string\n type?: string\n /**\n * @default true\n */\n required?: boolean\n /**\n * @default true\n */\n enabled?: boolean\n default?: string\n}\n\ntype FunctionParamsASTWithType = {\n name?: never\n type: string\n /**\n * @default true\n */\n required?: boolean\n /**\n * @default true\n */\n enabled?: boolean\n default?: string\n}\n/**\n * @deprecated\n */\nexport type FunctionParamsAST = FunctionParamsASTWithoutType | FunctionParamsASTWithType\n\n/**\n * @deprecated\n */\nexport class FunctionParams {\n #items: Array<FunctionParamsAST | FunctionParamsAST[]> = []\n constructor() {\n return this\n }\n\n get items(): FunctionParamsAST[] {\n return this.#items.flat()\n }\n\n add(item: FunctionParamsAST | Array<FunctionParamsAST | FunctionParamsAST[] | undefined> | undefined): FunctionParams {\n if (!item) {\n return this\n }\n\n if (Array.isArray(item)) {\n item.filter(Boolean).forEach((it) => {\n this.#items.push(it)\n })\n return this\n }\n this.#items.push(item)\n\n return this\n }\n static #orderItems(items: Array<FunctionParamsAST | FunctionParamsAST[]>) {\n return orderBy(\n items.filter(Boolean),\n [\n (v) => {\n if (Array.isArray(v)) {\n return undefined\n }\n return !v.default\n },\n (v) => {\n if (Array.isArray(v)) {\n return undefined\n }\n return v.required ?? true\n },\n ],\n ['desc', 'desc'],\n )\n }\n\n static #addParams(acc: string[], item: FunctionParamsAST) {\n const { enabled = true, name, type, required = true, ...rest } = item\n\n if (!enabled) {\n return acc\n }\n\n if (!name) {\n // when name is not se we will use TypeScript generics\n acc.push(`${type}${rest.default ? ` = ${rest.default}` : ''}`)\n\n return acc\n }\n // TODO check whey we still need the camelcase here\n const parameterName = name.startsWith('{') ? name : camelCase(name)\n\n if (type) {\n if (required) {\n acc.push(`${parameterName}: ${type}${rest.default ? ` = ${rest.default}` : ''}`)\n } else {\n acc.push(`${parameterName}?: ${type}`)\n }\n } else {\n acc.push(`${parameterName}`)\n }\n\n return acc\n }\n\n static toObject(items: FunctionParamsAST[]): FunctionParamsAST {\n let type: string[] = []\n let name: string[] = []\n\n const enabled = items.every((item) => item.enabled) ? items.at(0)?.enabled : true\n const required = items.every((item) => item.required) ?? true\n\n items.forEach((item) => {\n name = FunctionParams.#addParams(name, { ...item, type: undefined })\n if (items.some((item) => item.type)) {\n type = FunctionParams.#addParams(type, item)\n }\n })\n\n return {\n name: `{ ${name.join(', ')} }`,\n type: type.length ? `{ ${type.join('; ')} }` : undefined,\n enabled,\n required,\n }\n }\n\n static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string {\n const sortedData = FunctionParams.#orderItems(items)\n\n return sortedData\n .reduce((acc, item) => {\n if (Array.isArray(item)) {\n if (item.length <= 0) {\n return acc\n }\n const subItems = FunctionParams.#orderItems(item) as FunctionParamsAST[]\n const objectItem = FunctionParams.toObject(subItems)\n\n return FunctionParams.#addParams(acc, objectItem)\n }\n\n return FunctionParams.#addParams(acc, item)\n }, [] as string[])\n .join(', ')\n }\n\n toObject(): FunctionParamsAST {\n const items = FunctionParams.#orderItems(this.#items).flat()\n\n return FunctionParams.toObject(items)\n }\n\n toString(): string {\n const items = FunctionParams.#orderItems(this.#items)\n\n return FunctionParams.toString(items)\n }\n}\n","import type { PossiblePromise } from './types.ts'\n\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return !!result && typeof (result as Promise<unknown>)?.then === 'function'\n}\n\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","export function renderTemplate<TData extends Record<string, unknown> = Record<string, unknown>>(template: string, data: TData | undefined = undefined): string {\n if (!data || !Object.keys(data).length) {\n return template.replace(/{{(.*?)}}/g, '')\n }\n\n const matches = template.match(/{{(.*?)}}/g)\n\n return (\n matches?.reduce((prev, curr) => {\n const index = curr.split(/{{|}}/).filter(Boolean)[0]?.trim()\n if (index === undefined) {\n return prev\n }\n const value = data[index]\n\n if (value === undefined) {\n return prev\n }\n\n return prev\n .replace(curr, () => {\n if (typeof value === 'boolean') {\n return `${value.toString()}` || 'false'\n }\n\n return (value as string) || ''\n })\n .trim()\n }, template) || ''\n )\n}\n","export async function timeout(ms: number): Promise<unknown> {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(true)\n }, ms)\n })\n}\n"],"mappings":";;;;;;;AAAA,IAAa,QAAb,MAAsB;CACpB,0BAAU,IAAI,KAAgB;CAE9B,MAAM,IAAI,KAAgC;AACxC,SAAO,MAAKA,OAAQ,IAAI,IAAI,IAAI;;CAGlC,MAAM,IAAI,KAAa,OAAyB;AAC9C,QAAKA,OAAQ,IAAI,KAAK,MAAM;;CAG9B,MAAM,OAAO,KAA4B;AACvC,QAAKA,OAAQ,OAAO,IAAI;;CAG1B,MAAM,QAAuB;AAC3B,QAAKA,OAAQ,OAAO;;CAGtB,MAAM,OAA0B;AAC9B,SAAO,CAAC,GAAG,MAAKA,OAAQ,MAAM,CAAC;;CAGjC,MAAM,SAAuB;AAC3B,SAAO,CAAC,GAAG,MAAKA,OAAQ,QAAQ,CAAC;;CAGnC,MAAM,QAAuB;;;;;;;;ACY/B,IAAa,iBAAb,MAAa,eAAe;CAC1B,SAAyD,EAAE;CAC3D,cAAc;AACZ,SAAO;;CAGT,IAAI,QAA6B;AAC/B,SAAO,MAAKC,MAAO,MAAM;;CAG3B,IAAI,MAAkH;AACpH,MAAI,CAAC,KACH,QAAO;AAGT,MAAI,MAAM,QAAQ,KAAK,EAAE;AACvB,QAAK,OAAO,QAAQ,CAAC,SAAS,OAAO;AACnC,UAAKA,MAAO,KAAK,GAAG;KACpB;AACF,UAAO;;A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