@ir-kit/openapi 0.3.0 → 0.5.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.
- package/README.md +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/operation/iter.d.ts +5 -0
- package/dist/operation/iter.d.ts.map +1 -1
- package/dist/operation/iter.js +17 -0
- package/dist/operation/iter.js.map +1 -1
- package/dist/spec/normalize/index.d.ts +1 -0
- package/dist/spec/normalize/index.d.ts.map +1 -1
- package/dist/spec/normalize/index.js +1 -0
- package/dist/spec/normalize/index.js.map +1 -1
- package/dist/spec/normalize/refs.d.ts +8 -0
- package/dist/spec/normalize/refs.d.ts.map +1 -0
- package/dist/spec/normalize/refs.js +98 -0
- package/dist/spec/normalize/refs.js.map +1 -0
- package/dist/type/components.d.ts +36 -0
- package/dist/type/components.d.ts.map +1 -0
- package/dist/type/components.js +34 -0
- package/dist/type/components.js.map +1 -0
- package/dist/type/context.d.ts +6 -0
- package/dist/type/context.d.ts.map +1 -1
- package/dist/type/dispatch.d.ts +22 -3
- package/dist/type/dispatch.d.ts.map +1 -1
- package/dist/type/dispatch.js +49 -9
- package/dist/type/dispatch.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -119,7 +119,7 @@ When you spot duplication in `@ir-kit/openapi-{go,kotlin,swift}`:
|
|
|
119
119
|
|
|
120
120
|
1. Identify the **pre-work** (what does the IR walk produce that's target-neutral?) vs the **render** (what's the target-specific shape it gets wrapped in?).
|
|
121
121
|
2. Add the pre-work helper to this package — pure function, generator, or classifier.
|
|
122
|
-
3. Update each emitter to consume it. Verify the petstore SDK regen is byte-identical (the repo's `examples/
|
|
122
|
+
3. Update each emitter to consume it. Verify the petstore SDK regen is byte-identical (the repo's `examples/openapi-sdk-petstore/` is the canonical fixture).
|
|
123
123
|
4. Land in one commit per emitter pass for clean git history.
|
|
124
124
|
|
|
125
125
|
If the duplication is in render — different code paths producing structurally-different target code — it stays per-emitter. Push back on consolidating principled language differences just because they look similar.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type { EnumEntryIdent, EnumKind, EnumLiteral, ObjectProperty, ObjectShape, Schema, SchemaDiscriminator, SchemaOrBool, SchemaPrimitiveType, UnionShape, } from "@ir-kit/schema";
|
|
2
|
-
export {
|
|
2
|
+
export { classifyEnumLiterals, classifyObject, classifyUnion, extractEnumValues, isNullable, isPrimitive, isRefOnly, isSchemaObject, isUnionShape, iterateObjectProperties, primitiveTag, refName, typeList, uniqueEnumEntries, } from "@ir-kit/schema";
|
|
3
3
|
export { fromHeyApi } from "@ir-kit/schema/adapters/heyapi";
|
|
4
4
|
export type { BodyShape, ClassifiedBody } from "./operation/body.js";
|
|
5
5
|
export { classifyBody, isOpaqueJsonBody } from "./operation/body.js";
|
|
6
6
|
export type { IteratedOperation } from "./operation/iter.js";
|
|
7
|
-
export { iterOperations } from "./operation/iter.js";
|
|
7
|
+
export { groupOperationsByTag, iterOperations } from "./operation/iter.js";
|
|
8
8
|
export type { LocatedParam, ParamLocation } from "./operation/params.js";
|
|
9
9
|
export { collectLocatedParams, PARAM_LOCATIONS, paramsAt, } from "./operation/params.js";
|
|
10
10
|
export type { ResponseCase, ReturnShape } from "./operation/responses.js";
|
|
@@ -14,10 +14,11 @@ export type { TemplatePart } from "./operation/template.js";
|
|
|
14
14
|
export { parseTemplatedSegment } from "./operation/template.js";
|
|
15
15
|
export { FORM_URLENCODED_MEDIA, HTTP_METHOD_LITERAL, HTTP_METHODS, type HttpMethod, JSON_MEDIA_RE, MULTIPART_FORM_MEDIA, } from "./spec/constants.js";
|
|
16
16
|
export type { Casing, EnumPassOptions, NamingConfig, NamingRule, NormalizeOptions, ObjectPassOptions, } from "./spec/normalize/index.js";
|
|
17
|
-
export { normalizeSpec, SAFE_NORMALIZE } from "./spec/normalize/index.js";
|
|
17
|
+
export { hoistForeignSchemaRefs, normalizeSpec, SAFE_NORMALIZE, } from "./spec/normalize/index.js";
|
|
18
18
|
export { isMeaningless } from "./spec/ref.js";
|
|
19
19
|
export { extractSecuritySchemeNames, securityKey } from "./spec/security.js";
|
|
20
|
+
export { type Component, type ComponentShape, classifyComponents, } from "./type/components.js";
|
|
20
21
|
export type { TypeCtx } from "./type/context.js";
|
|
21
22
|
export type { SchemaToTypeOps } from "./type/dispatch.js";
|
|
22
|
-
export { schemaToType } from "./type/dispatch.js";
|
|
23
|
+
export { enumType, schemaToType, schemaTypeName, synthTypeName, } from "./type/dispatch.js";
|
|
23
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,cAAc,EACd,WAAW,EACX,MAAM,EACN,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,cAAc,EACd,WAAW,EACX,MAAM,EACN,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,SAAS,EACT,cAAc,EACd,YAAY,EACZ,uBAAuB,EACvB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,cAAc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;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { classifyEnumLiterals, classifyObject, classifyUnion, extractEnumValues, isNullable, isPrimitive, isRefOnly, isSchemaObject, isUnionShape, iterateObjectProperties, primitiveTag, refName, typeList, uniqueEnumEntries, } from "@ir-kit/schema";
|
|
2
2
|
export { fromHeyApi } from "@ir-kit/schema/adapters/heyapi";
|
|
3
3
|
export { classifyBody, isOpaqueJsonBody } from "./operation/body.js";
|
|
4
|
-
export { iterOperations } from "./operation/iter.js";
|
|
4
|
+
export { groupOperationsByTag, iterOperations } from "./operation/iter.js";
|
|
5
5
|
export { collectLocatedParams, PARAM_LOCATIONS, paramsAt, } from "./operation/params.js";
|
|
6
6
|
export { classifyReturnShape, isSuccessStatus, successResponses, } from "./operation/responses.js";
|
|
7
7
|
export { deriveBaseName, operationDocLine, splitPathSegments, } from "./operation/signature.js";
|
|
8
8
|
export { parseTemplatedSegment } from "./operation/template.js";
|
|
9
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";
|
|
10
|
+
export { hoistForeignSchemaRefs, normalizeSpec, SAFE_NORMALIZE, } from "./spec/normalize/index.js";
|
|
11
11
|
export { isMeaningless } from "./spec/ref.js";
|
|
12
12
|
export { extractSecuritySchemeNames, securityKey } from "./spec/security.js";
|
|
13
|
-
export {
|
|
13
|
+
export { classifyComponents, } from "./type/components.js";
|
|
14
|
+
export { enumType, schemaToType, schemaTypeName, synthTypeName, } from "./type/dispatch.js";
|
|
14
15
|
//# 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":"AAYA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,SAAS,EACT,cAAc,EACd,YAAY,EACZ,uBAAuB,EACvB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EAEZ,aAAa,EACb,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAGL,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,oBAAoB,CAAC"}
|
package/dist/operation/iter.d.ts
CHANGED
|
@@ -19,4 +19,9 @@ export interface IteratedOperation {
|
|
|
19
19
|
* stable and matches the existing emit order.
|
|
20
20
|
*/
|
|
21
21
|
export declare function iterOperations(paths: IR.PathsObject | undefined, schemeNames?: ReadonlyMap<string, ReadonlyArray<string>>): Generator<IteratedOperation>;
|
|
22
|
+
/**
|
|
23
|
+
* Group every operation under its first tag (or `defaultTag`), mapped
|
|
24
|
+
* through `sign`. Tags keep first-seen order; operations keep walk order.
|
|
25
|
+
*/
|
|
26
|
+
export declare function groupOperationsByTag<S>(paths: IR.PathsObject | undefined, schemeNames: ReadonlyMap<string, ReadonlyArray<string>> | undefined, defaultTag: string, sign: (operation: IteratedOperation) => S): Map<string, S[]>;
|
|
22
27
|
//# sourceMappingURL=iter.d.ts.map
|
|
@@ -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,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
|
+
{"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;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,EAAE,CAAC,WAAW,GAAG,SAAS,EACjC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,EACnE,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,CAAC,GACxC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAUlB"}
|
package/dist/operation/iter.js
CHANGED
|
@@ -25,4 +25,21 @@ export function* iterOperations(paths, schemeNames) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Group every operation under its first tag (or `defaultTag`), mapped
|
|
30
|
+
* through `sign`. Tags keep first-seen order; operations keep walk order.
|
|
31
|
+
*/
|
|
32
|
+
export function groupOperationsByTag(paths, schemeNames, defaultTag, sign) {
|
|
33
|
+
const byTag = new Map();
|
|
34
|
+
for (const operation of iterOperations(paths, schemeNames)) {
|
|
35
|
+
const tag = operation.op.tags?.[0] ?? defaultTag;
|
|
36
|
+
const signed = sign(operation);
|
|
37
|
+
const list = byTag.get(tag);
|
|
38
|
+
if (list)
|
|
39
|
+
list.push(signed);
|
|
40
|
+
else
|
|
41
|
+
byTag.set(tag, [signed]);
|
|
42
|
+
}
|
|
43
|
+
return byTag;
|
|
44
|
+
}
|
|
28
45
|
//# sourceMappingURL=iter.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"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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
|
4
4
|
export type { Casing, NamingConfig, NamingRule } from "./name.js";
|
|
5
5
|
export type { ObjectPassOptions } from "./objects.js";
|
|
6
|
+
export { hoistForeignSchemaRefs } from "./refs.js";
|
|
6
7
|
export interface NormalizeOptions {
|
|
7
8
|
/** Hoist identical inline enums to `components.schemas`. */
|
|
8
9
|
enums?: boolean | EnumPassOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spec/normalize/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAItD,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spec/normalize/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAItD,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,GAAG,eAAe,CAAC;IAClC,oDAAoD;IACpD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACtC,yGAAyG;IACzG,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAE,gBAAqB,GAAG,CAAC,CAmBxE;AAED,0EAA0E;AAC1E,eAAO,MAAM,cAAc,EAAE,gBAI5B,CAAC"}
|
|
@@ -9,6 +9,7 @@ import { collapseSingleAllOf } from "./allOf.js";
|
|
|
9
9
|
import { dedupeInlineEnums } from "./enums.js";
|
|
10
10
|
import { dedupeInlineObjects } from "./objects.js";
|
|
11
11
|
import { pruneUnusedSchemas } from "./prune.js";
|
|
12
|
+
export { hoistForeignSchemaRefs } from "./refs.js";
|
|
12
13
|
/** Apply enabled passes to `spec` in place. Returns the same reference. */
|
|
13
14
|
export function normalizeSpec(spec, opts = {}) {
|
|
14
15
|
if (opts.allOf)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spec/normalize/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spec/normalize/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAKhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAanD,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CAAI,IAAO,EAAE,OAAyB,EAAE;IACnE,IAAI,IAAI,CAAC,KAAK;QAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,iBAAiB,CAC7B,IAAI,EACJ,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CACtC,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,KAAK,GAAG,mBAAmB,CAC/B,IAAI,EACJ,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAC1C,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,IAAI,CAAC,KAAK;QAAE,kBAAkB,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;CACZ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Give every schema that is `$ref`'d from outside the components section
|
|
3
|
+
* (e.g. `#/paths/~1apps/get/responses/200/.../properties/cors`) a home in
|
|
4
|
+
* `components.schemas`, and point those refs at it. Generators then only
|
|
5
|
+
* ever see refs to declared components. Returns the added schema names.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hoistForeignSchemaRefs(spec: unknown): Set<string>;
|
|
8
|
+
//# sourceMappingURL=refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../src/spec/normalize/refs.ts"],"names":[],"mappings":"AAsDA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAoCjE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { uniqueComponentName } from "./name.js";
|
|
2
|
+
import { getSchemasObject, schemasPointerPrefix } from "./walk.js";
|
|
3
|
+
const STRUCTURAL = new Set([
|
|
4
|
+
"additionalProperties",
|
|
5
|
+
"allOf",
|
|
6
|
+
"anyOf",
|
|
7
|
+
"content",
|
|
8
|
+
"items",
|
|
9
|
+
"not",
|
|
10
|
+
"oneOf",
|
|
11
|
+
"properties",
|
|
12
|
+
"schema",
|
|
13
|
+
]);
|
|
14
|
+
function decodePointer(ref) {
|
|
15
|
+
return ref
|
|
16
|
+
.slice(2)
|
|
17
|
+
.split("/")
|
|
18
|
+
.map((s) => decodeURIComponent(s).replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
19
|
+
}
|
|
20
|
+
function resolvePointer(spec, segments) {
|
|
21
|
+
let node = spec;
|
|
22
|
+
for (const seg of segments) {
|
|
23
|
+
if (!node || typeof node !== "object")
|
|
24
|
+
return undefined;
|
|
25
|
+
node = node[seg];
|
|
26
|
+
}
|
|
27
|
+
return node;
|
|
28
|
+
}
|
|
29
|
+
function visitRefs(node, visit) {
|
|
30
|
+
if (!node || typeof node !== "object")
|
|
31
|
+
return;
|
|
32
|
+
if (Array.isArray(node)) {
|
|
33
|
+
for (const item of node)
|
|
34
|
+
visitRefs(item, visit);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const obj = node;
|
|
38
|
+
if (typeof obj.$ref === "string")
|
|
39
|
+
visit(obj, obj.$ref);
|
|
40
|
+
for (const v of Object.values(obj))
|
|
41
|
+
visitRefs(v, visit);
|
|
42
|
+
}
|
|
43
|
+
function nameFor(segments) {
|
|
44
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
45
|
+
const seg = segments[i];
|
|
46
|
+
if (!STRUCTURAL.has(seg) && !/^\d+$/.test(seg) && !seg.includes("/"))
|
|
47
|
+
return seg;
|
|
48
|
+
}
|
|
49
|
+
return "Schema";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Give every schema that is `$ref`'d from outside the components section
|
|
53
|
+
* (e.g. `#/paths/~1apps/get/responses/200/.../properties/cors`) a home in
|
|
54
|
+
* `components.schemas`, and point those refs at it. Generators then only
|
|
55
|
+
* ever see refs to declared components. Returns the added schema names.
|
|
56
|
+
*/
|
|
57
|
+
export function hoistForeignSchemaRefs(spec) {
|
|
58
|
+
const added = new Set();
|
|
59
|
+
const schemas = getSchemasObject(spec);
|
|
60
|
+
const prefix = schemasPointerPrefix(spec);
|
|
61
|
+
if (!schemas || !prefix)
|
|
62
|
+
return added;
|
|
63
|
+
const isForeign = (ref) => {
|
|
64
|
+
if (!ref.startsWith("#/") || ref.startsWith("#/components/"))
|
|
65
|
+
return false;
|
|
66
|
+
if (ref.startsWith("#/definitions/"))
|
|
67
|
+
return false;
|
|
68
|
+
return decodePointer(ref).some((s) => s === "schema" || s === "schemas");
|
|
69
|
+
};
|
|
70
|
+
const targets = new Map();
|
|
71
|
+
visitRefs(spec, (_, ref) => {
|
|
72
|
+
if (!isForeign(ref) || targets.has(ref))
|
|
73
|
+
return;
|
|
74
|
+
const segments = decodePointer(ref);
|
|
75
|
+
let target = resolvePointer(spec, segments);
|
|
76
|
+
if (!target || typeof target !== "object")
|
|
77
|
+
return;
|
|
78
|
+
const inner = target.$ref;
|
|
79
|
+
if (typeof inner === "string" && !isForeign(inner)) {
|
|
80
|
+
targets.set(ref, inner);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const name = uniqueComponentName(nameFor(segments), schemas, added);
|
|
84
|
+
target = structuredClone(target);
|
|
85
|
+
schemas[name] = target;
|
|
86
|
+
added.add(name);
|
|
87
|
+
targets.set(ref, `${prefix}${name}`);
|
|
88
|
+
});
|
|
89
|
+
if (targets.size === 0)
|
|
90
|
+
return added;
|
|
91
|
+
visitRefs(spec, (holder, ref) => {
|
|
92
|
+
const next = targets.get(ref);
|
|
93
|
+
if (next)
|
|
94
|
+
holder.$ref = next;
|
|
95
|
+
});
|
|
96
|
+
return added;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=refs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../../src/spec/normalize/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEnE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,sBAAsB;IACtB,OAAO;IACP,OAAO;IACP,SAAS;IACT,OAAO;IACP,KAAK;IACL,OAAO;IACP,YAAY;IACZ,QAAQ;CACT,CAAC,CAAC;AAEH,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,GAAG;SACP,KAAK,CAAC,CAAC,CAAC;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,cAAc,CAAC,IAAa,EAAE,QAA+B;IACpE,IAAI,IAAI,GAAY,IAAI,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,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AC;QACD,MAAM,IAAI,GAAG,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACpE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;QACvB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,IAAI;YAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IR } from "@hey-api/shared";
|
|
2
|
+
import type { Namespace } from "@ir-kit/codegen-core";
|
|
3
|
+
import { type Schema } from "@ir-kit/schema";
|
|
4
|
+
/** How a top-level component schema maps onto a declaration. */
|
|
5
|
+
export type ComponentShape =
|
|
6
|
+
/** Alias of another component, by its claimed type name. */
|
|
7
|
+
{
|
|
8
|
+
kind: "ref";
|
|
9
|
+
target: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "enum";
|
|
12
|
+
}
|
|
13
|
+
/** Object with properties, or sealed (`additionalProperties: false`). */
|
|
14
|
+
| {
|
|
15
|
+
kind: "struct";
|
|
16
|
+
}
|
|
17
|
+
/** Open object; `value` is the typed `additionalProperties`, if any. */
|
|
18
|
+
| {
|
|
19
|
+
kind: "map";
|
|
20
|
+
value?: Schema;
|
|
21
|
+
}
|
|
22
|
+
/** Anything else: an alias of the schema's own type. */
|
|
23
|
+
| {
|
|
24
|
+
kind: "type";
|
|
25
|
+
};
|
|
26
|
+
export interface Component {
|
|
27
|
+
name: string;
|
|
28
|
+
schema: Schema;
|
|
29
|
+
shape: ComponentShape;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Claim every component's type name, then classify each one. Names are
|
|
33
|
+
* claimed up front so they win over synthesized inline type names.
|
|
34
|
+
*/
|
|
35
|
+
export declare function classifyComponents(schemas: Record<string, IR.SchemaObject>, names: Namespace): Component[];
|
|
36
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/type/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAKtD,gEAAgE;AAChE,MAAM,MAAM,cAAc;AACxB,4DAA4D;AAC1D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;AAClB,yEAAyE;GACvE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE;AACpB,wEAAwE;GACtE;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AACjC,wDAAwD;GACtD;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,cAAc,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,EACxC,KAAK,EAAE,SAAS,GACf,SAAS,EAAE,CAUb"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { refName } from "@ir-kit/schema";
|
|
2
|
+
import { fromHeyApi } from "@ir-kit/schema/adapters/heyapi";
|
|
3
|
+
import { schemaTypeName } from "./dispatch.js";
|
|
4
|
+
/**
|
|
5
|
+
* Claim every component's type name, then classify each one. Names are
|
|
6
|
+
* claimed up front so they win over synthesized inline type names.
|
|
7
|
+
*/
|
|
8
|
+
export function classifyComponents(schemas, names) {
|
|
9
|
+
for (const rawName of Object.keys(schemas))
|
|
10
|
+
schemaTypeName(names, rawName);
|
|
11
|
+
return Object.entries(schemas).map(([rawName, heySchema]) => {
|
|
12
|
+
const schema = fromHeyApi(heySchema);
|
|
13
|
+
return {
|
|
14
|
+
name: schemaTypeName(names, rawName),
|
|
15
|
+
schema,
|
|
16
|
+
shape: componentShape(schema, names),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function componentShape(schema, names) {
|
|
21
|
+
if (schema.$ref) {
|
|
22
|
+
return { kind: "ref", target: schemaTypeName(names, refName(schema.$ref)) };
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
25
|
+
return { kind: "enum" };
|
|
26
|
+
}
|
|
27
|
+
if (schema.type !== "object")
|
|
28
|
+
return { kind: "type" };
|
|
29
|
+
const ap = schema.additionalProperties;
|
|
30
|
+
if (schema.properties || ap === false)
|
|
31
|
+
return { kind: "struct" };
|
|
32
|
+
return { kind: "map", value: ap && typeof ap === "object" ? ap : undefined };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/type/components.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAe,MAAM,gBAAgB,CAAC;AACtD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QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAC/E,CAAC"}
|
package/dist/type/context.d.ts
CHANGED
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
* `propPath` drive deterministic names for those synthesised types
|
|
9
9
|
* (e.g. `Owner_Path`).
|
|
10
10
|
*/
|
|
11
|
+
import type { Namespace } from "@ir-kit/codegen-core";
|
|
11
12
|
export interface TypeCtx<D> {
|
|
12
13
|
emit: (d: D) => void;
|
|
14
|
+
/** Owns every top-level type name for one generation run. Component
|
|
15
|
+
* schemas, `$ref`s and synthesized inline types all resolve through
|
|
16
|
+
* it, so a name is spelled the same at every site and never declared
|
|
17
|
+
* twice. */
|
|
18
|
+
names: Namespace;
|
|
13
19
|
/** Used to synthesise names for inline objects/enums: `Owner_Path`. */
|
|
14
20
|
ownerName: string;
|
|
15
21
|
propPath: ReadonlyArray<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/type/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IACrB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACjC"}
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/type/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IACrB;;;iBAGa;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACjC"}
|
package/dist/type/dispatch.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Namespace } from "@ir-kit/codegen-core";
|
|
2
|
+
import { type EnumLiteral, type ObjectProperty, type Schema } from "@ir-kit/schema";
|
|
2
3
|
import type { TypeCtx } from "./context.js";
|
|
3
4
|
/**
|
|
4
5
|
* Per-target leaf operations the shared dispatchers (`schemaToType`,
|
|
@@ -36,8 +37,12 @@ export interface SchemaToTypeOps<T, D> {
|
|
|
36
37
|
* use `"_"`. */
|
|
37
38
|
synthName(ownerName: string, propPath: ReadonlyArray<string>): string;
|
|
38
39
|
buildStructDecl(name: string, properties: ReadonlyArray<ObjectProperty>, ctx: TypeCtx<D>, dispatch: (s: Schema, c: TypeCtx<D>) => T): D;
|
|
39
|
-
emitStringEnum(name: string, raws: ReadonlyArray<string>, emit: (d: D) => void): T;
|
|
40
|
-
emitIntegerEnum(name: string, raws: ReadonlyArray<number>, emit: (d: D) => void): T;
|
|
40
|
+
emitStringEnum(name: string, raws: ReadonlyArray<string>, emit: (d: D) => void, names: Namespace): T;
|
|
41
|
+
emitIntegerEnum(name: string, raws: ReadonlyArray<number>, emit: (d: D) => void, names: Namespace): T;
|
|
42
|
+
/** Unions with 2+ non-null branches. Targets with a native sum type
|
|
43
|
+
* (e.g. protobuf `oneof`) build it here; others fall back to
|
|
44
|
+
* `unionFallback`. */
|
|
45
|
+
multiUnion?(schema: Schema, ctx: TypeCtx<D>, dispatch: (s: Schema, c: TypeCtx<D>) => T): T;
|
|
41
46
|
}
|
|
42
47
|
export declare function unionToType<T, D>(schema: Schema, ctx: TypeCtx<D>, ops: SchemaToTypeOps<T, D>, dispatch: (s: Schema, c: TypeCtx<D>) => T): T;
|
|
43
48
|
export declare function inlineObjectType<T, D>(schema: Schema, ctx: TypeCtx<D>, ops: SchemaToTypeOps<T, D>, dispatch: (s: Schema, c: TypeCtx<D>) => T): T;
|
|
@@ -55,4 +60,18 @@ export declare function inlineObjectType<T, D>(schema: Schema, ctx: TypeCtx<D>,
|
|
|
55
60
|
* 5. compound by `type` (array / object / null)
|
|
56
61
|
*/
|
|
57
62
|
export declare function schemaToType<T, D>(schema: Schema, ctx: TypeCtx<D>, ops: SchemaToTypeOps<T, D>): T;
|
|
63
|
+
/** Type name for the component schema `rawName` (`#/components/schemas/<rawName>`). */
|
|
64
|
+
export declare function schemaTypeName(names: Namespace, rawName: string): string;
|
|
65
|
+
/** Type name for the inline schema at `ctx.ownerName` + `ctx.propPath`. */
|
|
66
|
+
export declare function synthTypeName<T, D>(ctx: TypeCtx<D>, ops: Pick<SchemaToTypeOps<T, D>, "synthName">, path?: ReadonlyArray<string>): string;
|
|
67
|
+
/**
|
|
68
|
+
* Map enum literals onto a target type. String / integer domains emit a
|
|
69
|
+
* named enum (`named: true`); number / boolean domains become the
|
|
70
|
+
* matching primitive and mixed domains the untyped fallback — those
|
|
71
|
+
* leave `name` unused so the caller decides whether to alias it.
|
|
72
|
+
*/
|
|
73
|
+
export declare function enumType<T, D>(name: string, literals: ReadonlyArray<EnumLiteral>, ops: SchemaToTypeOps<T, D>, { emit, names }: Pick<TypeCtx<D>, "emit" | "names">): {
|
|
74
|
+
type: T;
|
|
75
|
+
named: boolean;
|
|
76
|
+
};
|
|
58
77
|
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/type/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/type/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,S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H;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAChC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EACf,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,EAC7C,IAAI,GAAE,aAAa,CAAC,MAAM,CAAgB,GACzC,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAC3B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,EACpC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAClD;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAyB7B"}
|
package/dist/type/dispatch.js
CHANGED
|
@@ -9,14 +9,16 @@ export function unionToType(schema, ctx, ops, dispatch) {
|
|
|
9
9
|
case "single":
|
|
10
10
|
return ops.wrapForUnionSingle(dispatch(shape.inner, ctx), shape.nullable);
|
|
11
11
|
case "multi":
|
|
12
|
-
return ops.
|
|
12
|
+
return ops.multiUnion
|
|
13
|
+
? ops.multiUnion(schema, ctx, dispatch)
|
|
14
|
+
: ops.unionFallback(shape.nullable);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
export function inlineObjectType(schema, ctx, ops, dispatch) {
|
|
16
18
|
const shape = classifyObject(schema);
|
|
17
19
|
switch (shape.kind) {
|
|
18
20
|
case "named-struct": {
|
|
19
|
-
const name =
|
|
21
|
+
const name = synthTypeName(ctx, ops);
|
|
20
22
|
const properties = Array.from(iterateObjectProperties(schema));
|
|
21
23
|
ctx.emit(ops.buildStructDecl(name, properties, ctx, dispatch));
|
|
22
24
|
return ops.refType(name);
|
|
@@ -43,17 +45,15 @@ export function inlineObjectType(schema, ctx, ops, dispatch) {
|
|
|
43
45
|
export function schemaToType(schema, ctx, ops) {
|
|
44
46
|
const dispatch = (s, c) => schemaToType(s, c, ops);
|
|
45
47
|
if (schema.$ref)
|
|
46
|
-
return ops.refType(refName(schema.$ref));
|
|
48
|
+
return ops.refType(schemaTypeName(ctx.names, refName(schema.$ref)));
|
|
47
49
|
const enumValues = extractEnumValues(schema);
|
|
48
50
|
if (enumValues && enumValues.length > 0) {
|
|
49
|
-
const
|
|
50
|
-
const filtered = enumValues.filter((v) => typeof v === "string" ||
|
|
51
|
+
const literals = enumValues.filter((v) => typeof v === "string" ||
|
|
51
52
|
typeof v === "number" ||
|
|
52
53
|
typeof v === "boolean");
|
|
53
|
-
const kind = classifyEnumLiterals(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return ops.emitStringEnum(name, filtered, ctx.emit);
|
|
54
|
+
const kind = classifyEnumLiterals(literals);
|
|
55
|
+
const name = kind === "string" || kind === "integer" ? synthTypeName(ctx, ops) : "";
|
|
56
|
+
return enumType(name, literals, ops, ctx).type;
|
|
57
57
|
}
|
|
58
58
|
if (isUnionShape(schema))
|
|
59
59
|
return unionToType(schema, ctx, ops, dispatch);
|
|
@@ -76,4 +76,44 @@ export function schemaToType(schema, ctx, ops) {
|
|
|
76
76
|
return ops.anyType();
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
/** Type name for the component schema `rawName` (`#/components/schemas/<rawName>`). */
|
|
80
|
+
export function schemaTypeName(names, rawName) {
|
|
81
|
+
return names.claim(`schema:${rawName}`, rawName);
|
|
82
|
+
}
|
|
83
|
+
/** Type name for the inline schema at `ctx.ownerName` + `ctx.propPath`. */
|
|
84
|
+
export function synthTypeName(ctx, ops, path = ctx.propPath) {
|
|
85
|
+
return ctx.names.claim(`synth:${ctx.ownerName}/${path.join("/")}`, ops.synthName(ctx.ownerName, path));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Map enum literals onto a target type. String / integer domains emit a
|
|
89
|
+
* named enum (`named: true`); number / boolean domains become the
|
|
90
|
+
* matching primitive and mixed domains the untyped fallback — those
|
|
91
|
+
* leave `name` unused so the caller decides whether to alias it.
|
|
92
|
+
*/
|
|
93
|
+
export function enumType(name, literals, ops, { emit, names }) {
|
|
94
|
+
switch (classifyEnumLiterals(literals)) {
|
|
95
|
+
case "string":
|
|
96
|
+
return {
|
|
97
|
+
type: ops.emitStringEnum(name, literals, emit, names),
|
|
98
|
+
named: true,
|
|
99
|
+
};
|
|
100
|
+
case "integer":
|
|
101
|
+
return {
|
|
102
|
+
type: ops.emitIntegerEnum(name, literals, emit, names),
|
|
103
|
+
named: true,
|
|
104
|
+
};
|
|
105
|
+
case "number":
|
|
106
|
+
return {
|
|
107
|
+
type: ops.primitiveType({ type: "number" }) ?? ops.anyType(),
|
|
108
|
+
named: false,
|
|
109
|
+
};
|
|
110
|
+
case "boolean":
|
|
111
|
+
return {
|
|
112
|
+
type: ops.primitiveType({ type: "boolean" }) ?? ops.anyType(),
|
|
113
|
+
named: false,
|
|
114
|
+
};
|
|
115
|
+
case "mixed":
|
|
116
|
+
return { type: ops.anyType(), named: false };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
79
119
|
//# sourceMappingURL=dispatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/type/dispatch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/type/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,aAAa,EAEb,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,uBAAuB,EAEvB,OAAO,GAER,MAAM,gBAAgB,CAAC;AAmEx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|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"codegen",
|
|
9
9
|
"sdk"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://github.com/
|
|
11
|
+
"homepage": "https://github.com/ahmedrowaihi/ir-kit/tree/main/packages/openapi/ir",
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/
|
|
13
|
+
"url": "https://github.com/ahmedrowaihi/ir-kit/issues"
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/
|
|
22
|
+
"url": "git+https://github.com/ahmedrowaihi/ir-kit.git",
|
|
23
23
|
"directory": "packages/openapi/ir"
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@hey-api/shared": ">=0.3.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@hey-api/shared": "^0.
|
|
49
|
+
"@hey-api/shared": "^0.5.0",
|
|
50
50
|
"@types/node": "^22",
|
|
51
51
|
"vitest": "^4.0.0",
|
|
52
52
|
"@ir-kit/tsconfig": "0.0.0"
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"node": ">=20.19.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@ir-kit/
|
|
59
|
-
"@ir-kit/
|
|
58
|
+
"@ir-kit/schema": "0.3.1",
|
|
59
|
+
"@ir-kit/codegen-core": "0.3.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsc -p tsconfig.build.json",
|