feat: complete Ancestor quote bot with production-ready Docker support

This commit is contained in:
unfunny
2026-09-13 14:14:38 -04:00
parent f2016da05a
commit fe7351a7dc
1145 changed files with 30890 additions and 97684 deletions

View File

@@ -1,21 +1,26 @@
import { type TypedEventEmitter } from "../models/typed-event-emitter.ts";
import { Method } from "./method.ts";
import { type BaseRequestOpts, HttpApiEvent, type HttpApiEventHandlerMap, type IHttpOpts, type IRequestOpts, type Body } from "./interface.ts";
import { type QueryDict } from "../utils.ts";
import { TypedEventEmitter } from "../models/typed-event-emitter";
import { Method } from "./method";
import { HttpApiEvent, HttpApiEventHandlerMap, IHttpOpts, IRequestOpts, Body } from "./interface";
import { QueryDict } from "../utils";
interface TypedResponse<T> extends Response {
json(): Promise<T>;
}
export type ResponseType<T, O extends IHttpOpts> = O extends undefined ? T : O extends {
onlyData: true;
} ? T : TypedResponse<T>;
export declare class FetchHttpApi<O extends IHttpOpts> {
private eventEmitter;
readonly opts: O;
private abortController;
private readonly tokenRefresher;
constructor(eventEmitter: TypedEventEmitter<HttpApiEvent, HttpApiEventHandlerMap>, opts: O);
abort(): void;
fetch(resource: URL | string, options?: RequestInit): ReturnType<typeof globalThis.fetch>;
fetch(resource: URL | string, options?: RequestInit): ReturnType<typeof global.fetch>;
/**
* Sets the base URL for the identity server
* @param url - The new base url
*/
setIdBaseUrl(url?: string): void;
idServerRequest<T extends object = Record<string, unknown>>(method: Method, path: string, params: Record<string, string | string[]> | undefined, prefix: string, accessToken?: string): Promise<T>;
idServerRequest<T extends {} = Record<string, unknown>>(method: Method, path: string, params: Record<string, string | string[]> | undefined, prefix: string, accessToken?: string): Promise<ResponseType<T, O>>;
/**
* Perform an authorised request to the homeserver.
* @param method - The HTTP method e.g. "GET".
@@ -27,15 +32,22 @@ export declare class FetchHttpApi<O extends IHttpOpts> {
*
* @param body - The HTTP JSON body.
*
* @param paramOpts - additional options.
* When `paramOpts.doNotAttemptTokenRefresh` is true, token refresh will not be attempted
* when an expired token is encountered. Used to only attempt token refresh once.
* @param opts - additional options. If a number is specified,
* this is treated as `opts.localTimeoutMs`.
*
* @returns The parsed response.
* @throws Error if a problem occurred. This includes network problems and Matrix-specific error JSON.
* @returns Promise which resolves to
* ```
* {
* data: {Object},
* headers: {Object},
* code: {Number},
* }
* ```
* If `onlyData` is set, this will resolve to the `data` object only.
* @returns Rejects with an error if a problem occurred.
* This includes network problems and Matrix-specific error JSON.
*/
authedRequest<T>(method: Method, path: string, queryParams?: QueryDict, body?: Body, paramOpts?: IRequestOpts): Promise<T>;
private doAuthedRequest;
authedRequest<T>(method: Method, path: string, queryParams?: QueryDict, body?: Body, opts?: IRequestOpts): Promise<ResponseType<T, O>>;
/**
* Perform a request to the homeserver without any credentials.
* @param method - The HTTP method e.g. "GET".
@@ -49,10 +61,20 @@ export declare class FetchHttpApi<O extends IHttpOpts> {
*
* @param opts - additional options
*
* @returns The parsed response.
* @throws Error if a problem occurred. This includes network problems and Matrix-specific error JSON.
* @returns Promise which resolves to
* ```
* {
* data: {Object},
* headers: {Object},
* code: {Number},
* }
* ```
* If `onlyData</code> is set, this will resolve to the <code>data`
* object only.
* @returns Rejects with an error if a problem
* occurred. This includes network problems and Matrix-specific error JSON.
*/
request<T = unknown>(method: Method, path: string, queryParams?: QueryDict, body?: Body, opts?: IRequestOpts): Promise<T>;
request<T>(method: Method, path: string, queryParams?: QueryDict, body?: Body, opts?: IRequestOpts): Promise<ResponseType<T, O>>;
/**
* Perform a request to an arbitrary URL.
* @param method - The HTTP method e.g. "GET".
@@ -62,10 +84,12 @@ export declare class FetchHttpApi<O extends IHttpOpts> {
*
* @param opts - additional options
*
* @returns The parsed response.
* @throws Error if a problem occurred. This includes network problems and Matrix-specific error JSON.
* @returns Promise which resolves to data unless `onlyData` is specified as false,
* where the resolved value will be a fetch Response object.
* @returns Rejects with an error if a problem
* occurred. This includes network problems and Matrix-specific error JSON.
*/
requestOtherUrl<T>(method: Method, url: URL | string, body?: Body, opts?: BaseRequestOpts): Promise<T>;
requestOtherUrl<T>(method: Method, url: URL | string, body?: Body, opts?: Pick<IRequestOpts, "headers" | "json" | "localTimeoutMs" | "keepAlive" | "abortSignal" | "priority">): Promise<ResponseType<T, O>>;
private sanitizeUrlForLogs;
/**
* Form and return a homeserver request URL based on the given path params and prefix.
@@ -77,4 +101,5 @@ export declare class FetchHttpApi<O extends IHttpOpts> {
*/
getUrl(path: string, queryParams?: QueryDict, prefix?: string, baseUrl?: string): URL;
}
export {};
//# sourceMappingURL=fetch.d.ts.map