effect-dynamodb 1.37.0 → 1.38.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/DynamoClient.d.ts +6 -5
- package/dist/DynamoClient.d.ts.map +1 -1
- package/dist/DynamoClient.js +7 -6
- package/dist/DynamoClient.js.map +1 -1
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +15 -18
- package/dist/Entity.js.map +1 -1
- package/dist/EventStore.d.ts +8 -8
- package/dist/EventStore.js +2 -2
- package/dist/internal/TransactableOps.d.ts +2 -2
- package/dist/internal/TransactableOps.d.ts.map +1 -1
- package/dist/internal/TransactableOps.js +5 -5
- package/dist/internal/TransactableOps.js.map +1 -1
- package/package.json +5 -5
package/dist/Entity.js
CHANGED
|
@@ -17,7 +17,8 @@ import * as KeyText136 from "@effect-dynamodb/schema/internal/KeyText136.js";
|
|
|
17
17
|
import * as KeyComposer from "@effect-dynamodb/schema/KeyComposer.js";
|
|
18
18
|
import { normalizeGsiConfig } from "@effect-dynamodb/schema/KeyComposer.js";
|
|
19
19
|
import { deriveSourceText } from "@effect-dynamodb/schema/VectorIndex.js";
|
|
20
|
-
import { Cause, Context,
|
|
20
|
+
import { Cause, Context, Data, DateTime, Effect, Equal, Option, Schema, Stream, } from "effect";
|
|
21
|
+
import { SecureRandom } from "effect/crypto";
|
|
21
22
|
import { attributeValueEquals } from "./internal/AttributeValueEquals.js";
|
|
22
23
|
import { isBoundOp, makeBoundAppend, makeBoundDelete, makeBoundGet, makeBoundPut, makeBoundUpdate, } from "./internal/BoundCrud.js";
|
|
23
24
|
import { BoundQueryImpl, entityNaming, } from "./internal/BoundQuery.js";
|
|
@@ -1041,11 +1042,11 @@ const makeImpl = (config, precomputedData) => {
|
|
|
1041
1042
|
});
|
|
1042
1043
|
/**
|
|
1043
1044
|
* Fill the auto-generated id field on the raw `put` input when configured and
|
|
1044
|
-
* absent. Sources a UUID from the bundled `
|
|
1045
|
+
* absent. Sources a UUID from the bundled `SecureRandom` service. Caller-supplied
|
|
1045
1046
|
* values are respected (never overwritten). Returns the input unchanged when
|
|
1046
|
-
* `generatedId` is not configured — entities without it never touch
|
|
1047
|
+
* `generatedId` is not configured — entities without it never touch SecureRandom.
|
|
1047
1048
|
*
|
|
1048
|
-
* `
|
|
1049
|
+
* `SecureRandom` is provided from the context `DynamoClient.make` bundles,
|
|
1049
1050
|
* so the bound `put` stays `R = never` despite this yield.
|
|
1050
1051
|
*/
|
|
1051
1052
|
const fillGeneratedId = (input) => {
|
|
@@ -1058,14 +1059,10 @@ const makeImpl = (config, precomputedData) => {
|
|
|
1058
1059
|
return Effect.succeed(input);
|
|
1059
1060
|
}
|
|
1060
1061
|
return Effect.gen(function* () {
|
|
1061
|
-
const
|
|
1062
|
-
const id = generatedIdVersion === "v7" ? yield*
|
|
1062
|
+
const random = yield* SecureRandom.SecureRandom;
|
|
1063
|
+
const id = generatedIdVersion === "v7" ? yield* random.uuidV7() : yield* random.uuidV4();
|
|
1063
1064
|
return { ...rec, [generatedIdField]: id };
|
|
1064
|
-
})
|
|
1065
|
-
// randomUUIDv4/v7 surface a PlatformError; the global Crypto wrapper never
|
|
1066
|
-
// fails in practice, so collapse it to a defect rather than widening the
|
|
1067
|
-
// put error channel.
|
|
1068
|
-
Effect.orDie);
|
|
1065
|
+
});
|
|
1069
1066
|
};
|
|
1070
1067
|
/**
|
|
1071
1068
|
* The model fields with a decoding default (`Schema.withDecodingDefault` and
|
|
@@ -4101,7 +4098,7 @@ const makeImpl = (config, precomputedData) => {
|
|
|
4101
4098
|
// Auto-generated id: fill the configured primary-key field with a
|
|
4102
4099
|
// fresh UUID BEFORE the encode, but only when the caller omitted it —
|
|
4103
4100
|
// a caller-supplied value is always respected. The id is sourced from
|
|
4104
|
-
// the bundled
|
|
4101
|
+
// the bundled SecureRandom service (`DynamoClient.make` provides a default),
|
|
4105
4102
|
// so this keeps the bound `put` at `R = never`. The filled id then
|
|
4106
4103
|
// flows through input validation → key composition → stored item →
|
|
4107
4104
|
// returned record in this same pass.
|
|
@@ -9732,19 +9729,19 @@ const makeImpl = (config, precomputedData) => {
|
|
|
9732
9729
|
* @internal Used by `DynamoClient.make()` to bind entities.
|
|
9733
9730
|
*/
|
|
9734
9731
|
export const bind = (entity) => Effect.gen(function* () {
|
|
9735
|
-
// Bundle a default `
|
|
9732
|
+
// Bundle a default `SecureRandom` service into the captured context. This is how
|
|
9736
9733
|
// `generatedId` put auto-fills a UUID while keeping bound `put` at
|
|
9737
|
-
// `R = never`: the entity op yields `
|
|
9734
|
+
// `R = never`: the entity op yields `SecureRandom`, and `provide` supplies
|
|
9738
9735
|
// it from this bundled context rather than surfacing it as a requirement.
|
|
9739
|
-
// The `provide` helper is widened to admit `
|
|
9740
|
-
//
|
|
9736
|
+
// The `provide` helper is widened to admit `SecureRandom` so the
|
|
9737
|
+
// SecureRandom-requiring entity ops typecheck. A platform override supplied via
|
|
9741
9738
|
// `DynamoClient.make({ crypto })` is already in `baseCtx` and is respected
|
|
9742
9739
|
// (we only fill the default when absent). See `DESIGN.md`.
|
|
9743
9740
|
// Detached: no current operation or parent span is pinned for later calls (#174).
|
|
9744
9741
|
const baseCtx = Capacity.detachContext(yield* Effect.context());
|
|
9745
|
-
const ctx = Option.isSome(Context.getOption(baseCtx,
|
|
9742
|
+
const ctx = Option.isSome(Context.getOption(baseCtx, SecureRandom.SecureRandom))
|
|
9746
9743
|
? baseCtx
|
|
9747
|
-
: Context.add(baseCtx,
|
|
9744
|
+
: Context.add(baseCtx, SecureRandom.SecureRandom, makeDefaultCrypto());
|
|
9748
9745
|
const provide = (effect) => Effect.provide(effect, ctx);
|
|
9749
9746
|
// Sparse-field map (if any) — extracted from the Entity's configured model
|
|
9750
9747
|
// so the PathBuilder used by `.condition((t, ops) => ...)` exposes
|