add ability to edit bandwidth limits for existing repositories
This commit is contained in:
parent
623b4b7116
commit
e60eed2535
20 changed files with 6186 additions and 6736 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,12 +1,7 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import {
|
import { type ClientOptions, type Config, createClient, createConfig } from './client';
|
||||||
type ClientOptions,
|
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
||||||
type Config,
|
|
||||||
createClient,
|
|
||||||
createConfig,
|
|
||||||
} from "./client";
|
|
||||||
import type { ClientOptions as ClientOptions2 } from "./types.gen";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `createClientConfig()` function will be called on client initialization
|
* The `createClientConfig()` function will be called on client initialization
|
||||||
|
|
@ -16,10 +11,6 @@ import type { ClientOptions as ClientOptions2 } from "./types.gen";
|
||||||
* `setConfig()`. This is useful for example if you're using Next.js
|
* `setConfig()`. This is useful for example if you're using Next.js
|
||||||
* to ensure your client always has the correct values.
|
* to ensure your client always has the correct values.
|
||||||
*/
|
*/
|
||||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
||||||
override?: Config<ClientOptions & T>,
|
|
||||||
) => Config<Required<ClientOptions> & T>;
|
|
||||||
|
|
||||||
export const client = createClient(
|
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:4096' }));
|
||||||
createConfig<ClientOptions2>({ baseUrl: "http://localhost:4096" }),
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import { createSseClient } from "../core/serverSentEvents.gen";
|
import { createSseClient } from '../core/serverSentEvents.gen';
|
||||||
import type { HttpMethod } from "../core/types.gen";
|
import type { HttpMethod } from '../core/types.gen';
|
||||||
import { getValidRequestBody } from "../core/utils.gen";
|
import { getValidRequestBody } from '../core/utils.gen';
|
||||||
import type {
|
import type {
|
||||||
Client,
|
Client,
|
||||||
Config,
|
Config,
|
||||||
RequestOptions,
|
RequestOptions,
|
||||||
ResolvedRequestOptions,
|
ResolvedRequestOptions,
|
||||||
} from "./types.gen";
|
} from './types.gen';
|
||||||
import {
|
import {
|
||||||
buildUrl,
|
buildUrl,
|
||||||
createConfig,
|
createConfig,
|
||||||
|
|
@ -17,9 +17,9 @@ import {
|
||||||
mergeConfigs,
|
mergeConfigs,
|
||||||
mergeHeaders,
|
mergeHeaders,
|
||||||
setAuthParams,
|
setAuthParams,
|
||||||
} from "./utils.gen";
|
} from './utils.gen';
|
||||||
|
|
||||||
type ReqInit = Omit<RequestInit, "body" | "headers"> & {
|
type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
|
||||||
body?: any;
|
body?: any;
|
||||||
headers: ReturnType<typeof mergeHeaders>;
|
headers: ReturnType<typeof mergeHeaders>;
|
||||||
};
|
};
|
||||||
|
|
@ -66,8 +66,8 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove Content-Type header if body is empty to avoid sending invalid requests
|
// remove Content-Type header if body is empty to avoid sending invalid requests
|
||||||
if (opts.body === undefined || opts.serializedBody === "") {
|
if (opts.body === undefined || opts.serializedBody === '') {
|
||||||
opts.headers.delete("Content-Type");
|
opts.headers.delete('Content-Type');
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = buildUrl(opts);
|
const url = buildUrl(opts);
|
||||||
|
|
@ -75,11 +75,11 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
return { opts, url };
|
return { opts, url };
|
||||||
};
|
};
|
||||||
|
|
||||||
const request: Client["request"] = async (options) => {
|
const request: Client['request'] = async (options) => {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const { opts, url } = await beforeRequest(options);
|
const { opts, url } = await beforeRequest(options);
|
||||||
const requestInit: ReqInit = {
|
const requestInit: ReqInit = {
|
||||||
redirect: "follow",
|
redirect: 'follow',
|
||||||
...opts,
|
...opts,
|
||||||
body: getValidRequestBody(opts),
|
body: getValidRequestBody(opts),
|
||||||
};
|
};
|
||||||
|
|
@ -121,7 +121,7 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return error response
|
// Return error response
|
||||||
return opts.responseStyle === "data"
|
return opts.responseStyle === 'data'
|
||||||
? undefined
|
? undefined
|
||||||
: {
|
: {
|
||||||
error: finalError,
|
error: finalError,
|
||||||
|
|
@ -143,33 +143,33 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const parseAs =
|
const parseAs =
|
||||||
(opts.parseAs === "auto"
|
(opts.parseAs === 'auto'
|
||||||
? getParseAs(response.headers.get("Content-Type"))
|
? getParseAs(response.headers.get('Content-Type'))
|
||||||
: opts.parseAs) ?? "json";
|
: opts.parseAs) ?? 'json';
|
||||||
|
|
||||||
if (
|
if (
|
||||||
response.status === 204 ||
|
response.status === 204 ||
|
||||||
response.headers.get("Content-Length") === "0"
|
response.headers.get('Content-Length') === '0'
|
||||||
) {
|
) {
|
||||||
let emptyData: any;
|
let emptyData: any;
|
||||||
switch (parseAs) {
|
switch (parseAs) {
|
||||||
case "arrayBuffer":
|
case 'arrayBuffer':
|
||||||
case "blob":
|
case 'blob':
|
||||||
case "text":
|
case 'text':
|
||||||
emptyData = await response[parseAs]();
|
emptyData = await response[parseAs]();
|
||||||
break;
|
break;
|
||||||
case "formData":
|
case 'formData':
|
||||||
emptyData = new FormData();
|
emptyData = new FormData();
|
||||||
break;
|
break;
|
||||||
case "stream":
|
case 'stream':
|
||||||
emptyData = response.body;
|
emptyData = response.body;
|
||||||
break;
|
break;
|
||||||
case "json":
|
case 'json':
|
||||||
default:
|
default:
|
||||||
emptyData = {};
|
emptyData = {};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return opts.responseStyle === "data"
|
return opts.responseStyle === 'data'
|
||||||
? emptyData
|
? emptyData
|
||||||
: {
|
: {
|
||||||
data: emptyData,
|
data: emptyData,
|
||||||
|
|
@ -179,15 +179,15 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
|
|
||||||
let data: any;
|
let data: any;
|
||||||
switch (parseAs) {
|
switch (parseAs) {
|
||||||
case "arrayBuffer":
|
case 'arrayBuffer':
|
||||||
case "blob":
|
case 'blob':
|
||||||
case "formData":
|
case 'formData':
|
||||||
case "json":
|
case 'json':
|
||||||
case "text":
|
case 'text':
|
||||||
data = await response[parseAs]();
|
data = await response[parseAs]();
|
||||||
break;
|
break;
|
||||||
case "stream":
|
case 'stream':
|
||||||
return opts.responseStyle === "data"
|
return opts.responseStyle === 'data'
|
||||||
? response.body
|
? response.body
|
||||||
: {
|
: {
|
||||||
data: response.body,
|
data: response.body,
|
||||||
|
|
@ -195,7 +195,7 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseAs === "json") {
|
if (parseAs === 'json') {
|
||||||
if (opts.responseValidator) {
|
if (opts.responseValidator) {
|
||||||
await opts.responseValidator(data);
|
await opts.responseValidator(data);
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +205,7 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return opts.responseStyle === "data"
|
return opts.responseStyle === 'data'
|
||||||
? data
|
? data
|
||||||
: {
|
: {
|
||||||
data,
|
data,
|
||||||
|
|
@ -238,7 +238,7 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: we probably want to return error and improve types
|
// TODO: we probably want to return error and improve types
|
||||||
return opts.responseStyle === "data"
|
return opts.responseStyle === 'data'
|
||||||
? undefined
|
? undefined
|
||||||
: {
|
: {
|
||||||
error: finalError,
|
error: finalError,
|
||||||
|
|
@ -267,35 +267,39 @@ export const createClient = (config: Config = {}): Client => {
|
||||||
}
|
}
|
||||||
return request;
|
return request;
|
||||||
},
|
},
|
||||||
|
serializedBody: getValidRequestBody(opts) as
|
||||||
|
| BodyInit
|
||||||
|
| null
|
||||||
|
| undefined,
|
||||||
url,
|
url,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
buildUrl,
|
buildUrl,
|
||||||
connect: makeMethodFn("CONNECT"),
|
connect: makeMethodFn('CONNECT'),
|
||||||
delete: makeMethodFn("DELETE"),
|
delete: makeMethodFn('DELETE'),
|
||||||
get: makeMethodFn("GET"),
|
get: makeMethodFn('GET'),
|
||||||
getConfig,
|
getConfig,
|
||||||
head: makeMethodFn("HEAD"),
|
head: makeMethodFn('HEAD'),
|
||||||
interceptors,
|
interceptors,
|
||||||
options: makeMethodFn("OPTIONS"),
|
options: makeMethodFn('OPTIONS'),
|
||||||
patch: makeMethodFn("PATCH"),
|
patch: makeMethodFn('PATCH'),
|
||||||
post: makeMethodFn("POST"),
|
post: makeMethodFn('POST'),
|
||||||
put: makeMethodFn("PUT"),
|
put: makeMethodFn('PUT'),
|
||||||
request,
|
request,
|
||||||
setConfig,
|
setConfig,
|
||||||
sse: {
|
sse: {
|
||||||
connect: makeSseFn("CONNECT"),
|
connect: makeSseFn('CONNECT'),
|
||||||
delete: makeSseFn("DELETE"),
|
delete: makeSseFn('DELETE'),
|
||||||
get: makeSseFn("GET"),
|
get: makeSseFn('GET'),
|
||||||
head: makeSseFn("HEAD"),
|
head: makeSseFn('HEAD'),
|
||||||
options: makeSseFn("OPTIONS"),
|
options: makeSseFn('OPTIONS'),
|
||||||
patch: makeSseFn("PATCH"),
|
patch: makeSseFn('PATCH'),
|
||||||
post: makeSseFn("POST"),
|
post: makeSseFn('POST'),
|
||||||
put: makeSseFn("PUT"),
|
put: makeSseFn('PUT'),
|
||||||
trace: makeSseFn("TRACE"),
|
trace: makeSseFn('TRACE'),
|
||||||
},
|
},
|
||||||
trace: makeMethodFn("TRACE"),
|
trace: makeMethodFn('TRACE'),
|
||||||
} as Client;
|
} as Client;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
export type { Auth } from "../core/auth.gen";
|
export type { Auth } from '../core/auth.gen';
|
||||||
export type { QuerySerializerOptions } from "../core/bodySerializer.gen";
|
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
||||||
export {
|
export {
|
||||||
formDataBodySerializer,
|
formDataBodySerializer,
|
||||||
jsonBodySerializer,
|
jsonBodySerializer,
|
||||||
urlSearchParamsBodySerializer,
|
urlSearchParamsBodySerializer,
|
||||||
} from "../core/bodySerializer.gen";
|
} from '../core/bodySerializer.gen';
|
||||||
export { buildClientParams } from "../core/params.gen";
|
export { buildClientParams } from '../core/params.gen';
|
||||||
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen";
|
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
||||||
export { createClient } from "./client.gen";
|
export { createClient } from './client.gen';
|
||||||
export type {
|
export type {
|
||||||
Client,
|
Client,
|
||||||
ClientOptions,
|
ClientOptions,
|
||||||
|
|
@ -21,5 +21,5 @@ export type {
|
||||||
ResolvedRequestOptions,
|
ResolvedRequestOptions,
|
||||||
ResponseStyle,
|
ResponseStyle,
|
||||||
TDataShape,
|
TDataShape,
|
||||||
} from "./types.gen";
|
} from './types.gen';
|
||||||
export { createConfig, mergeHeaders } from "./utils.gen";
|
export { createConfig, mergeHeaders } from './utils.gen';
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import type { Auth } from "../core/auth.gen";
|
import type { Auth } from '../core/auth.gen';
|
||||||
import type {
|
import type {
|
||||||
ServerSentEventsOptions,
|
ServerSentEventsOptions,
|
||||||
ServerSentEventsResult,
|
ServerSentEventsResult,
|
||||||
} from "../core/serverSentEvents.gen";
|
} from '../core/serverSentEvents.gen';
|
||||||
import type {
|
import type {
|
||||||
Client as CoreClient,
|
Client as CoreClient,
|
||||||
Config as CoreConfig,
|
Config as CoreConfig,
|
||||||
} from "../core/types.gen";
|
} from '../core/types.gen';
|
||||||
import type { Middleware } from "./utils.gen";
|
import type { Middleware } from './utils.gen';
|
||||||
|
|
||||||
export type ResponseStyle = "data" | "fields";
|
export type ResponseStyle = 'data' | 'fields';
|
||||||
|
|
||||||
export interface Config<T extends ClientOptions = ClientOptions>
|
export interface Config<T extends ClientOptions = ClientOptions>
|
||||||
extends Omit<RequestInit, "body" | "headers" | "method">,
|
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
|
||||||
CoreConfig {
|
CoreConfig {
|
||||||
/**
|
/**
|
||||||
* Base URL for all requests made by this client.
|
* Base URL for all requests made by this client.
|
||||||
*/
|
*/
|
||||||
baseUrl?: T["baseUrl"];
|
baseUrl?: T['baseUrl'];
|
||||||
/**
|
/**
|
||||||
* Fetch API implementation. You can use this option to provide a custom
|
* Fetch API implementation. You can use this option to provide a custom
|
||||||
* fetch instance.
|
* fetch instance.
|
||||||
|
|
@ -43,13 +43,13 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
||||||
* @default 'auto'
|
* @default 'auto'
|
||||||
*/
|
*/
|
||||||
parseAs?:
|
parseAs?:
|
||||||
| "arrayBuffer"
|
| 'arrayBuffer'
|
||||||
| "auto"
|
| 'auto'
|
||||||
| "blob"
|
| 'blob'
|
||||||
| "formData"
|
| 'formData'
|
||||||
| "json"
|
| 'json'
|
||||||
| "stream"
|
| 'stream'
|
||||||
| "text";
|
| 'text';
|
||||||
/**
|
/**
|
||||||
* Should we return only data or multiple fields (data, error, response, etc.)?
|
* Should we return only data or multiple fields (data, error, response, etc.)?
|
||||||
*
|
*
|
||||||
|
|
@ -61,12 +61,12 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
||||||
*
|
*
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
throwOnError?: T["throwOnError"];
|
throwOnError?: T['throwOnError'];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RequestOptions<
|
export interface RequestOptions<
|
||||||
TData = unknown,
|
TData = unknown,
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
ThrowOnError extends boolean = boolean,
|
ThrowOnError extends boolean = boolean,
|
||||||
Url extends string = string,
|
Url extends string = string,
|
||||||
> extends Config<{
|
> extends Config<{
|
||||||
|
|
@ -75,11 +75,11 @@ export interface RequestOptions<
|
||||||
}>,
|
}>,
|
||||||
Pick<
|
Pick<
|
||||||
ServerSentEventsOptions<TData>,
|
ServerSentEventsOptions<TData>,
|
||||||
| "onSseError"
|
| 'onSseError'
|
||||||
| "onSseEvent"
|
| 'onSseEvent'
|
||||||
| "sseDefaultRetryDelay"
|
| 'sseDefaultRetryDelay'
|
||||||
| "sseMaxRetryAttempts"
|
| 'sseMaxRetryAttempts'
|
||||||
| "sseMaxRetryDelay"
|
| 'sseMaxRetryDelay'
|
||||||
> {
|
> {
|
||||||
/**
|
/**
|
||||||
* Any body that you want to add to your request.
|
* Any body that you want to add to your request.
|
||||||
|
|
@ -97,7 +97,7 @@ export interface RequestOptions<
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResolvedRequestOptions<
|
export interface ResolvedRequestOptions<
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
ThrowOnError extends boolean = boolean,
|
ThrowOnError extends boolean = boolean,
|
||||||
Url extends string = string,
|
Url extends string = string,
|
||||||
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
||||||
|
|
@ -108,10 +108,10 @@ export type RequestResult<
|
||||||
TData = unknown,
|
TData = unknown,
|
||||||
TError = unknown,
|
TError = unknown,
|
||||||
ThrowOnError extends boolean = boolean,
|
ThrowOnError extends boolean = boolean,
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
> = ThrowOnError extends true
|
> = ThrowOnError extends true
|
||||||
? Promise<
|
? Promise<
|
||||||
TResponseStyle extends "data"
|
TResponseStyle extends 'data'
|
||||||
? TData extends Record<string, unknown>
|
? TData extends Record<string, unknown>
|
||||||
? TData[keyof TData]
|
? TData[keyof TData]
|
||||||
: TData
|
: TData
|
||||||
|
|
@ -124,7 +124,7 @@ export type RequestResult<
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
: Promise<
|
: Promise<
|
||||||
TResponseStyle extends "data"
|
TResponseStyle extends 'data'
|
||||||
?
|
?
|
||||||
| (TData extends Record<string, unknown>
|
| (TData extends Record<string, unknown>
|
||||||
? TData[keyof TData]
|
? TData[keyof TData]
|
||||||
|
|
@ -159,30 +159,30 @@ type MethodFn = <
|
||||||
TData = unknown,
|
TData = unknown,
|
||||||
TError = unknown,
|
TError = unknown,
|
||||||
ThrowOnError extends boolean = false,
|
ThrowOnError extends boolean = false,
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
>(
|
>(
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
|
||||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
||||||
|
|
||||||
type SseFn = <
|
type SseFn = <
|
||||||
TData = unknown,
|
TData = unknown,
|
||||||
TError = unknown,
|
TError = unknown,
|
||||||
ThrowOnError extends boolean = false,
|
ThrowOnError extends boolean = false,
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
>(
|
>(
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">,
|
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
|
||||||
) => Promise<ServerSentEventsResult<TData, TError>>;
|
) => Promise<ServerSentEventsResult<TData, TError>>;
|
||||||
|
|
||||||
type RequestFn = <
|
type RequestFn = <
|
||||||
TData = unknown,
|
TData = unknown,
|
||||||
TError = unknown,
|
TError = unknown,
|
||||||
ThrowOnError extends boolean = false,
|
ThrowOnError extends boolean = false,
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
>(
|
>(
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method"> &
|
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
|
||||||
Pick<
|
Pick<
|
||||||
Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
|
Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
|
||||||
"method"
|
'method'
|
||||||
>,
|
>,
|
||||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
||||||
|
|
||||||
|
|
@ -233,9 +233,9 @@ export type Options<
|
||||||
TData extends TDataShape = TDataShape,
|
TData extends TDataShape = TDataShape,
|
||||||
ThrowOnError extends boolean = boolean,
|
ThrowOnError extends boolean = boolean,
|
||||||
TResponse = unknown,
|
TResponse = unknown,
|
||||||
TResponseStyle extends ResponseStyle = "fields",
|
TResponseStyle extends ResponseStyle = 'fields',
|
||||||
> = OmitKeys<
|
> = OmitKeys<
|
||||||
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
||||||
"body" | "path" | "query" | "url"
|
'body' | 'path' | 'query' | 'url'
|
||||||
> &
|
> &
|
||||||
([TData] extends [never] ? unknown : Omit<TData, "url">);
|
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,15 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import { getAuthToken } from "../core/auth.gen";
|
import { getAuthToken } from '../core/auth.gen';
|
||||||
import type { QuerySerializerOptions } from "../core/bodySerializer.gen";
|
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
||||||
import { jsonBodySerializer } from "../core/bodySerializer.gen";
|
import { jsonBodySerializer } from '../core/bodySerializer.gen';
|
||||||
import {
|
import {
|
||||||
serializeArrayParam,
|
serializeArrayParam,
|
||||||
serializeObjectParam,
|
serializeObjectParam,
|
||||||
serializePrimitiveParam,
|
serializePrimitiveParam,
|
||||||
} from "../core/pathSerializer.gen";
|
} from '../core/pathSerializer.gen';
|
||||||
import { getUrl } from "../core/utils.gen";
|
import { getUrl } from '../core/utils.gen';
|
||||||
import type {
|
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
||||||
Client,
|
|
||||||
ClientOptions,
|
|
||||||
Config,
|
|
||||||
RequestOptions,
|
|
||||||
} from "./types.gen";
|
|
||||||
|
|
||||||
export const createQuerySerializer = <T = unknown>({
|
export const createQuerySerializer = <T = unknown>({
|
||||||
parameters = {},
|
parameters = {},
|
||||||
|
|
@ -22,7 +17,7 @@ export const createQuerySerializer = <T = unknown>({
|
||||||
}: QuerySerializerOptions = {}) => {
|
}: QuerySerializerOptions = {}) => {
|
||||||
const querySerializer = (queryParams: T) => {
|
const querySerializer = (queryParams: T) => {
|
||||||
const search: string[] = [];
|
const search: string[] = [];
|
||||||
if (queryParams && typeof queryParams === "object") {
|
if (queryParams && typeof queryParams === 'object') {
|
||||||
for (const name in queryParams) {
|
for (const name in queryParams) {
|
||||||
const value = queryParams[name];
|
const value = queryParams[name];
|
||||||
|
|
||||||
|
|
@ -37,17 +32,17 @@ export const createQuerySerializer = <T = unknown>({
|
||||||
allowReserved: options.allowReserved,
|
allowReserved: options.allowReserved,
|
||||||
explode: true,
|
explode: true,
|
||||||
name,
|
name,
|
||||||
style: "form",
|
style: 'form',
|
||||||
value,
|
value,
|
||||||
...options.array,
|
...options.array,
|
||||||
});
|
});
|
||||||
if (serializedArray) search.push(serializedArray);
|
if (serializedArray) search.push(serializedArray);
|
||||||
} else if (typeof value === "object") {
|
} else if (typeof value === 'object') {
|
||||||
const serializedObject = serializeObjectParam({
|
const serializedObject = serializeObjectParam({
|
||||||
allowReserved: options.allowReserved,
|
allowReserved: options.allowReserved,
|
||||||
explode: true,
|
explode: true,
|
||||||
name,
|
name,
|
||||||
style: "deepObject",
|
style: 'deepObject',
|
||||||
value: value as Record<string, unknown>,
|
value: value as Record<string, unknown>,
|
||||||
...options.object,
|
...options.object,
|
||||||
});
|
});
|
||||||
|
|
@ -62,7 +57,7 @@ export const createQuerySerializer = <T = unknown>({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return search.join("&");
|
return search.join('&');
|
||||||
};
|
};
|
||||||
return querySerializer;
|
return querySerializer;
|
||||||
};
|
};
|
||||||
|
|
@ -72,47 +67,47 @@ export const createQuerySerializer = <T = unknown>({
|
||||||
*/
|
*/
|
||||||
export const getParseAs = (
|
export const getParseAs = (
|
||||||
contentType: string | null,
|
contentType: string | null,
|
||||||
): Exclude<Config["parseAs"], "auto"> => {
|
): Exclude<Config['parseAs'], 'auto'> => {
|
||||||
if (!contentType) {
|
if (!contentType) {
|
||||||
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
||||||
// which is effectively the same as the 'stream' option.
|
// which is effectively the same as the 'stream' option.
|
||||||
return "stream";
|
return 'stream';
|
||||||
}
|
}
|
||||||
|
|
||||||
const cleanContent = contentType.split(";")[0]?.trim();
|
const cleanContent = contentType.split(';')[0]?.trim();
|
||||||
|
|
||||||
if (!cleanContent) {
|
if (!cleanContent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
cleanContent.startsWith("application/json") ||
|
cleanContent.startsWith('application/json') ||
|
||||||
cleanContent.endsWith("+json")
|
cleanContent.endsWith('+json')
|
||||||
) {
|
) {
|
||||||
return "json";
|
return 'json';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cleanContent === "multipart/form-data") {
|
if (cleanContent === 'multipart/form-data') {
|
||||||
return "formData";
|
return 'formData';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
["application/", "audio/", "image/", "video/"].some((type) =>
|
['application/', 'audio/', 'image/', 'video/'].some((type) =>
|
||||||
cleanContent.startsWith(type),
|
cleanContent.startsWith(type),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return "blob";
|
return 'blob';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cleanContent.startsWith("text/")) {
|
if (cleanContent.startsWith('text/')) {
|
||||||
return "text";
|
return 'text';
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkForExistence = (
|
const checkForExistence = (
|
||||||
options: Pick<RequestOptions, "auth" | "query"> & {
|
options: Pick<RequestOptions, 'auth' | 'query'> & {
|
||||||
headers: Headers;
|
headers: Headers;
|
||||||
},
|
},
|
||||||
name?: string,
|
name?: string,
|
||||||
|
|
@ -123,7 +118,7 @@ const checkForExistence = (
|
||||||
if (
|
if (
|
||||||
options.headers.has(name) ||
|
options.headers.has(name) ||
|
||||||
options.query?.[name] ||
|
options.query?.[name] ||
|
||||||
options.headers.get("Cookie")?.includes(`${name}=`)
|
options.headers.get('Cookie')?.includes(`${name}=`)
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -133,8 +128,8 @@ const checkForExistence = (
|
||||||
export const setAuthParams = async ({
|
export const setAuthParams = async ({
|
||||||
security,
|
security,
|
||||||
...options
|
...options
|
||||||
}: Pick<Required<RequestOptions>, "security"> &
|
}: Pick<Required<RequestOptions>, 'security'> &
|
||||||
Pick<RequestOptions, "auth" | "query"> & {
|
Pick<RequestOptions, 'auth' | 'query'> & {
|
||||||
headers: Headers;
|
headers: Headers;
|
||||||
}) => {
|
}) => {
|
||||||
for (const auth of security) {
|
for (const auth of security) {
|
||||||
|
|
@ -148,19 +143,19 @@ export const setAuthParams = async ({
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = auth.name ?? "Authorization";
|
const name = auth.name ?? 'Authorization';
|
||||||
|
|
||||||
switch (auth.in) {
|
switch (auth.in) {
|
||||||
case "query":
|
case 'query':
|
||||||
if (!options.query) {
|
if (!options.query) {
|
||||||
options.query = {};
|
options.query = {};
|
||||||
}
|
}
|
||||||
options.query[name] = token;
|
options.query[name] = token;
|
||||||
break;
|
break;
|
||||||
case "cookie":
|
case 'cookie':
|
||||||
options.headers.append("Cookie", `${name}=${token}`);
|
options.headers.append('Cookie', `${name}=${token}`);
|
||||||
break;
|
break;
|
||||||
case "header":
|
case 'header':
|
||||||
default:
|
default:
|
||||||
options.headers.set(name, token);
|
options.headers.set(name, token);
|
||||||
break;
|
break;
|
||||||
|
|
@ -168,13 +163,13 @@ export const setAuthParams = async ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildUrl: Client["buildUrl"] = (options) =>
|
export const buildUrl: Client['buildUrl'] = (options) =>
|
||||||
getUrl({
|
getUrl({
|
||||||
baseUrl: options.baseUrl as string,
|
baseUrl: options.baseUrl as string,
|
||||||
path: options.path,
|
path: options.path,
|
||||||
query: options.query,
|
query: options.query,
|
||||||
querySerializer:
|
querySerializer:
|
||||||
typeof options.querySerializer === "function"
|
typeof options.querySerializer === 'function'
|
||||||
? options.querySerializer
|
? options.querySerializer
|
||||||
: createQuerySerializer(options.querySerializer),
|
: createQuerySerializer(options.querySerializer),
|
||||||
url: options.url,
|
url: options.url,
|
||||||
|
|
@ -182,7 +177,7 @@ export const buildUrl: Client["buildUrl"] = (options) =>
|
||||||
|
|
||||||
export const mergeConfigs = (a: Config, b: Config): Config => {
|
export const mergeConfigs = (a: Config, b: Config): Config => {
|
||||||
const config = { ...a, ...b };
|
const config = { ...a, ...b };
|
||||||
if (config.baseUrl?.endsWith("/")) {
|
if (config.baseUrl?.endsWith('/')) {
|
||||||
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
||||||
}
|
}
|
||||||
config.headers = mergeHeaders(a.headers, b.headers);
|
config.headers = mergeHeaders(a.headers, b.headers);
|
||||||
|
|
@ -198,7 +193,7 @@ const headersEntries = (headers: Headers): Array<[string, string]> => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mergeHeaders = (
|
export const mergeHeaders = (
|
||||||
...headers: Array<Required<Config>["headers"] | undefined>
|
...headers: Array<Required<Config>['headers'] | undefined>
|
||||||
): Headers => {
|
): Headers => {
|
||||||
const mergedHeaders = new Headers();
|
const mergedHeaders = new Headers();
|
||||||
for (const header of headers) {
|
for (const header of headers) {
|
||||||
|
|
@ -223,7 +218,7 @@ export const mergeHeaders = (
|
||||||
// content value in OpenAPI specification is 'application/json'
|
// content value in OpenAPI specification is 'application/json'
|
||||||
mergedHeaders.set(
|
mergedHeaders.set(
|
||||||
key,
|
key,
|
||||||
typeof value === "object" ? JSON.stringify(value) : (value as string),
|
typeof value === 'object' ? JSON.stringify(value) : (value as string),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +264,7 @@ class Interceptors<Interceptor> {
|
||||||
}
|
}
|
||||||
|
|
||||||
getInterceptorIndex(id: number | Interceptor): number {
|
getInterceptorIndex(id: number | Interceptor): number {
|
||||||
if (typeof id === "number") {
|
if (typeof id === 'number') {
|
||||||
return this.fns[id] ? id : -1;
|
return this.fns[id] ? id : -1;
|
||||||
}
|
}
|
||||||
return this.fns.indexOf(id);
|
return this.fns.indexOf(id);
|
||||||
|
|
@ -314,16 +309,16 @@ const defaultQuerySerializer = createQuerySerializer({
|
||||||
allowReserved: false,
|
allowReserved: false,
|
||||||
array: {
|
array: {
|
||||||
explode: true,
|
explode: true,
|
||||||
style: "form",
|
style: 'form',
|
||||||
},
|
},
|
||||||
object: {
|
object: {
|
||||||
explode: true,
|
explode: true,
|
||||||
style: "deepObject",
|
style: 'deepObject',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const defaultHeaders = {
|
const defaultHeaders = {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
||||||
|
|
@ -331,7 +326,7 @@ export const createConfig = <T extends ClientOptions = ClientOptions>(
|
||||||
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
||||||
...jsonBodySerializer,
|
...jsonBodySerializer,
|
||||||
headers: defaultHeaders,
|
headers: defaultHeaders,
|
||||||
parseAs: "auto",
|
parseAs: 'auto',
|
||||||
querySerializer: defaultQuerySerializer,
|
querySerializer: defaultQuerySerializer,
|
||||||
...override,
|
...override,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,15 @@ export interface Auth {
|
||||||
*
|
*
|
||||||
* @default 'header'
|
* @default 'header'
|
||||||
*/
|
*/
|
||||||
in?: "header" | "query" | "cookie";
|
in?: 'header' | 'query' | 'cookie';
|
||||||
/**
|
/**
|
||||||
* Header or query parameter name.
|
* Header or query parameter name.
|
||||||
*
|
*
|
||||||
* @default 'Authorization'
|
* @default 'Authorization'
|
||||||
*/
|
*/
|
||||||
name?: string;
|
name?: string;
|
||||||
scheme?: "basic" | "bearer";
|
scheme?: 'basic' | 'bearer';
|
||||||
type: "apiKey" | "http";
|
type: 'apiKey' | 'http';
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getAuthToken = async (
|
export const getAuthToken = async (
|
||||||
|
|
@ -24,17 +24,17 @@ export const getAuthToken = async (
|
||||||
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
||||||
): Promise<string | undefined> => {
|
): Promise<string | undefined> => {
|
||||||
const token =
|
const token =
|
||||||
typeof callback === "function" ? await callback(auth) : callback;
|
typeof callback === 'function' ? await callback(auth) : callback;
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth.scheme === "bearer") {
|
if (auth.scheme === 'bearer') {
|
||||||
return `Bearer ${token}`;
|
return `Bearer ${token}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth.scheme === "basic") {
|
if (auth.scheme === 'basic') {
|
||||||
return `Basic ${btoa(token)}`;
|
return `Basic ${btoa(token)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import type {
|
||||||
ArrayStyle,
|
ArrayStyle,
|
||||||
ObjectStyle,
|
ObjectStyle,
|
||||||
SerializerOptions,
|
SerializerOptions,
|
||||||
} from "./pathSerializer.gen";
|
} from './pathSerializer.gen';
|
||||||
|
|
||||||
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ const serializeFormDataPair = (
|
||||||
key: string,
|
key: string,
|
||||||
value: unknown,
|
value: unknown,
|
||||||
): void => {
|
): void => {
|
||||||
if (typeof value === "string" || value instanceof Blob) {
|
if (typeof value === 'string' || value instanceof Blob) {
|
||||||
data.append(key, value);
|
data.append(key, value);
|
||||||
} else if (value instanceof Date) {
|
} else if (value instanceof Date) {
|
||||||
data.append(key, value.toISOString());
|
data.append(key, value.toISOString());
|
||||||
|
|
@ -43,7 +43,7 @@ const serializeUrlSearchParamsPair = (
|
||||||
key: string,
|
key: string,
|
||||||
value: unknown,
|
value: unknown,
|
||||||
): void => {
|
): void => {
|
||||||
if (typeof value === "string") {
|
if (typeof value === 'string') {
|
||||||
data.append(key, value);
|
data.append(key, value);
|
||||||
} else {
|
} else {
|
||||||
data.append(key, JSON.stringify(value));
|
data.append(key, JSON.stringify(value));
|
||||||
|
|
@ -74,7 +74,7 @@ export const formDataBodySerializer = {
|
||||||
export const jsonBodySerializer = {
|
export const jsonBodySerializer = {
|
||||||
bodySerializer: <T>(body: T): string =>
|
bodySerializer: <T>(body: T): string =>
|
||||||
JSON.stringify(body, (_key, value) =>
|
JSON.stringify(body, (_key, value) =>
|
||||||
typeof value === "bigint" ? value.toString() : value,
|
typeof value === 'bigint' ? value.toString() : value,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
type Slot = "body" | "headers" | "path" | "query";
|
type Slot = 'body' | 'headers' | 'path' | 'query';
|
||||||
|
|
||||||
export type Field =
|
export type Field =
|
||||||
| {
|
| {
|
||||||
in: Exclude<Slot, "body">;
|
in: Exclude<Slot, 'body'>;
|
||||||
/**
|
/**
|
||||||
* Field name. This is the name we want the user to see and use.
|
* Field name. This is the name we want the user to see and use.
|
||||||
*/
|
*/
|
||||||
|
|
@ -16,7 +16,7 @@ export type Field =
|
||||||
map?: string;
|
map?: string;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
in: Extract<Slot, "body">;
|
in: Extract<Slot, 'body'>;
|
||||||
/**
|
/**
|
||||||
* Key isn't required for bodies.
|
* Key isn't required for bodies.
|
||||||
*/
|
*/
|
||||||
|
|
@ -43,10 +43,10 @@ export interface Fields {
|
||||||
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
||||||
|
|
||||||
const extraPrefixesMap: Record<string, Slot> = {
|
const extraPrefixesMap: Record<string, Slot> = {
|
||||||
$body_: "body",
|
$body_: 'body',
|
||||||
$headers_: "headers",
|
$headers_: 'headers',
|
||||||
$path_: "path",
|
$path_: 'path',
|
||||||
$query_: "query",
|
$query_: 'query',
|
||||||
};
|
};
|
||||||
const extraPrefixes = Object.entries(extraPrefixesMap);
|
const extraPrefixes = Object.entries(extraPrefixesMap);
|
||||||
|
|
||||||
|
|
@ -68,14 +68,14 @@ const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const config of fields) {
|
for (const config of fields) {
|
||||||
if ("in" in config) {
|
if ('in' in config) {
|
||||||
if (config.key) {
|
if (config.key) {
|
||||||
map.set(config.key, {
|
map.set(config.key, {
|
||||||
in: config.in,
|
in: config.in,
|
||||||
map: config.map,
|
map: config.map,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if ("key" in config) {
|
} else if ('key' in config) {
|
||||||
map.set(config.key, {
|
map.set(config.key, {
|
||||||
map: config.map,
|
map: config.map,
|
||||||
});
|
});
|
||||||
|
|
@ -96,7 +96,7 @@ interface Params {
|
||||||
|
|
||||||
const stripEmptySlots = (params: Params) => {
|
const stripEmptySlots = (params: Params) => {
|
||||||
for (const [slot, value] of Object.entries(params)) {
|
for (const [slot, value] of Object.entries(params)) {
|
||||||
if (value && typeof value === "object" && !Object.keys(value).length) {
|
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
||||||
delete params[slot as Slot];
|
delete params[slot as Slot];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +126,7 @@ export const buildClientParams = (
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("in" in config) {
|
if ('in' in config) {
|
||||||
if (config.key) {
|
if (config.key) {
|
||||||
const field = map.get(config.key)!;
|
const field = map.get(config.key)!;
|
||||||
const name = field.map || config.key;
|
const name = field.map || config.key;
|
||||||
|
|
@ -157,7 +157,7 @@ export const buildClientParams = (
|
||||||
(params[slot] as Record<string, unknown>)[
|
(params[slot] as Record<string, unknown>)[
|
||||||
key.slice(prefix.length)
|
key.slice(prefix.length)
|
||||||
] = value;
|
] = value;
|
||||||
} else if ("allowExtra" in config && config.allowExtra) {
|
} else if ('allowExtra' in config && config.allowExtra) {
|
||||||
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ export interface SerializerOptions<T> {
|
||||||
style: T;
|
style: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited";
|
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
||||||
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
||||||
type MatrixStyle = "label" | "matrix" | "simple";
|
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
||||||
export type ObjectStyle = "form" | "deepObject";
|
export type ObjectStyle = 'form' | 'deepObject';
|
||||||
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
||||||
|
|
||||||
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
||||||
|
|
@ -29,40 +29,40 @@ interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
||||||
|
|
||||||
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case "label":
|
case 'label':
|
||||||
return ".";
|
return '.';
|
||||||
case "matrix":
|
case 'matrix':
|
||||||
return ";";
|
return ';';
|
||||||
case "simple":
|
case 'simple':
|
||||||
return ",";
|
return ',';
|
||||||
default:
|
default:
|
||||||
return "&";
|
return '&';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case "form":
|
case 'form':
|
||||||
return ",";
|
return ',';
|
||||||
case "pipeDelimited":
|
case 'pipeDelimited':
|
||||||
return "|";
|
return '|';
|
||||||
case "spaceDelimited":
|
case 'spaceDelimited':
|
||||||
return "%20";
|
return '%20';
|
||||||
default:
|
default:
|
||||||
return ",";
|
return ',';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case "label":
|
case 'label':
|
||||||
return ".";
|
return '.';
|
||||||
case "matrix":
|
case 'matrix':
|
||||||
return ";";
|
return ';';
|
||||||
case "simple":
|
case 'simple':
|
||||||
return ",";
|
return ',';
|
||||||
default:
|
default:
|
||||||
return "&";
|
return '&';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -80,11 +80,11 @@ export const serializeArrayParam = ({
|
||||||
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
||||||
).join(separatorArrayNoExplode(style));
|
).join(separatorArrayNoExplode(style));
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case "label":
|
case 'label':
|
||||||
return `.${joinedValues}`;
|
return `.${joinedValues}`;
|
||||||
case "matrix":
|
case 'matrix':
|
||||||
return `;${name}=${joinedValues}`;
|
return `;${name}=${joinedValues}`;
|
||||||
case "simple":
|
case 'simple':
|
||||||
return joinedValues;
|
return joinedValues;
|
||||||
default:
|
default:
|
||||||
return `${name}=${joinedValues}`;
|
return `${name}=${joinedValues}`;
|
||||||
|
|
@ -94,7 +94,7 @@ export const serializeArrayParam = ({
|
||||||
const separator = separatorArrayExplode(style);
|
const separator = separatorArrayExplode(style);
|
||||||
const joinedValues = value
|
const joinedValues = value
|
||||||
.map((v) => {
|
.map((v) => {
|
||||||
if (style === "label" || style === "simple") {
|
if (style === 'label' || style === 'simple') {
|
||||||
return allowReserved ? v : encodeURIComponent(v as string);
|
return allowReserved ? v : encodeURIComponent(v as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ export const serializeArrayParam = ({
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.join(separator);
|
.join(separator);
|
||||||
return style === "label" || style === "matrix"
|
return style === 'label' || style === 'matrix'
|
||||||
? separator + joinedValues
|
? separator + joinedValues
|
||||||
: joinedValues;
|
: joinedValues;
|
||||||
};
|
};
|
||||||
|
|
@ -116,12 +116,12 @@ export const serializePrimitiveParam = ({
|
||||||
value,
|
value,
|
||||||
}: SerializePrimitiveParam) => {
|
}: SerializePrimitiveParam) => {
|
||||||
if (value === undefined || value === null) {
|
if (value === undefined || value === null) {
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === "object") {
|
if (typeof value === 'object') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.",
|
'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ export const serializeObjectParam = ({
|
||||||
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style !== "deepObject" && !explode) {
|
if (style !== 'deepObject' && !explode) {
|
||||||
let values: string[] = [];
|
let values: string[] = [];
|
||||||
Object.entries(value).forEach(([key, v]) => {
|
Object.entries(value).forEach(([key, v]) => {
|
||||||
values = [
|
values = [
|
||||||
|
|
@ -152,13 +152,13 @@ export const serializeObjectParam = ({
|
||||||
allowReserved ? (v as string) : encodeURIComponent(v as string),
|
allowReserved ? (v as string) : encodeURIComponent(v as string),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
const joinedValues = values.join(",");
|
const joinedValues = values.join(',');
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case "form":
|
case 'form':
|
||||||
return `${name}=${joinedValues}`;
|
return `${name}=${joinedValues}`;
|
||||||
case "label":
|
case 'label':
|
||||||
return `.${joinedValues}`;
|
return `.${joinedValues}`;
|
||||||
case "matrix":
|
case 'matrix':
|
||||||
return `;${name}=${joinedValues}`;
|
return `;${name}=${joinedValues}`;
|
||||||
default:
|
default:
|
||||||
return joinedValues;
|
return joinedValues;
|
||||||
|
|
@ -170,12 +170,12 @@ export const serializeObjectParam = ({
|
||||||
.map(([key, v]) =>
|
.map(([key, v]) =>
|
||||||
serializePrimitiveParam({
|
serializePrimitiveParam({
|
||||||
allowReserved,
|
allowReserved,
|
||||||
name: style === "deepObject" ? `${name}[${key}]` : key,
|
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
||||||
value: v as string,
|
value: v as string,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.join(separator);
|
.join(separator);
|
||||||
return style === "label" || style === "matrix"
|
return style === 'label' || style === 'matrix'
|
||||||
? separator + joinedValues
|
? separator + joinedValues
|
||||||
: joinedValues;
|
: joinedValues;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@ export type JsonValue =
|
||||||
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
||||||
if (
|
if (
|
||||||
value === undefined ||
|
value === undefined ||
|
||||||
typeof value === "function" ||
|
typeof value === 'function' ||
|
||||||
typeof value === "symbol"
|
typeof value === 'symbol'
|
||||||
) {
|
) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (typeof value === "bigint") {
|
if (typeof value === 'bigint') {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
|
|
@ -50,7 +50,7 @@ export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
|
||||||
* Detects plain objects (including objects with a null prototype).
|
* Detects plain objects (including objects with a null prototype).
|
||||||
*/
|
*/
|
||||||
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
||||||
if (value === null || typeof value !== "object") {
|
if (value === null || typeof value !== 'object') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const prototype = Object.getPrototypeOf(value as object);
|
const prototype = Object.getPrototypeOf(value as object);
|
||||||
|
|
@ -94,22 +94,22 @@ export const serializeQueryKeyValue = (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof value === "string" ||
|
typeof value === 'string' ||
|
||||||
typeof value === "number" ||
|
typeof value === 'number' ||
|
||||||
typeof value === "boolean"
|
typeof value === 'boolean'
|
||||||
) {
|
) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
value === undefined ||
|
value === undefined ||
|
||||||
typeof value === "function" ||
|
typeof value === 'function' ||
|
||||||
typeof value === "symbol"
|
typeof value === 'symbol'
|
||||||
) {
|
) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === "bigint") {
|
if (typeof value === 'bigint') {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,7 +122,7 @@ export const serializeQueryKeyValue = (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof URLSearchParams !== "undefined" &&
|
typeof URLSearchParams !== 'undefined' &&
|
||||||
value instanceof URLSearchParams
|
value instanceof URLSearchParams
|
||||||
) {
|
) {
|
||||||
return serializeSearchParams(value);
|
return serializeSearchParams(value);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import type { Config } from "./types.gen";
|
import type { Config } from './types.gen';
|
||||||
|
|
||||||
export type ServerSentEventsOptions<TData = unknown> = Omit<
|
export type ServerSentEventsOptions<TData = unknown> = Omit<
|
||||||
RequestInit,
|
RequestInit,
|
||||||
"method"
|
'method'
|
||||||
> &
|
> &
|
||||||
Pick<Config, "method" | "responseTransformer" | "responseValidator"> & {
|
Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
||||||
/**
|
/**
|
||||||
* Fetch API implementation. You can use this option to provide a custom
|
* Fetch API implementation. You can use this option to provide a custom
|
||||||
* fetch instance.
|
* fetch instance.
|
||||||
|
|
@ -35,7 +35,7 @@ export type ServerSentEventsOptions<TData = unknown> = Omit<
|
||||||
* @returns Nothing (void).
|
* @returns Nothing (void).
|
||||||
*/
|
*/
|
||||||
onSseEvent?: (event: StreamEvent<TData>) => void;
|
onSseEvent?: (event: StreamEvent<TData>) => void;
|
||||||
serializedBody?: RequestInit["body"];
|
serializedBody?: RequestInit['body'];
|
||||||
/**
|
/**
|
||||||
* Default retry delay in milliseconds.
|
* Default retry delay in milliseconds.
|
||||||
*
|
*
|
||||||
|
|
@ -121,12 +121,12 @@ export const createSseClient = <TData = unknown>({
|
||||||
: new Headers(options.headers as Record<string, string> | undefined);
|
: new Headers(options.headers as Record<string, string> | undefined);
|
||||||
|
|
||||||
if (lastEventId !== undefined) {
|
if (lastEventId !== undefined) {
|
||||||
headers.set("Last-Event-ID", lastEventId);
|
headers.set('Last-Event-ID', lastEventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const requestInit: RequestInit = {
|
const requestInit: RequestInit = {
|
||||||
redirect: "follow",
|
redirect: 'follow',
|
||||||
...options,
|
...options,
|
||||||
body: options.serializedBody,
|
body: options.serializedBody,
|
||||||
headers,
|
headers,
|
||||||
|
|
@ -146,13 +146,13 @@ export const createSseClient = <TData = unknown>({
|
||||||
`SSE failed: ${response.status} ${response.statusText}`,
|
`SSE failed: ${response.status} ${response.statusText}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!response.body) throw new Error("No body in SSE response");
|
if (!response.body) throw new Error('No body in SSE response');
|
||||||
|
|
||||||
const reader = response.body
|
const reader = response.body
|
||||||
.pipeThrough(new TextDecoderStream())
|
.pipeThrough(new TextDecoderStream())
|
||||||
.getReader();
|
.getReader();
|
||||||
|
|
||||||
let buffer = "";
|
let buffer = '';
|
||||||
|
|
||||||
const abortHandler = () => {
|
const abortHandler = () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -162,7 +162,7 @@ export const createSseClient = <TData = unknown>({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
signal.addEventListener("abort", abortHandler);
|
signal.addEventListener('abort', abortHandler);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
@ -170,26 +170,26 @@ export const createSseClient = <TData = unknown>({
|
||||||
if (done) break;
|
if (done) break;
|
||||||
buffer += value;
|
buffer += value;
|
||||||
// Normalize line endings: CRLF -> LF, then CR -> LF
|
// Normalize line endings: CRLF -> LF, then CR -> LF
|
||||||
buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||||
|
|
||||||
const chunks = buffer.split("\n\n");
|
const chunks = buffer.split('\n\n');
|
||||||
buffer = chunks.pop() ?? "";
|
buffer = chunks.pop() ?? '';
|
||||||
|
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
const lines = chunk.split("\n");
|
const lines = chunk.split('\n');
|
||||||
const dataLines: Array<string> = [];
|
const dataLines: Array<string> = [];
|
||||||
let eventName: string | undefined;
|
let eventName: string | undefined;
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.startsWith("data:")) {
|
if (line.startsWith('data:')) {
|
||||||
dataLines.push(line.replace(/^data:\s*/, ""));
|
dataLines.push(line.replace(/^data:\s*/, ''));
|
||||||
} else if (line.startsWith("event:")) {
|
} else if (line.startsWith('event:')) {
|
||||||
eventName = line.replace(/^event:\s*/, "");
|
eventName = line.replace(/^event:\s*/, '');
|
||||||
} else if (line.startsWith("id:")) {
|
} else if (line.startsWith('id:')) {
|
||||||
lastEventId = line.replace(/^id:\s*/, "");
|
lastEventId = line.replace(/^id:\s*/, '');
|
||||||
} else if (line.startsWith("retry:")) {
|
} else if (line.startsWith('retry:')) {
|
||||||
const parsed = Number.parseInt(
|
const parsed = Number.parseInt(
|
||||||
line.replace(/^retry:\s*/, ""),
|
line.replace(/^retry:\s*/, ''),
|
||||||
10,
|
10,
|
||||||
);
|
);
|
||||||
if (!Number.isNaN(parsed)) {
|
if (!Number.isNaN(parsed)) {
|
||||||
|
|
@ -202,7 +202,7 @@ export const createSseClient = <TData = unknown>({
|
||||||
let parsedJson = false;
|
let parsedJson = false;
|
||||||
|
|
||||||
if (dataLines.length) {
|
if (dataLines.length) {
|
||||||
const rawData = dataLines.join("\n");
|
const rawData = dataLines.join('\n');
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(rawData);
|
data = JSON.parse(rawData);
|
||||||
parsedJson = true;
|
parsedJson = true;
|
||||||
|
|
@ -234,7 +234,7 @@ export const createSseClient = <TData = unknown>({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
signal.removeEventListener("abort", abortHandler);
|
signal.removeEventListener('abort', abortHandler);
|
||||||
reader.releaseLock();
|
reader.releaseLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import type { Auth, AuthToken } from "./auth.gen";
|
import type { Auth, AuthToken } from './auth.gen';
|
||||||
import type {
|
import type {
|
||||||
BodySerializer,
|
BodySerializer,
|
||||||
QuerySerializer,
|
QuerySerializer,
|
||||||
QuerySerializerOptions,
|
QuerySerializerOptions,
|
||||||
} from "./bodySerializer.gen";
|
} from './bodySerializer.gen';
|
||||||
|
|
||||||
export type HttpMethod =
|
export type HttpMethod =
|
||||||
| "connect"
|
| 'connect'
|
||||||
| "delete"
|
| 'delete'
|
||||||
| "get"
|
| 'get'
|
||||||
| "head"
|
| 'head'
|
||||||
| "options"
|
| 'options'
|
||||||
| "patch"
|
| 'patch'
|
||||||
| "post"
|
| 'post'
|
||||||
| "put"
|
| 'put'
|
||||||
| "trace";
|
| 'trace';
|
||||||
|
|
||||||
export type Client<
|
export type Client<
|
||||||
RequestFn = never,
|
RequestFn = never,
|
||||||
|
|
@ -56,7 +56,7 @@ export interface Config {
|
||||||
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
||||||
*/
|
*/
|
||||||
headers?:
|
headers?:
|
||||||
| RequestInit["headers"]
|
| RequestInit['headers']
|
||||||
| Record<
|
| Record<
|
||||||
string,
|
string,
|
||||||
| string
|
| string
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import type { BodySerializer, QuerySerializer } from "./bodySerializer.gen";
|
import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
|
||||||
import {
|
import {
|
||||||
type ArraySeparatorStyle,
|
type ArraySeparatorStyle,
|
||||||
serializeArrayParam,
|
serializeArrayParam,
|
||||||
serializeObjectParam,
|
serializeObjectParam,
|
||||||
serializePrimitiveParam,
|
serializePrimitiveParam,
|
||||||
} from "./pathSerializer.gen";
|
} from './pathSerializer.gen';
|
||||||
|
|
||||||
export interface PathSerializer {
|
export interface PathSerializer {
|
||||||
path: Record<string, unknown>;
|
path: Record<string, unknown>;
|
||||||
|
|
@ -22,19 +22,19 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
let explode = false;
|
let explode = false;
|
||||||
let name = match.substring(1, match.length - 1);
|
let name = match.substring(1, match.length - 1);
|
||||||
let style: ArraySeparatorStyle = "simple";
|
let style: ArraySeparatorStyle = 'simple';
|
||||||
|
|
||||||
if (name.endsWith("*")) {
|
if (name.endsWith('*')) {
|
||||||
explode = true;
|
explode = true;
|
||||||
name = name.substring(0, name.length - 1);
|
name = name.substring(0, name.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.startsWith(".")) {
|
if (name.startsWith('.')) {
|
||||||
name = name.substring(1);
|
name = name.substring(1);
|
||||||
style = "label";
|
style = 'label';
|
||||||
} else if (name.startsWith(";")) {
|
} else if (name.startsWith(';')) {
|
||||||
name = name.substring(1);
|
name = name.substring(1);
|
||||||
style = "matrix";
|
style = 'matrix';
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = path[name];
|
const value = path[name];
|
||||||
|
|
@ -51,7 +51,7 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === "object") {
|
if (typeof value === 'object') {
|
||||||
url = url.replace(
|
url = url.replace(
|
||||||
match,
|
match,
|
||||||
serializeObjectParam({
|
serializeObjectParam({
|
||||||
|
|
@ -65,7 +65,7 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style === "matrix") {
|
if (style === 'matrix') {
|
||||||
url = url.replace(
|
url = url.replace(
|
||||||
match,
|
match,
|
||||||
`;${serializePrimitiveParam({
|
`;${serializePrimitiveParam({
|
||||||
|
|
@ -77,7 +77,7 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const replaceValue = encodeURIComponent(
|
const replaceValue = encodeURIComponent(
|
||||||
style === "label" ? `.${value as string}` : (value as string),
|
style === 'label' ? `.${value as string}` : (value as string),
|
||||||
);
|
);
|
||||||
url = url.replace(match, replaceValue);
|
url = url.replace(match, replaceValue);
|
||||||
}
|
}
|
||||||
|
|
@ -98,13 +98,13 @@ export const getUrl = ({
|
||||||
querySerializer: QuerySerializer;
|
querySerializer: QuerySerializer;
|
||||||
url: string;
|
url: string;
|
||||||
}) => {
|
}) => {
|
||||||
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
||||||
let url = (baseUrl ?? "") + pathUrl;
|
let url = (baseUrl ?? '') + pathUrl;
|
||||||
if (path) {
|
if (path) {
|
||||||
url = defaultPathSerializer({ path, url });
|
url = defaultPathSerializer({ path, url });
|
||||||
}
|
}
|
||||||
let search = query ? querySerializer(query) : "";
|
let search = query ? querySerializer(query) : '';
|
||||||
if (search.startsWith("?")) {
|
if (search.startsWith('?')) {
|
||||||
search = search.substring(1);
|
search = search.substring(1);
|
||||||
}
|
}
|
||||||
if (search) {
|
if (search) {
|
||||||
|
|
@ -122,15 +122,15 @@ export function getValidRequestBody(options: {
|
||||||
const isSerializedBody = hasBody && options.bodySerializer;
|
const isSerializedBody = hasBody && options.bodySerializer;
|
||||||
|
|
||||||
if (isSerializedBody) {
|
if (isSerializedBody) {
|
||||||
if ("serializedBody" in options) {
|
if ('serializedBody' in options) {
|
||||||
const hasSerializedBody =
|
const hasSerializedBody =
|
||||||
options.serializedBody !== undefined && options.serializedBody !== "";
|
options.serializedBody !== undefined && options.serializedBody !== '';
|
||||||
|
|
||||||
return hasSerializedBody ? options.serializedBody : null;
|
return hasSerializedBody ? options.serializedBody : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not all clients implement a serializedBody property (i.e. client-axios)
|
// not all clients implement a serializedBody property (i.e. client-axios)
|
||||||
return options.body !== "" ? options.body : null;
|
return options.body !== '' ? options.body : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// plain/text body
|
// plain/text body
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
export type * from "./types.gen";
|
export { browseFilesystem, createBackupSchedule, createNotificationDestination, createRepository, createVolume, deleteBackupSchedule, deleteNotificationDestination, deleteRepository, deleteSnapshot, deleteSnapshots, deleteVolume, doctorRepository, downloadResticPassword, getBackupSchedule, getBackupScheduleForVolume, getMirrorCompatibility, getNotificationDestination, getRepository, getScheduleMirrors, getScheduleNotifications, getSnapshotDetails, getStatus, getSystemInfo, getUpdates, getVolume, healthCheckVolume, listBackupSchedules, listFiles, listNotificationDestinations, listRcloneRemotes, listRepositories, listSnapshotFiles, listSnapshots, listVolumes, mountVolume, type Options, reorderBackupSchedules, restoreSnapshot, runBackupNow, runForget, stopBackup, tagSnapshots, testConnection, testNotificationDestination, unmountVolume, updateBackupSchedule, updateNotificationDestination, updateRepository, updateScheduleMirrors, updateScheduleNotifications, updateVolume } from './sdk.gen';
|
||||||
export * from "./sdk.gen";
|
export type { BrowseFilesystemData, BrowseFilesystemResponse, BrowseFilesystemResponses, ClientOptions, CreateBackupScheduleData, CreateBackupScheduleResponse, CreateBackupScheduleResponses, CreateNotificationDestinationData, CreateNotificationDestinationResponse, CreateNotificationDestinationResponses, CreateRepositoryData, CreateRepositoryResponse, CreateRepositoryResponses, CreateVolumeData, CreateVolumeResponse, CreateVolumeResponses, DeleteBackupScheduleData, DeleteBackupScheduleResponse, DeleteBackupScheduleResponses, DeleteNotificationDestinationData, DeleteNotificationDestinationErrors, DeleteNotificationDestinationResponse, DeleteNotificationDestinationResponses, DeleteRepositoryData, DeleteRepositoryResponse, DeleteRepositoryResponses, DeleteSnapshotData, DeleteSnapshotResponse, DeleteSnapshotResponses, DeleteSnapshotsData, DeleteSnapshotsResponse, DeleteSnapshotsResponses, DeleteVolumeData, DeleteVolumeResponse, DeleteVolumeResponses, DoctorRepositoryData, DoctorRepositoryResponse, DoctorRepositoryResponses, DownloadResticPasswordData, DownloadResticPasswordResponse, DownloadResticPasswordResponses, GetBackupScheduleData, GetBackupScheduleForVolumeData, GetBackupScheduleForVolumeResponse, GetBackupScheduleForVolumeResponses, GetBackupScheduleResponse, GetBackupScheduleResponses, GetMirrorCompatibilityData, GetMirrorCompatibilityResponse, GetMirrorCompatibilityResponses, GetNotificationDestinationData, GetNotificationDestinationErrors, GetNotificationDestinationResponse, GetNotificationDestinationResponses, GetRepositoryData, GetRepositoryResponse, GetRepositoryResponses, GetScheduleMirrorsData, GetScheduleMirrorsResponse, GetScheduleMirrorsResponses, GetScheduleNotificationsData, GetScheduleNotificationsResponse, GetScheduleNotificationsResponses, GetSnapshotDetailsData, GetSnapshotDetailsResponse, GetSnapshotDetailsResponses, GetStatusData, GetStatusResponse, GetStatusResponses, GetSystemInfoData, GetSystemInfoResponse, GetSystemInfoResponses, GetUpdatesData, GetUpdatesResponse, GetUpdatesResponses, GetVolumeData, GetVolumeErrors, GetVolumeResponse, GetVolumeResponses, HealthCheckVolumeData, HealthCheckVolumeErrors, HealthCheckVolumeResponse, HealthCheckVolumeResponses, ListBackupSchedulesData, ListBackupSchedulesResponse, ListBackupSchedulesResponses, ListFilesData, ListFilesResponse, ListFilesResponses, ListNotificationDestinationsData, ListNotificationDestinationsResponse, ListNotificationDestinationsResponses, ListRcloneRemotesData, ListRcloneRemotesResponse, ListRcloneRemotesResponses, ListRepositoriesData, ListRepositoriesResponse, ListRepositoriesResponses, ListSnapshotFilesData, ListSnapshotFilesResponse, ListSnapshotFilesResponses, ListSnapshotsData, ListSnapshotsResponse, ListSnapshotsResponses, ListVolumesData, ListVolumesResponse, ListVolumesResponses, MountVolumeData, MountVolumeResponse, MountVolumeResponses, ReorderBackupSchedulesData, ReorderBackupSchedulesResponse, ReorderBackupSchedulesResponses, RestoreSnapshotData, RestoreSnapshotResponse, RestoreSnapshotResponses, RunBackupNowData, RunBackupNowResponse, RunBackupNowResponses, RunForgetData, RunForgetResponse, RunForgetResponses, StopBackupData, StopBackupErrors, StopBackupResponse, StopBackupResponses, TagSnapshotsData, TagSnapshotsResponse, TagSnapshotsResponses, TestConnectionData, TestConnectionResponse, TestConnectionResponses, TestNotificationDestinationData, TestNotificationDestinationErrors, TestNotificationDestinationResponse, TestNotificationDestinationResponses, UnmountVolumeData, UnmountVolumeResponse, UnmountVolumeResponses, UpdateBackupScheduleData, UpdateBackupScheduleResponse, UpdateBackupScheduleResponses, UpdateNotificationDestinationData, UpdateNotificationDestinationErrors, UpdateNotificationDestinationResponse, UpdateNotificationDestinationResponses, UpdateRepositoryData, UpdateRepositoryErrors, UpdateRepositoryResponse, UpdateRepositoryResponses, UpdateScheduleMirrorsData, UpdateScheduleMirrorsResponse, UpdateScheduleMirrorsResponses, UpdateScheduleNotificationsData, UpdateScheduleNotificationsResponse, UpdateScheduleNotificationsResponses, UpdateVolumeData, UpdateVolumeErrors, UpdateVolumeResponse, UpdateVolumeResponses } from './types.gen';
|
||||||
|
|
|
||||||
|
|
@ -1,123 +1,10 @@
|
||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import type { Client, Options as Options2, TDataShape } from "./client";
|
import type { Client, Options as Options2, TDataShape } from './client';
|
||||||
import { client } from "./client.gen";
|
import { client } from './client.gen';
|
||||||
import type {
|
import type { BrowseFilesystemData, BrowseFilesystemResponses, CreateBackupScheduleData, CreateBackupScheduleResponses, CreateNotificationDestinationData, CreateNotificationDestinationResponses, CreateRepositoryData, CreateRepositoryResponses, CreateVolumeData, CreateVolumeResponses, DeleteBackupScheduleData, DeleteBackupScheduleResponses, DeleteNotificationDestinationData, DeleteNotificationDestinationErrors, DeleteNotificationDestinationResponses, DeleteRepositoryData, DeleteRepositoryResponses, DeleteSnapshotData, DeleteSnapshotResponses, DeleteSnapshotsData, DeleteSnapshotsResponses, DeleteVolumeData, DeleteVolumeResponses, DoctorRepositoryData, DoctorRepositoryResponses, DownloadResticPasswordData, DownloadResticPasswordResponses, GetBackupScheduleData, GetBackupScheduleForVolumeData, GetBackupScheduleForVolumeResponses, GetBackupScheduleResponses, GetMirrorCompatibilityData, GetMirrorCompatibilityResponses, GetNotificationDestinationData, GetNotificationDestinationErrors, GetNotificationDestinationResponses, GetRepositoryData, GetRepositoryResponses, GetScheduleMirrorsData, GetScheduleMirrorsResponses, GetScheduleNotificationsData, GetScheduleNotificationsResponses, GetSnapshotDetailsData, GetSnapshotDetailsResponses, GetStatusData, GetStatusResponses, GetSystemInfoData, GetSystemInfoResponses, GetUpdatesData, GetUpdatesResponses, GetVolumeData, GetVolumeErrors, GetVolumeResponses, HealthCheckVolumeData, HealthCheckVolumeErrors, HealthCheckVolumeResponses, ListBackupSchedulesData, ListBackupSchedulesResponses, ListFilesData, ListFilesResponses, ListNotificationDestinationsData, ListNotificationDestinationsResponses, ListRcloneRemotesData, ListRcloneRemotesResponses, ListRepositoriesData, ListRepositoriesResponses, ListSnapshotFilesData, ListSnapshotFilesResponses, ListSnapshotsData, ListSnapshotsResponses, ListVolumesData, ListVolumesResponses, MountVolumeData, MountVolumeResponses, ReorderBackupSchedulesData, ReorderBackupSchedulesResponses, RestoreSnapshotData, RestoreSnapshotResponses, RunBackupNowData, RunBackupNowResponses, RunForgetData, RunForgetResponses, StopBackupData, StopBackupErrors, StopBackupResponses, TagSnapshotsData, TagSnapshotsResponses, TestConnectionData, TestConnectionResponses, TestNotificationDestinationData, TestNotificationDestinationErrors, TestNotificationDestinationResponses, UnmountVolumeData, UnmountVolumeResponses, UpdateBackupScheduleData, UpdateBackupScheduleResponses, UpdateNotificationDestinationData, UpdateNotificationDestinationErrors, UpdateNotificationDestinationResponses, UpdateRepositoryData, UpdateRepositoryErrors, UpdateRepositoryResponses, UpdateScheduleMirrorsData, UpdateScheduleMirrorsResponses, UpdateScheduleNotificationsData, UpdateScheduleNotificationsResponses, UpdateVolumeData, UpdateVolumeErrors, UpdateVolumeResponses } from './types.gen';
|
||||||
BrowseFilesystemData,
|
|
||||||
BrowseFilesystemResponses,
|
|
||||||
CreateBackupScheduleData,
|
|
||||||
CreateBackupScheduleResponses,
|
|
||||||
CreateNotificationDestinationData,
|
|
||||||
CreateNotificationDestinationResponses,
|
|
||||||
CreateRepositoryData,
|
|
||||||
CreateRepositoryResponses,
|
|
||||||
CreateVolumeData,
|
|
||||||
CreateVolumeResponses,
|
|
||||||
DeleteBackupScheduleData,
|
|
||||||
DeleteBackupScheduleResponses,
|
|
||||||
DeleteNotificationDestinationData,
|
|
||||||
DeleteNotificationDestinationErrors,
|
|
||||||
DeleteNotificationDestinationResponses,
|
|
||||||
DeleteRepositoryData,
|
|
||||||
DeleteRepositoryResponses,
|
|
||||||
DeleteSnapshotData,
|
|
||||||
DeleteSnapshotResponses,
|
|
||||||
DeleteSnapshotsData,
|
|
||||||
DeleteSnapshotsResponses,
|
|
||||||
DeleteVolumeData,
|
|
||||||
DeleteVolumeResponses,
|
|
||||||
DoctorRepositoryData,
|
|
||||||
DoctorRepositoryResponses,
|
|
||||||
DownloadResticPasswordData,
|
|
||||||
DownloadResticPasswordResponses,
|
|
||||||
GetBackupScheduleData,
|
|
||||||
GetBackupScheduleForVolumeData,
|
|
||||||
GetBackupScheduleForVolumeResponses,
|
|
||||||
GetBackupScheduleResponses,
|
|
||||||
GetMirrorCompatibilityData,
|
|
||||||
GetMirrorCompatibilityResponses,
|
|
||||||
GetNotificationDestinationData,
|
|
||||||
GetNotificationDestinationErrors,
|
|
||||||
GetNotificationDestinationResponses,
|
|
||||||
GetRepositoryData,
|
|
||||||
GetRepositoryResponses,
|
|
||||||
GetScheduleMirrorsData,
|
|
||||||
GetScheduleMirrorsResponses,
|
|
||||||
GetScheduleNotificationsData,
|
|
||||||
GetScheduleNotificationsResponses,
|
|
||||||
GetSnapshotDetailsData,
|
|
||||||
GetSnapshotDetailsResponses,
|
|
||||||
GetStatusData,
|
|
||||||
GetStatusResponses,
|
|
||||||
GetSystemInfoData,
|
|
||||||
GetSystemInfoResponses,
|
|
||||||
GetUpdatesData,
|
|
||||||
GetUpdatesResponses,
|
|
||||||
GetVolumeData,
|
|
||||||
GetVolumeErrors,
|
|
||||||
GetVolumeResponses,
|
|
||||||
HealthCheckVolumeData,
|
|
||||||
HealthCheckVolumeErrors,
|
|
||||||
HealthCheckVolumeResponses,
|
|
||||||
ListBackupSchedulesData,
|
|
||||||
ListBackupSchedulesResponses,
|
|
||||||
ListFilesData,
|
|
||||||
ListFilesResponses,
|
|
||||||
ListNotificationDestinationsData,
|
|
||||||
ListNotificationDestinationsResponses,
|
|
||||||
ListRcloneRemotesData,
|
|
||||||
ListRcloneRemotesResponses,
|
|
||||||
ListRepositoriesData,
|
|
||||||
ListRepositoriesResponses,
|
|
||||||
ListSnapshotFilesData,
|
|
||||||
ListSnapshotFilesResponses,
|
|
||||||
ListSnapshotsData,
|
|
||||||
ListSnapshotsResponses,
|
|
||||||
ListVolumesData,
|
|
||||||
ListVolumesResponses,
|
|
||||||
MountVolumeData,
|
|
||||||
MountVolumeResponses,
|
|
||||||
ReorderBackupSchedulesData,
|
|
||||||
ReorderBackupSchedulesResponses,
|
|
||||||
RestoreSnapshotData,
|
|
||||||
RestoreSnapshotResponses,
|
|
||||||
RunBackupNowData,
|
|
||||||
RunBackupNowResponses,
|
|
||||||
RunForgetData,
|
|
||||||
RunForgetResponses,
|
|
||||||
StopBackupData,
|
|
||||||
StopBackupErrors,
|
|
||||||
StopBackupResponses,
|
|
||||||
TagSnapshotsData,
|
|
||||||
TagSnapshotsResponses,
|
|
||||||
TestConnectionData,
|
|
||||||
TestConnectionResponses,
|
|
||||||
TestNotificationDestinationData,
|
|
||||||
TestNotificationDestinationErrors,
|
|
||||||
TestNotificationDestinationResponses,
|
|
||||||
UnmountVolumeData,
|
|
||||||
UnmountVolumeResponses,
|
|
||||||
UpdateBackupScheduleData,
|
|
||||||
UpdateBackupScheduleResponses,
|
|
||||||
UpdateNotificationDestinationData,
|
|
||||||
UpdateNotificationDestinationErrors,
|
|
||||||
UpdateNotificationDestinationResponses,
|
|
||||||
UpdateRepositoryData,
|
|
||||||
UpdateRepositoryErrors,
|
|
||||||
UpdateRepositoryResponses,
|
|
||||||
UpdateScheduleMirrorsData,
|
|
||||||
UpdateScheduleMirrorsResponses,
|
|
||||||
UpdateScheduleNotificationsData,
|
|
||||||
UpdateScheduleNotificationsResponses,
|
|
||||||
UpdateVolumeData,
|
|
||||||
UpdateVolumeErrors,
|
|
||||||
UpdateVolumeResponses,
|
|
||||||
} from "./types.gen";
|
|
||||||
|
|
||||||
export type Options<
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
||||||
TData extends TDataShape = TDataShape,
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
> = Options2<TData, ThrowOnError> & {
|
|
||||||
/**
|
/**
|
||||||
* You can provide a client instance returned by `createClient()` instead of
|
* You can provide a client instance returned by `createClient()` instead of
|
||||||
* individual options. This might be also useful if you want to implement a
|
* individual options. This might be also useful if you want to implement a
|
||||||
|
|
@ -134,716 +21,361 @@ export type Options<
|
||||||
/**
|
/**
|
||||||
* Get authentication system status
|
* Get authentication system status
|
||||||
*/
|
*/
|
||||||
export const getStatus = <ThrowOnError extends boolean = false>(
|
export const getStatus = <ThrowOnError extends boolean = false>(options?: Options<GetStatusData, ThrowOnError>) => (options?.client ?? client).get<GetStatusResponses, unknown, ThrowOnError>({ url: '/api/v1/auth/status', ...options });
|
||||||
options?: Options<GetStatusData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<GetStatusResponses, unknown, ThrowOnError>({
|
|
||||||
url: "/api/v1/auth/status",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all volumes
|
* List all volumes
|
||||||
*/
|
*/
|
||||||
export const listVolumes = <ThrowOnError extends boolean = false>(
|
export const listVolumes = <ThrowOnError extends boolean = false>(options?: Options<ListVolumesData, ThrowOnError>) => (options?.client ?? client).get<ListVolumesResponses, unknown, ThrowOnError>({ url: '/api/v1/volumes', ...options });
|
||||||
options?: Options<ListVolumesData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<ListVolumesResponses, unknown, ThrowOnError>({
|
|
||||||
url: "/api/v1/volumes",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new volume
|
* Create a new volume
|
||||||
*/
|
*/
|
||||||
export const createVolume = <ThrowOnError extends boolean = false>(
|
export const createVolume = <ThrowOnError extends boolean = false>(options?: Options<CreateVolumeData, ThrowOnError>) => (options?.client ?? client).post<CreateVolumeResponses, unknown, ThrowOnError>({
|
||||||
options?: Options<CreateVolumeData, ThrowOnError>,
|
url: '/api/v1/volumes',
|
||||||
) =>
|
|
||||||
(options?.client ?? client).post<
|
|
||||||
CreateVolumeResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/volumes",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options?.headers,
|
...options?.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test connection to backend
|
* Test connection to backend
|
||||||
*/
|
*/
|
||||||
export const testConnection = <ThrowOnError extends boolean = false>(
|
export const testConnection = <ThrowOnError extends boolean = false>(options?: Options<TestConnectionData, ThrowOnError>) => (options?.client ?? client).post<TestConnectionResponses, unknown, ThrowOnError>({
|
||||||
options?: Options<TestConnectionData, ThrowOnError>,
|
url: '/api/v1/volumes/test-connection',
|
||||||
) =>
|
|
||||||
(options?.client ?? client).post<
|
|
||||||
TestConnectionResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/volumes/test-connection",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options?.headers,
|
...options?.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a volume
|
* Delete a volume
|
||||||
*/
|
*/
|
||||||
export const deleteVolume = <ThrowOnError extends boolean = false>(
|
export const deleteVolume = <ThrowOnError extends boolean = false>(options: Options<DeleteVolumeData, ThrowOnError>) => (options.client ?? client).delete<DeleteVolumeResponses, unknown, ThrowOnError>({ url: '/api/v1/volumes/{name}', ...options });
|
||||||
options: Options<DeleteVolumeData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).delete<
|
|
||||||
DeleteVolumeResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/volumes/{name}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a volume by name
|
* Get a volume by name
|
||||||
*/
|
*/
|
||||||
export const getVolume = <ThrowOnError extends boolean = false>(
|
export const getVolume = <ThrowOnError extends boolean = false>(options: Options<GetVolumeData, ThrowOnError>) => (options.client ?? client).get<GetVolumeResponses, GetVolumeErrors, ThrowOnError>({ url: '/api/v1/volumes/{name}', ...options });
|
||||||
options: Options<GetVolumeData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
GetVolumeResponses,
|
|
||||||
GetVolumeErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/volumes/{name}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a volume's configuration
|
* Update a volume's configuration
|
||||||
*/
|
*/
|
||||||
export const updateVolume = <ThrowOnError extends boolean = false>(
|
export const updateVolume = <ThrowOnError extends boolean = false>(options: Options<UpdateVolumeData, ThrowOnError>) => (options.client ?? client).put<UpdateVolumeResponses, UpdateVolumeErrors, ThrowOnError>({
|
||||||
options: Options<UpdateVolumeData, ThrowOnError>,
|
url: '/api/v1/volumes/{name}',
|
||||||
) =>
|
|
||||||
(options.client ?? client).put<
|
|
||||||
UpdateVolumeResponses,
|
|
||||||
UpdateVolumeErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/volumes/{name}",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mount a volume
|
* Mount a volume
|
||||||
*/
|
*/
|
||||||
export const mountVolume = <ThrowOnError extends boolean = false>(
|
export const mountVolume = <ThrowOnError extends boolean = false>(options: Options<MountVolumeData, ThrowOnError>) => (options.client ?? client).post<MountVolumeResponses, unknown, ThrowOnError>({ url: '/api/v1/volumes/{name}/mount', ...options });
|
||||||
options: Options<MountVolumeData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<MountVolumeResponses, unknown, ThrowOnError>({
|
|
||||||
url: "/api/v1/volumes/{name}/mount",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmount a volume
|
* Unmount a volume
|
||||||
*/
|
*/
|
||||||
export const unmountVolume = <ThrowOnError extends boolean = false>(
|
export const unmountVolume = <ThrowOnError extends boolean = false>(options: Options<UnmountVolumeData, ThrowOnError>) => (options.client ?? client).post<UnmountVolumeResponses, unknown, ThrowOnError>({ url: '/api/v1/volumes/{name}/unmount', ...options });
|
||||||
options: Options<UnmountVolumeData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<
|
|
||||||
UnmountVolumeResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/volumes/{name}/unmount", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a health check on a volume
|
* Perform a health check on a volume
|
||||||
*/
|
*/
|
||||||
export const healthCheckVolume = <ThrowOnError extends boolean = false>(
|
export const healthCheckVolume = <ThrowOnError extends boolean = false>(options: Options<HealthCheckVolumeData, ThrowOnError>) => (options.client ?? client).post<HealthCheckVolumeResponses, HealthCheckVolumeErrors, ThrowOnError>({ url: '/api/v1/volumes/{name}/health-check', ...options });
|
||||||
options: Options<HealthCheckVolumeData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<
|
|
||||||
HealthCheckVolumeResponses,
|
|
||||||
HealthCheckVolumeErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/volumes/{name}/health-check", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List files in a volume directory
|
* List files in a volume directory
|
||||||
*/
|
*/
|
||||||
export const listFiles = <ThrowOnError extends boolean = false>(
|
export const listFiles = <ThrowOnError extends boolean = false>(options: Options<ListFilesData, ThrowOnError>) => (options.client ?? client).get<ListFilesResponses, unknown, ThrowOnError>({ url: '/api/v1/volumes/{name}/files', ...options });
|
||||||
options: Options<ListFilesData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<ListFilesResponses, unknown, ThrowOnError>({
|
|
||||||
url: "/api/v1/volumes/{name}/files",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Browse directories on the host filesystem
|
* Browse directories on the host filesystem
|
||||||
*/
|
*/
|
||||||
export const browseFilesystem = <ThrowOnError extends boolean = false>(
|
export const browseFilesystem = <ThrowOnError extends boolean = false>(options?: Options<BrowseFilesystemData, ThrowOnError>) => (options?.client ?? client).get<BrowseFilesystemResponses, unknown, ThrowOnError>({ url: '/api/v1/volumes/filesystem/browse', ...options });
|
||||||
options?: Options<BrowseFilesystemData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<
|
|
||||||
BrowseFilesystemResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/volumes/filesystem/browse", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all repositories
|
* List all repositories
|
||||||
*/
|
*/
|
||||||
export const listRepositories = <ThrowOnError extends boolean = false>(
|
export const listRepositories = <ThrowOnError extends boolean = false>(options?: Options<ListRepositoriesData, ThrowOnError>) => (options?.client ?? client).get<ListRepositoriesResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories', ...options });
|
||||||
options?: Options<ListRepositoriesData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<
|
|
||||||
ListRepositoriesResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/repositories", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new restic repository
|
* Create a new restic repository
|
||||||
*/
|
*/
|
||||||
export const createRepository = <ThrowOnError extends boolean = false>(
|
export const createRepository = <ThrowOnError extends boolean = false>(options?: Options<CreateRepositoryData, ThrowOnError>) => (options?.client ?? client).post<CreateRepositoryResponses, unknown, ThrowOnError>({
|
||||||
options?: Options<CreateRepositoryData, ThrowOnError>,
|
url: '/api/v1/repositories',
|
||||||
) =>
|
|
||||||
(options?.client ?? client).post<
|
|
||||||
CreateRepositoryResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/repositories",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options?.headers,
|
...options?.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all configured rclone remotes on the host system
|
* List all configured rclone remotes on the host system
|
||||||
*/
|
*/
|
||||||
export const listRcloneRemotes = <ThrowOnError extends boolean = false>(
|
export const listRcloneRemotes = <ThrowOnError extends boolean = false>(options?: Options<ListRcloneRemotesData, ThrowOnError>) => (options?.client ?? client).get<ListRcloneRemotesResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories/rclone-remotes', ...options });
|
||||||
options?: Options<ListRcloneRemotesData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<
|
|
||||||
ListRcloneRemotesResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/repositories/rclone-remotes", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a repository
|
* Delete a repository
|
||||||
*/
|
*/
|
||||||
export const deleteRepository = <ThrowOnError extends boolean = false>(
|
export const deleteRepository = <ThrowOnError extends boolean = false>(options: Options<DeleteRepositoryData, ThrowOnError>) => (options.client ?? client).delete<DeleteRepositoryResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories/{id}', ...options });
|
||||||
options: Options<DeleteRepositoryData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).delete<
|
|
||||||
DeleteRepositoryResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/repositories/{id}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a single repository by ID
|
* Get a single repository by ID
|
||||||
*/
|
*/
|
||||||
export const getRepository = <ThrowOnError extends boolean = false>(
|
export const getRepository = <ThrowOnError extends boolean = false>(options: Options<GetRepositoryData, ThrowOnError>) => (options.client ?? client).get<GetRepositoryResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories/{id}', ...options });
|
||||||
options: Options<GetRepositoryData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<GetRepositoryResponses, unknown, ThrowOnError>(
|
|
||||||
{ url: "/api/v1/repositories/{id}", ...options },
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a repository's name or settings
|
* Update a repository's name or settings
|
||||||
*/
|
*/
|
||||||
export const updateRepository = <ThrowOnError extends boolean = false>(
|
export const updateRepository = <ThrowOnError extends boolean = false>(options: Options<UpdateRepositoryData, ThrowOnError>) => (options.client ?? client).patch<UpdateRepositoryResponses, UpdateRepositoryErrors, ThrowOnError>({
|
||||||
options: Options<UpdateRepositoryData, ThrowOnError>,
|
url: '/api/v1/repositories/{id}',
|
||||||
) =>
|
|
||||||
(options.client ?? client).patch<
|
|
||||||
UpdateRepositoryResponses,
|
|
||||||
UpdateRepositoryErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/repositories/{id}",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete multiple snapshots from a repository
|
* Delete multiple snapshots from a repository
|
||||||
*/
|
*/
|
||||||
export const deleteSnapshots = <ThrowOnError extends boolean = false>(
|
export const deleteSnapshots = <ThrowOnError extends boolean = false>(options: Options<DeleteSnapshotsData, ThrowOnError>) => (options.client ?? client).delete<DeleteSnapshotsResponses, unknown, ThrowOnError>({
|
||||||
options: Options<DeleteSnapshotsData, ThrowOnError>,
|
url: '/api/v1/repositories/{id}/snapshots',
|
||||||
) =>
|
|
||||||
(options.client ?? client).delete<
|
|
||||||
DeleteSnapshotsResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/repositories/{id}/snapshots",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all snapshots in a repository
|
* List all snapshots in a repository
|
||||||
*/
|
*/
|
||||||
export const listSnapshots = <ThrowOnError extends boolean = false>(
|
export const listSnapshots = <ThrowOnError extends boolean = false>(options: Options<ListSnapshotsData, ThrowOnError>) => (options.client ?? client).get<ListSnapshotsResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories/{id}/snapshots', ...options });
|
||||||
options: Options<ListSnapshotsData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<ListSnapshotsResponses, unknown, ThrowOnError>(
|
|
||||||
{ url: "/api/v1/repositories/{id}/snapshots", ...options },
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a specific snapshot from a repository
|
* Delete a specific snapshot from a repository
|
||||||
*/
|
*/
|
||||||
export const deleteSnapshot = <ThrowOnError extends boolean = false>(
|
export const deleteSnapshot = <ThrowOnError extends boolean = false>(options: Options<DeleteSnapshotData, ThrowOnError>) => (options.client ?? client).delete<DeleteSnapshotResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories/{id}/snapshots/{snapshotId}', ...options });
|
||||||
options: Options<DeleteSnapshotData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).delete<
|
|
||||||
DeleteSnapshotResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/repositories/{id}/snapshots/{snapshotId}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get details of a specific snapshot
|
* Get details of a specific snapshot
|
||||||
*/
|
*/
|
||||||
export const getSnapshotDetails = <ThrowOnError extends boolean = false>(
|
export const getSnapshotDetails = <ThrowOnError extends boolean = false>(options: Options<GetSnapshotDetailsData, ThrowOnError>) => (options.client ?? client).get<GetSnapshotDetailsResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories/{id}/snapshots/{snapshotId}', ...options });
|
||||||
options: Options<GetSnapshotDetailsData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
GetSnapshotDetailsResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/repositories/{id}/snapshots/{snapshotId}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List files and directories in a snapshot
|
* List files and directories in a snapshot
|
||||||
*/
|
*/
|
||||||
export const listSnapshotFiles = <ThrowOnError extends boolean = false>(
|
export const listSnapshotFiles = <ThrowOnError extends boolean = false>(options: Options<ListSnapshotFilesData, ThrowOnError>) => (options.client ?? client).get<ListSnapshotFilesResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories/{id}/snapshots/{snapshotId}/files', ...options });
|
||||||
options: Options<ListSnapshotFilesData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
ListSnapshotFilesResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/repositories/{id}/snapshots/{snapshotId}/files",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore a snapshot to a target path on the filesystem
|
* Restore a snapshot to a target path on the filesystem
|
||||||
*/
|
*/
|
||||||
export const restoreSnapshot = <ThrowOnError extends boolean = false>(
|
export const restoreSnapshot = <ThrowOnError extends boolean = false>(options: Options<RestoreSnapshotData, ThrowOnError>) => (options.client ?? client).post<RestoreSnapshotResponses, unknown, ThrowOnError>({
|
||||||
options: Options<RestoreSnapshotData, ThrowOnError>,
|
url: '/api/v1/repositories/{id}/restore',
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<
|
|
||||||
RestoreSnapshotResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/repositories/{id}/restore",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run doctor operations on a repository to fix common issues (unlock, check, repair index). Use this when the repository is locked or has errors.
|
* Run doctor operations on a repository to fix common issues (unlock, check, repair index). Use this when the repository is locked or has errors.
|
||||||
*/
|
*/
|
||||||
export const doctorRepository = <ThrowOnError extends boolean = false>(
|
export const doctorRepository = <ThrowOnError extends boolean = false>(options: Options<DoctorRepositoryData, ThrowOnError>) => (options.client ?? client).post<DoctorRepositoryResponses, unknown, ThrowOnError>({ url: '/api/v1/repositories/{id}/doctor', ...options });
|
||||||
options: Options<DoctorRepositoryData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<
|
|
||||||
DoctorRepositoryResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/repositories/{id}/doctor", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag multiple snapshots in a repository
|
* Tag multiple snapshots in a repository
|
||||||
*/
|
*/
|
||||||
export const tagSnapshots = <ThrowOnError extends boolean = false>(
|
export const tagSnapshots = <ThrowOnError extends boolean = false>(options: Options<TagSnapshotsData, ThrowOnError>) => (options.client ?? client).post<TagSnapshotsResponses, unknown, ThrowOnError>({
|
||||||
options: Options<TagSnapshotsData, ThrowOnError>,
|
url: '/api/v1/repositories/{id}/snapshots/tag',
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<TagSnapshotsResponses, unknown, ThrowOnError>(
|
|
||||||
{
|
|
||||||
url: "/api/v1/repositories/{id}/snapshots/tag",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all backup schedules
|
* List all backup schedules
|
||||||
*/
|
*/
|
||||||
export const listBackupSchedules = <ThrowOnError extends boolean = false>(
|
export const listBackupSchedules = <ThrowOnError extends boolean = false>(options?: Options<ListBackupSchedulesData, ThrowOnError>) => (options?.client ?? client).get<ListBackupSchedulesResponses, unknown, ThrowOnError>({ url: '/api/v1/backups', ...options });
|
||||||
options?: Options<ListBackupSchedulesData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<
|
|
||||||
ListBackupSchedulesResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/backups", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new backup schedule for a volume
|
* Create a new backup schedule for a volume
|
||||||
*/
|
*/
|
||||||
export const createBackupSchedule = <ThrowOnError extends boolean = false>(
|
export const createBackupSchedule = <ThrowOnError extends boolean = false>(options?: Options<CreateBackupScheduleData, ThrowOnError>) => (options?.client ?? client).post<CreateBackupScheduleResponses, unknown, ThrowOnError>({
|
||||||
options?: Options<CreateBackupScheduleData, ThrowOnError>,
|
url: '/api/v1/backups',
|
||||||
) =>
|
|
||||||
(options?.client ?? client).post<
|
|
||||||
CreateBackupScheduleResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/backups",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options?.headers,
|
...options?.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a backup schedule
|
* Delete a backup schedule
|
||||||
*/
|
*/
|
||||||
export const deleteBackupSchedule = <ThrowOnError extends boolean = false>(
|
export const deleteBackupSchedule = <ThrowOnError extends boolean = false>(options: Options<DeleteBackupScheduleData, ThrowOnError>) => (options.client ?? client).delete<DeleteBackupScheduleResponses, unknown, ThrowOnError>({ url: '/api/v1/backups/{scheduleId}', ...options });
|
||||||
options: Options<DeleteBackupScheduleData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).delete<
|
|
||||||
DeleteBackupScheduleResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/backups/{scheduleId}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a backup schedule by ID
|
* Get a backup schedule by ID
|
||||||
*/
|
*/
|
||||||
export const getBackupSchedule = <ThrowOnError extends boolean = false>(
|
export const getBackupSchedule = <ThrowOnError extends boolean = false>(options: Options<GetBackupScheduleData, ThrowOnError>) => (options.client ?? client).get<GetBackupScheduleResponses, unknown, ThrowOnError>({ url: '/api/v1/backups/{scheduleId}', ...options });
|
||||||
options: Options<GetBackupScheduleData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
GetBackupScheduleResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/backups/{scheduleId}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a backup schedule
|
* Update a backup schedule
|
||||||
*/
|
*/
|
||||||
export const updateBackupSchedule = <ThrowOnError extends boolean = false>(
|
export const updateBackupSchedule = <ThrowOnError extends boolean = false>(options: Options<UpdateBackupScheduleData, ThrowOnError>) => (options.client ?? client).patch<UpdateBackupScheduleResponses, unknown, ThrowOnError>({
|
||||||
options: Options<UpdateBackupScheduleData, ThrowOnError>,
|
url: '/api/v1/backups/{scheduleId}',
|
||||||
) =>
|
|
||||||
(options.client ?? client).patch<
|
|
||||||
UpdateBackupScheduleResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/backups/{scheduleId}",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a backup schedule for a specific volume
|
* Get a backup schedule for a specific volume
|
||||||
*/
|
*/
|
||||||
export const getBackupScheduleForVolume = <
|
export const getBackupScheduleForVolume = <ThrowOnError extends boolean = false>(options: Options<GetBackupScheduleForVolumeData, ThrowOnError>) => (options.client ?? client).get<GetBackupScheduleForVolumeResponses, unknown, ThrowOnError>({ url: '/api/v1/backups/volume/{volumeId}', ...options });
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
>(
|
|
||||||
options: Options<GetBackupScheduleForVolumeData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
GetBackupScheduleForVolumeResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/backups/volume/{volumeId}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger a backup immediately for a schedule
|
* Trigger a backup immediately for a schedule
|
||||||
*/
|
*/
|
||||||
export const runBackupNow = <ThrowOnError extends boolean = false>(
|
export const runBackupNow = <ThrowOnError extends boolean = false>(options: Options<RunBackupNowData, ThrowOnError>) => (options.client ?? client).post<RunBackupNowResponses, unknown, ThrowOnError>({ url: '/api/v1/backups/{scheduleId}/run', ...options });
|
||||||
options: Options<RunBackupNowData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<RunBackupNowResponses, unknown, ThrowOnError>(
|
|
||||||
{ url: "/api/v1/backups/{scheduleId}/run", ...options },
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop a backup that is currently in progress
|
* Stop a backup that is currently in progress
|
||||||
*/
|
*/
|
||||||
export const stopBackup = <ThrowOnError extends boolean = false>(
|
export const stopBackup = <ThrowOnError extends boolean = false>(options: Options<StopBackupData, ThrowOnError>) => (options.client ?? client).post<StopBackupResponses, StopBackupErrors, ThrowOnError>({ url: '/api/v1/backups/{scheduleId}/stop', ...options });
|
||||||
options: Options<StopBackupData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<
|
|
||||||
StopBackupResponses,
|
|
||||||
StopBackupErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/backups/{scheduleId}/stop", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually apply retention policy to clean up old snapshots
|
* Manually apply retention policy to clean up old snapshots
|
||||||
*/
|
*/
|
||||||
export const runForget = <ThrowOnError extends boolean = false>(
|
export const runForget = <ThrowOnError extends boolean = false>(options: Options<RunForgetData, ThrowOnError>) => (options.client ?? client).post<RunForgetResponses, unknown, ThrowOnError>({ url: '/api/v1/backups/{scheduleId}/forget', ...options });
|
||||||
options: Options<RunForgetData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<RunForgetResponses, unknown, ThrowOnError>({
|
|
||||||
url: "/api/v1/backups/{scheduleId}/forget",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get notification assignments for a backup schedule
|
* Get notification assignments for a backup schedule
|
||||||
*/
|
*/
|
||||||
export const getScheduleNotifications = <ThrowOnError extends boolean = false>(
|
export const getScheduleNotifications = <ThrowOnError extends boolean = false>(options: Options<GetScheduleNotificationsData, ThrowOnError>) => (options.client ?? client).get<GetScheduleNotificationsResponses, unknown, ThrowOnError>({ url: '/api/v1/backups/{scheduleId}/notifications', ...options });
|
||||||
options: Options<GetScheduleNotificationsData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
GetScheduleNotificationsResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/backups/{scheduleId}/notifications", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update notification assignments for a backup schedule
|
* Update notification assignments for a backup schedule
|
||||||
*/
|
*/
|
||||||
export const updateScheduleNotifications = <
|
export const updateScheduleNotifications = <ThrowOnError extends boolean = false>(options: Options<UpdateScheduleNotificationsData, ThrowOnError>) => (options.client ?? client).put<UpdateScheduleNotificationsResponses, unknown, ThrowOnError>({
|
||||||
ThrowOnError extends boolean = false,
|
url: '/api/v1/backups/{scheduleId}/notifications',
|
||||||
>(
|
|
||||||
options: Options<UpdateScheduleNotificationsData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).put<
|
|
||||||
UpdateScheduleNotificationsResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/backups/{scheduleId}/notifications",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mirror repository assignments for a backup schedule
|
* Get mirror repository assignments for a backup schedule
|
||||||
*/
|
*/
|
||||||
export const getScheduleMirrors = <ThrowOnError extends boolean = false>(
|
export const getScheduleMirrors = <ThrowOnError extends boolean = false>(options: Options<GetScheduleMirrorsData, ThrowOnError>) => (options.client ?? client).get<GetScheduleMirrorsResponses, unknown, ThrowOnError>({ url: '/api/v1/backups/{scheduleId}/mirrors', ...options });
|
||||||
options: Options<GetScheduleMirrorsData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
GetScheduleMirrorsResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/backups/{scheduleId}/mirrors", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update mirror repository assignments for a backup schedule
|
* Update mirror repository assignments for a backup schedule
|
||||||
*/
|
*/
|
||||||
export const updateScheduleMirrors = <ThrowOnError extends boolean = false>(
|
export const updateScheduleMirrors = <ThrowOnError extends boolean = false>(options: Options<UpdateScheduleMirrorsData, ThrowOnError>) => (options.client ?? client).put<UpdateScheduleMirrorsResponses, unknown, ThrowOnError>({
|
||||||
options: Options<UpdateScheduleMirrorsData, ThrowOnError>,
|
url: '/api/v1/backups/{scheduleId}/mirrors',
|
||||||
) =>
|
|
||||||
(options.client ?? client).put<
|
|
||||||
UpdateScheduleMirrorsResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/backups/{scheduleId}/mirrors",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mirror compatibility info for all repositories relative to a backup schedule's primary repository
|
* Get mirror compatibility info for all repositories relative to a backup schedule's primary repository
|
||||||
*/
|
*/
|
||||||
export const getMirrorCompatibility = <ThrowOnError extends boolean = false>(
|
export const getMirrorCompatibility = <ThrowOnError extends boolean = false>(options: Options<GetMirrorCompatibilityData, ThrowOnError>) => (options.client ?? client).get<GetMirrorCompatibilityResponses, unknown, ThrowOnError>({ url: '/api/v1/backups/{scheduleId}/mirrors/compatibility', ...options });
|
||||||
options: Options<GetMirrorCompatibilityData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
GetMirrorCompatibilityResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/backups/{scheduleId}/mirrors/compatibility", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reorder backup schedules by providing an array of schedule IDs in the desired order
|
* Reorder backup schedules by providing an array of schedule IDs in the desired order
|
||||||
*/
|
*/
|
||||||
export const reorderBackupSchedules = <ThrowOnError extends boolean = false>(
|
export const reorderBackupSchedules = <ThrowOnError extends boolean = false>(options?: Options<ReorderBackupSchedulesData, ThrowOnError>) => (options?.client ?? client).post<ReorderBackupSchedulesResponses, unknown, ThrowOnError>({
|
||||||
options?: Options<ReorderBackupSchedulesData, ThrowOnError>,
|
url: '/api/v1/backups/reorder',
|
||||||
) =>
|
|
||||||
(options?.client ?? client).post<
|
|
||||||
ReorderBackupSchedulesResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/backups/reorder",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options?.headers,
|
...options?.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all notification destinations
|
* List all notification destinations
|
||||||
*/
|
*/
|
||||||
export const listNotificationDestinations = <
|
export const listNotificationDestinations = <ThrowOnError extends boolean = false>(options?: Options<ListNotificationDestinationsData, ThrowOnError>) => (options?.client ?? client).get<ListNotificationDestinationsResponses, unknown, ThrowOnError>({ url: '/api/v1/notifications/destinations', ...options });
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
>(
|
|
||||||
options?: Options<ListNotificationDestinationsData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<
|
|
||||||
ListNotificationDestinationsResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/notifications/destinations", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new notification destination
|
* Create a new notification destination
|
||||||
*/
|
*/
|
||||||
export const createNotificationDestination = <
|
export const createNotificationDestination = <ThrowOnError extends boolean = false>(options?: Options<CreateNotificationDestinationData, ThrowOnError>) => (options?.client ?? client).post<CreateNotificationDestinationResponses, unknown, ThrowOnError>({
|
||||||
ThrowOnError extends boolean = false,
|
url: '/api/v1/notifications/destinations',
|
||||||
>(
|
|
||||||
options?: Options<CreateNotificationDestinationData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).post<
|
|
||||||
CreateNotificationDestinationResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/notifications/destinations",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options?.headers,
|
...options?.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a notification destination
|
* Delete a notification destination
|
||||||
*/
|
*/
|
||||||
export const deleteNotificationDestination = <
|
export const deleteNotificationDestination = <ThrowOnError extends boolean = false>(options: Options<DeleteNotificationDestinationData, ThrowOnError>) => (options.client ?? client).delete<DeleteNotificationDestinationResponses, DeleteNotificationDestinationErrors, ThrowOnError>({ url: '/api/v1/notifications/destinations/{id}', ...options });
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
>(
|
|
||||||
options: Options<DeleteNotificationDestinationData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).delete<
|
|
||||||
DeleteNotificationDestinationResponses,
|
|
||||||
DeleteNotificationDestinationErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/notifications/destinations/{id}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a notification destination by ID
|
* Get a notification destination by ID
|
||||||
*/
|
*/
|
||||||
export const getNotificationDestination = <
|
export const getNotificationDestination = <ThrowOnError extends boolean = false>(options: Options<GetNotificationDestinationData, ThrowOnError>) => (options.client ?? client).get<GetNotificationDestinationResponses, GetNotificationDestinationErrors, ThrowOnError>({ url: '/api/v1/notifications/destinations/{id}', ...options });
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
>(
|
|
||||||
options: Options<GetNotificationDestinationData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).get<
|
|
||||||
GetNotificationDestinationResponses,
|
|
||||||
GetNotificationDestinationErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/notifications/destinations/{id}", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a notification destination
|
* Update a notification destination
|
||||||
*/
|
*/
|
||||||
export const updateNotificationDestination = <
|
export const updateNotificationDestination = <ThrowOnError extends boolean = false>(options: Options<UpdateNotificationDestinationData, ThrowOnError>) => (options.client ?? client).patch<UpdateNotificationDestinationResponses, UpdateNotificationDestinationErrors, ThrowOnError>({
|
||||||
ThrowOnError extends boolean = false,
|
url: '/api/v1/notifications/destinations/{id}',
|
||||||
>(
|
|
||||||
options: Options<UpdateNotificationDestinationData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).patch<
|
|
||||||
UpdateNotificationDestinationResponses,
|
|
||||||
UpdateNotificationDestinationErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/notifications/destinations/{id}",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options.headers,
|
...options.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a notification destination by sending a test message
|
* Test a notification destination by sending a test message
|
||||||
*/
|
*/
|
||||||
export const testNotificationDestination = <
|
export const testNotificationDestination = <ThrowOnError extends boolean = false>(options: Options<TestNotificationDestinationData, ThrowOnError>) => (options.client ?? client).post<TestNotificationDestinationResponses, TestNotificationDestinationErrors, ThrowOnError>({ url: '/api/v1/notifications/destinations/{id}/test', ...options });
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
>(
|
|
||||||
options: Options<TestNotificationDestinationData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options.client ?? client).post<
|
|
||||||
TestNotificationDestinationResponses,
|
|
||||||
TestNotificationDestinationErrors,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/notifications/destinations/{id}/test", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get system information including available capabilities
|
* Get system information including available capabilities
|
||||||
*/
|
*/
|
||||||
export const getSystemInfo = <ThrowOnError extends boolean = false>(
|
export const getSystemInfo = <ThrowOnError extends boolean = false>(options?: Options<GetSystemInfoData, ThrowOnError>) => (options?.client ?? client).get<GetSystemInfoResponses, unknown, ThrowOnError>({ url: '/api/v1/system/info', ...options });
|
||||||
options?: Options<GetSystemInfoData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<
|
|
||||||
GetSystemInfoResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({ url: "/api/v1/system/info", ...options });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for application updates from GitHub
|
* Check for application updates from GitHub
|
||||||
*/
|
*/
|
||||||
export const getUpdates = <ThrowOnError extends boolean = false>(
|
export const getUpdates = <ThrowOnError extends boolean = false>(options?: Options<GetUpdatesData, ThrowOnError>) => (options?.client ?? client).get<GetUpdatesResponses, unknown, ThrowOnError>({ url: '/api/v1/system/updates', ...options });
|
||||||
options?: Options<GetUpdatesData, ThrowOnError>,
|
|
||||||
) =>
|
|
||||||
(options?.client ?? client).get<GetUpdatesResponses, unknown, ThrowOnError>({
|
|
||||||
url: "/api/v1/system/updates",
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download the Restic password file for backup recovery. Requires password re-authentication.
|
* Download the Restic password file for backup recovery. Requires password re-authentication.
|
||||||
*/
|
*/
|
||||||
export const downloadResticPassword = <ThrowOnError extends boolean = false>(
|
export const downloadResticPassword = <ThrowOnError extends boolean = false>(options?: Options<DownloadResticPasswordData, ThrowOnError>) => (options?.client ?? client).post<DownloadResticPasswordResponses, unknown, ThrowOnError>({
|
||||||
options?: Options<DownloadResticPasswordData, ThrowOnError>,
|
url: '/api/v1/system/restic-password',
|
||||||
) =>
|
|
||||||
(options?.client ?? client).post<
|
|
||||||
DownloadResticPasswordResponses,
|
|
||||||
unknown,
|
|
||||||
ThrowOnError
|
|
||||||
>({
|
|
||||||
url: "/api/v1/system/restic-password",
|
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
...options?.headers,
|
...options?.headers
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -7,6 +7,7 @@ import { Button } from "~/client/components/ui/button";
|
||||||
import { Input } from "~/client/components/ui/input";
|
import { Input } from "~/client/components/ui/input";
|
||||||
import { Label } from "~/client/components/ui/label";
|
import { Label } from "~/client/components/ui/label";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "~/client/components/ui/select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "~/client/components/ui/select";
|
||||||
|
import { Checkbox } from "~/client/components/ui/checkbox";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
|
|
@ -20,7 +21,8 @@ import {
|
||||||
import type { Repository } from "~/client/lib/types";
|
import type { Repository } from "~/client/lib/types";
|
||||||
import { REPOSITORY_BASE } from "~/client/lib/constants";
|
import { REPOSITORY_BASE } from "~/client/lib/constants";
|
||||||
import { updateRepositoryMutation } from "~/client/api-client/@tanstack/react-query.gen";
|
import { updateRepositoryMutation } from "~/client/api-client/@tanstack/react-query.gen";
|
||||||
import type { CompressionMode, RepositoryConfig } from "~/schemas/restic";
|
import type { CompressionMode, RepositoryConfig, BandwidthUnit } from "~/schemas/restic";
|
||||||
|
import { BANDWIDTH_UNITS } from "~/schemas/restic";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
repository: Repository;
|
repository: Repository;
|
||||||
|
|
@ -43,6 +45,28 @@ export const RepositoryInfoTabContent = ({ repository }: Props) => {
|
||||||
const [compressionMode, setCompressionMode] = useState<CompressionMode>(
|
const [compressionMode, setCompressionMode] = useState<CompressionMode>(
|
||||||
(repository.compressionMode as CompressionMode) || "off",
|
(repository.compressionMode as CompressionMode) || "off",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Bandwidth limit states
|
||||||
|
const [uploadLimitEnabled, setUploadLimitEnabled] = useState(
|
||||||
|
(repository as any).uploadLimitEnabled ?? false
|
||||||
|
);
|
||||||
|
const [uploadLimitValue, setUploadLimitValue] = useState(
|
||||||
|
(repository as any).uploadLimitValue ?? 0
|
||||||
|
);
|
||||||
|
const [uploadLimitUnit, setUploadLimitUnit] = useState<BandwidthUnit>(
|
||||||
|
(repository as any).uploadLimitUnit ?? "Mbps"
|
||||||
|
);
|
||||||
|
|
||||||
|
const [downloadLimitEnabled, setDownloadLimitEnabled] = useState(
|
||||||
|
(repository as any).downloadLimitEnabled ?? false
|
||||||
|
);
|
||||||
|
const [downloadLimitValue, setDownloadLimitValue] = useState(
|
||||||
|
(repository as any).downloadLimitValue ?? 0
|
||||||
|
);
|
||||||
|
const [downloadLimitUnit, setDownloadLimitUnit] = useState<BandwidthUnit>(
|
||||||
|
(repository as any).downloadLimitUnit ?? "Mbps"
|
||||||
|
);
|
||||||
|
|
||||||
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
||||||
|
|
||||||
const effectiveLocalPath = getEffectiveLocalPath(repository);
|
const effectiveLocalPath = getEffectiveLocalPath(repository);
|
||||||
|
|
@ -67,12 +91,32 @@ export const RepositoryInfoTabContent = ({ repository }: Props) => {
|
||||||
const confirmUpdate = () => {
|
const confirmUpdate = () => {
|
||||||
updateMutation.mutate({
|
updateMutation.mutate({
|
||||||
path: { id: repository.id },
|
path: { id: repository.id },
|
||||||
body: { name, compressionMode },
|
body: {
|
||||||
|
name,
|
||||||
|
compressionMode,
|
||||||
|
uploadLimit: {
|
||||||
|
enabled: uploadLimitEnabled,
|
||||||
|
value: uploadLimitValue,
|
||||||
|
unit: uploadLimitUnit,
|
||||||
|
},
|
||||||
|
downloadLimit: {
|
||||||
|
enabled: downloadLimitEnabled,
|
||||||
|
value: downloadLimitValue,
|
||||||
|
unit: downloadLimitUnit,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasChanges =
|
const hasChanges =
|
||||||
name !== repository.name || compressionMode !== ((repository.compressionMode as CompressionMode) || "off");
|
name !== repository.name ||
|
||||||
|
compressionMode !== ((repository.compressionMode as CompressionMode) || "off") ||
|
||||||
|
uploadLimitEnabled !== ((repository as any).uploadLimitEnabled ?? false) ||
|
||||||
|
uploadLimitValue !== ((repository as any).uploadLimitValue ?? 0) ||
|
||||||
|
uploadLimitUnit !== ((repository as any).uploadLimitUnit ?? "Mbps") ||
|
||||||
|
downloadLimitEnabled !== ((repository as any).downloadLimitEnabled ?? false) ||
|
||||||
|
downloadLimitValue !== ((repository as any).downloadLimitValue ?? 0) ||
|
||||||
|
downloadLimitUnit !== ((repository as any).downloadLimitUnit ?? "Mbps");
|
||||||
|
|
||||||
const config = repository.config as RepositoryConfig;
|
const config = repository.config as RepositoryConfig;
|
||||||
|
|
||||||
|
|
@ -112,6 +156,108 @@ export const RepositoryInfoTabContent = ({ repository }: Props) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Bandwidth Limits Section */}
|
||||||
|
<div>
|
||||||
|
<h3 className="text-lg font-semibold mb-4">Bandwidth Limits</h3>
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
|
{/* Upload Limit */}
|
||||||
|
<div className="space-y-4 rounded-lg border bg-background/50 p-4">
|
||||||
|
<div className="flex flex-row items-start space-x-3 space-y-0">
|
||||||
|
<Checkbox
|
||||||
|
checked={uploadLimitEnabled}
|
||||||
|
onCheckedChange={(checked) => setUploadLimitEnabled(!!checked)}
|
||||||
|
/>
|
||||||
|
<div className="space-y-1 leading-none">
|
||||||
|
<Label>Enable upload speed limit</Label>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
Limit upload speed to the repository
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{uploadLimitEnabled && (
|
||||||
|
<div className="space-y-3 pt-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<div className="flex-1">
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
placeholder="10"
|
||||||
|
min="0"
|
||||||
|
step="0.1"
|
||||||
|
value={uploadLimitValue}
|
||||||
|
onChange={(e) => setUploadLimitValue(parseFloat(e.target.value) || 0)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Select
|
||||||
|
value={uploadLimitUnit}
|
||||||
|
onValueChange={(val) => setUploadLimitUnit(val as BandwidthUnit)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-24 text-xs">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{Object.keys(BANDWIDTH_UNITS).map((unit) => (
|
||||||
|
<SelectItem key={unit} value={unit} className="text-xs">
|
||||||
|
{unit}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Download Limit */}
|
||||||
|
<div className="space-y-4 rounded-lg border bg-background/50 p-4">
|
||||||
|
<div className="flex flex-row items-start space-x-3 space-y-0">
|
||||||
|
<Checkbox
|
||||||
|
checked={downloadLimitEnabled}
|
||||||
|
onCheckedChange={(checked) => setDownloadLimitEnabled(!!checked)}
|
||||||
|
/>
|
||||||
|
<div className="space-y-1 leading-none">
|
||||||
|
<Label>Enable download speed limit</Label>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
Limit download speed from the repository
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{downloadLimitEnabled && (
|
||||||
|
<div className="space-y-3 pt-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<div className="flex-1">
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
placeholder="10"
|
||||||
|
min="0"
|
||||||
|
step="0.1"
|
||||||
|
value={downloadLimitValue}
|
||||||
|
onChange={(e) => setDownloadLimitValue(parseFloat(e.target.value) || 0)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Select
|
||||||
|
value={downloadLimitUnit}
|
||||||
|
onValueChange={(val) => setDownloadLimitUnit(val as BandwidthUnit)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-24 text-xs">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{Object.keys(BANDWIDTH_UNITS).map((unit) => (
|
||||||
|
<SelectItem key={unit} value={unit} className="text-xs">
|
||||||
|
{unit}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-lg font-semibold mb-4">Repository Information</h3>
|
<h3 className="text-lg font-semibold mb-4">Repository Information</h3>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,16 @@ export const deleteRepositoryDto = describeRoute({
|
||||||
export const updateRepositoryBody = type({
|
export const updateRepositoryBody = type({
|
||||||
name: "string?",
|
name: "string?",
|
||||||
compressionMode: type.valueOf(COMPRESSION_MODES).optional(),
|
compressionMode: type.valueOf(COMPRESSION_MODES).optional(),
|
||||||
|
"uploadLimit?": {
|
||||||
|
enabled: "boolean",
|
||||||
|
value: "number >= 0",
|
||||||
|
unit: "string",
|
||||||
|
},
|
||||||
|
"downloadLimit?": {
|
||||||
|
enabled: "boolean",
|
||||||
|
value: "number >= 0",
|
||||||
|
unit: "string",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export type UpdateRepositoryBody = typeof updateRepositoryBody.infer;
|
export type UpdateRepositoryBody = typeof updateRepositoryBody.infer;
|
||||||
|
|
|
||||||
|
|
@ -469,7 +469,15 @@ const tagSnapshots = async (
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateRepository = async (id: string, updates: { name?: string; compressionMode?: CompressionMode }) => {
|
const updateRepository = async (
|
||||||
|
id: string,
|
||||||
|
updates: {
|
||||||
|
name?: string;
|
||||||
|
compressionMode?: CompressionMode;
|
||||||
|
uploadLimit?: { enabled: boolean; value: number; unit: string };
|
||||||
|
downloadLimit?: { enabled: boolean; value: number; unit: string };
|
||||||
|
},
|
||||||
|
) => {
|
||||||
const existing = await findRepository(id);
|
const existing = await findRepository(id);
|
||||||
|
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
|
|
@ -488,14 +496,30 @@ const updateRepository = async (id: string, updates: { name?: string; compressio
|
||||||
newName = updates.name.trim();
|
newName = updates.name.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
const [updated] = await db
|
const updateData: Record<string, any> = {
|
||||||
.update(repositoriesTable)
|
|
||||||
.set({
|
|
||||||
name: newName,
|
name: newName,
|
||||||
compressionMode: updates.compressionMode ?? existing.compressionMode,
|
compressionMode: updates.compressionMode ?? existing.compressionMode,
|
||||||
updatedAt: Date.now(),
|
updatedAt: Date.now(),
|
||||||
config: encryptedConfig,
|
config: encryptedConfig,
|
||||||
})
|
};
|
||||||
|
|
||||||
|
// Update upload limit if provided
|
||||||
|
if (updates.uploadLimit !== undefined) {
|
||||||
|
updateData.uploadLimitEnabled = updates.uploadLimit.enabled;
|
||||||
|
updateData.uploadLimitValue = updates.uploadLimit.value;
|
||||||
|
updateData.uploadLimitUnit = updates.uploadLimit.unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update download limit if provided
|
||||||
|
if (updates.downloadLimit !== undefined) {
|
||||||
|
updateData.downloadLimitEnabled = updates.downloadLimit.enabled;
|
||||||
|
updateData.downloadLimitValue = updates.downloadLimit.value;
|
||||||
|
updateData.downloadLimitUnit = updates.downloadLimit.unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [updated] = await db
|
||||||
|
.update(repositoriesTable)
|
||||||
|
.set(updateData)
|
||||||
.where(eq(repositoriesTable.id, existing.id))
|
.where(eq(repositoriesTable.id, existing.id))
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue