@townco/fly 0.1.30 → 0.1.32
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/api/client/client.gen.d.ts +2 -2
- package/dist/api/client/client.gen.js +46 -45
- package/dist/api/client/index.d.ts +8 -8
- package/dist/api/client/index.js +5 -5
- package/dist/api/client/types.gen.d.ts +18 -18
- package/dist/api/client/utils.gen.d.ts +7 -7
- package/dist/api/client/utils.gen.js +34 -33
- package/dist/api/client.gen.d.ts +2 -2
- package/dist/api/client.gen.js +3 -3
- package/dist/api/core/auth.gen.d.ts +3 -3
- package/dist/api/core/auth.gen.js +3 -3
- package/dist/api/core/bodySerializer.gen.d.ts +3 -3
- package/dist/api/core/bodySerializer.gen.js +3 -3
- package/dist/api/core/params.gen.d.ts +4 -4
- package/dist/api/core/params.gen.js +9 -9
- package/dist/api/core/pathSerializer.gen.d.ts +8 -8
- package/dist/api/core/pathSerializer.gen.js +36 -36
- package/dist/api/core/queryKeySerializer.gen.js +11 -11
- package/dist/api/core/serverSentEvents.gen.d.ts +4 -4
- package/dist/api/core/serverSentEvents.gen.js +18 -18
- package/dist/api/core/types.gen.d.ts +4 -4
- package/dist/api/core/utils.gen.d.ts +4 -4
- package/dist/api/core/utils.gen.js +17 -17
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +1 -1
- package/dist/api/sdk.gen.d.ts +5 -5
- package/dist/api/sdk.gen.js +130 -160
- package/dist/api/types.gen.d.ts +84 -84
- package/package.json +7 -7
- package/dist/client/client.gen.d.ts +0 -2
- package/dist/client/client.gen.js +0 -228
- package/dist/client/index.d.ts +0 -8
- package/dist/client/index.js +0 -6
- package/dist/client/types.gen.d.ts +0 -117
- package/dist/client/types.gen.js +0 -2
- package/dist/client/utils.gen.d.ts +0 -33
- package/dist/client/utils.gen.js +0 -231
- package/dist/client.gen.d.ts +0 -12
- package/dist/client.gen.js +0 -3
- package/dist/core/auth.gen.d.ts +0 -18
- package/dist/core/auth.gen.js +0 -14
- package/dist/core/bodySerializer.gen.d.ts +0 -25
- package/dist/core/bodySerializer.gen.js +0 -57
- package/dist/core/params.gen.d.ts +0 -43
- package/dist/core/params.gen.js +0 -100
- package/dist/core/pathSerializer.gen.d.ts +0 -33
- package/dist/core/pathSerializer.gen.js +0 -114
- package/dist/core/queryKeySerializer.gen.d.ts +0 -18
- package/dist/core/queryKeySerializer.gen.js +0 -99
- package/dist/core/serverSentEvents.gen.d.ts +0 -71
- package/dist/core/serverSentEvents.gen.js +0 -135
- package/dist/core/types.gen.d.ts +0 -78
- package/dist/core/types.gen.js +0 -2
- package/dist/core/utils.gen.d.ts +0 -19
- package/dist/core/utils.gen.js +0 -87
- package/dist/sdk.gen.d.ts +0 -379
- package/dist/sdk.gen.js +0 -557
- package/dist/types.gen.d.ts +0 -2592
- package/dist/types.gen.js +0 -2
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
|
|
3
|
-
let lastEventId;
|
|
4
|
-
const sleep = sseSleepFn ??
|
|
5
|
-
((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
6
|
-
const createStream = async function* () {
|
|
7
|
-
let retryDelay = sseDefaultRetryDelay ?? 3000;
|
|
8
|
-
let attempt = 0;
|
|
9
|
-
const signal = options.signal ?? new AbortController().signal;
|
|
10
|
-
while (true) {
|
|
11
|
-
if (signal.aborted)
|
|
12
|
-
break;
|
|
13
|
-
attempt++;
|
|
14
|
-
const headers = options.headers instanceof Headers
|
|
15
|
-
? options.headers
|
|
16
|
-
: new Headers(options.headers);
|
|
17
|
-
if (lastEventId !== undefined) {
|
|
18
|
-
headers.set("Last-Event-ID", lastEventId);
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const requestInit = {
|
|
22
|
-
redirect: "follow",
|
|
23
|
-
...options,
|
|
24
|
-
body: options.serializedBody,
|
|
25
|
-
headers,
|
|
26
|
-
signal,
|
|
27
|
-
};
|
|
28
|
-
let request = new Request(url, requestInit);
|
|
29
|
-
if (onRequest) {
|
|
30
|
-
request = await onRequest(url, requestInit);
|
|
31
|
-
}
|
|
32
|
-
// fetch must be assigned here, otherwise it would throw the error:
|
|
33
|
-
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
34
|
-
const _fetch = options.fetch ?? globalThis.fetch;
|
|
35
|
-
const response = await _fetch(request);
|
|
36
|
-
if (!response.ok)
|
|
37
|
-
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
38
|
-
if (!response.body)
|
|
39
|
-
throw new Error("No body in SSE response");
|
|
40
|
-
const reader = response.body
|
|
41
|
-
.pipeThrough(new TextDecoderStream())
|
|
42
|
-
.getReader();
|
|
43
|
-
let buffer = "";
|
|
44
|
-
const abortHandler = () => {
|
|
45
|
-
try {
|
|
46
|
-
reader.cancel();
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// noop
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
signal.addEventListener("abort", abortHandler);
|
|
53
|
-
try {
|
|
54
|
-
while (true) {
|
|
55
|
-
const { done, value } = await reader.read();
|
|
56
|
-
if (done)
|
|
57
|
-
break;
|
|
58
|
-
buffer += value;
|
|
59
|
-
const chunks = buffer.split("\n\n");
|
|
60
|
-
buffer = chunks.pop() ?? "";
|
|
61
|
-
for (const chunk of chunks) {
|
|
62
|
-
const lines = chunk.split("\n");
|
|
63
|
-
const dataLines = [];
|
|
64
|
-
let eventName;
|
|
65
|
-
for (const line of lines) {
|
|
66
|
-
if (line.startsWith("data:")) {
|
|
67
|
-
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
68
|
-
}
|
|
69
|
-
else if (line.startsWith("event:")) {
|
|
70
|
-
eventName = line.replace(/^event:\s*/, "");
|
|
71
|
-
}
|
|
72
|
-
else if (line.startsWith("id:")) {
|
|
73
|
-
lastEventId = line.replace(/^id:\s*/, "");
|
|
74
|
-
}
|
|
75
|
-
else if (line.startsWith("retry:")) {
|
|
76
|
-
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
77
|
-
if (!Number.isNaN(parsed)) {
|
|
78
|
-
retryDelay = parsed;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
let data;
|
|
83
|
-
let parsedJson = false;
|
|
84
|
-
if (dataLines.length) {
|
|
85
|
-
const rawData = dataLines.join("\n");
|
|
86
|
-
try {
|
|
87
|
-
data = JSON.parse(rawData);
|
|
88
|
-
parsedJson = true;
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
data = rawData;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (parsedJson) {
|
|
95
|
-
if (responseValidator) {
|
|
96
|
-
await responseValidator(data);
|
|
97
|
-
}
|
|
98
|
-
if (responseTransformer) {
|
|
99
|
-
data = await responseTransformer(data);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
onSseEvent?.({
|
|
103
|
-
data,
|
|
104
|
-
event: eventName,
|
|
105
|
-
id: lastEventId,
|
|
106
|
-
retry: retryDelay,
|
|
107
|
-
});
|
|
108
|
-
if (dataLines.length) {
|
|
109
|
-
yield data;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
finally {
|
|
115
|
-
signal.removeEventListener("abort", abortHandler);
|
|
116
|
-
reader.releaseLock();
|
|
117
|
-
}
|
|
118
|
-
break; // exit loop on normal completion
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
// connection failed or aborted; retry after delay
|
|
122
|
-
onSseError?.(error);
|
|
123
|
-
if (sseMaxRetryAttempts !== undefined &&
|
|
124
|
-
attempt >= sseMaxRetryAttempts) {
|
|
125
|
-
break; // stop after firing error
|
|
126
|
-
}
|
|
127
|
-
// exponential backoff: double retry each attempt, cap at 30s
|
|
128
|
-
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
|
129
|
-
await sleep(backoff);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const stream = createStream();
|
|
134
|
-
return { stream };
|
|
135
|
-
};
|
package/dist/core/types.gen.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { Auth, AuthToken } from "./auth.gen";
|
|
2
|
-
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer.gen";
|
|
3
|
-
export type HttpMethod = "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
|
|
4
|
-
export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
5
|
-
/**
|
|
6
|
-
* Returns the final request URL.
|
|
7
|
-
*/
|
|
8
|
-
buildUrl: BuildUrlFn;
|
|
9
|
-
getConfig: () => Config;
|
|
10
|
-
request: RequestFn;
|
|
11
|
-
setConfig: (config: Config) => Config;
|
|
12
|
-
} & {
|
|
13
|
-
[K in HttpMethod]: MethodFn;
|
|
14
|
-
} & ([SseFn] extends [never] ? {
|
|
15
|
-
sse?: never;
|
|
16
|
-
} : {
|
|
17
|
-
sse: {
|
|
18
|
-
[K in HttpMethod]: SseFn;
|
|
19
|
-
};
|
|
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?: Uppercase<HttpMethod>;
|
|
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 {};
|
package/dist/core/types.gen.js
DELETED
package/dist/core/utils.gen.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { BodySerializer, QuerySerializer } from "./bodySerializer.gen";
|
|
2
|
-
export interface PathSerializer {
|
|
3
|
-
path: Record<string, unknown>;
|
|
4
|
-
url: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const PATH_PARAM_RE: RegExp;
|
|
7
|
-
export declare const defaultPathSerializer: ({ path, url: _url }: PathSerializer) => string;
|
|
8
|
-
export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
|
|
9
|
-
baseUrl?: string;
|
|
10
|
-
path?: Record<string, unknown>;
|
|
11
|
-
query?: Record<string, unknown>;
|
|
12
|
-
querySerializer: QuerySerializer;
|
|
13
|
-
url: string;
|
|
14
|
-
}) => string;
|
|
15
|
-
export declare function getValidRequestBody(options: {
|
|
16
|
-
body?: unknown;
|
|
17
|
-
bodySerializer?: BodySerializer | null;
|
|
18
|
-
serializedBody?: unknown;
|
|
19
|
-
}): unknown;
|
package/dist/core/utils.gen.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from "./pathSerializer.gen";
|
|
3
|
-
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
4
|
-
export const defaultPathSerializer = ({ path, url: _url }) => {
|
|
5
|
-
let url = _url;
|
|
6
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
7
|
-
if (matches) {
|
|
8
|
-
for (const match of matches) {
|
|
9
|
-
let explode = false;
|
|
10
|
-
let name = match.substring(1, match.length - 1);
|
|
11
|
-
let style = "simple";
|
|
12
|
-
if (name.endsWith("*")) {
|
|
13
|
-
explode = true;
|
|
14
|
-
name = name.substring(0, name.length - 1);
|
|
15
|
-
}
|
|
16
|
-
if (name.startsWith(".")) {
|
|
17
|
-
name = name.substring(1);
|
|
18
|
-
style = "label";
|
|
19
|
-
}
|
|
20
|
-
else if (name.startsWith(";")) {
|
|
21
|
-
name = name.substring(1);
|
|
22
|
-
style = "matrix";
|
|
23
|
-
}
|
|
24
|
-
const value = path[name];
|
|
25
|
-
if (value === undefined || value === null) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(value)) {
|
|
29
|
-
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (typeof value === "object") {
|
|
33
|
-
url = url.replace(match, serializeObjectParam({
|
|
34
|
-
explode,
|
|
35
|
-
name,
|
|
36
|
-
style,
|
|
37
|
-
value: value,
|
|
38
|
-
valueOnly: true,
|
|
39
|
-
}));
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (style === "matrix") {
|
|
43
|
-
url = url.replace(match, `;${serializePrimitiveParam({
|
|
44
|
-
name,
|
|
45
|
-
value: value,
|
|
46
|
-
})}`);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
50
|
-
url = url.replace(match, replaceValue);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return url;
|
|
54
|
-
};
|
|
55
|
-
export const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
56
|
-
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
57
|
-
let url = (baseUrl ?? "") + pathUrl;
|
|
58
|
-
if (path) {
|
|
59
|
-
url = defaultPathSerializer({ path, url });
|
|
60
|
-
}
|
|
61
|
-
let search = query ? querySerializer(query) : "";
|
|
62
|
-
if (search.startsWith("?")) {
|
|
63
|
-
search = search.substring(1);
|
|
64
|
-
}
|
|
65
|
-
if (search) {
|
|
66
|
-
url += `?${search}`;
|
|
67
|
-
}
|
|
68
|
-
return url;
|
|
69
|
-
};
|
|
70
|
-
export function getValidRequestBody(options) {
|
|
71
|
-
const hasBody = options.body !== undefined;
|
|
72
|
-
const isSerializedBody = hasBody && options.bodySerializer;
|
|
73
|
-
if (isSerializedBody) {
|
|
74
|
-
if ("serializedBody" in options) {
|
|
75
|
-
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
|
|
76
|
-
return hasSerializedBody ? options.serializedBody : null;
|
|
77
|
-
}
|
|
78
|
-
// not all clients implement a serializedBody property (i.e. client-axios)
|
|
79
|
-
return options.body !== "" ? options.body : null;
|
|
80
|
-
}
|
|
81
|
-
// plain/text body
|
|
82
|
-
if (hasBody) {
|
|
83
|
-
return options.body;
|
|
84
|
-
}
|
|
85
|
-
// no body was provided
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|