@ultimat3/entity 31.53.0 → 31.54.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/entity",
3
- "version": "31.53.0",
3
+ "version": "31.54.0",
4
4
  "description": "A table + its domain type + invariants the database also enforces",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -45,9 +45,9 @@
45
45
  "test": "bun test"
46
46
  },
47
47
  "dependencies": {
48
- "@ultimat3/core": "31.53.0",
49
- "@ultimat3/db": "31.53.0",
50
- "@ultimat3/schema": "31.53.0",
51
- "@ultimat3/time": "31.53.0"
48
+ "@ultimat3/core": "31.54.0",
49
+ "@ultimat3/db": "31.54.0",
50
+ "@ultimat3/schema": "31.54.0",
51
+ "@ultimat3/time": "31.54.0"
52
52
  }
53
53
  }
@@ -6,7 +6,12 @@
6
6
  import { DEFAULT_ENVIRONMENT, logger, tryResolveEnvironment } from '@ultimat3/core';
7
7
  import { DEFAULT_PAGE_SIZE } from './plan';
8
8
 
9
- /** The one log message this writes: a subscriber matches `log.record`'s `message` against it. */
9
+ /**
10
+ * The one log message this writes: a subscriber matches `log.record`'s `message` against it.
11
+ *
12
+ * @deprecated Removed at the next major: a truncated `.all()` refuses `X_ENTITY_ALL_TRUNCATED`
13
+ * instead of logging, so there is no message to match.
14
+ */
10
15
  export const ALL_TRUNCATED = 'entity.all.truncated';
11
16
 
12
17
  /** The warning's code, on `fields.code`. A refusal under the same code is `next`'s, not 31.x's. */
package/src/uuid-text.ts CHANGED
@@ -8,12 +8,33 @@
8
8
  */
9
9
  const UUID_TEXT = /^(?:[0-9a-f]{4}-?){7}[0-9a-f]{4}$/i;
10
10
 
11
+ /** Where `8-4-4-4-12` puts its hyphens. */
12
+ const HYPHENS = new Set([8, 13, 18, 23]);
13
+
14
+ /**
15
+ * Already the one spelling — what every stored id is — read by char code, with no regex and no
16
+ * copy. The memory driver keys, sorts and matches each row by this, and the general path's three
17
+ * allocations per call were a second of a 50,001-row `updateWhere` (the `MAX_ASSERTED_ROWS` tests).
18
+ */
19
+ const isCanonical = (text: string): boolean => {
20
+ if (text.length !== 36) return false;
21
+ for (let at = 0; at < 36; at += 1) {
22
+ const code = text.charCodeAt(at);
23
+ if (
24
+ HYPHENS.has(at) ? code !== 45 : !((code >= 48 && code <= 57) || (code >= 97 && code <= 102))
25
+ )
26
+ return false;
27
+ }
28
+ return true;
29
+ };
30
+
11
31
  /**
12
32
  * The lower-cased `8-4-4-4-12` spelling of `value`, or `undefined` when it is not a `uuid`'s text.
13
33
  * Bound as a parameter the latter is `22P02`, a 500 for an id straight out of a URL.
14
34
  */
15
35
  export const canonicalUuid = (value: unknown): string | undefined => {
16
36
  if (typeof value !== 'string') return undefined;
37
+ if (isCanonical(value)) return value;
17
38
  const braced = value.startsWith('{') && value.endsWith('}');
18
39
  const text = braced ? value.slice(1, -1) : value;
19
40
  if (!UUID_TEXT.test(text)) return undefined;