effect-dynamodb 1.39.0 → 1.41.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/README.md +1 -1
- package/dist/Aggregate.d.ts +138 -16
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js +4298 -725
- package/dist/Aggregate.js.map +1 -1
- package/dist/Batch.d.ts +9 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +28 -44
- package/dist/Batch.js.map +1 -1
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +16 -9
- package/dist/Collection.js.map +1 -1
- package/dist/ConsumedCapacity.js +1 -1
- package/dist/ConsumedCapacity.js.map +1 -1
- package/dist/DynamoClient.d.ts +44 -21
- package/dist/DynamoClient.d.ts.map +1 -1
- package/dist/DynamoClient.js +342 -124
- package/dist/DynamoClient.js.map +1 -1
- package/dist/Entity.d.ts +246 -41
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +6818 -1166
- package/dist/Entity.js.map +1 -1
- package/dist/EventStore.d.ts +37 -15
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +403 -163
- package/dist/EventStore.js.map +1 -1
- package/dist/Expression.d.ts.map +1 -1
- package/dist/Expression.js +40 -24
- package/dist/Expression.js.map +1 -1
- package/dist/Marshaller.d.ts +72 -11
- package/dist/Marshaller.d.ts.map +1 -1
- package/dist/Marshaller.js +625 -71
- package/dist/Marshaller.js.map +1 -1
- package/dist/Query.d.ts +103 -5
- package/dist/Query.d.ts.map +1 -1
- package/dist/Query.js +262 -15
- package/dist/Query.js.map +1 -1
- package/dist/StorageEncoding.d.ts +7 -1
- package/dist/StorageEncoding.d.ts.map +1 -1
- package/dist/StorageEncoding.js +8 -2
- package/dist/StorageEncoding.js.map +1 -1
- package/dist/Table.d.ts +338 -16
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +30 -2
- package/dist/Table.js.map +1 -1
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +70 -7
- package/dist/Transaction.js.map +1 -1
- package/dist/VectorSearchEmulation.d.ts.map +1 -1
- package/dist/VectorSearchEmulation.js +4 -3
- package/dist/VectorSearchEmulation.js.map +1 -1
- package/dist/change-feed/ChangeFeed.d.ts +8 -3
- package/dist/change-feed/ChangeFeed.d.ts.map +1 -1
- package/dist/change-feed/ChangeFeed.js +76 -9
- package/dist/change-feed/ChangeFeed.js.map +1 -1
- package/dist/change-feed/CheckpointStore.js +1 -1
- package/dist/change-feed/CheckpointStore.js.map +1 -1
- package/dist/change-feed/DynamoStreamsClient.d.ts +19 -10
- package/dist/change-feed/DynamoStreamsClient.d.ts.map +1 -1
- package/dist/change-feed/DynamoStreamsClient.js +24 -14
- package/dist/change-feed/DynamoStreamsClient.js.map +1 -1
- package/dist/index.d.ts +2 -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/BoundCrud.d.ts +78 -32
- package/dist/internal/BoundCrud.d.ts.map +1 -1
- package/dist/internal/BoundCrud.js +25 -0
- package/dist/internal/BoundCrud.js.map +1 -1
- package/dist/internal/BoundQuery.d.ts +46 -3
- package/dist/internal/BoundQuery.d.ts.map +1 -1
- package/dist/internal/BoundQuery.js +402 -37
- package/dist/internal/BoundQuery.js.map +1 -1
- package/dist/internal/BoundVectorQuery.d.ts +6 -0
- package/dist/internal/BoundVectorQuery.d.ts.map +1 -1
- package/dist/internal/BoundVectorQuery.js +7 -4
- package/dist/internal/BoundVectorQuery.js.map +1 -1
- package/dist/internal/Capacity.d.ts +46 -5
- package/dist/internal/Capacity.d.ts.map +1 -1
- package/dist/internal/Capacity.js +177 -26
- package/dist/internal/Capacity.js.map +1 -1
- package/dist/internal/ClientOptions.d.ts +144 -0
- package/dist/internal/ClientOptions.d.ts.map +1 -0
- package/dist/internal/ClientOptions.js +290 -0
- package/dist/internal/ClientOptions.js.map +1 -0
- package/dist/internal/ConditionHolds.d.ts +29 -0
- package/dist/internal/ConditionHolds.d.ts.map +1 -0
- package/dist/internal/ConditionHolds.js +453 -0
- package/dist/internal/ConditionHolds.js.map +1 -0
- package/dist/internal/Cursor.d.ts +19 -10
- package/dist/internal/Cursor.d.ts.map +1 -1
- package/dist/internal/Cursor.js +25 -10
- package/dist/internal/Cursor.js.map +1 -1
- package/dist/internal/Digest.d.ts +20 -0
- package/dist/internal/Digest.d.ts.map +1 -0
- package/dist/internal/Digest.js +106 -0
- package/dist/internal/Digest.js.map +1 -0
- package/dist/internal/DynamoArithmetic.d.ts +33 -0
- package/dist/internal/DynamoArithmetic.d.ts.map +1 -0
- package/dist/internal/DynamoArithmetic.js +112 -0
- package/dist/internal/DynamoArithmetic.js.map +1 -0
- package/dist/internal/EntityCombinators.d.ts +23 -8
- package/dist/internal/EntityCombinators.d.ts.map +1 -1
- package/dist/internal/EntityCombinators.js +6 -2
- package/dist/internal/EntityCombinators.js.map +1 -1
- package/dist/internal/EntityOps.d.ts +69 -8
- package/dist/internal/EntityOps.d.ts.map +1 -1
- package/dist/internal/EntityOps.js.map +1 -1
- package/dist/internal/EventProjection.d.ts +18 -4
- package/dist/internal/EventProjection.d.ts.map +1 -1
- package/dist/internal/EventProjection.js +36 -8
- package/dist/internal/EventProjection.js.map +1 -1
- package/dist/internal/Expr.d.ts +72 -2
- package/dist/internal/Expr.d.ts.map +1 -1
- package/dist/internal/Expr.js +264 -5
- package/dist/internal/Expr.js.map +1 -1
- package/dist/internal/ExpressionLimits.d.ts +57 -1
- package/dist/internal/ExpressionLimits.d.ts.map +1 -1
- package/dist/internal/ExpressionLimits.js +97 -4
- package/dist/internal/ExpressionLimits.js.map +1 -1
- package/dist/internal/FormGuard.d.ts +52 -0
- package/dist/internal/FormGuard.d.ts.map +1 -0
- package/dist/internal/FormGuard.js +83 -0
- package/dist/internal/FormGuard.js.map +1 -0
- package/dist/internal/Hydrate.d.ts.map +1 -1
- package/dist/internal/Hydrate.js +2 -1
- package/dist/internal/Hydrate.js.map +1 -1
- package/dist/internal/InputForm.d.ts +24 -0
- package/dist/internal/InputForm.d.ts.map +1 -0
- package/dist/internal/InputForm.js +44 -0
- package/dist/internal/InputForm.js.map +1 -0
- package/dist/internal/InsertStatement.d.ts +15 -0
- package/dist/internal/InsertStatement.d.ts.map +1 -0
- package/dist/internal/InsertStatement.js +18 -0
- package/dist/internal/InsertStatement.js.map +1 -0
- package/dist/internal/ItemSize.d.ts +108 -4
- package/dist/internal/ItemSize.d.ts.map +1 -1
- package/dist/internal/ItemSize.js +190 -3
- package/dist/internal/ItemSize.js.map +1 -1
- package/dist/internal/MultiProjection.d.ts +7 -2
- package/dist/internal/MultiProjection.d.ts.map +1 -1
- package/dist/internal/MultiProjection.js +18 -12
- package/dist/internal/MultiProjection.js.map +1 -1
- package/dist/internal/OperandReaders.d.ts +36 -0
- package/dist/internal/OperandReaders.d.ts.map +1 -0
- package/dist/internal/OperandReaders.js +176 -0
- package/dist/internal/OperandReaders.js.map +1 -0
- package/dist/internal/Packed.d.ts.map +1 -1
- package/dist/internal/Packed.js +11 -10
- package/dist/internal/Packed.js.map +1 -1
- package/dist/internal/PathBuilder.d.ts +57 -8
- package/dist/internal/PathBuilder.d.ts.map +1 -1
- package/dist/internal/PathBuilder.js +98 -24
- package/dist/internal/PathBuilder.js.map +1 -1
- package/dist/internal/ProjectionEngine.d.ts +196 -3
- package/dist/internal/ProjectionEngine.d.ts.map +1 -1
- package/dist/internal/ProjectionEngine.js +1251 -86
- package/dist/internal/ProjectionEngine.js.map +1 -1
- package/dist/internal/Rekey.d.ts +187 -21
- package/dist/internal/Rekey.d.ts.map +1 -1
- package/dist/internal/Rekey.js +1349 -63
- package/dist/internal/Rekey.js.map +1 -1
- package/dist/internal/ReturnedItem.d.ts +23 -0
- package/dist/internal/ReturnedItem.d.ts.map +1 -0
- package/dist/internal/ReturnedItem.js +39 -0
- package/dist/internal/ReturnedItem.js.map +1 -0
- package/dist/internal/RoundTrip.d.ts +45 -0
- package/dist/internal/RoundTrip.d.ts.map +1 -0
- package/dist/internal/RoundTrip.js +106 -0
- package/dist/internal/RoundTrip.js.map +1 -0
- package/dist/internal/SentRequest.d.ts +14 -0
- package/dist/internal/SentRequest.d.ts.map +1 -0
- package/dist/internal/SentRequest.js +31 -0
- package/dist/internal/SentRequest.js.map +1 -0
- package/dist/internal/TransactPlan.d.ts.map +1 -1
- package/dist/internal/TransactPlan.js +4 -0
- package/dist/internal/TransactPlan.js.map +1 -1
- package/dist/internal/TransactWriteOps.d.ts +70 -15
- package/dist/internal/TransactWriteOps.d.ts.map +1 -1
- package/dist/internal/TransactWriteOps.js +166 -112
- package/dist/internal/TransactWriteOps.js.map +1 -1
- package/dist/internal/TransactableOps.d.ts +230 -27
- package/dist/internal/TransactableOps.d.ts.map +1 -1
- package/dist/internal/TransactableOps.js +549 -92
- package/dist/internal/TransactableOps.js.map +1 -1
- package/dist/internal/WriteDiagnosis.d.ts +66 -3
- package/dist/internal/WriteDiagnosis.d.ts.map +1 -1
- package/dist/internal/WriteDiagnosis.js +261 -15
- package/dist/internal/WriteDiagnosis.js.map +1 -1
- package/package.json +5 -5
package/dist/DynamoClient.js
CHANGED
|
@@ -7,29 +7,33 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
import { BatchGetItemCommand, BatchWriteItemCommand, CreateBackupCommand, CreateTableCommand, DeleteBackupCommand, DeleteItemCommand, DeleteTableCommand, DescribeContinuousBackupsCommand, DescribeExportCommand, DescribeTableCommand, DescribeTimeToLiveCommand, DynamoDBClient, ExportTableToPointInTimeCommand, GetItemCommand, ListBackupsCommand, ListTablesCommand, ListTagsOfResourceCommand, PutItemCommand, QueryCommand, RestoreTableFromBackupCommand, RestoreTableToPointInTimeCommand, ScanCommand, SearchVectorsCommand, TagResourceCommand, TransactGetItemsCommand, TransactWriteItemsCommand, UntagResourceCommand, UpdateContinuousBackupsCommand, UpdateItemCommand, UpdateTableCommand, UpdateTimeToLiveCommand, } from "@aws-sdk/client-dynamodb";
|
|
10
|
+
import { BatchGetItemCommand, BatchWriteItemCommand, CreateBackupCommand, CreateTableCommand, DeleteBackupCommand, DeleteItemCommand, DeleteTableCommand, DescribeContinuousBackupsCommand, DescribeExportCommand, DescribeTableCommand, DescribeTimeToLiveCommand, DynamoDBClient, ExecuteStatementCommand, ExecuteTransactionCommand, ExportTableToPointInTimeCommand, GetItemCommand, ListBackupsCommand, ListTablesCommand, ListTagsOfResourceCommand, PutItemCommand, QueryCommand, RestoreTableFromBackupCommand, RestoreTableToPointInTimeCommand, ScanCommand, SearchVectorsCommand, TagResourceCommand, TransactGetItemsCommand, TransactWriteItemsCommand, UntagResourceCommand, UpdateContinuousBackupsCommand, UpdateItemCommand, UpdateTableCommand, UpdateTimeToLiveCommand, } from "@aws-sdk/client-dynamodb";
|
|
11
11
|
import { Compression, make as makeCompressionRegistry, } from "@effect-dynamodb/schema/Compression.js";
|
|
12
12
|
import * as DynamoSchema from "@effect-dynamodb/schema/DynamoSchema.js";
|
|
13
13
|
import { Embedder } from "@effect-dynamodb/schema/Embedder.js";
|
|
14
14
|
import { DynamoError, DynamoValidationError, InternalServerError, isAwsInternalServerError, isAwsResourceNotFound, isAwsThrottling, isAwsValidationError, ResourceNotFoundError, ThrottlingError, ValidationError, } from "@effect-dynamodb/schema/Errors.js";
|
|
15
|
-
import { compositeKeyFormKind, keyFormValueKind, makeCompositeKeyForm, toCompositeKeyRecord, } from "@effect-dynamodb/schema/internal/CompositeCodec.js";
|
|
15
|
+
import { compositeKeyFormKind, keyFormValueKind, keyFormValueKindOf, makeCompositeDomainKeyForm, makeCompositeKeyForm, refuseInexact, toCompositeKeyRecord, } from "@effect-dynamodb/schema/internal/CompositeCodec.js";
|
|
16
16
|
import { makeDefaultCrypto } from "@effect-dynamodb/schema/internal/DefaultCrypto.js";
|
|
17
|
+
import { given, ownValue, setOwn } from "@effect-dynamodb/schema/internal/OwnNames.js";
|
|
17
18
|
import { getSchemaFields } from "@effect-dynamodb/schema/internal/SchemaAccessors.js";
|
|
18
19
|
import * as ZOrderCurve from "@effect-dynamodb/schema/internal/ZOrderCurve.js";
|
|
19
20
|
import * as KeyComposer from "@effect-dynamodb/schema/KeyComposer.js";
|
|
20
21
|
import { Config, Context, DateTime, Duration, Effect, Layer, Option, SchemaAST, } from "effect";
|
|
21
22
|
import { SecureRandom } from "effect/crypto";
|
|
22
|
-
import { bind as aggregateBind } from "./Aggregate.js";
|
|
23
|
-
import { bind as entityBind, fromDefinition as entityFromDefinition } from "./Entity.js";
|
|
24
|
-
import { BoundQueryImpl, collectionNaming, entityNaming, } from "./internal/BoundQuery.js";
|
|
23
|
+
import { bind as aggregateBind, ownershipConflict } from "./Aggregate.js";
|
|
24
|
+
import { bind as entityBind, fromDefinition as entityFromDefinition, storedRefIdOf, } from "./Entity.js";
|
|
25
|
+
import { BoundQueryImpl, collectionNaming, entityNaming, wholeRowsOf, } from "./internal/BoundQuery.js";
|
|
25
26
|
import { makeBoundVectorQuery, } from "./internal/BoundVectorQuery.js";
|
|
26
27
|
import * as Capacity from "./internal/Capacity.js";
|
|
28
|
+
import { acquireSdkClient, readClientOptions, readCredentials, sdkCredentials, } from "./internal/ClientOptions.js";
|
|
27
29
|
import { redactCredentialRefusal } from "./internal/CredentialRefusal.js";
|
|
28
30
|
import { createConditionOps, ExprTag } from "./internal/Expr.js";
|
|
29
31
|
import { codecRequirements, collectionPackedQueryOptions, entityPackedQueryOptions, unregisteredCodecError, } from "./internal/Packed.js";
|
|
30
|
-
import {
|
|
32
|
+
import { pathBuilderOf } from "./internal/PathBuilder.js";
|
|
33
|
+
import { physicalTableName, refuseSharedOutboxKeySpace, rekeyOutboxMember, remoteOutboxesOf, sharedOutboxKeySpace, } from "./internal/ProjectionEngine.js";
|
|
31
34
|
import { canonicalJson, compareUtf8, compositePlanner, keyJustBelow, zorderPlanner, } from "./internal/RangePlanner.js";
|
|
32
35
|
import * as Rekey from "./internal/Rekey.js";
|
|
36
|
+
import { hideReturnedItems } from "./internal/ReturnedItem.js";
|
|
33
37
|
import { diagnoseFailure, explainDiagnosis, withCause, } from "./internal/WriteDiagnosis.js";
|
|
34
38
|
import * as Query from "./Query.js";
|
|
35
39
|
import { mergeVectorIndexes, definition as tableDefinition, toVectorIndexSpec } from "./Table.js";
|
|
@@ -238,21 +242,35 @@ const BOUND_OPERATORS = new Set(["eq", "between", "gt", "gte", "lt", "lte"]);
|
|
|
238
242
|
* inside the stored ref, which is the value the key was composed from —
|
|
239
243
|
* through the accessor's encoder for a numeric field stored as a string, so a
|
|
240
244
|
* stored `"950000"` reads as `950000`. `undefined` when the row lacks it.
|
|
245
|
+
*
|
|
246
|
+
* A stored ref holds its id in the referenced entity's stored form, which is
|
|
247
|
+
* not always the form the key was composed from (a date key stored as epoch
|
|
248
|
+
* milliseconds, keyed as its ISO text): read as a value of that entity's key
|
|
249
|
+
* (`storedRefIdOf`), then keyed as a caller's value is (#241). Up to 1.40.0 it
|
|
250
|
+
* was compared as stored, and a bound on such an id matched no row.
|
|
241
251
|
*/
|
|
242
252
|
const storedKeyForm = (args, field) => {
|
|
243
253
|
const resolve = args.entityLike._resolveDbName ?? ((name) => name);
|
|
244
254
|
const ref = args.entityLike._resolvedRefs?.find((r) => r.idFieldName === field);
|
|
245
255
|
const attribute = resolve(ref?.fieldName ?? field);
|
|
246
|
-
const schema = getSchemaFields(args.encoderSource)
|
|
256
|
+
const schema = ownValue(getSchemaFields(args.encoderSource), field);
|
|
247
257
|
const wantsBigInt = schema !== undefined && SchemaAST.isBigInt(SchemaAST.toType(schema.ast));
|
|
248
258
|
const typeNumeric = compositeKeyFormKind(args.encoderSource, field) === "type-numeric";
|
|
249
259
|
return {
|
|
250
260
|
attribute,
|
|
251
261
|
read: (row) => {
|
|
252
|
-
const value = ref === undefined
|
|
262
|
+
const value = ref === undefined
|
|
263
|
+
? ownValue(row, attribute)
|
|
264
|
+
: ownValue(ownValue(row, attribute)?.M, ref.keyField);
|
|
253
265
|
if (value === undefined)
|
|
254
266
|
return undefined;
|
|
255
267
|
const stored = value.S ?? value.N;
|
|
268
|
+
if (ref !== undefined && stored !== undefined) {
|
|
269
|
+
const held = value.S ?? (wantsBigInt ? BigInt(value.N) : Number(value.N));
|
|
270
|
+
const id = storedRefIdOf(ref, held);
|
|
271
|
+
if (Option.isSome(id))
|
|
272
|
+
return args.domainKeyForm(field, id.value);
|
|
273
|
+
}
|
|
256
274
|
if (typeNumeric && stored !== undefined)
|
|
257
275
|
return args.compositeKeyForm(field, stored);
|
|
258
276
|
if (value.S !== undefined)
|
|
@@ -303,10 +321,10 @@ const combineRowChecks = (checks) => checks.length === 0
|
|
|
303
321
|
* nothing: the query is returned as it is.
|
|
304
322
|
*/
|
|
305
323
|
const planCompositeWithin = (args) => {
|
|
306
|
-
const { entityLike, accessor, indexDef,
|
|
324
|
+
const { entityLike, accessor, indexDef, domainKeyForm, pinnedKeyForm } = args;
|
|
307
325
|
const sk = indexDef.sk.composite;
|
|
308
326
|
const n = sk.length;
|
|
309
|
-
const p = sk.findIndex((attr) => pinnedKeyForm
|
|
327
|
+
const p = sk.findIndex((attr) => given(pinnedKeyForm, attr) === undefined);
|
|
310
328
|
const pinnedCount = p === -1 ? n : p;
|
|
311
329
|
const refuse = (why) => {
|
|
312
330
|
throw new Error(`[EDD-9093] .within() on index "${accessor}" of entity "${entityLike.entityType}": ${why}`);
|
|
@@ -320,7 +338,7 @@ const planCompositeWithin = (args) => {
|
|
|
320
338
|
const refOf = (field) => entityLike._resolvedRefs?.find((ref) => ref.idFieldName === field);
|
|
321
339
|
/** The kind of value a composite's key form is, when its schema says (EDD-9093's type check). */
|
|
322
340
|
const kindOf = (field) => {
|
|
323
|
-
const schema = fields
|
|
341
|
+
const schema = ownValue(fields, field);
|
|
324
342
|
return schema === undefined ? undefined : keyFormValueKind(schema);
|
|
325
343
|
};
|
|
326
344
|
// -- validate and normalise (EDD-9093) --
|
|
@@ -360,8 +378,8 @@ const planCompositeWithin = (args) => {
|
|
|
360
378
|
}
|
|
361
379
|
const expected = kindOf(field);
|
|
362
380
|
const keyForm = (value) => {
|
|
363
|
-
const converted =
|
|
364
|
-
if (expected !== undefined &&
|
|
381
|
+
const converted = domainKeyForm(field, value);
|
|
382
|
+
if (expected !== undefined && keyFormValueKindOf(converted) !== expected) {
|
|
365
383
|
return refuse(`the bound on "${field}" is ${JSON.stringify(String(value))} (${typeof value}), but ` +
|
|
366
384
|
`the composite's key form is a ${expected}.`);
|
|
367
385
|
}
|
|
@@ -641,13 +659,14 @@ const withinEnds = (value, lower, upper, compare) => {
|
|
|
641
659
|
* where it doesn't (numbers stored as strings, zoned dates, a `literals`
|
|
642
660
|
* selection too large for `IN`) and for hashed prefix values (collisions).
|
|
643
661
|
*
|
|
644
|
-
* Throws `[EDD-9093]` for misuse from untyped code
|
|
645
|
-
* that doesn't reach key form
|
|
646
|
-
*
|
|
647
|
-
*
|
|
662
|
+
* Throws `[EDD-9093]` for misuse from untyped code and `[EDD-9050]` for a value
|
|
663
|
+
* that doesn't reach key form, at `.within()`, so every terminal (and `explain`)
|
|
664
|
+
* has a valid box. A value no level holds throws `ZOrderValueError` (`[EDD-9092]`),
|
|
665
|
+
* which `.within()` turns into the query's `ValidationError`. `{}` plans nothing:
|
|
666
|
+
* the query is returned as it is.
|
|
648
667
|
*/
|
|
649
668
|
const planZOrderWithin = (args) => {
|
|
650
|
-
const { entityLike, accessor, indexDef,
|
|
669
|
+
const { entityLike, accessor, indexDef, domainKeyForm } = args;
|
|
651
670
|
const refuse = (why) => {
|
|
652
671
|
throw new Error(`[EDD-9093] .within() on index "${accessor}" of entity "${entityLike.entityType}": ${why}`);
|
|
653
672
|
};
|
|
@@ -664,10 +683,10 @@ const planZOrderWithin = (args) => {
|
|
|
664
683
|
const fields = getSchemaFields(args.encoderSource);
|
|
665
684
|
/** `value` in the field's key form: `[EDD-9050]` from the encoder, `[EDD-9093]` for the wrong type. */
|
|
666
685
|
const keyForm = (field, value) => {
|
|
667
|
-
const converted =
|
|
668
|
-
const schema = fields
|
|
686
|
+
const converted = domainKeyForm(field, value);
|
|
687
|
+
const schema = ownValue(fields, field);
|
|
669
688
|
const expected = schema === undefined ? undefined : keyFormValueKind(schema);
|
|
670
|
-
if (expected !== undefined &&
|
|
689
|
+
if (expected !== undefined && keyFormValueKindOf(converted) !== expected) {
|
|
671
690
|
return refuse(`the bound on "${field}" is ${JSON.stringify(String(value))} (${typeof value}), but ` +
|
|
672
691
|
`the field's key form is a ${expected}.`);
|
|
673
692
|
}
|
|
@@ -802,22 +821,14 @@ const planZOrderWithin = (args) => {
|
|
|
802
821
|
return Array.from({ length: Math.max(0, hi - lo + 1) }, (_, i) => lo + i);
|
|
803
822
|
};
|
|
804
823
|
const { box, selections } = (() => {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
return { box: none ? "empty" : quantized, selections: selected };
|
|
814
|
-
}
|
|
815
|
-
catch (error) {
|
|
816
|
-
// A value that reaches key form but no level (§3.3): thrown, like EDD-9050.
|
|
817
|
-
if (ZOrderCurve.isZOrderValueError(error))
|
|
818
|
-
throw new Error(error.message);
|
|
819
|
-
throw error;
|
|
820
|
-
}
|
|
824
|
+
const quantized = ZOrderCurve.quantizeBounds(layout, Object.fromEntries(dimensions
|
|
825
|
+
.filter((dim) => bounded.has(dim.field))
|
|
826
|
+
.map((dim) => [dim.field, quantizable(dim)])));
|
|
827
|
+
const selected = new Map(dimensions
|
|
828
|
+
.filter((dim) => dim.spec.kind === "literals" && bounded.has(dim.field))
|
|
829
|
+
.map((dim) => [dim.field, literalSelection(dim, bounded.get(dim.field).keyForm)]));
|
|
830
|
+
const none = [...selected.values()].some((members) => members.length === 0);
|
|
831
|
+
return { box: none ? "empty" : quantized, selections: selected };
|
|
821
832
|
})();
|
|
822
833
|
// -- exact bounds (§11): a FilterExpression where DynamoDB's order agrees, else row checks --
|
|
823
834
|
const path = (field) => ({ _tag: "path", segments: [field] });
|
|
@@ -949,7 +960,7 @@ const planZOrderWithin = (args) => {
|
|
|
949
960
|
const later = firstMissing === -1 ? [] : prefix.slice(firstMissing);
|
|
950
961
|
const hashed = prefix.filter((part) => part.hash !== undefined && prefixValues.has(part.field));
|
|
951
962
|
const parsedExactly = later.filter((part) => part.hash === undefined && prefixValues.has(part.field));
|
|
952
|
-
const renameExpr = entityNaming(entityLike._resolveDbName).renameExpr ?? ((expr) => expr);
|
|
963
|
+
const renameExpr = entityNaming(entityLike._resolveDbName, undefined, wholeRowsOf(entityLike), entityLike._storedBelow).renameExpr ?? ((expr) => expr);
|
|
953
964
|
const filter = filters.length === 0
|
|
954
965
|
? undefined
|
|
955
966
|
: renameExpr(filters.length === 1
|
|
@@ -996,18 +1007,21 @@ const planZOrderWithin = (args) => {
|
|
|
996
1007
|
});
|
|
997
1008
|
};
|
|
998
1009
|
/**
|
|
999
|
-
* The
|
|
1000
|
-
* `
|
|
1010
|
+
* The key form of a caller's DOMAIN record for an arbitrary entity-like value —
|
|
1011
|
+
* the key `put` wrote for those values (`internal/CompositeCodec.ts`,
|
|
1012
|
+
* `makeCompositeDomainKeyForm`), as `Entity._domainKeyForm` composes it.
|
|
1001
1013
|
*/
|
|
1002
|
-
const
|
|
1014
|
+
const entityDomainKeyForm = (entityLike, record, needs) => {
|
|
1003
1015
|
const source = (entityLike.schemas?.inputSchema ?? entityLike.model);
|
|
1004
1016
|
if (source === undefined)
|
|
1005
1017
|
return record;
|
|
1006
|
-
const form =
|
|
1018
|
+
const form = makeCompositeDomainKeyForm(source, (attr, value, reason) => {
|
|
1019
|
+
if (reason !== undefined)
|
|
1020
|
+
return refuseInexact(`Composite "${attr}"`, value, reason);
|
|
1007
1021
|
throw new Error(`[EDD-9050] Composite "${attr}" could not be put into its key form: ` +
|
|
1008
1022
|
`${JSON.stringify(String(value))} resolves under neither encode nor decode->encode.`);
|
|
1009
1023
|
});
|
|
1010
|
-
return toCompositeKeyRecord(form, record);
|
|
1024
|
+
return toCompositeKeyRecord(form, record, needs);
|
|
1011
1025
|
};
|
|
1012
1026
|
/**
|
|
1013
1027
|
* Fail at bind time when a collection's members spell a shared PK composite
|
|
@@ -1069,7 +1083,15 @@ export class DynamoClient extends Context.Service()("@effect-dynamodb/DynamoClie
|
|
|
1069
1083
|
*
|
|
1070
1084
|
* @param config.region - AWS region
|
|
1071
1085
|
* @param config.endpoint - Optional endpoint override (e.g., for DynamoDB Local)
|
|
1072
|
-
* @param config.credentials - Optional static credentials
|
|
1086
|
+
* @param config.credentials - Optional static credentials, with a
|
|
1087
|
+
* `sessionToken` when they are temporary (an assumed role)
|
|
1088
|
+
* @param config.requestHandler - Optional HTTP handler, or the options of the
|
|
1089
|
+
* runtime's handler (`{ socketTimeout: 5000 }`), passed to the SDK client.
|
|
1090
|
+
* None is set by default, so without one a connection that stays open and
|
|
1091
|
+
* never answers keeps a call waiting until it is interrupted. A handler you
|
|
1092
|
+
* pass is destroyed with the layer.
|
|
1093
|
+
* @param config.maxAttempts - Optional attempts per request, the first
|
|
1094
|
+
* included, passed to the SDK client (its default is 3)
|
|
1073
1095
|
* @param config.compressors - Optional compressors for packed storage
|
|
1074
1096
|
* (`DynamoModel.Packed` with `compression`). When given, the layer also
|
|
1075
1097
|
* provides the `Compression` service built from them. That reaches whatever
|
|
@@ -1090,14 +1112,28 @@ export class DynamoClient extends Context.Service()("@effect-dynamodb/DynamoClie
|
|
|
1090
1112
|
* const live = DynamoClient.layer({ region: "us-east-1", compressors: [ZlibCompression.zstd()] })
|
|
1091
1113
|
* ```
|
|
1092
1114
|
*/
|
|
1093
|
-
static layer = (config) => withCompressors(Layer.effect(DynamoClient, buildService(config.region, config.endpoint, config.credentials)), config.compressors);
|
|
1115
|
+
static layer = (config) => withCompressors(Layer.effect(DynamoClient, buildService(config.region, config.endpoint, config.credentials, config)), config.compressors);
|
|
1094
1116
|
/**
|
|
1095
1117
|
* Create a live Layer that reads configuration from Effect Config providers
|
|
1096
1118
|
* (e.g., environment variables, config files).
|
|
1097
1119
|
*
|
|
1098
1120
|
* @param config.region - Config for AWS region
|
|
1099
1121
|
* @param config.endpoint - Optional Config for endpoint override
|
|
1100
|
-
* @param config.credentials - Optional Config for static credentials
|
|
1122
|
+
* @param config.credentials - Optional Config for static credentials, with a
|
|
1123
|
+
* `sessionToken` when they are temporary (an assumed role). With none of
|
|
1124
|
+
* them in the provider, the SDK's default credential chain applies. With
|
|
1125
|
+
* one of them there and another missing (an empty value counts as
|
|
1126
|
+
* missing), the layer fails with the `Config`'s error for what is missing;
|
|
1127
|
+
* a token that may be absent is read with `Config.withDefault(undefined)`.
|
|
1128
|
+
* Both must be shown to be parts of the credentials: a value given, or
|
|
1129
|
+
* one missing, that is a mode, a flag or another setting, or a part the
|
|
1130
|
+
* `Config` turns into other text, leaves the default chain, as before.
|
|
1131
|
+
* @param config.requestHandler - Optional Config for each of the handler's
|
|
1132
|
+
* timeouts (`connectionTimeout`, `socketTimeout`, `requestTimeout`,
|
|
1133
|
+
* `throwOnRequestTimeout`), which an operator tunes per environment, or an
|
|
1134
|
+
* HTTP handler, which is code and is passed as itself. A timeout missing
|
|
1135
|
+
* from the provider stays unset.
|
|
1136
|
+
* @param config.maxAttempts - Optional Config for the attempts per request
|
|
1101
1137
|
* @param config.compressors - Optional compressors for packed storage; when
|
|
1102
1138
|
* given, the layer also provides the `Compression` service (see {@link layer}
|
|
1103
1139
|
* for why a separate `Compression.layer([...])` is the recommended form).
|
|
@@ -1105,10 +1141,9 @@ export class DynamoClient extends Context.Service()("@effect-dynamodb/DynamoClie
|
|
|
1105
1141
|
static layerConfig = (config) => withCompressors(Layer.effect(DynamoClient, Effect.gen(function* () {
|
|
1106
1142
|
const region = yield* config.region;
|
|
1107
1143
|
const endpoint = config.endpoint ? yield* Config.option(config.endpoint) : undefined;
|
|
1108
|
-
const credentials = config.credentials
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
return yield* buildService(region, endpoint && endpoint._tag === "Some" ? endpoint.value : undefined, credentials && credentials._tag === "Some" ? credentials.value : undefined);
|
|
1144
|
+
const credentials = yield* readCredentials(config.credentials);
|
|
1145
|
+
const options = yield* readClientOptions(config);
|
|
1146
|
+
return yield* buildService(region, endpoint && endpoint._tag === "Some" ? endpoint.value : undefined, credentials, options);
|
|
1112
1147
|
})), config.compressors);
|
|
1113
1148
|
/**
|
|
1114
1149
|
* Create a typed client gateway from entities, aggregates, and (optionally) tables.
|
|
@@ -1141,6 +1176,12 @@ export class DynamoClient extends Context.Service()("@effect-dynamodb/DynamoClie
|
|
|
1141
1176
|
* that lands on one of these would take the corresponding feature offline.
|
|
1142
1177
|
*/
|
|
1143
1178
|
const RESERVED_ACCESSOR_NAMES = new Set(["scan", "reembed"]);
|
|
1179
|
+
/**
|
|
1180
|
+
* A query's path builder over the members' models (`pathBuilderOf`): `.entry(key)` on each sparse
|
|
1181
|
+
* map field, baked with the first member's prefix where members declare one field with different
|
|
1182
|
+
* ones (a collection names each member's entry by its own prefix: `collectionNaming`).
|
|
1183
|
+
*/
|
|
1184
|
+
const queryPathBuilder = (entities) => pathBuilderOf(entities.map((entityLike) => entityLike.model));
|
|
1144
1185
|
/** An entity's domain field names (its record's), when its schema exposes them. */
|
|
1145
1186
|
const domainFieldsOf = (entityLike) => {
|
|
1146
1187
|
const fields = entityLike.schemas.recordSchema.fields;
|
|
@@ -1223,6 +1264,15 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1223
1264
|
? Context.add(withEmbedder, Compression, compressionRegistry)
|
|
1224
1265
|
: withEmbedder;
|
|
1225
1266
|
const provide = (effect) => Effect.provide(effect, ctx);
|
|
1267
|
+
// A table's TTL attribute is named by its configuration, so an entity that sets it is checked
|
|
1268
|
+
// here, where the table is bound: a row's reader may not take it as a sparse map's entry
|
|
1269
|
+
// (`[EDD-9140]`, as `Entity.make` checks every name the definition supplies).
|
|
1270
|
+
for (const rawEntity of Object.values(config.entities)) {
|
|
1271
|
+
const entityLike = rawEntity;
|
|
1272
|
+
const tableConfig = Option.getOrUndefined(Context.getOption(baseCtx, entityLike._tableTag));
|
|
1273
|
+
if (tableConfig !== undefined)
|
|
1274
|
+
entityLike._refuseTableAttributes?.(tableConfig);
|
|
1275
|
+
}
|
|
1226
1276
|
// Dimension agreement between the Embedder and every bound vector index is
|
|
1227
1277
|
// a construction-time invariant — a mismatch would otherwise surface as a
|
|
1228
1278
|
// per-write failure long after wiring. See `DESIGN.md §14`.
|
|
@@ -1247,14 +1297,14 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1247
1297
|
const skAttrs = indexDef.sk.composite;
|
|
1248
1298
|
// 1. All PK composites must be present
|
|
1249
1299
|
for (const attr of pkAttrs) {
|
|
1250
|
-
if (composites
|
|
1300
|
+
if (given(composites, attr) === undefined) {
|
|
1251
1301
|
throw new Error(`[EDD-9002] Missing required partition key attribute "${attr}" for index "${indexName}"`);
|
|
1252
1302
|
}
|
|
1253
1303
|
}
|
|
1254
1304
|
// 2. SK composites must follow prefix ordering
|
|
1255
1305
|
let lastProvided = -1;
|
|
1256
1306
|
for (let i = 0; i < skAttrs.length; i++) {
|
|
1257
|
-
if (composites
|
|
1307
|
+
if (given(composites, skAttrs[i]) !== undefined) {
|
|
1258
1308
|
if (i !== lastProvided + 1) {
|
|
1259
1309
|
const missing = skAttrs.slice(lastProvided + 1, i).join(", ");
|
|
1260
1310
|
throw new Error(`[EDD-9004] Sort key composite "${skAttrs[i]}" for index "${indexName}" requires prior composites: ${missing}. Sort key composites must follow prefix ordering.`);
|
|
@@ -1282,13 +1332,20 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1282
1332
|
// composing keys. The raw model is not equivalent — entity derivation
|
|
1283
1333
|
// substitutes date/Redacted fields with their wire transforms.
|
|
1284
1334
|
const encoderSource = entityLike.schemas.inputSchema ?? entityLike.model;
|
|
1285
|
-
const
|
|
1335
|
+
const unencodable = (attr, value, reason) => {
|
|
1336
|
+
if (reason !== undefined) {
|
|
1337
|
+
return refuseInexact(`Composite "${attr}" on index "${_indexName}" of entity "${entityLike.entityType}"`, value, reason);
|
|
1338
|
+
}
|
|
1286
1339
|
throw new Error(`[EDD-9050] Composite "${attr}" on index "${_indexName}" of entity ` +
|
|
1287
1340
|
`"${entityLike.entityType}" could not be encoded to its stored form. The ` +
|
|
1288
1341
|
`attribute's schema carries an encoding transformation, so the stored key holds ` +
|
|
1289
1342
|
`the ENCODED value, but ${JSON.stringify(String(value))} encodes under neither ` +
|
|
1290
1343
|
`encode nor decode->encode. Supply a value of the attribute's own type.`);
|
|
1291
|
-
}
|
|
1344
|
+
};
|
|
1345
|
+
const compositeKeyForm = makeCompositeKeyForm(encoderSource, unencodable);
|
|
1346
|
+
// The caller's composites and bounds are DOMAIN values: the key `put` wrote for one is
|
|
1347
|
+
// the key form of the value it stores (`Entity._domainKeyForm`).
|
|
1348
|
+
const domainKeyForm = makeCompositeDomainKeyForm(encoderSource, unencodable);
|
|
1292
1349
|
// A Z-order sort key (#171) is a binary address: its prefix composites
|
|
1293
1350
|
// and dimensions are bounded with `.within()`, never pinned by the
|
|
1294
1351
|
// accessor, which takes the partition key composites only.
|
|
@@ -1301,9 +1358,9 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1301
1358
|
? indexDef.sk.zorderHalf.layout
|
|
1302
1359
|
: undefined;
|
|
1303
1360
|
const zorderPlans = zorderLayout === undefined ? undefined : makeZOrderPlans(zorderLayout);
|
|
1304
|
-
|
|
1361
|
+
const accessor = (rawComposites) => {
|
|
1305
1362
|
if (zorder) {
|
|
1306
|
-
const misplaced = indexDef.sk.composite.filter((attr) => rawComposites
|
|
1363
|
+
const misplaced = indexDef.sk.composite.filter((attr) => given(rawComposites, attr) !== undefined);
|
|
1307
1364
|
if (misplaced.length > 0) {
|
|
1308
1365
|
throw new Error(`[EDD-9093] Index "${_indexName}" of entity "${entityLike.entityType}" has a ` +
|
|
1309
1366
|
`Z-order sort key, so ${misplaced.map((attr) => `"${attr}"`).join(", ")} can't ` +
|
|
@@ -1312,7 +1369,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1312
1369
|
}
|
|
1313
1370
|
}
|
|
1314
1371
|
validateQueryComposites(_indexName, accessorDef, rawComposites);
|
|
1315
|
-
const compositesKeyForm = toCompositeKeyRecord(
|
|
1372
|
+
const compositesKeyForm = toCompositeKeyRecord(domainKeyForm, rawComposites, indexDef.pk.composite, indexDef.sk.composite);
|
|
1316
1373
|
// One partition, or a sharded index's several (#183).
|
|
1317
1374
|
const read = KeyComposer.composeReadPartitions(entityLike._schema, entityLike.entityType, indexDef, compositesKeyForm);
|
|
1318
1375
|
const pkValue = read.partitions[0];
|
|
@@ -1350,11 +1407,11 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1350
1407
|
// complete key is an exact `=`, or `seq: 3` also matches 3.14 and
|
|
1351
1408
|
// `name: "a"` also matches "ab".
|
|
1352
1409
|
const hasSkComposites = !zorder &&
|
|
1353
|
-
indexDef.sk.composite.some((attr) => compositesKeyForm
|
|
1410
|
+
indexDef.sk.composite.some((attr) => given(compositesKeyForm, attr) !== undefined);
|
|
1354
1411
|
const pinnedQuery = hasSkComposites
|
|
1355
1412
|
? Query.whereUnderPins(query, KeyComposer.composeSortKeyCondition(entityLike._schema, entityLike.entityType, 1, indexDef, compositesKeyForm))
|
|
1356
1413
|
: query;
|
|
1357
|
-
const pathBuilder =
|
|
1414
|
+
const pathBuilder = queryPathBuilder([entityLike]);
|
|
1358
1415
|
const conditionOps = createConditionOps();
|
|
1359
1416
|
// composeSkCondition — compose the user's `.where()` operand into a full
|
|
1360
1417
|
// sort key value the same way `put` composes the stored one
|
|
@@ -1376,7 +1433,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1376
1433
|
// with EDD-9004 before the accessor is built — so this count is also
|
|
1377
1434
|
// the index of the first composite still open to a condition.
|
|
1378
1435
|
const pinnedCount = (() => {
|
|
1379
|
-
const i = skComposites.findIndex((attr) => compositesKeyForm
|
|
1436
|
+
const i = skComposites.findIndex((attr) => given(compositesKeyForm, attr) === undefined);
|
|
1380
1437
|
return i === -1 ? skComposites.length : i;
|
|
1381
1438
|
})();
|
|
1382
1439
|
/**
|
|
@@ -1397,7 +1454,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1397
1454
|
*/
|
|
1398
1455
|
const rejectPinned = (attr) => {
|
|
1399
1456
|
throw new Error(`[EDD-9053] Sort key composite "${attr}" for index "${_indexName}" is already ` +
|
|
1400
|
-
`pinned to ${JSON.stringify(String(compositesKeyForm
|
|
1457
|
+
`pinned to ${JSON.stringify(String(given(compositesKeyForm, attr)))} by the accessor, ` +
|
|
1401
1458
|
`so .where() cannot also constrain it: DynamoDB allows one sort key condition, ` +
|
|
1402
1459
|
`and this one would REPLACE the accessor's own prefix rather than narrow it — ` +
|
|
1403
1460
|
`returning rows outside the pinned value. Drop "${attr}" from the accessor call ` +
|
|
@@ -1426,7 +1483,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1426
1483
|
// silently compare against the wrong prefix.
|
|
1427
1484
|
const missing = skComposites
|
|
1428
1485
|
.slice(0, targetIndex)
|
|
1429
|
-
.filter((attr) => compositesKeyForm
|
|
1486
|
+
.filter((attr) => given(compositesKeyForm, attr) === undefined);
|
|
1430
1487
|
if (missing.length > 0) {
|
|
1431
1488
|
throw new Error(`[EDD-9004] Sort key condition on "${targetAttr}" for index "${_indexName}" ` +
|
|
1432
1489
|
`requires prior composites: ${missing.join(", ")}. Sort key composites must ` +
|
|
@@ -1437,7 +1494,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1437
1494
|
// follows them, so the shared delimiter rule always applies).
|
|
1438
1495
|
const pinnedKeyForm = {};
|
|
1439
1496
|
for (let i = 0; i < targetIndex; i++) {
|
|
1440
|
-
pinnedKeyForm[skComposites[i]] = compositesKeyForm
|
|
1497
|
+
pinnedKeyForm[skComposites[i]] = given(compositesKeyForm, skComposites[i]);
|
|
1441
1498
|
}
|
|
1442
1499
|
const prefixText = KeyComposer.composeSortKeyBeginsWith(entityLike._schema, entityLike.entityType, 1, indexDef, pinnedKeyForm);
|
|
1443
1500
|
// Operands are encoded exactly as the accessor composites (and the
|
|
@@ -1456,7 +1513,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1456
1513
|
casing: KeyComposer.effectiveCasing(entityLike._schema, indexDef),
|
|
1457
1514
|
isLast: targetIndex === skComposites.length - 1,
|
|
1458
1515
|
secondary: indexDef.index !== undefined,
|
|
1459
|
-
}, prefixText, targetAttr, mapBound(condition, (value) =>
|
|
1516
|
+
}, prefixText, targetAttr, mapBound(condition, (value) => domainKeyForm(targetAttr, value)), { clampToPrefix: pinnedCount > 0 });
|
|
1460
1517
|
};
|
|
1461
1518
|
const bqConfig = {
|
|
1462
1519
|
pathBuilder,
|
|
@@ -1474,6 +1531,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1474
1531
|
indexDef,
|
|
1475
1532
|
encoderSource,
|
|
1476
1533
|
compositeKeyForm,
|
|
1534
|
+
domainKeyForm,
|
|
1477
1535
|
pkValue,
|
|
1478
1536
|
plans: zorderPlans,
|
|
1479
1537
|
query: q,
|
|
@@ -1488,6 +1546,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1488
1546
|
indexDef,
|
|
1489
1547
|
encoderSource,
|
|
1490
1548
|
compositeKeyForm,
|
|
1549
|
+
domainKeyForm,
|
|
1491
1550
|
pinnedKeyForm: compositesKeyForm,
|
|
1492
1551
|
pkValue,
|
|
1493
1552
|
query: q,
|
|
@@ -1496,11 +1555,25 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1496
1555
|
}),
|
|
1497
1556
|
}),
|
|
1498
1557
|
skFields: accessorDef.sk.composite,
|
|
1499
|
-
...entityNaming(entityLike._resolveDbName),
|
|
1558
|
+
...entityNaming(entityLike._resolveDbName, entityLike._storedFormAt, wholeRowsOf(entityLike), entityLike._storedBelow),
|
|
1500
1559
|
operation: { name: "Entity.query", target: entityLike.entityType, index: _indexName },
|
|
1501
1560
|
};
|
|
1502
1561
|
return new BoundQueryImpl(pinnedQuery, bqConfig);
|
|
1503
1562
|
};
|
|
1563
|
+
return (rawComposites) => {
|
|
1564
|
+
const operation = {
|
|
1565
|
+
name: "Entity.query",
|
|
1566
|
+
target: entityLike.entityType,
|
|
1567
|
+
index: _indexName,
|
|
1568
|
+
};
|
|
1569
|
+
return Query.orRefusal(operation, () => accessor(rawComposites), (refusal) => new BoundQueryImpl(Query.refused(indexDef.index, refusal), {
|
|
1570
|
+
pathBuilder: queryPathBuilder([entityLike]),
|
|
1571
|
+
conditionOps: createConditionOps(),
|
|
1572
|
+
provide,
|
|
1573
|
+
...entityNaming(entityLike._resolveDbName, entityLike._storedFormAt, wholeRowsOf(entityLike), entityLike._storedBelow),
|
|
1574
|
+
operation,
|
|
1575
|
+
}));
|
|
1576
|
+
};
|
|
1504
1577
|
};
|
|
1505
1578
|
// 2. Bind entities + build entity query accessors
|
|
1506
1579
|
const boundEntities = {};
|
|
@@ -1531,7 +1604,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1531
1604
|
for (const [indexName, indexDef] of Object.entries(entityLike.indexes)) {
|
|
1532
1605
|
if (!indexDef)
|
|
1533
1606
|
continue;
|
|
1534
|
-
accessors
|
|
1607
|
+
setOwn(accessors, indexName, buildEntityQueryAccessor(entityLike, indexName, indexDef));
|
|
1535
1608
|
// Track collection membership for auto-discovery
|
|
1536
1609
|
if (indexDef.collection) {
|
|
1537
1610
|
const collNames = Array.isArray(indexDef.collection)
|
|
@@ -1551,13 +1624,13 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1551
1624
|
// named after an existing index accessor (or `scan` / `reembed`) would
|
|
1552
1625
|
// silently replace it and take the other feature offline, so make the
|
|
1553
1626
|
// collision a construction-time failure instead.
|
|
1554
|
-
if (logicalName
|
|
1627
|
+
if (Object.hasOwn(accessors, logicalName) || RESERVED_ACCESSOR_NAMES.has(logicalName)) {
|
|
1555
1628
|
throw new Error(`[EDD-9038] Entity "${key}": vector index "${logicalName}" collides with an existing ` +
|
|
1556
1629
|
`accessor of the same name. Vector index names share a namespace with GSI query ` +
|
|
1557
1630
|
`accessors, \`scan\` and \`reembed\` — rename one of them.`);
|
|
1558
1631
|
}
|
|
1559
1632
|
const vqConfig = {
|
|
1560
|
-
keyForm: (record) =>
|
|
1633
|
+
keyForm: (record) => entityDomainKeyForm(entityLike, record, definition.partition ?? []),
|
|
1561
1634
|
entityType: entityLike.entityType,
|
|
1562
1635
|
logicalName,
|
|
1563
1636
|
definition,
|
|
@@ -1568,6 +1641,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1568
1641
|
unpackAttributes: entityLike._dispatchAttributes,
|
|
1569
1642
|
provide,
|
|
1570
1643
|
resolveDbName: entityLike._resolveDbName ?? ((domainName) => domainName),
|
|
1644
|
+
storedAt: entityLike._storedFormAt,
|
|
1571
1645
|
};
|
|
1572
1646
|
accessors[logicalName] = (query) => makeBoundVectorQuery(vqConfig, query);
|
|
1573
1647
|
}
|
|
@@ -1583,13 +1657,13 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1583
1657
|
keyFields: [entityLike.indexes.primary?.pk.field, entityLike.indexes.primary?.sk.field],
|
|
1584
1658
|
liveRows: entityLike._liveRows?.(),
|
|
1585
1659
|
});
|
|
1586
|
-
const pathBuilder =
|
|
1660
|
+
const pathBuilder = queryPathBuilder([entityLike]);
|
|
1587
1661
|
const conditionOps = createConditionOps();
|
|
1588
1662
|
const bqConfig = {
|
|
1589
1663
|
pathBuilder,
|
|
1590
1664
|
conditionOps,
|
|
1591
1665
|
provide,
|
|
1592
|
-
...entityNaming(entityLike._resolveDbName),
|
|
1666
|
+
...entityNaming(entityLike._resolveDbName, entityLike._storedFormAt, wholeRowsOf(entityLike), entityLike._storedBelow),
|
|
1593
1667
|
operation: { name: "Entity.scan", target: entityLike.entityType },
|
|
1594
1668
|
};
|
|
1595
1669
|
return new BoundQueryImpl(scanQuery, bqConfig);
|
|
@@ -1608,7 +1682,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1608
1682
|
assertCollectionKeyFormAgreement(collName, members);
|
|
1609
1683
|
KeyComposer.assertCollectionCasingAgreement(collName, members.map((m) => ({ key: m.entityKey, schema: m.entityLike._schema, index: m.indexDef })));
|
|
1610
1684
|
KeyComposer.assertCollectionShardsAgreement(collName, members.map((m) => ({ key: m.entityKey, index: m.indexDef })));
|
|
1611
|
-
|
|
1685
|
+
const collectionAccessor = (composites) => {
|
|
1612
1686
|
// Use the first member for PK composition — verified above to agree
|
|
1613
1687
|
// with every other member.
|
|
1614
1688
|
const firstMember = members[0];
|
|
@@ -1647,7 +1721,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1647
1721
|
// different PK from `db.entities.Readings.byWindow({ takenAt })` and
|
|
1648
1722
|
// returned nothing.
|
|
1649
1723
|
// Members share the partitions, whatever each hashes: never pruned (#183).
|
|
1650
|
-
const read = KeyComposer.composeReadPartitions(firstMember.entityLike._schema, firstMember.entityLike.entityType, indexDef,
|
|
1724
|
+
const read = KeyComposer.composeReadPartitions(firstMember.entityLike._schema, firstMember.entityLike.entityType, indexDef, entityDomainKeyForm(firstMember.entityLike, composites, indexDef.pk.composite), { prune: false });
|
|
1651
1725
|
// Always isolated — begins_with on collection SK prefix
|
|
1652
1726
|
let query = Query.make({
|
|
1653
1727
|
tableName: "",
|
|
@@ -1689,7 +1763,7 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1689
1763
|
query = Query.where(query, { beginsWith: skPrefix });
|
|
1690
1764
|
}
|
|
1691
1765
|
// Wrap in BoundQuery that groups results by entity key
|
|
1692
|
-
const pathBuilder =
|
|
1766
|
+
const pathBuilder = queryPathBuilder(members.map((m) => m.entityLike));
|
|
1693
1767
|
const conditionOps = createConditionOps();
|
|
1694
1768
|
const collectionProvide = (eff) => Effect.provide(eff, ctx);
|
|
1695
1769
|
const bqConfig = {
|
|
@@ -1722,11 +1796,78 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1722
1796
|
entityKey: m.entityKey,
|
|
1723
1797
|
resolve: m.entityLike._resolveDbName ?? ((name) => name),
|
|
1724
1798
|
fields: domainFieldsOf(m.entityLike),
|
|
1799
|
+
storedAt: m.entityLike._storedFormAt,
|
|
1800
|
+
wholeRows: wholeRowsOf(m.entityLike),
|
|
1801
|
+
below: m.entityLike._storedBelow,
|
|
1725
1802
|
}))),
|
|
1726
1803
|
operation: { name: "Collection.query", target: collName },
|
|
1727
1804
|
};
|
|
1728
1805
|
return new BoundQueryImpl(query, bqConfig);
|
|
1729
1806
|
};
|
|
1807
|
+
boundCollections[collName] = (composites) => {
|
|
1808
|
+
const operation = { name: "Collection.query", target: collName };
|
|
1809
|
+
return Query.orRefusal(operation, () => collectionAccessor(composites), (refusal) => new BoundQueryImpl(Query.refused(members[0].indexDef.index, refusal), {
|
|
1810
|
+
pathBuilder: queryPathBuilder(members.map((m) => m.entityLike)),
|
|
1811
|
+
conditionOps: createConditionOps(),
|
|
1812
|
+
provide,
|
|
1813
|
+
operation,
|
|
1814
|
+
}));
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
// An aggregate declaring `ownsRows` takes every row of its types in its partition. Refused when
|
|
1818
|
+
// another member this client can see can write such a row there (DESIGN.md §7 "Which rows in
|
|
1819
|
+
// its partition are an aggregate's"): those its table declares, those the client binds, and
|
|
1820
|
+
// those of every table the client binds, on the same physical table (by table, or by the
|
|
1821
|
+
// name it resolves to here). A writer it doesn't see, here or in another process, isn't checked.
|
|
1822
|
+
const tableNameOf = (table) => {
|
|
1823
|
+
// A table's tag is a function.
|
|
1824
|
+
if (table === null ||
|
|
1825
|
+
(typeof table !== "object" && typeof table !== "function") ||
|
|
1826
|
+
!("key" in table)) {
|
|
1827
|
+
return undefined;
|
|
1828
|
+
}
|
|
1829
|
+
return Option.getOrUndefined(Context.getOption(baseCtx, table))?.name;
|
|
1830
|
+
};
|
|
1831
|
+
// Every entity the client sees: those it binds, then those of every table it binds, named as a
|
|
1832
|
+
// refusal names them. A member may reach the client only as another bound table's.
|
|
1833
|
+
const visible = [
|
|
1834
|
+
...Object.entries(config.entities),
|
|
1835
|
+
...Object.entries(config.tables ?? {}).flatMap(([tableKey, table]) => Object.entries(table.entities).map(([key, entity]) => [`${tableKey}.${key}`, entity])),
|
|
1836
|
+
];
|
|
1837
|
+
// And every aggregate it sees, the same way.
|
|
1838
|
+
const visibleAggregates = [
|
|
1839
|
+
...Object.entries(config.aggregates ?? {}),
|
|
1840
|
+
...Object.entries(config.tables ?? {}).flatMap(([tableKey, table]) => Object.entries(table.aggregates ?? {}).map(([key, aggregate]) => [`${tableKey}.${key}`, aggregate])),
|
|
1841
|
+
];
|
|
1842
|
+
const visibleMembers = [...visible, ...visibleAggregates].map(([name, member]) => ({
|
|
1843
|
+
name,
|
|
1844
|
+
member,
|
|
1845
|
+
}));
|
|
1846
|
+
// The owners checked are the aggregates it sees, from the same list: `rekey` runs the handler of
|
|
1847
|
+
// a table's aggregate the client doesn't bind itself. Each once, by the first name it has.
|
|
1848
|
+
const checked = new Set();
|
|
1849
|
+
for (const [key, aggregate] of visibleAggregates) {
|
|
1850
|
+
if (aggregate._ownsRows !== true)
|
|
1851
|
+
continue;
|
|
1852
|
+
if (checked.has(aggregate))
|
|
1853
|
+
continue;
|
|
1854
|
+
checked.add(aggregate);
|
|
1855
|
+
const own = aggregate._tableTag;
|
|
1856
|
+
const ownName = tableNameOf(own);
|
|
1857
|
+
const conflict = ownershipConflict(aggregate, visibleMembers, (table) => {
|
|
1858
|
+
if (table === own)
|
|
1859
|
+
return true;
|
|
1860
|
+
const keyOf = (t) => t?.key;
|
|
1861
|
+
if (keyOf(table) !== undefined && keyOf(table) === keyOf(own))
|
|
1862
|
+
return true;
|
|
1863
|
+
return ownName !== undefined && tableNameOf(table) === ownName;
|
|
1864
|
+
});
|
|
1865
|
+
if (conflict !== undefined) {
|
|
1866
|
+
throw new Error(`[EDD-9130] Aggregate "${key}" declares \`ownsRows\`, but "${conflict.member}" can write ` +
|
|
1867
|
+
`a row of type "${conflict.type}" into its partition (${conflict.channel}). ` +
|
|
1868
|
+
`\`ownsRows\` would take that row for the aggregate's: leave it off, or keep ` +
|
|
1869
|
+
`"${conflict.member}"'s rows out of the aggregate's partition.`);
|
|
1870
|
+
}
|
|
1730
1871
|
}
|
|
1731
1872
|
// 4. Bind aggregates
|
|
1732
1873
|
const boundAggregates = {};
|
|
@@ -1740,39 +1881,104 @@ const makeFromConfig = (config) => Effect.gen(function* () {
|
|
|
1740
1881
|
// 5. Build table operations
|
|
1741
1882
|
const client = yield* DynamoClient;
|
|
1742
1883
|
const tables = {};
|
|
1884
|
+
// The entities the client sees (`visible`) are where `rekey` finds the outboxes of their
|
|
1885
|
+
// projections. `entities` comes first, so the read models it found before keep their order.
|
|
1886
|
+
const visibleEntities = visible.map(([, entity]) => entity);
|
|
1887
|
+
const named = visible.map(([name, entity]) => [`"${name}"`, entity]);
|
|
1888
|
+
yield* refuseSharedOutboxKeySpace("DynamoClient.make", named);
|
|
1743
1889
|
// `rekey` (#171) hands each row to the member owning it: the table's
|
|
1744
1890
|
// entities and aggregates, those the client binds on the same table, and
|
|
1745
1891
|
// the streams the caller passes (`DynamoClient.make` binds no streams).
|
|
1746
|
-
const rekeyFor = (tableName, tagKey, registered) => (options) => {
|
|
1747
|
-
const onTable = (member) => member._tableTag?.key ===
|
|
1892
|
+
const rekeyFor = (tableName, tagKey, registered) => (options) => provide(Effect.gen(function* () {
|
|
1893
|
+
const onTable = (member) => member._tableTag?.key ===
|
|
1894
|
+
tagKey;
|
|
1748
1895
|
const handlers = new Set();
|
|
1749
|
-
|
|
1896
|
+
const tableMembers = [
|
|
1750
1897
|
...registered,
|
|
1751
1898
|
...Object.values(config.entities).filter(onTable),
|
|
1752
1899
|
...Object.values(config.aggregates ?? {}).filter(onTable),
|
|
1753
|
-
|
|
1754
|
-
]) {
|
|
1900
|
+
];
|
|
1901
|
+
for (const member of [...tableMembers, ...(options?.streams ?? [])]) {
|
|
1755
1902
|
const handler = Rekey.handlerOf(member);
|
|
1756
1903
|
if (handler !== undefined)
|
|
1757
1904
|
handlers.add(handler);
|
|
1758
1905
|
}
|
|
1759
|
-
//
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1906
|
+
// The read models whose outboxes are on this table are checked before anything is
|
|
1907
|
+
// sent, as `DynamoClient.make` checks them: two whose items would overwrite each other
|
|
1908
|
+
// in normal operation are refused, and so is a member of this table claiming a read
|
|
1909
|
+
// model's items whose own would. Projections are defined when the program runs them,
|
|
1910
|
+
// so one defined after the client was made has its outbox recorded only now. Whose an
|
|
1911
|
+
// item is otherwise is decided item by item (`rekeyOutboxMember`). A run's refusal is
|
|
1912
|
+
// the run's `ValidationError`.
|
|
1913
|
+
const shared = yield* sharedOutboxKeySpace("rekey", named, {
|
|
1914
|
+
key: tagKey,
|
|
1915
|
+
name: tableName,
|
|
1916
|
+
members: [...new Set(tableMembers)].map((member) => [
|
|
1917
|
+
named.find(([, entity]) => entity === member)?.[0] ??
|
|
1918
|
+
`"${member.entityType}"`,
|
|
1919
|
+
member,
|
|
1920
|
+
]),
|
|
1921
|
+
});
|
|
1922
|
+
if (shared !== undefined) {
|
|
1923
|
+
return yield* new ValidationError({
|
|
1924
|
+
entityType: "Table",
|
|
1925
|
+
operation: "rekey",
|
|
1926
|
+
cause: shared,
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
// The outbox items on this table, by entity type, are judged by one member each, which
|
|
1930
|
+
// asks every read model of that type that can have written them (#237): the table's
|
|
1931
|
+
// members (their own projections' outbox items), then each read model whose
|
|
1932
|
+
// projection's outbox is on this table (#171) — every projection's, so a second
|
|
1933
|
+
// projection of one read model doesn't hide the first's items, named by this table's
|
|
1934
|
+
// service or by another handle on the same physical table. A read model's projections
|
|
1935
|
+
// may have one each, on tables of their own.
|
|
1936
|
+
const outboxCandidates = new Map();
|
|
1937
|
+
const addCandidate = (entity, key) => {
|
|
1938
|
+
const type = entity.entityType;
|
|
1939
|
+
const byEntity = outboxCandidates.get(type) ??
|
|
1940
|
+
new Map();
|
|
1941
|
+
outboxCandidates.set(type, byEntity);
|
|
1942
|
+
const keys = byEntity.get(entity) ?? [];
|
|
1943
|
+
byEntity.set(entity, keys);
|
|
1944
|
+
if (!keys.some((k) => k.pk === key.pk && k.sk === key.sk))
|
|
1945
|
+
keys.push(key);
|
|
1946
|
+
};
|
|
1947
|
+
for (const member of new Set(tableMembers)) {
|
|
1948
|
+
const type = member.entityType;
|
|
1949
|
+
const primary = member.indexes?.primary;
|
|
1950
|
+
if (type === undefined ||
|
|
1951
|
+
primary === undefined ||
|
|
1952
|
+
member._valuelessMove === undefined ||
|
|
1953
|
+
Rekey.handlerOf(member)?.types.includes(`${type}#outbox`) !== true) {
|
|
1764
1954
|
continue;
|
|
1765
1955
|
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1956
|
+
addCandidate(member, { pk: primary.pk.field, sk: primary.sk.field });
|
|
1957
|
+
}
|
|
1958
|
+
for (const entity of new Set([...registered, ...visibleEntities])) {
|
|
1959
|
+
for (const outbox of remoteOutboxesOf(entity)) {
|
|
1960
|
+
if (outbox.table.Tag.key !== tagKey &&
|
|
1961
|
+
(yield* physicalTableName(outbox.table.Tag)) !== tableName) {
|
|
1962
|
+
continue;
|
|
1963
|
+
}
|
|
1964
|
+
addCandidate(entity, { pk: outbox.pk, sk: outbox.sk });
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
for (const [type, byEntity] of outboxCandidates) {
|
|
1968
|
+
// A read model with one layout on this table names the table's key attributes.
|
|
1969
|
+
const layout = [...byEntity.values()].find((keys) => keys.length === 1)?.[0];
|
|
1768
1970
|
handlers.add({
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1971
|
+
...rekeyOutboxMember(type, [...byEntity].map(([entity, keys]) => ({
|
|
1972
|
+
readModel: entity,
|
|
1973
|
+
// A table has one key schema, so its items are under the layout whose
|
|
1974
|
+
// attributes they hold.
|
|
1975
|
+
keys: (row) => keys.find((key) => row[key.pk]?.S !== undefined && row[key.sk]?.S !== undefined) ?? keys[0],
|
|
1976
|
+
}))),
|
|
1977
|
+
...(layout !== undefined && { key: layout }),
|
|
1772
1978
|
});
|
|
1773
1979
|
}
|
|
1774
|
-
return
|
|
1775
|
-
};
|
|
1980
|
+
return yield* Rekey.run({ tableName, members: [...handlers], options });
|
|
1981
|
+
}));
|
|
1776
1982
|
if (config.tables) {
|
|
1777
1983
|
for (const [tableKey, table] of Object.entries(config.tables)) {
|
|
1778
1984
|
const tableConfig = yield* table.Tag;
|
|
@@ -2094,7 +2300,7 @@ const waitForVectorIndexReady = (tableName, indexName, client, options) => {
|
|
|
2094
2300
|
};
|
|
2095
2301
|
/** @internal Classify an AWS SDK error into a specific tagged error type. */
|
|
2096
2302
|
export const classifyError = (operation) => (thrown) => {
|
|
2097
|
-
const cause = redactCredentialRefusal(thrown);
|
|
2303
|
+
const cause = hideReturnedItems(redactCredentialRefusal(thrown));
|
|
2098
2304
|
if (isAwsThrottling(cause))
|
|
2099
2305
|
return new ThrottlingError({ operation, cause });
|
|
2100
2306
|
if (isAwsValidationError(cause))
|
|
@@ -2106,138 +2312,150 @@ export const classifyError = (operation) => (thrown) => {
|
|
|
2106
2312
|
return new DynamoError({ operation, cause });
|
|
2107
2313
|
};
|
|
2108
2314
|
/** @internal Build the DynamoClient service implementation from resolved config values. */
|
|
2109
|
-
const buildService = (region, endpoint, credentials) => Effect.gen(function* () {
|
|
2315
|
+
const buildService = (region, endpoint, credentials, options) => Effect.gen(function* () {
|
|
2110
2316
|
const clientConfig = { region };
|
|
2111
2317
|
if (endpoint !== undefined)
|
|
2112
2318
|
clientConfig.endpoint = endpoint;
|
|
2113
2319
|
if (credentials !== undefined)
|
|
2114
|
-
clientConfig.credentials = credentials;
|
|
2115
|
-
|
|
2320
|
+
clientConfig.credentials = sdkCredentials(credentials);
|
|
2321
|
+
if (options.requestHandler !== undefined)
|
|
2322
|
+
clientConfig.requestHandler = options.requestHandler;
|
|
2323
|
+
if (options.maxAttempts !== undefined)
|
|
2324
|
+
clientConfig.maxAttempts = options.maxAttempts;
|
|
2325
|
+
const client = yield* acquireSdkClient(() => new DynamoDBClient(clientConfig));
|
|
2116
2326
|
return {
|
|
2117
2327
|
createTable: (input) => Effect.tryPromise({
|
|
2118
|
-
try: () => client.send(new CreateTableCommand(input)),
|
|
2328
|
+
try: (signal) => client.send(new CreateTableCommand(input), { abortSignal: signal }),
|
|
2119
2329
|
catch: classifyError("CreateTable"),
|
|
2120
2330
|
}),
|
|
2121
2331
|
deleteTable: (input) => Effect.tryPromise({
|
|
2122
|
-
try: () => client.send(new DeleteTableCommand(input)),
|
|
2332
|
+
try: (signal) => client.send(new DeleteTableCommand(input), { abortSignal: signal }),
|
|
2123
2333
|
catch: classifyError("DeleteTable"),
|
|
2124
2334
|
}),
|
|
2125
2335
|
describeTable: (input) => Effect.tryPromise({
|
|
2126
|
-
try: () => client.send(new DescribeTableCommand(input)),
|
|
2336
|
+
try: (signal) => client.send(new DescribeTableCommand(input), { abortSignal: signal }),
|
|
2127
2337
|
catch: classifyError("DescribeTable"),
|
|
2128
2338
|
}),
|
|
2129
2339
|
putItem: (input) => Effect.tryPromise({
|
|
2130
|
-
try: () => client.send(new PutItemCommand(input)),
|
|
2340
|
+
try: (signal) => client.send(new PutItemCommand(input), { abortSignal: signal }),
|
|
2131
2341
|
catch: classifyError("PutItem"),
|
|
2132
2342
|
}),
|
|
2133
2343
|
getItem: (input) => Effect.tryPromise({
|
|
2134
|
-
try: () => client.send(new GetItemCommand(input)),
|
|
2344
|
+
try: (signal) => client.send(new GetItemCommand(input), { abortSignal: signal }),
|
|
2135
2345
|
catch: classifyError("GetItem"),
|
|
2136
2346
|
}),
|
|
2137
2347
|
deleteItem: (input) => Effect.tryPromise({
|
|
2138
|
-
try: () => client.send(new DeleteItemCommand(input)),
|
|
2348
|
+
try: (signal) => client.send(new DeleteItemCommand(input), { abortSignal: signal }),
|
|
2139
2349
|
catch: classifyError("DeleteItem"),
|
|
2140
2350
|
}),
|
|
2141
2351
|
updateItem: (input) => Effect.tryPromise({
|
|
2142
|
-
try: () => client.send(new UpdateItemCommand(input)),
|
|
2352
|
+
try: (signal) => client.send(new UpdateItemCommand(input), { abortSignal: signal }),
|
|
2143
2353
|
catch: classifyError("UpdateItem"),
|
|
2144
2354
|
}),
|
|
2145
2355
|
query: (input) => Effect.tryPromise({
|
|
2146
|
-
try: () => client.send(new QueryCommand(input)),
|
|
2356
|
+
try: (signal) => client.send(new QueryCommand(input), { abortSignal: signal }),
|
|
2147
2357
|
catch: classifyError("Query"),
|
|
2148
2358
|
}),
|
|
2149
2359
|
scan: (input) => Effect.tryPromise({
|
|
2150
|
-
try: () => client.send(new ScanCommand(input)),
|
|
2360
|
+
try: (signal) => client.send(new ScanCommand(input), { abortSignal: signal }),
|
|
2151
2361
|
catch: classifyError("Scan"),
|
|
2152
2362
|
}),
|
|
2153
2363
|
searchVectors: (input) => Effect.tryPromise({
|
|
2154
|
-
try: () => client.send(new SearchVectorsCommand(input)),
|
|
2364
|
+
try: (signal) => client.send(new SearchVectorsCommand(input), { abortSignal: signal }),
|
|
2155
2365
|
catch: classifyError("SearchVectors"),
|
|
2156
2366
|
}),
|
|
2157
2367
|
batchGetItem: (input) => Effect.tryPromise({
|
|
2158
|
-
try: () => client.send(new BatchGetItemCommand(input)),
|
|
2368
|
+
try: (signal) => client.send(new BatchGetItemCommand(input), { abortSignal: signal }),
|
|
2159
2369
|
catch: classifyError("BatchGetItem"),
|
|
2160
2370
|
}),
|
|
2161
2371
|
batchWriteItem: (input) => Effect.tryPromise({
|
|
2162
|
-
try: () => client.send(new BatchWriteItemCommand(input)),
|
|
2372
|
+
try: (signal) => client.send(new BatchWriteItemCommand(input), { abortSignal: signal }),
|
|
2163
2373
|
catch: classifyError("BatchWriteItem"),
|
|
2164
2374
|
}),
|
|
2165
2375
|
transactGetItems: (input) => Effect.tryPromise({
|
|
2166
|
-
try: () => client.send(new TransactGetItemsCommand(input)),
|
|
2376
|
+
try: (signal) => client.send(new TransactGetItemsCommand(input), { abortSignal: signal }),
|
|
2167
2377
|
catch: classifyError("TransactGetItems"),
|
|
2168
2378
|
}),
|
|
2169
2379
|
transactWriteItems: (input) => Effect.tryPromise({
|
|
2170
|
-
try: () => client.send(new TransactWriteItemsCommand(input)),
|
|
2380
|
+
try: (signal) => client.send(new TransactWriteItemsCommand(input), { abortSignal: signal }),
|
|
2171
2381
|
catch: classifyError("TransactWriteItems"),
|
|
2172
2382
|
}),
|
|
2383
|
+
executeStatement: (input) => Effect.tryPromise({
|
|
2384
|
+
try: (signal) => client.send(new ExecuteStatementCommand(input), { abortSignal: signal }),
|
|
2385
|
+
catch: classifyError("ExecuteStatement"),
|
|
2386
|
+
}),
|
|
2387
|
+
executeTransaction: (input) => Effect.tryPromise({
|
|
2388
|
+
try: (signal) => client.send(new ExecuteTransactionCommand(input), { abortSignal: signal }),
|
|
2389
|
+
catch: classifyError("ExecuteTransaction"),
|
|
2390
|
+
}),
|
|
2173
2391
|
// --- Table management ---
|
|
2174
2392
|
updateTable: (input) => Effect.tryPromise({
|
|
2175
|
-
try: () => client.send(new UpdateTableCommand(input)),
|
|
2393
|
+
try: (signal) => client.send(new UpdateTableCommand(input), { abortSignal: signal }),
|
|
2176
2394
|
catch: classifyError("UpdateTable"),
|
|
2177
2395
|
}),
|
|
2178
2396
|
listTables: (input) => Effect.tryPromise({
|
|
2179
|
-
try: () => client.send(new ListTablesCommand(input)),
|
|
2397
|
+
try: (signal) => client.send(new ListTablesCommand(input), { abortSignal: signal }),
|
|
2180
2398
|
catch: classifyError("ListTables"),
|
|
2181
2399
|
}),
|
|
2182
2400
|
// --- Backup ---
|
|
2183
2401
|
createBackup: (input) => Effect.tryPromise({
|
|
2184
|
-
try: () => client.send(new CreateBackupCommand(input)),
|
|
2402
|
+
try: (signal) => client.send(new CreateBackupCommand(input), { abortSignal: signal }),
|
|
2185
2403
|
catch: classifyError("CreateBackup"),
|
|
2186
2404
|
}),
|
|
2187
2405
|
deleteBackup: (input) => Effect.tryPromise({
|
|
2188
|
-
try: () => client.send(new DeleteBackupCommand(input)),
|
|
2406
|
+
try: (signal) => client.send(new DeleteBackupCommand(input), { abortSignal: signal }),
|
|
2189
2407
|
catch: classifyError("DeleteBackup"),
|
|
2190
2408
|
}),
|
|
2191
2409
|
listBackups: (input) => Effect.tryPromise({
|
|
2192
|
-
try: () => client.send(new ListBackupsCommand(input)),
|
|
2410
|
+
try: (signal) => client.send(new ListBackupsCommand(input), { abortSignal: signal }),
|
|
2193
2411
|
catch: classifyError("ListBackups"),
|
|
2194
2412
|
}),
|
|
2195
2413
|
restoreTableFromBackup: (input) => Effect.tryPromise({
|
|
2196
|
-
try: () => client.send(new RestoreTableFromBackupCommand(input)),
|
|
2414
|
+
try: (signal) => client.send(new RestoreTableFromBackupCommand(input), { abortSignal: signal }),
|
|
2197
2415
|
catch: classifyError("RestoreTableFromBackup"),
|
|
2198
2416
|
}),
|
|
2199
2417
|
// --- PITR ---
|
|
2200
2418
|
describeContinuousBackups: (input) => Effect.tryPromise({
|
|
2201
|
-
try: () => client.send(new DescribeContinuousBackupsCommand(input)),
|
|
2419
|
+
try: (signal) => client.send(new DescribeContinuousBackupsCommand(input), { abortSignal: signal }),
|
|
2202
2420
|
catch: classifyError("DescribeContinuousBackups"),
|
|
2203
2421
|
}),
|
|
2204
2422
|
updateContinuousBackups: (input) => Effect.tryPromise({
|
|
2205
|
-
try: () => client.send(new UpdateContinuousBackupsCommand(input)),
|
|
2423
|
+
try: (signal) => client.send(new UpdateContinuousBackupsCommand(input), { abortSignal: signal }),
|
|
2206
2424
|
catch: classifyError("UpdateContinuousBackups"),
|
|
2207
2425
|
}),
|
|
2208
2426
|
restoreTableToPointInTime: (input) => Effect.tryPromise({
|
|
2209
|
-
try: () => client.send(new RestoreTableToPointInTimeCommand(input)),
|
|
2427
|
+
try: (signal) => client.send(new RestoreTableToPointInTimeCommand(input), { abortSignal: signal }),
|
|
2210
2428
|
catch: classifyError("RestoreTableToPointInTime"),
|
|
2211
2429
|
}),
|
|
2212
2430
|
// --- Export ---
|
|
2213
2431
|
exportTableToPointInTime: (input) => Effect.tryPromise({
|
|
2214
|
-
try: () => client.send(new ExportTableToPointInTimeCommand(input)),
|
|
2432
|
+
try: (signal) => client.send(new ExportTableToPointInTimeCommand(input), { abortSignal: signal }),
|
|
2215
2433
|
catch: classifyError("ExportTableToPointInTime"),
|
|
2216
2434
|
}),
|
|
2217
2435
|
describeExport: (input) => Effect.tryPromise({
|
|
2218
|
-
try: () => client.send(new DescribeExportCommand(input)),
|
|
2436
|
+
try: (signal) => client.send(new DescribeExportCommand(input), { abortSignal: signal }),
|
|
2219
2437
|
catch: classifyError("DescribeExport"),
|
|
2220
2438
|
}),
|
|
2221
2439
|
// --- TTL ---
|
|
2222
2440
|
updateTimeToLive: (input) => Effect.tryPromise({
|
|
2223
|
-
try: () => client.send(new UpdateTimeToLiveCommand(input)),
|
|
2441
|
+
try: (signal) => client.send(new UpdateTimeToLiveCommand(input), { abortSignal: signal }),
|
|
2224
2442
|
catch: classifyError("UpdateTimeToLive"),
|
|
2225
2443
|
}),
|
|
2226
2444
|
describeTimeToLive: (input) => Effect.tryPromise({
|
|
2227
|
-
try: () => client.send(new DescribeTimeToLiveCommand(input)),
|
|
2445
|
+
try: (signal) => client.send(new DescribeTimeToLiveCommand(input), { abortSignal: signal }),
|
|
2228
2446
|
catch: classifyError("DescribeTimeToLive"),
|
|
2229
2447
|
}),
|
|
2230
2448
|
// --- Tags ---
|
|
2231
2449
|
tagResource: (input) => Effect.tryPromise({
|
|
2232
|
-
try: () => client.send(new TagResourceCommand(input)),
|
|
2450
|
+
try: (signal) => client.send(new TagResourceCommand(input), { abortSignal: signal }),
|
|
2233
2451
|
catch: classifyError("TagResource"),
|
|
2234
2452
|
}),
|
|
2235
2453
|
untagResource: (input) => Effect.tryPromise({
|
|
2236
|
-
try: () => client.send(new UntagResourceCommand(input)),
|
|
2454
|
+
try: (signal) => client.send(new UntagResourceCommand(input), { abortSignal: signal }),
|
|
2237
2455
|
catch: classifyError("UntagResource"),
|
|
2238
2456
|
}),
|
|
2239
2457
|
listTagsOfResource: (input) => Effect.tryPromise({
|
|
2240
|
-
try: () => client.send(new ListTagsOfResourceCommand(input)),
|
|
2458
|
+
try: (signal) => client.send(new ListTagsOfResourceCommand(input), { abortSignal: signal }),
|
|
2241
2459
|
catch: classifyError("ListTagsOfResource"),
|
|
2242
2460
|
}),
|
|
2243
2461
|
};
|