@effect-dynamodb/schema 1.42.2 → 1.44.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/Aggregate.d.ts +15 -3
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js +4 -2
- package/dist/Aggregate.js.map +1 -1
- package/dist/DynamoModel.d.ts +227 -30
- package/dist/DynamoModel.d.ts.map +1 -1
- package/dist/DynamoModel.js +153 -38
- package/dist/DynamoModel.js.map +1 -1
- package/dist/Entity.d.ts +38 -10
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +32 -2
- package/dist/Entity.js.map +1 -1
- package/dist/Errors.d.ts +77 -4
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js +36 -0
- package/dist/Errors.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/AggregateCursor.d.ts +5 -0
- package/dist/internal/AggregateCursor.d.ts.map +1 -1
- package/dist/internal/AggregateSchemas.d.ts +54 -2
- package/dist/internal/AggregateSchemas.d.ts.map +1 -1
- package/dist/internal/AggregateSchemas.js +145 -4
- package/dist/internal/AggregateSchemas.js.map +1 -1
- package/dist/internal/AggregateTypes.d.ts +13 -5
- package/dist/internal/AggregateTypes.d.ts.map +1 -1
- package/dist/internal/BlobPointer.d.ts +157 -0
- package/dist/internal/BlobPointer.d.ts.map +1 -0
- package/dist/internal/BlobPointer.js +471 -0
- package/dist/internal/BlobPointer.js.map +1 -0
- package/dist/internal/Crc64Nvme.d.ts +42 -0
- package/dist/internal/Crc64Nvme.d.ts.map +1 -0
- package/dist/internal/Crc64Nvme.js +128 -0
- package/dist/internal/Crc64Nvme.js.map +1 -0
- package/dist/internal/EntityConfig.d.ts +30 -0
- package/dist/internal/EntityConfig.d.ts.map +1 -1
- package/dist/internal/EntityOffload.d.ts +112 -0
- package/dist/internal/EntityOffload.d.ts.map +1 -0
- package/dist/internal/EntityOffload.js +260 -0
- package/dist/internal/EntityOffload.js.map +1 -0
- package/dist/internal/EntityPacked.d.ts +11 -10
- package/dist/internal/EntityPacked.d.ts.map +1 -1
- package/dist/internal/EntityPacked.js +6 -5
- package/dist/internal/EntityPacked.js.map +1 -1
- package/dist/internal/EntitySchemas.d.ts +11 -2
- package/dist/internal/EntitySchemas.d.ts.map +1 -1
- package/dist/internal/EntitySchemas.js +37 -5
- package/dist/internal/EntitySchemas.js.map +1 -1
- package/dist/internal/EntityTypes.d.ts +40 -2
- package/dist/internal/EntityTypes.d.ts.map +1 -1
- package/dist/internal/PackedCodec.d.ts +82 -27
- package/dist/internal/PackedCodec.d.ts.map +1 -1
- package/dist/internal/PackedCodec.js +175 -44
- package/dist/internal/PackedCodec.js.map +1 -1
- package/dist/internal/Sha256.d.ts +34 -0
- package/dist/internal/Sha256.d.ts.map +1 -0
- package/dist/internal/Sha256.js +144 -0
- package/dist/internal/Sha256.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal CRC-64/NVME, the NVMe CRC-64 — the content checksum of offloaded
|
|
3
|
+
* values and the trailer of a blob pointer (#179, design §4.2 and §5).
|
|
4
|
+
*
|
|
5
|
+
* Parameters (the CRC catalogue's "CRC-64/NVME", identical to S3's full-object
|
|
6
|
+
* `CRC64NVME`): width 64, polynomial `0xad93d23594c93659` (reflected
|
|
7
|
+
* `0x9a6c9329ac4bc9b5`), init all ones, input and output reflected, final XOR
|
|
8
|
+
* all ones. Check value: `"123456789"` → `ae8b14860a799888`.
|
|
9
|
+
*
|
|
10
|
+
* A digest is 8 bytes, most significant first — the bytes whose base64 S3
|
|
11
|
+
* sends and returns as `ChecksumCRC64NVME`.
|
|
12
|
+
*
|
|
13
|
+
* Pure JS, synchronous and runtime-neutral: slice-by-8 over 32-bit halves held
|
|
14
|
+
* in `Uint32Array` tables, so the hot loop needs no `BigInt`. Vendored rather
|
|
15
|
+
* than taken as a dependency because the schema package's pointer codec needs
|
|
16
|
+
* it and the package stays free of the AWS SDK and of Node builtins
|
|
17
|
+
* (`aws-free-guard.test.ts`, `node-free-guard.test.ts`).
|
|
18
|
+
*
|
|
19
|
+
* Not tamper evidence: a CRC is linear, so content with a chosen checksum is
|
|
20
|
+
* easy to craft. Callers use a match only where a false match is harmless or
|
|
21
|
+
* is backed by a real comparison (§5).
|
|
22
|
+
*
|
|
23
|
+
* Not part of the public API.
|
|
24
|
+
*/
|
|
25
|
+
/** Bytes in a CRC-64/NVME digest. */
|
|
26
|
+
export declare const CRC64NVME_BYTES = 8;
|
|
27
|
+
/** An incremental CRC-64/NVME. */
|
|
28
|
+
export type Crc64Nvme = {
|
|
29
|
+
/** Feed the next bytes (any view: offset and length are respected). */
|
|
30
|
+
readonly update: (bytes: Uint8Array) => Crc64Nvme;
|
|
31
|
+
/**
|
|
32
|
+
* The checksum of every byte fed so far: a fresh 8-byte array, most
|
|
33
|
+
* significant byte first. Does not end the computation — `update` may
|
|
34
|
+
* continue afterwards.
|
|
35
|
+
*/
|
|
36
|
+
readonly digest: () => Uint8Array;
|
|
37
|
+
};
|
|
38
|
+
/** A new incremental CRC-64/NVME over no bytes yet. */
|
|
39
|
+
export declare const make: () => Crc64Nvme;
|
|
40
|
+
/** The CRC-64/NVME of `bytes`: 8 bytes, most significant first. */
|
|
41
|
+
export declare const crc64nvme: (bytes: Uint8Array) => Uint8Array;
|
|
42
|
+
//# sourceMappingURL=Crc64Nvme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Crc64Nvme.d.ts","sourceRoot":"","sources":["../../src/internal/Crc64Nvme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,qCAAqC;AACrC,eAAO,MAAM,eAAe,IAAI,CAAA;AA6ChC,kCAAkC;AAClC,MAAM,MAAM,SAAS,GAAG;IACtB,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,SAAS,CAAA;IACjD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,UAAU,CAAA;CAClC,CAAA;AA+DD,uDAAuD;AACvD,eAAO,MAAM,IAAI,QAAO,SAAkC,CAAA;AAE1D,mEAAmE;AACnE,eAAO,MAAM,SAAS,GAAI,OAAO,UAAU,KAAG,UAA2C,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal CRC-64/NVME, the NVMe CRC-64 — the content checksum of offloaded
|
|
3
|
+
* values and the trailer of a blob pointer (#179, design §4.2 and §5).
|
|
4
|
+
*
|
|
5
|
+
* Parameters (the CRC catalogue's "CRC-64/NVME", identical to S3's full-object
|
|
6
|
+
* `CRC64NVME`): width 64, polynomial `0xad93d23594c93659` (reflected
|
|
7
|
+
* `0x9a6c9329ac4bc9b5`), init all ones, input and output reflected, final XOR
|
|
8
|
+
* all ones. Check value: `"123456789"` → `ae8b14860a799888`.
|
|
9
|
+
*
|
|
10
|
+
* A digest is 8 bytes, most significant first — the bytes whose base64 S3
|
|
11
|
+
* sends and returns as `ChecksumCRC64NVME`.
|
|
12
|
+
*
|
|
13
|
+
* Pure JS, synchronous and runtime-neutral: slice-by-8 over 32-bit halves held
|
|
14
|
+
* in `Uint32Array` tables, so the hot loop needs no `BigInt`. Vendored rather
|
|
15
|
+
* than taken as a dependency because the schema package's pointer codec needs
|
|
16
|
+
* it and the package stays free of the AWS SDK and of Node builtins
|
|
17
|
+
* (`aws-free-guard.test.ts`, `node-free-guard.test.ts`).
|
|
18
|
+
*
|
|
19
|
+
* Not tamper evidence: a CRC is linear, so content with a chosen checksum is
|
|
20
|
+
* easy to craft. Callers use a match only where a false match is harmless or
|
|
21
|
+
* is backed by a real comparison (§5).
|
|
22
|
+
*
|
|
23
|
+
* Not part of the public API.
|
|
24
|
+
*/
|
|
25
|
+
/** Bytes in a CRC-64/NVME digest. */
|
|
26
|
+
export const CRC64NVME_BYTES = 8;
|
|
27
|
+
/** The reflected polynomial, as two 32-bit halves. */
|
|
28
|
+
const POLY_HI = 0x9a6c9329;
|
|
29
|
+
const POLY_LO = 0xac4bc9b5;
|
|
30
|
+
/**
|
|
31
|
+
* Slice tables: entry `slice * 256 + i` is the CRC register after byte `i`
|
|
32
|
+
* followed by `slice` zero bytes. Built on first use, so importing the module
|
|
33
|
+
* computes nothing.
|
|
34
|
+
*/
|
|
35
|
+
let tableHi;
|
|
36
|
+
let tableLo;
|
|
37
|
+
const buildTables = () => {
|
|
38
|
+
const hi = new Uint32Array(8 * 256);
|
|
39
|
+
const lo = new Uint32Array(8 * 256);
|
|
40
|
+
for (let i = 0; i < 256; i++) {
|
|
41
|
+
let h = 0;
|
|
42
|
+
let l = i;
|
|
43
|
+
for (let bit = 0; bit < 8; bit++) {
|
|
44
|
+
const carry = l & 1;
|
|
45
|
+
l = (l >>> 1) | (h << 31);
|
|
46
|
+
h >>>= 1;
|
|
47
|
+
if (carry !== 0) {
|
|
48
|
+
h ^= POLY_HI;
|
|
49
|
+
l ^= POLY_LO;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
hi[i] = h;
|
|
53
|
+
lo[i] = l;
|
|
54
|
+
}
|
|
55
|
+
for (let slice = 1; slice < 8; slice++) {
|
|
56
|
+
for (let i = 0; i < 256; i++) {
|
|
57
|
+
const h = hi[(slice - 1) * 256 + i];
|
|
58
|
+
const l = lo[(slice - 1) * 256 + i];
|
|
59
|
+
const index = l & 0xff;
|
|
60
|
+
hi[slice * 256 + i] = (h >>> 8) ^ hi[index];
|
|
61
|
+
lo[slice * 256 + i] = ((l >>> 8) | (h << 24)) ^ lo[index];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
tableHi = hi;
|
|
65
|
+
tableLo = lo;
|
|
66
|
+
};
|
|
67
|
+
class Crc64NvmeHasher {
|
|
68
|
+
// The register before the final XOR, as two 32-bit halves (init: all ones).
|
|
69
|
+
hi = 0xffffffff;
|
|
70
|
+
lo = 0xffffffff;
|
|
71
|
+
update = (bytes) => {
|
|
72
|
+
if (tableHi === undefined || tableLo === undefined)
|
|
73
|
+
buildTables();
|
|
74
|
+
const th = tableHi;
|
|
75
|
+
const tl = tableLo;
|
|
76
|
+
const length = bytes.length;
|
|
77
|
+
let hi = this.hi;
|
|
78
|
+
let lo = this.lo;
|
|
79
|
+
let i = 0;
|
|
80
|
+
// Eight bytes at a time: XOR them into the register (little-endian, as
|
|
81
|
+
// the CRC is reflected), then look each register byte up in the table
|
|
82
|
+
// for its distance from the end of the word.
|
|
83
|
+
while (length - i >= 8) {
|
|
84
|
+
const l = lo ^ (bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24));
|
|
85
|
+
const h = hi ^ (bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24));
|
|
86
|
+
const i7 = 0x700 | (l & 0xff);
|
|
87
|
+
const i6 = 0x600 | ((l >>> 8) & 0xff);
|
|
88
|
+
const i5 = 0x500 | ((l >>> 16) & 0xff);
|
|
89
|
+
const i4 = 0x400 | (l >>> 24);
|
|
90
|
+
const i3 = 0x300 | (h & 0xff);
|
|
91
|
+
const i2 = 0x200 | ((h >>> 8) & 0xff);
|
|
92
|
+
const i1 = 0x100 | ((h >>> 16) & 0xff);
|
|
93
|
+
const i0 = h >>> 24;
|
|
94
|
+
hi = th[i7] ^ th[i6] ^ th[i5] ^ th[i4] ^ th[i3] ^ th[i2] ^ th[i1] ^ th[i0];
|
|
95
|
+
lo = tl[i7] ^ tl[i6] ^ tl[i5] ^ tl[i4] ^ tl[i3] ^ tl[i2] ^ tl[i1] ^ tl[i0];
|
|
96
|
+
i += 8;
|
|
97
|
+
}
|
|
98
|
+
// The tail, a byte at a time.
|
|
99
|
+
while (i < length) {
|
|
100
|
+
const index = (lo ^ bytes[i]) & 0xff;
|
|
101
|
+
lo = ((lo >>> 8) | (hi << 24)) ^ tl[index];
|
|
102
|
+
hi = (hi >>> 8) ^ th[index];
|
|
103
|
+
i++;
|
|
104
|
+
}
|
|
105
|
+
this.hi = hi;
|
|
106
|
+
this.lo = lo;
|
|
107
|
+
return this;
|
|
108
|
+
};
|
|
109
|
+
digest = () => {
|
|
110
|
+
const hi = ~this.hi;
|
|
111
|
+
const lo = ~this.lo;
|
|
112
|
+
return new Uint8Array([
|
|
113
|
+
hi >>> 24,
|
|
114
|
+
(hi >>> 16) & 0xff,
|
|
115
|
+
(hi >>> 8) & 0xff,
|
|
116
|
+
hi & 0xff,
|
|
117
|
+
lo >>> 24,
|
|
118
|
+
(lo >>> 16) & 0xff,
|
|
119
|
+
(lo >>> 8) & 0xff,
|
|
120
|
+
lo & 0xff,
|
|
121
|
+
]);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** A new incremental CRC-64/NVME over no bytes yet. */
|
|
125
|
+
export const make = () => new Crc64NvmeHasher();
|
|
126
|
+
/** The CRC-64/NVME of `bytes`: 8 bytes, most significant first. */
|
|
127
|
+
export const crc64nvme = (bytes) => make().update(bytes).digest();
|
|
128
|
+
//# sourceMappingURL=Crc64Nvme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Crc64Nvme.js","sourceRoot":"","sources":["../../src/internal/Crc64Nvme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,qCAAqC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AAEhC,sDAAsD;AACtD,MAAM,OAAO,GAAG,UAAU,CAAA;AAC1B,MAAM,OAAO,GAAG,UAAU,CAAA;AAE1B;;;;GAIG;AACH,IAAI,OAAgC,CAAA;AACpC,IAAI,OAAgC,CAAA;AAEpC,MAAM,WAAW,GAAG,GAAS,EAAE;IAC7B,MAAM,EAAE,GAAG,IAAI,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA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AuD;AACvD,MAAM,CAAC,MAAM,IAAI,GAAG,GAAc,EAAE,CAAC,IAAI,eAAe,EAAE,CAAA;AAE1D,mEAAmE;AACnE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAiB,EAAc,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAA"}
|
|
@@ -162,4 +162,34 @@ export interface RefValue {
|
|
|
162
162
|
};
|
|
163
163
|
readonly cascade?: CascadeIndexConfig;
|
|
164
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Item-level offload settings of a member with offloaded fields
|
|
167
|
+
* (`Entity.make({ offload })`, `EventStore.makeStream({ offload })`, #179).
|
|
168
|
+
* See `DESIGN.md §7 "Offloaded Storage"`.
|
|
169
|
+
*/
|
|
170
|
+
export interface OffloadConfig {
|
|
171
|
+
/**
|
|
172
|
+
* Stored item bytes the library keeps an item under by offloading overflow
|
|
173
|
+
* fields (`Packed({ external })`), largest first, where it builds the whole
|
|
174
|
+
* item. A safe integer in 1 … 409,600. A routing decision, not a limit
|
|
175
|
+
* check: DynamoDB's own limits are still diagnosed from the failed request.
|
|
176
|
+
* Absent: thresholds only.
|
|
177
|
+
*/
|
|
178
|
+
readonly itemBudget?: number | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* Replaces the store's prefix for every object key this member writes — a
|
|
181
|
+
* non-empty string of RFC 3986 unreserved characters and `/`, at most 256
|
|
182
|
+
* bytes, not starting with `/`. The bucket's IAM policy must cover it.
|
|
183
|
+
*/
|
|
184
|
+
readonly prefix?: string | undefined;
|
|
185
|
+
}
|
|
186
|
+
/** The resolved offload settings exposed on an entity (`entity.offload`). */
|
|
187
|
+
export interface ResolvedOffload {
|
|
188
|
+
readonly itemBudget: number | undefined;
|
|
189
|
+
readonly prefix: string | undefined;
|
|
190
|
+
/** Domain names of the overflow fields (`Packed({ external })`). */
|
|
191
|
+
readonly overflow: ReadonlyArray<string>;
|
|
192
|
+
/** Domain names of the binary fields (`External()`). */
|
|
193
|
+
readonly binary: ReadonlyArray<string>;
|
|
194
|
+
}
|
|
165
195
|
//# sourceMappingURL=EntityConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityConfig.d.ts","sourceRoot":"","sources":["../../src/internal/EntityConfig.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAM9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,MAAM,CAAC,GAAG,GACV;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG,GAAG,SAAS,CAAA;CAAE,CAAA;AAErF;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP;IACE,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAA;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAA;CACxC,CAAA;AAEL;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACvB,OAAO,GACP;IACE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAA;CAC1C,CAAA;AAEL;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP;IACE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAA;IACzC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAClC,CAAA;AAEL;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,gBAAgB,CAC1B,YAAY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,mBAAmB,CAAC,CAAC,CAAC,CACvB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IACvC,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CACxC;AAED;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAA;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAA;CACtC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACrC;AAED,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACxC,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACvC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal Offloaded entity fields (#179) — definition-time guards and the
|
|
3
|
+
* resolved offload settings.
|
|
4
|
+
*
|
|
5
|
+
* Two field kinds offload to the blob store: **overflow** fields
|
|
6
|
+
* (`storedAs: DynamoModel.Packed({ external })`, which are packed fields and
|
|
7
|
+
* so also pass every Packed guard of `internal/EntityPacked.ts`) and
|
|
8
|
+
* **binary** fields (`storedAs: DynamoModel.External(...)`). Shared by the
|
|
9
|
+
* pure `Entity.make` (this package) and the runtime one (`effect-dynamodb`),
|
|
10
|
+
* through `buildEntityDefinition`; the aggregate and EventStore guards reuse
|
|
11
|
+
* the pieces exported here. See `docs/designs/blob-offload.md` §3, §13–§15 and
|
|
12
|
+
* `DESIGN.md §7 "Offloaded Storage"`.
|
|
13
|
+
*
|
|
14
|
+
* Guards (thrown as plain `Error`s at `Entity.make()`, like the Packed ones):
|
|
15
|
+
*
|
|
16
|
+
* - `[EDD-9111]` an `External` field does not exist on the model, or its
|
|
17
|
+
* encoded side is not `Uint8Array`.
|
|
18
|
+
* - `[EDD-9142]` an `External` field is a key or index attribute source (a
|
|
19
|
+
* primary-key / secondary-index composite or a `shards.by` source,
|
|
20
|
+
* {@link externalIndexRefusal}, or `timeSeries.orderBy`), a unique-constraint field, a `DynamoModel.ref`
|
|
21
|
+
* field, the entity's identifier (which refs and cascade indexes compose
|
|
22
|
+
* into keys), or a vector index source, partition or filter field.
|
|
23
|
+
* - `[EDD-9143]` a ref whose schema includes a field the referenced entity
|
|
24
|
+
* offloads: the denormalised copy would inline it, need to marshal a lazy
|
|
25
|
+
* handle, or copy a pointer across item families.
|
|
26
|
+
* - `[EDD-9114]` invalid `offload` options (see {@link resolveOffloadOptions}).
|
|
27
|
+
*/
|
|
28
|
+
import { type Schema } from "effect";
|
|
29
|
+
import { type ExternalConfig, type ExternalPackedConfig } from "../DynamoModel.js";
|
|
30
|
+
import type { IndexDefinition } from "../KeyComposer.js";
|
|
31
|
+
import type { VectorIndexConfig } from "../VectorIndex.js";
|
|
32
|
+
import type { OffloadConfig, ResolvedOffload, TimeSeriesConfig, UniqueConfig } from "./EntityConfig.js";
|
|
33
|
+
/** The largest `offload.itemBudget`: DynamoDB's item limit, 400 KB. */
|
|
34
|
+
export declare const MAX_ITEM_BUDGET = 409600;
|
|
35
|
+
/** The longest `offload.prefix`, in bytes. */
|
|
36
|
+
export declare const MAX_OFFLOAD_PREFIX_BYTES = 256;
|
|
37
|
+
/** The offloaded fields of a model, by kind (domain field name → config). */
|
|
38
|
+
export interface OffloadedFields {
|
|
39
|
+
readonly overflow: Readonly<Record<string, ExternalPackedConfig>>;
|
|
40
|
+
readonly binary: Readonly<Record<string, ExternalConfig>>;
|
|
41
|
+
}
|
|
42
|
+
/** The offloaded fields a (possibly configured) model declares. */
|
|
43
|
+
export declare const offloadedFieldsOf: (model: Schema.Top) => OffloadedFields;
|
|
44
|
+
/** The resolved `offload` options of a member. */
|
|
45
|
+
export interface OffloadOptions {
|
|
46
|
+
readonly itemBudget: number | undefined;
|
|
47
|
+
readonly prefix: string | undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validate a member's `offload` options (`[EDD-9114]`): an object with only
|
|
51
|
+
* `itemBudget` (a safe integer in 1 … 409,600) and `prefix` (a non-empty
|
|
52
|
+
* string of RFC 3986 unreserved characters and `/`, at most 256 bytes, not
|
|
53
|
+
* starting with `/`); `itemBudget` only on a member with an overflow value,
|
|
54
|
+
* and `offload` only on a member that offloads something.
|
|
55
|
+
*
|
|
56
|
+
* `member` labels messages (`Entity "Document"`, `EventStream "Ledger"`).
|
|
57
|
+
*/
|
|
58
|
+
export declare const resolveOffloadOptions: (member: string, options: unknown, kinds: {
|
|
59
|
+
readonly overflow: boolean;
|
|
60
|
+
readonly offloaded: boolean;
|
|
61
|
+
}) => OffloadOptions;
|
|
62
|
+
/**
|
|
63
|
+
* Why an index cannot be declared on an entity with these `External` fields,
|
|
64
|
+
* or `undefined` (`[EDD-9142]`): a binary field is a source of its write
|
|
65
|
+
* sharding (`shards.by`, #183), whose hash would read the stored pointer, or
|
|
66
|
+
* one of its composites. Matched by own key (`Object.hasOwn`) as
|
|
67
|
+
* `packedIndexRefusal` matches packed ones. (An overflow field is a packed
|
|
68
|
+
* one: as a composite it is refused by the Packed guard, and `shards.by`
|
|
69
|
+
* names only composites.)
|
|
70
|
+
*/
|
|
71
|
+
export declare const externalIndexRefusal: (entityType: string, externalFields: Readonly<Record<string, ExternalConfig>>, indexName: string, def: IndexDefinition) => string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Why the ref `refName` (a denormalised copy of `target`, described by
|
|
74
|
+
* `refSchema`) cannot be declared, or `undefined`: its schema includes a field
|
|
75
|
+
* the referenced entity offloads (`[EDD-9143]`). `owner` labels the message
|
|
76
|
+
* (`Entity "Order"`, `Aggregate edge "team"`).
|
|
77
|
+
*/
|
|
78
|
+
export declare const refOffloadRefusal: (owner: string, refName: string, refSchema: Schema.Top, target: {
|
|
79
|
+
readonly entityType: string;
|
|
80
|
+
readonly model: Schema.Top;
|
|
81
|
+
}) => string | undefined;
|
|
82
|
+
/** The offload plan of an entity definition. */
|
|
83
|
+
export interface OffloadPlan {
|
|
84
|
+
/** Domain field name → config, for every `External` (binary) field. */
|
|
85
|
+
readonly externalFields: Readonly<Record<string, ExternalConfig>>;
|
|
86
|
+
/** Domain field name → config, for every overflow field (`Packed({ external })`). */
|
|
87
|
+
readonly overflowFields: Readonly<Record<string, ExternalPackedConfig>>;
|
|
88
|
+
/** The resolved `entity.offload`; `undefined` when the entity offloads nothing. */
|
|
89
|
+
readonly offload: ResolvedOffload | undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Validate the offloaded fields and `offload` options of an entity definition
|
|
93
|
+
* and derive its {@link OffloadPlan}. Throws on the first refusal (see the
|
|
94
|
+
* module header).
|
|
95
|
+
*/
|
|
96
|
+
export declare const resolveOffloadPlan: (args: {
|
|
97
|
+
readonly entityType: string;
|
|
98
|
+
readonly model: Schema.Top;
|
|
99
|
+
readonly modelFields: Readonly<Record<string, Schema.Top>>;
|
|
100
|
+
readonly indexes: Readonly<Record<string, IndexDefinition>>;
|
|
101
|
+
readonly unique: UniqueConfig | undefined;
|
|
102
|
+
readonly timeSeries: TimeSeriesConfig<any> | undefined;
|
|
103
|
+
readonly vectorIndexes: Readonly<Record<string, VectorIndexConfig>> | undefined;
|
|
104
|
+
readonly refs: Readonly<Record<string, {
|
|
105
|
+
readonly entity: {
|
|
106
|
+
readonly entityType: string;
|
|
107
|
+
readonly model: Schema.Top;
|
|
108
|
+
};
|
|
109
|
+
}>> | undefined;
|
|
110
|
+
readonly offload: OffloadConfig | undefined;
|
|
111
|
+
}) => OffloadPlan;
|
|
112
|
+
//# sourceMappingURL=EntityOffload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityOffload.d.ts","sourceRoot":"","sources":["../../src/internal/EntityOffload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,QAAQ,CAAA;AAC/C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAM1B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,YAAY,EACb,MAAM,mBAAmB,CAAA;AAK1B,uEAAuE;AACvE,eAAO,MAAM,eAAe,SAAU,CAAA;AAEtC,8CAA8C;AAC9C,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAK3C,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAA;IACjE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;CAC1D;AAED,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,GAAI,OAA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AAI,MAAM;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1D,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAA;IAC3D,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAA;IACtD,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,GAAG,SAAS,CAAA;IAC/E,QAAQ,CAAC,IAAI,EACT,QAAQ,CACN,MAAM,CACJ,MAAM,EACN;QAAE,QAAQ,CAAC,MAAM,EAAE;YAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAA;SAAE,CAAA;KAAE,CACjF,CACF,GACD,SAAS,CAAA;IACb,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAAA;CAC5C,KAAG,WA4HH,CAAA"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal Offloaded entity fields (#179) — definition-time guards and the
|
|
3
|
+
* resolved offload settings.
|
|
4
|
+
*
|
|
5
|
+
* Two field kinds offload to the blob store: **overflow** fields
|
|
6
|
+
* (`storedAs: DynamoModel.Packed({ external })`, which are packed fields and
|
|
7
|
+
* so also pass every Packed guard of `internal/EntityPacked.ts`) and
|
|
8
|
+
* **binary** fields (`storedAs: DynamoModel.External(...)`). Shared by the
|
|
9
|
+
* pure `Entity.make` (this package) and the runtime one (`effect-dynamodb`),
|
|
10
|
+
* through `buildEntityDefinition`; the aggregate and EventStore guards reuse
|
|
11
|
+
* the pieces exported here. See `docs/designs/blob-offload.md` §3, §13–§15 and
|
|
12
|
+
* `DESIGN.md §7 "Offloaded Storage"`.
|
|
13
|
+
*
|
|
14
|
+
* Guards (thrown as plain `Error`s at `Entity.make()`, like the Packed ones):
|
|
15
|
+
*
|
|
16
|
+
* - `[EDD-9111]` an `External` field does not exist on the model, or its
|
|
17
|
+
* encoded side is not `Uint8Array`.
|
|
18
|
+
* - `[EDD-9142]` an `External` field is a key or index attribute source (a
|
|
19
|
+
* primary-key / secondary-index composite or a `shards.by` source,
|
|
20
|
+
* {@link externalIndexRefusal}, or `timeSeries.orderBy`), a unique-constraint field, a `DynamoModel.ref`
|
|
21
|
+
* field, the entity's identifier (which refs and cascade indexes compose
|
|
22
|
+
* into keys), or a vector index source, partition or filter field.
|
|
23
|
+
* - `[EDD-9143]` a ref whose schema includes a field the referenced entity
|
|
24
|
+
* offloads: the denormalised copy would inline it, need to marshal a lazy
|
|
25
|
+
* handle, or copy a pointer across item families.
|
|
26
|
+
* - `[EDD-9114]` invalid `offload` options (see {@link resolveOffloadOptions}).
|
|
27
|
+
*/
|
|
28
|
+
import { SchemaAST } from "effect";
|
|
29
|
+
import { getExternalFields, getIdentifierField, getPackedFields, isExternalPackedConfig, isRefField, } from "../DynamoModel.js";
|
|
30
|
+
import { resolveUniqueFields } from "./EntitySchemas.js";
|
|
31
|
+
import { binaryShapeRefusal } from "./PackedCodec.js";
|
|
32
|
+
import { firstTypeParameterAst } from "./SchemaAccessors.js";
|
|
33
|
+
/** The largest `offload.itemBudget`: DynamoDB's item limit, 400 KB. */
|
|
34
|
+
export const MAX_ITEM_BUDGET = 409_600;
|
|
35
|
+
/** The longest `offload.prefix`, in bytes. */
|
|
36
|
+
export const MAX_OFFLOAD_PREFIX_BYTES = 256;
|
|
37
|
+
/** RFC 3986 unreserved characters, plus `/`. */
|
|
38
|
+
const PREFIX_PATTERN = /^[A-Za-z0-9\-._~/]+$/;
|
|
39
|
+
/** The offloaded fields a (possibly configured) model declares. */
|
|
40
|
+
export const offloadedFieldsOf = (model) => {
|
|
41
|
+
const overflow = {};
|
|
42
|
+
for (const [field, config] of Object.entries(getPackedFields(model))) {
|
|
43
|
+
if (isExternalPackedConfig(config))
|
|
44
|
+
overflow[field] = config;
|
|
45
|
+
}
|
|
46
|
+
return { overflow, binary: getExternalFields(model) };
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Validate a member's `offload` options (`[EDD-9114]`): an object with only
|
|
50
|
+
* `itemBudget` (a safe integer in 1 … 409,600) and `prefix` (a non-empty
|
|
51
|
+
* string of RFC 3986 unreserved characters and `/`, at most 256 bytes, not
|
|
52
|
+
* starting with `/`); `itemBudget` only on a member with an overflow value,
|
|
53
|
+
* and `offload` only on a member that offloads something.
|
|
54
|
+
*
|
|
55
|
+
* `member` labels messages (`Entity "Document"`, `EventStream "Ledger"`).
|
|
56
|
+
*/
|
|
57
|
+
export const resolveOffloadOptions = (member, options, kinds) => {
|
|
58
|
+
if (options === undefined)
|
|
59
|
+
return { itemBudget: undefined, prefix: undefined };
|
|
60
|
+
const fail = (message) => {
|
|
61
|
+
throw new Error(`[EDD-9114] ${member}: ${message}`);
|
|
62
|
+
};
|
|
63
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) {
|
|
64
|
+
return fail(`offload must be an object { itemBudget?, prefix? }; received ` +
|
|
65
|
+
`${options === null ? "null" : Array.isArray(options) ? "an array" : typeof options}.`);
|
|
66
|
+
}
|
|
67
|
+
for (const key of Object.keys(options)) {
|
|
68
|
+
if (key !== "itemBudget" && key !== "prefix") {
|
|
69
|
+
fail(`unknown offload option "${key}" (expected optional "itemBudget" and "prefix").`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!kinds.offloaded) {
|
|
73
|
+
fail("offload is set, but nothing is offloaded. Declare an overflow field " +
|
|
74
|
+
"(DynamoModel.Packed({ external })) or a binary field (DynamoModel.External()) first.");
|
|
75
|
+
}
|
|
76
|
+
const { itemBudget, prefix } = options;
|
|
77
|
+
if (itemBudget !== undefined) {
|
|
78
|
+
if (typeof itemBudget !== "number" ||
|
|
79
|
+
!Number.isSafeInteger(itemBudget) ||
|
|
80
|
+
itemBudget < 1 ||
|
|
81
|
+
itemBudget > MAX_ITEM_BUDGET) {
|
|
82
|
+
fail(`offload.itemBudget must be a safe integer in 1 … ${MAX_ITEM_BUDGET} (stored item ` +
|
|
83
|
+
`bytes), got ${String(itemBudget)}.`);
|
|
84
|
+
}
|
|
85
|
+
if (!kinds.overflow) {
|
|
86
|
+
fail("offload.itemBudget is set, but nothing can be offloaded to meet it: the budget routes " +
|
|
87
|
+
"overflow values (DynamoModel.Packed({ external })), and there are none.");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (prefix !== undefined) {
|
|
91
|
+
if (typeof prefix !== "string" ||
|
|
92
|
+
prefix.length === 0 ||
|
|
93
|
+
prefix.length > MAX_OFFLOAD_PREFIX_BYTES ||
|
|
94
|
+
!PREFIX_PATTERN.test(prefix) ||
|
|
95
|
+
prefix.startsWith("/")) {
|
|
96
|
+
fail(`offload.prefix must be a non-empty string of RFC 3986 unreserved characters ` +
|
|
97
|
+
`(A–Z a–z 0–9 - . _ ~) and "/", at most ${MAX_OFFLOAD_PREFIX_BYTES} bytes, not ` +
|
|
98
|
+
`starting with "/"; got ${typeof prefix === "string" ? JSON.stringify(prefix) : String(prefix)}.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
itemBudget: itemBudget,
|
|
103
|
+
prefix: prefix,
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Why an index cannot be declared on an entity with these `External` fields,
|
|
108
|
+
* or `undefined` (`[EDD-9142]`): a binary field is a source of its write
|
|
109
|
+
* sharding (`shards.by`, #183), whose hash would read the stored pointer, or
|
|
110
|
+
* one of its composites. Matched by own key (`Object.hasOwn`) as
|
|
111
|
+
* `packedIndexRefusal` matches packed ones. (An overflow field is a packed
|
|
112
|
+
* one: as a composite it is refused by the Packed guard, and `shards.by`
|
|
113
|
+
* names only composites.)
|
|
114
|
+
*/
|
|
115
|
+
export const externalIndexRefusal = (entityType, externalFields, indexName, def) => {
|
|
116
|
+
for (const attr of def.shards?.by ?? []) {
|
|
117
|
+
if (Object.hasOwn(externalFields, attr)) {
|
|
118
|
+
return (`[EDD-9142] Entity "${entityType}": External field "${attr}" cannot be a shards.by ` +
|
|
119
|
+
`source of index "${indexName}". The shard is hashed from the field's value, which lives ` +
|
|
120
|
+
"in the blob store; shard sources must be scalar sort key composites.");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (const attr of [...def.pk.composite, ...def.sk.composite]) {
|
|
124
|
+
if (Object.hasOwn(externalFields, attr)) {
|
|
125
|
+
return (`[EDD-9142] Entity "${entityType}": External field "${attr}" cannot be a composite of ` +
|
|
126
|
+
`${indexName === "primary" ? "the primary key" : `index "${indexName}"`}. Its value ` +
|
|
127
|
+
"lives in the blob store; key composites must be scalar model values.");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return undefined;
|
|
131
|
+
};
|
|
132
|
+
/** The domain property names a (struct- or class-shaped) schema declares. */
|
|
133
|
+
const propertyNames = (ast, seen, out) => {
|
|
134
|
+
if (seen.has(ast))
|
|
135
|
+
return;
|
|
136
|
+
seen.add(ast);
|
|
137
|
+
const type = SchemaAST.toType(ast);
|
|
138
|
+
if (SchemaAST.isObjects(type)) {
|
|
139
|
+
for (const signature of type.propertySignatures) {
|
|
140
|
+
if (typeof signature.name === "string")
|
|
141
|
+
out.add(signature.name);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (SchemaAST.isUnion(type)) {
|
|
145
|
+
for (const member of type.types)
|
|
146
|
+
propertyNames(member, seen, out);
|
|
147
|
+
}
|
|
148
|
+
else if (SchemaAST.isSuspend(type)) {
|
|
149
|
+
propertyNames(type.thunk(), seen, out);
|
|
150
|
+
}
|
|
151
|
+
else if (SchemaAST.isDeclaration(type)) {
|
|
152
|
+
// A Schema.Class: its fields are the declaration's type parameter.
|
|
153
|
+
const fields = firstTypeParameterAst(type);
|
|
154
|
+
if (fields !== undefined)
|
|
155
|
+
propertyNames(fields, seen, out);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Why the ref `refName` (a denormalised copy of `target`, described by
|
|
160
|
+
* `refSchema`) cannot be declared, or `undefined`: its schema includes a field
|
|
161
|
+
* the referenced entity offloads (`[EDD-9143]`). `owner` labels the message
|
|
162
|
+
* (`Entity "Order"`, `Aggregate edge "team"`).
|
|
163
|
+
*/
|
|
164
|
+
export const refOffloadRefusal = (owner, refName, refSchema, target) => {
|
|
165
|
+
const offloaded = offloadedFieldsOf(target.model);
|
|
166
|
+
const names = new Set();
|
|
167
|
+
propertyNames(refSchema.ast, new Set(), names);
|
|
168
|
+
const included = [...Object.keys(offloaded.overflow), ...Object.keys(offloaded.binary)].filter((field) => names.has(field));
|
|
169
|
+
if (included.length === 0)
|
|
170
|
+
return undefined;
|
|
171
|
+
return (`[EDD-9143] ${owner}: ref "${refName}" copies entity "${target.entityType}", and its schema ` +
|
|
172
|
+
`includes ${included.map((field) => `"${field}"`).join(", ")}, which that entity offloads to ` +
|
|
173
|
+
"the blob store. A ref is a denormalised copy: it would inline the value (risking the 400 KB " +
|
|
174
|
+
"item limit) or copy a pointer across item families. Reference a subset model without " +
|
|
175
|
+
(included.length === 1 ? "that field." : "those fields."));
|
|
176
|
+
};
|
|
177
|
+
const refusal = (code, entityType, field, message) => new Error(`[${code}] Entity "${entityType}": External field "${field}" ${message}`);
|
|
178
|
+
/**
|
|
179
|
+
* Validate the offloaded fields and `offload` options of an entity definition
|
|
180
|
+
* and derive its {@link OffloadPlan}. Throws on the first refusal (see the
|
|
181
|
+
* module header).
|
|
182
|
+
*/
|
|
183
|
+
export const resolveOffloadPlan = (args) => {
|
|
184
|
+
const { entityType, modelFields } = args;
|
|
185
|
+
const fields = offloadedFieldsOf(args.model);
|
|
186
|
+
const identifier = getIdentifierField(args.model)?.name;
|
|
187
|
+
for (const field of Object.keys(fields.binary)) {
|
|
188
|
+
const schema = modelFields[field];
|
|
189
|
+
if (schema === undefined) {
|
|
190
|
+
throw refusal("EDD-9111", entityType, field, `does not exist on the model. Valid model fields: ${Object.keys(modelFields).sort().join(", ")}`);
|
|
191
|
+
}
|
|
192
|
+
const notBinary = binaryShapeRefusal(schema);
|
|
193
|
+
if (notBinary !== undefined) {
|
|
194
|
+
throw refusal("EDD-9111", entityType, field, `must be binary: ${notBinary}. DynamoModel.External stores a Uint8Array field ` +
|
|
195
|
+
"(Schema.Uint8Array, optionally optional / NullOr); Uint8ArrayFromBase64 stores text.");
|
|
196
|
+
}
|
|
197
|
+
if (isRefField(field, args.model)) {
|
|
198
|
+
throw refusal("EDD-9142", entityType, field, "is a DynamoModel.ref field. A ref is a denormalised copy the library writes and " +
|
|
199
|
+
"cascades into; it stays a native map.");
|
|
200
|
+
}
|
|
201
|
+
if (identifier === field) {
|
|
202
|
+
throw refusal("EDD-9142", entityType, field, "is the entity's identifier. Refs to the entity and their cascade indexes compose it " +
|
|
203
|
+
"into keys, which must be scalar model values.");
|
|
204
|
+
}
|
|
205
|
+
for (const [indexName, def] of Object.entries(args.indexes)) {
|
|
206
|
+
if ([...(def.shards?.by ?? []), ...def.pk.composite, ...def.sk.composite].includes(field)) {
|
|
207
|
+
throw new Error(externalIndexRefusal(entityType, fields.binary, indexName, def));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (args.timeSeries?.orderBy === field) {
|
|
211
|
+
throw refusal("EDD-9142", entityType, field, "cannot be timeSeries.orderBy: the event clock is compared by DynamoDB (CAS) and " +
|
|
212
|
+
"composed into the event sort key.");
|
|
213
|
+
}
|
|
214
|
+
for (const [name, vector] of Object.entries(args.vectorIndexes ?? {})) {
|
|
215
|
+
if ((vector.source?.fields ?? []).includes(field)) {
|
|
216
|
+
throw refusal("EDD-9142", entityType, field, `cannot be a source field of vector index "${name}": the embedder reads text.`);
|
|
217
|
+
}
|
|
218
|
+
if ((vector.partition ?? []).includes(field)) {
|
|
219
|
+
throw refusal("EDD-9142", entityType, field, `cannot be a partition composite of vector index "${name}".`);
|
|
220
|
+
}
|
|
221
|
+
if ((vector.filters ?? []).includes(field)) {
|
|
222
|
+
throw refusal("EDD-9142", entityType, field, `cannot be a filter field of vector index "${name}": DynamoDB filters on the stored value.`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
for (const [constraint, def] of Object.entries(args.unique ?? {})) {
|
|
226
|
+
if (resolveUniqueFields(def).includes(field)) {
|
|
227
|
+
throw refusal("EDD-9142", entityType, field, `cannot be named by unique constraint "${constraint}": its sentinel is composed from ` +
|
|
228
|
+
"scalar field values.");
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
for (const [refName, refValue] of Object.entries(args.refs ?? {})) {
|
|
233
|
+
const refSchema = modelFields[refName];
|
|
234
|
+
// A ref naming no model field is refused when refs are resolved.
|
|
235
|
+
if (refSchema === undefined || refValue?.entity?.model === undefined)
|
|
236
|
+
continue;
|
|
237
|
+
const refused = refOffloadRefusal(`Entity "${entityType}"`, refName, refSchema, refValue.entity);
|
|
238
|
+
if (refused !== undefined)
|
|
239
|
+
throw new Error(refused);
|
|
240
|
+
}
|
|
241
|
+
const overflow = Object.keys(fields.overflow);
|
|
242
|
+
const binary = Object.keys(fields.binary);
|
|
243
|
+
const options = resolveOffloadOptions(`Entity "${entityType}"`, args.offload, {
|
|
244
|
+
overflow: overflow.length > 0,
|
|
245
|
+
offloaded: overflow.length + binary.length > 0,
|
|
246
|
+
});
|
|
247
|
+
return {
|
|
248
|
+
externalFields: fields.binary,
|
|
249
|
+
overflowFields: fields.overflow,
|
|
250
|
+
offload: overflow.length + binary.length === 0
|
|
251
|
+
? undefined
|
|
252
|
+
: Object.freeze({
|
|
253
|
+
itemBudget: options.itemBudget,
|
|
254
|
+
prefix: options.prefix,
|
|
255
|
+
overflow: Object.freeze(overflow),
|
|
256
|
+
binary: Object.freeze(binary),
|
|
257
|
+
}),
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
//# sourceMappingURL=EntityOffload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityOffload.js","sourceRoot":"","sources":["../../src/internal/EntityOffload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAe,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAGL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,UAAU,GACX,MAAM,mBAAmB,CAAA;AAS1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAA;AAEtC,8CAA8C;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAE3C,gDAAgD;AAChD,MAAM,cAAc,GAAG,sBAAsB,CAAA;AAQ7C,mEAAmE;AACnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAiB,EAAmB,EAAE;IACtE,MAAM,QAAQ,GAAyC,EAAE,CAAA;IACzD,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACrE,IAAI,sBAAsB,CAAC,MAAM,CAAC;YAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,MAAM,CAAA;IAC9D,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,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