@ir-kit/openapi-ts-paths 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.
- package/dist/config.d.ts +13 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +20 -4
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +2 -5
- package/dist/plugin.js.map +1 -1
- package/package.json +16 -11
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import type { PathsPlugin } from "./types";
|
|
1
|
+
import type { PathsPlugin } from "./types.js";
|
|
2
2
|
export declare const defaultConfig: PathsPlugin["Config"];
|
|
3
|
-
export declare const defineConfig: (userConfig?: Omit<import("./types").UserConfig, "name"> | undefined) =>
|
|
3
|
+
export declare const defineConfig: (userConfig?: Omit<import("./types.js").UserConfig, "name"> | undefined) => {
|
|
4
|
+
config: import("@hey-api/shared").ConfigTable<Omit<import("./types.js").UserConfig, "name">, import("./types.js").Config>;
|
|
5
|
+
dependencies: readonly import("@hey-api/shared").AnyPluginName[] | undefined;
|
|
4
6
|
name: any;
|
|
7
|
+
api?: {
|
|
8
|
+
[x: string]: unknown;
|
|
9
|
+
} | undefined;
|
|
10
|
+
handler: (args: {
|
|
11
|
+
plugin: import("@hey-api/shared").PluginInstance<import("@hey-api/shared").Plugin.Types<import("./types.js").UserConfig, import("./types.js").Config, never, Record<never, never>>>;
|
|
12
|
+
}) => void;
|
|
13
|
+
imports?: ((plugin: import("@hey-api/shared").PluginInstance<import("@hey-api/shared").Plugin.Types<import("./types.js").UserConfig, import("./types.js").Config, never, Record<never, never>>>) => Record<never, never>) | undefined;
|
|
14
|
+
symbolMeta?: (symbol: Omit<log, "name">) => log;
|
|
15
|
+
tags?: ReadonlyArray<import("@hey-api/shared").PluginTag>;
|
|
5
16
|
};
|
|
6
17
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAkB9C,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,QAAQ,CAY/C,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;+BAAwB,GAAG,cAC5C,GAAI;;CAD2C,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { coerce } from "@hey-api/shared";
|
|
2
|
+
import { definePlugin } from "@ir-kit/openapi-ts-plugin-kit";
|
|
3
|
+
import { handler } from "./plugin.js";
|
|
4
|
+
const CASINGS = new Set([
|
|
5
|
+
"camelCase",
|
|
6
|
+
"PascalCase",
|
|
7
|
+
"preserve",
|
|
8
|
+
"snake_case",
|
|
9
|
+
"SCREAMING_SNAKE_CASE",
|
|
10
|
+
]);
|
|
11
|
+
const resolveCasing = (rule) => {
|
|
12
|
+
if (typeof rule === "string" && CASINGS.has(rule))
|
|
13
|
+
return rule;
|
|
14
|
+
if (rule && typeof rule === "object") {
|
|
15
|
+
return rule.casing ?? rule.case ?? "camelCase";
|
|
16
|
+
}
|
|
17
|
+
return "camelCase";
|
|
18
|
+
};
|
|
3
19
|
export const defaultConfig = {
|
|
4
20
|
config: {
|
|
5
21
|
output: "paths",
|
|
6
22
|
naming: {
|
|
7
|
-
casing:
|
|
23
|
+
casing: coerce(resolveCasing),
|
|
8
24
|
suffix: "Route",
|
|
9
25
|
},
|
|
10
26
|
},
|
|
@@ -13,5 +29,5 @@ export const defaultConfig = {
|
|
|
13
29
|
name: "@ir-kit/paths",
|
|
14
30
|
tags: ["transformer"],
|
|
15
31
|
};
|
|
16
|
-
export const defineConfig =
|
|
32
|
+
export const defineConfig = definePlugin(defaultConfig);
|
|
17
33
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAmB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAS;IACnD,WAAW;IACX,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,sBAAsB;CACvB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,IAAqC,EAAU,EAAE;IACtE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAc,CAAC;IACzE,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,WAAW,CAAC;IACjD,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA0B;IAClD,MAAM,EAAE;QACN,MAAM,EAAE,OAAO;QACf,MAAM,EAAE;YACN,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;YAC7B,MAAM,EAAE,OAAO;SAChB;KACF;IACD,YAAY,EAAE,CAAC,qBAAqB,CAAC;IACrC,OAAO;IACP,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,CAAC,aAAa,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./types";
|
|
2
|
-
export { defaultConfig, defineConfig } from "./config";
|
|
3
|
-
export type { PathsPlugin } from "./types";
|
|
1
|
+
import "./types.js";
|
|
2
|
+
export { defaultConfig, defineConfig } from "./config.js";
|
|
3
|
+
export type { PathsPlugin } from "./types.js";
|
|
4
4
|
//# 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,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./types";
|
|
2
|
-
export { defaultConfig, defineConfig } from "./config";
|
|
1
|
+
import "./types.js";
|
|
2
|
+
export { defaultConfig, defineConfig } from "./config.js";
|
|
3
3
|
//# 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":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C,eAAO,MAAM,OAAO,EAAE,WAAW,CAAC,SAAS,CAoB1C,CAAC"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { $ } from "@hey-api/openapi-ts";
|
|
2
|
-
import {
|
|
2
|
+
import { identifierName } from "@ir-kit/openapi-ts-plugin-kit";
|
|
3
3
|
/** `/users/{id}/posts/{postId}` → `/users/:id/posts/:postId` */
|
|
4
4
|
function specToPattern(spec) {
|
|
5
5
|
return spec.replace(/\{([^}]+)\}/g, ":$1");
|
|
6
6
|
}
|
|
7
|
-
function sanitize(name) {
|
|
8
|
-
return name.replace(/[^\w]/g, "");
|
|
9
|
-
}
|
|
10
7
|
export const handler = ({ plugin }) => {
|
|
11
8
|
const { casing, suffix } = plugin.config.naming;
|
|
12
9
|
plugin.forEach("operation", ({ operation }) => {
|
|
13
10
|
if (!operation.path || !operation.id)
|
|
14
11
|
return;
|
|
15
|
-
const baseName =
|
|
12
|
+
const baseName = identifierName(operation.id, { casing });
|
|
16
13
|
const symbolName = `${baseName}${suffix}`;
|
|
17
14
|
const symbol = plugin.symbol(symbolName);
|
|
18
15
|
let routeObj = $.object()
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file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,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ir-kit/openapi-ts-paths",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Plugin for @hey-api/openapi-ts — emit per-operation route consts (spec template, URLPattern, method, operationId) for tree-shakable runtime routing and matching",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"type-safe",
|
|
15
15
|
"plugin"
|
|
16
16
|
],
|
|
17
|
-
"homepage": "https://github.com/
|
|
17
|
+
"homepage": "https://github.com/ahmedrowaihi/ir-kit/tree/main/packages/openapi/plugins/paths",
|
|
18
18
|
"bugs": {
|
|
19
|
-
"url": "https://github.com/
|
|
19
|
+
"url": "https://github.com/ahmedrowaihi/ir-kit/issues"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/
|
|
28
|
+
"url": "git+https://github.com/ahmedrowaihi/ir-kit.git",
|
|
29
29
|
"directory": "packages/openapi/plugins/paths"
|
|
30
30
|
},
|
|
31
31
|
"type": "module",
|
|
@@ -48,16 +48,20 @@
|
|
|
48
48
|
"access": "public",
|
|
49
49
|
"provenance": true
|
|
50
50
|
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@ir-kit/openapi-ts-plugin-kit": "^0.2.0"
|
|
53
|
+
},
|
|
51
54
|
"peerDependencies": {
|
|
52
|
-
"@hey-api/codegen-core": "
|
|
53
|
-
"@hey-api/openapi-ts": "
|
|
54
|
-
"@hey-api/shared": "
|
|
55
|
+
"@hey-api/codegen-core": "0.0.0-next-20260930190945",
|
|
56
|
+
"@hey-api/openapi-ts": "0.0.0-next-20260930190945",
|
|
57
|
+
"@hey-api/shared": "0.0.0-next-20260930190945"
|
|
55
58
|
},
|
|
56
59
|
"devDependencies": {
|
|
57
|
-
"@hey-api/codegen-core": "
|
|
58
|
-
"@hey-api/openapi-ts": "
|
|
59
|
-
"@hey-api/shared": "
|
|
60
|
+
"@hey-api/codegen-core": "0.0.0-next-20260930190945",
|
|
61
|
+
"@hey-api/openapi-ts": "0.0.0-next-20260930190945",
|
|
62
|
+
"@hey-api/shared": "0.0.0-next-20260930190945",
|
|
60
63
|
"@types/node": "^22",
|
|
64
|
+
"vitest": "^4.0.0",
|
|
61
65
|
"@ir-kit/tsconfig": "0.0.0"
|
|
62
66
|
},
|
|
63
67
|
"engines": {
|
|
@@ -66,6 +70,7 @@
|
|
|
66
70
|
"scripts": {
|
|
67
71
|
"build": "tsc",
|
|
68
72
|
"dev": "tsc --watch",
|
|
69
|
-
"typecheck": "tsc --noEmit"
|
|
73
|
+
"typecheck": "tsc --noEmit",
|
|
74
|
+
"test": "vitest run"
|
|
70
75
|
}
|
|
71
76
|
}
|