effect-dynamodb 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 +157 -20
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js +1219 -286
- package/dist/Aggregate.js.map +1 -1
- package/dist/Batch.d.ts +17 -4
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +129 -62
- package/dist/Batch.js.map +1 -1
- package/dist/BlobGc.d.ts +243 -0
- package/dist/BlobGc.d.ts.map +1 -0
- package/dist/BlobGc.js +961 -0
- package/dist/BlobGc.js.map +1 -0
- package/dist/BlobStore.d.ts +83 -0
- package/dist/BlobStore.d.ts.map +1 -0
- package/dist/BlobStore.js +70 -0
- package/dist/BlobStore.js.map +1 -0
- package/dist/Collection.d.ts +88 -8
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +22 -26
- package/dist/Collection.js.map +1 -1
- package/dist/Collections.d.ts +0 -7
- package/dist/Collections.d.ts.map +1 -1
- package/dist/Collections.js +0 -16
- package/dist/Collections.js.map +1 -1
- package/dist/DynamoClient.d.ts +68 -35
- package/dist/DynamoClient.d.ts.map +1 -1
- package/dist/DynamoClient.js +58 -12
- package/dist/DynamoClient.js.map +1 -1
- package/dist/Entity.d.ts +403 -104
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +1771 -382
- package/dist/Entity.js.map +1 -1
- package/dist/EventStore.d.ts +323 -77
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +473 -96
- package/dist/EventStore.js.map +1 -1
- package/dist/Offload.d.ts +199 -0
- package/dist/Offload.d.ts.map +1 -0
- package/dist/Offload.js +120 -0
- package/dist/Offload.js.map +1 -0
- package/dist/Query.d.ts +132 -59
- package/dist/Query.d.ts.map +1 -1
- package/dist/Query.js +95 -31
- package/dist/Query.js.map +1 -1
- package/dist/StorageEncoding.d.ts +62 -15
- package/dist/StorageEncoding.d.ts.map +1 -1
- package/dist/StorageEncoding.js +108 -24
- package/dist/StorageEncoding.js.map +1 -1
- package/dist/Table.d.ts +1 -1
- package/dist/Table.d.ts.map +1 -1
- package/dist/Transaction.d.ts +16 -3
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +28 -9
- package/dist/Transaction.js.map +1 -1
- package/dist/blob/S3BlobStore.d.ts +178 -0
- package/dist/blob/S3BlobStore.d.ts.map +1 -0
- package/dist/blob/S3BlobStore.js +770 -0
- package/dist/blob/S3BlobStore.js.map +1 -0
- package/dist/blob/s3.d.ts +122 -0
- package/dist/blob/s3.d.ts.map +1 -0
- package/dist/blob/s3.js +143 -0
- package/dist/blob/s3.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/AggregateWrite.d.ts +130 -0
- package/dist/internal/AggregateWrite.d.ts.map +1 -0
- package/dist/internal/AggregateWrite.js +341 -0
- package/dist/internal/AggregateWrite.js.map +1 -0
- package/dist/internal/BlobCalls.d.ts +70 -0
- package/dist/internal/BlobCalls.d.ts.map +1 -0
- package/dist/internal/BlobCalls.js +105 -0
- package/dist/internal/BlobCalls.js.map +1 -0
- package/dist/internal/BlobKeys.d.ts +100 -0
- package/dist/internal/BlobKeys.d.ts.map +1 -0
- package/dist/internal/BlobKeys.js +135 -0
- package/dist/internal/BlobKeys.js.map +1 -0
- package/dist/internal/BlobLedger.d.ts +323 -0
- package/dist/internal/BlobLedger.d.ts.map +1 -0
- package/dist/internal/BlobLedger.js +1012 -0
- package/dist/internal/BlobLedger.js.map +1 -0
- package/dist/internal/BlobMetadata.d.ts +109 -0
- package/dist/internal/BlobMetadata.d.ts.map +1 -0
- package/dist/internal/BlobMetadata.js +249 -0
- package/dist/internal/BlobMetadata.js.map +1 -0
- package/dist/internal/BlobResolver.d.ts +146 -0
- package/dist/internal/BlobResolver.d.ts.map +1 -0
- package/dist/internal/BlobResolver.js +417 -0
- package/dist/internal/BlobResolver.js.map +1 -0
- package/dist/internal/BlobStoreContract.d.ts +214 -0
- package/dist/internal/BlobStoreContract.d.ts.map +1 -0
- package/dist/internal/BlobStoreContract.js +181 -0
- package/dist/internal/BlobStoreContract.js.map +1 -0
- package/dist/internal/BoundCrud.d.ts +153 -53
- package/dist/internal/BoundCrud.d.ts.map +1 -1
- package/dist/internal/BoundCrud.js +27 -5
- package/dist/internal/BoundCrud.js.map +1 -1
- package/dist/internal/BoundQuery.d.ts +49 -33
- package/dist/internal/BoundQuery.d.ts.map +1 -1
- package/dist/internal/BoundQuery.js +8 -2
- package/dist/internal/BoundQuery.js.map +1 -1
- package/dist/internal/BoundVectorQuery.d.ts +59 -25
- package/dist/internal/BoundVectorQuery.d.ts.map +1 -1
- package/dist/internal/BoundVectorQuery.js +38 -17
- package/dist/internal/BoundVectorQuery.js.map +1 -1
- package/dist/internal/Capacity.d.ts +17 -2
- package/dist/internal/Capacity.d.ts.map +1 -1
- package/dist/internal/Capacity.js +47 -9
- package/dist/internal/Capacity.js.map +1 -1
- package/dist/internal/ConditionHolds.d.ts.map +1 -1
- package/dist/internal/ConditionHolds.js +2 -8
- package/dist/internal/ConditionHolds.js.map +1 -1
- package/dist/internal/CredentialRefusal.d.ts.map +1 -1
- package/dist/internal/CredentialRefusal.js +4 -0
- package/dist/internal/CredentialRefusal.js.map +1 -1
- package/dist/internal/Digest.d.ts +4 -3
- package/dist/internal/Digest.d.ts.map +1 -1
- package/dist/internal/Digest.js +25 -82
- package/dist/internal/Digest.js.map +1 -1
- package/dist/internal/EntityCombinators.d.ts +93 -45
- package/dist/internal/EntityCombinators.d.ts.map +1 -1
- package/dist/internal/EntityCombinators.js +42 -7
- package/dist/internal/EntityCombinators.js.map +1 -1
- package/dist/internal/EntityOps.d.ts +47 -6
- package/dist/internal/EntityOps.d.ts.map +1 -1
- package/dist/internal/EntityOps.js +30 -10
- package/dist/internal/EntityOps.js.map +1 -1
- package/dist/internal/EventProjection.d.ts +99 -25
- package/dist/internal/EventProjection.d.ts.map +1 -1
- package/dist/internal/EventProjection.js +124 -33
- package/dist/internal/EventProjection.js.map +1 -1
- package/dist/internal/ExpressionLimits.d.ts +22 -3
- package/dist/internal/ExpressionLimits.d.ts.map +1 -1
- package/dist/internal/ExpressionLimits.js +46 -7
- package/dist/internal/ExpressionLimits.js.map +1 -1
- package/dist/internal/GcSupport.d.ts +258 -0
- package/dist/internal/GcSupport.d.ts.map +1 -0
- package/dist/internal/GcSupport.js +284 -0
- package/dist/internal/GcSupport.js.map +1 -0
- package/dist/internal/ItemSize.d.ts +7 -1
- package/dist/internal/ItemSize.d.ts.map +1 -1
- package/dist/internal/ItemSize.js +13 -5
- package/dist/internal/ItemSize.js.map +1 -1
- package/dist/internal/MemoryBlobStore.d.ts +203 -0
- package/dist/internal/MemoryBlobStore.d.ts.map +1 -0
- package/dist/internal/MemoryBlobStore.js +623 -0
- package/dist/internal/MemoryBlobStore.js.map +1 -0
- package/dist/internal/MultiProjection.d.ts +56 -28
- package/dist/internal/MultiProjection.d.ts.map +1 -1
- package/dist/internal/MultiProjection.js +9 -3
- package/dist/internal/MultiProjection.js.map +1 -1
- package/dist/internal/Multipart.d.ts +96 -0
- package/dist/internal/Multipart.d.ts.map +1 -0
- package/dist/internal/Multipart.js +143 -0
- package/dist/internal/Multipart.js.map +1 -0
- package/dist/internal/OffloadChange.d.ts +187 -0
- package/dist/internal/OffloadChange.d.ts.map +1 -0
- package/dist/internal/OffloadChange.js +391 -0
- package/dist/internal/OffloadChange.js.map +1 -0
- package/dist/internal/OffloadInput.d.ts +141 -0
- package/dist/internal/OffloadInput.d.ts.map +1 -0
- package/dist/internal/OffloadInput.js +236 -0
- package/dist/internal/OffloadInput.js.map +1 -0
- package/dist/internal/OffloadRead.d.ts +140 -0
- package/dist/internal/OffloadRead.d.ts.map +1 -0
- package/dist/internal/OffloadRead.js +369 -0
- package/dist/internal/OffloadRead.js.map +1 -0
- package/dist/internal/OffloadTypes.d.ts +182 -0
- package/dist/internal/OffloadTypes.d.ts.map +1 -0
- package/dist/internal/OffloadTypes.js +15 -0
- package/dist/internal/OffloadTypes.js.map +1 -0
- package/dist/internal/OffloadValues.d.ts +87 -0
- package/dist/internal/OffloadValues.d.ts.map +1 -0
- package/dist/internal/OffloadValues.js +114 -0
- package/dist/internal/OffloadValues.js.map +1 -0
- package/dist/internal/OffloadWrite.d.ts +267 -0
- package/dist/internal/OffloadWrite.d.ts.map +1 -0
- package/dist/internal/OffloadWrite.js +766 -0
- package/dist/internal/OffloadWrite.js.map +1 -0
- package/dist/internal/Packed.d.ts +58 -23
- package/dist/internal/Packed.d.ts.map +1 -1
- package/dist/internal/Packed.js +108 -33
- package/dist/internal/Packed.js.map +1 -1
- package/dist/internal/ProjectionEngine.d.ts +28 -3
- package/dist/internal/ProjectionEngine.d.ts.map +1 -1
- package/dist/internal/ProjectionEngine.js +47 -9
- package/dist/internal/ProjectionEngine.js.map +1 -1
- package/dist/internal/RangePlanner.d.ts +3 -6
- package/dist/internal/RangePlanner.d.ts.map +1 -1
- package/dist/internal/RangePlanner.js +3 -29
- package/dist/internal/RangePlanner.js.map +1 -1
- package/dist/internal/Rekey.d.ts +16 -0
- package/dist/internal/Rekey.d.ts.map +1 -1
- package/dist/internal/Rekey.js +31 -2
- package/dist/internal/Rekey.js.map +1 -1
- package/dist/internal/StoredPointer.d.ts +19 -0
- package/dist/internal/StoredPointer.d.ts.map +1 -0
- package/dist/internal/StoredPointer.js +59 -0
- package/dist/internal/StoredPointer.js.map +1 -0
- package/dist/internal/TransactPlan.d.ts +18 -1
- package/dist/internal/TransactPlan.d.ts.map +1 -1
- package/dist/internal/TransactPlan.js +50 -10
- package/dist/internal/TransactPlan.js.map +1 -1
- package/dist/internal/TransactWriteOps.d.ts +33 -12
- package/dist/internal/TransactWriteOps.d.ts.map +1 -1
- package/dist/internal/TransactWriteOps.js +49 -19
- package/dist/internal/TransactWriteOps.js.map +1 -1
- package/dist/internal/TransactableOps.d.ts +58 -11
- package/dist/internal/TransactableOps.d.ts.map +1 -1
- package/dist/internal/TransactableOps.js +95 -19
- package/dist/internal/TransactableOps.js.map +1 -1
- package/dist/internal/Utf8Order.d.ts +21 -0
- package/dist/internal/Utf8Order.d.ts.map +1 -0
- package/dist/internal/Utf8Order.js +44 -0
- package/dist/internal/Utf8Order.js.map +1 -0
- package/dist/internal/WriteDiagnosis.d.ts +7 -1
- package/dist/internal/WriteDiagnosis.d.ts.map +1 -1
- package/dist/internal/WriteDiagnosis.js +12 -16
- package/dist/internal/WriteDiagnosis.js.map +1 -1
- package/package.json +15 -4
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal Write inputs of binary fields (#179, design §3.8, §7): what a
|
|
3
|
+
* `DynamoModel.External()` field takes on a write — a `Uint8Array`, a
|
|
4
|
+
* `Stream` of bytes, a `BlobHandle` (content to copy) or `Offload.source(...)`
|
|
5
|
+
* (bytes or a stream with upload options) — and how a write carries each one
|
|
6
|
+
* from its input to its upload.
|
|
7
|
+
*
|
|
8
|
+
* - **Placeholders.** Schema encoding, renames and request building handle a
|
|
9
|
+
* binary field's value as a `Uint8Array`. So {@link prepare} replaces every
|
|
10
|
+
* input that is not one with a fresh `Uint8Array` **placeholder**,
|
|
11
|
+
* registered (by identity) with what it stands for; the write path carries
|
|
12
|
+
* the placeholder to `OffloadWrite.route`, which uploads what it stands for
|
|
13
|
+
* ({@link preparedOf}). The bytes of an `Offload.source(bytes)` are the
|
|
14
|
+
* placeholder's own content (a copy), so the field's schema checks them
|
|
15
|
+
* like any other bytes; a stream's or a handle's placeholder is empty and
|
|
16
|
+
* **opaque** — the write path skips the field's schema for it
|
|
17
|
+
* ({@link opaqueFields}), as its content is not in hand before the upload.
|
|
18
|
+
* - **Single-use streams.** A placeholder stands for its stream; the upload
|
|
19
|
+
* ledger runs a given stream at most once, for one target object
|
|
20
|
+
* (`BlobLedger`, `[EDD-9120]`).
|
|
21
|
+
* - **Refusals.** {@link prepare} refuses, as a `ValidationError` naming
|
|
22
|
+
* `[EDD-9120]`, an input of the wrong shape for a binary field and a
|
|
23
|
+
* stream, handle, source or lazy value for an overflow field (which takes
|
|
24
|
+
* its domain value) — reachable only from untyped code.
|
|
25
|
+
*
|
|
26
|
+
* `prepare` is idempotent: a placeholder is kept as it is, so a write path
|
|
27
|
+
* that hands its prepared input to another (a guarded upsert's create, an
|
|
28
|
+
* update that creates its missing item) prepares nothing twice.
|
|
29
|
+
*
|
|
30
|
+
* Not part of the public API (`Offload.source`, `BinaryInput` and
|
|
31
|
+
* `BlobSource` are).
|
|
32
|
+
*/
|
|
33
|
+
import { ValidationError } from "@effect-dynamodb/schema/Errors.js";
|
|
34
|
+
import { MAX_CONTENT_TYPE_BYTES } from "@effect-dynamodb/schema/internal/BlobPointer.js";
|
|
35
|
+
import { Effect, Inspectable, Pipeable, Stream } from "effect";
|
|
36
|
+
import { isBlobHandle, isOffloadedValue } from "./OffloadValues.js";
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// BlobSource (public through Offload.ts)
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
export const BlobSourceTypeId = Symbol.for("effect-dynamodb/BlobSource");
|
|
41
|
+
const BlobSourceProto = Object.assign(Object.create(Inspectable.BaseProto), {
|
|
42
|
+
[BlobSourceTypeId]: BlobSourceTypeId,
|
|
43
|
+
pipe() {
|
|
44
|
+
return Pipeable.pipeArguments(this, arguments);
|
|
45
|
+
},
|
|
46
|
+
toJSON() {
|
|
47
|
+
return {
|
|
48
|
+
_id: "BlobSource",
|
|
49
|
+
body: this.body instanceof Uint8Array ? `Uint8Array(${this.body.length})` : "Stream",
|
|
50
|
+
contentType: this.contentType,
|
|
51
|
+
contentLength: this.contentLength,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* A binary field's value with upload options: its bytes or a stream of them,
|
|
57
|
+
* the object's content type, and the body's length when known. The options
|
|
58
|
+
* are checked when the write runs (`[EDD-9120]`).
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* db.entities.Documents.put({
|
|
63
|
+
* id,
|
|
64
|
+
* owner,
|
|
65
|
+
* scan: Offload.source(fileStream, { contentType: "image/png", contentLength: size }),
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export const source = (body, options) => Object.freeze(Object.assign(Object.create(BlobSourceProto), {
|
|
70
|
+
body,
|
|
71
|
+
contentType: options?.contentType,
|
|
72
|
+
contentLength: options?.contentLength,
|
|
73
|
+
}));
|
|
74
|
+
/** True iff `u` is a {@link BlobSource}. */
|
|
75
|
+
export const isBlobSource = (u) => typeof u === "object" && u !== null && BlobSourceTypeId in u;
|
|
76
|
+
const placeholders = new WeakMap();
|
|
77
|
+
/** What `value` stands for, when it is a placeholder {@link prepare} made. */
|
|
78
|
+
export const preparedOf = (value) => value instanceof Uint8Array ? placeholders.get(value) : undefined;
|
|
79
|
+
/** True iff `value` is an opaque placeholder (a stream's or a handle's). */
|
|
80
|
+
export const isOpaque = (value) => {
|
|
81
|
+
const prepared = preparedOf(value);
|
|
82
|
+
return prepared !== undefined && prepared._tag !== "Bytes";
|
|
83
|
+
};
|
|
84
|
+
const placeholder = (prepared, bytes) => {
|
|
85
|
+
const out = bytes === undefined ? new Uint8Array(0) : new Uint8Array(bytes);
|
|
86
|
+
placeholders.set(out, prepared);
|
|
87
|
+
return out;
|
|
88
|
+
};
|
|
89
|
+
/** The `[EDD-9120]` refusal of an offloaded field's write input. */
|
|
90
|
+
export const unusable = (entityType, operation, message) => new ValidationError({
|
|
91
|
+
entityType,
|
|
92
|
+
operation,
|
|
93
|
+
cause: new Error(`[EDD-9120] Entity "${entityType}": ${message}`),
|
|
94
|
+
});
|
|
95
|
+
const describe = (value) => value === null
|
|
96
|
+
? "null"
|
|
97
|
+
: Array.isArray(value)
|
|
98
|
+
? "an array"
|
|
99
|
+
: isOffloadedValue(value)
|
|
100
|
+
? "an OffloadedValue"
|
|
101
|
+
: typeof value === "object"
|
|
102
|
+
? `an object (${Object.prototype.toString.call(value).slice(8, -1)})`
|
|
103
|
+
: typeof value;
|
|
104
|
+
/** The rule of `DynamoModel.External({ contentType })`: printable US-ASCII (0x20–0x7e). */
|
|
105
|
+
const isPrintableAscii = (text) => {
|
|
106
|
+
for (let i = 0; i < text.length; i++) {
|
|
107
|
+
const code = text.charCodeAt(i);
|
|
108
|
+
if (code < 0x20 || code > 0x7e)
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
};
|
|
113
|
+
/** Why `options` of a source are unusable, or `undefined`. */
|
|
114
|
+
const sourceRefusal = (source) => {
|
|
115
|
+
const { body, contentType, contentLength } = source;
|
|
116
|
+
if (!(body instanceof Uint8Array) && !Stream.isStream(body)) {
|
|
117
|
+
return `Offload.source takes a Uint8Array or a Stream of bytes, got ${describe(body)}`;
|
|
118
|
+
}
|
|
119
|
+
if (contentType !== undefined &&
|
|
120
|
+
(typeof contentType !== "string" ||
|
|
121
|
+
contentType.length === 0 ||
|
|
122
|
+
contentType.length > MAX_CONTENT_TYPE_BYTES ||
|
|
123
|
+
!isPrintableAscii(contentType))) {
|
|
124
|
+
return (`Offload.source contentType must be a non-empty printable US-ASCII string of at most ` +
|
|
125
|
+
`${MAX_CONTENT_TYPE_BYTES} bytes, got ${JSON.stringify(contentType)}`);
|
|
126
|
+
}
|
|
127
|
+
if (contentLength !== undefined &&
|
|
128
|
+
(typeof contentLength !== "number" || !Number.isSafeInteger(contentLength) || contentLength < 0)) {
|
|
129
|
+
return `Offload.source contentLength must be a non-negative integer, got ${String(contentLength)}`;
|
|
130
|
+
}
|
|
131
|
+
if (body instanceof Uint8Array && contentLength !== undefined && contentLength !== body.length) {
|
|
132
|
+
return `Offload.source contentLength is ${contentLength}, but its bytes are ${body.length}`;
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
};
|
|
136
|
+
/** The placeholder of a binary field's input, `undefined` to keep it, or why it is unusable. */
|
|
137
|
+
const prepareBinary = (field, value) => {
|
|
138
|
+
if (value === undefined || value === null || value instanceof Uint8Array)
|
|
139
|
+
return undefined;
|
|
140
|
+
if (isBlobSource(value)) {
|
|
141
|
+
const refusal = sourceRefusal(value);
|
|
142
|
+
if (refusal !== undefined)
|
|
143
|
+
return `binary field "${field}": ${refusal}`;
|
|
144
|
+
return value.body instanceof Uint8Array
|
|
145
|
+
? placeholder({ _tag: "Bytes", contentType: value.contentType }, value.body)
|
|
146
|
+
: placeholder({
|
|
147
|
+
_tag: "Stream",
|
|
148
|
+
stream: value.body,
|
|
149
|
+
identity: value.body,
|
|
150
|
+
contentType: value.contentType,
|
|
151
|
+
contentLength: value.contentLength,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (Stream.isStream(value)) {
|
|
155
|
+
return placeholder({
|
|
156
|
+
_tag: "Stream",
|
|
157
|
+
stream: value,
|
|
158
|
+
identity: value,
|
|
159
|
+
contentType: undefined,
|
|
160
|
+
contentLength: undefined,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (isBlobHandle(value))
|
|
164
|
+
return placeholder({ _tag: "Handle", handle: value });
|
|
165
|
+
return (`binary field "${field}" takes a Uint8Array, a Stream of bytes, a BlobHandle or ` +
|
|
166
|
+
`Offload.source(...), got ${describe(value)}`);
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Replace every binary input of `record` that is not a `Uint8Array` with its
|
|
170
|
+
* placeholder, and refuse an unusable one (`[EDD-9120]`). `record` itself
|
|
171
|
+
* when nothing is replaced (a class instance keeps its prototype); a shallow
|
|
172
|
+
* copy otherwise.
|
|
173
|
+
*/
|
|
174
|
+
export const prepare = (record, fields, operation) => {
|
|
175
|
+
if (typeof record !== "object" || record === null)
|
|
176
|
+
return Effect.succeed(record);
|
|
177
|
+
const input = record;
|
|
178
|
+
let out;
|
|
179
|
+
for (const field of fields.overflow) {
|
|
180
|
+
const value = input[field];
|
|
181
|
+
if (Stream.isStream(value) || isBlobHandle(value) || isBlobSource(value)) {
|
|
182
|
+
return Effect.fail(unusable(fields.entityType, operation, `overflow field "${field}" takes its domain value, got ` +
|
|
183
|
+
(Stream.isStream(value)
|
|
184
|
+
? "a Stream"
|
|
185
|
+
: isBlobHandle(value)
|
|
186
|
+
? "a BlobHandle"
|
|
187
|
+
: "an Offload.source(...)") +
|
|
188
|
+
": only a binary (DynamoModel.External) field takes bytes from a stream, a handle " +
|
|
189
|
+
"or a source"));
|
|
190
|
+
}
|
|
191
|
+
if (isOffloadedValue(value)) {
|
|
192
|
+
return Effect.fail(unusable(fields.entityType, operation, `overflow field "${field}" takes its domain value, got an OffloadedValue (a lazy ` +
|
|
193
|
+
"read): read() it first, or read the item eagerly"));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
for (const field of fields.binary) {
|
|
197
|
+
const prepared = prepareBinary(field, input[field]);
|
|
198
|
+
if (prepared === undefined)
|
|
199
|
+
continue;
|
|
200
|
+
if (typeof prepared === "string") {
|
|
201
|
+
return Effect.fail(unusable(fields.entityType, operation, prepared));
|
|
202
|
+
}
|
|
203
|
+
out ??= { ...input };
|
|
204
|
+
out[field] = prepared;
|
|
205
|
+
}
|
|
206
|
+
return Effect.succeed(out ?? record);
|
|
207
|
+
};
|
|
208
|
+
/** The fields of `record` among `binary` that hold an opaque placeholder. */
|
|
209
|
+
export const opaqueFields = (record, binary) => {
|
|
210
|
+
if (typeof record !== "object" || record === null)
|
|
211
|
+
return [];
|
|
212
|
+
const input = record;
|
|
213
|
+
return binary.filter((field) => isOpaque(input[field]));
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* `encoded` (the schema encoding of a prepared `input`) with each
|
|
217
|
+
* `Offload.source(bytes)` placeholder's upload options kept on its encoded
|
|
218
|
+
* bytes, when the field's schema gave a new array for them.
|
|
219
|
+
*/
|
|
220
|
+
export const carry = (input, encoded, binary) => {
|
|
221
|
+
if (typeof input !== "object" || input === null)
|
|
222
|
+
return encoded;
|
|
223
|
+
if (typeof encoded !== "object" || encoded === null)
|
|
224
|
+
return encoded;
|
|
225
|
+
const from = input;
|
|
226
|
+
const to = encoded;
|
|
227
|
+
for (const field of binary) {
|
|
228
|
+
const prepared = preparedOf(from[field]);
|
|
229
|
+
const out = to[field];
|
|
230
|
+
if (prepared?._tag === "Bytes" && out instanceof Uint8Array && out !== from[field]) {
|
|
231
|
+
placeholders.set(out, prepared);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return encoded;
|
|
235
|
+
};
|
|
236
|
+
//# sourceMappingURL=OffloadInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OffloadInput.js","sourceRoot":"","sources":["../../src/internal/OffloadInput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAA;AACxF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC9D,OAAO,EAAmB,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAEpF,8EAA8E;AAC9E,yCAAyC;AACzC,8EAA8E;AAE9E,MAAM,CAAC,MAAM,gBAAgB,GAAkB,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AA+CvF,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CACnC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAA4B,EAC/D;IACE,CAAC,gBAAgB,CAAC,EAAE,gBAAoC;IACxD,IAAI;QACF,OAAO,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAChD,CAAC;IACD,MAAM;QACJ,OAAO;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AC,KAAK,CAAC,CAAA;QACrB,IAAI,QAAQ,EAAE,IAAI,KAAK,OAAO,IAAI,GAAG,YAAY,UAAU,IAAI,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACnF,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal The read side of offloaded values per member (#179, design §8):
|
|
3
|
+
* the read modes a decode runs under, and phase one of the two-phase decode —
|
|
4
|
+
* the unpack that turns each pointer a row holds into a placeholder, the
|
|
5
|
+
* batched resolution of those placeholders (`BlobResolver`), and the handle
|
|
6
|
+
* schemas a lazily read field decodes through.
|
|
7
|
+
*
|
|
8
|
+
* - **Modes.** A read's effective modes ({@link Modes}: overflow / binary,
|
|
9
|
+
* each `"eager"` or `"lazy"`) are set per builder (`.offloaded(m)`, parsed
|
|
10
|
+
* by {@link parseModes}, which throws `[EDD-9117]` for a mode the library
|
|
11
|
+
* cannot honour) and reach the decoders through {@link CurrentReadModes},
|
|
12
|
+
* which every operation of an offloading member provides. Default: overflow
|
|
13
|
+
* eager, binary lazy.
|
|
14
|
+
* - **Load** ({@link loadRows}): for a batch of unmarshalled, stored-name rows
|
|
15
|
+
* — a page, a batch response, one item — every packed or dispatch-eligible
|
|
16
|
+
* attribute is read by its stored form, a `B` json pointer becoming a
|
|
17
|
+
* placeholder; every attribute whose encoded side is bytes (`External` or
|
|
18
|
+
* not, §4.7) has its `~edbp:` text read as a bytes pointer; in lazy mode an
|
|
19
|
+
* offloaded value stored inline becomes an inline handle; then every
|
|
20
|
+
* placeholder of the batch resolves together. A pointer on an attribute the
|
|
21
|
+
* member no longer offloads (§4.7, switching off) resolves eagerly through
|
|
22
|
+
* the ambient store, a store failure being the `cause` of a
|
|
23
|
+
* `ValidationError`, so the member's error types stay honest. Loaded rows
|
|
24
|
+
* are remembered ({@link isPrepared}), so a decoder handed a row a query
|
|
25
|
+
* prefetched does not load it again.
|
|
26
|
+
* - **Schemas** ({@link lazyReadSchema}): a read schema with each lazily read
|
|
27
|
+
* field accepting its handle (`OffloadedValue` / `BlobHandle`).
|
|
28
|
+
*
|
|
29
|
+
* Not part of the public API.
|
|
30
|
+
*/
|
|
31
|
+
import type { BlobStoreError } from "@effect-dynamodb/schema/Errors.js";
|
|
32
|
+
import { ValidationError } from "@effect-dynamodb/schema/Errors.js";
|
|
33
|
+
import { Context, Effect, Schema, type Semaphore } from "effect";
|
|
34
|
+
import { DEFAULT_MODES, EAGER_MODES, LAZY_MODES, type Modes, type OffloadKind } from "./BlobResolver.js";
|
|
35
|
+
export { DEFAULT_MODES, EAGER_MODES, LAZY_MODES, type Modes };
|
|
36
|
+
/**
|
|
37
|
+
* The read modes the decoders of the running operation use. Every operation
|
|
38
|
+
* of an offloading member provides its own (the builder's, or the defaults),
|
|
39
|
+
* so an operation never inherits another's.
|
|
40
|
+
*/
|
|
41
|
+
export declare const CurrentReadModes: Context.Reference<Modes>;
|
|
42
|
+
/** The read modes in scope. */
|
|
43
|
+
export declare const currentModes: Effect.Effect<Modes>;
|
|
44
|
+
/** Run `effect` with `modes` as its read modes. */
|
|
45
|
+
export declare const withModes: <A, E, R>(effect: Effect.Effect<A, E, R>, modes: Modes) => Effect.Effect<A, E, R>;
|
|
46
|
+
/** The `[EDD-9117]` error of an offload mode the library cannot honour. */
|
|
47
|
+
export declare const modeError: (message: string) => Error;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve `.offloaded(mode)`'s argument over `base`: a string sets both
|
|
50
|
+
* kinds, an object overrides the kinds it names. Throws `[EDD-9117]` for an
|
|
51
|
+
* unknown mode string, key or value (reachable from untyped code only).
|
|
52
|
+
*/
|
|
53
|
+
export declare const parseModes: (mode: unknown, base: Modes, where: string) => Modes;
|
|
54
|
+
/**
|
|
55
|
+
* {@link parseModes} for an operation that takes `{ offloaded }` as an option
|
|
56
|
+
* (an Effect, which fails rather than throws): `undefined` gives `base`.
|
|
57
|
+
*/
|
|
58
|
+
export declare const parseModesOption: (mode: unknown, base: Modes, ctx: {
|
|
59
|
+
readonly entityType: string;
|
|
60
|
+
readonly operation: string;
|
|
61
|
+
}) => Modes | ValidationError;
|
|
62
|
+
/** The `[EDD-9117]` refusal of `.offloaded()` after `.filterBy()` (design §8.5). */
|
|
63
|
+
export declare const offloadedAfterFilterBy: (where: string) => Error;
|
|
64
|
+
/** How one member's stored rows are read. */
|
|
65
|
+
export interface ReadPlan {
|
|
66
|
+
readonly entityType: string;
|
|
67
|
+
/** Stored attributes read by their packed stored form (packed ∪ dispatch-eligible). */
|
|
68
|
+
readonly dispatch: ReadonlyArray<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Stored attributes whose encoded side is bytes, `External` or not: an `S`
|
|
71
|
+
* value there that starts with `~edbp:` is a bytes pointer (§4.7).
|
|
72
|
+
*/
|
|
73
|
+
readonly binary: ReadonlyArray<string>;
|
|
74
|
+
/** The member's offloaded attributes: stored name → kind. */
|
|
75
|
+
readonly offloaded: Readonly<Record<string, OffloadKind>>;
|
|
76
|
+
/** Stored name → domain field name (the attributes above). */
|
|
77
|
+
readonly fieldOf: Readonly<Record<string, string>>;
|
|
78
|
+
/** An `External` attribute's content type (inline handles carry it). */
|
|
79
|
+
readonly contentTypeOf: Readonly<Record<string, string>>;
|
|
80
|
+
/**
|
|
81
|
+
* Decode a lazily read overflow value's wire form through its field's
|
|
82
|
+
* schema — when `read()` is called (`operation` is the read's).
|
|
83
|
+
*/
|
|
84
|
+
readonly decodeField: (field: string, wire: unknown, operation: string) => Effect.Effect<unknown, ValidationError>;
|
|
85
|
+
}
|
|
86
|
+
/** True iff a plan has nothing to read by stored form: a native row is then final. */
|
|
87
|
+
export declare const isEmptyPlan: (plan: ReadPlan) => boolean;
|
|
88
|
+
/** The attributes a read of `plan` may rewrite (a projection naming none runs no hook). */
|
|
89
|
+
export declare const readAttributes: (plan: ReadPlan) => ReadonlyArray<string>;
|
|
90
|
+
/** What a load is for. */
|
|
91
|
+
export interface LoadOptions {
|
|
92
|
+
/** The operation errors name; a lazy value's reads name `<operation>.read`. */
|
|
93
|
+
readonly operation: string;
|
|
94
|
+
readonly modes: Modes;
|
|
95
|
+
/**
|
|
96
|
+
* A raw projection or a raw-mode read: values stay their JSON wire form (a
|
|
97
|
+
* lazy overflow value's `read()` returns it, not the field's domain value).
|
|
98
|
+
*/
|
|
99
|
+
readonly raw?: boolean | undefined;
|
|
100
|
+
/** The rows are a committed write's result (a store failure says so, §6.13). */
|
|
101
|
+
readonly committed?: boolean | undefined;
|
|
102
|
+
/** Unmarshalled stream images: a `B` value may be base64 text. */
|
|
103
|
+
readonly image?: boolean | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* No store I/O (an error payload, §6.13): offloaded fields read lazily
|
|
106
|
+
* whatever `modes` say, and a pointer on an attribute the member no longer
|
|
107
|
+
* offloads (which would need a fetch) fails the load.
|
|
108
|
+
*/
|
|
109
|
+
readonly noFetch?: boolean | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Store-read permits shared with the operation's other loads running at the
|
|
112
|
+
* same time (`BlobResolver.ResolveOptions.permits`): `GeoIndex.nearby`'s
|
|
113
|
+
* parallel cell queries share one pool of the store's `readConcurrency`.
|
|
114
|
+
*/
|
|
115
|
+
readonly permits?: Semaphore.Semaphore | undefined;
|
|
116
|
+
}
|
|
117
|
+
/** True iff `row` was already loaded (by a query's page prefetch). */
|
|
118
|
+
export declare const isPrepared: (row: object) => boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Unpack and resolve, in place, every row of `rows` per `plan` (see the
|
|
121
|
+
* module header): afterwards each offloaded attribute holds its value — the
|
|
122
|
+
* JSON wire form (overflow), the bytes (binary) — or, in lazy mode, its
|
|
123
|
+
* handle, and every packed attribute its JSON wire form. Rows already loaded
|
|
124
|
+
* are skipped. A row without a stored-form value costs one `typeof` per
|
|
125
|
+
* attribute of the plan.
|
|
126
|
+
*/
|
|
127
|
+
export declare const loadRows: (plan: ReadPlan, rows: ReadonlyArray<Record<string, unknown>>, options: LoadOptions) => Effect.Effect<void, ValidationError | BlobStoreError>;
|
|
128
|
+
/**
|
|
129
|
+
* `base` (a read schema: a `Schema.Struct` keyed by domain names) with each
|
|
130
|
+
* field of `lazy` accepting its handle — a lazily read field holds one
|
|
131
|
+
* whenever it holds a value (`null` / `undefined` decode as before). `base`
|
|
132
|
+
* itself when no field is lazy.
|
|
133
|
+
*/
|
|
134
|
+
export declare const lazyReadSchema: (base: Schema.Codec<any>, lazy: ReadonlyArray<readonly [field: string, kind: OffloadKind]>) => Schema.Codec<any>;
|
|
135
|
+
/** The fields of `byKind` read lazily under `modes`. */
|
|
136
|
+
export declare const lazyFields: (byKind: {
|
|
137
|
+
readonly overflow: ReadonlyArray<string>;
|
|
138
|
+
readonly binary: ReadonlyArray<string>;
|
|
139
|
+
}, modes: Modes) => ReadonlyArray<readonly [string, OffloadKind]>;
|
|
140
|
+
//# sourceMappingURL=OffloadRead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OffloadRead.d.ts","sourceRoot":"","sources":["../../src/internal/OffloadRead.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AASnE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEhE,OAAO,EACL,aAAa,EACb,WAAW,EAGX,UAAU,EACV,KAAK,KAAK,EAEV,KAAK,WAAW,EAGjB,MAAM,mBAAmB,CAAA;AAK1B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,KAAK,EAAE,CAAA;AAM7D;;;;GA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