effect-dynamodb 1.10.0 → 1.12.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.
Files changed (51) hide show
  1. package/dist/DynamoClient.d.ts +88 -5
  2. package/dist/DynamoClient.d.ts.map +1 -1
  3. package/dist/DynamoClient.js +158 -4
  4. package/dist/DynamoClient.js.map +1 -1
  5. package/dist/Entity.d.ts +35 -17
  6. package/dist/Entity.d.ts.map +1 -1
  7. package/dist/Entity.js +499 -9
  8. package/dist/Entity.js.map +1 -1
  9. package/dist/EventStore.d.ts +242 -35
  10. package/dist/EventStore.d.ts.map +1 -1
  11. package/dist/EventStore.js +516 -72
  12. package/dist/EventStore.js.map +1 -1
  13. package/dist/Table.d.ts +78 -0
  14. package/dist/Table.d.ts.map +1 -1
  15. package/dist/Table.js +153 -0
  16. package/dist/Table.js.map +1 -1
  17. package/dist/Transaction.d.ts +3 -18
  18. package/dist/Transaction.d.ts.map +1 -1
  19. package/dist/Transaction.js +13 -74
  20. package/dist/Transaction.js.map +1 -1
  21. package/dist/VectorSearchEmulation.d.ts +101 -0
  22. package/dist/VectorSearchEmulation.d.ts.map +1 -0
  23. package/dist/VectorSearchEmulation.js +290 -0
  24. package/dist/VectorSearchEmulation.js.map +1 -0
  25. package/dist/index.d.ts +9 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +4 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/internal/BoundCrud.d.ts +62 -48
  30. package/dist/internal/BoundCrud.d.ts.map +1 -1
  31. package/dist/internal/BoundCrud.js +7 -1
  32. package/dist/internal/BoundCrud.js.map +1 -1
  33. package/dist/internal/BoundVectorQuery.d.ts +130 -0
  34. package/dist/internal/BoundVectorQuery.d.ts.map +1 -0
  35. package/dist/internal/BoundVectorQuery.js +257 -0
  36. package/dist/internal/BoundVectorQuery.js.map +1 -0
  37. package/dist/internal/EntityCombinators.d.ts +16 -0
  38. package/dist/internal/EntityCombinators.d.ts.map +1 -1
  39. package/dist/internal/EntityCombinators.js +25 -1
  40. package/dist/internal/EntityCombinators.js.map +1 -1
  41. package/dist/internal/EntityOps.d.ts +19 -6
  42. package/dist/internal/EntityOps.d.ts.map +1 -1
  43. package/dist/internal/EntityOps.js +5 -2
  44. package/dist/internal/EntityOps.js.map +1 -1
  45. package/dist/internal/TransactWriteOps.d.ts +50 -0
  46. package/dist/internal/TransactWriteOps.d.ts.map +1 -0
  47. package/dist/internal/TransactWriteOps.js +102 -0
  48. package/dist/internal/TransactWriteOps.js.map +1 -0
  49. package/dist/internal/TransactableOps.d.ts +1 -1
  50. package/dist/internal/TransactableOps.d.ts.map +1 -1
  51. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactWriteOps.d.ts","sourceRoot":"","sources":["../../src/internal/TransactWriteOps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAO9C,gBAAgB;AAChB,eAAO,MAAM,oBAAoB,EAAE,OAAO,MAAqD,CAAA;AAC/F,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAA;AAE9D;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;CACtC;AAED,gEAAgE;AAChE,YAAY,EAAE,iBAAiB,EAAE,CAAA;AAEjC;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAC7B,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,GACtB,gBAAgB,CAAA;AAMpB;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAClC,YAAY,aAAa,CAAC,eAAe,CAAC,EAC1C,WAAW,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,eAAe,EAAE,WAAW,CAkFnE,CAAA"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @internal Shared `TransactWriteItems` item-building for `Transaction.transactWrite`
3
+ * and `EventStore.append`'s `additionalItems`.
4
+ *
5
+ * The builder is a pure compile step — its `R` is `TableConfig` only (no
6
+ * `DynamoClient`) — so both call sites can assemble items before deciding what
7
+ * to do with them (execute directly, or merge into a larger transaction).
8
+ *
9
+ * Keeping one builder is what lets `EventStore.append({ additionalItems })` and
10
+ * `Transaction.transactWrite` accept exactly the same op union: they cannot
11
+ * drift, and support added here (e.g. `EntityUpdate`) lands for both at once.
12
+ */
13
+ import { ValidationError } from "@effect-dynamodb/schema/Errors.js";
14
+ import { Effect } from "effect";
15
+ import { extractTransactable } from "../Entity.js";
16
+ import { toAttributeMap } from "../Marshaller.js";
17
+ import { composePrimaryKey, resolveTableNames, validateAndBuildPutItem } from "./TransactableOps.js";
18
+ // ---------------------------------------------------------------------------
19
+ // ConditionCheck — composable from EntityGet + condition expression
20
+ // ---------------------------------------------------------------------------
21
+ /** @internal */
22
+ export const ConditionCheckTypeId = Symbol.for("effect-dynamodb/ConditionCheck");
23
+ // ---------------------------------------------------------------------------
24
+ // buildTransactWriteItems
25
+ // ---------------------------------------------------------------------------
26
+ /**
27
+ * Compile a list of Entity write ops into marshalled `TransactWriteItems` entries,
28
+ * preserving caller order (positions are load-bearing: `EventStore.append` maps
29
+ * `CancellationReasons` back to `additionalItems` indices by position).
30
+ *
31
+ * Does NOT enforce `TRANSACT_WRITE_ITEMS_LIMIT` — the caller counts, because the
32
+ * total may include items this builder never sees (event puts, dedup sentinels).
33
+ */
34
+ export const buildTransactWriteItems = (operations, operation) => Effect.gen(function* () {
35
+ if (operations.length === 0)
36
+ return [];
37
+ const opInfos = [];
38
+ for (const op of operations) {
39
+ // Check for ConditionCheckOp first (has its own TypeId)
40
+ if (op != null && typeof op === "object" && ConditionCheckTypeId in op) {
41
+ const checkOp = op;
42
+ opInfos.push({
43
+ type: "conditionCheck",
44
+ entity: checkOp._entity,
45
+ key: checkOp._key,
46
+ condition: checkOp._condition,
47
+ });
48
+ continue;
49
+ }
50
+ const info = extractTransactable(op);
51
+ if (!info) {
52
+ return yield* new ValidationError({
53
+ entityType: "unknown",
54
+ operation,
55
+ cause: `${operation}: unrecognized operation type. Use EntityPut, EntityDelete, or Transaction.check().`,
56
+ });
57
+ }
58
+ if (info.opType === "put") {
59
+ opInfos.push({ type: "put", entity: info.entity, input: info.input });
60
+ }
61
+ else if (info.opType === "delete") {
62
+ opInfos.push({ type: "delete", entity: info.entity, key: info.key });
63
+ }
64
+ else {
65
+ return yield* new ValidationError({
66
+ entityType: info.entity.entityType,
67
+ operation,
68
+ cause: `${operation}: unsupported operation type "${info.opType}". Use EntityPut, EntityDelete, or Transaction.check().`,
69
+ });
70
+ }
71
+ }
72
+ const tableNames = yield* resolveTableNames(opInfos);
73
+ const transactItems = [];
74
+ for (const op of opInfos) {
75
+ const tableName = tableNames.get(op.entity);
76
+ if (op.type === "put") {
77
+ const marshalledItem = yield* validateAndBuildPutItem(op.entity, op.input, `${operation}.put`);
78
+ transactItems.push({ Put: { TableName: tableName, Item: marshalledItem } });
79
+ }
80
+ else if (op.type === "delete") {
81
+ transactItems.push({
82
+ Delete: {
83
+ TableName: tableName,
84
+ Key: toAttributeMap(composePrimaryKey(op.entity, op.key)),
85
+ },
86
+ });
87
+ }
88
+ else {
89
+ transactItems.push({
90
+ ConditionCheck: {
91
+ TableName: tableName,
92
+ Key: toAttributeMap(composePrimaryKey(op.entity, op.key)),
93
+ ConditionExpression: op.condition.expression,
94
+ ExpressionAttributeNames: op.condition.names,
95
+ ExpressionAttributeValues: op.condition.values,
96
+ },
97
+ });
98
+ }
99
+ }
100
+ return transactItems;
101
+ });
102
+ //# sourceMappingURL=TransactWriteOps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactWriteOps.js","sourceRoot":"","sources":["../../src/internal/TransactWriteOps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAEpG,8EAA8E;AAC9E,oEAAoE;AACpE,8EAA8E;AAE9E,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAkB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;AA4B/F,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,UAA0C,EAC1C,SAAiB,EACsD,EAAE,CACzE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAEtC,MAAM,OAAO,GAMR,EAAE,CAAA;IAEP,KAAK,MAAM,EAAE,IAAI,UA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A;QACJ,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAA;AACtB,CAAC,CAAC,CAAA"}
@@ -25,7 +25,7 @@ export declare const generateTimestampPrimitive: (now: DateTime.Utc, encoding: D
25
25
  */
26
26
  export declare const resolveTableNames: (infos: ReadonlyArray<{
27
27
  readonly entity: Entity;
28
- }>) => Effect.Effect<Map<Entity<Schema.Top, string, Record<string, KeyComposer.IndexDefinition>, import("@effect-dynamodb/schema/internal/EntityConfig.js").TimestampsConfig | undefined, import("@effect-dynamodb/schema/internal/EntityConfig.js").VersionedConfig | undefined, import("@effect-dynamodb/schema/internal/EntityConfig.js").SoftDeleteConfig | undefined, import("@effect-dynamodb/schema/internal/EntityConfig.js").UniqueConfig | undefined, undefined, undefined, undefined, undefined>, string>, never, import("../Table.js").TableConfig>;
28
+ }>) => Effect.Effect<Map<Entity<Schema.Top, string, Record<string, KeyComposer.IndexDefinition>, import("@effect-dynamodb/schema/internal/EntityConfig.js").TimestampsConfig | undefined, import("@effect-dynamodb/schema/internal/EntityConfig.js").VersionedConfig | undefined, import("@effect-dynamodb/schema/internal/EntityConfig.js").SoftDeleteConfig | undefined, import("@effect-dynamodb/schema/internal/EntityConfig.js").UniqueConfig | undefined, undefined, undefined, undefined, undefined, undefined>, string>, never, import("../Table.js").TableConfig>;
29
29
  /**
30
30
  * Compose the primary key for an entity item.
31
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TransactableOps.d.ts","sourceRoot":"","sources":["../../src/internal/TransactableOps.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,WAAW,MAAM,wCAAwC,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,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iBAAiB,GAAI,OAAO,aAAa,CAAC;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,wiBAU/E,CAAA;AAEJ;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EACd,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAOxB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,EACd,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,WAAW,MAAM,KAChB,MAAM,CAAC,MAAM,CACd,MAAM,CAAC,MAAM,EAAE,OAAO,0BAA0B,EAAE,cAAc,CAAC,EACjE,eAAe,CAkEb,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect-dynamodb",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Effect TS ORM for DynamoDB — schema-driven entity modeling, single-table design, composite keys, transactions, and Stream-based pagination",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,9 +46,9 @@
46
46
  "LICENSE"
47
47
  ],
48
48
  "dependencies": {
49
- "@aws-sdk/client-dynamodb": "^3.700.0",
49
+ "@aws-sdk/client-dynamodb": "^3.1104.0",
50
50
  "@aws-sdk/util-dynamodb": "^3.700.0",
51
- "@effect-dynamodb/schema": "^1.10.0"
51
+ "@effect-dynamodb/schema": "^1.12.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "effect": "^4.0.0-rc.109"