snowtransfer 0.18.0 → 0.19.0

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/Constants.d.ts +59 -0
  3. package/dist/Constants.js +123 -0
  4. package/dist/Endpoints.d.ts +120 -0
  5. package/dist/Endpoints.js +121 -0
  6. package/dist/RequestHandler.d.ts +258 -0
  7. package/dist/RequestHandler.js +629 -0
  8. package/dist/SnowTransfer.d.ts +70 -0
  9. package/dist/SnowTransfer.js +105 -0
  10. package/dist/StateMachine.d.ts +104 -0
  11. package/dist/StateMachine.js +238 -0
  12. package/dist/StateMachineGraph.d.ts +3 -0
  13. package/dist/StateMachineGraph.js +23 -0
  14. package/dist/Types.d.ts +76 -0
  15. package/dist/Types.js +2 -0
  16. package/dist/index.d.ts +25 -718
  17. package/dist/index.js +63 -44
  18. package/dist/methods/Assets.d.ts +290 -0
  19. package/dist/methods/Assets.js +326 -0
  20. package/dist/methods/AuditLog.d.ts +40 -0
  21. package/dist/methods/AuditLog.js +44 -0
  22. package/dist/methods/AutoModeration.d.ts +122 -0
  23. package/dist/methods/AutoModeration.js +135 -0
  24. package/dist/methods/Bot.d.ts +65 -0
  25. package/dist/methods/Bot.js +75 -0
  26. package/dist/methods/Channel.d.ts +866 -0
  27. package/dist/methods/Channel.js +982 -0
  28. package/dist/methods/Entitlements.d.ts +87 -0
  29. package/dist/methods/Entitlements.js +99 -0
  30. package/dist/methods/Guild.d.ts +722 -0
  31. package/dist/methods/Guild.js +785 -0
  32. package/dist/methods/GuildScheduledEvent.d.ts +138 -0
  33. package/dist/methods/GuildScheduledEvent.js +155 -0
  34. package/dist/methods/GuildTemplate.d.ts +110 -0
  35. package/dist/methods/GuildTemplate.js +124 -0
  36. package/dist/methods/Interaction.d.ts +339 -0
  37. package/dist/methods/Interaction.js +359 -0
  38. package/dist/methods/Invite.d.ts +81 -0
  39. package/dist/methods/Invite.js +107 -0
  40. package/dist/methods/Sku.d.ts +58 -0
  41. package/dist/methods/Sku.js +66 -0
  42. package/dist/methods/StageInstance.d.ts +86 -0
  43. package/dist/methods/StageInstance.js +97 -0
  44. package/dist/methods/User.d.ts +167 -0
  45. package/dist/methods/User.js +184 -0
  46. package/dist/methods/Voice.d.ts +44 -0
  47. package/dist/methods/Voice.js +52 -0
  48. package/dist/methods/Webhook.d.ts +265 -0
  49. package/dist/methods/Webhook.js +256 -0
  50. package/dist/tokenless.d.ts +19 -0
  51. package/dist/tokenless.js +31 -0
  52. package/package.json +9 -9
  53. package/dist/index.js.map +0 -1
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ const RequestHandler_1 = require("./RequestHandler");
3
+ const AssetsMethods = require("./methods/Assets");
4
+ const AuditLogMethods = require("./methods/AuditLog");
5
+ const AutoModerationMethods = require("./methods/AutoModeration");
6
+ const BotMethods = require("./methods/Bot");
7
+ const ChannelMethods = require("./methods/Channel");
8
+ const EntitlementMethods = require("./methods/Entitlements");
9
+ const GuildMethods = require("./methods/Guild");
10
+ const GuildScheduledEventMethods = require("./methods/GuildScheduledEvent");
11
+ const GuildTemplateMethods = require("./methods/GuildTemplate");
12
+ const InteractionMethods = require("./methods/Interaction");
13
+ const InviteMethods = require("./methods/Invite");
14
+ const SkuMethods = require("./methods/Sku");
15
+ const StageInstanceMethods = require("./methods/StageInstance");
16
+ const UserMethods = require("./methods/User");
17
+ const VoiceMethods = require("./methods/Voice");
18
+ const WebhookMethods = require("./methods/Webhook");
19
+ const Endpoints = require("./Endpoints");
20
+ const Constants = require("./Constants");
21
+ /**
22
+ * @since 0.1.0
23
+ */
24
+ class SnowTransfer {
25
+ /** Options for this SnowTransfer instance */
26
+ options;
27
+ /** The access token to use for requests. Can be a bot or bearer token */
28
+ token;
29
+ /** Methods related to channels */
30
+ channel;
31
+ /** Helper to execute REST calls */
32
+ requestHandler;
33
+ /** Methods related to users */
34
+ user;
35
+ /** Methods related to stickers and emojis */
36
+ assets;
37
+ /** Methods related to webhooks */
38
+ webhook;
39
+ /** Methods related to guilds */
40
+ guild;
41
+ /** Methods related to guild scheduled events */
42
+ guildScheduledEvent;
43
+ /** Methods related to guild templates */
44
+ guildTemplate;
45
+ /** Methods related to application commands/interactions */
46
+ interaction;
47
+ /** Methods related to invites */
48
+ invite;
49
+ /** Methods related to voice regions */
50
+ voice;
51
+ /** Methods related to getting gateway connect info */
52
+ bot;
53
+ /** Methods related to guild audit logs */
54
+ auditLog;
55
+ /** Methods related to guild stage instances */
56
+ stageInstance;
57
+ /** Methods related to guild auto mod */
58
+ autoMod;
59
+ /** Methods related to entitlements */
60
+ entitlement;
61
+ /** Methods related to SKUs */
62
+ sku;
63
+ /** Ratelimiter used for handling the ratelimits imposed by the rest api */
64
+ ratelimiter;
65
+ /**
66
+ * Create a new Rest Client
67
+ * @param token Discord Bot token to use
68
+ * @param options options
69
+ */
70
+ constructor(token, options) {
71
+ if (typeof token === "string" && token === "")
72
+ throw new Error("Missing token");
73
+ if (token && (!token.startsWith("Bot ") && !token.startsWith("Bearer ")))
74
+ token = `Bot ${token}`;
75
+ this.options = { baseHost: Endpoints.BASE_HOST, baseURL: Endpoints.BASE_URL, fetch: globalThis.fetch, allowed_mentions: undefined, bypassBuckets: false, retryRequests: false, retryLimit: Constants.DEFAULT_RETRY_LIMIT, ...options };
76
+ this.token = token;
77
+ this.ratelimiter = new RequestHandler_1.Ratelimiter();
78
+ this.requestHandler = new RequestHandler_1.RequestHandler(this.ratelimiter, {
79
+ token: this.token,
80
+ baseHost: this.options.baseHost,
81
+ baseURL: this.options.baseURL,
82
+ bypassBuckets: this.options.bypassBuckets,
83
+ retryFailed: this.options.retryRequests,
84
+ retryLimit: this.options.retryLimit,
85
+ fetch: this.options.fetch
86
+ });
87
+ this.channel = new ChannelMethods(this.requestHandler, this.options);
88
+ this.user = new UserMethods(this.requestHandler);
89
+ this.assets = new AssetsMethods(this.requestHandler);
90
+ this.webhook = new WebhookMethods(this.requestHandler, this.options);
91
+ this.guild = new GuildMethods(this.requestHandler);
92
+ this.guildScheduledEvent = new GuildScheduledEventMethods(this.requestHandler);
93
+ this.guildTemplate = new GuildTemplateMethods(this.requestHandler);
94
+ this.interaction = new InteractionMethods(this.requestHandler, this.webhook, this.options);
95
+ this.invite = new InviteMethods(this.requestHandler);
96
+ this.voice = new VoiceMethods(this.requestHandler);
97
+ this.bot = new BotMethods(this.requestHandler);
98
+ this.auditLog = new AuditLogMethods(this.requestHandler);
99
+ this.stageInstance = new StageInstanceMethods(this.requestHandler);
100
+ this.autoMod = new AutoModerationMethods(this.requestHandler);
101
+ this.entitlement = new EntitlementMethods(this.requestHandler);
102
+ this.sku = new SkuMethods(this.requestHandler);
103
+ }
104
+ }
105
+ module.exports = SnowTransfer;
@@ -0,0 +1,104 @@
1
+ import { EventEmitter } from "node:events";
2
+ import type { SMState, SMTransition } from "./Types";
3
+ interface StateMachineEvents {
4
+ enter: [string];
5
+ }
6
+ /**
7
+ * Class used to define states code is expected to be in and transitions to other states and code to run during those transitions and states
8
+ * @since 0.16.0
9
+ */
10
+ declare class StateMachine extends EventEmitter<StateMachineEvents> {
11
+ currentStateName: string;
12
+ readonly states: Map<string, SMState>;
13
+ private editable;
14
+ private readonly deferredTransitionCreators;
15
+ private readonly history;
16
+ /** Transitions requested while another transition was still running. Drained in order once the running transition completes. */
17
+ private readonly pendingTransitions;
18
+ /** Whether a transition is currently being executed, making new transition requests queue instead of nesting. */
19
+ private transitioning;
20
+ /**
21
+ * Create a new StateMachine
22
+ * @param currentStateName The state this state machine is currently in. When constructing the StateMachine, this is the entry state.
23
+ */
24
+ constructor(currentStateName: string);
25
+ /**
26
+ * Helper function that throws an Error when something tries to edit the state machine after it has been frozen/finalized.
27
+ * @since 0.16.0
28
+ */
29
+ guardEditable(): void;
30
+ /**
31
+ * Helper function that throws an Error when something tries to use the state machine before it has been frozen/finalized.
32
+ * @since 0.16.0
33
+ */
34
+ guardNotEditable(): void;
35
+ /**
36
+ * Define a state in the state machine.
37
+ * @since 0.16.0
38
+ * @param name The name of the state.
39
+ * @param cbs Callbacks for points during transitions relating to this state as well as transitions to other states.
40
+ */
41
+ defineState(name: string, cbs?: {
42
+ onEnter: SMState["onEnter"];
43
+ onLeave: SMState["onLeave"];
44
+ transitions: Map<string, SMTransition>;
45
+ }): this;
46
+ /**
47
+ * Define a transition between 2 states in the state machine.
48
+ * @since 0.16.0
49
+ * @param from The name of the state this transition would come from.
50
+ * @param event The event that can trigger this transition.
51
+ * @param to The name of the state this transition would go to.
52
+ * @param cb A callback to run when this transition occurs.
53
+ */
54
+ defineTransition(from: string, event: string, to: string, cb?: (...args: any[]) => unknown): this;
55
+ /**
56
+ * Define a transition from every state to another state in the state machine.
57
+ * @since 0.16.0
58
+ * @param event The event that can trigger this transition.
59
+ * @param to The name of the state this transition would go to.
60
+ * @param cb A callback to run when this transition occurs.
61
+ */
62
+ defineUniversalTransition(event: string, to: string, cb?: (...args: any[]) => unknown): this;
63
+ /**
64
+ * Finalize the state machine, making its states and transitions now readonly and usable.
65
+ * @since 0.16.0
66
+ */
67
+ freeze(): void;
68
+ /**
69
+ * Trigger an event to do a transition from the current state to another as defined previously.
70
+ *
71
+ * Will throw an Error if there is no transition from the current state to another based off the event.
72
+ *
73
+ * If called while another transition is still running (from an onLeave/onTransition/onEnter callback or
74
+ * something those callbacks synchronously invoke), the transition is queued and runs once the current one
75
+ * has fully completed, instead of nesting. Nested execution used to corrupt the enter sequence: the outer
76
+ * transition would re-emit "enter" for whatever state the nested transition landed in, re-running that
77
+ * state's onEnter callbacks and cancelling doTransitionLater timers that were still supposed to be pending.
78
+ * @since 0.16.0
79
+ * @param event The event that occurred.
80
+ * @param args Arguments to pass to the callback of the transition's onTransition functions if any.
81
+ */
82
+ doTransition(event: string, ...args: any[]): void;
83
+ /**
84
+ * Runs a single transition to completion: onLeave, state change, onTransition, "enter", onEnter.
85
+ * Only ever called from doTransition's drain loop so transitions cannot nest.
86
+ */
87
+ private _transition;
88
+ /**
89
+ * Trigger an event to do a transition from the current state to another as defined previously at a later point in time.
90
+ *
91
+ * Will throw an Error if there is no transition from the current state to another based off the event.
92
+ * @since 0.16.0
93
+ * @param event The event that occured.
94
+ * @param delayMs The time in milliseconds this transition will run in.
95
+ * @param args Arguments to pass to the callback of the transition's onTransition functions if any.
96
+ */
97
+ doTransitionLater(event: string, delayMs: number, ...args: Array<any>): void;
98
+ /**
99
+ * Print debug info about this state machine to stdout in the form of a table.
100
+ * @since 0.16.0
101
+ */
102
+ debug(): void;
103
+ }
104
+ export = StateMachine;
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ const node_events_1 = require("node:events");
3
+ /**
4
+ * Class used to define states code is expected to be in and transitions to other states and code to run during those transitions and states
5
+ * @since 0.16.0
6
+ */
7
+ class StateMachine extends node_events_1.EventEmitter {
8
+ currentStateName;
9
+ states = new Map();
10
+ editable = true;
11
+ deferredTransitionCreators = [];
12
+ history = [];
13
+ /** Transitions requested while another transition was still running. Drained in order once the running transition completes. */
14
+ pendingTransitions = [];
15
+ /** Whether a transition is currently being executed, making new transition requests queue instead of nesting. */
16
+ transitioning = false;
17
+ /**
18
+ * Create a new StateMachine
19
+ * @param currentStateName The state this state machine is currently in. When constructing the StateMachine, this is the entry state.
20
+ */
21
+ constructor(currentStateName) {
22
+ super();
23
+ this.currentStateName = currentStateName;
24
+ this.deferredTransitionCreators.push(() => {
25
+ if (!this.states.has(currentStateName)) {
26
+ this.defineState(currentStateName);
27
+ }
28
+ });
29
+ }
30
+ /**
31
+ * Helper function that throws an Error when something tries to edit the state machine after it has been frozen/finalized.
32
+ * @since 0.16.0
33
+ */
34
+ guardEditable() {
35
+ if (!this.editable)
36
+ throw new Error("tried to edit state machine after machine has been frozen");
37
+ }
38
+ /**
39
+ * Helper function that throws an Error when something tries to use the state machine before it has been frozen/finalized.
40
+ * @since 0.16.0
41
+ */
42
+ guardNotEditable() {
43
+ if (this.editable)
44
+ throw new Error("tried to do transition before machine has been frozen");
45
+ }
46
+ /**
47
+ * Define a state in the state machine.
48
+ * @since 0.16.0
49
+ * @param name The name of the state.
50
+ * @param cbs Callbacks for points during transitions relating to this state as well as transitions to other states.
51
+ */
52
+ defineState(name, cbs) {
53
+ const options = { onEnter: [], onLeave: [], transitions: new Map(), ...cbs };
54
+ this.guardEditable();
55
+ if (this.states.has(name))
56
+ throw new Error(`attempt to redefine state ${name}, please edit it instead`);
57
+ this.states.set(name, {
58
+ onEnter: options.onEnter,
59
+ onLeave: options.onLeave,
60
+ transitions: options.transitions
61
+ });
62
+ return this;
63
+ }
64
+ /**
65
+ * Define a transition between 2 states in the state machine.
66
+ * @since 0.16.0
67
+ * @param from The name of the state this transition would come from.
68
+ * @param event The event that can trigger this transition.
69
+ * @param to The name of the state this transition would go to.
70
+ * @param cb A callback to run when this transition occurs.
71
+ */
72
+ defineTransition(from, event, to, cb) {
73
+ this.guardEditable();
74
+ const state = this.states.get(from);
75
+ if (state.transitions.has(event))
76
+ throw new Error(`attempt to redefine transition ${from} --${event}--> *, please only create transitions once`);
77
+ const onTransition = [];
78
+ if (cb)
79
+ onTransition.push(cb);
80
+ state.transitions.set(event, { destination: to, onTransition });
81
+ return this;
82
+ }
83
+ /**
84
+ * Define a transition from every state to another state in the state machine.
85
+ * @since 0.16.0
86
+ * @param event The event that can trigger this transition.
87
+ * @param to The name of the state this transition would go to.
88
+ * @param cb A callback to run when this transition occurs.
89
+ */
90
+ defineUniversalTransition(event, to, cb) {
91
+ this.guardEditable();
92
+ this.deferredTransitionCreators.push(() => {
93
+ for (const [stateName, state] of this.states.entries()) {
94
+ if (!state.transitions.has(event)) {
95
+ this.defineTransition(stateName, event, to, cb);
96
+ }
97
+ }
98
+ });
99
+ return this;
100
+ }
101
+ /**
102
+ * Finalize the state machine, making its states and transitions now readonly and usable.
103
+ * @since 0.16.0
104
+ */
105
+ freeze() {
106
+ this.guardEditable();
107
+ // Add deferred transitions
108
+ for (const cb of this.deferredTransitionCreators) {
109
+ cb();
110
+ }
111
+ // Check consistency
112
+ const problems = [];
113
+ for (const [stateName, state] of this.states.entries()) {
114
+ for (const [transitionName, transition] of state.transitions.entries()) {
115
+ if (!this.states.has(transition.destination)) {
116
+ problems.push(`transition ${stateName} --${transitionName}--> ${transition.destination} has an invalid destination`);
117
+ }
118
+ }
119
+ }
120
+ if (problems.length) {
121
+ throw new Error(`Consistency problems in state machine: ${problems.join(";")}`);
122
+ }
123
+ this.editable = false;
124
+ }
125
+ /**
126
+ * Trigger an event to do a transition from the current state to another as defined previously.
127
+ *
128
+ * Will throw an Error if there is no transition from the current state to another based off the event.
129
+ *
130
+ * If called while another transition is still running (from an onLeave/onTransition/onEnter callback or
131
+ * something those callbacks synchronously invoke), the transition is queued and runs once the current one
132
+ * has fully completed, instead of nesting. Nested execution used to corrupt the enter sequence: the outer
133
+ * transition would re-emit "enter" for whatever state the nested transition landed in, re-running that
134
+ * state's onEnter callbacks and cancelling doTransitionLater timers that were still supposed to be pending.
135
+ * @since 0.16.0
136
+ * @param event The event that occurred.
137
+ * @param args Arguments to pass to the callback of the transition's onTransition functions if any.
138
+ */
139
+ doTransition(event, ...args) {
140
+ this.guardNotEditable();
141
+ this.pendingTransitions.push({ event, args });
142
+ if (this.transitioning)
143
+ return; // the drain loop below picks it up once the current transition has fully completed
144
+ this.transitioning = true;
145
+ try {
146
+ while (this.pendingTransitions.length) {
147
+ const next = this.pendingTransitions.shift();
148
+ this._transition(next.event, next.args);
149
+ }
150
+ }
151
+ finally {
152
+ this.transitioning = false;
153
+ this.pendingTransitions.length = 0; // if a transition threw, queued followers must not leak into an unrelated later call
154
+ }
155
+ }
156
+ /**
157
+ * Runs a single transition to completion: onLeave, state change, onTransition, "enter", onEnter.
158
+ * Only ever called from doTransition's drain loop so transitions cannot nest.
159
+ */
160
+ _transition(event, args) {
161
+ const from = this.currentStateName;
162
+ const currentState = this.states.get(this.currentStateName);
163
+ const transition = currentState.transitions.get(event);
164
+ if (!transition)
165
+ throw new Error(`undefined transition: ${this.currentStateName} -> ${event} -> ?`);
166
+ this.history.push({ from, event, to: transition.destination, time: Date.now() });
167
+ if (this.history.length > 20)
168
+ this.history.shift();
169
+ // Leave state
170
+ for (const cb of this.states.get(this.currentStateName).onLeave) {
171
+ try {
172
+ cb(event);
173
+ }
174
+ catch (e) {
175
+ this.debug();
176
+ throw new Error(`onLeave callback for state ${from} (during transition ${from} --${event}--> ${transition.destination})`, { cause: e });
177
+ }
178
+ }
179
+ // Do transition
180
+ this.currentStateName = transition.destination;
181
+ for (const cb of transition.onTransition ?? []) {
182
+ try {
183
+ cb(...args);
184
+ }
185
+ catch (e) {
186
+ this.debug();
187
+ throw new Error(`onTransition callback during ${from} --${event}--> ${transition.destination}`, { cause: e });
188
+ }
189
+ }
190
+ // Enter state
191
+ this.emit("enter", this.currentStateName);
192
+ for (const cb of this.states.get(this.currentStateName).onEnter) {
193
+ try {
194
+ cb(event);
195
+ }
196
+ catch (e) {
197
+ this.debug();
198
+ throw new Error(`onEnter callback for state ${transition.destination} (during transition ${from} --${event}--> ${transition.destination})`, { cause: e });
199
+ }
200
+ }
201
+ }
202
+ /**
203
+ * Trigger an event to do a transition from the current state to another as defined previously at a later point in time.
204
+ *
205
+ * Will throw an Error if there is no transition from the current state to another based off the event.
206
+ * @since 0.16.0
207
+ * @param event The event that occured.
208
+ * @param delayMs The time in milliseconds this transition will run in.
209
+ * @param args Arguments to pass to the callback of the transition's onTransition functions if any.
210
+ */
211
+ doTransitionLater(event, delayMs, ...args) {
212
+ this.guardNotEditable();
213
+ const timer = setTimeout(() => {
214
+ this.doTransition(event, ...args);
215
+ }, delayMs);
216
+ this.once("enter", () => {
217
+ clearTimeout(timer);
218
+ });
219
+ }
220
+ /**
221
+ * Print debug info about this state machine to stdout in the form of a table.
222
+ * @since 0.16.0
223
+ */
224
+ debug() {
225
+ console.table(this.history.map(h => ({
226
+ "At": new Date(h.time),
227
+ "From -->": h.from,
228
+ "-- Event -->": h.event,
229
+ "--> To": h.to
230
+ })).concat({
231
+ "At": new Date(),
232
+ "From -->": this.currentStateName,
233
+ "-- Event -->": "(debug)",
234
+ "--> To": ""
235
+ }));
236
+ }
237
+ }
238
+ module.exports = StateMachine;
@@ -0,0 +1,3 @@
1
+ import StateMachine = require("./StateMachine");
2
+ declare function graph(stateMachine: StateMachine): string;
3
+ export { graph };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.graph = graph;
4
+ function graph(stateMachine) {
5
+ stateMachine.guardNotEditable();
6
+ let output = "digraph {\n";
7
+ output += "rankdir=LR\n";
8
+ output += `${stateMachine.currentStateName}\n`;
9
+ for (const [stateName, state] of stateMachine.states.entries()) {
10
+ if (state.onEnter.length) {
11
+ output += `${stateName} [fontcolor=blue]\n`;
12
+ }
13
+ for (const [transitionName, transition] of state.transitions.entries()) {
14
+ output += `${stateName} -> ${transition.destination}`;
15
+ const attrs = [`label="${transitionName}"`];
16
+ if (transition.onTransition?.length)
17
+ attrs.push("color=blue", "fontcolor=blue");
18
+ output += `[${attrs.join(" ")}]\n`;
19
+ }
20
+ }
21
+ output += "}";
22
+ return output;
23
+ }
@@ -0,0 +1,76 @@
1
+ import type { APIAllowedMentions } from "discord-api-types/v10";
2
+ import type { Readable } from "node:stream";
3
+ export type HTTPMethod = "get" | "post" | "patch" | "head" | "put" | "delete" | "connect" | "options" | "trace";
4
+ /**
5
+ * A file that can be uploaded to Discord's API
6
+ * @since 0.18.1
7
+ */
8
+ export type SendableFile = Buffer | Blob | File | Readable | ReadableStream;
9
+ /**
10
+ * A file to upload, or a factory that produces a fresh one each time the payload is materialized.
11
+ *
12
+ * Streams are single use: once a request has consumed them, sending the same payload again would upload nothing.
13
+ * If you want to reuse a payload containing streams across calls, pass a factory that returns a new stream each time,
14
+ * e.g. `file: () => fs.createReadStream(path)`. Buffers and Blobs are re-readable and don't need this.
15
+ * @since 0.18.1
16
+ */
17
+ export type FileInput = SendableFile | (() => SendableFile | Promise<SendableFile>);
18
+ export type SnowTransferOptions = {
19
+ /** The URL to start requests from. eg: https://discord.com */
20
+ baseHost: string;
21
+ /** The base path of the base URL to use for the API. Defaults to /api/v${Constants.REST_API_VERSION} */
22
+ baseURL: string;
23
+ /** The fetch implementation to use when making requests. Defaults to globalThis.fetch */
24
+ fetch: typeof globalThis.fetch;
25
+ /** The default allowed_mentions object to send when creating/updating messages */
26
+ allowed_mentions: APIAllowedMentions | undefined;
27
+ /** If rate limit buckets should be totally bypassed and functions are executed as fast as possible. Only use if you are 100% certain you wont run into issues or if you are proxying */
28
+ bypassBuckets: boolean;
29
+ /** If failed requests that can be retried should be retried, up to retryLimit times. */
30
+ retryRequests: boolean;
31
+ /** How many times requests should be retried if they fail and can be retried. */
32
+ retryLimit: number;
33
+ };
34
+ export type RESTPostAPIAttachmentsRefreshURLsResult = {
35
+ refreshed_urls: Array<{
36
+ original: string;
37
+ refreshed: string;
38
+ }>;
39
+ };
40
+ export type RatelimitInfo = {
41
+ message: string;
42
+ retry_after: number;
43
+ global: boolean;
44
+ code?: number;
45
+ };
46
+ export type RequestEventData = {
47
+ endpoint: string;
48
+ method: string;
49
+ dataType: "json" | "multipart";
50
+ data: any;
51
+ };
52
+ export type HandlerEvents = {
53
+ request: [string, RequestEventData];
54
+ done: [string, Response, RequestEventData];
55
+ requestError: [string, Error];
56
+ rateLimit: [{
57
+ method: string;
58
+ path: string;
59
+ route: string;
60
+ }];
61
+ };
62
+ export type SMState = {
63
+ onEnter: Array<(event: string) => unknown>;
64
+ onLeave: Array<(event: string) => unknown>;
65
+ transitions: Map<string, SMTransition>;
66
+ };
67
+ export type SMTransition = {
68
+ destination: string;
69
+ onTransition?: Array<(...args: any[]) => unknown>;
70
+ };
71
+ export type SMHistory = {
72
+ from: string;
73
+ event: string;
74
+ to: string;
75
+ time: number;
76
+ };
package/dist/Types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });