@sonatel-os/openapi-runtime 0.1.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.
@@ -0,0 +1,33 @@
1
+ export function setAuth(name: any, providers: any): void;
2
+ export function applyAuth(entry: any, operationId: any, req: any): Promise<void>;
3
+ export function apiKey({ in: placement, name, getValue }: {
4
+ in: any;
5
+ name: any;
6
+ getValue: any;
7
+ }): {
8
+ apply(_entry: any, _schemeName: any, _scopes: any, req: any): Promise<void>;
9
+ };
10
+ export function basic({ username, password, getCredentials }: {
11
+ username: any;
12
+ password: any;
13
+ getCredentials: any;
14
+ }): {
15
+ apply(_entry: any, _schemeName: any, _scopes: any, req: any): Promise<void>;
16
+ };
17
+ export function bearer({ token, getToken }: {
18
+ token: any;
19
+ getToken: any;
20
+ }): {
21
+ apply(_entry: any, _schemeName: any, _scopes: any, req: any): Promise<void>;
22
+ };
23
+ export function clientCredentials({ tokenUrl, clientId, clientSecret, scope, audience, extraParams }: {
24
+ tokenUrl: any;
25
+ clientId: any;
26
+ clientSecret: any;
27
+ scope: any;
28
+ audience: any;
29
+ extraParams: any;
30
+ }): {
31
+ apply(_entry: any, _schemeName: any, reqScopes: any, req: any): Promise<void>;
32
+ };
33
+ export function providersFromConfig(_name: any, _spec: any, cfg: any): {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @param {{ name: string, spec: string|object }} opts
3
+ * @returns {Promise<import('./registry.js').SpecEntry>}
4
+ */
5
+ export function buildClient({ name, spec }: {
6
+ name: string;
7
+ spec: string | object;
8
+ }): Promise<import("./registry.js").SpecEntry>;
9
+ /**
10
+ * Execute with merged headers, auth, and simple interceptors.
11
+ * @param {import('./registry.js').SpecEntry} entry
12
+ * @param {{ operationId: string, parameters?: object, requestBody?: any, headers?: object, qs?: object }} req
13
+ */
14
+ export function executeByOperationId(entry: import("./registry.js").SpecEntry, req: {
15
+ operationId: string;
16
+ parameters?: object;
17
+ requestBody?: any;
18
+ headers?: object;
19
+ qs?: object;
20
+ }): Promise<any>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Load auth config from YAML if available.
3
+ * Path: process.env.OPENAPI_RUNTIME_AUTH_CONFIG || "./openapi.auth.yml"
4
+ * Returns a plain object or null.
5
+ */
6
+ export function loadAuthConfig(): any;
7
+ /**
8
+ * Read an env var safely (supports default via "ENV|default").
9
+ */
10
+ export function getEnv(keyOrExpr: any): any;
File without changes
@@ -0,0 +1,6 @@
1
+ /**
2
+ * React helper to bind a spec name.
3
+ * @param {string} name
4
+ */
5
+ export function useOpenAPI(name: string): any;
6
+ export default useOpenAPI;
@@ -0,0 +1,28 @@
1
+ export function getRegistry(): Map<any, any>;
2
+ export function ensureEntry(name: any): any;
3
+ export function indexOperations(spec: any): {
4
+ opsById: Map<string, object>;
5
+ operations: OperationInfo[];
6
+ };
7
+ export type OperationInfo = {
8
+ operationId: string;
9
+ method: string;
10
+ path: string;
11
+ summary?: string | undefined;
12
+ tags?: string[] | undefined;
13
+ };
14
+ export type SpecEntry = {
15
+ name: string;
16
+ client: any;
17
+ spec: object;
18
+ opsById: Map<string, object>;
19
+ operations: OperationInfo[];
20
+ defaults: {
21
+ headers?: Record<string, string>;
22
+ };
23
+ interceptors: {
24
+ request?: Function;
25
+ response?: Function;
26
+ error?: Function;
27
+ };
28
+ };
@@ -0,0 +1,2 @@
1
+ export function responseSampleFor(entry: any, api: any, status: any): unknown;
2
+ export function requestSampleFor(entry: any, api: any): unknown;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Build a validator for a given operation's response.
3
+ * @param {import('./registry.js').SpecEntry} entry
4
+ * @param {{ api: string, status: string, contentType: string, data: any }} opts
5
+ */
6
+ export function validateResponseFor(entry: import("./registry.js").SpecEntry, { api, status, contentType, data }: {
7
+ api: string;
8
+ status: string;
9
+ contentType: string;
10
+ data: any;
11
+ }): {
12
+ valid: boolean;
13
+ errors?: undefined;
14
+ } | {
15
+ valid: boolean;
16
+ errors: import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
17
+ };
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@sonatel-os/openapi-runtime",
3
+ "version": "0.1.0",
4
+ "description": "The dynamic, zero-codegen OpenAPI SDK. Load specs at runtime, mock responses, validate payloads, and execute requests without generating a single file.",
5
+ "license": "MIT",
6
+ "author": "Sonatel Open Source <opensource@sonatel.com>",
7
+ "homepage": "https://github.com/sonatel-os/openapi-runtime#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/sonatel-os/openapi-runtime.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/sonatel-os/openapi-runtime/issues"
14
+ },
15
+ "keywords": [
16
+ "openapi",
17
+ "swagger",
18
+ "runtime",
19
+ "client",
20
+ "sdk",
21
+ "fetch",
22
+ "mock",
23
+ "validation",
24
+ "sonatel",
25
+ "zero-codegen",
26
+ "dynamic-client"
27
+ ],
28
+ "type": "module",
29
+ "main": "dist/index.cjs",
30
+ "module": "dist/index.esm.js",
31
+ "types": "dist/index.d.ts",
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "registry": "https://registry.npmjs.org/"
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "README.md"
39
+ ],
40
+ "exports": {
41
+ ".": {
42
+ "require": "./dist/index.cjs",
43
+ "import": "./dist/index.esm.js",
44
+ "types": "./dist/index.d.ts"
45
+ }
46
+ },
47
+ "sideEffects": false,
48
+ "engines": {
49
+ "node": ">=18.0.0"
50
+ },
51
+ "scripts": {
52
+ "dev": "node --watch src/index.js",
53
+ "build": "rm -rf dist && vite build && npx tsc --emitDeclarationOnly --declaration --declarationDir dist",
54
+ "lint": "eslint .",
55
+ "test": "node --test",
56
+ "prepublishOnly": "npm run build"
57
+ },
58
+ "peerDependencies": {
59
+ "react": ">=18"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "react": {
63
+ "optional": true
64
+ }
65
+ },
66
+ "devDependencies": {
67
+ "typescript": "^5.5.4",
68
+ "vite": "^5.4.3"
69
+ },
70
+ "dependencies": {
71
+ "ajv": "^8.17.1",
72
+ "ajv-formats": "^3.0.1",
73
+ "cross-fetch": "^4.0.0",
74
+ "js-yaml": "^4.1.0",
75
+ "openapi-sampler": "^1.5.1",
76
+ "swagger-client": "^3.26.1"
77
+ }
78
+ }