@follow-app/client-sdk
Version:
TypeScript client SDK for Follow RSS Server API
581 lines (580 loc) • 19.2 kB
text/typescript
import * as zod from "zod";
import * as better_auth0 from "better-auth";
//#region .generated/auth-plugins/index.d.ts
//#region ../../node_modules/better-call/dist/helper.d.mts
type Prettify<T> = { [K in keyof T]: T[K] } & {};
type IsEmptyObject<T> = keyof T extends never ? true : false;
type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}:${infer Param}` ? { [K in Param]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamPath<Rest> : {};
type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/${infer Rest}` | `${infer _Start}/**:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}/*` ? { [K in "_"]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamWildCard<Rest> : {}; //#endregion
//#endregion
//#region ../../node_modules/better-call/dist/standard-schema.d.mts
//#region src/standard-schema.d.ts
/** The Standard Schema interface. */
interface StandardSchemaV1<Input = unknown, Output = Input> {
/** The Standard Schema properties. */
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
}
declare namespace StandardSchemaV1 {
/** The Standard Schema properties interface. */
interface Props<Input = unknown, Output = Input> {
/** The version number of the standard. */
readonly version: 1;
/** The vendor name of the schema library. */
readonly vendor: string;
/** Validates unknown input values. */
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
/** Inferred types associated with the schema. */
readonly types?: Types<Input, Output> | undefined;
}
/** The result interface of the validate function. */
type Result<Output> = SuccessResult<Output> | FailureResult;
/** The result interface if validation succeeds. */
interface SuccessResult<Output> {
/** The typed output value. */
readonly value: Output;
/** The non-existent issues. */
readonly issues?: undefined;
}
/** The result interface if validation fails. */
interface FailureResult {
/** The issues of failed validation. */
readonly issues: ReadonlyArray<Issue>;
}
/** The issue interface of the failure output. */
interface Issue {
/** The error message of the issue. */
readonly message: string;
/** The path of the issue, if any. */
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
}
/** The path segment interface of the issue. */
interface PathSegment {
/** The key representing a path segment. */
readonly key: PropertyKey;
}
/** The Standard Schema types interface. */
interface Types<Input = unknown, Output = Input> {
/** The input type of the schema. */
readonly input: Input;
/** The output type of the schema. */
readonly output: Output;
}
/** Infers the input type of a Standard Schema. */
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
/** Infers the output type of a Standard Schema. */
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
} //#endregion
//#endregion
//#region ../../node_modules/better-call/dist/error.d.mts
declare const statusCodes: {
OK: number;
CREATED: number;
ACCEPTED: number;
NO_CONTENT: number;
MULTIPLE_CHOICES: number;
MOVED_PERMANENTLY: number;
FOUND: number;
SEE_OTHER: number;
NOT_MODIFIED: number;
TEMPORARY_REDIRECT: number;
BAD_REQUEST: number;
UNAUTHORIZED: number;
PAYMENT_REQUIRED: number;
FORBIDDEN: number;
NOT_FOUND: number;
METHOD_NOT_ALLOWED: number;
NOT_ACCEPTABLE: number;
PROXY_AUTHENTICATION_REQUIRED: number;
REQUEST_TIMEOUT: number;
CONFLICT: number;
GONE: number;
LENGTH_REQUIRED: number;
PRECONDITION_FAILED: number;
PAYLOAD_TOO_LARGE: number;
URI_TOO_LONG: number;
UNSUPPORTED_MEDIA_TYPE: number;
RANGE_NOT_SATISFIABLE: number;
EXPECTATION_FAILED: number;
"I'M_A_TEAPOT": number;
MISDIRECTED_REQUEST: number;
UNPROCESSABLE_ENTITY: number;
LOCKED: number;
FAILED_DEPENDENCY: number;
TOO_EARLY: number;
UPGRADE_REQUIRED: number;
PRECONDITION_REQUIRED: number;
TOO_MANY_REQUESTS: number;
REQUEST_HEADER_FIELDS_TOO_LARGE: number;
UNAVAILABLE_FOR_LEGAL_REASONS: number;
INTERNAL_SERVER_ERROR: number;
NOT_IMPLEMENTED: number;
BAD_GATEWAY: number;
SERVICE_UNAVAILABLE: number;
GATEWAY_TIMEOUT: number;
HTTP_VERSION_NOT_SUPPORTED: number;
VARIANT_ALSO_NEGOTIATES: number;
INSUFFICIENT_STORAGE: number;
LOOP_DETECTED: number;
NOT_EXTENDED: number;
NETWORK_AUTHENTICATION_REQUIRED: number;
};
type Status = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
declare class InternalAPIError extends Error {
status: keyof typeof statusCodes | Status;
body: ({
message?: string;
code?: string;
cause?: unknown;
} & Record<string, any>) | undefined;
headers: HeadersInit;
statusCode: number;
constructor(status?: keyof typeof statusCodes | Status, body?: ({
message?: string;
code?: string;
cause?: unknown;
} & Record<string, any>) | undefined, headers?: HeadersInit, statusCode?: number);
}
type APIError$1 = InstanceType<typeof InternalAPIError>;
declare const APIError$1: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED" | undefined, body?: ({
message?: string;
code?: string;
cause?: unknown;
} & Record<string, any>) | undefined, headers?: HeadersInit | undefined, statusCode?: number | undefined) => InternalAPIError & {
errorStack: string | undefined;
}; //#endregion
//#endregion
//#region ../../node_modules/better-call/dist/openapi.d.mts
//#region src/openapi.d.ts
type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
interface OpenAPIParameter {
in: "query" | "path" | "header" | "cookie";
name?: string;
description?: string;
required?: boolean;
schema?: {
type: OpenAPISchemaType;
format?: string;
items?: {
type: OpenAPISchemaType;
};
enum?: string[];
minLength?: number;
description?: string;
default?: string;
example?: string;
};
} //#endregion
//#region ../../node_modules/better-call/dist/endpoint.d.mts
//#region src/endpoint.d.ts
interface EndpointBaseOptions {
/**
* Query Schema
*/
query?: StandardSchemaV1;
/**
* Error Schema
*/
error?: StandardSchemaV1;
/**
* If true headers will be required to be passed in the context
*/
requireHeaders?: boolean;
/**
* If true request object will be required
*/
requireRequest?: boolean;
/**
* Clone the request object from the router
*/
cloneRequest?: boolean;
/**
* If true the body will be undefined
*/
disableBody?: boolean;
/**
* Endpoint metadata
*/
metadata?: {
/**
* Open API definition
*/
openapi?: {
summary?: string;
description?: string;
tags?: string[];
operationId?: string;
parameters?: OpenAPIParameter[];
requestBody?: {
content: {
"application/json": {
schema: {
type?: OpenAPISchemaType;
properties?: Record<string, any>;
required?: string[];
$ref?: string;
};
};
};
};
responses?: {
[status: string]: {
description: string;
content?: {
"application/json"?: {
schema: {
type?: OpenAPISchemaType;
properties?: Record<string, any>;
required?: string[];
$ref?: string;
};
};
"text/plain"?: {
schema?: {
type?: OpenAPISchemaType;
properties?: Record<string, any>;
required?: string[];
$ref?: string;
};
};
"text/html"?: {
schema?: {
type?: OpenAPISchemaType;
properties?: Record<string, any>;
required?: string[];
$ref?: string;
};
};
};
};
};
};
/**
* Infer body and query type from ts interface
*
* useful for generic and dynamic types
*
* @example
* ```ts
* const endpoint = createEndpoint("/path", {
* method: "POST",
* body: z.record(z.string()),
* $Infer: {
* body: {} as {
* type: InferTypeFromOptions<Option> // custom type inference
* }
* }
* }, async(ctx)=>{
* const body = ctx.body
* })
* ```
*/
$Infer?: {
/**
* Body
*/
body?: any;
/**
* Query
*/
query?: Record<string, any>;
};
/**
* If enabled, endpoint won't be exposed over a router
* @deprecated Use path-less endpoints instead
*/
SERVER_ONLY?: boolean;
/**
* If enabled, endpoint won't be exposed as an action to the client
* @deprecated Use path-less endpoints instead
*/
isAction?: boolean;
/**
* Defines the places where the endpoint will be available
*
* Possible options:
* - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
* - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
* - `http` - the endpoint is only exposed to the router
* @default "rpc"
*/
scope?: "rpc" | "server" | "http";
/**
* List of allowed media types (MIME types) for the endpoint
*
* if provided, only the media types in the list will be allowed to be passed in the body
*
* @example
* ```ts
* const endpoint = createEndpoint("/path", {
* method: "POST",
* allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
* }, async(ctx)=>{
* const body = ctx.body
* })
* ```
*/
allowedMediaTypes?: string[];
/**
* Extra metadata
*/
[key: string]: any;
};
/**
* List of middlewares to use
*/
use?: Middleware[];
/**
* A callback to run before any API error is throw or returned
*
* @param e - The API error
* @returns - The response to return
*/
onAPIError?: (e: APIError$1) => void | Promise<void>;
/**
* A callback to run before a validation error is thrown
* You can customize the validation error message by throwing your own APIError
*/
onValidationError?: ({
issues,
message
}: {
message: string;
issues: readonly StandardSchemaV1.Issue[];
}) => void | Promise<void>;
}
type EndpointBodyMethodOptions = {
/**
* Request Method
*/
method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
/**
* Body Schema
*/
body?: StandardSchemaV1;
} | {
/**
* Request Method
*/
method: "GET" | "HEAD" | ("GET" | "HEAD")[];
/**
* Body Schema
*/
body?: never;
} | {
/**
* Request Method
*/
method: "*";
/**
* Body Schema
*/
body?: StandardSchemaV1;
} | {
/**
* Request Method
*/
method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
/**
* Body Schema
*/
body?: StandardSchemaV1;
};
type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
(context: InputContext<Path, Options> & {
asResponse: true;
}): Promise<Response>;
(context: InputContext<Path, Options> & {
returnHeaders: true;
returnStatus: true;
}): Promise<{
headers: Headers;
status: number;
response: Awaited<R>;
}>;
(context: InputContext<Path, Options> & {
returnHeaders: true;
returnStatus: false;
}): Promise<{
headers: Headers;
response: Awaited<R>;
}>;
(context: InputContext<Path, Options> & {
returnHeaders: false;
returnStatus: true;
}): Promise<{
status: number;
response: Awaited<R>;
}>;
(context: InputContext<Path, Options> & {
returnHeaders: false;
returnStatus: false;
}): Promise<R>;
(context: InputContext<Path, Options> & {
returnHeaders: true;
}): Promise<{
headers: Headers;
response: Awaited<R>;
}>;
(context: InputContext<Path, Options> & {
returnStatus: true;
}): Promise<{
status: number;
response: Awaited<R>;
}>;
(context?: InputContext<Path, Options>): Promise<R>;
options: Options;
path: Path;
}; //#endregion
//#region ../../node_modules/better-call/dist/middleware.d.mts
//#region src/middleware.d.ts
interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {}
type MiddlewareInputContext<Options extends MiddlewareOptions> = InferBodyInput<Options> & InferQueryInput<Options> & InferRequestInput<Options> & InferHeadersInput<Options> & {
asResponse?: boolean;
returnHeaders?: boolean;
use?: Middleware[];
};
type Middleware<Options extends MiddlewareOptions = MiddlewareOptions, Handler extends (inputCtx: any) => Promise<any> = any> = Handler & {
options: Options;
}; //#endregion
//#endregion
//#region ../../node_modules/better-call/dist/context.d.mts
//#region src/context.d.ts
type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions, Body = (Options["metadata"] extends {
$Infer: {
body: infer B;
};
} ? B : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["body"]> : undefined)> = undefined extends Body ? {
body?: Body;
} : {
body: Body;
};
type InferQueryInput<Options extends EndpointOptions | MiddlewareOptions, Query = (Options["metadata"] extends {
$Infer: {
query: infer Query;
};
} ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined)> = undefined extends Query ? {
query?: Query;
} : {
query: Query;
};
type InferInputMethod<Options extends EndpointOptions, Method = (Options["method"] extends Array<any> ? Options["method"][number] | undefined : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined)> = undefined extends Method ? {
method?: Method;
} : {
method: Method;
};
type InferParamInput<Path extends string> = [Path] extends [never] ? {
params?: Record<string, any>;
} : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
params?: Record<string, any>;
} : {
params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
};
type InferRequestInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? {
request: Request;
} : {
request?: Request;
};
type InferHeadersInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? {
headers: HeadersInit;
} : {
headers?: HeadersInit;
};
type InputContext<Path extends string, Options extends EndpointOptions> = InferBodyInput<Options> & InferInputMethod<Options> & InferQueryInput<Options> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
asResponse?: boolean;
returnHeaders?: boolean;
returnStatus?: boolean;
use?: Middleware[];
path?: string;
context?: Record<string, any>;
}; //#endregion
//#region ../../apps/core/src/lib/auth-plugins/index.d.ts
declare const authPlugins: ({
id: "customGetProviders";
endpoints: {
customGetProviders: StrictEndpoint<"/get-providers", {
method: "GET";
}, any>;
};
} | {
id: "getAccountInfo";
endpoints: {
getAccountInfo: StrictEndpoint<"/get-account-info", {
method: "GET";
}, ({
id: string;
provider: string;
profile: better_auth0.OAuth2UserInfo;
accountId?: undefined;
} | {
id: string;
accountId: string;
provider: string;
profile: better_auth0.OAuth2UserInfo | undefined;
})[] | null>;
};
} | {
id: "deleteUserCustom";
endpoints: {
deleteUserCustom: StrictEndpoint<"/delete-user-custom", {
method: "POST";
body: zod.ZodObject<{
TOTPCode: zod.ZodOptional<zod.ZodString>;
}, better_auth0.$strip>;
}, void>;
};
} | {
id: "oneTimeToken";
endpoints: {
generateOneTimeToken: StrictEndpoint<"/one-time-token/generate", {
method: "GET";
use: ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<{
session: {
session: Record<string, any> & {
id: string;
createdAt: Date;
updatedAt: Date;
userId: string;
expiresAt: Date;
token: string;
ipAddress?: string | null | undefined;
userAgent?: string | null | undefined;
};
user: Record<string, any> & {
id: string;
createdAt: Date;
updatedAt: Date;
email: string;
emailVerified: boolean;
name: string;
image?: string | null | undefined;
};
};
}>)[];
}, {
token: string;
}>;
applyOneTimeToken: StrictEndpoint<"/one-time-token/apply", {
method: "POST";
body: zod.ZodObject<{
token: zod.ZodString;
}, better_auth0.$strip>;
}, {
user: {
id: string;
createdAt: Date;
updatedAt: Date;
email: string;
emailVerified: boolean;
name: string;
image?: string | null | undefined;
} & Record<string, any>;
}>;
};
})[]; //#endregion
//#endregion
//#region src/auth.d.ts
type AuthPlugins = typeof authPlugins;
//#endregion
export { AuthPlugins };