@fluxerjs/util 2.2.0 → 3.1.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.
- package/dist/index.d.mts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +16 -7
- package/dist/index.mjs +16 -7
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -92,12 +92,20 @@ declare const ErrorCodes: {
|
|
|
92
92
|
readonly InvalidFetchLimit: "INVALID_FETCH_LIMIT";
|
|
93
93
|
/** Attachment plan/file mismatch or invalid attachment input. */
|
|
94
94
|
readonly InvalidAttachmentInput: "INVALID_ATTACHMENT_INPUT";
|
|
95
|
+
/** File exceeds the bot attachment size ceiling (50 MiB). */
|
|
96
|
+
readonly AttachmentTooLarge: "ATTACHMENT_TOO_LARGE";
|
|
95
97
|
/** Presigned CDN PUT failed. */
|
|
96
98
|
readonly AttachmentUploadFailed: "ATTACHMENT_UPLOAD_FAILED";
|
|
97
99
|
/** Operation requires a personal-notes channel (or wrong channel type). */
|
|
98
100
|
readonly InvalidChannelType: "INVALID_CHANNEL_TYPE";
|
|
99
101
|
/** Gateway opcode payload missing required fields. */
|
|
100
102
|
readonly InvalidGatewayRequest: "INVALID_GATEWAY_REQUEST";
|
|
103
|
+
/** Collector ended because its time limit elapsed. */
|
|
104
|
+
readonly CollectorIdle: "COLLECTOR_IDLE";
|
|
105
|
+
/** Collector ended because its max item limit was reached. */
|
|
106
|
+
readonly CollectorMax: "COLLECTOR_MAX";
|
|
107
|
+
/** Collector requires `time` and/or `max`. */
|
|
108
|
+
readonly CollectorOptionsRequired: "COLLECTOR_OPTIONS_REQUIRED";
|
|
101
109
|
};
|
|
102
110
|
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
103
111
|
|
|
@@ -133,7 +141,7 @@ declare function formatColor(color: number): string;
|
|
|
133
141
|
declare function escapeMarkdown(text: string): string;
|
|
134
142
|
type TimestampStyle = 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R';
|
|
135
143
|
/**
|
|
136
|
-
* Format a Unix timestamp (milliseconds) as a Fluxer
|
|
144
|
+
* Format a Unix timestamp (milliseconds) as a Fluxer timestamp mention.
|
|
137
145
|
* @param timestampMs - Unix timestamp in milliseconds
|
|
138
146
|
* @param style - Optional display style (`t`, `T`, `d`, `D`, `f`, `F`, `R`)
|
|
139
147
|
*/
|
|
@@ -184,7 +192,6 @@ declare const MessageFlagsBits: {
|
|
|
184
192
|
readonly SuppressEmbeds: bigint;
|
|
185
193
|
readonly SuppressNotifications: bigint;
|
|
186
194
|
readonly VoiceMessage: bigint;
|
|
187
|
-
readonly CompactAttachments: bigint;
|
|
188
195
|
};
|
|
189
196
|
type MessageFlagsString = keyof typeof MessageFlagsBits;
|
|
190
197
|
type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;
|
|
@@ -193,7 +200,6 @@ declare class MessageFlagsBitField extends BitField<MessageFlagsString> {
|
|
|
193
200
|
readonly SuppressEmbeds: bigint;
|
|
194
201
|
readonly SuppressNotifications: bigint;
|
|
195
202
|
readonly VoiceMessage: bigint;
|
|
196
|
-
readonly CompactAttachments: bigint;
|
|
197
203
|
};
|
|
198
204
|
}
|
|
199
205
|
|
|
@@ -350,9 +356,15 @@ interface DeconstructedSnowflake {
|
|
|
350
356
|
/** Unix timestamp in milliseconds. */
|
|
351
357
|
timestamp: number;
|
|
352
358
|
date: Date;
|
|
359
|
+
/** Worker ID (10 bits, 0–1023). */
|
|
353
360
|
workerId: number;
|
|
361
|
+
/** Per-worker sequence (12 bits, 0–4095). */
|
|
362
|
+
sequence: number;
|
|
363
|
+
/**
|
|
364
|
+
* @deprecated Fluxer snowflakes have no process ID. Always `0`.
|
|
365
|
+
* Present for discord.js migrants that read `processId`.
|
|
366
|
+
*/
|
|
354
367
|
processId: number;
|
|
355
|
-
increment: number;
|
|
356
368
|
}
|
|
357
369
|
/**
|
|
358
370
|
* Fluxer snowflake IDs (Twitter layout, custom epoch).
|
|
@@ -373,7 +385,7 @@ declare class SnowflakeUtil {
|
|
|
373
385
|
* Useful for pagination (`before` / `after`).
|
|
374
386
|
*/
|
|
375
387
|
static snowflakeFromTimestamp(timestamp: number): Snowflake;
|
|
376
|
-
/** Deconstruct a snowflake into timestamp / worker /
|
|
388
|
+
/** Deconstruct a snowflake into timestamp / worker / sequence. */
|
|
377
389
|
static deconstruct(snowflake: Snowflake): DeconstructedSnowflake;
|
|
378
390
|
}
|
|
379
391
|
|
package/dist/index.d.ts
CHANGED
|
@@ -92,12 +92,20 @@ declare const ErrorCodes: {
|
|
|
92
92
|
readonly InvalidFetchLimit: "INVALID_FETCH_LIMIT";
|
|
93
93
|
/** Attachment plan/file mismatch or invalid attachment input. */
|
|
94
94
|
readonly InvalidAttachmentInput: "INVALID_ATTACHMENT_INPUT";
|
|
95
|
+
/** File exceeds the bot attachment size ceiling (50 MiB). */
|
|
96
|
+
readonly AttachmentTooLarge: "ATTACHMENT_TOO_LARGE";
|
|
95
97
|
/** Presigned CDN PUT failed. */
|
|
96
98
|
readonly AttachmentUploadFailed: "ATTACHMENT_UPLOAD_FAILED";
|
|
97
99
|
/** Operation requires a personal-notes channel (or wrong channel type). */
|
|
98
100
|
readonly InvalidChannelType: "INVALID_CHANNEL_TYPE";
|
|
99
101
|
/** Gateway opcode payload missing required fields. */
|
|
100
102
|
readonly InvalidGatewayRequest: "INVALID_GATEWAY_REQUEST";
|
|
103
|
+
/** Collector ended because its time limit elapsed. */
|
|
104
|
+
readonly CollectorIdle: "COLLECTOR_IDLE";
|
|
105
|
+
/** Collector ended because its max item limit was reached. */
|
|
106
|
+
readonly CollectorMax: "COLLECTOR_MAX";
|
|
107
|
+
/** Collector requires `time` and/or `max`. */
|
|
108
|
+
readonly CollectorOptionsRequired: "COLLECTOR_OPTIONS_REQUIRED";
|
|
101
109
|
};
|
|
102
110
|
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
103
111
|
|
|
@@ -133,7 +141,7 @@ declare function formatColor(color: number): string;
|
|
|
133
141
|
declare function escapeMarkdown(text: string): string;
|
|
134
142
|
type TimestampStyle = 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R';
|
|
135
143
|
/**
|
|
136
|
-
* Format a Unix timestamp (milliseconds) as a Fluxer
|
|
144
|
+
* Format a Unix timestamp (milliseconds) as a Fluxer timestamp mention.
|
|
137
145
|
* @param timestampMs - Unix timestamp in milliseconds
|
|
138
146
|
* @param style - Optional display style (`t`, `T`, `d`, `D`, `f`, `F`, `R`)
|
|
139
147
|
*/
|
|
@@ -184,7 +192,6 @@ declare const MessageFlagsBits: {
|
|
|
184
192
|
readonly SuppressEmbeds: bigint;
|
|
185
193
|
readonly SuppressNotifications: bigint;
|
|
186
194
|
readonly VoiceMessage: bigint;
|
|
187
|
-
readonly CompactAttachments: bigint;
|
|
188
195
|
};
|
|
189
196
|
type MessageFlagsString = keyof typeof MessageFlagsBits;
|
|
190
197
|
type MessageFlagsResolvable = BitFieldResolvable<MessageFlagsString>;
|
|
@@ -193,7 +200,6 @@ declare class MessageFlagsBitField extends BitField<MessageFlagsString> {
|
|
|
193
200
|
readonly SuppressEmbeds: bigint;
|
|
194
201
|
readonly SuppressNotifications: bigint;
|
|
195
202
|
readonly VoiceMessage: bigint;
|
|
196
|
-
readonly CompactAttachments: bigint;
|
|
197
203
|
};
|
|
198
204
|
}
|
|
199
205
|
|
|
@@ -350,9 +356,15 @@ interface DeconstructedSnowflake {
|
|
|
350
356
|
/** Unix timestamp in milliseconds. */
|
|
351
357
|
timestamp: number;
|
|
352
358
|
date: Date;
|
|
359
|
+
/** Worker ID (10 bits, 0–1023). */
|
|
353
360
|
workerId: number;
|
|
361
|
+
/** Per-worker sequence (12 bits, 0–4095). */
|
|
362
|
+
sequence: number;
|
|
363
|
+
/**
|
|
364
|
+
* @deprecated Fluxer snowflakes have no process ID. Always `0`.
|
|
365
|
+
* Present for discord.js migrants that read `processId`.
|
|
366
|
+
*/
|
|
354
367
|
processId: number;
|
|
355
|
-
increment: number;
|
|
356
368
|
}
|
|
357
369
|
/**
|
|
358
370
|
* Fluxer snowflake IDs (Twitter layout, custom epoch).
|
|
@@ -373,7 +385,7 @@ declare class SnowflakeUtil {
|
|
|
373
385
|
* Useful for pagination (`before` / `after`).
|
|
374
386
|
*/
|
|
375
387
|
static snowflakeFromTimestamp(timestamp: number): Snowflake;
|
|
376
|
-
/** Deconstruct a snowflake into timestamp / worker /
|
|
388
|
+
/** Deconstruct a snowflake into timestamp / worker / sequence. */
|
|
377
389
|
static deconstruct(snowflake: Snowflake): DeconstructedSnowflake;
|
|
378
390
|
}
|
|
379
391
|
|
package/dist/index.js
CHANGED
|
@@ -220,12 +220,20 @@ var ErrorCodes = {
|
|
|
220
220
|
InvalidFetchLimit: "INVALID_FETCH_LIMIT",
|
|
221
221
|
/** Attachment plan/file mismatch or invalid attachment input. */
|
|
222
222
|
InvalidAttachmentInput: "INVALID_ATTACHMENT_INPUT",
|
|
223
|
+
/** File exceeds the bot attachment size ceiling (50 MiB). */
|
|
224
|
+
AttachmentTooLarge: "ATTACHMENT_TOO_LARGE",
|
|
223
225
|
/** Presigned CDN PUT failed. */
|
|
224
226
|
AttachmentUploadFailed: "ATTACHMENT_UPLOAD_FAILED",
|
|
225
227
|
/** Operation requires a personal-notes channel (or wrong channel type). */
|
|
226
228
|
InvalidChannelType: "INVALID_CHANNEL_TYPE",
|
|
227
229
|
/** Gateway opcode payload missing required fields. */
|
|
228
|
-
InvalidGatewayRequest: "INVALID_GATEWAY_REQUEST"
|
|
230
|
+
InvalidGatewayRequest: "INVALID_GATEWAY_REQUEST",
|
|
231
|
+
/** Collector ended because its time limit elapsed. */
|
|
232
|
+
CollectorIdle: "COLLECTOR_IDLE",
|
|
233
|
+
/** Collector ended because its max item limit was reached. */
|
|
234
|
+
CollectorMax: "COLLECTOR_MAX",
|
|
235
|
+
/** Collector requires `time` and/or `max`. */
|
|
236
|
+
CollectorOptionsRequired: "COLLECTOR_OPTIONS_REQUIRED"
|
|
229
237
|
};
|
|
230
238
|
|
|
231
239
|
// src/Errors/FluxerError.ts
|
|
@@ -473,8 +481,7 @@ var import_types2 = require("@fluxerjs/types");
|
|
|
473
481
|
var MessageFlagsBits = {
|
|
474
482
|
SuppressEmbeds: BigInt(import_types2.MessageFlags.SuppressEmbeds),
|
|
475
483
|
SuppressNotifications: BigInt(import_types2.MessageFlags.SuppressNotifications),
|
|
476
|
-
VoiceMessage: BigInt(import_types2.MessageFlags.VoiceMessage)
|
|
477
|
-
CompactAttachments: BigInt(import_types2.MessageFlags.CompactAttachments)
|
|
484
|
+
VoiceMessage: BigInt(import_types2.MessageFlags.VoiceMessage)
|
|
478
485
|
};
|
|
479
486
|
var MessageFlagsBitField = class extends BitField {
|
|
480
487
|
static Flags = MessageFlagsBits;
|
|
@@ -582,16 +589,18 @@ var SnowflakeUtil = class _SnowflakeUtil {
|
|
|
582
589
|
}
|
|
583
590
|
return (BigInt(Math.trunc(timestamp)) - FLUXER_EPOCH << 22n).toString();
|
|
584
591
|
}
|
|
585
|
-
/** Deconstruct a snowflake into timestamp / worker /
|
|
592
|
+
/** Deconstruct a snowflake into timestamp / worker / sequence. */
|
|
586
593
|
static deconstruct(snowflake) {
|
|
587
594
|
const big = _SnowflakeUtil.parse(snowflake);
|
|
588
595
|
const timestamp = Number((big >> 22n) + FLUXER_EPOCH);
|
|
596
|
+
const workerId = Number(big >> 12n & 0x3ffn);
|
|
597
|
+
const sequence = Number(big & 0xfffn);
|
|
589
598
|
return {
|
|
590
599
|
timestamp,
|
|
591
600
|
date: new Date(timestamp),
|
|
592
|
-
workerId
|
|
593
|
-
|
|
594
|
-
|
|
601
|
+
workerId,
|
|
602
|
+
sequence,
|
|
603
|
+
processId: 0
|
|
595
604
|
};
|
|
596
605
|
}
|
|
597
606
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -164,12 +164,20 @@ var ErrorCodes = {
|
|
|
164
164
|
InvalidFetchLimit: "INVALID_FETCH_LIMIT",
|
|
165
165
|
/** Attachment plan/file mismatch or invalid attachment input. */
|
|
166
166
|
InvalidAttachmentInput: "INVALID_ATTACHMENT_INPUT",
|
|
167
|
+
/** File exceeds the bot attachment size ceiling (50 MiB). */
|
|
168
|
+
AttachmentTooLarge: "ATTACHMENT_TOO_LARGE",
|
|
167
169
|
/** Presigned CDN PUT failed. */
|
|
168
170
|
AttachmentUploadFailed: "ATTACHMENT_UPLOAD_FAILED",
|
|
169
171
|
/** Operation requires a personal-notes channel (or wrong channel type). */
|
|
170
172
|
InvalidChannelType: "INVALID_CHANNEL_TYPE",
|
|
171
173
|
/** Gateway opcode payload missing required fields. */
|
|
172
|
-
InvalidGatewayRequest: "INVALID_GATEWAY_REQUEST"
|
|
174
|
+
InvalidGatewayRequest: "INVALID_GATEWAY_REQUEST",
|
|
175
|
+
/** Collector ended because its time limit elapsed. */
|
|
176
|
+
CollectorIdle: "COLLECTOR_IDLE",
|
|
177
|
+
/** Collector ended because its max item limit was reached. */
|
|
178
|
+
CollectorMax: "COLLECTOR_MAX",
|
|
179
|
+
/** Collector requires `time` and/or `max`. */
|
|
180
|
+
CollectorOptionsRequired: "COLLECTOR_OPTIONS_REQUIRED"
|
|
173
181
|
};
|
|
174
182
|
|
|
175
183
|
// src/Errors/FluxerError.ts
|
|
@@ -417,8 +425,7 @@ import { MessageFlags } from "@fluxerjs/types";
|
|
|
417
425
|
var MessageFlagsBits = {
|
|
418
426
|
SuppressEmbeds: BigInt(MessageFlags.SuppressEmbeds),
|
|
419
427
|
SuppressNotifications: BigInt(MessageFlags.SuppressNotifications),
|
|
420
|
-
VoiceMessage: BigInt(MessageFlags.VoiceMessage)
|
|
421
|
-
CompactAttachments: BigInt(MessageFlags.CompactAttachments)
|
|
428
|
+
VoiceMessage: BigInt(MessageFlags.VoiceMessage)
|
|
422
429
|
};
|
|
423
430
|
var MessageFlagsBitField = class extends BitField {
|
|
424
431
|
static Flags = MessageFlagsBits;
|
|
@@ -526,16 +533,18 @@ var SnowflakeUtil = class _SnowflakeUtil {
|
|
|
526
533
|
}
|
|
527
534
|
return (BigInt(Math.trunc(timestamp)) - FLUXER_EPOCH << 22n).toString();
|
|
528
535
|
}
|
|
529
|
-
/** Deconstruct a snowflake into timestamp / worker /
|
|
536
|
+
/** Deconstruct a snowflake into timestamp / worker / sequence. */
|
|
530
537
|
static deconstruct(snowflake) {
|
|
531
538
|
const big = _SnowflakeUtil.parse(snowflake);
|
|
532
539
|
const timestamp = Number((big >> 22n) + FLUXER_EPOCH);
|
|
540
|
+
const workerId = Number(big >> 12n & 0x3ffn);
|
|
541
|
+
const sequence = Number(big & 0xfffn);
|
|
533
542
|
return {
|
|
534
543
|
timestamp,
|
|
535
544
|
date: new Date(timestamp),
|
|
536
|
-
workerId
|
|
537
|
-
|
|
538
|
-
|
|
545
|
+
workerId,
|
|
546
|
+
sequence,
|
|
547
|
+
processId: 0
|
|
539
548
|
};
|
|
540
549
|
}
|
|
541
550
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "3.1.0",
|
|
7
7
|
"description": "Shared utilities for @fluxerjs/core",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/util"
|
|
12
12
|
},
|
|
13
13
|
"bugs": "https://github.com/fluxerjs/core/issues",
|
|
14
|
-
"homepage": "https://
|
|
14
|
+
"homepage": "https://fluxer.js.org",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"fluxer",
|
|
17
17
|
"util",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@fluxerjs/types": "
|
|
23
|
+
"@fluxerjs/types": "3.1.0"
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"main": "./dist/index.js",
|