@kubb/ast 5.0.0-beta.36 → 5.0.0-beta.38

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
@@ -555,7 +555,7 @@ function isNode(value) {
555
555
  /**
556
556
  * Returns the immediate traversable children of `node` based on {@link VISITOR_KEYS}.
557
557
  *
558
- * `Schema` children are only included when `recurse` is `true`; shallow mode skips them.
558
+ * `Schema` children are only included when `recurse` is `true`. Shallow mode skips them.
559
559
  *
560
560
  * @example
561
561
  * ```ts
@@ -577,7 +577,7 @@ function* getChildren(node, recurse) {
577
577
  }
578
578
  /**
579
579
  * Maps a node `kind` to the matching visitor callback name. Only the seven
580
- * traversable node kinds have an entry; every other kind resolves to
580
+ * traversable node kinds have an entry. Every other kind resolves to
581
581
  * `undefined` and is skipped.
582
582
  */
583
583
  const VISITOR_KEY_BY_KIND = {
@@ -610,7 +610,7 @@ function applyVisitor(node, visitor, parent) {
610
610
  *
611
611
  * Sibling nodes at each depth run concurrently up to `options.concurrency`
612
612
  * (defaults to `WALK_CONCURRENCY`). Higher values overlap I/O-bound visitor
613
- * work; lower values reduce memory pressure.
613
+ * work. Lower values reduce memory pressure.
614
614
  *
615
615
  * @example Log every operation
616
616
  * ```ts
@@ -1047,7 +1047,7 @@ function importKey(path, name, isTypeOnly) {
1047
1047
  }
1048
1048
  /**
1049
1049
  * Computes a multi-level sort key for exports and imports:
1050
- * non-array names first (wildcards/namespace aliases); type-only before value; alphabetical path; unnamed before named.
1050
+ * non-array names first (wildcards/namespace aliases). Type-only before value. Alphabetical path. Unnamed before named.
1051
1051
  */
1052
1052
  function sortKey(node) {
1053
1053
  const isArray = Array.isArray(node.name) ? "1" : "0";
@@ -1222,7 +1222,7 @@ function resolveRefName(node) {
1222
1222
  /**
1223
1223
  * Collects every named schema referenced (transitively) from a node via ref edges.
1224
1224
  *
1225
- * Refs are followed by name only the resolved `node.schema` is not traversed inline.
1225
+ * Refs are followed by name only, the resolved `node.schema` is not traversed inline.
1226
1226
  * Use this to determine schema dependencies, build reference graphs, or detect what schemas need to be emitted.
1227
1227
  *
1228
1228
  * @example Collect refs from a single schema
@@ -1258,7 +1258,7 @@ function collectReferencedSchemaNames(node, out = /* @__PURE__ */ new Set()) {
1258
1258
  * Collects the names of all top-level schemas transitively used by a set of operations.
1259
1259
  *
1260
1260
  * An operation uses a schema when any of its parameters, request body content, or responses
1261
- * reference it directly or indirectly through other named schemas.
1261
+ * reference it, directly or indirectly through other named schemas.
1262
1262
  * The walk is iterative and safe against reference cycles.
1263
1263
  *
1264
1264
  * Use this together with `include` filters to determine which schemas from `components/schemas`
@@ -1348,7 +1348,7 @@ function findCircularSchemas(schemas) {
1348
1348
  * Use `excludeName` to ignore refs to specific schemas (useful when self-references are handled separately).
1349
1349
  * Commonly used with `findCircularSchemas()` to detect where lazy wrappers are needed in code generation.
1350
1350
  *
1351
- * @note Returns `true` for the first matching circular ref found; use for fast dependency checks.
1351
+ * @note Returns `true` for the first matching circular ref found. Use for fast dependency checks.
1352
1352
  */
1353
1353
  function containsCircularRef(node, { circularSchemas, excludeName }) {
1354
1354
  if (!node || circularSchemas.size === 0) return false;
@@ -1383,7 +1383,7 @@ function syncOptionality(schema, required) {
1383
1383
  * `changes` already equals (by reference) the current value, otherwise a new node
1384
1384
  * with the changes applied.
1385
1385
  *
1386
- * Mirrors the TypeScript compiler's `factory.updateX` contract pair it with the
1386
+ * Mirrors the TypeScript compiler's `factory.updateX` contract, pair it with the
1387
1387
  * structural sharing in {@link transform} so a no-op rewrite doesn't allocate and
1388
1388
  * downstream passes can detect "nothing changed" by identity. Comparison is
1389
1389
  * shallow: a structurally-equal but newly-allocated array/object counts as a change.
@@ -1499,7 +1499,7 @@ function createOperation(props) {
1499
1499
  }
1500
1500
  /**
1501
1501
  * Maps schema `type` to its underlying `primitive`.
1502
- * Primitive types map to themselves; special string formats map to `'string'`.
1502
+ * Primitive types map to themselves. Special string formats map to `'string'`.
1503
1503
  * Complex types (`ref`, `enum`, `union`, `intersection`, `tuple`, `blob`) are left unset.
1504
1504
  */
1505
1505
  const TYPE_TO_PRIMITIVE = {
@@ -1650,7 +1650,7 @@ function createResponse(props) {
1650
1650
  * // → params?: QueryParams
1651
1651
  * ```
1652
1652
  *
1653
- * @example Param with default (implicitly optional; cannot combine with `optional: true`)
1653
+ * @example Param with default (implicitly optional. Cannot combine with `optional: true`)
1654
1654
  * ```ts
1655
1655
  * createFunctionParameter({ name: 'config', type: createParamsType({ variant: 'reference', name: 'RequestConfig' }), default: '{}' })
1656
1656
  * // → config: RequestConfig = {}
@@ -1707,7 +1707,7 @@ function createParamsType(props) {
1707
1707
  * // call → { id, name }
1708
1708
  * ```
1709
1709
  *
1710
- * @example Inline (spread) children emitted as individual top-level parameters
1710
+ * @example Inline (spread), children emitted as individual top-level parameters
1711
1711
  * ```ts
1712
1712
  * createParameterGroup({
1713
1713
  * properties: [createFunctionParameter({ name: 'petId', type: createParamsType({ variant: 'reference', name: 'string' }), optional: false })],
@@ -1809,9 +1809,9 @@ function createSource(props) {
1809
1809
  * Creates a fully resolved `FileNode` from a file input descriptor.
1810
1810
  *
1811
1811
  * Computes:
1812
- * - `id` SHA256 hash of the file path
1813
- * - `name` `baseName` without extension
1814
- * - `extname` extension extracted from `baseName`
1812
+ * - `id` SHA256 hash of the file path
1813
+ * - `name` `baseName` without extension
1814
+ * - `extname` extension extracted from `baseName`
1815
1815
  *
1816
1816
  * Deduplicates:
1817
1817
  * - `sources` via `combineSources`
@@ -2043,7 +2043,7 @@ function createJsx(value) {
2043
2043
  /**
2044
2044
  * The shape-affecting flags shared by every node kind: base primitive, format, and `nullable`.
2045
2045
  * Documentation and usage-slot flags (`optional`/`nullish`/`readOnly`/`writeOnly`) are
2046
- * intentionally excluded they describe the property slot, not the type.
2046
+ * intentionally excluded, they describe the property slot, not the type.
2047
2047
  */
2048
2048
  function flagsDescriptor(node) {
2049
2049
  return `${node.primitive ?? ""};${node.format ?? ""};${node.nullable ? 1 : 0}`;
@@ -2256,7 +2256,7 @@ function serializeShapeField(field, node, record) {
2256
2256
  }
2257
2257
  /**
2258
2258
  * Builds the local, shape-only descriptor for a node: its kind, flags, constraints, and its
2259
- * children's signatures. {@link signatureOf} hashes this string; children contribute their
2259
+ * children's signatures. {@link signatureOf} hashes this string. Children contribute their
2260
2260
  * fixed-length signature rather than their own full descriptor, which keeps the result bounded.
2261
2261
  */
2262
2262
  function describeShape(node) {
@@ -2275,14 +2275,14 @@ function describeShape(node) {
2275
2275
  * during dedupe planning is not re-hashed when the same tree is rewritten during streaming
2276
2276
  * (where `schemaSignature` and `applyDedupe` would otherwise each walk it from scratch). Reuse
2277
2277
  * across calls is sound because a signature depends only on a node's content, and schema nodes
2278
- * are immutable once created transforms allocate new objects rather than mutating in place.
2278
+ * are immutable once created, transforms allocate new objects rather than mutating in place.
2279
2279
  */
2280
2280
  const signatureCache = /* @__PURE__ */ new WeakMap();
2281
2281
  /**
2282
2282
  * Hash-consing: each node's signature is a fixed-length digest of its local shape plus its
2283
2283
  * children's digests (a Merkle hash). Children contribute their 64-char hash instead of their
2284
2284
  * full nested descriptor, so a signature stays bounded regardless of subtree depth, and the
2285
- * digest is identical across calls because it depends only on content never on traversal
2285
+ * digest is identical across calls because it depends only on content, never on traversal
2286
2286
  * order. This keeps the keys built during planning consistent with the ones recomputed later
2287
2287
  * during streaming. {@link signatureCache} memoizes node → digest across every computation.
2288
2288
  */
@@ -2360,7 +2360,7 @@ function cleanDefinition(node, name) {
2360
2360
  *
2361
2361
  * A shape that occurs at least `minOccurrences` times is deduplicated: if any occurrence
2362
2362
  * is a named top-level schema, that name becomes the canonical (so other top-level duplicates
2363
- * and inline copies turn into references to it); otherwise a new definition is hoisted using
2363
+ * and inline copies turn into references to it). Otherwise a new definition is hoisted using
2364
2364
  * `nameFor`. The plan is then applied per node with {@link applyDedupe}.
2365
2365
  *
2366
2366
  * @example
@@ -2425,7 +2425,7 @@ function buildDedupePlan(roots, options) {
2425
2425
  //#region src/dialect.ts
2426
2426
  /**
2427
2427
  * Identity helper that types a {@link SchemaDialect} for an adapter. Like
2428
- * `defineParser`, it adds no runtime behavior it pins the dialect's type for
2428
+ * `defineParser`, it adds no runtime behavior, it pins the dialect's type for
2429
2429
  * inference and gives adapter authors a discoverable anchor.
2430
2430
  *
2431
2431
  * @example
@@ -2455,7 +2455,7 @@ function defineSchemaDialect(dialect) {
2455
2455
  *
2456
2456
  * An adapter derives a context from a source spec node, then declares an ordered table of
2457
2457
  * rules mapping spec shapes onto Kubb AST nodes. To add support for a new spec, write a new
2458
- * context type and a new rules table the traversal here is reused unchanged.
2458
+ * context type and a new rules table, the traversal here is reused unchanged.
2459
2459
  *
2460
2460
  * Order is significant: earlier rules win, so list higher-precedence or more specific shapes
2461
2461
  * first (e.g. composition keywords before plain `type`). A rule whose `match` returns `true`
@@ -2485,11 +2485,11 @@ function dispatch(rules, context) {
2485
2485
  *
2486
2486
  * The builder receives resolved options and returns:
2487
2487
  *
2488
- * - `name` unique identifier for the printer.
2489
- * - `options` stored on the returned printer instance.
2490
- * - `nodes` map of `SchemaType` → handler. Handlers return the rendered
2488
+ * - `name` unique identifier for the printer.
2489
+ * - `options` stored on the returned printer instance.
2490
+ * - `nodes` map of `SchemaType` → handler. Handlers return the rendered
2491
2491
  * output (a string, a TypeScript AST node, ...) for that schema type.
2492
- * - `print` (optional) top-level override exposed as `printer.print`.
2492
+ * - `print` (optional), top-level override exposed as `printer.print`.
2493
2493
  * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.
2494
2494
  *
2495
2495
  * Without a `print` override, `printer.print` falls back to `printer.transform`