@fluxerjs/util 3.0.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 CHANGED
@@ -92,6 +92,8 @@ 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). */
@@ -354,9 +356,15 @@ interface DeconstructedSnowflake {
354
356
  /** Unix timestamp in milliseconds. */
355
357
  timestamp: number;
356
358
  date: Date;
359
+ /** Worker ID (10 bits, 0–1023). */
357
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
+ */
358
367
  processId: number;
359
- increment: number;
360
368
  }
361
369
  /**
362
370
  * Fluxer snowflake IDs (Twitter layout, custom epoch).
@@ -377,7 +385,7 @@ declare class SnowflakeUtil {
377
385
  * Useful for pagination (`before` / `after`).
378
386
  */
379
387
  static snowflakeFromTimestamp(timestamp: number): Snowflake;
380
- /** Deconstruct a snowflake into timestamp / worker / process / increment. */
388
+ /** Deconstruct a snowflake into timestamp / worker / sequence. */
381
389
  static deconstruct(snowflake: Snowflake): DeconstructedSnowflake;
382
390
  }
383
391
 
package/dist/index.d.ts CHANGED
@@ -92,6 +92,8 @@ 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). */
@@ -354,9 +356,15 @@ interface DeconstructedSnowflake {
354
356
  /** Unix timestamp in milliseconds. */
355
357
  timestamp: number;
356
358
  date: Date;
359
+ /** Worker ID (10 bits, 0–1023). */
357
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
+ */
358
367
  processId: number;
359
- increment: number;
360
368
  }
361
369
  /**
362
370
  * Fluxer snowflake IDs (Twitter layout, custom epoch).
@@ -377,7 +385,7 @@ declare class SnowflakeUtil {
377
385
  * Useful for pagination (`before` / `after`).
378
386
  */
379
387
  static snowflakeFromTimestamp(timestamp: number): Snowflake;
380
- /** Deconstruct a snowflake into timestamp / worker / process / increment. */
388
+ /** Deconstruct a snowflake into timestamp / worker / sequence. */
381
389
  static deconstruct(snowflake: Snowflake): DeconstructedSnowflake;
382
390
  }
383
391
 
package/dist/index.js CHANGED
@@ -220,6 +220,8 @@ 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). */
@@ -587,16 +589,18 @@ var SnowflakeUtil = class _SnowflakeUtil {
587
589
  }
588
590
  return (BigInt(Math.trunc(timestamp)) - FLUXER_EPOCH << 22n).toString();
589
591
  }
590
- /** Deconstruct a snowflake into timestamp / worker / process / increment. */
592
+ /** Deconstruct a snowflake into timestamp / worker / sequence. */
591
593
  static deconstruct(snowflake) {
592
594
  const big = _SnowflakeUtil.parse(snowflake);
593
595
  const timestamp = Number((big >> 22n) + FLUXER_EPOCH);
596
+ const workerId = Number(big >> 12n & 0x3ffn);
597
+ const sequence = Number(big & 0xfffn);
594
598
  return {
595
599
  timestamp,
596
600
  date: new Date(timestamp),
597
- workerId: Number(big >> 17n & 0x1fn),
598
- processId: Number(big >> 12n & 0x1fn),
599
- increment: Number(big & 0xfffn)
601
+ workerId,
602
+ sequence,
603
+ processId: 0
600
604
  };
601
605
  }
602
606
  };
package/dist/index.mjs CHANGED
@@ -164,6 +164,8 @@ 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). */
@@ -531,16 +533,18 @@ var SnowflakeUtil = class _SnowflakeUtil {
531
533
  }
532
534
  return (BigInt(Math.trunc(timestamp)) - FLUXER_EPOCH << 22n).toString();
533
535
  }
534
- /** Deconstruct a snowflake into timestamp / worker / process / increment. */
536
+ /** Deconstruct a snowflake into timestamp / worker / sequence. */
535
537
  static deconstruct(snowflake) {
536
538
  const big = _SnowflakeUtil.parse(snowflake);
537
539
  const timestamp = Number((big >> 22n) + FLUXER_EPOCH);
540
+ const workerId = Number(big >> 12n & 0x3ffn);
541
+ const sequence = Number(big & 0xfffn);
538
542
  return {
539
543
  timestamp,
540
544
  date: new Date(timestamp),
541
- workerId: Number(big >> 17n & 0x1fn),
542
- processId: Number(big >> 12n & 0x1fn),
543
- increment: Number(big & 0xfffn)
545
+ workerId,
546
+ sequence,
547
+ processId: 0
544
548
  };
545
549
  }
546
550
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.0.0",
6
+ "version": "3.1.0",
7
7
  "description": "Shared utilities for @fluxerjs/core",
8
8
  "repository": {
9
9
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@fluxerjs/types": "3.0.0"
23
+ "@fluxerjs/types": "3.1.0"
24
24
  },
25
25
  "sideEffects": false,
26
26
  "main": "./dist/index.js",