@ir-kit/openapi 0.1.0 → 0.3.0

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 (80) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +9 -7
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +6 -3
  5. package/dist/index.js.map +1 -1
  6. package/dist/operation/body.d.ts +23 -31
  7. package/dist/operation/body.d.ts.map +1 -1
  8. package/dist/operation/body.js +24 -17
  9. package/dist/operation/body.js.map +1 -1
  10. package/dist/operation/iter.d.ts +1 -1
  11. package/dist/operation/iter.d.ts.map +1 -1
  12. package/dist/operation/iter.js +2 -1
  13. package/dist/operation/iter.js.map +1 -1
  14. package/dist/operation/responses.d.ts +14 -34
  15. package/dist/operation/responses.d.ts.map +1 -1
  16. package/dist/operation/responses.js +21 -21
  17. package/dist/operation/responses.js.map +1 -1
  18. package/dist/operation/signature.d.ts +1 -1
  19. package/dist/operation/signature.js +1 -1
  20. package/dist/spec/constants.d.ts +20 -0
  21. package/dist/spec/constants.d.ts.map +1 -0
  22. package/dist/spec/constants.js +37 -0
  23. package/dist/spec/constants.js.map +1 -0
  24. package/dist/spec/normalize/allOf.d.ts +3 -0
  25. package/dist/spec/normalize/allOf.d.ts.map +1 -0
  26. package/dist/spec/normalize/allOf.js +42 -0
  27. package/dist/spec/normalize/allOf.js.map +1 -0
  28. package/dist/spec/normalize/enums.d.ts +10 -0
  29. package/dist/spec/normalize/enums.d.ts.map +1 -0
  30. package/dist/spec/normalize/enums.js +121 -0
  31. package/dist/spec/normalize/enums.js.map +1 -0
  32. package/dist/spec/normalize/index.d.ts +20 -0
  33. package/dist/spec/normalize/index.d.ts.map +1 -0
  34. package/dist/spec/normalize/index.js +37 -0
  35. package/dist/spec/normalize/index.js.map +1 -0
  36. package/dist/spec/normalize/metadata.d.ts +12 -0
  37. package/dist/spec/normalize/metadata.d.ts.map +1 -0
  38. package/dist/spec/normalize/metadata.js +49 -0
  39. package/dist/spec/normalize/metadata.js.map +1 -0
  40. package/dist/spec/normalize/name.d.ts +8 -0
  41. package/dist/spec/normalize/name.d.ts.map +1 -0
  42. package/dist/spec/normalize/name.js +24 -0
  43. package/dist/spec/normalize/name.js.map +1 -0
  44. package/dist/spec/normalize/objects.d.ts +14 -0
  45. package/dist/spec/normalize/objects.d.ts.map +1 -0
  46. package/dist/spec/normalize/objects.js +229 -0
  47. package/dist/spec/normalize/objects.js.map +1 -0
  48. package/dist/spec/normalize/prune.d.ts +15 -0
  49. package/dist/spec/normalize/prune.d.ts.map +1 -0
  50. package/dist/spec/normalize/prune.js +87 -0
  51. package/dist/spec/normalize/prune.js.map +1 -0
  52. package/dist/spec/normalize/walk.d.ts +21 -0
  53. package/dist/spec/normalize/walk.d.ts.map +1 -0
  54. package/dist/spec/normalize/walk.js +91 -0
  55. package/dist/spec/normalize/walk.js.map +1 -0
  56. package/dist/spec/ref.d.ts +7 -0
  57. package/dist/spec/ref.d.ts.map +1 -0
  58. package/dist/spec/ref.js +18 -0
  59. package/dist/spec/ref.js.map +1 -0
  60. package/dist/spec/security.d.ts +22 -0
  61. package/dist/spec/security.d.ts.map +1 -0
  62. package/dist/spec/security.js +47 -0
  63. package/dist/spec/security.js.map +1 -0
  64. package/dist/type/dispatch.d.ts +36 -64
  65. package/dist/type/dispatch.d.ts.map +1 -1
  66. package/dist/type/dispatch.js +31 -54
  67. package/dist/type/dispatch.js.map +1 -1
  68. package/package.json +2 -2
  69. package/dist/type/enum.d.ts +0 -42
  70. package/dist/type/enum.d.ts.map +0 -1
  71. package/dist/type/enum.js +0 -49
  72. package/dist/type/enum.js.map +0 -1
  73. package/dist/type/object.d.ts +0 -53
  74. package/dist/type/object.d.ts.map +0 -1
  75. package/dist/type/object.js +0 -36
  76. package/dist/type/object.js.map +0 -1
  77. package/dist/type/union.d.ts +0 -35
  78. package/dist/type/union.d.ts.map +0 -1
  79. package/dist/type/union.js +0 -29
  80. package/dist/type/union.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ir-kit/openapi",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Language-agnostic OpenAPI IR-walking primitives shared by the native-SDK generators. Each helper consumes @hey-api/shared's IR and returns target-neutral data — parameter locations, response categories, body media-type classifications — so per-language emitters can stay focused on rendering.",
5
5
  "keywords": [
6
6
  "openapi",
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@ir-kit/codegen-core": "0.1.0",
59
- "@ir-kit/openapi-core": "0.1.0"
59
+ "@ir-kit/schema": "0.2.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "tsc -p tsconfig.build.json",
@@ -1,42 +0,0 @@
1
- /**
2
- * The supported leaf shape for `IR.SchemaObject` enum values. Mirrors
3
- * `EnumLiteral` from `@ir-kit/openapi-tools` — re-declared here to keep
4
- * the package's dependency footprint minimal (this is a 3-word union;
5
- * a workspace dep just to import it would be heavyweight).
6
- */
7
- export type EnumLiteral = string | number | boolean;
8
- export type EnumKind = "string" | "integer";
9
- /**
10
- * Classify a set of enum literals as all-string or all-integer. Throws
11
- * on mixed (or otherwise unsupported) shapes. Each emitter then picks
12
- * its target rendering — Go emits `type ... string` + typed-consts,
13
- * Kotlin emits an `enum class(val raw: String)` or a typealias to
14
- * `Int`, Swift emits a raw-typed `enum: String, Codable`.
15
- *
16
- * `name` is woven into the thrown error message so the caller doesn't
17
- * have to re-wrap; emitter call-sites previously open-coded the same
18
- * `throw new Error(\`Enum ${name}: members must all be strings or all
19
- * integers; got ...\`)` line.
20
- */
21
- export declare function classifyEnumLiterals(values: ReadonlyArray<EnumLiteral>, name: string): EnumKind;
22
- export interface EnumEntryIdent<T extends string | number> {
23
- /** The identifier emitted into the target source (Go `StatusAvailable`,
24
- * Kotlin `available`, Swift `available`). */
25
- identifier: string;
26
- /** The raw enum value the identifier was derived from. */
27
- raw: T;
28
- }
29
- /**
30
- * Detect emitter-side identifier collisions across enum entries and
31
- * throw a descriptive error. Each emitter normalises raw enum values
32
- * to its own identifier convention (Go `enumEntrySuffix`, Kotlin
33
- * `enumEntryIdent`, Swift `safeCaseName`); when two raw values
34
- * normalise to the same identifier the emitted source won't compile,
35
- * so we throw early with the offending name and the colliding raws.
36
- *
37
- * `noun` is the label used in the error message — kept per-emitter to
38
- * preserve historical wording (Go / Kotlin say `entry name`, Swift
39
- * says `case name`); tests pin the exact phrase.
40
- */
41
- export declare function assertNoEnumCollisions<T extends string | number>(schemaName: string, entries: Iterable<EnumEntryIdent<T>>, noun?: "entry name" | "case name"): void;
42
- //# sourceMappingURL=enum.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/type/enum.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,EAClC,IAAI,EAAE,MAAM,GACX,QAAQ,CAWV;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACvD;kDAC8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,GAAG,EAAE,CAAC,CAAC;CACR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAC9D,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EACpC,IAAI,GAAE,YAAY,GAAG,WAA0B,GAC9C,IAAI,CAiBN"}
package/dist/type/enum.js DELETED
@@ -1,49 +0,0 @@
1
- /**
2
- * Classify a set of enum literals as all-string or all-integer. Throws
3
- * on mixed (or otherwise unsupported) shapes. Each emitter then picks
4
- * its target rendering — Go emits `type ... string` + typed-consts,
5
- * Kotlin emits an `enum class(val raw: String)` or a typealias to
6
- * `Int`, Swift emits a raw-typed `enum: String, Codable`.
7
- *
8
- * `name` is woven into the thrown error message so the caller doesn't
9
- * have to re-wrap; emitter call-sites previously open-coded the same
10
- * `throw new Error(\`Enum ${name}: members must all be strings or all
11
- * integers; got ...\`)` line.
12
- */
13
- export function classifyEnumLiterals(values, name) {
14
- const allStrings = values.every((v) => typeof v === "string");
15
- const allIntegers = values.every((v) => typeof v === "number" && Number.isInteger(v));
16
- if (!allStrings && !allIntegers) {
17
- throw new Error(`Enum ${name}: members must all be strings or all integers; got ${JSON.stringify(values)}`);
18
- }
19
- return allIntegers ? "integer" : "string";
20
- }
21
- /**
22
- * Detect emitter-side identifier collisions across enum entries and
23
- * throw a descriptive error. Each emitter normalises raw enum values
24
- * to its own identifier convention (Go `enumEntrySuffix`, Kotlin
25
- * `enumEntryIdent`, Swift `safeCaseName`); when two raw values
26
- * normalise to the same identifier the emitted source won't compile,
27
- * so we throw early with the offending name and the colliding raws.
28
- *
29
- * `noun` is the label used in the error message — kept per-emitter to
30
- * preserve historical wording (Go / Kotlin say `entry name`, Swift
31
- * says `case name`); tests pin the exact phrase.
32
- */
33
- export function assertNoEnumCollisions(schemaName, entries, noun = "entry name") {
34
- const collisions = new Map();
35
- for (const { identifier, raw } of entries) {
36
- const list = collisions.get(identifier) ?? [];
37
- list.push(raw);
38
- collisions.set(identifier, list);
39
- }
40
- for (const [identifier, raws] of collisions) {
41
- if (raws.length > 1) {
42
- const formatted = raws
43
- .map((r) => (typeof r === "string" ? `"${r}"` : String(r)))
44
- .join(", ");
45
- throw new Error(`Enum ${schemaName}: ${noun} "${identifier}" collides for raw values [${formatted}]`);
46
- }
47
- }
48
- }
49
- //# sourceMappingURL=enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/type/enum.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAkC,EAClC,IAAY;IAEZ,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;IAC9D,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAC9B,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CACpD,CAAC;IACF,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,QAAQ,IAAI,sDAAsD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAC3F,CAAC;IACJ,CAAC;IACD,OAAO,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5C,CAAC;AAUD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAkB,EAClB,OAAoC,EACpC,OAAmC,YAAY;IAE/C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAe,CAAC;IAC1C,KAAK,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,OAAO,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QAC9C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC;QAC5C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,SAAS,GAAG,IAAI;iBACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;iBAC1D,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,MAAM,IAAI,KAAK,CACb,QAAQ,UAAU,KAAK,IAAI,KAAK,UAAU,8BAA8B,SAAS,GAAG,CACrF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,53 +0,0 @@
1
- import type { IR } from "@hey-api/shared";
2
- /**
3
- * High-level dispatch for inline object schemas. Each emitter then
4
- * picks its target rendering:
5
- *
6
- * - `named-struct` → synth a name, emit a struct/data-class/struct,
7
- * return a ref to it
8
- * - `map` → render as `map[string]V` / `Map<String, V>` /
9
- * `[String: V]` over the inner value schema
10
- * - `open-map` → same map, but value is `any` / `Any` / `Any`
11
- * since `additionalProperties` was missing or
12
- * `true`/empty
13
- */
14
- export type ObjectShape = {
15
- kind: "named-struct";
16
- } | {
17
- kind: "map";
18
- valueSchema: IR.SchemaObject;
19
- } | {
20
- kind: "open-map";
21
- };
22
- /**
23
- * Classify an object-shaped schema by its property layout. Used by
24
- * each emitter's `inlineObjectType` to drive the same three-way
25
- * dispatch identically.
26
- */
27
- export declare function classifyObjectShape(schema: IR.SchemaObject): ObjectShape;
28
- export interface ObjectProperty {
29
- jsonKey: string;
30
- schema: IR.SchemaObject;
31
- /** True when the property name appears in `schema.required`. */
32
- required: boolean;
33
- /** True when the property is `string` + `format: "binary"`. Common
34
- * enough across emitters (multipart-binary handling) to surface
35
- * alongside the basic iteration. */
36
- isBinary: boolean;
37
- /** The propPath segment for this property, ready to plug into a
38
- * recursive `schemaToType(propSchema, { ...ctx, propPath: [segment] })`
39
- * call. Pre-computed as `pascal(jsonKey)` since both `synthName`
40
- * variants (codegen-core's `_`-joined and Go's `""`-joined) expect
41
- * PascalCase parts. */
42
- propPathSegment: string;
43
- }
44
- /**
45
- * Walk `schema.properties` in declaration order and yield one
46
- * `ObjectProperty` per entry, with the `required` membership,
47
- * binary-format detection, and pre-computed propPath segment
48
- * surfaced. Used by every emitter's `type/object.ts`
49
- * (struct/data-class/struct field generation) and `operation/body.ts`
50
- * (multipart / urlencoded flat-param expansion).
51
- */
52
- export declare function iterateObjectProperties(schema: IR.SchemaObject): Generator<ObjectProperty>;
53
- //# sourceMappingURL=object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/type/object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAG1C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,WAAW,EAAE,EAAE,CAAC,YAAY,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAEzB;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,GAAG,WAAW,CAMxE;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC;IACxB,gEAAgE;IAChE,QAAQ,EAAE,OAAO,CAAC;IAClB;;yCAEqC;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;4BAIwB;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAiB,uBAAuB,CACtC,MAAM,EAAE,EAAE,CAAC,YAAY,GACtB,SAAS,CAAC,cAAc,CAAC,CAW3B"}
@@ -1,36 +0,0 @@
1
- import { pascal } from "@ir-kit/codegen-core";
2
- /**
3
- * Classify an object-shaped schema by its property layout. Used by
4
- * each emitter's `inlineObjectType` to drive the same three-way
5
- * dispatch identically.
6
- */
7
- export function classifyObjectShape(schema) {
8
- const hasNamedProperties = Object.keys(schema.properties ?? {}).length > 0;
9
- if (hasNamedProperties)
10
- return { kind: "named-struct" };
11
- const ap = schema.additionalProperties;
12
- if (ap && typeof ap === "object")
13
- return { kind: "map", valueSchema: ap };
14
- return { kind: "open-map" };
15
- }
16
- /**
17
- * Walk `schema.properties` in declaration order and yield one
18
- * `ObjectProperty` per entry, with the `required` membership,
19
- * binary-format detection, and pre-computed propPath segment
20
- * surfaced. Used by every emitter's `type/object.ts`
21
- * (struct/data-class/struct field generation) and `operation/body.ts`
22
- * (multipart / urlencoded flat-param expansion).
23
- */
24
- export function* iterateObjectProperties(schema) {
25
- const required = new Set(schema.required ?? []);
26
- for (const [jsonKey, propSchema] of Object.entries(schema.properties ?? {})) {
27
- yield {
28
- jsonKey,
29
- schema: propSchema,
30
- required: required.has(jsonKey),
31
- isBinary: propSchema.type === "string" && propSchema.format === "binary",
32
- propPathSegment: pascal(jsonKey),
33
- };
34
- }
35
- }
36
- //# sourceMappingURL=object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/type/object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAmB9C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAuB;IACzD,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3E,IAAI,kBAAkB;QAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IACxD,MAAM,EAAE,GAAG,MAAM,CAAC,oBAAoB,CAAC;IACvC,IAAI,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAC1E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,CAAC;AAmBD;;;;;;;GAOG;AACH,MAAM,SAAS,CAAC,CAAC,uBAAuB,CACtC,MAAuB;IAEvB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAChD,KAAK,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5E,MAAM;YACJ,OAAO;YACP,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;YAC/B,QAAQ,EAAE,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,KAAK,QAAQ;YACxE,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC;SACjC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,35 +0,0 @@
1
- import type { IR } from "@hey-api/shared";
2
- /**
3
- * Outcome of inspecting a union-shaped schema. Pure structural —
4
- * caller still needs to decide how to render each kind in its target
5
- * language (Go pointer vs Kotlin nullable vs Swift optional, fall-back
6
- * to `any` vs `Any` vs language equivalents).
7
- */
8
- export type UnionShape = {
9
- kind: "intersection-with-properties";
10
- } | {
11
- kind: "intersection-empty";
12
- } | {
13
- kind: "single";
14
- inner: IR.SchemaObject;
15
- nullable: boolean;
16
- } | {
17
- kind: "multi";
18
- nullable: boolean;
19
- };
20
- /**
21
- * Classify a union-shaped schema (`logicalOperator: "or" | "and"`)
22
- * into one of the cases each emitter handles. hey-api represents
23
- * OpenAPI 3.1 nullables as `or` unions with a `{type:"null"}` branch;
24
- * `allOf` folds become `and`.
25
- *
26
- * - `and` + properties → caller dispatches to its inline-object path.
27
- * - `and` empty → caller renders its `any` analog.
28
- * - 1 non-null branch → caller renders the inner, applying its own
29
- * nullable wrapper iff `nullable === true`.
30
- * - 2+ non-null → caller falls back to its `any`; `nullable`
31
- * is reported but caller decides whether to
32
- * apply it (Go drops it, KT/Swift wrap).
33
- */
34
- export declare function classifyUnion(schema: IR.SchemaObject): UnionShape;
35
- //# sourceMappingURL=union.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../src/type/union.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,8BAA8B,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,GAAG,UAAU,CAajE"}
@@ -1,29 +0,0 @@
1
- /**
2
- * Classify a union-shaped schema (`logicalOperator: "or" | "and"`)
3
- * into one of the cases each emitter handles. hey-api represents
4
- * OpenAPI 3.1 nullables as `or` unions with a `{type:"null"}` branch;
5
- * `allOf` folds become `and`.
6
- *
7
- * - `and` + properties → caller dispatches to its inline-object path.
8
- * - `and` empty → caller renders its `any` analog.
9
- * - 1 non-null branch → caller renders the inner, applying its own
10
- * nullable wrapper iff `nullable === true`.
11
- * - 2+ non-null → caller falls back to its `any`; `nullable`
12
- * is reported but caller decides whether to
13
- * apply it (Go drops it, KT/Swift wrap).
14
- */
15
- export function classifyUnion(schema) {
16
- if (schema.logicalOperator === "and") {
17
- return schema.properties
18
- ? { kind: "intersection-with-properties" }
19
- : { kind: "intersection-empty" };
20
- }
21
- const items = schema.items ?? [];
22
- const nonNull = items.filter((i) => i.type !== "null");
23
- const nullable = nonNull.length < items.length;
24
- if (nonNull.length === 1) {
25
- return { kind: "single", inner: nonNull[0], nullable };
26
- }
27
- return { kind: "multi", nullable };
28
- }
29
- //# sourceMappingURL=union.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"union.js","sourceRoot":"","sources":["../../src/type/union.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAAC,MAAuB;IACnD,IAAI,MAAM,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,UAAU;YACtB,CAAC,CAAC,EAAE,IAAI,EAAE,8BAA8B,EAAE;YAC1C,CAAC,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;IACrC,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC/C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,QAAQ,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACrC,CAAC"}