@chainfuse/helpers 4.1.0 → 4.1.2

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/README.md CHANGED
@@ -22,7 +22,7 @@ In Japanese, する (suru) is a versatile, irregular verb meaning "to do"
22
22
 
23
23
  | Format | Example |
24
24
  | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
- | hex | `11f3fffffc18001000004522706e3aa036a0ea9c0d7d27581ebf4876defd304469119f0f4cfc41b0fb96d6b1e18900ec` |
25
+ | hex | `101f3fffffc1800100000522706e3aa036a0ea9c0d7d27581ebf4876defd304469119f0f4cfc41b0fb96d6b1e18900ec` |
26
26
  | SQLite Blob | `1724325525525224016006934112110581605416023415613125398830191721182222534868105171591576252651762511502141772251370236` |
27
27
  | JS Buffer Array | `[17,243,255,255,252,24,0,16,0,0,69,34,112,110,58,160,54,160,234,156,13,125,39,88,30,191,72,118,222,253,48,68,105,17,159,15,76,252,65,176,251,150,214,177,225,137,0,236]` |
28
28
  | base64 | `EfP///wYABAAAEUicG46oDag6pwNfSdYHr9Idt79MERpEZ8PTPxBsPuW1rHhiQDs` |
@@ -30,14 +30,14 @@ In Japanese, する (suru) is a versatile, irregular verb meaning "to do"
30
30
 
31
31
  ### Breakdown
32
32
 
33
- | Offset (bits) | Size (bits) | Field | (Hex) Example | Notes |
34
- | ------------- | ----------- | ------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
35
- | 0 | 4 | Version | `1` | Masked into timestamp's top nibble |
36
- | 4 | 44 | Timestamp | ~~`0`~~`1f3fffffc18` | Lower 44 bits of 48bit epoch milliseconds (max date value `2527-06-23T06:20:44.415Z`) |
37
- | 48 | 12 | System Type | `001` | `D0SystemType` TS Enum |
38
- | 60 | 12 | Location | `000` | `D0CombinedLocations` TS Enum |
39
- | 72 | 8 | Shard Type | `00` | `D0ShardType` TS Enum |
40
- | 80 | 44 | Suffix random | `4522706e3aa` | Fresh entropy per ID to ensure uniqueness even if other fields match |
41
- | 124 | 4 | Environment | `0` | `D0Environment` TS Enum |
42
- | 128 | 256 | Stable random | `36a0ea9c0d7d27581ebf4876defd304469119f0f4cfc41b0fb96d6b1e18900ec` | Stable per logical entity; correlates related IDs without DB lookups |
33
+ | Offset (bits) | Size (bits) | Field | (Hex) Example | Notes |
34
+ | ------------- | ----------- | ------------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
35
+ | 0 | 4 | Version | `1` | Standalone version field |
36
+ | 4 | 48 | Timestamp | `01f3fffffc18` | Full 48-bit epoch milliseconds (max date value `+010889-08-02T05:31:50.655Z`) |
37
+ | 52 | 12 | System Type | `001` | `D0SystemType` TS Enum |
38
+ | 64 | 12 | Location | `000` | `D0CombinedLocations` TS Enum |
39
+ | 76 | 8 | Shard Type | `00` | `D0ShardType` TS Enum |
40
+ | 84 | 40 | Suffix random | `522706e3aa` | Fresh entropy per ID to ensure uniqueness even if other fields match |
41
+ | 124 | 4 | Environment | `0` | `D0Environment` TS Enum |
42
+ | 128 | 256 | Stable random | `36a0ea9c0d7d27581ebf4876defd304469119f0f4cfc41b0fb96d6b1e18900ec` | Stable per logical entity; correlates related IDs without DB lookups |
43
43
  | **Total** | **384** |
package/dist/suru.d.mts CHANGED
@@ -49,8 +49,8 @@ export declare class SuruId {
49
49
  version: z.ZodMiniDefault<z.ZodMiniEnum<typeof D0Version>>;
50
50
  date: z.ZodMiniDefault<z.ZodMiniDate<Date>>;
51
51
  shardType: z.ZodMiniDefault<z.ZodMiniEnum<typeof D0ShardType>>;
52
- suffixRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>>;
53
- stableRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>>;
52
+ suffixRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>, z.ZodMiniPipe<z.ZodMiniBase64, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniPipe<z.ZodMiniBase64URL, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>]>>;
53
+ stableRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>, z.ZodMiniPipe<z.ZodMiniBase64, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniPipe<z.ZodMiniBase64URL, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>]>>;
54
54
  systemType: z.ZodMiniEnum<typeof D0SystemType>;
55
55
  environment: z.ZodMiniEnum<typeof D0Environment>;
56
56
  }, z.core.$strip>;
@@ -58,8 +58,8 @@ export declare class SuruId {
58
58
  version: z.ZodMiniDefault<z.ZodMiniEnum<typeof D0Version>>;
59
59
  date: z.ZodMiniDefault<z.ZodMiniDate<Date>>;
60
60
  shardType: z.ZodMiniDefault<z.ZodMiniEnum<typeof D0ShardType>>;
61
- suffixRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>>;
62
- stableRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>>;
61
+ suffixRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>, z.ZodMiniPipe<z.ZodMiniBase64, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniPipe<z.ZodMiniBase64URL, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>]>>;
62
+ stableRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>, z.ZodMiniPipe<z.ZodMiniBase64, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniPipe<z.ZodMiniBase64URL, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>]>>;
63
63
  systemType: z.ZodMiniEnum<typeof D0SystemType>;
64
64
  environment: z.ZodMiniEnum<typeof D0Environment>;
65
65
  locationJurisdiction: z.ZodMiniDefault<z.ZodMiniNullable<z.ZodMiniEnum<typeof DOJurisdictions>>>;
@@ -68,8 +68,8 @@ export declare class SuruId {
68
68
  version: z.ZodMiniDefault<z.ZodMiniEnum<typeof D0Version>>;
69
69
  date: z.ZodMiniDefault<z.ZodMiniDate<Date>>;
70
70
  shardType: z.ZodMiniDefault<z.ZodMiniEnum<typeof D0ShardType>>;
71
- suffixRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>>;
72
- stableRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>>;
71
+ suffixRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>, z.ZodMiniPipe<z.ZodMiniBase64, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniPipe<z.ZodMiniBase64URL, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>]>>;
72
+ stableRandom: z.ZodMiniDefault<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustomStringFormat<"hex">, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>, z.ZodMiniPipe<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBuffer>>>, z.ZodMiniPipe<z.ZodMiniUnion<readonly [z.ZodMiniPipe<z.ZodMiniCustom<ArrayBuffer, ArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, ArrayBuffer>>, z.ZodMiniPipe<z.ZodMiniCustom<SharedArrayBuffer, SharedArrayBuffer>, z.ZodMiniTransform<ArrayBufferLike, SharedArrayBuffer>>]>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, ArrayBufferLike>>, z.ZodMiniPipe<z.ZodMiniTuple<readonly [z.ZodMiniNumberFormat], z.ZodMiniNumberFormat>, z.ZodMiniTransform<Uint8Array<ArrayBufferLike>, [number, ...number[]]>>]>, z.ZodMiniPipe<z.ZodMiniBase64, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>, z.ZodMiniPipe<z.ZodMiniBase64URL, z.ZodMiniTransform<Uint8Array<ArrayBuffer>, string>>]>>;
73
73
  systemType: z.ZodMiniEnum<typeof D0SystemType>;
74
74
  environment: z.ZodMiniEnum<typeof D0Environment>;
75
75
  locationJurisdiction: z.ZodMiniDefault<z.ZodMiniNull>;
package/dist/suru.mjs CHANGED
@@ -12,9 +12,9 @@ export class SuruId {
12
12
  shardType: z.enum(D0ShardType),
13
13
  // Location
14
14
  suffixRandom: z.object({
15
- hex: z.hex().check(z.trim(), z.toLowerCase(), z.length(11)),
16
- base64: z.base64().check(z.trim(), z.maxLength(Math.ceil((11 * (4 / 6)) / 4) * 4)),
17
- base64url: z.base64url().check(z.trim(), z.maxLength(Math.round(11 * (4 / 6)))),
15
+ hex: z.hex().check(z.trim(), z.toLowerCase(), z.length(10)),
16
+ base64: z.base64().check(z.trim(), z.maxLength(Math.ceil((10 * (4 / 6)) / 4) * 4)),
17
+ base64url: z.base64url().check(z.trim(), z.maxLength(Math.round(10 * (4 / 6)))),
18
18
  }),
19
19
  environment: z.enum(D0Environment),
20
20
  stableRandom: z.object({
@@ -40,9 +40,31 @@ export class SuruId {
40
40
  // systemType
41
41
  shardType: z._default(this.extractOutputBase.def.shape.shardType, D0ShardType.None),
42
42
  // Location
43
- suffixRandom: z._default(ZodBlob, () => CryptoHelpers.secretBytesSync(Math.ceil(44 / 8))).check(z.refine((b) => b.byteLength === Math.ceil(44 / 8))),
43
+ suffixRandom: z
44
+ ._default(z.union([
45
+ // hex
46
+ z.pipe(this.extractOutputBase.def.shape.suffixRandom.shape.hex, z.transform((hex) => new Uint8Array(BufferHelpers.hexToBufferSync(hex)))),
47
+ // blob
48
+ ZodBlob,
49
+ // base64
50
+ z.pipe(this.extractOutputBase.def.shape.suffixRandom.shape.base64, z.transform((base64) => new Uint8Array(BufferHelpers.base64ToBufferSync(base64)))),
51
+ // base64url
52
+ z.pipe(this.extractOutputBase.def.shape.suffixRandom.shape.base64url, z.transform((base64url) => new Uint8Array(BufferHelpers.base64ToBufferSync(base64url)))),
53
+ ]), () => CryptoHelpers.secretBytesSync(40 / 8))
54
+ .check(z.refine((b) => b.byteLength === 40 / 8)),
44
55
  // environment
45
- stableRandom: z._default(ZodBlob, () => CryptoHelpers.secretBytesSync(256 / 8)).check(z.refine((b) => b.byteLength === 256 / 8)),
56
+ stableRandom: z
57
+ ._default(z.union([
58
+ // hex
59
+ z.pipe(this.extractOutputBase.def.shape.stableRandom.shape.hex, z.transform((hex) => new Uint8Array(BufferHelpers.hexToBufferSync(hex)))),
60
+ // blob
61
+ ZodBlob,
62
+ // base64
63
+ z.pipe(this.extractOutputBase.def.shape.stableRandom.shape.base64, z.transform((base64) => new Uint8Array(BufferHelpers.base64ToBufferSync(base64)))),
64
+ // base64url
65
+ z.pipe(this.extractOutputBase.def.shape.stableRandom.shape.base64url, z.transform((base64url) => new Uint8Array(BufferHelpers.base64ToBufferSync(base64url)))),
66
+ ]), () => CryptoHelpers.secretBytesSync(256 / 8))
67
+ .check(z.refine((b) => b.byteLength === 256 / 8)),
46
68
  });
47
69
  static createInput = z.union([
48
70
  z.extend(SuruId.createInputBase, {
@@ -58,21 +80,21 @@ export class SuruId {
58
80
  return SuruId.createInput.parseAsync(_input).then(async (input) => {
59
81
  // Pack fields into hex
60
82
  let hex = '';
61
- // Version (4 bytes)
83
+ // Version (4 bits = 1 hex char)
62
84
  hex += Number(input.version).toString(16);
63
- // Timestamp (11 bytes, pad to 12 chars, mask top nibble for version)
64
- hex += input.date.getTime().toString(16).padStart(12, '0').slice(-11);
65
- // System Type (3 bytes)
85
+ // Timestamp (48 bits, 12 hex chars)
86
+ hex += input.date.getTime().toString(16).padStart(12, '0');
87
+ // System Type (12 bits = 3 hex chars)
66
88
  hex += input.systemType.toString(16).padStart(3, '0').slice(-3);
67
- // Location (3 bytes)
89
+ // Location (12 bits = 3 hex chars)
68
90
  hex += (input.locationJurisdiction ? D0CombinedLocations[input.locationJurisdiction] : input.locationHint ? D0CombinedLocations[input.locationHint] : D0CombinedLocations.none).toString(16).padStart(3, '0').slice(-3);
69
- // Shard Type (2 bytes)
91
+ // Shard Type (8 bits = 2 hex chars)
70
92
  hex += input.shardType.toString(16).padStart(2, '0').slice(-2);
71
- // Suffix random (11 bytes)
72
- hex += (await BufferHelpers.bufferToHex(input.suffixRandom.buffer)).padStart(11, '0').slice(-11);
73
- // Environment (1 byte)
74
- hex += input.environment.toString(16).slice(-3);
75
- // Stable random (32 bytes)
93
+ // Suffix random (40 bits = 10 hex chars)
94
+ hex += (await BufferHelpers.bufferToHex(input.suffixRandom.buffer)).padStart(10, '0').slice(-10);
95
+ // Environment (4 bits = 1 hex char)
96
+ hex += input.environment.toString(16);
97
+ // Stable random (256 bits = 64 hex chars)
76
98
  hex += (await BufferHelpers.bufferToHex(input.stableRandom.buffer)).padStart(64, '0').slice(-64);
77
99
  const blob = await BufferHelpers.hexToBuffer(hex);
78
100
  const [base64, base64url] = await Promise.all([BufferHelpers.bufferToBase64(blob, false), BufferHelpers.bufferToBase64(blob, true)]);
@@ -88,21 +110,21 @@ export class SuruId {
88
110
  const input = SuruId.createInput.parse(_input);
89
111
  // Pack fields into hex
90
112
  let hex = '';
91
- // Version (4 bytes)
113
+ // Version (4 bits = 1 hex char)
92
114
  hex += Number(input.version).toString(16);
93
- // Timestamp (11 bytes, pad to 12 chars, mask top nibble for version)
94
- hex += input.date.getTime().toString(16).padStart(12, '0').slice(-11);
95
- // System Type (3 bytes)
115
+ // Timestamp (48 bits, 12 hex chars)
116
+ hex += input.date.getTime().toString(16).padStart(12, '0');
117
+ // System Type (12 bits = 3 hex chars)
96
118
  hex += input.systemType.toString(16).padStart(3, '0').slice(-3);
97
- // Location (3 bytes)
119
+ // Location (12 bits = 3 hex chars)
98
120
  hex += (input.locationJurisdiction ? D0CombinedLocations[input.locationJurisdiction] : input.locationHint ? D0CombinedLocations[input.locationHint] : D0CombinedLocations.none).toString(16).padStart(3, '0').slice(-3);
99
- // Shard Type (2 bytes)
121
+ // Shard Type (8 bits = 2 hex chars)
100
122
  hex += input.shardType.toString(16).padStart(2, '0').slice(-2);
101
- // Suffix random (11 bytes)
102
- hex += BufferHelpers.bufferToHexSync(input.suffixRandom.buffer).padStart(11, '0').slice(-11);
103
- // Environment (1 byte)
104
- hex += input.environment.toString(16).slice(-3);
105
- // Stable random (32 bytes)
123
+ // Suffix random (40 bits = 10 hex chars)
124
+ hex += BufferHelpers.bufferToHexSync(input.suffixRandom.buffer).padStart(10, '0').slice(-10);
125
+ // Environment (4 bits = 1 hex char)
126
+ hex += input.environment.toString(16);
127
+ // Stable random (256 bits = 64 hex chars)
106
128
  hex += BufferHelpers.bufferToHexSync(input.stableRandom.buffer).padStart(64, '0').slice(-64);
107
129
  const blob = BufferHelpers.hexToBufferSync(hex);
108
130
  return this.convertOutput.parse({
@@ -225,14 +247,14 @@ export class SuruId {
225
247
  // Version (1 char = 4 bits)
226
248
  const version = parseInt(hex.slice(offset, offset + 1), 16);
227
249
  offset += 1;
228
- // Timestamp (11 chars)
229
- const timestamp = parseInt(hex.slice(offset, offset + 11), 16);
250
+ // Timestamp (12 chars = 48 bits)
251
+ const timestamp = parseInt(hex.slice(offset, offset + 12), 16);
230
252
  const date = new Date(timestamp);
231
- offset += 11;
232
- // System Type (3 chars)
253
+ offset += 12;
254
+ // System Type (3 chars = 12 bits)
233
255
  const systemType = parseInt(hex.slice(offset, offset + 3), 16);
234
256
  offset += 3;
235
- // Location (3 chars)
257
+ // Location (3 chars = 12 bits)
236
258
  const locationValue = parseInt(hex.slice(offset, offset + 3), 16);
237
259
  offset += 3;
238
260
  // Find jurisdiction and hint from location value
@@ -251,18 +273,18 @@ export class SuruId {
251
273
  locationHint = locationKey;
252
274
  }
253
275
  }
254
- // Shard Type (2 chars)
276
+ // Shard Type (2 chars = 8 bits)
255
277
  const shardType = parseInt(hex.slice(offset, offset + 2), 16);
256
278
  offset += 2;
257
- // Suffix random (11 chars)
258
- const suffixRandomHex = hex.slice(offset, offset + 11);
279
+ // Suffix random (10 chars = 40 bits)
280
+ const suffixRandomHex = hex.slice(offset, offset + 10);
259
281
  const suffixRandomBuffer = await BufferHelpers.hexToBuffer(suffixRandomHex);
260
282
  const [suffixRandomBase64, suffixRandomBase64Url] = await Promise.all([BufferHelpers.bufferToBase64(suffixRandomBuffer, false), BufferHelpers.bufferToBase64(suffixRandomBuffer, true)]);
261
- offset += 11;
262
- // Environment (1 char)
283
+ offset += 10;
284
+ // Environment (1 char = 4 bits)
263
285
  const environment = parseInt(hex.slice(offset, offset + 1), 16);
264
286
  offset += 1;
265
- // Stable random (64 chars)
287
+ // Stable random (64 chars = 256 bits)
266
288
  const stableRandomHex = hex.slice(offset, offset + 64);
267
289
  const stableRandomBuffer = await BufferHelpers.hexToBuffer(stableRandomHex);
268
290
  const [stableRandomBase64, stableRandomBase64Url] = await Promise.all([BufferHelpers.bufferToBase64(stableRandomBuffer, false), BufferHelpers.bufferToBase64(stableRandomBuffer, true)]);
@@ -310,14 +332,14 @@ export class SuruId {
310
332
  // Version (1 char = 4 bits)
311
333
  const version = parseInt(hex.slice(offset, offset + 1), 16);
312
334
  offset += 1;
313
- // Timestamp (11 chars)
314
- const timestamp = parseInt(hex.slice(offset, offset + 11), 16);
335
+ // Timestamp (12 chars = 48 bits)
336
+ const timestamp = parseInt(hex.slice(offset, offset + 12), 16);
315
337
  const date = new Date(timestamp);
316
- offset += 11;
317
- // System Type (3 chars)
338
+ offset += 12;
339
+ // System Type (3 chars = 12 bits)
318
340
  const systemType = parseInt(hex.slice(offset, offset + 3), 16);
319
341
  offset += 3;
320
- // Location (3 chars)
342
+ // Location (3 chars = 12 bits)
321
343
  const locationValue = parseInt(hex.slice(offset, offset + 3), 16);
322
344
  offset += 3;
323
345
  // Find jurisdiction and hint from location value
@@ -336,19 +358,19 @@ export class SuruId {
336
358
  locationHint = locationKey;
337
359
  }
338
360
  }
339
- // Shard Type (2 chars)
361
+ // Shard Type (2 chars = 8 bits)
340
362
  const shardType = parseInt(hex.slice(offset, offset + 2), 16);
341
363
  offset += 2;
342
- // Suffix random (11 chars)
343
- const suffixRandomHex = hex.slice(offset, offset + 11);
364
+ // Suffix random (10 chars = 40 bits)
365
+ const suffixRandomHex = hex.slice(offset, offset + 10);
344
366
  const suffixRandomBuffer = BufferHelpers.hexToBufferSync(suffixRandomHex);
345
367
  const suffixRandomBase64 = BufferHelpers.bufferToBase64Sync(suffixRandomBuffer, false);
346
368
  const suffixRandomBase64Url = BufferHelpers.bufferToBase64Sync(suffixRandomBuffer, true);
347
- offset += 11;
348
- // Environment (1 char)
369
+ offset += 10;
370
+ // Environment (1 char = 4 bits)
349
371
  const environment = parseInt(hex.slice(offset, offset + 1), 16);
350
372
  offset += 1;
351
- // Stable random (64 chars)
373
+ // Stable random (64 chars = 256 bits)
352
374
  const stableRandomHex = hex.slice(offset, offset + 64);
353
375
  const stableRandomBuffer = BufferHelpers.hexToBufferSync(stableRandomHex);
354
376
  const stableRandomBase64 = BufferHelpers.bufferToBase64Sync(stableRandomBuffer, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainfuse/helpers",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "",
5
5
  "author": "ChainFuse",
6
6
  "homepage": "https://github.com/ChainFuse/packages/tree/main/packages/helpers#readme",
@@ -72,11 +72,15 @@
72
72
  "./net": {
73
73
  "import": "./dist/net.mjs",
74
74
  "types": "./dist/net.d.mts"
75
+ },
76
+ "./suru": {
77
+ "import": "./dist/suru.mjs",
78
+ "types": "./dist/suru.d.mts"
75
79
  }
76
80
  },
77
81
  "prettier": "@demosjarco/prettier-config",
78
82
  "dependencies": {
79
- "@chainfuse/types": "^4.0.1",
83
+ "@chainfuse/types": "^4.0.3",
80
84
  "@discordjs/rest": "^2.6.0",
81
85
  "chalk": "^5.6.2",
82
86
  "cloudflare": "^5.1.0",
@@ -89,5 +93,5 @@
89
93
  "@cloudflare/workers-types": "^4.20250923.0",
90
94
  "@types/node": "^22.18.6"
91
95
  },
92
- "gitHead": "ab58de73242e411360ae80368ee2f69a5798c653"
96
+ "gitHead": "bccfd0f28c9e57d57f86a6b160a7fd32c7846080"
93
97
  }