@kubb/ast 5.18.1 → 5.18.3

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.d.cts CHANGED
@@ -1157,6 +1157,11 @@ type ParameterNode = BaseNode & {
1157
1157
  * `application/json` when the value is sent as a JSON-encoded string. Absent for `schema` parameters.
1158
1158
  */
1159
1159
  contentType?: string;
1160
+ /**
1161
+ * Serialization settings per property of a `content` parameter, from the `encoding` of its media type. An OpenAPI 3.2
1162
+ * `querystring` parameter sent as `application/x-www-form-urlencoded` uses it to set `style` and `explode` per field.
1163
+ */
1164
+ encoding?: Record<string, EncodingNode>;
1160
1165
  examples?: Array<ExampleNode>;
1161
1166
  deprecated?: boolean;
1162
1167
  allowEmptyValue?: boolean;
package/dist/index.d.ts CHANGED
@@ -1157,6 +1157,11 @@ type ParameterNode = BaseNode & {
1157
1157
  * `application/json` when the value is sent as a JSON-encoded string. Absent for `schema` parameters.
1158
1158
  */
1159
1159
  contentType?: string;
1160
+ /**
1161
+ * Serialization settings per property of a `content` parameter, from the `encoding` of its media type. An OpenAPI 3.2
1162
+ * `querystring` parameter sent as `application/x-www-form-urlencoded` uses it to set `style` and `explode` per field.
1163
+ */
1164
+ encoding?: Record<string, EncodingNode>;
1160
1165
  examples?: Array<ExampleNode>;
1161
1166
  deprecated?: boolean;
1162
1167
  allowEmptyValue?: boolean;
package/dist/index.js CHANGED
@@ -699,6 +699,12 @@ function extractStringsFromNodes(nodes) {
699
699
  return collected.join("\n");
700
700
  }
701
701
  // src/utils/combineFileMembers.ts
702
+ /**
703
+ * File-member merging. `combineImports` and `combineExports` deduplicate and sort the import and
704
+ * export entries of one file, while `combineSources` deduplicates source entries in original order.
705
+ * `combineImports` also drops imports nothing references. This works on a file's members, not on
706
+ * schema content.
707
+ */
702
708
  const IDENTIFIER_RUN = /[\w$]+/g;
703
709
  /**
704
710
  * How many imports a file needs before indexing the source beats scanning it once per name.
@@ -712,15 +718,24 @@ function importLocalName(item) {
712
718
  return typeof item === "string" ? item : item.name ?? item.propertyName;
713
719
  }
714
720
  /**
721
+ * Returns the specifier a member is written with: POSIX and relative to the importing file when it
722
+ * has a `root`, like `getRelativePath` in parser-ts. Sorting on it keeps the order the same on every OS.
723
+ */
724
+ function specifier(node) {
725
+ if (!node.root) return node.path;
726
+ const relative = path.relative(path.dirname(node.root), node.path).replaceAll("\\", "/");
727
+ return relative.startsWith("../") ? relative : `./${relative}`;
728
+ }
729
+ /**
715
730
  * Computes a multi-level sort key for exports and imports:
716
- * non-array names first (wildcards/namespace aliases). Type-only before value. Alphabetical path. Unnamed before named.
731
+ * non-array names first (wildcards/namespace aliases). Type-only before value. Alphabetical specifier. Unnamed before named.
717
732
  */
718
733
  function sortKey(node) {
719
734
  const isArray = Array.isArray(node.name) ? "1" : "0";
720
735
  const typeOnly = node.isTypeOnly ? "0" : "1";
721
736
  const hasName = node.name != null ? "1" : "0";
722
737
  const name = Array.isArray(node.name) ? node.name.toSorted().join("\0") : node.name ?? "";
723
- return `${isArray}:${typeOnly}:${node.path}:${hasName}:${name}`;
738
+ return `${isArray}:${typeOnly}:${specifier(node)}:${hasName}:${name}`;
724
739
  }
725
740
  /**
726
741
  * Sorts members by {@link sortKey}. Keys are computed once per node, not per comparison.