shelving 1.143.0 → 1.143.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/error/BaseError.d.ts +3 -6
- package/error/BaseError.js +6 -13
- package/error/NetworkError.js +0 -1
- package/error/RequestError.d.ts +7 -12
- package/error/RequestError.js +10 -18
- package/error/RequiredError.js +0 -1
- package/error/ResponseError.js +0 -1
- package/error/UnexpectedError.js +0 -1
- package/error/UnimplementedError.js +0 -1
- package/error/ValueError.js +0 -1
- package/package.json +1 -1
- package/util/array.d.ts +1 -1
- package/util/async.d.ts +3 -4
- package/util/boolean.d.ts +1 -1
- package/util/bytes.d.ts +1 -1
- package/util/callback.d.ts +2 -0
- package/util/color.d.ts +1 -1
- package/util/data.d.ts +1 -1
- package/util/date.d.ts +1 -1
- package/util/dictionary.d.ts +1 -1
- package/util/entity.d.ts +1 -1
- package/util/equal.d.ts +1 -1
- package/util/error.d.ts +0 -2
- package/util/error.js +1 -1
- package/util/file.d.ts +1 -1
- package/util/function.d.ts +3 -0
- package/util/http.d.ts +1 -1
- package/util/jwt.d.ts +1 -1
- package/util/link.d.ts +1 -1
- package/util/map.d.ts +1 -1
- package/util/null.d.ts +1 -1
- package/util/number.d.ts +1 -1
- package/util/optional.d.ts +1 -1
- package/util/path.d.ts +1 -1
- package/util/sequence.d.ts +2 -2
- package/util/set.d.ts +1 -1
- package/util/source.d.ts +1 -1
- package/util/string.d.ts +1 -1
- package/util/template.d.ts +1 -1
- package/util/time.d.ts +1 -1
- package/util/undefined.d.ts +1 -1
- package/util/url.d.ts +1 -1
- package/util/validate.d.ts +2 -1
package/error/BaseError.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AnyFunction } from "../util/function.js";
|
|
3
|
-
/** Any calling function or constructor that can appear in a stack tracer. */
|
|
4
|
-
export type AnyCaller = AnyFunction | AnyConstructor;
|
|
1
|
+
import type { AnyCaller } from "../util/function.js";
|
|
5
2
|
/** Options for `BaseError` that provide additional helpful error functionality. */
|
|
6
3
|
export interface BaseErrorOptions extends ErrorOptions {
|
|
7
4
|
/**
|
|
@@ -15,7 +12,7 @@ export interface BaseErrorOptions extends ErrorOptions {
|
|
|
15
12
|
}
|
|
16
13
|
/** An error that provides additional helpful functionality. */
|
|
17
14
|
export declare abstract class BaseError extends Error {
|
|
18
|
-
/** Provide additional named contextual data that
|
|
19
|
-
[key: string]: unknown;
|
|
15
|
+
/** Provide additional named contextual data that is relevant to the `Error` instance. */
|
|
16
|
+
readonly [key: string]: unknown;
|
|
20
17
|
constructor(message?: string, options?: BaseErrorOptions);
|
|
21
18
|
}
|
package/error/BaseError.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
/** An error that provides additional helpful functionality. */
|
|
2
2
|
export class BaseError extends Error {
|
|
3
|
-
constructor(message, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Error.captureStackTrace(this, caller);
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
super(message);
|
|
13
|
-
Error.captureStackTrace(this, BaseError);
|
|
14
|
-
}
|
|
3
|
+
constructor(message, options = {}) {
|
|
4
|
+
super(message, options);
|
|
5
|
+
const { cause, caller = BaseError, ...rest } = options;
|
|
6
|
+
for (const [key, value] of Object.entries(rest))
|
|
7
|
+
this[key] = value;
|
|
8
|
+
Error.captureStackTrace(this, caller);
|
|
15
9
|
}
|
|
16
10
|
}
|
|
17
11
|
BaseError.prototype.name = "BaseError";
|
|
18
|
-
BaseError.prototype.message = "Unknown error";
|
package/error/NetworkError.js
CHANGED
package/error/RequestError.d.ts
CHANGED
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
import { BaseError, type BaseErrorOptions } from "./BaseError.js";
|
|
2
|
-
/** Options for a `RequestError` */
|
|
3
|
-
interface RequestErrorOptions extends BaseErrorOptions {
|
|
4
|
-
code?: number;
|
|
5
|
-
}
|
|
6
2
|
/** Error thrown when a request isn't well-formed. */
|
|
7
3
|
export declare class RequestError extends BaseError {
|
|
8
4
|
/** The corresponding HTTP status code for this error, in the range `400-499` */
|
|
9
|
-
code: number;
|
|
10
|
-
constructor(message?: string, options?:
|
|
5
|
+
readonly code: number;
|
|
6
|
+
constructor(message?: string, options?: BaseErrorOptions);
|
|
11
7
|
}
|
|
12
8
|
/** Thrown if an operation failed because the user is not logged in, or the login information is not well-formed. */
|
|
13
9
|
export declare class UnauthorizedError extends RequestError {
|
|
14
10
|
readonly code: number;
|
|
15
|
-
constructor(message?: string, options?:
|
|
11
|
+
constructor(message?: string, options?: BaseErrorOptions);
|
|
16
12
|
}
|
|
17
13
|
/** Thrown if the requested content is not found. */
|
|
18
14
|
export declare class NotFoundError extends RequestError {
|
|
19
|
-
readonly code
|
|
20
|
-
constructor(message?: string, options?:
|
|
15
|
+
readonly code: number;
|
|
16
|
+
constructor(message?: string, options?: BaseErrorOptions);
|
|
21
17
|
}
|
|
22
18
|
/** Error thrown when a request is is valid and well-formed, but its actual data is not. */
|
|
23
19
|
export declare class UnprocessableError extends RequestError {
|
|
24
20
|
readonly code: number;
|
|
25
|
-
constructor(message?: string, options?:
|
|
21
|
+
constructor(message?: string, options?: BaseErrorOptions);
|
|
26
22
|
}
|
|
27
23
|
/** Thrown if an operation failed because the user is logged in, but does not have sufficient privileges to access this content. */
|
|
28
24
|
export declare class ForbiddenError extends RequestError {
|
|
29
25
|
readonly code: number;
|
|
30
|
-
constructor(message?: string, options?:
|
|
26
|
+
constructor(message?: string, options?: BaseErrorOptions);
|
|
31
27
|
}
|
|
32
|
-
export {};
|
package/error/RequestError.js
CHANGED
|
@@ -2,49 +2,41 @@ import { BaseError } from "./BaseError.js";
|
|
|
2
2
|
/** Error thrown when a request isn't well-formed. */
|
|
3
3
|
export class RequestError extends BaseError {
|
|
4
4
|
/** The corresponding HTTP status code for this error, in the range `400-499` */
|
|
5
|
-
code;
|
|
6
|
-
constructor(message
|
|
5
|
+
code = 400;
|
|
6
|
+
constructor(message, options) {
|
|
7
7
|
super(message, { caller: RequestError, ...options });
|
|
8
|
-
this.code = options?.code || 400;
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
RequestError.prototype.name = "RequestError";
|
|
12
|
-
RequestError.prototype.message = "Invalid request";
|
|
13
11
|
/** Thrown if an operation failed because the user is not logged in, or the login information is not well-formed. */
|
|
14
12
|
export class UnauthorizedError extends RequestError {
|
|
15
13
|
code = 401;
|
|
16
|
-
constructor(message
|
|
17
|
-
super(message, { caller: UnauthorizedError,
|
|
14
|
+
constructor(message, options) {
|
|
15
|
+
super(message, { caller: UnauthorizedError, ...options });
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
UnauthorizedError.prototype.name = "UnauthorizedError";
|
|
21
|
-
UnauthorizedError.prototype.message = "Authorization is required";
|
|
22
19
|
/** Thrown if the requested content is not found. */
|
|
23
20
|
export class NotFoundError extends RequestError {
|
|
24
21
|
code = 404;
|
|
25
|
-
constructor(message
|
|
26
|
-
super(message, { caller: NotFoundError,
|
|
27
|
-
Error.captureStackTrace(this, NotFoundError);
|
|
22
|
+
constructor(message, options) {
|
|
23
|
+
super(message, { caller: NotFoundError, ...options });
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
26
|
NotFoundError.prototype.name = "NotFoundError";
|
|
31
|
-
NotFoundError.prototype.message = "Cannot find requested content";
|
|
32
27
|
/** Error thrown when a request is is valid and well-formed, but its actual data is not. */
|
|
33
28
|
export class UnprocessableError extends RequestError {
|
|
34
29
|
code = 422;
|
|
35
|
-
constructor(message
|
|
36
|
-
super(message, { caller: UnprocessableError,
|
|
37
|
-
Error.captureStackTrace(this, UnprocessableError);
|
|
30
|
+
constructor(message, options) {
|
|
31
|
+
super(message, { caller: UnprocessableError, ...options });
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
UnprocessableError.prototype.name = "UnprocessableError";
|
|
41
|
-
UnprocessableError.prototype.message = "Input data is invalid";
|
|
42
35
|
/** Thrown if an operation failed because the user is logged in, but does not have sufficient privileges to access this content. */
|
|
43
36
|
export class ForbiddenError extends RequestError {
|
|
44
37
|
code = 403;
|
|
45
|
-
constructor(message
|
|
46
|
-
super(message, { caller: ForbiddenError,
|
|
38
|
+
constructor(message, options) {
|
|
39
|
+
super(message, { caller: ForbiddenError, ...options });
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
42
|
ForbiddenError.prototype.name = "ForbiddenError";
|
|
50
|
-
ForbiddenError.prototype.message = "Insufficient privileges to access this content";
|
package/error/RequiredError.js
CHANGED
package/error/ResponseError.js
CHANGED
package/error/UnexpectedError.js
CHANGED
package/error/ValueError.js
CHANGED
package/package.json
CHANGED
package/util/array.d.ts
CHANGED
package/util/async.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ImmutableArray } from "./array.js";
|
|
2
|
-
import type { ValueCallback } from "./callback.js";
|
|
3
|
-
import type { Report } from "./error.js";
|
|
2
|
+
import type { ErrorCallback, ValueCallback } from "./callback.js";
|
|
4
3
|
/** Is a value an asynchronous value implementing a `then()` function. */
|
|
5
4
|
export declare function isAsync<T>(value: PromiseLike<T> | T): value is PromiseLike<T>;
|
|
6
5
|
/** Is a value a synchronous value. */
|
|
@@ -39,14 +38,14 @@ export declare abstract class AbstractPromise<T> extends Promise<T> {
|
|
|
39
38
|
/** Resolve this promise with a value. */
|
|
40
39
|
protected readonly _resolve: ValueCallback<T>;
|
|
41
40
|
/** Reject this promise with a reason. */
|
|
42
|
-
protected readonly _reject:
|
|
41
|
+
protected readonly _reject: ErrorCallback;
|
|
43
42
|
constructor();
|
|
44
43
|
}
|
|
45
44
|
/** Deferred allows you to access the internal resolve/reject callbacks of a `Promise` */
|
|
46
45
|
export type Deferred<T> = {
|
|
47
46
|
promise: Promise<T>;
|
|
48
47
|
resolve: ValueCallback<T>;
|
|
49
|
-
reject:
|
|
48
|
+
reject: ErrorCallback;
|
|
50
49
|
};
|
|
51
50
|
/**
|
|
52
51
|
* Get a deferred to access the `resolve()` and `reject()` functions of a promise.
|
package/util/boolean.d.ts
CHANGED
package/util/bytes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyCaller } from "
|
|
1
|
+
import type { AnyCaller } from "./function.js";
|
|
2
2
|
/** Types that can be converted to a `Uint8Array` byte sequence. */
|
|
3
3
|
export type PossibleBytes = Uint8Array | ArrayBuffer | string;
|
|
4
4
|
/** Assert that an unknown value is a `Uint8Array` byte sequence. */
|
package/util/callback.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type AsyncValueCallback<T = void> = (value: T) => void | PromiseLike<void
|
|
|
11
11
|
export type ValuesCallback<T extends Arguments = []> = (...values: T) => void;
|
|
12
12
|
/** Callback function that receives multiple values and possibly returns a promise that must be handled. */
|
|
13
13
|
export type AsyncValuesCallback<T extends Arguments = []> = (...values: T) => void | PromiseLike<void>;
|
|
14
|
+
/** Callback function that receives an error. */
|
|
15
|
+
export type ErrorCallback = (reason: unknown) => void;
|
|
14
16
|
/** Safely call a callback function (possibly with a value). */
|
|
15
17
|
export declare function call<A extends Arguments = []>(callback: (...v: A) => unknown, ...values: A): void;
|
|
16
18
|
/** Return a callback function that safely calls a callback function (possibly with a value). */
|
package/util/color.d.ts
CHANGED
package/util/data.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AnyCaller } from "../error/BaseError.js";
|
|
2
1
|
import type { ImmutableArray } from "./array.js";
|
|
3
2
|
import type { EntryObject } from "./entry.js";
|
|
3
|
+
import type { AnyCaller } from "./function.js";
|
|
4
4
|
import type { DeepPartial } from "./object.js";
|
|
5
5
|
/** Data object. */
|
|
6
6
|
export type Data = {
|
package/util/date.d.ts
CHANGED
package/util/dictionary.d.ts
CHANGED
package/util/entity.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyCaller } from "
|
|
1
|
+
import type { AnyCaller } from "./function.js";
|
|
2
2
|
import type { Optional } from "./optional.js";
|
|
3
3
|
/** Entity strings combine a type and ID, e.g. `challenge:a1b2c3` */
|
|
4
4
|
export type Entity<T extends string = string> = `${T}:${string}`;
|
package/util/equal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AnyCaller } from "../error/BaseError.js";
|
|
2
1
|
import type { ImmutableArray } from "./array.js";
|
|
3
2
|
import type { Match } from "./filter.js";
|
|
3
|
+
import type { AnyCaller } from "./function.js";
|
|
4
4
|
import type { ImmutableMap } from "./map.js";
|
|
5
5
|
import type { ImmutableObject } from "./object.js";
|
|
6
6
|
/** Assert two values are equal. */
|
package/util/error.d.ts
CHANGED
package/util/error.js
CHANGED
package/util/file.d.ts
CHANGED
package/util/function.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { AnyConstructor } from "./class.js";
|
|
1
2
|
/** Unknown function. */
|
|
2
3
|
export type UnknownFunction = (...args: unknown[]) => unknown;
|
|
3
4
|
/** Any function (purposefully as wide as possible for use with `extends X` or `is X` statements). */
|
|
4
5
|
export type AnyFunction = (...args: any) => any;
|
|
6
|
+
/** Any calling function or constructor, usually referring to something that can call in the current scope that can appear in a stack trace. */
|
|
7
|
+
export type AnyCaller = AnyFunction | AnyConstructor;
|
|
5
8
|
/** Is a value a function? */
|
|
6
9
|
export declare function isFunction(value: unknown): value is AnyFunction;
|
|
7
10
|
/** Assert that a value is a function. */
|
package/util/http.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AnyCaller } from "../error/BaseError.js";
|
|
2
1
|
import { RequestError } from "../error/RequestError.js";
|
|
3
2
|
import { ResponseError } from "../error/ResponseError.js";
|
|
3
|
+
import type { AnyCaller } from "./function.js";
|
|
4
4
|
/** A handler function takes a `Request` and returns a `Response` (possibly asynchronously). */
|
|
5
5
|
export type RequestHandler = (request: Request) => Response | Promise<Response>;
|
|
6
6
|
export declare function _getMessageJSON(message: Request | Response, MessageError: typeof RequestError | typeof ResponseError, caller: AnyCaller): Promise<unknown>;
|
package/util/jwt.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AnyCaller } from "../error/BaseError.js";
|
|
2
1
|
import { type PossibleBytes } from "./bytes.js";
|
|
3
2
|
import type { Data } from "./data.js";
|
|
3
|
+
import type { AnyCaller } from "./function.js";
|
|
4
4
|
/**
|
|
5
5
|
* Encode a JWT and return the string token.
|
|
6
6
|
* - Currently only supports HMAC SHA-512 signing.
|
package/util/link.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnyCaller } from "../error/BaseError.js";
|
|
2
1
|
import type { ImmutableArray } from "./array.js";
|
|
2
|
+
import type { AnyCaller } from "./function.js";
|
|
3
3
|
import type { Optional } from "./optional.js";
|
|
4
4
|
import type { Path } from "./path.js";
|
|
5
5
|
import { type PossibleURL } from "./url.js";
|
package/util/map.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnyCaller } from "../error/BaseError.js";
|
|
2
1
|
import type { Entry } from "./entry.js";
|
|
2
|
+
import type { AnyCaller } from "./function.js";
|
|
3
3
|
/** `Map` that cannot be changed. */
|
|
4
4
|
export type ImmutableMap<K = unknown, T = unknown> = ReadonlyMap<K, T>;
|
|
5
5
|
/** Class for a `Map` that cannot be changed (so you can extend `Map` while implementing `ImmutableMap`). */
|
package/util/null.d.ts
CHANGED
package/util/number.d.ts
CHANGED
package/util/optional.d.ts
CHANGED
package/util/path.d.ts
CHANGED
package/util/sequence.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AsyncValueCallback, ValueCallback } from "./callback.js";
|
|
2
|
+
import type { ErrorCallback } from "./callback.js";
|
|
2
3
|
import { STOP } from "./constants.js";
|
|
3
|
-
import type { Report } from "./error.js";
|
|
4
4
|
import type { Stop } from "./start.js";
|
|
5
5
|
/**
|
|
6
6
|
* Is a value an async iterable object?
|
|
@@ -15,4 +15,4 @@ export declare function repeatDelay(ms: number): AsyncIterable<number>;
|
|
|
15
15
|
/** Dispatch items in a sequence to a (possibly async) callback. */
|
|
16
16
|
export declare function callSequence<T>(sequence: AsyncIterable<T>, callback: AsyncValueCallback<T>): AsyncIterable<T>;
|
|
17
17
|
/** Pull values from a sequence until the returned function is called. */
|
|
18
|
-
export declare function runSequence<T>(sequence: AsyncIterable<T>, onNext?: ValueCallback<T>, onError?:
|
|
18
|
+
export declare function runSequence<T>(sequence: AsyncIterable<T>, onNext?: ValueCallback<T>, onError?: ErrorCallback): Stop;
|
package/util/set.d.ts
CHANGED
package/util/source.d.ts
CHANGED
package/util/string.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnyCaller } from "../error/BaseError.js";
|
|
2
1
|
import type { ImmutableArray } from "./array.js";
|
|
2
|
+
import type { AnyCaller } from "./function.js";
|
|
3
3
|
/**
|
|
4
4
|
* Type that never matches the `string` type.
|
|
5
5
|
* - `string` itself is iterable (iterating over its individual characters) and implements `Iterable<string>`
|
package/util/template.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AnyCaller } from "../error/BaseError.js";
|
|
2
1
|
import type { ImmutableArray } from "./array.js";
|
|
3
2
|
import { type ImmutableDictionary } from "./dictionary.js";
|
|
3
|
+
import type { AnyCaller } from "./function.js";
|
|
4
4
|
import type { NotString } from "./string.js";
|
|
5
5
|
/** Dictionary of named template values in `{ myPlaceholder: "value" }` format. */
|
|
6
6
|
export type TemplateDictionary = ImmutableDictionary<string>;
|
package/util/time.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyCaller } from "
|
|
1
|
+
import type { AnyCaller } from "./function.js";
|
|
2
2
|
/** Class representing a time in the day in 24 hour format in the user's current locale. */
|
|
3
3
|
export declare class Time {
|
|
4
4
|
/** Make a new `Time` instance from a time string. */
|
package/util/undefined.d.ts
CHANGED
package/util/url.d.ts
CHANGED
package/util/validate.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BaseError, BaseErrorOptions } from "../error/BaseError.js";
|
|
2
2
|
import type { ImmutableArray, PossibleArray } from "./array.js";
|
|
3
3
|
import type { Constructor } from "./class.js";
|
|
4
4
|
import type { Data } from "./data.js";
|
|
5
5
|
import type { ImmutableDictionary } from "./dictionary.js";
|
|
6
|
+
import type { AnyCaller } from "./function.js";
|
|
6
7
|
import type { DeepPartial } from "./object.js";
|
|
7
8
|
/** Object that can validate an unknown value with its `validate()` method. */
|
|
8
9
|
export interface Validator<T> {
|