effect-dynamodb 1.23.0 → 1.25.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 +5 -2
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js +136 -53
- package/dist/Aggregate.js.map +1 -1
- package/dist/Batch.d.ts +14 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +184 -119
- package/dist/Batch.js.map +1 -1
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +2 -4
- package/dist/Collection.js.map +1 -1
- package/dist/DynamoClient.d.ts.map +1 -1
- package/dist/DynamoClient.js +42 -14
- package/dist/DynamoClient.js.map +1 -1
- package/dist/Entity.d.ts +19 -13
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +287 -226
- package/dist/Entity.js.map +1 -1
- package/dist/EventStore.d.ts +1060 -50
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +1607 -299
- package/dist/EventStore.js.map +1 -1
- package/dist/Query.d.ts +47 -14
- package/dist/Query.d.ts.map +1 -1
- package/dist/Query.js +190 -68
- package/dist/Query.js.map +1 -1
- package/dist/Table.d.ts +56 -6
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +134 -54
- package/dist/Table.js.map +1 -1
- package/dist/Transaction.d.ts +8 -0
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +67 -22
- package/dist/Transaction.js.map +1 -1
- package/dist/VectorSearchEmulation.d.ts +3 -2
- package/dist/VectorSearchEmulation.d.ts.map +1 -1
- package/dist/VectorSearchEmulation.js +14 -2
- package/dist/VectorSearchEmulation.js.map +1 -1
- package/dist/internal/BoundQuery.d.ts +3 -2
- package/dist/internal/BoundQuery.d.ts.map +1 -1
- package/dist/internal/BoundQuery.js.map +1 -1
- package/dist/internal/BoundVectorQuery.d.ts +5 -1
- package/dist/internal/BoundVectorQuery.d.ts.map +1 -1
- package/dist/internal/BoundVectorQuery.js +17 -5
- package/dist/internal/BoundVectorQuery.js.map +1 -1
- package/dist/internal/EntityCombinators.d.ts +8 -5
- package/dist/internal/EntityCombinators.d.ts.map +1 -1
- package/dist/internal/EntityCombinators.js +8 -5
- package/dist/internal/EntityCombinators.js.map +1 -1
- package/dist/internal/EntityOps.d.ts +1 -1
- package/dist/internal/Expr.d.ts +4 -0
- package/dist/internal/Expr.d.ts.map +1 -1
- package/dist/internal/Expr.js +6 -4
- package/dist/internal/Expr.js.map +1 -1
- package/dist/internal/ExpressionLimits.d.ts +45 -0
- package/dist/internal/ExpressionLimits.d.ts.map +1 -0
- package/dist/internal/ExpressionLimits.js +89 -0
- package/dist/internal/ExpressionLimits.js.map +1 -0
- package/dist/internal/Hydrate.d.ts +62 -0
- package/dist/internal/Hydrate.d.ts.map +1 -0
- package/dist/internal/Hydrate.js +191 -0
- package/dist/internal/Hydrate.js.map +1 -0
- package/dist/internal/ItemSize.d.ts +60 -24
- package/dist/internal/ItemSize.d.ts.map +1 -1
- package/dist/internal/ItemSize.js +122 -39
- package/dist/internal/ItemSize.js.map +1 -1
- package/dist/internal/TransactWriteOps.d.ts +22 -46
- package/dist/internal/TransactWriteOps.d.ts.map +1 -1
- package/dist/internal/TransactWriteOps.js +26 -95
- package/dist/internal/TransactWriteOps.js.map +1 -1
- package/dist/internal/WriteDiagnosis.d.ts +353 -0
- package/dist/internal/WriteDiagnosis.d.ts.map +1 -0
- package/dist/internal/WriteDiagnosis.js +1028 -0
- package/dist/internal/WriteDiagnosis.js.map +1 -0
- package/dist/internal/sparse_check.js +43 -79
- package/dist/internal/sparse_check.js.map +1 -1
- package/package.json +2 -2
package/dist/Aggregate.d.ts
CHANGED
|
@@ -300,8 +300,11 @@ interface AggregateConfig<_TSchema extends Schema.Top, TEdges extends Record<str
|
|
|
300
300
|
* the RCU cost of every assembly read.
|
|
301
301
|
*
|
|
302
302
|
* Only valid where the assembly query can be strongly consistent: the base table (no
|
|
303
|
-
* `collection.index`) or an LSI. DynamoDB rejects consistent reads against a GSI
|
|
304
|
-
*
|
|
303
|
+
* `collection.index`) or an LSI. DynamoDB rejects consistent reads against a GSI; with
|
|
304
|
+
* a GSI collection index, each assembly read fails with that rejection, named for the
|
|
305
|
+
* aggregate and the index (a `ValidationError`, `operation: "<op>.consistentRead"`;
|
|
306
|
+
* `delete`'s read keeps DynamoDB's `DynamoValidationError` tag). It is not refused at
|
|
307
|
+
* `make()` time (#144).
|
|
305
308
|
*/
|
|
306
309
|
readonly consistentRead?: boolean;
|
|
307
310
|
readonly context?: ReadonlyArray<string>;
|
package/dist/Aggregate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Aggregate.d.ts","sourceRoot":"","sources":["../src/Aggregate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAGtF,OAAO,KAAK,KAAK,kBAAkB,MAAM,yCAAyC,CAAA;AAGlF,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"Aggregate.d.ts","sourceRoot":"","sources":["../src/Aggregate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAGtF,OAAO,KAAK,KAAK,kBAAkB,MAAM,yCAAyC,CAAA;AAGlF,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,sBAAsB,EAGtB,KAAK,YAAY,EACjB,WAAW,EACX,oBAAoB,EACpB,eAAe,EAChB,MAAM,mCAAmC,CAAA;AAK1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAA;AAgBxF,OAAO,EACL,KAAK,OAAO,EAEZ,MAAM,EAIN,MAAM,EAEP,MAAM,QAAQ,CAAA;AA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,EAEvC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,GAC5C,SAAS,CACV,OAAO,EACP,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAC7D,CAAA;AA+tCD;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,SAAS,MAAM,CAAC,GAAG,EAAE,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAC3F,WAAW,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAC1C,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,GAAG,WAAW,CA2BrF,CAAA"}
|
package/dist/Aggregate.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { TypeId as SchemaAggregateTypeId } from "@effect-dynamodb/schema/Aggregate.js";
|
|
12
12
|
import * as DynamoModel from "@effect-dynamodb/schema/DynamoModel.js";
|
|
13
13
|
import { composeCollectionKey, composeKey } from "@effect-dynamodb/schema/DynamoSchema.js";
|
|
14
|
-
import { AggregateAssemblyError, AggregateDecompositionError, AggregateTransactionOverflow, ConditionalCheckFailed, DynamoError, RefNotFound, TransactionCancelled, ValidationError, } from "@effect-dynamodb/schema/Errors.js";
|
|
14
|
+
import { AggregateAssemblyError, AggregateDecompositionError, AggregateTransactionOverflow, ConditionalCheckFailed, DynamoError, DynamoValidationError, RefNotFound, TransactionCancelled, ValidationError, } from "@effect-dynamodb/schema/Errors.js";
|
|
15
15
|
import { makeCompositeKeyForm, toCompositeKeyRecord, } from "@effect-dynamodb/schema/internal/CompositeCodec.js";
|
|
16
16
|
import { buildDateTransform, containsWireTransform, matchDateRepresentation, optionalField, resolveSystemFields, substituteSchemaDeep, validateNoTransformOverride, } from "@effect-dynamodb/schema/internal/EntitySchemas.js";
|
|
17
17
|
import { extractArrayElement, getSchemaFields, hasEncodingTransformation, } from "@effect-dynamodb/schema/internal/SchemaAccessors.js";
|
|
@@ -23,6 +23,7 @@ import { fromDefinition as entityFromDefinition } from "./Entity.js";
|
|
|
23
23
|
import { compileExpr, createConditionOps, emptyPartProblem, isEmptyExpr, parseSimpleShorthand, } from "./internal/Expr.js";
|
|
24
24
|
import { createPathBuilder } from "./internal/PathBuilder.js";
|
|
25
25
|
import { generateTimestampPrimitive } from "./internal/TransactableOps.js";
|
|
26
|
+
import { diagnosedValidationError, diagnoseFailure, explainDiagnosis, mergeKeyAttributes, transactItemTarget, withCause, } from "./internal/WriteDiagnosis.js";
|
|
26
27
|
import { fromAttributeMap, toAttributeMap, toAttributeValue } from "./Marshaller.js";
|
|
27
28
|
import { resolvePrimaryKey } from "./Table.js";
|
|
28
29
|
// Internal modules (decomposed from Aggregate.ts)
|
|
@@ -443,6 +444,23 @@ const applyNodeAttrEncoders = (attrs, encoders) => {
|
|
|
443
444
|
// ---------------------------------------------------------------------------
|
|
444
445
|
const makeAggregate = (schema, config) => {
|
|
445
446
|
const aggregateName = config.root.entityType;
|
|
447
|
+
const groupKeys = {
|
|
448
|
+
pkField: config.pk.field,
|
|
449
|
+
// Every key attribute an aggregate item can carry: `pk` / `sk`, the
|
|
450
|
+
// collection index's PK and SK mirror, and the list index's (root items).
|
|
451
|
+
keys: mergeKeyAttributes({
|
|
452
|
+
partition: [
|
|
453
|
+
"pk",
|
|
454
|
+
config.pk.field,
|
|
455
|
+
...(config.list === undefined ? [] : [config.list.pk.field]),
|
|
456
|
+
],
|
|
457
|
+
sort: [
|
|
458
|
+
"sk",
|
|
459
|
+
...(config.collection.sk === undefined ? [] : [config.collection.sk.field]),
|
|
460
|
+
...(config.list === undefined ? [] : [config.list.sk.field]),
|
|
461
|
+
],
|
|
462
|
+
}),
|
|
463
|
+
};
|
|
446
464
|
const contextFields = config.context ?? [];
|
|
447
465
|
// Policy: aggregate fields that already carry a date transform schema
|
|
448
466
|
// (e.g. `Schema.DateTimeUtcFromString`) cannot be combined with a
|
|
@@ -508,14 +526,13 @@ const makeAggregate = (schema, config) => {
|
|
|
508
526
|
resolveRef,
|
|
509
527
|
enforceChecks: true,
|
|
510
528
|
});
|
|
511
|
-
// Validate the collection index
|
|
512
|
-
//
|
|
513
|
-
//
|
|
529
|
+
// Validate the collection index against the table's primary key. Best effort: a
|
|
530
|
+
// table registering only aggregates has no primary key to resolve, in which case
|
|
531
|
+
// the check is skipped rather than guessed at. `consistentRead` on a GSI collection
|
|
532
|
+
// index is not refused here: DynamoDB rejects the consistent read, and the
|
|
533
|
+
// assembly read diagnoses it, naming the aggregate and the index (#144).
|
|
514
534
|
const consistentRead = config.consistentRead ?? false;
|
|
515
535
|
const tablePrimary = resolvePrimaryKey(config.table.entities);
|
|
516
|
-
const collectionIsGsi = tablePrimary !== undefined &&
|
|
517
|
-
config.collection.index !== undefined &&
|
|
518
|
-
config.pk.field !== tablePrimary.pk;
|
|
519
536
|
if (tablePrimary !== undefined && config.collection.index === undefined) {
|
|
520
537
|
if (config.pk.field !== tablePrimary.pk) {
|
|
521
538
|
throw new Error(`[EDD-9041] Aggregate "${aggregateName}": collection PK field "${config.pk.field}" is ` +
|
|
@@ -530,14 +547,6 @@ const makeAggregate = (schema, config) => {
|
|
|
530
547
|
`sort by — declare both to assemble through an index, or neither to assemble off the ` +
|
|
531
548
|
`base table.`);
|
|
532
549
|
}
|
|
533
|
-
if (consistentRead && collectionIsGsi) {
|
|
534
|
-
throw new Error(`[EDD-9042] Aggregate "${aggregateName}": \`consistentRead\` is not supported against a ` +
|
|
535
|
-
`GSI. Collection index "${config.collection.index}" is partitioned by ` +
|
|
536
|
-
`"${config.pk.field}" rather than the table's primary partition key ` +
|
|
537
|
-
`("${tablePrimary?.pk}"), which makes it a GSI, and DynamoDB serves GSI reads as ` +
|
|
538
|
-
`eventually consistent only. Drop \`consistentRead\`, or key the aggregate on the ` +
|
|
539
|
-
`table's primary partition key so assembly reads the base table.`);
|
|
540
|
-
}
|
|
541
550
|
// System timestamps (#98). Aggregates compose their DynamoDB items directly
|
|
542
551
|
// rather than routing through Entity write ops, so Entity's timestamp
|
|
543
552
|
// machinery never reached these rows. Resolution goes through the SAME
|
|
@@ -622,15 +631,28 @@ const makeAggregate = (schema, config) => {
|
|
|
622
631
|
}
|
|
623
632
|
return toCompositeKeyRecord(compositeKeyForm, composites);
|
|
624
633
|
};
|
|
625
|
-
/**
|
|
626
|
-
|
|
634
|
+
/**
|
|
635
|
+
* DynamoDB's rejection of an assembly read (#144) — a consistent read of a
|
|
636
|
+
* GSI collection index — explained for the aggregate and its index.
|
|
637
|
+
*/
|
|
638
|
+
const assemblyReadCause = (operation, diagnosis, original) => withCause(`Aggregate "${aggregateName}" ${operation}: ${explainDiagnosis(diagnosis, operation)} ` +
|
|
639
|
+
"Drop `consistentRead` from the aggregate, or key it on the table's primary " +
|
|
640
|
+
"partition key so assembly reads the base table.", original);
|
|
641
|
+
/** Compose the PK and query all items; a rejected read fails as `rejected` names it. */
|
|
642
|
+
const readPartition = (key, rejected) => Effect.gen(function* () {
|
|
627
643
|
const client = yield* DynamoClient;
|
|
628
644
|
const tableConfig = yield* config.table.Tag;
|
|
629
645
|
const composites = KeyComposer.extractComposites(config.pk.composite, keyRecord(key));
|
|
630
646
|
const pkValue = composeCollectionKey(config.schema, config.collection.name, composites);
|
|
631
|
-
const allItems = yield* queryAllItems(client, tableConfig.name, config.collection.index, config.pk.field, pkValue, consistentRead);
|
|
647
|
+
const allItems = yield* queryAllItems(client, tableConfig.name, config.collection.index, config.pk.field, pkValue, consistentRead, rejected);
|
|
632
648
|
return { client, tableConfig, pkValue, composites, allItems };
|
|
633
649
|
});
|
|
650
|
+
/** Shared: compose PK and query all items, a rejected read a `ValidationError`. */
|
|
651
|
+
const fetchPartition = (key, operation) => readPartition(key, (diagnosis, original) => new ValidationError({
|
|
652
|
+
entityType: aggregateName,
|
|
653
|
+
operation: `${operation}.consistentRead`,
|
|
654
|
+
cause: assemblyReadCause(operation, diagnosis, original),
|
|
655
|
+
}));
|
|
634
656
|
const derivedSchemas = deriveAggregateSchemas(schema, config.edges, config.pk.composite);
|
|
635
657
|
return {
|
|
636
658
|
[TypeId]: TypeId,
|
|
@@ -654,7 +676,7 @@ const makeAggregate = (schema, config) => {
|
|
|
654
676
|
createSchema: derivedSchemas.inputSchema,
|
|
655
677
|
updateSchema: derivedSchemas.updateSchema,
|
|
656
678
|
get: (key) => Effect.gen(function* () {
|
|
657
|
-
const { allItems } = yield* fetchPartition(key);
|
|
679
|
+
const { allItems } = yield* fetchPartition(key, "get");
|
|
658
680
|
if (allItems.length === 0) {
|
|
659
681
|
return yield* new AggregateAssemblyError({
|
|
660
682
|
aggregate: aggregateName,
|
|
@@ -707,7 +729,7 @@ const makeAggregate = (schema, config) => {
|
|
|
707
729
|
puts: [...g.items].sort((a, b) => Number(isRoot(b)) - Number(isRoot(a))),
|
|
708
730
|
deletes: [],
|
|
709
731
|
}));
|
|
710
|
-
yield* writeTransactionGroups(client, tableConfig.name, ordered, aggregateName, {
|
|
732
|
+
yield* writeTransactionGroups(client, tableConfig.name, ordered, aggregateName, groupKeys, {
|
|
711
733
|
pkField: config.pk.field,
|
|
712
734
|
entityType: config.root.entityType,
|
|
713
735
|
key: { [config.pk.field]: pkValue, sk: rootSk },
|
|
@@ -715,7 +737,7 @@ const makeAggregate = (schema, config) => {
|
|
|
715
737
|
return decoded;
|
|
716
738
|
}),
|
|
717
739
|
update: (key, mutationFn) => Effect.gen(function* () {
|
|
718
|
-
const { client, tableConfig, pkValue, allItems } = yield* fetchPartition(key);
|
|
740
|
+
const { client, tableConfig, pkValue, allItems } = yield* fetchPartition(key, "update");
|
|
719
741
|
if (allItems.length === 0) {
|
|
720
742
|
return yield* new AggregateAssemblyError({
|
|
721
743
|
aggregate: aggregateName,
|
|
@@ -811,12 +833,18 @@ const makeAggregate = (schema, config) => {
|
|
|
811
833
|
groupWrites.push({ group: name, puts, deletes });
|
|
812
834
|
}
|
|
813
835
|
if (groupWrites.length > 0) {
|
|
814
|
-
yield* writeTransactionGroups(client, tableConfig.name, groupWrites, aggregateName);
|
|
836
|
+
yield* writeTransactionGroups(client, tableConfig.name, groupWrites, aggregateName, groupKeys);
|
|
815
837
|
}
|
|
816
838
|
return decoded;
|
|
817
839
|
}),
|
|
818
840
|
delete: (key) => Effect.gen(function* () {
|
|
819
|
-
const { client, tableConfig, allItems } = yield*
|
|
841
|
+
const { client, tableConfig, allItems } = yield* readPartition(key,
|
|
842
|
+
// `delete` declares no `ValidationError`: a rejected read keeps
|
|
843
|
+
// DynamoDB's own tag, its message explained.
|
|
844
|
+
(diagnosis, original) => new DynamoValidationError({
|
|
845
|
+
operation: "Query",
|
|
846
|
+
cause: assemblyReadCause("delete", diagnosis, original),
|
|
847
|
+
}));
|
|
820
848
|
if (allItems.length === 0) {
|
|
821
849
|
return yield* new AggregateAssemblyError({
|
|
822
850
|
aggregate: aggregateName,
|
|
@@ -908,7 +936,7 @@ const makeAggregate = (schema, config) => {
|
|
|
908
936
|
accept: options?.filterBy,
|
|
909
937
|
reverse: options?.reverse === true,
|
|
910
938
|
keyFields: listKeyFields,
|
|
911
|
-
});
|
|
939
|
+
}, aggregateName);
|
|
912
940
|
});
|
|
913
941
|
const shardResults = yield* Effect.all(shardQueries);
|
|
914
942
|
const merged = shardResults.flatMap((r) => r.items);
|
|
@@ -932,7 +960,7 @@ const makeAggregate = (schema, config) => {
|
|
|
932
960
|
accept: options?.filterBy,
|
|
933
961
|
reverse: options?.reverse === true,
|
|
934
962
|
keyFields: listKeyFields,
|
|
935
|
-
});
|
|
963
|
+
}, aggregateName);
|
|
936
964
|
rootItems = result.items;
|
|
937
965
|
nextKey = result.lastKey;
|
|
938
966
|
}
|
|
@@ -944,7 +972,7 @@ const makeAggregate = (schema, config) => {
|
|
|
944
972
|
key[composite] = rootItem[composite];
|
|
945
973
|
}
|
|
946
974
|
const assembled = yield* Effect.gen(function* () {
|
|
947
|
-
const { allItems } = yield* fetchPartition(key);
|
|
975
|
+
const { allItems } = yield* fetchPartition(key, "list");
|
|
948
976
|
if (allItems.length === 0)
|
|
949
977
|
return undefined;
|
|
950
978
|
const result = yield* assembleAggregate(decodeSchema, rootNode, allItems, contextFields, key, aggregateName, systemAttrs);
|
|
@@ -1125,14 +1153,16 @@ const resolveNode = (args) => {
|
|
|
1125
1153
|
// ---------------------------------------------------------------------------
|
|
1126
1154
|
// Internal: Query all items in the aggregate partition
|
|
1127
1155
|
// ---------------------------------------------------------------------------
|
|
1128
|
-
const queryAllItems = (client, tableName, indexName, pkField, pkValue, consistentRead
|
|
1156
|
+
const queryAllItems = (client, tableName, indexName, pkField, pkValue, consistentRead,
|
|
1157
|
+
/** A consistent read of a GSI, which DynamoDB rejects, as the caller names it (#144). */
|
|
1158
|
+
consistentReadRejected) => Effect.gen(function* () {
|
|
1129
1159
|
const allItems = [];
|
|
1130
1160
|
let exclusiveStartKey;
|
|
1131
1161
|
// Paginate through all results. Assembly needs every item in the partition and
|
|
1132
1162
|
// discriminates them by `__edd_e__`, so there is no sort-key condition and no
|
|
1133
1163
|
// ordering requirement — which is why `IndexName` is optional here.
|
|
1134
1164
|
do {
|
|
1135
|
-
const
|
|
1165
|
+
const input = {
|
|
1136
1166
|
TableName: tableName,
|
|
1137
1167
|
IndexName: indexName,
|
|
1138
1168
|
KeyConditionExpression: "#pk = :pk",
|
|
@@ -1140,7 +1170,12 @@ const queryAllItems = (client, tableName, indexName, pkField, pkValue, consisten
|
|
|
1140
1170
|
ExpressionAttributeValues: { ":pk": toAttributeValue(pkValue) },
|
|
1141
1171
|
ExclusiveStartKey: exclusiveStartKey,
|
|
1142
1172
|
ConsistentRead: consistentRead || undefined,
|
|
1143
|
-
}
|
|
1173
|
+
};
|
|
1174
|
+
const result = yield* client.query(input).pipe(diagnoseFailure({
|
|
1175
|
+
sent: () => ({ _tag: "Read", scan: false, input }),
|
|
1176
|
+
only: ["ConsistentReadOnGsi"],
|
|
1177
|
+
rewrite: consistentReadRejected,
|
|
1178
|
+
}));
|
|
1144
1179
|
if (result.Items) {
|
|
1145
1180
|
for (const item of result.Items) {
|
|
1146
1181
|
allItems.push(fromAttributeMap(item));
|
|
@@ -1996,24 +2031,14 @@ keyRecord, stamp) => groups.map((group) => ({
|
|
|
1996
2031
|
return toAttributeMap(attrs);
|
|
1997
2032
|
}),
|
|
1998
2033
|
}));
|
|
1999
|
-
function writeTransactionGroups(client, tableName, groups, aggregateName, rootGuard) {
|
|
2034
|
+
function writeTransactionGroups(client, tableName, groups, aggregateName, keys, rootGuard) {
|
|
2000
2035
|
return Effect.gen(function* () {
|
|
2001
|
-
//
|
|
2002
|
-
//
|
|
2003
|
-
//
|
|
2004
|
-
//
|
|
2005
|
-
//
|
|
2006
|
-
|
|
2007
|
-
const itemCount = group.puts.length + group.deletes.length;
|
|
2008
|
-
if (itemCount > 100) {
|
|
2009
|
-
return yield* new AggregateTransactionOverflow({
|
|
2010
|
-
aggregate: aggregateName,
|
|
2011
|
-
subgraph: group.group,
|
|
2012
|
-
itemCount,
|
|
2013
|
-
limit: 100,
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2036
|
+
// Each group is its own transaction (DynamoDB: 100 items per
|
|
2037
|
+
// TransactWriteItems, Puts AND Deletes together). DynamoDB's limits are
|
|
2038
|
+
// not pre-checked (#144): a group over one is sent, rejected whole, and
|
|
2039
|
+
// diagnosed — naming the sub-aggregates earlier groups already committed,
|
|
2040
|
+
// since a multi-group write was never atomic.
|
|
2041
|
+
const committed = [];
|
|
2017
2042
|
for (const [groupIndex, group] of groups.entries()) {
|
|
2018
2043
|
// Each group is one transaction — Puts AND Deletes applied atomically, so an
|
|
2019
2044
|
// edge add and a sibling edge removal in the same sub-aggregate commit together.
|
|
@@ -2040,7 +2065,45 @@ function writeTransactionGroups(client, tableName, groups, aggregateName, rootGu
|
|
|
2040
2065
|
})),
|
|
2041
2066
|
...group.deletes.map((key) => ({ Delete: { TableName: tableName, Key: key } })),
|
|
2042
2067
|
];
|
|
2043
|
-
|
|
2068
|
+
// Named once, for both diagnoses below.
|
|
2069
|
+
const sent = () => ({
|
|
2070
|
+
_tag: "Transaction",
|
|
2071
|
+
items: transactItems,
|
|
2072
|
+
targets: () => transactItems.map((item) => {
|
|
2073
|
+
const entityType = item.Put?.Item?.__edd_e__?.S ?? aggregateName;
|
|
2074
|
+
return transactItemTarget(item, tableName, [keys.pkField, "sk"], entityType, `the ${item.Put !== undefined ? entityType : "removed"} item of ` +
|
|
2075
|
+
`sub-aggregate "${group.group}"`);
|
|
2076
|
+
}),
|
|
2077
|
+
});
|
|
2078
|
+
const already = [...committed];
|
|
2079
|
+
const diagnosed = (diagnosis, original) => diagnosis._tag === "TooManyItems"
|
|
2080
|
+
? new AggregateTransactionOverflow({
|
|
2081
|
+
aggregate: aggregateName,
|
|
2082
|
+
subgraph: group.group,
|
|
2083
|
+
itemCount: diagnosis.count,
|
|
2084
|
+
limit: diagnosis.limit,
|
|
2085
|
+
committed: already,
|
|
2086
|
+
operation: rootGuard !== undefined ? "create" : "update",
|
|
2087
|
+
cause: original,
|
|
2088
|
+
})
|
|
2089
|
+
: diagnosedValidationError(diagnosis, original, {
|
|
2090
|
+
operation: `Aggregate.write(${aggregateName})`,
|
|
2091
|
+
entityType: aggregateName,
|
|
2092
|
+
// Each group commits on its own: say exactly what already did.
|
|
2093
|
+
...(already.length > 0 && {
|
|
2094
|
+
committed: `earlier transactions of this write already committed sub-aggregates ` +
|
|
2095
|
+
already.map((name) => `"${name}"`).join(", ") +
|
|
2096
|
+
(rootGuard !== undefined
|
|
2097
|
+
? ", so a retried create fails on the existing root: update or delete " +
|
|
2098
|
+
"the partial aggregate instead"
|
|
2099
|
+
: ""),
|
|
2100
|
+
}),
|
|
2101
|
+
});
|
|
2102
|
+
yield* client.transactWriteItems({ TransactItems: transactItems }).pipe(
|
|
2103
|
+
// One operation per item (#144): diagnosed BEFORE the root guard's
|
|
2104
|
+
// mapping, which would read a repeat's conditional failure as an
|
|
2105
|
+
// existing root.
|
|
2106
|
+
diagnoseFailure({ sent, only: ["RepeatedItem"], rewrite: diagnosed }), Effect.mapError((error) => {
|
|
2044
2107
|
if (error.cause != null &&
|
|
2045
2108
|
typeof error.cause === "object" &&
|
|
2046
2109
|
"name" in error.cause &&
|
|
@@ -2064,7 +2127,11 @@ function writeTransactionGroups(client, tableName, groups, aggregateName, rootGu
|
|
|
2064
2127
|
});
|
|
2065
2128
|
}
|
|
2066
2129
|
return error;
|
|
2067
|
-
})
|
|
2130
|
+
}),
|
|
2131
|
+
// A limit DynamoDB enforced (#144), named — after the root guard's
|
|
2132
|
+
// mapping, which a conditional failure always takes.
|
|
2133
|
+
diagnoseFailure({ sent, keys: () => keys.keys, rewrite: diagnosed }));
|
|
2134
|
+
committed.push(group.group);
|
|
2068
2135
|
}
|
|
2069
2136
|
});
|
|
2070
2137
|
}
|
|
@@ -2089,6 +2156,9 @@ const deleteAllItems = (client, tableName, allItems, pkField) => Effect.gen(func
|
|
|
2089
2156
|
let pending = deleteRequests.slice(i, i + 25);
|
|
2090
2157
|
let retries = 0;
|
|
2091
2158
|
while (pending.length > 0) {
|
|
2159
|
+
// Not diagnosed (#144): these are deletes of keys that were stored, so
|
|
2160
|
+
// they cannot meet a size or sort-key limit, and `delete`'s error
|
|
2161
|
+
// channel has no `ValidationError` to carry one.
|
|
2092
2162
|
const response = yield* client.batchWriteItem({
|
|
2093
2163
|
RequestItems: { [tableName]: pending },
|
|
2094
2164
|
});
|
|
@@ -2121,8 +2191,9 @@ const DELETE_BASE_DELAY_MS = 100;
|
|
|
2121
2191
|
* the same thing here as they do on an entity query, under the same empty-part
|
|
2122
2192
|
* rules (#134): a filter that asserts nothing (`{}`, `and()`) is no filter, an
|
|
2123
2193
|
* empty part directly under `and` is left out, and one anywhere else — or an
|
|
2124
|
-
* `or()` with no parts
|
|
2125
|
-
* `
|
|
2194
|
+
* `or()` with no parts — is refused with a `ValidationError` before anything
|
|
2195
|
+
* is sent. An `isIn` with no values is sent, and DynamoDB's rejection of its
|
|
2196
|
+
* `IN ()` diagnosed (#144).
|
|
2126
2197
|
*/
|
|
2127
2198
|
const compileListFilter = (filter, aggregateName) => {
|
|
2128
2199
|
if (filter === undefined)
|
|
@@ -2173,7 +2244,7 @@ const listKeyFromItem = (item, names) => {
|
|
|
2173
2244
|
}
|
|
2174
2245
|
return key;
|
|
2175
2246
|
};
|
|
2176
|
-
const queryListPartition = (client, tableConfig, listConfig, schema, options) => Effect.gen(function* () {
|
|
2247
|
+
const queryListPartition = (client, tableConfig, listConfig, schema, options, aggregateName) => Effect.gen(function* () {
|
|
2177
2248
|
const { filter, limit, pkValue, skValues } = options;
|
|
2178
2249
|
const exprNames = { "#pk": listConfig.pk.field };
|
|
2179
2250
|
const exprValues = { ":pk": toAttributeValue(pkValue) };
|
|
@@ -2196,7 +2267,7 @@ const queryListPartition = (client, tableConfig, listConfig, schema, options) =>
|
|
|
2196
2267
|
for (;;) {
|
|
2197
2268
|
const remaining = limit === undefined ? undefined : limit - items.length;
|
|
2198
2269
|
const requestLimit = listRequestLimit(options, remaining);
|
|
2199
|
-
const
|
|
2270
|
+
const input = {
|
|
2200
2271
|
TableName: tableConfig.name,
|
|
2201
2272
|
IndexName: listConfig.index,
|
|
2202
2273
|
KeyConditionExpression: keyCondition,
|
|
@@ -2206,7 +2277,19 @@ const queryListPartition = (client, tableConfig, listConfig, schema, options) =>
|
|
|
2206
2277
|
...(filter !== undefined ? { FilterExpression: filter.expression } : {}),
|
|
2207
2278
|
...(requestLimit !== undefined ? { Limit: requestLimit } : {}),
|
|
2208
2279
|
...(options.reverse === true ? { ScanIndexForward: false } : {}),
|
|
2209
|
-
}
|
|
2280
|
+
};
|
|
2281
|
+
const result = yield* client.query(input).pipe(
|
|
2282
|
+
// DynamoDB's rejection of the filter's `IN ()` (an `isIn` with no
|
|
2283
|
+
// values), not pre-checked, is named (#144).
|
|
2284
|
+
diagnoseFailure({
|
|
2285
|
+
sent: () => ({ _tag: "Read", scan: false, input }),
|
|
2286
|
+
only: ["EmptyIn"],
|
|
2287
|
+
rewrite: (diagnosis, original) => new ValidationError({
|
|
2288
|
+
entityType: aggregateName,
|
|
2289
|
+
operation: "list.filter",
|
|
2290
|
+
cause: withCause(explainDiagnosis(diagnosis, `Aggregate "${aggregateName}" list`), original),
|
|
2291
|
+
}),
|
|
2292
|
+
}));
|
|
2210
2293
|
const returned = (result.Items ?? []);
|
|
2211
2294
|
const lastEvaluatedKey = result.LastEvaluatedKey;
|
|
2212
2295
|
// Without a client-side predicate every returned row is kept, so the take
|