@kubb/plugin-faker 5.3.0-canary.20261029T124214 → 5.3.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.
- package/dist/index.cjs +98 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +32 -15
- package/dist/index.js.map +1 -1
- package/kubb-extension.json +1 -1
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
|
-
import { KubbReactNode } from "kubb/jsx";
|
|
1
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "@kubb/kit";
|
|
2
|
+
import { KubbReactNode } from "@kubb/renderer-jsx";
|
|
3
3
|
/**
|
|
4
4
|
* Resolver for Faker that provides naming methods for mock functions.
|
|
5
5
|
*
|
|
@@ -245,7 +245,7 @@ export declare function Faker({ node, description, name, typeName, printer, canO
|
|
|
245
245
|
* factory returns a value matching the corresponding TypeScript type from
|
|
246
246
|
* `@kubb/plugin-ts`.
|
|
247
247
|
*/
|
|
248
|
-
export declare const fakerGenerator: import("kubb/kit").Generator<PluginFaker, unknown>;
|
|
248
|
+
export declare const fakerGenerator: import("@kubb/kit").Generator<PluginFaker, unknown>;
|
|
249
249
|
/**
|
|
250
250
|
* Canonical plugin name for `@kubb/plugin-faker`. Used for driver lookups and
|
|
251
251
|
* cross-plugin dependency references.
|
|
@@ -275,7 +275,7 @@ export declare const pluginFakerName = "plugin-faker";
|
|
|
275
275
|
* })
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
|
-
export declare const pluginFaker: import("kubb/kit").PluginFactory<PluginFaker>;
|
|
278
|
+
export declare const pluginFaker: import("@kubb/kit").PluginFactory<PluginFaker>;
|
|
279
279
|
/**
|
|
280
280
|
* Default resolver used by `@kubb/plugin-faker`. Decides the names and file
|
|
281
281
|
* paths for every generated mock factory. Functions and files are prefixed
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
|
-
import { KubbReactNode } from "kubb/jsx";
|
|
1
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "@kubb/kit";
|
|
2
|
+
import { KubbReactNode } from "@kubb/renderer-jsx";
|
|
3
3
|
/**
|
|
4
4
|
* Resolver for Faker that provides naming methods for mock functions.
|
|
5
5
|
*
|
|
@@ -245,7 +245,7 @@ export declare function Faker({ node, description, name, typeName, printer, canO
|
|
|
245
245
|
* factory returns a value matching the corresponding TypeScript type from
|
|
246
246
|
* `@kubb/plugin-ts`.
|
|
247
247
|
*/
|
|
248
|
-
export declare const fakerGenerator: import("kubb/kit").Generator<PluginFaker, unknown>;
|
|
248
|
+
export declare const fakerGenerator: import("@kubb/kit").Generator<PluginFaker, unknown>;
|
|
249
249
|
/**
|
|
250
250
|
* Canonical plugin name for `@kubb/plugin-faker`. Used for driver lookups and
|
|
251
251
|
* cross-plugin dependency references.
|
|
@@ -275,7 +275,7 @@ export declare const pluginFakerName = "plugin-faker";
|
|
|
275
275
|
* })
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
|
-
export declare const pluginFaker: import("kubb/kit").PluginFactory<PluginFaker>;
|
|
278
|
+
export declare const pluginFaker: import("@kubb/kit").PluginFactory<PluginFaker>;
|
|
279
279
|
/**
|
|
280
280
|
* Default resolver used by `@kubb/plugin-faker`. Decides the names and file
|
|
281
281
|
* paths for every generated mock factory. Functions and files are prefixed
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import { Diagnostics, Resolver, addGenerator, ast, camelCase, containsCircularRef, createResolver, defineExtension, defineGenerator, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
|
|
3
|
-
import { File, Function, jsxRenderer } from "kubb/jsx";
|
|
4
|
-
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
2
|
+
import { Diagnostics, Resolver, addGenerator, ast, camelCase, containsCircularRef, createResolver, defineExtension, defineGenerator, setMacros, setResolver, syncSchemaRef } from "@kubb/kit";
|
|
3
|
+
import { File, Function, jsxRenderer } from "@kubb/renderer-jsx";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
|
|
5
5
|
import { buildParams, enumTypeName, pluginTsName } from "@kubb/plugin-ts";
|
|
6
6
|
// ../../internals/utils/src/reserved.ts
|
|
7
7
|
/**
|
|
@@ -587,19 +587,19 @@ function operationFileEntry(node, name, extname = ".ts") {
|
|
|
587
587
|
};
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
|
-
* Resolves a dependency plugin's generated file for `node.operationId`, cached in `
|
|
591
|
-
*
|
|
590
|
+
* Resolves a dependency plugin's generated file for `node.operationId`, cached in `memo` (the
|
|
591
|
+
* build's `ctx.memo`) under the resolver's own plugin name and the operation. Several dependents reading the
|
|
592
592
|
* same dependency for the same operation in one pass (a query plugin's several hook generators, the
|
|
593
593
|
* MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.
|
|
594
594
|
*
|
|
595
595
|
* @example Cache `plugin-ts`'s file for the current operation
|
|
596
596
|
* ```ts
|
|
597
|
-
* const fileTs = resolveDependencyOperationFile({
|
|
597
|
+
* const fileTs = resolveDependencyOperationFile({ memo: ctx.memo, node, resolver: tsResolver, root, output })
|
|
598
598
|
* ```
|
|
599
599
|
*/
|
|
600
600
|
function resolveDependencyOperationFile(options) {
|
|
601
|
-
const {
|
|
602
|
-
return
|
|
601
|
+
const { memo, node, resolver, root, output, group } = options;
|
|
602
|
+
return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => resolver.file({
|
|
603
603
|
...operationFileEntry(node, node.operationId),
|
|
604
604
|
root,
|
|
605
605
|
output,
|
|
@@ -656,6 +656,22 @@ function resolveContentTypeVariants(entries, baseName) {
|
|
|
656
656
|
}
|
|
657
657
|
const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
658
658
|
/**
|
|
659
|
+
* An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter
|
|
660
|
+
* per property, typed and serialized like any other.
|
|
661
|
+
* Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.
|
|
662
|
+
*/
|
|
663
|
+
function spreadQuerystring(param) {
|
|
664
|
+
const schema = param.schema.type === "ref" ? param.schema.schema : param.schema;
|
|
665
|
+
const formEncoded = !param.contentType || param.contentType.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded";
|
|
666
|
+
if (schema?.type !== "object" || !formEncoded) return [param];
|
|
667
|
+
return schema.properties.map((property) => ast.factory.createParameter({
|
|
668
|
+
name: property.name,
|
|
669
|
+
in: "query",
|
|
670
|
+
schema: property.schema,
|
|
671
|
+
required: param.required && property.required
|
|
672
|
+
}));
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
659
675
|
* Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each
|
|
660
676
|
* group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance
|
|
661
677
|
* (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the
|
|
@@ -664,17 +680,18 @@ const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
|
664
680
|
function getOperationParameters(node) {
|
|
665
681
|
const cached = operationParameterGroupsByNode.get(node);
|
|
666
682
|
if (cached) return cached;
|
|
667
|
-
const
|
|
683
|
+
const dedupe = (params) => {
|
|
668
684
|
const seen = /* @__PURE__ */ new Set();
|
|
669
|
-
return
|
|
670
|
-
if (
|
|
685
|
+
return params.filter((param) => {
|
|
686
|
+
if (seen.has(param.name)) return false;
|
|
671
687
|
seen.add(param.name);
|
|
672
688
|
return true;
|
|
673
689
|
});
|
|
674
690
|
};
|
|
691
|
+
const group = (location) => dedupe(node.parameters.filter((param) => param.in === location));
|
|
675
692
|
const groups = {
|
|
676
693
|
path: group("path"),
|
|
677
|
-
query: group("query"),
|
|
694
|
+
query: dedupe([...group("query"), ...group("querystring").flatMap(spreadQuerystring)]),
|
|
678
695
|
header: group("header"),
|
|
679
696
|
cookie: group("cookie")
|
|
680
697
|
};
|
|
@@ -1339,7 +1356,7 @@ const fakerGenerator = defineGenerator({
|
|
|
1339
1356
|
group: group ?? void 0
|
|
1340
1357
|
}),
|
|
1341
1358
|
typeFile: resolveDependencyOperationFile({
|
|
1342
|
-
|
|
1359
|
+
memo: ctx.memo,
|
|
1343
1360
|
node,
|
|
1344
1361
|
resolver: tsResolver,
|
|
1345
1362
|
root,
|
|
@@ -1472,11 +1489,11 @@ const fakerGenerator = defineGenerator({
|
|
|
1472
1489
|
});
|
|
1473
1490
|
// kubb-extension.json
|
|
1474
1491
|
var compatibility = {
|
|
1475
|
-
"kubb": ">=5.
|
|
1492
|
+
"kubb": ">=5.16.0",
|
|
1476
1493
|
"node": ">=22.22"
|
|
1477
1494
|
};
|
|
1478
1495
|
// package.json
|
|
1479
|
-
var version = "5.3.
|
|
1496
|
+
var version = "5.3.1";
|
|
1480
1497
|
// src/resolvers/resolverFaker.ts
|
|
1481
1498
|
/**
|
|
1482
1499
|
* Default resolver used by `@kubb/plugin-faker`. Decides the names and file
|