@sonatel-os/openapi-runtime 0.1.1 → 0.2.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 +458 -170
- package/dist/errors.cjs +154 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.esm.js +154 -0
- package/dist/errors.esm.js.map +1 -0
- package/dist/index.cjs +557 -5453
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -74
- package/dist/index.esm.js +560 -5455
- package/dist/index.esm.js.map +1 -1
- package/dist/react/index.cjs +129 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.esm.js +129 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/src/auth/config.d.ts +170 -0
- package/dist/src/auth/index.d.ts +3 -0
- package/dist/src/auth/manager.d.ts +51 -0
- package/dist/src/auth/providers.d.ts +178 -0
- package/dist/src/constants.d.ts +30 -0
- package/dist/src/core/client.d.ts +83 -0
- package/dist/src/core/registry.d.ts +116 -0
- package/dist/src/errors.d.ts +126 -0
- package/dist/src/index.d.ts +230 -0
- package/dist/src/mocking/index.d.ts +1 -0
- package/dist/src/mocking/sampler.d.ts +87 -0
- package/dist/src/react/useOpenAPI.d.ts +127 -3
- package/dist/src/utils.d.ts +103 -0
- package/dist/src/validation/index.d.ts +1 -0
- package/dist/src/validation/validator.d.ts +117 -0
- package/package.json +25 -8
- package/dist/src/auth.d.ts +0 -33
- package/dist/src/client.d.ts +0 -20
- package/dist/src/config.d.ts +0 -10
- package/dist/src/http.d.ts +0 -0
- package/dist/src/registry.d.ts +0 -28
- package/dist/src/sampler.d.ts +0 -2
- package/dist/src/validate.d.ts +0 -17
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonatel-os/openapi-runtime",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Enterprise-grade, zero-codegen OpenAPI runtime. Load specs dynamically, execute APIs with type-safe validation, mock responses, and robust authentication.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sonatel Open Source <opensource@sonatel.com>",
|
|
7
7
|
"homepage": "https://github.com/sonatel-os/openapi-runtime#readme",
|
|
@@ -21,9 +21,12 @@
|
|
|
21
21
|
"fetch",
|
|
22
22
|
"mock",
|
|
23
23
|
"validation",
|
|
24
|
-
"
|
|
24
|
+
"enterprise",
|
|
25
25
|
"zero-codegen",
|
|
26
|
-
"dynamic-client"
|
|
26
|
+
"dynamic-client",
|
|
27
|
+
"api",
|
|
28
|
+
"rest",
|
|
29
|
+
"typescript"
|
|
27
30
|
],
|
|
28
31
|
"type": "module",
|
|
29
32
|
"main": "dist/index.cjs",
|
|
@@ -42,6 +45,16 @@
|
|
|
42
45
|
"require": "./dist/index.cjs",
|
|
43
46
|
"import": "./dist/index.esm.js",
|
|
44
47
|
"types": "./dist/index.d.ts"
|
|
48
|
+
},
|
|
49
|
+
"./react": {
|
|
50
|
+
"require": "./dist/react/index.cjs",
|
|
51
|
+
"import": "./dist/react/index.esm.js",
|
|
52
|
+
"types": "./dist/react/index.d.ts"
|
|
53
|
+
},
|
|
54
|
+
"./errors": {
|
|
55
|
+
"require": "./dist/errors.cjs",
|
|
56
|
+
"import": "./dist/errors.esm.js",
|
|
57
|
+
"types": "./dist/errors.d.ts"
|
|
45
58
|
}
|
|
46
59
|
},
|
|
47
60
|
"sideEffects": false,
|
|
@@ -50,10 +63,14 @@
|
|
|
50
63
|
},
|
|
51
64
|
"scripts": {
|
|
52
65
|
"dev": "node --watch src/index.js",
|
|
53
|
-
"build": "rm -rf dist && vite build &&
|
|
66
|
+
"build": "rm -rf dist && vite build && npm run build:types",
|
|
67
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist",
|
|
54
68
|
"lint": "eslint .",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
69
|
+
"lint:fix": "eslint . --fix",
|
|
70
|
+
"test": "node --test src/**/*.test.js",
|
|
71
|
+
"test:watch": "node --test --watch src/**/*.test.js",
|
|
72
|
+
"prepublishOnly": "npm run build",
|
|
73
|
+
"typecheck": "tsc --noEmit"
|
|
57
74
|
},
|
|
58
75
|
"peerDependencies": {
|
|
59
76
|
"react": ">=18"
|
|
@@ -75,4 +92,4 @@
|
|
|
75
92
|
"openapi-sampler": "^1.5.1",
|
|
76
93
|
"swagger-client": "^3.26.1"
|
|
77
94
|
}
|
|
78
|
-
}
|
|
95
|
+
}
|
package/dist/src/auth.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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): {};
|
package/dist/src/client.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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>;
|
package/dist/src/config.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
package/dist/src/http.d.ts
DELETED
|
File without changes
|
package/dist/src/registry.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/src/sampler.d.ts
DELETED
package/dist/src/validate.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
};
|