@kubb/ast 5.0.0-beta.5 → 5.0.0-beta.51

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.
Files changed (48) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +28 -19
  3. package/dist/index.cjs +878 -788
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +33 -3326
  6. package/dist/index.js +863 -750
  7. package/dist/index.js.map +1 -1
  8. package/dist/types-BaaNZbSi.d.ts +3581 -0
  9. package/dist/types.cjs +0 -0
  10. package/dist/types.d.ts +2 -0
  11. package/dist/types.js +1 -0
  12. package/dist/utils-BIcKgbbc.js +626 -0
  13. package/dist/utils-BIcKgbbc.js.map +1 -0
  14. package/dist/utils-CMRZrT-w.cjs +794 -0
  15. package/dist/utils-CMRZrT-w.cjs.map +1 -0
  16. package/dist/utils.cjs +18 -0
  17. package/dist/utils.d.ts +205 -0
  18. package/dist/utils.js +2 -0
  19. package/package.json +13 -5
  20. package/src/constants.ts +10 -49
  21. package/src/dedupe.ts +200 -0
  22. package/src/dialect.ts +58 -0
  23. package/src/dispatch.ts +53 -0
  24. package/src/factory.ts +154 -21
  25. package/src/guards.ts +18 -48
  26. package/src/index.ts +11 -8
  27. package/src/infer.ts +16 -14
  28. package/src/nodes/base.ts +2 -0
  29. package/src/nodes/code.ts +22 -28
  30. package/src/nodes/content.ts +37 -0
  31. package/src/nodes/file.ts +17 -15
  32. package/src/nodes/function.ts +11 -11
  33. package/src/nodes/http.ts +1 -35
  34. package/src/nodes/index.ts +10 -12
  35. package/src/nodes/operation.ts +98 -62
  36. package/src/nodes/response.ts +21 -14
  37. package/src/nodes/root.ts +72 -10
  38. package/src/nodes/schema.ts +18 -15
  39. package/src/printer.ts +44 -38
  40. package/src/resolvers.ts +5 -19
  41. package/src/signature.ts +232 -0
  42. package/src/transformers.ts +21 -16
  43. package/src/types.ts +8 -18
  44. package/src/{utils.ts → utils/ast.ts} +125 -84
  45. package/src/utils/index.ts +295 -0
  46. package/src/visitor.ts +239 -281
  47. package/src/refs.ts +0 -67
  48. /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
package/src/refs.ts DELETED
@@ -1,67 +0,0 @@
1
- import type { InputNode } from './nodes/root.ts'
2
- import type { SchemaNode } from './nodes/schema.ts'
3
-
4
- /**
5
- * Lookup map from schema name to `SchemaNode`.
6
- */
7
- export type RefMap = Map<string, SchemaNode>
8
-
9
- /**
10
- * Returns the last path segment of a reference string.
11
- *
12
- * Example: `#/components/schemas/Pet` becomes `Pet`.
13
- *
14
- * @example
15
- * ```ts
16
- * extractRefName('#/components/schemas/Pet') // 'Pet'
17
- * ```
18
- */
19
- export function extractRefName(ref: string): string {
20
- return ref.split('/').at(-1) ?? ref
21
- }
22
-
23
- /**
24
- * Builds a `RefMap` from `input.schemas` using each schema's `name`.
25
- *
26
- * Unnamed schemas are skipped.
27
- *
28
- * @example
29
- * ```ts
30
- * const refMap = buildRefMap(input)
31
- * const pet = refMap.get('Pet')
32
- * ```
33
- */
34
- export function buildRefMap(input: InputNode): RefMap {
35
- const map: RefMap = new Map()
36
-
37
- for (const schema of input.schemas) {
38
- if (schema.name) {
39
- map.set(schema.name, schema)
40
- }
41
- }
42
- return map
43
- }
44
-
45
- /**
46
- * Resolves a schema by name from a `RefMap`.
47
- *
48
- * @example
49
- * ```ts
50
- * const petSchema = resolveRef(refMap, 'Pet')
51
- * ```
52
- */
53
- export function resolveRef(refMap: RefMap, ref: string): SchemaNode | undefined {
54
- return refMap.get(ref)
55
- }
56
-
57
- /**
58
- * Converts a `RefMap` into a plain object.
59
- *
60
- * @example
61
- * ```ts
62
- * const refsObject = refMapToObject(refMap)
63
- * ```
64
- */
65
- export function refMapToObject(refMap: RefMap): Record<string, SchemaNode> {
66
- return Object.fromEntries(refMap)
67
- }
File without changes