@kubb/core 5.0.0-alpha.3 → 5.0.0-alpha.4
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/hooks.d.ts +1 -1
- package/dist/index.cjs +88 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +38 -2
- package/dist/index.js +88 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-CiPWLv-5.d.ts → types-Bbh1o0yW.d.ts} +59 -3
- package/package.json +2 -2
- package/src/defineGenerator.ts +106 -0
- package/src/index.ts +2 -0
- package/src/types.ts +1 -0
- package/src/utils/resolveOptions.ts +93 -0
package/dist/hooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
2
|
+
import { I as PluginManager, T as ResolvePathParams, _ as PluginFactoryOptions, a as Config, h as Plugin, w as ResolveNameParams } from "./types-Bbh1o0yW.js";
|
|
3
3
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
4
|
|
|
5
5
|
//#region src/hooks/useKubb.d.ts
|
package/dist/index.cjs
CHANGED
|
@@ -1464,7 +1464,7 @@ const fsStorage = defineStorage(() => ({
|
|
|
1464
1464
|
}));
|
|
1465
1465
|
//#endregion
|
|
1466
1466
|
//#region package.json
|
|
1467
|
-
var version = "5.0.0-alpha.
|
|
1467
|
+
var version = "5.0.0-alpha.4";
|
|
1468
1468
|
//#endregion
|
|
1469
1469
|
//#region src/utils/diagnostics.ts
|
|
1470
1470
|
/**
|
|
@@ -1797,6 +1797,36 @@ function defineAdapter(build) {
|
|
|
1797
1797
|
return (options) => build(options ?? {});
|
|
1798
1798
|
}
|
|
1799
1799
|
//#endregion
|
|
1800
|
+
//#region src/defineGenerator.ts
|
|
1801
|
+
function defineGenerator(generator) {
|
|
1802
|
+
if (generator.type === "react") return {
|
|
1803
|
+
version: "2",
|
|
1804
|
+
Operations() {
|
|
1805
|
+
return null;
|
|
1806
|
+
},
|
|
1807
|
+
Operation() {
|
|
1808
|
+
return null;
|
|
1809
|
+
},
|
|
1810
|
+
Schema() {
|
|
1811
|
+
return null;
|
|
1812
|
+
},
|
|
1813
|
+
...generator
|
|
1814
|
+
};
|
|
1815
|
+
return {
|
|
1816
|
+
version: "2",
|
|
1817
|
+
async operations() {
|
|
1818
|
+
return [];
|
|
1819
|
+
},
|
|
1820
|
+
async operation() {
|
|
1821
|
+
return [];
|
|
1822
|
+
},
|
|
1823
|
+
async schema() {
|
|
1824
|
+
return [];
|
|
1825
|
+
},
|
|
1826
|
+
...generator
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
1829
|
+
//#endregion
|
|
1800
1830
|
//#region src/defineLogger.ts
|
|
1801
1831
|
function defineLogger(logger) {
|
|
1802
1832
|
return { ...logger };
|
|
@@ -2310,6 +2340,61 @@ async function detectLinter() {
|
|
|
2310
2340
|
]) if (await isLinterAvailable(linter)) return linter;
|
|
2311
2341
|
}
|
|
2312
2342
|
//#endregion
|
|
2343
|
+
//#region src/utils/resolveOptions.ts
|
|
2344
|
+
function matchesOperationPattern(node, type, pattern) {
|
|
2345
|
+
switch (type) {
|
|
2346
|
+
case "tag": return node.tags.some((tag) => !!tag.match(pattern));
|
|
2347
|
+
case "operationId": return !!node.operationId.match(pattern);
|
|
2348
|
+
case "path": return !!node.path.match(pattern);
|
|
2349
|
+
case "method": return !!node.method.toLowerCase().match(pattern);
|
|
2350
|
+
default: return false;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
function matchesSchemaPattern(node, type, pattern) {
|
|
2354
|
+
switch (type) {
|
|
2355
|
+
case "schemaName": return node.name ? !!node.name.match(pattern) : false;
|
|
2356
|
+
default: return null;
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Resolves the effective plugin options for a given AST node by applying
|
|
2361
|
+
* `exclude`, `include`, and `override` rules from the plugin configuration.
|
|
2362
|
+
*
|
|
2363
|
+
* Returns `null` when the node is excluded or not matched by `include`.
|
|
2364
|
+
* Returns the merged options (base options merged with any matching `override`) otherwise.
|
|
2365
|
+
*
|
|
2366
|
+
* Supported filter types for `OperationNode`: `tag`, `operationId`, `path`, `method`.
|
|
2367
|
+
* Supported filter types for `SchemaNode`: `schemaName`.
|
|
2368
|
+
*
|
|
2369
|
+
* @example
|
|
2370
|
+
* const resolved = resolveOptions(operationNode, { options, exclude, include, override })
|
|
2371
|
+
* if (!resolved) return // excluded
|
|
2372
|
+
*/
|
|
2373
|
+
function resolveOptions(node, { options, exclude = [], include, override = [] }) {
|
|
2374
|
+
if ((0, _kubb_ast.isOperationNode)(node)) {
|
|
2375
|
+
if (exclude.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) return null;
|
|
2376
|
+
if (include && !include.some(({ type, pattern }) => matchesOperationPattern(node, type, pattern))) return null;
|
|
2377
|
+
const overrideOptions = override.find(({ type, pattern }) => matchesOperationPattern(node, type, pattern))?.options;
|
|
2378
|
+
return {
|
|
2379
|
+
...options,
|
|
2380
|
+
...overrideOptions
|
|
2381
|
+
};
|
|
2382
|
+
}
|
|
2383
|
+
if ((0, _kubb_ast.isSchemaNode)(node)) {
|
|
2384
|
+
if (exclude.some(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)) return null;
|
|
2385
|
+
if (include) {
|
|
2386
|
+
const applicable = include.map(({ type, pattern }) => matchesSchemaPattern(node, type, pattern)).filter((r) => r !== null);
|
|
2387
|
+
if (applicable.length > 0 && !applicable.includes(true)) return null;
|
|
2388
|
+
}
|
|
2389
|
+
const overrideOptions = override.find(({ type, pattern }) => matchesSchemaPattern(node, type, pattern) === true)?.options;
|
|
2390
|
+
return {
|
|
2391
|
+
...options,
|
|
2392
|
+
...overrideOptions
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
2395
|
+
return options;
|
|
2396
|
+
}
|
|
2397
|
+
//#endregion
|
|
2313
2398
|
exports.AsyncEventEmitter = AsyncEventEmitter;
|
|
2314
2399
|
exports.FunctionParams = FunctionParams;
|
|
2315
2400
|
exports.PackageManager = PackageManager;
|
|
@@ -2320,6 +2405,7 @@ exports.build = build;
|
|
|
2320
2405
|
exports.default = build;
|
|
2321
2406
|
exports.defineAdapter = defineAdapter;
|
|
2322
2407
|
exports.defineConfig = defineConfig;
|
|
2408
|
+
exports.defineGenerator = defineGenerator;
|
|
2323
2409
|
exports.defineLogger = defineLogger;
|
|
2324
2410
|
exports.definePlugin = definePlugin;
|
|
2325
2411
|
Object.defineProperty(exports, "definePrinter", {
|
|
@@ -2340,6 +2426,7 @@ exports.isInputPath = isInputPath;
|
|
|
2340
2426
|
exports.linters = linters;
|
|
2341
2427
|
exports.logLevel = logLevel;
|
|
2342
2428
|
exports.memoryStorage = memoryStorage;
|
|
2429
|
+
exports.resolveOptions = resolveOptions;
|
|
2343
2430
|
exports.safeBuild = safeBuild;
|
|
2344
2431
|
exports.setup = setup;
|
|
2345
2432
|
|