@robosystems/client 0.1.10 → 0.1.12
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/client/client.gen.d.ts +2 -0
- package/client/client.gen.js +153 -0
- package/client/index.d.ts +7 -0
- package/client/index.js +15 -0
- package/client/types.gen.d.ts +122 -0
- package/client/types.gen.js +4 -0
- package/client/utils.gen.d.ts +45 -0
- package/client/utils.gen.js +296 -0
- package/client.gen.d.ts +12 -0
- package/client.gen.js +8 -0
- package/core/auth.gen.d.ts +18 -0
- package/core/auth.gen.js +18 -0
- package/core/bodySerializer.gen.d.ts +17 -0
- package/core/bodySerializer.gen.js +57 -0
- package/core/params.gen.d.ts +33 -0
- package/core/params.gen.js +92 -0
- package/core/pathSerializer.gen.d.ts +33 -0
- package/core/pathSerializer.gen.js +123 -0
- package/core/types.gen.d.ts +78 -0
- package/core/types.gen.js +4 -0
- package/extensions/OperationClient.d.js +45 -0
- package/extensions/OperationClient.d.ts +64 -0
- package/extensions/OperationClient.js +297 -0
- package/extensions/OperationClient.ts +322 -0
- package/extensions/QueryClient.d.js +22 -0
- package/extensions/QueryClient.d.ts +50 -0
- package/extensions/QueryClient.js +245 -0
- package/extensions/QueryClient.ts +283 -0
- package/extensions/SSEClient.d.js +35 -0
- package/extensions/SSEClient.d.ts +48 -0
- package/extensions/SSEClient.js +166 -0
- package/extensions/SSEClient.ts +189 -0
- package/extensions/config.d.js +25 -0
- package/extensions/config.d.ts +32 -0
- package/extensions/config.js +66 -0
- package/extensions/config.ts +91 -0
- package/extensions/hooks.d.js +80 -0
- package/extensions/hooks.d.ts +110 -0
- package/extensions/hooks.js +435 -0
- package/extensions/hooks.ts +438 -0
- package/extensions/index.d.js +35 -0
- package/extensions/index.d.ts +46 -0
- package/extensions/index.js +118 -0
- package/extensions/index.ts +123 -0
- package/package.json +3 -2
- package/prepare.js +10 -0
- package/sdk.gen.d.ts +1145 -0
- package/sdk.gen.js +2436 -0
- package/types.gen.d.ts +5712 -0
- package/types.gen.js +3 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type AuthToken = string | undefined;
|
|
2
|
+
export interface Auth {
|
|
3
|
+
/**
|
|
4
|
+
* Which part of the request do we use to send the auth?
|
|
5
|
+
*
|
|
6
|
+
* @default 'header'
|
|
7
|
+
*/
|
|
8
|
+
in?: 'header' | 'query' | 'cookie';
|
|
9
|
+
/**
|
|
10
|
+
* Header or query parameter name.
|
|
11
|
+
*
|
|
12
|
+
* @default 'Authorization'
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
scheme?: 'basic' | 'bearer';
|
|
16
|
+
type: 'apiKey' | 'http';
|
|
17
|
+
}
|
|
18
|
+
export declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
|
package/core/auth.gen.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getAuthToken = void 0;
|
|
5
|
+
const getAuthToken = async (auth, callback) => {
|
|
6
|
+
const token = typeof callback === 'function' ? await callback(auth) : callback;
|
|
7
|
+
if (!token) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (auth.scheme === 'bearer') {
|
|
11
|
+
return `Bearer ${token}`;
|
|
12
|
+
}
|
|
13
|
+
if (auth.scheme === 'basic') {
|
|
14
|
+
return `Basic ${btoa(token)}`;
|
|
15
|
+
}
|
|
16
|
+
return token;
|
|
17
|
+
};
|
|
18
|
+
exports.getAuthToken = getAuthToken;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen';
|
|
2
|
+
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
3
|
+
export type BodySerializer = (body: any) => any;
|
|
4
|
+
export interface QuerySerializerOptions {
|
|
5
|
+
allowReserved?: boolean;
|
|
6
|
+
array?: SerializerOptions<ArrayStyle>;
|
|
7
|
+
object?: SerializerOptions<ObjectStyle>;
|
|
8
|
+
}
|
|
9
|
+
export declare const formDataBodySerializer: {
|
|
10
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => FormData;
|
|
11
|
+
};
|
|
12
|
+
export declare const jsonBodySerializer: {
|
|
13
|
+
bodySerializer: <T>(body: T) => string;
|
|
14
|
+
};
|
|
15
|
+
export declare const urlSearchParamsBodySerializer: {
|
|
16
|
+
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T) => string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.urlSearchParamsBodySerializer = exports.jsonBodySerializer = exports.formDataBodySerializer = void 0;
|
|
5
|
+
const serializeFormDataPair = (data, key, value) => {
|
|
6
|
+
if (typeof value === 'string' || value instanceof Blob) {
|
|
7
|
+
data.append(key, value);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
data.append(key, JSON.stringify(value));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
14
|
+
if (typeof value === 'string') {
|
|
15
|
+
data.append(key, value);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
data.append(key, JSON.stringify(value));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.formDataBodySerializer = {
|
|
22
|
+
bodySerializer: (body) => {
|
|
23
|
+
const data = new FormData();
|
|
24
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
25
|
+
if (value === undefined || value === null) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
serializeFormDataPair(data, key, value);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return data;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
exports.jsonBodySerializer = {
|
|
39
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value),
|
|
40
|
+
};
|
|
41
|
+
exports.urlSearchParamsBodySerializer = {
|
|
42
|
+
bodySerializer: (body) => {
|
|
43
|
+
const data = new URLSearchParams();
|
|
44
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
45
|
+
if (value === undefined || value === null) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
serializeUrlSearchParamsPair(data, key, value);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return data.toString();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
2
|
+
export type Field = {
|
|
3
|
+
in: Exclude<Slot, 'body'>;
|
|
4
|
+
/**
|
|
5
|
+
* Field name. This is the name we want the user to see and use.
|
|
6
|
+
*/
|
|
7
|
+
key: string;
|
|
8
|
+
/**
|
|
9
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
10
|
+
* If omitted, we use the same value as `key`.
|
|
11
|
+
*/
|
|
12
|
+
map?: string;
|
|
13
|
+
} | {
|
|
14
|
+
in: Extract<Slot, 'body'>;
|
|
15
|
+
/**
|
|
16
|
+
* Key isn't required for bodies.
|
|
17
|
+
*/
|
|
18
|
+
key?: string;
|
|
19
|
+
map?: string;
|
|
20
|
+
};
|
|
21
|
+
export interface Fields {
|
|
22
|
+
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
23
|
+
args?: ReadonlyArray<Field>;
|
|
24
|
+
}
|
|
25
|
+
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
26
|
+
interface Params {
|
|
27
|
+
body: unknown;
|
|
28
|
+
headers: Record<string, unknown>;
|
|
29
|
+
path: Record<string, unknown>;
|
|
30
|
+
query: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export declare const buildClientParams: (args: ReadonlyArray<unknown>, fields: FieldsConfig) => Params;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.buildClientParams = void 0;
|
|
5
|
+
const extraPrefixesMap = {
|
|
6
|
+
$body_: 'body',
|
|
7
|
+
$headers_: 'headers',
|
|
8
|
+
$path_: 'path',
|
|
9
|
+
$query_: 'query',
|
|
10
|
+
};
|
|
11
|
+
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
12
|
+
const buildKeyMap = (fields, map) => {
|
|
13
|
+
if (!map) {
|
|
14
|
+
map = new Map();
|
|
15
|
+
}
|
|
16
|
+
for (const config of fields) {
|
|
17
|
+
if ('in' in config) {
|
|
18
|
+
if (config.key) {
|
|
19
|
+
map.set(config.key, {
|
|
20
|
+
in: config.in,
|
|
21
|
+
map: config.map,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (config.args) {
|
|
26
|
+
buildKeyMap(config.args, map);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return map;
|
|
30
|
+
};
|
|
31
|
+
const stripEmptySlots = (params) => {
|
|
32
|
+
for (const [slot, value] of Object.entries(params)) {
|
|
33
|
+
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
34
|
+
delete params[slot];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const buildClientParams = (args, fields) => {
|
|
39
|
+
const params = {
|
|
40
|
+
body: {},
|
|
41
|
+
headers: {},
|
|
42
|
+
path: {},
|
|
43
|
+
query: {},
|
|
44
|
+
};
|
|
45
|
+
const map = buildKeyMap(fields);
|
|
46
|
+
let config;
|
|
47
|
+
for (const [index, arg] of args.entries()) {
|
|
48
|
+
if (fields[index]) {
|
|
49
|
+
config = fields[index];
|
|
50
|
+
}
|
|
51
|
+
if (!config) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if ('in' in config) {
|
|
55
|
+
if (config.key) {
|
|
56
|
+
const field = map.get(config.key);
|
|
57
|
+
const name = field.map || config.key;
|
|
58
|
+
params[field.in][name] = arg;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
params.body = arg;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
66
|
+
const field = map.get(key);
|
|
67
|
+
if (field) {
|
|
68
|
+
const name = field.map || key;
|
|
69
|
+
params[field.in][name] = value;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
73
|
+
if (extra) {
|
|
74
|
+
const [prefix, slot] = extra;
|
|
75
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra ?? {})) {
|
|
79
|
+
if (allowed) {
|
|
80
|
+
params[slot][key] = value;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
stripEmptySlots(params);
|
|
90
|
+
return params;
|
|
91
|
+
};
|
|
92
|
+
exports.buildClientParams = buildClientParams;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {
|
|
2
|
+
}
|
|
3
|
+
interface SerializePrimitiveOptions {
|
|
4
|
+
allowReserved?: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SerializerOptions<T> {
|
|
8
|
+
/**
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
explode: boolean;
|
|
12
|
+
style: T;
|
|
13
|
+
}
|
|
14
|
+
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
15
|
+
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
|
16
|
+
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
|
17
|
+
export type ObjectStyle = 'form' | 'deepObject';
|
|
18
|
+
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
|
19
|
+
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const separatorArrayExplode: (style: ArraySeparatorStyle) => "." | ";" | "," | "&";
|
|
23
|
+
export declare const separatorArrayNoExplode: (style: ArraySeparatorStyle) => "," | "|" | "%20";
|
|
24
|
+
export declare const separatorObjectExplode: (style: ObjectSeparatorStyle) => "." | ";" | "," | "&";
|
|
25
|
+
export declare const serializeArrayParam: ({ allowReserved, explode, name, style, value, }: SerializeOptions<ArraySeparatorStyle> & {
|
|
26
|
+
value: unknown[];
|
|
27
|
+
}) => string;
|
|
28
|
+
export declare const serializePrimitiveParam: ({ allowReserved, name, value, }: SerializePrimitiveParam) => string;
|
|
29
|
+
export declare const serializeObjectParam: ({ allowReserved, explode, name, style, value, valueOnly, }: SerializeOptions<ObjectSeparatorStyle> & {
|
|
30
|
+
value: Record<string, unknown> | Date;
|
|
31
|
+
valueOnly?: boolean;
|
|
32
|
+
}) => string;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.serializeObjectParam = exports.serializePrimitiveParam = exports.serializeArrayParam = exports.separatorObjectExplode = exports.separatorArrayNoExplode = exports.separatorArrayExplode = void 0;
|
|
5
|
+
const separatorArrayExplode = (style) => {
|
|
6
|
+
switch (style) {
|
|
7
|
+
case 'label':
|
|
8
|
+
return '.';
|
|
9
|
+
case 'matrix':
|
|
10
|
+
return ';';
|
|
11
|
+
case 'simple':
|
|
12
|
+
return ',';
|
|
13
|
+
default:
|
|
14
|
+
return '&';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.separatorArrayExplode = separatorArrayExplode;
|
|
18
|
+
const separatorArrayNoExplode = (style) => {
|
|
19
|
+
switch (style) {
|
|
20
|
+
case 'form':
|
|
21
|
+
return ',';
|
|
22
|
+
case 'pipeDelimited':
|
|
23
|
+
return '|';
|
|
24
|
+
case 'spaceDelimited':
|
|
25
|
+
return '%20';
|
|
26
|
+
default:
|
|
27
|
+
return ',';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.separatorArrayNoExplode = separatorArrayNoExplode;
|
|
31
|
+
const separatorObjectExplode = (style) => {
|
|
32
|
+
switch (style) {
|
|
33
|
+
case 'label':
|
|
34
|
+
return '.';
|
|
35
|
+
case 'matrix':
|
|
36
|
+
return ';';
|
|
37
|
+
case 'simple':
|
|
38
|
+
return ',';
|
|
39
|
+
default:
|
|
40
|
+
return '&';
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.separatorObjectExplode = separatorObjectExplode;
|
|
44
|
+
const serializeArrayParam = ({ allowReserved, explode, name, style, value, }) => {
|
|
45
|
+
if (!explode) {
|
|
46
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join((0, exports.separatorArrayNoExplode)(style));
|
|
47
|
+
switch (style) {
|
|
48
|
+
case 'label':
|
|
49
|
+
return `.${joinedValues}`;
|
|
50
|
+
case 'matrix':
|
|
51
|
+
return `;${name}=${joinedValues}`;
|
|
52
|
+
case 'simple':
|
|
53
|
+
return joinedValues;
|
|
54
|
+
default:
|
|
55
|
+
return `${name}=${joinedValues}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const separator = (0, exports.separatorArrayExplode)(style);
|
|
59
|
+
const joinedValues = value
|
|
60
|
+
.map((v) => {
|
|
61
|
+
if (style === 'label' || style === 'simple') {
|
|
62
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
63
|
+
}
|
|
64
|
+
return (0, exports.serializePrimitiveParam)({
|
|
65
|
+
allowReserved,
|
|
66
|
+
name,
|
|
67
|
+
value: v,
|
|
68
|
+
});
|
|
69
|
+
})
|
|
70
|
+
.join(separator);
|
|
71
|
+
return style === 'label' || style === 'matrix'
|
|
72
|
+
? separator + joinedValues
|
|
73
|
+
: joinedValues;
|
|
74
|
+
};
|
|
75
|
+
exports.serializeArrayParam = serializeArrayParam;
|
|
76
|
+
const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
|
|
77
|
+
if (value === undefined || value === null) {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
if (typeof value === 'object') {
|
|
81
|
+
throw new Error('Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.');
|
|
82
|
+
}
|
|
83
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
84
|
+
};
|
|
85
|
+
exports.serializePrimitiveParam = serializePrimitiveParam;
|
|
86
|
+
const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly, }) => {
|
|
87
|
+
if (value instanceof Date) {
|
|
88
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
89
|
+
}
|
|
90
|
+
if (style !== 'deepObject' && !explode) {
|
|
91
|
+
let values = [];
|
|
92
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
93
|
+
values = [
|
|
94
|
+
...values,
|
|
95
|
+
key,
|
|
96
|
+
allowReserved ? v : encodeURIComponent(v),
|
|
97
|
+
];
|
|
98
|
+
});
|
|
99
|
+
const joinedValues = values.join(',');
|
|
100
|
+
switch (style) {
|
|
101
|
+
case 'form':
|
|
102
|
+
return `${name}=${joinedValues}`;
|
|
103
|
+
case 'label':
|
|
104
|
+
return `.${joinedValues}`;
|
|
105
|
+
case 'matrix':
|
|
106
|
+
return `;${name}=${joinedValues}`;
|
|
107
|
+
default:
|
|
108
|
+
return joinedValues;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const separator = (0, exports.separatorObjectExplode)(style);
|
|
112
|
+
const joinedValues = Object.entries(value)
|
|
113
|
+
.map(([key, v]) => (0, exports.serializePrimitiveParam)({
|
|
114
|
+
allowReserved,
|
|
115
|
+
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
|
116
|
+
value: v,
|
|
117
|
+
}))
|
|
118
|
+
.join(separator);
|
|
119
|
+
return style === 'label' || style === 'matrix'
|
|
120
|
+
? separator + joinedValues
|
|
121
|
+
: joinedValues;
|
|
122
|
+
};
|
|
123
|
+
exports.serializeObjectParam = serializeObjectParam;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Auth, AuthToken } from './auth.gen';
|
|
2
|
+
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
|
|
3
|
+
export interface Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never> {
|
|
4
|
+
/**
|
|
5
|
+
* Returns the final request URL.
|
|
6
|
+
*/
|
|
7
|
+
buildUrl: BuildUrlFn;
|
|
8
|
+
connect: MethodFn;
|
|
9
|
+
delete: MethodFn;
|
|
10
|
+
get: MethodFn;
|
|
11
|
+
getConfig: () => Config;
|
|
12
|
+
head: MethodFn;
|
|
13
|
+
options: MethodFn;
|
|
14
|
+
patch: MethodFn;
|
|
15
|
+
post: MethodFn;
|
|
16
|
+
put: MethodFn;
|
|
17
|
+
request: RequestFn;
|
|
18
|
+
setConfig: (config: Config) => Config;
|
|
19
|
+
trace: MethodFn;
|
|
20
|
+
}
|
|
21
|
+
export interface Config {
|
|
22
|
+
/**
|
|
23
|
+
* Auth token or a function returning auth token. The resolved value will be
|
|
24
|
+
* added to the request payload as defined by its `security` array.
|
|
25
|
+
*/
|
|
26
|
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
|
27
|
+
/**
|
|
28
|
+
* A function for serializing request body parameter. By default,
|
|
29
|
+
* {@link JSON.stringify()} will be used.
|
|
30
|
+
*/
|
|
31
|
+
bodySerializer?: BodySerializer | null;
|
|
32
|
+
/**
|
|
33
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
34
|
+
* `Headers` object with.
|
|
35
|
+
*
|
|
36
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
37
|
+
*/
|
|
38
|
+
headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* The request method.
|
|
41
|
+
*
|
|
42
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
43
|
+
*/
|
|
44
|
+
method?: 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
|
|
45
|
+
/**
|
|
46
|
+
* A function for serializing request query parameters. By default, arrays
|
|
47
|
+
* will be exploded in form style, objects will be exploded in deepObject
|
|
48
|
+
* style, and reserved characters are percent-encoded.
|
|
49
|
+
*
|
|
50
|
+
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
51
|
+
* API function is used.
|
|
52
|
+
*
|
|
53
|
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
54
|
+
*/
|
|
55
|
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
56
|
+
/**
|
|
57
|
+
* A function validating request data. This is useful if you want to ensure
|
|
58
|
+
* the request conforms to the desired shape, so it can be safely sent to
|
|
59
|
+
* the server.
|
|
60
|
+
*/
|
|
61
|
+
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* A function transforming response data before it's returned. This is useful
|
|
64
|
+
* for post-processing data, e.g. converting ISO strings into Date objects.
|
|
65
|
+
*/
|
|
66
|
+
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* A function validating response data. This is useful if you want to ensure
|
|
69
|
+
* the response conforms to the desired shape, so it can be safely passed to
|
|
70
|
+
* the transformers and returned to the user.
|
|
71
|
+
*/
|
|
72
|
+
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
73
|
+
}
|
|
74
|
+
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] ? true : [T] extends [never | undefined] ? [undefined] extends [T] ? false : true : false;
|
|
75
|
+
export type OmitNever<T extends Record<string, unknown>> = {
|
|
76
|
+
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
|
|
77
|
+
};
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export declare class OperationClient {
|
|
5
|
+
private sseClients;
|
|
6
|
+
private cleanupTimeouts;
|
|
7
|
+
private config;
|
|
8
|
+
private cleanupIntervalMs;
|
|
9
|
+
private cleanupInterval?;
|
|
10
|
+
constructor(config);
|
|
11
|
+
monitorOperation(operationId, options?)>;
|
|
12
|
+
/**
|
|
13
|
+
* Monitor multiple operations concurrently
|
|
14
|
+
*/
|
|
15
|
+
monitorMultiple(operationIds, options?)>>;
|
|
16
|
+
/**
|
|
17
|
+
* Get the current status of an operation (point-in-time check)
|
|
18
|
+
*/
|
|
19
|
+
getStatus(operationId);
|
|
20
|
+
/**
|
|
21
|
+
* Cancel a pending or running operation
|
|
22
|
+
*/
|
|
23
|
+
cancelOperation(operationId);
|
|
24
|
+
/**
|
|
25
|
+
* Wait for an operation with a simple promise interface
|
|
26
|
+
*/
|
|
27
|
+
waitForOperation(operationId, timeoutMs?);
|
|
28
|
+
/**
|
|
29
|
+
* Monitor operation with async iterator for progress updates
|
|
30
|
+
*/
|
|
31
|
+
monitorWithProgress(operationId)>;
|
|
32
|
+
private cleanupClient;
|
|
33
|
+
/**
|
|
34
|
+
* Schedule automatic cleanup of SSE client after a delay
|
|
35
|
+
*/
|
|
36
|
+
private scheduleCleanup;
|
|
37
|
+
/**
|
|
38
|
+
* Perform periodic cleanup of stale SSE connections
|
|
39
|
+
*/
|
|
40
|
+
private performPeriodicCleanup;
|
|
41
|
+
/**
|
|
42
|
+
* Close all active SSE connections and clean up resources
|
|
43
|
+
*/
|
|
44
|
+
closeAll();
|
|
45
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface OperationProgress {
|
|
2
|
+
message: string;
|
|
3
|
+
progressPercent?: number;
|
|
4
|
+
details?: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
export interface OperationResult<T = any> {
|
|
7
|
+
success: boolean;
|
|
8
|
+
result?: T;
|
|
9
|
+
error?: string;
|
|
10
|
+
metadata?: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export interface OperationMonitorOptions {
|
|
13
|
+
onProgress?: (progress: OperationProgress) => void;
|
|
14
|
+
onQueueUpdate?: (position: number, estimatedWait: number) => void;
|
|
15
|
+
timeout?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare class OperationClient {
|
|
18
|
+
private sseClients;
|
|
19
|
+
private cleanupTimeouts;
|
|
20
|
+
private config;
|
|
21
|
+
private cleanupIntervalMs;
|
|
22
|
+
private cleanupInterval?;
|
|
23
|
+
constructor(config: {
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
credentials?: 'include' | 'same-origin' | 'omit';
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
maxRetries?: number;
|
|
28
|
+
retryDelay?: number;
|
|
29
|
+
});
|
|
30
|
+
monitorOperation<T = any>(operationId: string, options?: OperationMonitorOptions): Promise<OperationResult<T>>;
|
|
31
|
+
/**
|
|
32
|
+
* Monitor multiple operations concurrently
|
|
33
|
+
*/
|
|
34
|
+
monitorMultiple<T = any>(operationIds: string[], options?: OperationMonitorOptions): Promise<Map<string, OperationResult<T>>>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the current status of an operation (point-in-time check)
|
|
37
|
+
*/
|
|
38
|
+
getStatus(operationId: string): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* Cancel a pending or running operation
|
|
41
|
+
*/
|
|
42
|
+
cancelOperation(operationId: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Wait for an operation with a simple promise interface
|
|
45
|
+
*/
|
|
46
|
+
waitForOperation<T = any>(operationId: string, timeoutMs?: number): Promise<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Monitor operation with async iterator for progress updates
|
|
49
|
+
*/
|
|
50
|
+
monitorWithProgress<T = any>(operationId: string): AsyncIterableIterator<OperationProgress | OperationResult<T>>;
|
|
51
|
+
private cleanupClient;
|
|
52
|
+
/**
|
|
53
|
+
* Schedule automatic cleanup of SSE client after a delay
|
|
54
|
+
*/
|
|
55
|
+
private scheduleCleanup;
|
|
56
|
+
/**
|
|
57
|
+
* Perform periodic cleanup of stale SSE connections
|
|
58
|
+
*/
|
|
59
|
+
private performPeriodicCleanup;
|
|
60
|
+
/**
|
|
61
|
+
* Close all active SSE connections and clean up resources
|
|
62
|
+
*/
|
|
63
|
+
closeAll(): void;
|
|
64
|
+
}
|