@ir-kit/openapi-tools 0.2.0 → 0.3.1
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 +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- 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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
OpenAPI utilities built on top of [`@hey-api/codegen-core`](https://github.com/hey-api/openapi-ts) and `@hey-api/shared`. Spec diffing, parsing, and helpers — usable on their own without `@hey-api/openapi-ts` plugins.
|
|
4
4
|
|
|
5
|
-
Part of [ir-kit](https://github.com/
|
|
5
|
+
Part of [ir-kit](https://github.com/ahmedrowaihi/ir-kit).
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ir-kit/openapi-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"tooling",
|
|
13
13
|
"typescript"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.com/
|
|
15
|
+
"homepage": "https://github.com/ahmedrowaihi/ir-kit/tree/main/packages/openapi/tools",
|
|
16
16
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "https://github.com/ahmedrowaihi/ir-kit/issues"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"author": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/
|
|
26
|
+
"url": "git+https://github.com/ahmedrowaihi/ir-kit.git",
|
|
27
27
|
"directory": "packages/openapi/tools"
|
|
28
28
|
},
|
|
29
29
|
"type": "module",
|
|
@@ -80,10 +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.
|
|
86
|
-
"@ir-kit/schema": "0.
|
|
84
|
+
"@ir-kit/openapi": "0.4.0",
|
|
85
|
+
"@ir-kit/schema": "0.3.0"
|
|
87
86
|
},
|
|
88
87
|
"devDependencies": {
|
|
89
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,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAEL,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC;AAgBzB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,IAAqB;IAErB,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IAChC,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC;QACnC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC;KAC1D,CAAC,CAA4B,CAAC;IAE/B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,aAAa,CACX,OAAO,EACP,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAC1D,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAgB,EAChB,MAAc,OAAO,CAAC,GAAG,EAAE;IAE3B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAClD,IAAI,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IACxC,OAAO,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|