@elaraai/e3-api-client 1.0.103 → 1.0.105

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.
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * The UUIDv7 a client mints to name a call it starts (east-workspace#1554),
7
+ * so it can ask the server to stop the call before the start answers.
8
+ *
9
+ * The same ids as e3-core's `uuidv7` (RFC 9562 §6.2's Method 1: a millisecond
10
+ * timestamp, then a counter in `rand_a`, then random bits), kept here because
11
+ * the client depends on no package of the server's.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ /** The largest value of the counter in `rand_a`'s 12 bits. */
16
+ const COUNTER_MAX = 0xfff;
17
+ /** A new millisecond's counter starts at random with its top bit clear, so at
18
+ * least 2,048 ids fit in the millisecond before the counter overflows. */
19
+ const COUNTER_SEED_MASK = 0x7ff;
20
+ let timestamp = -1;
21
+ let counter = 0;
22
+ /**
23
+ * Mints a UUIDv7 of now, which sorts after every id this process minted
24
+ * before it.
25
+ *
26
+ * @remarks
27
+ * In a new millisecond the counter starts at random; in the same one, or when
28
+ * the clock reads earlier than the last id's timestamp, the timestamp is kept
29
+ * and the counter goes up by one; a counter that would overflow moves the
30
+ * timestamp on by a millisecond. The 62 bits of `rand_b` are random, from the
31
+ * Web Crypto API's `getRandomValues`, which Node and every browser provide.
32
+ *
33
+ * @returns The id
34
+ *
35
+ * @internal
36
+ */
37
+ export function uuidv7() {
38
+ const random = globalThis.crypto.getRandomValues(new Uint8Array(10));
39
+ const seed = ((random[0] << 8) | random[1]) & COUNTER_SEED_MASK;
40
+ const clock = Date.now();
41
+ if (clock > timestamp) {
42
+ timestamp = clock;
43
+ counter = seed;
44
+ }
45
+ else if (counter < COUNTER_MAX) {
46
+ counter++;
47
+ }
48
+ else {
49
+ timestamp++;
50
+ counter = seed;
51
+ }
52
+ const bytes = new Uint8Array(16);
53
+ // Bytes 0-5: the timestamp (big-endian, 48 bits)
54
+ bytes[0] = (timestamp / 0x10000000000) & 0xff;
55
+ bytes[1] = (timestamp / 0x100000000) & 0xff;
56
+ bytes[2] = (timestamp / 0x1000000) & 0xff;
57
+ bytes[3] = (timestamp / 0x10000) & 0xff;
58
+ bytes[4] = (timestamp / 0x100) & 0xff;
59
+ bytes[5] = timestamp & 0xff;
60
+ // Bytes 6-7: the version (0111) and the counter's 12 bits
61
+ bytes[6] = 0x70 | (counter >> 8);
62
+ bytes[7] = counter & 0xff;
63
+ // Bytes 8-15: the variant (10) and 62 random bits
64
+ bytes[8] = (random[2] & 0x3f) | 0x80;
65
+ for (let i = 9; i < 16; i++)
66
+ bytes[i] = random[i - 6];
67
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
68
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
69
+ }
70
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../src/uuid.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B;2EAC2E;AAC3E,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC;AACnB,IAAI,OAAO,GAAG,CAAC,CAAC;AAEhB;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,MAAM;IACpB,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAE,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC,GAA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EAAE,EAAE,CAAC,EAAE;QAAE,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC;IAEvD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/E,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;AAC7G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elaraai/e3-api-client",
3
- "version": "1.0.103",
3
+ "version": "1.0.105",
4
4
  "type": "module",
5
5
  "description": "East Execution Engine API Client - TypeScript client library for e3 API server",
6
6
  "main": "dist/src/index.js",
@@ -30,10 +30,10 @@
30
30
  "directory": "libs/e3/packages/e3-api-client"
31
31
  },
32
32
  "dependencies": {
33
- "@elaraai/e3-types": "1.0.103"
33
+ "@elaraai/e3-types": "1.0.105"
34
34
  },
35
35
  "peerDependencies": {
36
- "@elaraai/east": "1.0.103"
36
+ "@elaraai/east": "1.0.105"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^22.0.0",
@@ -43,7 +43,7 @@
43
43
  "eslint-plugin-headers": "^1.3.3",
44
44
  "typescript": "npm:@typescript/typescript6@6.0.2",
45
45
  "typescript-7": "npm:typescript@7.0.2",
46
- "@elaraai/east-node-std": "1.0.103"
46
+ "@elaraai/east-node-std": "1.0.105"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsc",