ts / dist / cjs / errors.d.ts
494 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
 * Every failure raised by this client is a plain `Error` tagged with a
 * `kind`, so callers narrow with the type guards below (or on `kind`):
 *
 *   try { await domains.check(client, 'x.ro') }
 *   catch (e) { if (isApiError(e) && e.status === 402) ... }
 */
export type ApiError = Error & Readonly<{
    kind: 'api';
    /** Machine-readable error code from the API, when present. */
    code: string | null;
    /** HTTP status of the failed response. */
    status: number;
    /** The parsed error body, when it was JSON. */
    response: unknown;
}>;
export type TransportError = Error & Readonly<{
    kind: 'transport';
    detail: unknown;
}>;
export type ConfigError = Error & Readonly<{
    kind: 'config';
    detail: unknown;
}>;
export type DomainDeniedError = Error & Readonly<{
    kind: 'domainDenied';
    /** The normalized domain that was denied, or null when it could not be resolved. */
    domain: string | null;
    /** The deny/allow pattern that decided, or null when denied by an allow-list miss. */
    matchedPattern: string | null;
    /** The operation that was blocked, e.g. "POST /domains/registrations". */
    op: string;
}>;
export type TimeoutError = Error & Readonly<{
    kind: 'timeout';
    last: unknown;
}>;
export type JobFailedError = Error & Readonly<{
    kind: 'jobFailed';
    job: unknown;
}>;
export type UploadFailedError = Error & Readonly<{
    kind: 'uploadFailed';
    upload: unknown;
}>;
export type IrdError = ApiError | TransportError | ConfigError | DomainDeniedError | TimeoutError | JobFailedError | UploadFailedError;
export type ErrorKind = IrdError['kind'];
/** Error returned by the ird API (non-2xx HTTP status). */
export declare const apiError: (message: string, code: string | null, status: number, response: unknown) => ApiError;
/** Low-level failure talking to the API (connection failure, non-JSON body, ...). */
export declare const transportError: (message: string, detail: unknown, cause?: unknown) => TransportError;
/** Invalid client configuration or call arguments. */
export declare const configError: (message: string, detail: unknown) => ConfigError;
/**
 * Client-side domain gate violation: the operation targets a domain that the
 * client's deniedDomains/allowedDomains configuration forbids. Thrown before
 * any request reaches the API.
 */
export declare const domainDenied: (domain: string | null, matchedPattern: string | null, op: string) => DomainDeniedError;
/** A polling helper ran past its deadline; `last` is the last response seen. */
export declare const timeoutError: (message: string, last: unknown) => TimeoutError;
/** An async job reached a terminal failed status. */
export declare const jobFailed: (message: string, job: unknown) => JobFailedError;
/** An IPFS upload failed or expired. */
export declare const uploadFailed: (message: string, upload: unknown) => UploadFailedError;
export declare const isIrdError: (e: unknown) => e is IrdError;
export declare const isApiError: (e: unknown) => e is ApiError;
export declare const isTransportError: (e: unknown) => e is TransportError;
export declare const isConfigError: (e: unknown) => e is ConfigError;
export declare const isDomainDeniedError: (e: unknown) => e is DomainDeniedError;
export declare const isTimeoutError: (e: unknown) => e is TimeoutError;
export declare const isJobFailedError: (e: unknown) => e is JobFailedError;
export declare const isUploadFailedError: (e: unknown) => e is UploadFailedError;

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/ts.git