@elastic/request-converter-cli 0.1.0 → 0.2.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/convert.d.ts +9 -0
- package/dist/convert.js +14 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/convert.d.ts
CHANGED
|
@@ -6,4 +6,13 @@ export interface ParsedRequest {
|
|
|
6
6
|
params?: Record<string, unknown>;
|
|
7
7
|
body?: unknown;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The schema has no command for this API, so no CLI sample can exist.
|
|
11
|
+
* Callers tell this apart from a request that failed to convert by `code`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class UnsupportedEndpointError extends Error {
|
|
14
|
+
readonly api: string;
|
|
15
|
+
readonly code = "unsupported_endpoint";
|
|
16
|
+
constructor(api: string);
|
|
17
|
+
}
|
|
9
18
|
export declare function convert(request: ParsedRequest): string;
|
package/dist/convert.js
CHANGED
|
@@ -18,6 +18,19 @@ const SERVERLESS_NAMESPACES = new Set([
|
|
|
18
18
|
'traffic-filters',
|
|
19
19
|
'capabilities',
|
|
20
20
|
]);
|
|
21
|
+
/**
|
|
22
|
+
* The schema has no command for this API, so no CLI sample can exist.
|
|
23
|
+
* Callers tell this apart from a request that failed to convert by `code`.
|
|
24
|
+
*/
|
|
25
|
+
export class UnsupportedEndpointError extends Error {
|
|
26
|
+
api;
|
|
27
|
+
code = 'unsupported_endpoint';
|
|
28
|
+
constructor(api) {
|
|
29
|
+
super(`The CLI does not support the '${api}' endpoint`);
|
|
30
|
+
this.api = api;
|
|
31
|
+
this.name = 'UnsupportedEndpointError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
21
34
|
export function convert(request) {
|
|
22
35
|
const service = request.service ?? 'es';
|
|
23
36
|
if (service !== 'es' && service !== 'serverless') {
|
|
@@ -128,7 +141,7 @@ function loadSchema(api, service) {
|
|
|
128
141
|
catch (err) {
|
|
129
142
|
const code = err.code;
|
|
130
143
|
if (code === 'MODULE_NOT_FOUND' || code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
131
|
-
throw new
|
|
144
|
+
throw new UnsupportedEndpointError(api);
|
|
132
145
|
}
|
|
133
146
|
throw err;
|
|
134
147
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { convert } from './convert.js';
|
|
1
|
+
export { convert, UnsupportedEndpointError } from './convert.js';
|
|
2
2
|
export type { ParsedRequest } from './convert.js';
|
package/dist/index.js
CHANGED