@kubb/plugin-ts 5.4.0 → 5.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.
package/dist/index.cjs CHANGED
@@ -883,6 +883,22 @@ function resolveContentTypeVariants(entries, baseName) {
883
883
  }
884
884
  const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
885
885
  /**
886
+ * An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter
887
+ * per property, typed and serialized like any other.
888
+ * Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.
889
+ */
890
+ function spreadQuerystring(param) {
891
+ const schema = param.schema.type === "ref" ? param.schema.schema : param.schema;
892
+ const formEncoded = !param.contentType || param.contentType.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded";
893
+ if (schema?.type !== "object" || !formEncoded) return [param];
894
+ return schema.properties.map((property) => _kubb_kit.ast.factory.createParameter({
895
+ name: property.name,
896
+ in: "query",
897
+ schema: property.schema,
898
+ required: param.required && property.required
899
+ }));
900
+ }
901
+ /**
886
902
  * Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each
887
903
  * group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance
888
904
  * (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the
@@ -891,17 +907,18 @@ const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
891
907
  function getOperationParameters(node) {
892
908
  const cached = operationParameterGroupsByNode.get(node);
893
909
  if (cached) return cached;
894
- const group = (location) => {
910
+ const dedupe = (params) => {
895
911
  const seen = /* @__PURE__ */ new Set();
896
- return node.parameters.filter((param) => {
897
- if (param.in !== location || seen.has(param.name)) return false;
912
+ return params.filter((param) => {
913
+ if (seen.has(param.name)) return false;
898
914
  seen.add(param.name);
899
915
  return true;
900
916
  });
901
917
  };
918
+ const group = (location) => dedupe(node.parameters.filter((param) => param.in === location));
902
919
  const groups = {
903
920
  path: group("path"),
904
- query: group("query"),
921
+ query: dedupe([...group("query"), ...group("querystring").flatMap(spreadQuerystring)]),
905
922
  header: group("header"),
906
923
  cookie: group("cookie")
907
924
  };
@@ -1906,11 +1923,11 @@ const typeGenerator = (0, _kubb_kit.defineGenerator)({
1906
1923
  });
1907
1924
  // kubb-extension.json
1908
1925
  var compatibility = {
1909
- "kubb": ">=5.14.6",
1926
+ "kubb": ">=5.16.0",
1910
1927
  "node": ">=22.22"
1911
1928
  };
1912
1929
  // package.json
1913
- var version = "5.4.0";
1930
+ var version = "5.4.1";
1914
1931
  // src/resolvers/resolverTs.ts
1915
1932
  /**
1916
1933
  * Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths