@ir-kit/openapi-tools 0.1.1 → 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.
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +4 -5
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +6 -8
- package/dist/schema.js.map +1 -1
- package/package.json +3 -3
- package/dist/load.d.ts +0 -27
- package/dist/load.d.ts.map +0 -1
- package/dist/load.js +0 -38
- package/dist/load.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { type DiffOptions, type DiffReport, diffSpecs, type EndpointDiff, type RequiredChange, type ShapeDiff, type TypeChange, } from "./diff.js";
|
|
2
2
|
export { routesFromIR } from "./ir.js";
|
|
3
|
-
export { type LoadSpecOptions, loadSpec, resolveSpecInput, type SpecInput, } from "./load.js";
|
|
4
3
|
export { type ExtractParams, isInSpec, type MatchResult, match, } from "./match.js";
|
|
5
4
|
export type { IR } from "./parse.js";
|
|
6
5
|
export { parseSpec } from "./parse.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,KAAK,aAAa,EAClB,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,KAAK,WAAW,EAChB,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { diffSpecs, } from "./diff.js";
|
|
2
2
|
export { routesFromIR } from "./ir.js";
|
|
3
|
-
export { loadSpec, resolveSpecInput, } from "./load.js";
|
|
4
3
|
export { isInSpec, match, } from "./match.js";
|
|
5
4
|
export { parseSpec } from "./parse.js";
|
|
6
5
|
export { createRouter } from "./router.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,GAKV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAEL,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,GAKV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAEL,QAAQ,EAER,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AACxD,OAAO,EAEL,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,aAAa,CAAC"}
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Schema } from "@ir-kit/schema";
|
|
2
2
|
export type EnumLiteral = string | number | boolean;
|
|
3
|
-
export declare function getEnumLiterals(schema:
|
|
4
|
-
export declare function isEnumSchema(schema:
|
|
5
|
-
|
|
6
|
-
export declare function isUnionSchema(schema: IR.SchemaObject): boolean;
|
|
3
|
+
export declare function getEnumLiterals(schema: Schema): EnumLiteral[];
|
|
4
|
+
export declare function isEnumSchema(schema: Schema): boolean;
|
|
5
|
+
export declare function isUnionSchema(schema: Schema): boolean;
|
|
7
6
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAM7D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
package/dist/schema.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
import { extractEnumValues, isUnionShape } from "@ir-kit/schema";
|
|
1
2
|
export function getEnumLiterals(schema) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
.filter((v) => typeof v === "string" ||
|
|
5
|
-
typeof v === "number" ||
|
|
6
|
-
typeof v === "boolean");
|
|
3
|
+
const raw = extractEnumValues(schema) ?? [];
|
|
4
|
+
return raw.filter((v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean");
|
|
7
5
|
}
|
|
8
6
|
export function isEnumSchema(schema) {
|
|
9
|
-
|
|
7
|
+
const values = extractEnumValues(schema);
|
|
8
|
+
return Boolean(values && values.length > 0);
|
|
10
9
|
}
|
|
11
|
-
/** anyOf / oneOf / allOf — items present, concrete type absent. */
|
|
12
10
|
export function isUnionSchema(schema) {
|
|
13
|
-
return
|
|
11
|
+
return isUnionShape(schema);
|
|
14
12
|
}
|
|
15
13
|
//# sourceMappingURL=schema.js.map
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAI9E,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,MAAM,GAAG,GAAG,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5C,OAAO,GAAG,CAAC,MAAM,CACf,CAAC,CAAC,EAAoB,EAAE,CACtB,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS,CAC3E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ir-kit/openapi-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "OpenAPI utilities — request matching, spec diffing, parsing. Tree-shakable, pure functions, works on frontend or backend",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
"@hey-api/spec-types": ">=0.2.0"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@hey-api/json-schema-ref-parser": "^1.4.1",
|
|
84
83
|
"urlpattern-polyfill": "^10.1.0",
|
|
85
|
-
"@ir-kit/openapi": "0.
|
|
84
|
+
"@ir-kit/openapi": "0.3.0",
|
|
85
|
+
"@ir-kit/schema": "0.2.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@hey-api/codegen-core": "^0.8.1",
|
package/dist/load.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type NormalizeOptions } from "@ir-kit/openapi";
|
|
2
|
-
export type SpecInput = string | Record<string, unknown>;
|
|
3
|
-
export interface LoadSpecOptions {
|
|
4
|
-
/** File path, URL, or pre-parsed spec object. */
|
|
5
|
-
input: SpecInput;
|
|
6
|
-
/** Working directory used to resolve relative paths. Default: `process.cwd()`. */
|
|
7
|
-
cwd?: string;
|
|
8
|
-
/**
|
|
9
|
-
* Apply normalization after bundling. `true` enables the safe preset
|
|
10
|
-
* shared by every generator; pass an object for custom rules.
|
|
11
|
-
*/
|
|
12
|
-
normalize?: boolean | NormalizeOptions;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Single-source loader for every generator in the workspace.
|
|
16
|
-
* Path-vs-URL detection, `$RefParser.bundle()`, and the optional
|
|
17
|
-
* normalize step all happen here so individual generators stay focused
|
|
18
|
-
* on IR → target conversion.
|
|
19
|
-
*/
|
|
20
|
-
export declare function loadSpec(opts: LoadSpecOptions): Promise<Record<string, unknown>>;
|
|
21
|
-
/**
|
|
22
|
-
* Normalize a spec input string: URLs pass through verbatim, absolute
|
|
23
|
-
* paths pass through, relative paths resolve against `cwd`. Pre-parsed
|
|
24
|
-
* objects are returned as-is.
|
|
25
|
-
*/
|
|
26
|
-
export declare function resolveSpecInput(input: SpecInput, cwd?: string): SpecInput;
|
|
27
|
-
//# sourceMappingURL=load.d.ts.map
|
package/dist/load.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,KAAK,EAAE,SAAS,CAAC;IACjB,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;CACxC;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAclC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,EAChB,GAAG,GAAE,MAAsB,GAC1B,SAAS,CASX"}
|
package/dist/load.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, resolve } from "node:path";
|
|
2
|
-
import { $RefParser } from "@hey-api/json-schema-ref-parser";
|
|
3
|
-
import { normalizeSpec, SAFE_NORMALIZE, } from "@ir-kit/openapi";
|
|
4
|
-
/**
|
|
5
|
-
* Single-source loader for every generator in the workspace.
|
|
6
|
-
* Path-vs-URL detection, `$RefParser.bundle()`, and the optional
|
|
7
|
-
* normalize step all happen here so individual generators stay focused
|
|
8
|
-
* on IR → target conversion.
|
|
9
|
-
*/
|
|
10
|
-
export async function loadSpec(opts) {
|
|
11
|
-
const parser = new $RefParser();
|
|
12
|
-
const bundled = (await parser.bundle({
|
|
13
|
-
pathOrUrlOrSchema: resolveSpecInput(opts.input, opts.cwd),
|
|
14
|
-
}));
|
|
15
|
-
if (opts.normalize) {
|
|
16
|
-
normalizeSpec(bundled, opts.normalize === true ? SAFE_NORMALIZE : opts.normalize);
|
|
17
|
-
}
|
|
18
|
-
return bundled;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Normalize a spec input string: URLs pass through verbatim, absolute
|
|
22
|
-
* paths pass through, relative paths resolve against `cwd`. Pre-parsed
|
|
23
|
-
* objects are returned as-is.
|
|
24
|
-
*/
|
|
25
|
-
export function resolveSpecInput(input, cwd = process.cwd()) {
|
|
26
|
-
if (typeof input !== "string")
|
|
27
|
-
return input;
|
|
28
|
-
const trimmed = input.trim();
|
|
29
|
-
if (trimmed === "") {
|
|
30
|
-
throw new Error("OpenAPI spec input is empty or only whitespace.");
|
|
31
|
-
}
|
|
32
|
-
if (/^https?:\/\//i.test(trimmed))
|
|
33
|
-
return trimmed;
|
|
34
|
-
if (isAbsolute(trimmed))
|
|
35
|
-
return trimmed;
|
|
36
|
-
return resolve(cwd, trimmed);
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=load.js.map
|
package/dist/load.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE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