lunibee 0.3.1 → 0.3.3
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/dist/builders/attachment.d.ts +1 -0
- package/dist/builders/clone.d.ts +10 -0
- package/dist/builders/commands.d.ts +1 -1
- package/dist/builders/components.d.ts +24 -5
- package/dist/builders/index.js +64 -17
- package/dist/builders/index.js.map +10 -9
- package/dist/collection/index.d.ts +1 -0
- package/dist/collection/index.js +297 -19
- package/dist/collection/index.js.map +5 -4
- package/dist/collection/redis.d.ts +98 -0
- package/dist/core/collector.d.ts +8 -0
- package/dist/core/events.d.ts +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +6242 -4733
- package/dist/core/index.js.map +47 -40
- package/dist/core/permissions.d.ts +3 -402
- package/dist/core/redis-cache.d.ts +85 -0
- package/dist/formatters/index.d.ts +5 -1
- package/dist/formatters/index.js +7 -3
- package/dist/formatters/index.js.map +3 -3
- package/dist/handlers/index.js +11 -2
- package/dist/handlers/index.js.map +3 -3
- package/dist/index.js +8688 -6136
- package/dist/index.js.map +67 -59
- package/dist/managers/application.d.ts +10 -6
- package/dist/managers/base.d.ts +11 -1
- package/dist/managers/guild.d.ts +3 -1
- package/dist/managers/index.d.ts +6 -1
- package/dist/managers/index.js +383 -109
- package/dist/managers/index.js.map +20 -23
- package/dist/managers/member.d.ts +3 -1
- package/dist/managers/message.d.ts +13 -4
- package/dist/managers/thread.d.ts +3 -3
- package/dist/rest/decoder.d.ts +2 -0
- package/dist/rest/errors.d.ts +5 -2
- package/dist/rest/headers.d.ts +31 -0
- package/dist/rest/identity.d.ts +31 -0
- package/dist/rest/index.d.ts +97 -6
- package/dist/rest/index.js +1355 -220
- package/dist/rest/index.js.map +16 -13
- package/dist/rest/limiter.d.ts +75 -10
- package/dist/rest/redis.d.ts +103 -22
- package/dist/rest/scheduler.d.ts +13 -0
- package/dist/rest/store.d.ts +135 -12
- package/dist/rest/telemetry.d.ts +151 -0
- package/dist/rest/webhook.d.ts +18 -6
- package/dist/sharding/bus.d.ts +4 -2
- package/dist/sharding/cluster.d.ts +29 -1
- package/dist/sharding/health.d.ts +1 -1
- package/dist/sharding/host.d.ts +13 -2
- package/dist/sharding/identify.d.ts +2 -0
- package/dist/sharding/index.d.ts +8 -0
- package/dist/sharding/index.js +579 -65
- package/dist/sharding/index.js.map +17 -15
- package/dist/sharding/leader.d.ts +34 -0
- package/dist/sharding/remote.d.ts +36 -2
- package/dist/sharding/supervisor.d.ts +1 -1
- package/dist/sharding/thread.d.ts +30 -0
- package/dist/sharding/transport.d.ts +6 -5
- package/dist/sharding/worker.d.ts +11 -1
- package/dist/structures/base.d.ts +16 -5
- package/dist/structures/index.d.ts +1 -1
- package/dist/structures/index.js +57 -91
- package/dist/structures/index.js.map +10 -18
- package/dist/structures/options.d.ts +3 -2
- package/dist/structures/permissions.d.ts +409 -0
- package/dist/structures/resources.d.ts +4 -1
- package/dist/types/gateway.d.ts +4 -0
- package/dist/types/index.d.ts +14 -4
- package/dist/types/index.js.map +3 -3
- package/dist/utils/args.d.ts +3 -1
- package/dist/utils/index.d.ts +6 -1
- package/dist/utils/index.js +17 -10
- package/dist/utils/index.js.map +4 -4
- package/dist/voice/index.d.ts +7 -1
- package/dist/voice/index.js +33 -10
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/index.d.ts +2 -0
- package/dist/ws/index.js +32 -4
- package/dist/ws/index.js.map +5 -5
- package/package.json +21 -17
package/dist/rest/webhook.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type RESTFileAttachment } from "./index.js";
|
|
2
|
-
import type { APIEmbed, APIMessage, APIMessageComponent } from "@lunibee/types";
|
|
2
|
+
import type { AllowedMentions, APIEmbed, APIMessage, APIMessageComponent } from "@lunibee/types";
|
|
3
|
+
/** Where a `WebhookClient` sends: a Discord webhook `url`, or its `id` and `token`. */
|
|
3
4
|
export interface WebhookClientOptions {
|
|
4
5
|
id?: string;
|
|
5
6
|
token?: string;
|
|
6
7
|
url?: string;
|
|
7
8
|
}
|
|
9
|
+
/** A webhook message for `send()` and `editMessage()`; camelCase aliases (`avatarURL`, `threadId`, `allowedMentions`) are accepted beside the wire names. */
|
|
8
10
|
export interface WebhookMessageOptions {
|
|
9
11
|
content?: string;
|
|
10
12
|
username?: string;
|
|
@@ -20,6 +22,13 @@ export interface WebhookMessageOptions {
|
|
|
20
22
|
files?: RESTFileAttachment[];
|
|
21
23
|
flags?: number;
|
|
22
24
|
thread_id?: string;
|
|
25
|
+
/** Discord.js-familiar alias of `avatar_url`. */
|
|
26
|
+
avatarURL?: string;
|
|
27
|
+
/** Discord.js-familiar alias of `thread_id`. */
|
|
28
|
+
threadId?: string;
|
|
29
|
+
/** Discord.js-familiar alias of `allowed_mentions`. */
|
|
30
|
+
allowedMentions?: AllowedMentions;
|
|
31
|
+
allowed_mentions?: AllowedMentions;
|
|
23
32
|
}
|
|
24
33
|
/** Standalone client for sending Discord webhooks. */
|
|
25
34
|
export declare class WebhookClient {
|
|
@@ -34,11 +43,14 @@ export declare class WebhookClient {
|
|
|
34
43
|
});
|
|
35
44
|
/** Sends a message to the webhook. */
|
|
36
45
|
send(options: string | WebhookMessageOptions): Promise<APIMessage>;
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
embeds?: APIEmbed[];
|
|
46
|
+
/** Fetches a message this webhook sent (`threadId` for a message inside a thread). */
|
|
47
|
+
fetchMessage(messageId: string, options?: {
|
|
48
|
+
threadId?: string;
|
|
41
49
|
}): Promise<APIMessage>;
|
|
50
|
+
/** Edits a previously sent webhook message. Takes the same options as {@link WebhookClient.send}, files included. */
|
|
51
|
+
editMessage(messageId: string, options: string | WebhookMessageOptions): Promise<APIMessage>;
|
|
42
52
|
/** Deletes a previously sent webhook message. */
|
|
43
|
-
deleteMessage(messageId: string
|
|
53
|
+
deleteMessage(messageId: string, options?: {
|
|
54
|
+
threadId?: string;
|
|
55
|
+
}): Promise<void>;
|
|
44
56
|
}
|
package/dist/sharding/bus.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare class ShardBus {
|
|
|
55
55
|
/** Registers a message handler. @param type Message type. @param handler Handler callback. @returns This bus. @throws {TypeError} If type or handler is invalid. */
|
|
56
56
|
on<T>(type: string, handler: ShardMessageHandler<T>): this;
|
|
57
57
|
/** Removes a message handler. @param type Message type. @param handler Handler callback. @returns This bus. */
|
|
58
|
-
off<T>(type: string, handler: ShardMessageHandler<T>): this;
|
|
58
|
+
off<T>(type: string, handler: ShardMessageHandler<T> | ((data: T, message: ShardMessage<T>) => unknown)): this;
|
|
59
59
|
/** Registers a listener for errors thrown or rejected by message handlers. Without one, handler errors are isolated and dropped. @param handler Error listener. @returns This bus. @throws {TypeError} If handler is invalid. */
|
|
60
60
|
onError(handler: ShardBusErrorHandler): this;
|
|
61
61
|
/** Removes a handler error listener. @param handler Error listener. @returns This bus. */
|
|
@@ -78,7 +78,9 @@ export declare class ShardBus {
|
|
|
78
78
|
request<R = unknown, T = unknown>(target: number, type: string, data: T, timeoutMs?: number): Promise<R>;
|
|
79
79
|
/**
|
|
80
80
|
* Sends a request to every other shard and collects replies until
|
|
81
|
-
* `expected` have arrived or `timeoutMs` elapses
|
|
81
|
+
* `expected` have arrived or `timeoutMs` elapses. A timeout or a shard
|
|
82
|
+
* going away does not reject; a closed bus, a blank type or too many
|
|
83
|
+
* pending requests does.
|
|
82
84
|
*/
|
|
83
85
|
broadcastRequest<R = unknown, T = unknown>(type: string, data: T, options?: {
|
|
84
86
|
timeoutMs?: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ChildProcess } from "node:child_process";
|
|
2
2
|
import { type ShardReply } from "./bus.js";
|
|
3
3
|
import type { ClusterManagerHealth, ClusterState, WorkerReport } from "./health.js";
|
|
4
|
+
import type { LeaderLock } from "./leader.js";
|
|
4
5
|
import { type HostStatus, type RemoteOptions } from "./remote.js";
|
|
5
6
|
import { type SupervisorOptions } from "./supervisor.js";
|
|
6
7
|
/** Configuration for managing multiple shard clusters. */
|
|
@@ -82,6 +83,22 @@ export interface ClusterManagerOptions {
|
|
|
82
83
|
* workers like local ones. See {@link RemoteOptions}.
|
|
83
84
|
*/
|
|
84
85
|
remote?: RemoteOptions;
|
|
86
|
+
/**
|
|
87
|
+
* Run several coordinators of one deployment, one active at a time, so a
|
|
88
|
+
* standby takes over when the active one dies (`RedisLeaderLock`, or your
|
|
89
|
+
* own {@link LeaderLock}). `spawn()` waits until this coordinator holds
|
|
90
|
+
* the lock. The leader renews it every quarter of `ttl`; if it cannot for
|
|
91
|
+
* half of `ttl` (or another holds it) it kills every cluster at once,
|
|
92
|
+
* closes the host listener, and waits to lead again. A new leader waits
|
|
93
|
+
* two `remote.lease`s before it starts clusters, so the previous leader's
|
|
94
|
+
* hosts have fenced themselves. Point hosts at every coordinator
|
|
95
|
+
* (`ClusterHost` `url` as a list).
|
|
96
|
+
*/
|
|
97
|
+
leader?: {
|
|
98
|
+
lock: LeaderLock;
|
|
99
|
+
/** Lock lifetime in ms. Default 10,000; at least 100. */
|
|
100
|
+
ttl?: number;
|
|
101
|
+
};
|
|
85
102
|
/** Starts a worker process. Defaults to `child_process.fork()`; replace it for tests or custom launchers. */
|
|
86
103
|
fork?: (script: string, env: Record<string, string | undefined>) => ChildProcess;
|
|
87
104
|
/** Interval in milliseconds to automatically check for recommended shard count and re-scale if needed. */
|
|
@@ -179,6 +196,15 @@ export interface ClusterManagerEvents {
|
|
|
179
196
|
hostJoin: [hostId: string];
|
|
180
197
|
/** A host left or was lost. Its clusters are treated as crashed. */
|
|
181
198
|
hostLeave: [hostId: string, reason: string];
|
|
199
|
+
/** A lost host's cluster is restarting on another host (`remote.moveClusters`). */
|
|
200
|
+
clusterMoved: [cluster: ClusterInfo, info: {
|
|
201
|
+
from: string;
|
|
202
|
+
to: string;
|
|
203
|
+
}];
|
|
204
|
+
/** This coordinator took the `leader` lock and will start the clusters. */
|
|
205
|
+
leaderAcquired: [];
|
|
206
|
+
/** This coordinator lost the `leader` lock and killed its clusters; it waits to lead again. */
|
|
207
|
+
leaderLost: [reason: string];
|
|
182
208
|
/** An IDENTIFY is waiting for the session-start budget to reset. */
|
|
183
209
|
identifyWait: [info: {
|
|
184
210
|
shardId: number;
|
|
@@ -238,6 +264,8 @@ export declare class ClusterManager {
|
|
|
238
264
|
* @throws {Error} If called from a cluster worker (a worker must not start the fleet again).
|
|
239
265
|
*/
|
|
240
266
|
spawn(): Promise<void>;
|
|
267
|
+
/** Whether this coordinator holds the `leader` lock; always true without `leader`. */
|
|
268
|
+
get isLeader(): boolean;
|
|
241
269
|
/** The port hosts connect to, once the listener is open (useful with `remote.port: 0`). */
|
|
242
270
|
get remotePort(): number | undefined;
|
|
243
271
|
/** The hosts of this deployment: connected or not, and the clusters on each. Empty without `remote`. */
|
|
@@ -287,6 +315,6 @@ export declare class ClusterManager {
|
|
|
287
315
|
* @param timeoutMs Grace period per child before force-kill. Defaults to the configured `shutdownTimeout` (5000 ms).
|
|
288
316
|
*/
|
|
289
317
|
shutdownAll(timeoutMs?: number): Promise<void>;
|
|
290
|
-
/** Immediately
|
|
318
|
+
/** Immediately sends SIGTERM to every cluster process (no grace period, no SIGKILL escalation) and clears the cluster map. Prefer {@link shutdownAll} for a graceful stop. */
|
|
291
319
|
killAll(): void;
|
|
292
320
|
}
|
|
@@ -78,7 +78,7 @@ export interface ClusterHealth {
|
|
|
78
78
|
lastReadyAt?: number;
|
|
79
79
|
/** Per-shard health from the worker's last report. Empty until it reports. */
|
|
80
80
|
shards: ShardHealth[];
|
|
81
|
-
/** Present when requested with `
|
|
81
|
+
/** Present when requested with `refreshHealth({ metrics: true })` and the worker answered. */
|
|
82
82
|
metrics?: WorkerMetrics;
|
|
83
83
|
/** When `shards` and `metrics` were reported (epoch ms). */
|
|
84
84
|
reportedAt?: number;
|
package/dist/sharding/host.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { ChildProcess } from "node:child_process";
|
|
2
2
|
/** Options for a {@link ClusterHost}. */
|
|
3
3
|
export interface ClusterHostOptions {
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The coordinator's address: `wss://host:port`. `ws://` is accepted for
|
|
6
|
+
* this machine, or anywhere with `allowInsecure`. A list names every
|
|
7
|
+
* coordinator of a deployment with a `leader` lock: the host tries them in
|
|
8
|
+
* turn, and moves to the next whenever one cannot be reached or drops it.
|
|
9
|
+
*/
|
|
10
|
+
url: string | string[];
|
|
6
11
|
/** Connect with `ws://` to a coordinator on another machine, over a network you fully trust. Default false. */
|
|
7
12
|
allowInsecure?: boolean;
|
|
8
13
|
/** The coordinator's shared secret. */
|
|
@@ -20,6 +25,12 @@ export interface ClusterHostOptions {
|
|
|
20
25
|
reconnectDelay?: number;
|
|
21
26
|
/** Longest delay between reconnect attempts, in ms. Default 30,000. */
|
|
22
27
|
maxReconnectDelay?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Attempts `connect()` makes while the coordinator is busy (it answers
|
|
30
|
+
* "too many connections" or the hello timed out) before it gives up.
|
|
31
|
+
* Default 10. A refusal (bad secret, unknown or duplicate id) is final.
|
|
32
|
+
*/
|
|
33
|
+
connectAttempts?: number;
|
|
23
34
|
}
|
|
24
35
|
/** What a {@link ClusterHost} emits. */
|
|
25
36
|
export interface ClusterHostEvents {
|
|
@@ -6,6 +6,8 @@ export interface IdentifyBudget {
|
|
|
6
6
|
remaining: number;
|
|
7
7
|
/** Milliseconds until `remaining` resets, counted from construction. */
|
|
8
8
|
resetAfter: number;
|
|
9
|
+
/** Milliseconds between resets after that one. Discord resets the budget every 24 hours (the default). */
|
|
10
|
+
period?: number;
|
|
9
11
|
}
|
|
10
12
|
/** Options for an {@link IdentifyCoordinator}. */
|
|
11
13
|
export interface IdentifyCoordinatorOptions {
|
package/dist/sharding/index.d.ts
CHANGED
|
@@ -12,8 +12,10 @@ export { ClusterManager } from "./cluster.js";
|
|
|
12
12
|
export type { ClusterManagerOptions, ClusterManagerEvents, ClusterInfo, BroadcastResult, RequestOptions, } from "./cluster.js";
|
|
13
13
|
export { allocateShards, assertCompleteAllocation, isClusterWorker, readClusterContext, validateShardIds, type ClusterContext, } from "./context.js";
|
|
14
14
|
export { ClusterWorker, type IdentifyGate } from "./worker.js";
|
|
15
|
+
export { threadEndpoint, threadFork, type ThreadEndpoint, type ThreadForkOptions, } from "./thread.js";
|
|
15
16
|
export { ClusterHost, type ClusterHostEvents, type ClusterHostOptions, } from "./host.js";
|
|
16
17
|
export type { HostStatus, RemoteOptions } from "./remote.js";
|
|
18
|
+
export { RedisLeaderLock, type LeaderLock, type LeaderRedisClient, type RedisLeaderLockOptions, } from "./leader.js";
|
|
17
19
|
export { RemoteClose, REMOTE_PROTOCOL_VERSION } from "./remote-protocol.js";
|
|
18
20
|
export { IdentifyCoordinator, IDENTIFY_INTERVAL, type IdentifyBudget, type IdentifyCoordinatorOptions, } from "./identify.js";
|
|
19
21
|
export { RequestTracker } from "./requests.js";
|
|
@@ -91,6 +93,12 @@ export interface ShardManagerEvents {
|
|
|
91
93
|
shardError: [shardId: number, error: Error];
|
|
92
94
|
/** Every shard this manager owns is ready. Emitted again after a shard drops and recovers. */
|
|
93
95
|
ready: [];
|
|
96
|
+
/**
|
|
97
|
+
* A shard's `Gateway` was created and has not connected yet: attach dispatch
|
|
98
|
+
* listeners here so none of its events are missed. Fires again for the new
|
|
99
|
+
* Gateways after `destroy()` + `connect()` or `reshard()`.
|
|
100
|
+
*/
|
|
101
|
+
shardCreate: [shardId: number, gateway: Gateway];
|
|
94
102
|
/** A shard reconnected too often too fast and is backing off (see `Gateway` `unstable`). */
|
|
95
103
|
shardUnstable: [
|
|
96
104
|
shardId: number,
|