@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/README.md CHANGED
@@ -111,7 +111,7 @@ If you're picking up this package for the first time:
111
111
 
112
112
  - **Walks are generators, not arrays.** `iterOperations`, `iterateObjectProperties`. Lets callers short-circuit or filter without paying for a full list build. Callers that need an array do `Array.from(...)`.
113
113
 
114
- - **No target imports.** This package depends on `@hey-api/shared` (for IR types), `@ir-kit/openapi-core` (for ref / security / constants), and `@ir-kit/codegen-core` (for `pascal`, `synthName`). It does NOT depend on any go-dsl / kt-dsl / sw-dsl module.
114
+ - **No target imports.** This package depends on `@hey-api/shared` (for IR types) and `@ir-kit/codegen-core` (for `pascal`, `synthName`). Spec-level primitives (ref / security / constants / normalize) live under `src/spec/` and are re-exported. The package does NOT depend on any go-dsl / kt-dsl / sw-dsl module.
115
115
 
116
116
  ## Adding a new shared walk
117
117
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- export type { BodyShape } from "./operation/body.js";
1
+ export type { EnumEntryIdent, EnumKind, EnumLiteral, ObjectProperty, ObjectShape, Schema, SchemaDiscriminator, SchemaOrBool, SchemaPrimitiveType, UnionShape, } from "@ir-kit/schema";
2
+ export { assertNoEnumCollisions, classifyEnumLiterals, classifyObject, classifyUnion, extractEnumValues, isNullable, isPrimitive, isRefOnly, isSchemaObject, isUnionShape, iterateObjectProperties, primitiveTag, refName, typeList, } from "@ir-kit/schema";
3
+ export { fromHeyApi } from "@ir-kit/schema/adapters/heyapi";
4
+ export type { BodyShape, ClassifiedBody } from "./operation/body.js";
2
5
  export { classifyBody, isOpaqueJsonBody } from "./operation/body.js";
3
6
  export type { IteratedOperation } from "./operation/iter.js";
4
7
  export { iterOperations } from "./operation/iter.js";
@@ -9,13 +12,12 @@ export { classifyReturnShape, isSuccessStatus, successResponses, } from "./opera
9
12
  export { deriveBaseName, operationDocLine, splitPathSegments, } from "./operation/signature.js";
10
13
  export type { TemplatePart } from "./operation/template.js";
11
14
  export { parseTemplatedSegment } from "./operation/template.js";
15
+ export { FORM_URLENCODED_MEDIA, HTTP_METHOD_LITERAL, HTTP_METHODS, type HttpMethod, JSON_MEDIA_RE, MULTIPART_FORM_MEDIA, } from "./spec/constants.js";
16
+ export type { Casing, EnumPassOptions, NamingConfig, NamingRule, NormalizeOptions, ObjectPassOptions, } from "./spec/normalize/index.js";
17
+ export { normalizeSpec, SAFE_NORMALIZE } from "./spec/normalize/index.js";
18
+ export { isMeaningless } from "./spec/ref.js";
19
+ export { extractSecuritySchemeNames, securityKey } from "./spec/security.js";
12
20
  export type { TypeCtx } from "./type/context.js";
13
21
  export type { SchemaToTypeOps } from "./type/dispatch.js";
14
22
  export { schemaToType } from "./type/dispatch.js";
15
- export type { EnumEntryIdent, EnumKind, EnumLiteral } from "./type/enum.js";
16
- export { assertNoEnumCollisions, classifyEnumLiterals, } from "./type/enum.js";
17
- export type { ObjectProperty, ObjectShape } from "./type/object.js";
18
- export { classifyObjectShape, iterateObjectProperties, } from "./type/object.js";
19
- export type { UnionShape } from "./type/union.js";
20
- export { classifyUnion } from "./type/union.js";
21
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;A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
@@ -1,11 +1,14 @@
1
+ export { assertNoEnumCollisions, classifyEnumLiterals, classifyObject, classifyUnion, extractEnumValues, isNullable, isPrimitive, isRefOnly, isSchemaObject, isUnionShape, iterateObjectProperties, primitiveTag, refName, typeList, } from "@ir-kit/schema";
2
+ export { fromHeyApi } from "@ir-kit/schema/adapters/heyapi";
1
3
  export { classifyBody, isOpaqueJsonBody } from "./operation/body.js";
2
4
  export { iterOperations } from "./operation/iter.js";
3
5
  export { collectLocatedParams, PARAM_LOCATIONS, paramsAt, } from "./operation/params.js";
4
6
  export { classifyReturnShape, isSuccessStatus, successResponses, } from "./operation/responses.js";
5
7
  export { deriveBaseName, operationDocLine, splitPathSegments, } from "./operation/signature.js";
6
8
  export { parseTemplatedSegment } from "./operation/template.js";
9
+ export { FORM_URLENCODED_MEDIA, HTTP_METHOD_LITERAL, HTTP_METHODS, JSON_MEDIA_RE, MULTIPART_FORM_MEDIA, } from "./spec/constants.js";
10
+ export { normalizeSpec, SAFE_NORMALIZE } from "./spec/normalize/index.js";
11
+ export { isMeaningless } from "./spec/ref.js";
12
+ export { extractSecuritySchemeNames, securityKey } from "./spec/security.js";
7
13
  export { schemaToType } from "./type/dispatch.js";
8
- export { assertNoEnumCollisions, classifyEnumLiterals, } from "./type/enum.js";
9
- export { classifyObjectShape, iterateObjectProperties, } from "./type/object.js";
10
- export { classifyUnion } from "./type/union.js";
11
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GACjB,MAAM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EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,45 +1,37 @@
1
1
  import type { IR } from "@hey-api/shared";
2
+ import { type Schema } from "@ir-kit/schema";
2
3
  /**
3
- * `true` when a JSON-typed body has no concrete `type` but carries an
4
- * `items[]` (typical of bare `oneOf`/`anyOf` schemas) — there's no
5
- * cleanly-typed structure to bind to, so each emitter falls back to a
6
- * raw byte buffer (`[]byte` / `ByteArray` / `Data`).
4
+ * `true` when a JSON-typed body has no concrete `type` but carries
5
+ * `oneOf`/`anyOf` branches — there's no cleanly-typed structure to
6
+ * bind to, so each emitter falls back to a raw byte buffer (`[]byte` /
7
+ * `ByteArray` / `Data`).
7
8
  */
8
- export declare function isOpaqueJsonBody(schema: IR.SchemaObject): boolean;
9
+ export declare function isOpaqueJsonBody(schema: Schema): boolean;
9
10
  /**
10
- * Outcome of inspecting `IR.BodyObject`'s media type + schema shape.
11
- * Each emitter switches on `kind` to pick its body-param strategy.
11
+ * Outcome of inspecting a body's media type + schema shape. Each
12
+ * emitter switches on `kind` to pick its body-param strategy.
12
13
  */
13
- export type BodyShape =
14
- /** `application/json` with a meaningful schema. */
15
- {
14
+ export type BodyShape = {
16
15
  kind: "json-typed";
17
- }
18
- /** `application/json` whose schema collapses to opaque (oneOf/anyOf
19
- * without a single shared shape). Each emitter falls back to bytes. */
20
- | {
16
+ } | {
21
17
  kind: "json-opaque";
22
- }
23
- /** `multipart/form-data` whose schema is an object — flatten props
24
- * into one func param each. */
25
- | {
18
+ } | {
26
19
  kind: "multipart-object";
27
- }
28
- /** `application/x-www-form-urlencoded` whose schema is an object —
29
- * flatten props into one func param each. */
30
- | {
20
+ } | {
31
21
  kind: "form-urlencoded-object";
32
- }
33
- /** Empty / octet-stream / image/* / unknown — caller pre-encodes a
34
- * single bytes param. */
35
- | {
22
+ } | {
36
23
  kind: "opaque";
37
24
  };
25
+ export interface ClassifiedBody {
26
+ shape: BodyShape;
27
+ /** The body's schema in canonical form, ready to feed `schemaToType`
28
+ * or `iterateObjectProperties`. */
29
+ schema: Schema;
30
+ }
38
31
  /**
39
- * Classify a body by its media type + schema shape so emitters can
40
- * dispatch identically on `kind`. The media-type matching rules are
41
- * the same ones the generators agreed on (`@ir-kit/openapi-core`
42
- * constants) — single source of truth.
32
+ * Classify a body by media type + schema shape and return the schema
33
+ * pre-converted to canonical form so each emitter can dispatch on
34
+ * `shape.kind` without re-converting.
43
35
  */
44
- export declare function classifyBody(body: IR.BodyObject): BodyShape;
36
+ export declare function classifyBody(body: IR.BodyObject): ClassifiedBody;
45
37
  //# sourceMappingURL=body.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../src/operation/body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAO1C;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,GAAG,OAAO,CAEjE;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS;AACnB,mDAAmD;AACjD;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE;AACxB;wEACwE;GACtE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE;AACzB;gCACgC;GAC9B;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE;AAC9B;8CAC8C;GAC5C;IAAE,IAAI,EAAE,wBAAwB,CAAA;CAAE;AACpC;0BAC0B;GACxB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,SAAS,CAiB3D"}
1
+ {"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../src/operation/body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAS7C;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGxD;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,wBAAwB,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,CAAC;IACjB;wCACoC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,cAAc,CAkBhE"}
@@ -1,34 +1,41 @@
1
- import { FORM_URLENCODED_MEDIA, JSON_MEDIA_RE, MULTIPART_FORM_MEDIA, } from "@ir-kit/openapi-core";
1
+ import {} from "@ir-kit/schema";
2
+ import { fromHeyApi } from "@ir-kit/schema/adapters/heyapi";
3
+ import { FORM_URLENCODED_MEDIA, JSON_MEDIA_RE, MULTIPART_FORM_MEDIA, } from "../spec/constants.js";
2
4
  /**
3
- * `true` when a JSON-typed body has no concrete `type` but carries an
4
- * `items[]` (typical of bare `oneOf`/`anyOf` schemas) — there's no
5
- * cleanly-typed structure to bind to, so each emitter falls back to a
6
- * raw byte buffer (`[]byte` / `ByteArray` / `Data`).
5
+ * `true` when a JSON-typed body has no concrete `type` but carries
6
+ * `oneOf`/`anyOf` branches — there's no cleanly-typed structure to
7
+ * bind to, so each emitter falls back to a raw byte buffer (`[]byte` /
8
+ * `ByteArray` / `Data`).
7
9
  */
8
10
  export function isOpaqueJsonBody(schema) {
9
- return !schema.type && Array.isArray(schema.items) && schema.items.length > 0;
11
+ if (schema.type)
12
+ return false;
13
+ return Boolean(schema.oneOf?.length || schema.anyOf?.length);
10
14
  }
11
15
  /**
12
- * Classify a body by its media type + schema shape so emitters can
13
- * dispatch identically on `kind`. The media-type matching rules are
14
- * the same ones the generators agreed on (`@ir-kit/openapi-core`
15
- * constants) — single source of truth.
16
+ * Classify a body by media type + schema shape and return the schema
17
+ * pre-converted to canonical form so each emitter can dispatch on
18
+ * `shape.kind` without re-converting.
16
19
  */
17
20
  export function classifyBody(body) {
18
21
  const mt = (body.mediaType ?? "").toLowerCase();
19
- const schema = body.schema;
22
+ const schema = fromHeyApi(body.schema);
20
23
  const isObject = schema.type === "object" && Boolean(schema.properties);
24
+ let shape;
21
25
  if (mt && JSON_MEDIA_RE.test(mt)) {
22
- return isOpaqueJsonBody(schema)
26
+ shape = isOpaqueJsonBody(schema)
23
27
  ? { kind: "json-opaque" }
24
28
  : { kind: "json-typed" };
25
29
  }
26
- if (mt.startsWith(MULTIPART_FORM_MEDIA) && isObject) {
27
- return { kind: "multipart-object" };
30
+ else if (mt.startsWith(MULTIPART_FORM_MEDIA) && isObject) {
31
+ shape = { kind: "multipart-object" };
28
32
  }
29
- if (mt.startsWith(FORM_URLENCODED_MEDIA) && isObject) {
30
- return { kind: "form-urlencoded-object" };
33
+ else if (mt.startsWith(FORM_URLENCODED_MEDIA) && isObject) {
34
+ shape = { kind: "form-urlencoded-object" };
31
35
  }
32
- return { kind: "opaque" };
36
+ else {
37
+ shape = { kind: "opaque" };
38
+ }
39
+ return { shape, schema };
33
40
  }
34
41
  //# sourceMappingURL=body.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"body.js","sourceRoot":"","sources":["../../src/operation/body.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,oBAAoB,GACrB,MAAM,sBAAsB,CA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EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { IR } from "@hey-api/shared";
2
- import { type HttpMethod } from "@ir-kit/openapi-core";
2
+ import { type HttpMethod } from "../spec/constants.js";
3
3
  export interface IteratedOperation {
4
4
  pathStr: string;
5
5
  method: HttpMethod;
@@ -1 +1 @@
1
- {"version":3,"file":"iter.d.ts","sourceRoot":"","sources":["../../src/operation/iter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC;IACvB;0EACsE;IACtE,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAiB,cAAc,CAC7B,KAAK,EAAE,EAAE,CAAC,WAAW,GAAG,SAAS,EACjC,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,GACvD,SAAS,CAAC,iBAAiB,CAAC,CAa9B"}
1
+ {"version":3,"file":"iter.d.ts","sourceRoot":"","sources":["../../src/operation/iter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGrE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC;IACvB;0EACsE;IACtE,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAiB,cAAc,CAC7B,KAAK,EAAE,EAAE,CAAC,WAAW,GAAG,SAAS,EACjC,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,GACvD,SAAS,CAAC,iBAAiB,CAAC,CAa9B"}
@@ -1,4 +1,5 @@
1
- import { HTTP_METHODS, securityKey, } from "@ir-kit/openapi-core";
1
+ import { HTTP_METHODS } from "../spec/constants.js";
2
+ import { securityKey } from "../spec/security.js";
2
3
  /**
3
4
  * Walk `IR.PathsObject` and yield one entry per `(path, method)` that
4
5
  * carries an operation, with security-scheme names resolved up-front.
@@ -1 +1 @@
1
- {"version":3,"file":"iter.js","sourceRoot":"","sources":["../../src/operation/iter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EAEZ,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAW9B;;;;;;;;;GASG;AACH,MAAM,SAAS,CAAC,CAAC,cAAc,CAC7B,KAAiC,EACjC,WAAwD;IAExD,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QAC9D,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE,CAAC;YAClC,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAmC,CAAC;YAC9D,IAAI,CAAC,EAAE;gBAAE,SAAS;YAClB,MAAM;gBACJ,OAAO;gBACP,MAAM,EAAE,MAAoB;gBAC5B,EAAE;gBACF,WAAW,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE;aAClE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"iter.js","sourceRoot":"","sources":["../../src/operation/iter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAWlD;;;;;;;;;GASG;AACH,MAAM,SAAS,CAAC,CAAC,cAAc,CAC7B,KAAiC,EACjC,WAAwD;IAExD,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QAC9D,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE,CAAC;YAClC,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAmC,CAAC;YAC9D,IAAI,CAAC,EAAE;gBAAE,SAAS;YAClB,MAAM;gBACJ,OAAO;gBACP,MAAM,EAAE,MAAoB;gBAC5B,EAAE;gBACF,WAAW,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE;aAClE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,58 +1,38 @@
1
1
  import type { IR } from "@hey-api/shared";
2
- /**
3
- * Match a 3-digit HTTP status code in the 2xx range. Treats string
4
- * codes only (matching hey-api's IR shape) so `"default"` and `"4XX"`
5
- * style buckets don't accidentally classify as success.
6
- */
2
+ import type { Schema } from "@ir-kit/schema";
7
3
  export declare const isSuccessStatus: (code: string) => boolean;
8
4
  /**
9
- * Return the operation's 2xx responses as `[code, response]` tuples,
10
- * sorted by code for stable per-target emission order.
11
- *
12
- * Common pattern across emitters: 0 → no return, 1 → decode straight,
13
- * 2+ → emit a sum-type return that dispatches on the status code.
5
+ * Operation's 2xx responses as `[code, response]` tuples, sorted by
6
+ * code for stable per-target emission order.
14
7
  */
15
8
  export declare function successResponses(op: IR.OperationObject): Array<readonly [string, IR.ResponseObject]>;
16
9
  /**
17
- * One arm of a multi-2xx sum-type return. Each emitter parameterises
18
- * `T` with its own target type (`GoType`, `KtType`, `SwType`) for the
19
- * decoded payload. `payloadType` is omitted for empty bodies (e.g. 204).
10
+ * One arm of a multi-2xx sum-type return. Status code + payload
11
+ * schema (canonical, already converted from hey-api).
20
12
  */
21
- export interface ResponseCase<T> {
13
+ export interface ResponseCase {
22
14
  statusCode: string;
23
- caseName: string;
24
- payloadType?: T;
15
+ /** `undefined` for empty / meaningless responses (e.g. `204`). */
16
+ schema: Schema | undefined;
25
17
  }
26
18
  /**
27
19
  * Shape of an operation's success return, normalised so each emitter
28
- * can switch on `kind` instead of re-deriving the same 4-way logic
29
- * (no successes, single empty, single typed, multi-case) from the
30
- * `successResponses` array.
20
+ * can switch on `kind`. Schemas are canonical {@link Schema}.
31
21
  */
32
22
  export type ReturnShape =
33
- /** Either no 2xx responses at all, or a single 2xx whose schema is
34
- * empty / meaningless. Caller renders its Unit / Void analog. */
23
+ /** No 2xx responses, or a single 2xx with empty schema. */
35
24
  {
36
25
  kind: "void";
37
26
  }
38
- /** Single 2xx response with a non-empty schema. Caller calls
39
- * `schemaToType(schema)` and uses the result as the return. */
27
+ /** Single 2xx with non-empty schema. */
40
28
  | {
41
29
  kind: "single";
42
- schema: IR.SchemaObject;
30
+ schema: Schema;
43
31
  }
44
- /** Multiple 2xx responses. Caller emits a sum-type (Go interface,
45
- * Kotlin sealed class, Swift enum) and dispatches on status. */
32
+ /** Multiple 2xx — emitter renders a sum type. */
46
33
  | {
47
34
  kind: "multi";
48
- cases: ReadonlyArray<readonly [string, IR.ResponseObject]>;
35
+ cases: ReadonlyArray<ResponseCase>;
49
36
  };
50
- /**
51
- * Classify the success-path return for an operation. Folds the
52
- * "0 success → void / 1 success with empty schema → void / 1 success
53
- * with schema → single / 2+ success → multi" decision tree into one
54
- * tagged union so each emitter just switches on `kind` and applies
55
- * its target rendering.
56
- */
57
37
  export declare function classifyReturnShape(op: IR.OperationObject): ReturnShape;
58
38
  //# sourceMappingURL=responses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/operation/responses.ts"],"names":[],"mappings":"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AS,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAM7C;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW;AACrB,2DAA2D;AACzD;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;AAClB,wCAAwC;GACtC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACpC,iDAAiD;GAC/C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;CAAE,CAAC;AAE1D,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,EAAE,CAAC,eAAe,GAAG,WAAW,CAqBvE"}
@@ -1,39 +1,39 @@
1
- import { isMeaningless } from "@ir-kit/openapi-core";
2
- /**
3
- * Match a 3-digit HTTP status code in the 2xx range. Treats string
4
- * codes only (matching hey-api's IR shape) so `"default"` and `"4XX"`
5
- * style buckets don't accidentally classify as success.
6
- */
1
+ import { fromHeyApi } from "@ir-kit/schema/adapters/heyapi";
2
+ import { isMeaningless } from "../spec/ref.js";
7
3
  export const isSuccessStatus = (code) => /^2\d\d$/.test(code);
8
4
  /**
9
- * Return the operation's 2xx responses as `[code, response]` tuples,
10
- * sorted by code for stable per-target emission order.
11
- *
12
- * Common pattern across emitters: 0 → no return, 1 → decode straight,
13
- * 2+ → emit a sum-type return that dispatches on the status code.
5
+ * Operation's 2xx responses as `[code, response]` tuples, sorted by
6
+ * code for stable per-target emission order.
14
7
  */
15
8
  export function successResponses(op) {
16
9
  return Object.entries(op.responses ?? {})
17
10
  .filter(([k]) => isSuccessStatus(k))
18
11
  .sort(([a], [b]) => a.localeCompare(b));
19
12
  }
20
- /**
21
- * Classify the success-path return for an operation. Folds the
22
- * "0 success → void / 1 success with empty schema → void / 1 success
23
- * with schema → single / 2+ success → multi" decision tree into one
24
- * tagged union so each emitter just switches on `kind` and applies
25
- * its target rendering.
26
- */
27
13
  export function classifyReturnShape(op) {
28
14
  const success = successResponses(op);
29
15
  if (success.length === 0)
30
16
  return { kind: "void" };
31
17
  if (success.length === 1) {
32
18
  const [, resp] = success[0];
33
- if (!resp?.schema || isMeaningless(resp.schema))
19
+ if (!resp?.schema)
20
+ return { kind: "void" };
21
+ const schema = fromHeyApi(resp.schema);
22
+ if (isMeaningless(schema))
34
23
  return { kind: "void" };
35
- return { kind: "single", schema: resp.schema };
24
+ return { kind: "single", schema };
36
25
  }
37
- return { kind: "multi", cases: success };
26
+ return {
27
+ kind: "multi",
28
+ cases: success.map(([statusCode, resp]) => {
29
+ if (!resp?.schema)
30
+ return { statusCode, schema: undefined };
31
+ const schema = fromHeyApi(resp.schema);
32
+ return {
33
+ statusCode,
34
+ schema: isMeaningless(schema) ? undefined : schema,
35
+ };
36
+ }),
37
+ };
38
38
  }
39
39
  //# sourceMappingURL=responses.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/operation/responses.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE/E;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,EAAsB;IAEtB,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC;SACtC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;SACnC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,a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2
- import { type HttpMethod } from "@ir-kit/openapi-core";
2
+ import { type HttpMethod } from "../spec/constants.js";
3
3
  /**
4
4
  * Derive the canonical *base* name for an operation — the unstyled
5
5
  * identifier each emitter then runs through its own case transform
@@ -1,4 +1,4 @@
1
- import { HTTP_METHOD_LITERAL } from "@ir-kit/openapi-core";
1
+ import { HTTP_METHOD_LITERAL } from "../spec/constants.js";
2
2
  /**
3
3
  * Derive the canonical *base* name for an operation — the unstyled
4
4
  * identifier each emitter then runs through its own case transform
@@ -0,0 +1,20 @@
1
+ /**
2
+ * HTTP-method tuple iterated by every operation walker. Ordered to
3
+ * match the OpenAPI spec's canonical ordering so generated output is
4
+ * deterministic across runs and across generators.
5
+ */
6
+ export declare const HTTP_METHODS: readonly ["get", "post", "put", "delete", "patch", "head", "options", "trace"];
7
+ export type HttpMethod = (typeof HTTP_METHODS)[number];
8
+ /**
9
+ * Wire-format method literal expected by HTTP clients (`GET` not `get`).
10
+ */
11
+ export declare const HTTP_METHOD_LITERAL: Record<HttpMethod, string>;
12
+ /**
13
+ * Match `application/json` and any RFC 6839 structured-syntax suffix
14
+ * variant (e.g. `application/vnd.api+json`). Tolerant of trailing
15
+ * `;charset=...` parameters.
16
+ */
17
+ export declare const JSON_MEDIA_RE: RegExp;
18
+ export declare const FORM_URLENCODED_MEDIA = "application/x-www-form-urlencoded";
19
+ export declare const MULTIPART_FORM_MEDIA = "multipart/form-data";
20
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/spec/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY,gFASf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAS1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAqD,CAAC;AAEhF,eAAO,MAAM,qBAAqB,sCAAsC,CAAC;AACzE,eAAO,MAAM,oBAAoB,wBAAwB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * HTTP-method tuple iterated by every operation walker. Ordered to
3
+ * match the OpenAPI spec's canonical ordering so generated output is
4
+ * deterministic across runs and across generators.
5
+ */
6
+ export const HTTP_METHODS = [
7
+ "get",
8
+ "post",
9
+ "put",
10
+ "delete",
11
+ "patch",
12
+ "head",
13
+ "options",
14
+ "trace",
15
+ ];
16
+ /**
17
+ * Wire-format method literal expected by HTTP clients (`GET` not `get`).
18
+ */
19
+ export const HTTP_METHOD_LITERAL = {
20
+ get: "GET",
21
+ post: "POST",
22
+ put: "PUT",
23
+ delete: "DELETE",
24
+ patch: "PATCH",
25
+ head: "HEAD",
26
+ options: "OPTIONS",
27
+ trace: "TRACE",
28
+ };
29
+ /**
30
+ * Match `application/json` and any RFC 6839 structured-syntax suffix
31
+ * variant (e.g. `application/vnd.api+json`). Tolerant of trailing
32
+ * `;charset=...` parameters.
33
+ */
34
+ export const JSON_MEDIA_RE = /^application\/(?:json|[\w.+-]+\+json)(?:\s*;|$)/i;
35
+ export const FORM_URLENCODED_MEDIA = "application/x-www-form-urlencoded";
36
+ export const MULTIPART_FORM_MEDIA = "multipart/form-data";
37
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/spec/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK;IACL,MAAM;IACN,KAAK;IACL,QAAQ;IACR,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;CACC,CAAC;AAIX;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA+B;IAC7D,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,kDAAkD,CAAC;AAEhF,MAAM,CAAC,MAAM,qBAAqB,GAAG,mCAAmC,CAAC;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Collapse `{ allOf: [X] }` (single-element) into the parent. */
2
+ export declare function collapseSingleAllOf(spec: unknown): void;
3
+ //# sourceMappingURL=allOf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allOf.d.ts","sourceRoot":"","sources":["../../../src/spec/normalize/allOf.ts"],"names":[],"mappings":"AAEA,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAcvD"}
@@ -0,0 +1,42 @@
1
+ import { walkSchemas } from "./walk.js";
2
+ /** Collapse `{ allOf: [X] }` (single-element) into the parent. */
3
+ export function collapseSingleAllOf(spec) {
4
+ walkSchemas(spec, ({ node }) => {
5
+ if (!node || typeof node !== "object")
6
+ return;
7
+ const value = node;
8
+ const allOf = value.allOf;
9
+ if (!Array.isArray(allOf) || allOf.length !== 1)
10
+ return;
11
+ const sole = allOf[0];
12
+ if (!sole || typeof sole !== "object")
13
+ return;
14
+ if (hasMeaningfulSiblings(value))
15
+ return;
16
+ delete value.allOf;
17
+ Object.assign(value, sole);
18
+ });
19
+ }
20
+ function hasMeaningfulSiblings(value) {
21
+ for (const key of Object.keys(value)) {
22
+ if (key === "allOf")
23
+ continue;
24
+ if (PRESENTATIONAL.has(key))
25
+ continue;
26
+ if (key.startsWith("x-"))
27
+ continue;
28
+ return true;
29
+ }
30
+ return false;
31
+ }
32
+ const PRESENTATIONAL = new Set([
33
+ "description",
34
+ "title",
35
+ "deprecated",
36
+ "example",
37
+ "examples",
38
+ "externalDocs",
39
+ "readOnly",
40
+ "writeOnly",
41
+ ]);
42
+ //# sourceMappingURL=allOf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allOf.js","sourceRoot":"","sources":["../../../src/spec/normalize/allOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,kEAAkE;AAClE,MAAM,UAAU,mBAAmB,CAAC,IAAa;IAC/C,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO;QAC9C,MAAM,KAAK,GAAG,IAA+B,CAAC;QAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAExD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO;QAC9C,IAAI,qBAAqB,CAAC,KAAK,CAAC;YAAE,OAAO;QAEzC,OAAO,KAAK,CAAC,KAAK,CAAC;QACnB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAAC,KAA8B;IAC3D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,GAAG,KAAK,OAAO;YAAE,SAAS;QAC9B,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QACtC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,SAAS;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IAClD,aAAa;IACb,OAAO;IACP,YAAY;IACZ,SAAS;IACT,UAAU;IACV,cAAc;IACd,UAAU;IACV,WAAW;CACZ,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { NamingConfig } from "./name.js";
2
+ export interface EnumPassOptions {
3
+ naming?: NamingConfig;
4
+ }
5
+ /**
6
+ * Hoist identical inline enums to `components.schemas` and rewrite each
7
+ * occurrence as a `$ref`. Returns the set of newly-added schema names.
8
+ */
9
+ export declare function dedupeInlineEnums(spec: unknown, opts?: EnumPassOptions): Set<string>;
10
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../src/spec/normalize/enums.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAS9C,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAOD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,EACb,IAAI,GAAE,eAAoB,GACzB,GAAG,CAAC,MAAM,CAAC,CAkFb"}