@kubb/core 5.0.0-alpha.7 → 5.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PluginDriver-Dma9KhLK.d.ts → PluginDriver-DRfJIbG1.d.ts} +14 -14
- package/dist/hooks.d.ts +1 -1
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/{defineAdapter.ts → createAdapter.ts} +2 -2
- package/src/{defineGenerator.ts → createGenerator.ts} +3 -3
- package/src/{defineLogger.ts → createLogger.ts} +1 -1
- package/src/{definePlugin.ts → createPlugin.ts} +1 -1
- package/src/{defineStorage.ts → createStorage.ts} +5 -5
- package/src/index.ts +5 -5
- package/src/storages/fsStorage.ts +2 -2
- package/src/storages/memoryStorage.ts +2 -2
- package/src/types.ts +6 -6
|
@@ -138,7 +138,7 @@ declare const formatters: {
|
|
|
138
138
|
};
|
|
139
139
|
};
|
|
140
140
|
//#endregion
|
|
141
|
-
//#region src/
|
|
141
|
+
//#region src/createStorage.d.ts
|
|
142
142
|
/**
|
|
143
143
|
* Storage interface for persisting Kubb output.
|
|
144
144
|
*
|
|
@@ -146,7 +146,7 @@ declare const formatters: {
|
|
|
146
146
|
* Implement this interface to route generated files to any backend — filesystem,
|
|
147
147
|
* S3, Redis, in-memory, etc.
|
|
148
148
|
*
|
|
149
|
-
* Use `
|
|
149
|
+
* Use `createStorage` to create a typed storage driver.
|
|
150
150
|
*/
|
|
151
151
|
interface DefineStorage {
|
|
152
152
|
/** Identifier used for logging and debugging (e.g. `'fs'`, `'s3'`). */
|
|
@@ -168,16 +168,16 @@ interface DefineStorage {
|
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* Wraps a storage builder so the `options` argument is optional, following the
|
|
171
|
-
* same factory pattern as `
|
|
171
|
+
* same factory pattern as `createPlugin`, `createLogger`, and `createAdapter`.
|
|
172
172
|
*
|
|
173
173
|
* The builder receives the resolved options object and must return a
|
|
174
174
|
* `DefineStorage`-compatible object that includes a `name` string.
|
|
175
175
|
*
|
|
176
176
|
* @example
|
|
177
177
|
* ```ts
|
|
178
|
-
* import {
|
|
178
|
+
* import { createStorage } from '@kubb/core'
|
|
179
179
|
*
|
|
180
|
-
* export const memoryStorage =
|
|
180
|
+
* export const memoryStorage = createStorage((_options) => {
|
|
181
181
|
* const store = new Map<string, string>()
|
|
182
182
|
* return {
|
|
183
183
|
* name: 'memory',
|
|
@@ -191,7 +191,7 @@ interface DefineStorage {
|
|
|
191
191
|
* })
|
|
192
192
|
* ```
|
|
193
193
|
*/
|
|
194
|
-
declare function
|
|
194
|
+
declare function createStorage<TOptions = Record<string, never>>(build: (options: TOptions) => DefineStorage): (options?: TOptions) => DefineStorage;
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region src/Kubb.d.ts
|
|
197
197
|
type DebugEvent = {
|
|
@@ -409,7 +409,7 @@ interface KubbEvents {
|
|
|
409
409
|
'plugins:hook:processing:end': [meta: ExecutedMeta];
|
|
410
410
|
}
|
|
411
411
|
//#endregion
|
|
412
|
-
//#region src/
|
|
412
|
+
//#region src/createGenerator.d.ts
|
|
413
413
|
type OperationsV2Props<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
414
414
|
config: Config;
|
|
415
415
|
adapter: Adapter;
|
|
@@ -461,8 +461,8 @@ type ReactGeneratorV2<TPlugin extends PluginFactoryOptions = PluginFactoryOption
|
|
|
461
461
|
Schema(props: SchemaV2Props<TPlugin>): FabricReactNode;
|
|
462
462
|
};
|
|
463
463
|
type Generator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions> = UserCoreGeneratorV2<TPlugin> | UserReactGeneratorV2<TPlugin>;
|
|
464
|
-
declare function
|
|
465
|
-
declare function
|
|
464
|
+
declare function createGenerator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>(generator: UserReactGeneratorV2<TPlugin>): ReactGeneratorV2<TPlugin>;
|
|
465
|
+
declare function createGenerator<TPlugin extends PluginFactoryOptions = PluginFactoryOptions>(generator: UserCoreGeneratorV2<TPlugin>): CoreGeneratorV2<TPlugin>;
|
|
466
466
|
//#endregion
|
|
467
467
|
//#region src/types.d.ts
|
|
468
468
|
declare global {
|
|
@@ -632,8 +632,8 @@ type Config<TInput = Input> = {
|
|
|
632
632
|
* @default fsStorage()
|
|
633
633
|
* @example
|
|
634
634
|
* ```ts
|
|
635
|
-
* import {
|
|
636
|
-
* storage:
|
|
635
|
+
* import { createStorage, fsStorage } from '@kubb/core'
|
|
636
|
+
* storage: createStorage(fsStorage())
|
|
637
637
|
* ```
|
|
638
638
|
*/
|
|
639
639
|
storage?: DefineStorage;
|
|
@@ -783,7 +783,7 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
783
783
|
options: TOptions['resolvedOptions'];
|
|
784
784
|
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
785
785
|
/**
|
|
786
|
-
* Define a context that can be used by other plugins, see `PluginDriver' where we convert from `UserPlugin` to `Plugin`(used when calling `
|
|
786
|
+
* Define a context that can be used by other plugins, see `PluginDriver' where we convert from `UserPlugin` to `Plugin`(used when calling `createPlugin`).
|
|
787
787
|
*/
|
|
788
788
|
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
789
789
|
};
|
|
@@ -1052,5 +1052,5 @@ declare class PluginDriver {
|
|
|
1052
1052
|
getPluginsByName(hookName: keyof PluginWithLifeCycle, pluginName: string): Plugin[];
|
|
1053
1053
|
}
|
|
1054
1054
|
//#endregion
|
|
1055
|
-
export { UserConfig as A,
|
|
1056
|
-
//# sourceMappingURL=PluginDriver-
|
|
1055
|
+
export { UserConfig as A, createStorage as B, PluginParameter as C, ResolveNameParams as D, PrinterFactoryOptions as E, Generator as F, URLPath as G, linters as H, ReactGeneratorV2 as I, createGenerator as L, UserPlugin as M, UserPluginWithLifeCycle as N, ResolvePathParams as O, CoreGeneratorV2 as P, KubbEvents as R, PluginLifecycleHooks as S, Printer as T, logLevel as U, formatters as V, AsyncEventEmitter as W, Output as _, AdapterFactoryOptions as a, PluginFactoryOptions as b, Config as c, Group as d, InputData as f, LoggerOptions as g, LoggerContext as h, Adapter as i, UserLogger as j, UnknownUserPlugin as k, DevtoolsOptions as l, Logger as m, PluginDriver as n, AdapterSource as o, InputPath as p, getMode as r, BarrelType as s, GetFileOptions as t, GetPluginFactoryOptions as u, Plugin as v, PluginWithLifeCycle as w, PluginLifecycle as x, PluginContext as y, DefineStorage as z };
|
|
1056
|
+
//# sourceMappingURL=PluginDriver-DRfJIbG1.d.ts.map
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { D as ResolveNameParams, O as ResolvePathParams, b as PluginFactoryOptions, c as Config, n as PluginDriver, t as GetFileOptions, v as Plugin } from "./PluginDriver-
|
|
2
|
+
import { D as ResolveNameParams, O as ResolvePathParams, b as PluginFactoryOptions, c as Config, n as PluginDriver, t as GetFileOptions, v as Plugin } from "./PluginDriver-DRfJIbG1.js";
|
|
3
3
|
import { RootNode } from "@kubb/ast/types";
|
|
4
4
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
5
5
|
|
package/dist/index.cjs
CHANGED
|
@@ -1345,19 +1345,19 @@ var PluginDriver = class {
|
|
|
1345
1345
|
}
|
|
1346
1346
|
};
|
|
1347
1347
|
//#endregion
|
|
1348
|
-
//#region src/
|
|
1348
|
+
//#region src/createStorage.ts
|
|
1349
1349
|
/**
|
|
1350
1350
|
* Wraps a storage builder so the `options` argument is optional, following the
|
|
1351
|
-
* same factory pattern as `
|
|
1351
|
+
* same factory pattern as `createPlugin`, `createLogger`, and `createAdapter`.
|
|
1352
1352
|
*
|
|
1353
1353
|
* The builder receives the resolved options object and must return a
|
|
1354
1354
|
* `DefineStorage`-compatible object that includes a `name` string.
|
|
1355
1355
|
*
|
|
1356
1356
|
* @example
|
|
1357
1357
|
* ```ts
|
|
1358
|
-
* import {
|
|
1358
|
+
* import { createStorage } from '@kubb/core'
|
|
1359
1359
|
*
|
|
1360
|
-
* export const memoryStorage =
|
|
1360
|
+
* export const memoryStorage = createStorage((_options) => {
|
|
1361
1361
|
* const store = new Map<string, string>()
|
|
1362
1362
|
* return {
|
|
1363
1363
|
* name: 'memory',
|
|
@@ -1371,7 +1371,7 @@ var PluginDriver = class {
|
|
|
1371
1371
|
* })
|
|
1372
1372
|
* ```
|
|
1373
1373
|
*/
|
|
1374
|
-
function
|
|
1374
|
+
function createStorage(build) {
|
|
1375
1375
|
return (options) => build(options ?? {});
|
|
1376
1376
|
}
|
|
1377
1377
|
//#endregion
|
|
@@ -1399,7 +1399,7 @@ function defineStorage(build) {
|
|
|
1399
1399
|
* })
|
|
1400
1400
|
* ```
|
|
1401
1401
|
*/
|
|
1402
|
-
const fsStorage =
|
|
1402
|
+
const fsStorage = createStorage(() => ({
|
|
1403
1403
|
name: "fs",
|
|
1404
1404
|
async hasItem(key) {
|
|
1405
1405
|
try {
|
|
@@ -1447,7 +1447,7 @@ const fsStorage = defineStorage(() => ({
|
|
|
1447
1447
|
}));
|
|
1448
1448
|
//#endregion
|
|
1449
1449
|
//#region package.json
|
|
1450
|
-
var version = "5.0.0-alpha.
|
|
1450
|
+
var version = "5.0.0-alpha.8";
|
|
1451
1451
|
//#endregion
|
|
1452
1452
|
//#region src/utils/diagnostics.ts
|
|
1453
1453
|
/**
|
|
@@ -1760,13 +1760,13 @@ function inputToAdapterSource(config) {
|
|
|
1760
1760
|
};
|
|
1761
1761
|
}
|
|
1762
1762
|
//#endregion
|
|
1763
|
-
//#region src/
|
|
1763
|
+
//#region src/createAdapter.ts
|
|
1764
1764
|
/**
|
|
1765
1765
|
* Wraps an adapter builder to make the options parameter optional.
|
|
1766
1766
|
*
|
|
1767
1767
|
* @example
|
|
1768
1768
|
* ```ts
|
|
1769
|
-
* export const adapterOas =
|
|
1769
|
+
* export const adapterOas = createAdapter<OasAdapter>((options) => {
|
|
1770
1770
|
* const { validate = true, dateType = 'string' } = options
|
|
1771
1771
|
* return {
|
|
1772
1772
|
* name: adapterOasName,
|
|
@@ -1776,12 +1776,12 @@ function inputToAdapterSource(config) {
|
|
|
1776
1776
|
* })
|
|
1777
1777
|
* ```
|
|
1778
1778
|
*/
|
|
1779
|
-
function
|
|
1779
|
+
function createAdapter(build) {
|
|
1780
1780
|
return (options) => build(options ?? {});
|
|
1781
1781
|
}
|
|
1782
1782
|
//#endregion
|
|
1783
|
-
//#region src/
|
|
1784
|
-
function
|
|
1783
|
+
//#region src/createGenerator.ts
|
|
1784
|
+
function createGenerator(generator) {
|
|
1785
1785
|
if (generator.type === "react") return {
|
|
1786
1786
|
version: "2",
|
|
1787
1787
|
Operations() {
|
|
@@ -1810,16 +1810,16 @@ function defineGenerator(generator) {
|
|
|
1810
1810
|
};
|
|
1811
1811
|
}
|
|
1812
1812
|
//#endregion
|
|
1813
|
-
//#region src/
|
|
1814
|
-
function
|
|
1813
|
+
//#region src/createLogger.ts
|
|
1814
|
+
function createLogger(logger) {
|
|
1815
1815
|
return { ...logger };
|
|
1816
1816
|
}
|
|
1817
1817
|
//#endregion
|
|
1818
|
-
//#region src/
|
|
1818
|
+
//#region src/createPlugin.ts
|
|
1819
1819
|
/**
|
|
1820
1820
|
* Wraps a plugin builder to make the options parameter optional.
|
|
1821
1821
|
*/
|
|
1822
|
-
function
|
|
1822
|
+
function createPlugin(build) {
|
|
1823
1823
|
return (options) => build(options ?? {});
|
|
1824
1824
|
}
|
|
1825
1825
|
//#endregion
|
|
@@ -1924,7 +1924,7 @@ var PackageManager = class PackageManager {
|
|
|
1924
1924
|
* })
|
|
1925
1925
|
* ```
|
|
1926
1926
|
*/
|
|
1927
|
-
const memoryStorage =
|
|
1927
|
+
const memoryStorage = createStorage(() => {
|
|
1928
1928
|
const store = /* @__PURE__ */ new Map();
|
|
1929
1929
|
return {
|
|
1930
1930
|
name: "memory",
|
|
@@ -2375,19 +2375,19 @@ exports.PackageManager = PackageManager;
|
|
|
2375
2375
|
exports.PluginDriver = PluginDriver;
|
|
2376
2376
|
exports.URLPath = URLPath;
|
|
2377
2377
|
exports.build = build;
|
|
2378
|
+
exports.createAdapter = createAdapter;
|
|
2379
|
+
exports.createGenerator = createGenerator;
|
|
2380
|
+
exports.createLogger = createLogger;
|
|
2381
|
+
exports.createPlugin = createPlugin;
|
|
2382
|
+
exports.createStorage = createStorage;
|
|
2378
2383
|
exports.default = build;
|
|
2379
|
-
exports.defineAdapter = defineAdapter;
|
|
2380
2384
|
exports.defineConfig = defineConfig;
|
|
2381
|
-
exports.defineGenerator = defineGenerator;
|
|
2382
|
-
exports.defineLogger = defineLogger;
|
|
2383
|
-
exports.definePlugin = definePlugin;
|
|
2384
2385
|
Object.defineProperty(exports, "definePrinter", {
|
|
2385
2386
|
enumerable: true,
|
|
2386
2387
|
get: function() {
|
|
2387
2388
|
return _kubb_ast.definePrinter;
|
|
2388
2389
|
}
|
|
2389
2390
|
});
|
|
2390
|
-
exports.defineStorage = defineStorage;
|
|
2391
2391
|
exports.detectFormatter = detectFormatter;
|
|
2392
2392
|
exports.detectLinter = detectLinter;
|
|
2393
2393
|
exports.formatters = formatters;
|