@effect-dynamodb/schema 1.9.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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/Aggregate.d.ts +128 -0
- package/dist/Aggregate.d.ts.map +1 -0
- package/dist/Aggregate.js +69 -0
- package/dist/Aggregate.js.map +1 -0
- package/dist/DynamoModel.d.ts +370 -0
- package/dist/DynamoModel.d.ts.map +1 -0
- package/dist/DynamoModel.js +541 -0
- package/dist/DynamoModel.js.map +1 -0
- package/dist/DynamoSchema.d.ts +137 -0
- package/dist/DynamoSchema.d.ts.map +1 -0
- package/dist/DynamoSchema.js +188 -0
- package/dist/DynamoSchema.js.map +1 -0
- package/dist/Entity.d.ts +239 -0
- package/dist/Entity.d.ts.map +1 -0
- package/dist/Entity.js +558 -0
- package/dist/Entity.js.map +1 -0
- package/dist/Errors.d.ts +387 -0
- package/dist/Errors.d.ts.map +1 -0
- package/dist/Errors.js +218 -0
- package/dist/Errors.js.map +1 -0
- package/dist/KeyComposer.d.ts +264 -0
- package/dist/KeyComposer.d.ts.map +1 -0
- package/dist/KeyComposer.js +516 -0
- package/dist/KeyComposer.js.map +1 -0
- package/dist/Projection.d.ts +28 -0
- package/dist/Projection.d.ts.map +1 -0
- package/dist/Projection.js +39 -0
- package/dist/Projection.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/AggregateCursor.d.ts +44 -0
- package/dist/internal/AggregateCursor.d.ts.map +1 -0
- package/dist/internal/AggregateCursor.js +18 -0
- package/dist/internal/AggregateCursor.js.map +1 -0
- package/dist/internal/AggregateEdges.d.ts +117 -0
- package/dist/internal/AggregateEdges.d.ts.map +1 -0
- package/dist/internal/AggregateEdges.js +51 -0
- package/dist/internal/AggregateEdges.js.map +1 -0
- package/dist/internal/AggregateSchemas.d.ts +76 -0
- package/dist/internal/AggregateSchemas.d.ts.map +1 -0
- package/dist/internal/AggregateSchemas.js +164 -0
- package/dist/internal/AggregateSchemas.js.map +1 -0
- package/dist/internal/AggregateTypes.d.ts +132 -0
- package/dist/internal/AggregateTypes.d.ts.map +1 -0
- package/dist/internal/AggregateTypes.js +7 -0
- package/dist/internal/AggregateTypes.js.map +1 -0
- package/dist/internal/DefaultCrypto.d.ts +26 -0
- package/dist/internal/DefaultCrypto.d.ts.map +1 -0
- package/dist/internal/DefaultCrypto.js +40 -0
- package/dist/internal/DefaultCrypto.js.map +1 -0
- package/dist/internal/EntityConfig.d.ts +152 -0
- package/dist/internal/EntityConfig.d.ts.map +1 -0
- package/dist/internal/EntityConfig.js +7 -0
- package/dist/internal/EntityConfig.js.map +1 -0
- package/dist/internal/EntitySchemas.d.ts +198 -0
- package/dist/internal/EntitySchemas.d.ts.map +1 -0
- package/dist/internal/EntitySchemas.js +798 -0
- package/dist/internal/EntitySchemas.js.map +1 -0
- package/dist/internal/EntityTypes.d.ts +233 -0
- package/dist/internal/EntityTypes.d.ts.map +1 -0
- package/dist/internal/EntityTypes.js +7 -0
- package/dist/internal/EntityTypes.js.map +1 -0
- package/dist/internal/SchemaAccessors.d.ts +90 -0
- package/dist/internal/SchemaAccessors.d.ts.map +1 -0
- package/dist/internal/SchemaAccessors.js +171 -0
- package/dist/internal/SchemaAccessors.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DynamoModel — Schema annotations, date schemas, and model configuration for effect-dynamodb.
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - `configure` — per-field DynamoDB overrides (field rename, storage encoding, immutable, identifier, ref)
|
|
6
|
+
* - `Hidden` annotation — marks fields as excluded from default decode (asModel/asRecord)
|
|
7
|
+
* - `DynamoEncoding` annotation — controls how date fields are stored in DynamoDB
|
|
8
|
+
* - Date schemas — wire ↔ domain ↔ storage transformations for DateTime.Utc, DateTime.Zoned, Date
|
|
9
|
+
* - `storedAs` modifier — overrides DynamoDB storage format via annotation
|
|
10
|
+
* - `SparseMap()` — opt a `Schema.Record` field into flattened storage (one
|
|
11
|
+
* top-level attribute per entry)
|
|
12
|
+
*
|
|
13
|
+
* See docs/design-dynamo-model.md for the three-layer model (wire → domain → storage).
|
|
14
|
+
*/
|
|
15
|
+
import { DateTime, Effect, Option, Schema, SchemaAST, SchemaGetter, SchemaIssue } from "effect";
|
|
16
|
+
import { getSchemaFields, recordValueAst, recordValueAstFromAst, } from "./internal/SchemaAccessors.js";
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Identifier annotation
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
/** Unique symbol for the Identifier annotation */
|
|
21
|
+
const IdentifierId = Symbol.for("effect-dynamodb/Identifier");
|
|
22
|
+
/**
|
|
23
|
+
* Mark a schema field as the primary identifier for ref resolution.
|
|
24
|
+
*
|
|
25
|
+
* Entities that can be referenced via `DynamoModel.ref` must annotate exactly
|
|
26
|
+
* one field with `identifier`. The annotated field should be a string or
|
|
27
|
+
* branded string type.
|
|
28
|
+
*/
|
|
29
|
+
export const identifier = (schema) => schema.pipe(Schema.annotate({ [IdentifierId]: true }));
|
|
30
|
+
/**
|
|
31
|
+
* Check if a schema field has the Identifier annotation.
|
|
32
|
+
*/
|
|
33
|
+
export const isIdentifier = (schema) => SchemaAST.resolve(schema.ast)?.[IdentifierId] ?? false;
|
|
34
|
+
/**
|
|
35
|
+
* Find the identifier field in a schema with `.fields` (Schema.Class or Schema.Struct).
|
|
36
|
+
* Checks both schema-level `DynamoModel.identifier` annotations and ConfiguredModel
|
|
37
|
+
* `identifier: true` overrides.
|
|
38
|
+
*
|
|
39
|
+
* Returns the field name and schema, or undefined if no field has the identifier annotation.
|
|
40
|
+
*/
|
|
41
|
+
export const getIdentifierField = (model) => {
|
|
42
|
+
// Check ConfiguredModel attributes first (configure-level overrides take precedence)
|
|
43
|
+
if (isConfiguredModel(model)) {
|
|
44
|
+
const configured = model;
|
|
45
|
+
for (const [name, attr] of Object.entries(configured.attributes)) {
|
|
46
|
+
if (attr.identifier) {
|
|
47
|
+
const fields = getSchemaFields(configured.model);
|
|
48
|
+
if (fields) {
|
|
49
|
+
const fieldSchema = fields[name];
|
|
50
|
+
if (fieldSchema)
|
|
51
|
+
return { name, schema: fieldSchema };
|
|
52
|
+
}
|
|
53
|
+
// Fallback: return with a generic string schema
|
|
54
|
+
return { name, schema: Schema.String };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Fall through to check schema-level annotations on the inner model
|
|
58
|
+
return getIdentifierField(configured.model);
|
|
59
|
+
}
|
|
60
|
+
const fields = getSchemaFields(model);
|
|
61
|
+
if (!fields)
|
|
62
|
+
return undefined;
|
|
63
|
+
for (const [name, fieldSchema] of Object.entries(fields)) {
|
|
64
|
+
if (isIdentifier(fieldSchema))
|
|
65
|
+
return { name, schema: fieldSchema };
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
};
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// Ref annotation
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
/** Unique symbol for the Ref annotation */
|
|
73
|
+
const RefId = Symbol.for("effect-dynamodb/Ref");
|
|
74
|
+
/**
|
|
75
|
+
* Mark a schema field as a denormalized reference to another entity.
|
|
76
|
+
*
|
|
77
|
+
* Ref fields:
|
|
78
|
+
* - In `Entity.Input`, become ID fields (e.g., `team: Team` → `teamId: string`)
|
|
79
|
+
* - In `Entity.Record`, remain the full entity domain type
|
|
80
|
+
* - In `Entity.Update`, become optional ID fields
|
|
81
|
+
* - In DynamoDB, store the entity's core domain data as an embedded map
|
|
82
|
+
*
|
|
83
|
+
* The referenced entity's model must have exactly one `DynamoModel.identifier`-annotated field.
|
|
84
|
+
*/
|
|
85
|
+
export const ref = (schema) => {
|
|
86
|
+
// Extract Schema.Class identifier if available (e.g., "Team" from Schema.Class<Team>("Team"))
|
|
87
|
+
// In Effect v4, Schema.Class exposes `identifier` (not `_tag`) as the class name
|
|
88
|
+
const s = schema;
|
|
89
|
+
const refSchemaId = "identifier" in schema && typeof s.identifier === "string"
|
|
90
|
+
? s.identifier
|
|
91
|
+
: "_tag" in schema && typeof s._tag === "string"
|
|
92
|
+
? s._tag
|
|
93
|
+
: undefined;
|
|
94
|
+
return schema.pipe(Schema.annotate({ [RefId]: { _tag: "Ref", refSchemaId } }));
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Check if a schema field has the Ref annotation.
|
|
98
|
+
*/
|
|
99
|
+
export const isRef = (schema) => {
|
|
100
|
+
const ann = SchemaAST.resolve(schema.ast)?.[RefId];
|
|
101
|
+
return ann != null && typeof ann === "object" && ann._tag === "Ref";
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Check if a field is a ref, considering both schema-level annotations and
|
|
105
|
+
* ConfiguredModel overrides. Use this when you have access to the configured model.
|
|
106
|
+
*/
|
|
107
|
+
export const isRefField = (fieldName, model) => {
|
|
108
|
+
// Check ConfiguredModel attributes
|
|
109
|
+
if (isConfiguredModel(model)) {
|
|
110
|
+
const configured = model;
|
|
111
|
+
if (configured.attributes[fieldName]?.ref)
|
|
112
|
+
return true;
|
|
113
|
+
// Fall through to check schema-level annotation on the inner model
|
|
114
|
+
return isRefField(fieldName, configured.model);
|
|
115
|
+
}
|
|
116
|
+
// Check schema-level annotation
|
|
117
|
+
const fields = getSchemaFields(model);
|
|
118
|
+
if (fields) {
|
|
119
|
+
const fieldSchema = fields[fieldName];
|
|
120
|
+
if (fieldSchema)
|
|
121
|
+
return isRef(fieldSchema);
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Get the full Ref annotation metadata from a schema field.
|
|
127
|
+
* Returns undefined if the field is not ref-annotated.
|
|
128
|
+
*/
|
|
129
|
+
export const getRefAnnotation = (schema) => {
|
|
130
|
+
const ann = SchemaAST.resolve(schema.ast)?.[RefId];
|
|
131
|
+
if (ann != null && typeof ann === "object" && ann._tag === "Ref") {
|
|
132
|
+
return ann;
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
};
|
|
136
|
+
// ---------------------------------------------------------------------------
|
|
137
|
+
// Hidden annotation
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
/** Unique symbol for the Hidden annotation */
|
|
140
|
+
const HiddenId = Symbol.for("effect-dynamodb/Hidden");
|
|
141
|
+
/**
|
|
142
|
+
* Mark a schema field as hidden from default decode modes (asModel, asRecord).
|
|
143
|
+
*
|
|
144
|
+
* Hidden fields:
|
|
145
|
+
* - Stored in DynamoDB normally
|
|
146
|
+
* - Visible in asItem and asNative decode modes
|
|
147
|
+
* - Stripped from asModel and asRecord decode modes
|
|
148
|
+
*
|
|
149
|
+
* Use for internal/infrastructure fields that shouldn't leak into application code.
|
|
150
|
+
*/
|
|
151
|
+
export const Hidden = (schema) => schema.pipe(Schema.annotate({ [HiddenId]: true }));
|
|
152
|
+
/**
|
|
153
|
+
* Check if a schema field has the Hidden annotation.
|
|
154
|
+
*/
|
|
155
|
+
export const isHidden = (schema) => SchemaAST.resolve(schema.ast)?.[HiddenId] ?? false;
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// DynamoEncoding annotation
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
/** Unique symbol for the DynamoEncoding annotation */
|
|
160
|
+
export const DynamoEncodingKey = Symbol.for("effect-dynamodb/DynamoEncoding");
|
|
161
|
+
/**
|
|
162
|
+
* Read the DynamoEncoding annotation from a schema, if present.
|
|
163
|
+
*/
|
|
164
|
+
export const getEncoding = (schema) => SchemaAST.resolve(schema.ast)?.[DynamoEncodingKey];
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
// Date schemas — DateTime.Utc domain
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
/**
|
|
169
|
+
* Wire: ISO 8601 string ↔ Domain: DateTime.Utc
|
|
170
|
+
*
|
|
171
|
+
* Default storage: ISO string (`S`).
|
|
172
|
+
* This is a thin wrapper around `Schema.DateTimeUtcFromString` with the DynamoEncoding annotation.
|
|
173
|
+
*/
|
|
174
|
+
export const DateString = Schema.DateTimeUtcFromString.pipe(Schema.annotate({
|
|
175
|
+
[DynamoEncodingKey]: { storage: "string", domain: "DateTime.Utc" },
|
|
176
|
+
}));
|
|
177
|
+
/**
|
|
178
|
+
* Wire: epoch milliseconds (number) ↔ Domain: DateTime.Utc
|
|
179
|
+
*
|
|
180
|
+
* Default storage: epoch ms (`N`).
|
|
181
|
+
*/
|
|
182
|
+
export const DateEpochMs = Schema.Number.pipe(Schema.decodeTo(Schema.DateTimeUtc, {
|
|
183
|
+
decode: SchemaGetter.transform((n) => DateTime.makeUnsafe(n)),
|
|
184
|
+
encode: SchemaGetter.transform((dt) => DateTime.toEpochMillis(dt)),
|
|
185
|
+
}), Schema.annotate({
|
|
186
|
+
[DynamoEncodingKey]: { storage: "epochMs", domain: "DateTime.Utc" },
|
|
187
|
+
}));
|
|
188
|
+
/**
|
|
189
|
+
* Wire: epoch seconds (number) ↔ Domain: DateTime.Utc
|
|
190
|
+
*
|
|
191
|
+
* Default storage: epoch seconds (`N`).
|
|
192
|
+
* DynamoDB TTL requires this format.
|
|
193
|
+
*/
|
|
194
|
+
export const DateEpochSeconds = Schema.Number.pipe(Schema.decodeTo(Schema.DateTimeUtc, {
|
|
195
|
+
decode: SchemaGetter.transform((n) => DateTime.makeUnsafe(n * 1000)),
|
|
196
|
+
encode: SchemaGetter.transform((dt) => Math.floor(DateTime.toEpochMillis(dt) / 1000)),
|
|
197
|
+
}), Schema.annotate({
|
|
198
|
+
[DynamoEncodingKey]: {
|
|
199
|
+
storage: "epochSeconds",
|
|
200
|
+
domain: "DateTime.Utc",
|
|
201
|
+
},
|
|
202
|
+
}));
|
|
203
|
+
/**
|
|
204
|
+
* Wire: auto-detect epoch ms or seconds ↔ Domain: DateTime.Utc
|
|
205
|
+
*
|
|
206
|
+
* Uses a minimum threshold to disambiguate: if the value interpreted as ms
|
|
207
|
+
* produces a date before `minimum`, it tries seconds instead.
|
|
208
|
+
*
|
|
209
|
+
* @param options.minimum - Threshold date for disambiguation
|
|
210
|
+
* @param options.encode - Epoch schema for wire encoding (default: DateEpochMs)
|
|
211
|
+
*/
|
|
212
|
+
export const DateEpoch = (options) => {
|
|
213
|
+
const minEpochMs = typeof options.minimum === "string"
|
|
214
|
+
? new Date(options.minimum).getTime()
|
|
215
|
+
: DateTime.toEpochMillis(DateTime.makeUnsafe(options.minimum));
|
|
216
|
+
const encodeSchema = options.encode ?? DateEpochMs;
|
|
217
|
+
const encodeEncoding = getEncoding(encodeSchema);
|
|
218
|
+
return Schema.Number.pipe(Schema.decodeTo(Schema.DateTimeUtc, {
|
|
219
|
+
decode: SchemaGetter.transformOrFail((n) => {
|
|
220
|
+
// Try milliseconds first
|
|
221
|
+
try {
|
|
222
|
+
const asMs = DateTime.makeUnsafe(n);
|
|
223
|
+
if (DateTime.toEpochMillis(asMs) >= minEpochMs) {
|
|
224
|
+
return Effect.succeed(asMs);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
// fall through
|
|
229
|
+
}
|
|
230
|
+
// Fall back to seconds
|
|
231
|
+
try {
|
|
232
|
+
const asSec = DateTime.makeUnsafe(n * 1000);
|
|
233
|
+
if (DateTime.toEpochMillis(asSec) >= minEpochMs) {
|
|
234
|
+
return Effect.succeed(asSec);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
// fall through
|
|
239
|
+
}
|
|
240
|
+
return Effect.fail(new SchemaIssue.InvalidType(Schema.Number.ast, Option.some(n)));
|
|
241
|
+
}),
|
|
242
|
+
encode: SchemaGetter.transform((dt) => Schema.encodeSync(encodeSchema)(dt)),
|
|
243
|
+
}), Schema.annotate({
|
|
244
|
+
[DynamoEncodingKey]: {
|
|
245
|
+
storage: encodeEncoding?.storage ?? "epochMs",
|
|
246
|
+
domain: "DateTime.Utc",
|
|
247
|
+
},
|
|
248
|
+
}));
|
|
249
|
+
};
|
|
250
|
+
// ---------------------------------------------------------------------------
|
|
251
|
+
// Date schemas — DateTime.Zoned domain
|
|
252
|
+
// ---------------------------------------------------------------------------
|
|
253
|
+
/**
|
|
254
|
+
* Wire: ISO 8601 string with offset/zone ↔ Domain: DateTime.Zoned
|
|
255
|
+
*
|
|
256
|
+
* Default storage: extended ISO with zone (`S`).
|
|
257
|
+
* Format: `2024-01-01T15:00:00+09:00[Asia/Tokyo]`
|
|
258
|
+
*
|
|
259
|
+
* Cannot use epoch storage — timezone information would be lost (enforced at type level via storedAs).
|
|
260
|
+
*/
|
|
261
|
+
export const DateTimeZoned = Schema.String.pipe(Schema.decodeTo(Schema.DateTimeZoned, {
|
|
262
|
+
decode: SchemaGetter.transformOrFail((s) => {
|
|
263
|
+
// Parse extended ISO format: "2024-01-01T15:00:00+09:00[Asia/Tokyo]"
|
|
264
|
+
const match = s.match(/^(.+)\[(.+)\]$/);
|
|
265
|
+
if (match) {
|
|
266
|
+
const dateStr = match[1];
|
|
267
|
+
const tzName = match[2];
|
|
268
|
+
try {
|
|
269
|
+
const utc = DateTime.makeUnsafe(dateStr);
|
|
270
|
+
return Effect.succeed(DateTime.makeZonedUnsafe(utc, { timeZone: tzName }));
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return Effect.fail(new SchemaIssue.InvalidType(Schema.String.ast, Option.some(s)));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Try parsing as offset-only: "2024-01-01T15:00:00+09:00"
|
|
277
|
+
try {
|
|
278
|
+
const utc = DateTime.makeUnsafe(s);
|
|
279
|
+
return Effect.succeed(DateTime.makeZonedUnsafe(utc, { timeZone: "UTC" }));
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return Effect.fail(new SchemaIssue.InvalidType(Schema.String.ast, Option.some(s)));
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
285
|
+
encode: SchemaGetter.transform((dt) => DateTime.formatIsoZoned(dt)),
|
|
286
|
+
}), Schema.annotate({
|
|
287
|
+
[DynamoEncodingKey]: { storage: "string", domain: "DateTime.Zoned" },
|
|
288
|
+
}));
|
|
289
|
+
// ---------------------------------------------------------------------------
|
|
290
|
+
// Unsafe date schemas — native Date domain
|
|
291
|
+
// ---------------------------------------------------------------------------
|
|
292
|
+
/**
|
|
293
|
+
* Wire: ISO 8601 string ↔ Domain: native Date (mutable)
|
|
294
|
+
*
|
|
295
|
+
* Default storage: ISO string (`S`).
|
|
296
|
+
* For interop with non-Effect code that expects native JS Date objects.
|
|
297
|
+
*/
|
|
298
|
+
export const UnsafeDateString = Schema.String.pipe(Schema.decodeTo(Schema.DateValid, {
|
|
299
|
+
decode: SchemaGetter.transform((s) => new Date(s)),
|
|
300
|
+
encode: SchemaGetter.transform((d) => d.toISOString()),
|
|
301
|
+
}), Schema.annotate({
|
|
302
|
+
[DynamoEncodingKey]: { storage: "string", domain: "Date" },
|
|
303
|
+
}));
|
|
304
|
+
/**
|
|
305
|
+
* Wire: epoch milliseconds (number) ↔ Domain: native Date (mutable)
|
|
306
|
+
*
|
|
307
|
+
* Default storage: epoch ms (`N`).
|
|
308
|
+
*/
|
|
309
|
+
export const UnsafeDateEpochMs = Schema.Number.pipe(Schema.decodeTo(Schema.DateValid, {
|
|
310
|
+
decode: SchemaGetter.transform((ms) => new Date(ms)),
|
|
311
|
+
encode: SchemaGetter.transform((d) => d.getTime()),
|
|
312
|
+
}), Schema.annotate({
|
|
313
|
+
[DynamoEncodingKey]: { storage: "epochMs", domain: "Date" },
|
|
314
|
+
}));
|
|
315
|
+
/**
|
|
316
|
+
* Wire: epoch seconds (number) ↔ Domain: native Date (mutable)
|
|
317
|
+
*
|
|
318
|
+
* Default storage: epoch seconds (`N`).
|
|
319
|
+
*/
|
|
320
|
+
export const UnsafeDateEpochSeconds = Schema.Number.pipe(Schema.decodeTo(Schema.DateValid, {
|
|
321
|
+
decode: SchemaGetter.transform((s) => new Date(s * 1000)),
|
|
322
|
+
encode: SchemaGetter.transform((d) => Math.floor(d.getTime() / 1000)),
|
|
323
|
+
}), Schema.annotate({
|
|
324
|
+
[DynamoEncodingKey]: {
|
|
325
|
+
storage: "epochSeconds",
|
|
326
|
+
domain: "Date",
|
|
327
|
+
},
|
|
328
|
+
}));
|
|
329
|
+
// ---------------------------------------------------------------------------
|
|
330
|
+
// TTL alias
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
/**
|
|
333
|
+
* Alias for `DateEpochSeconds`. DynamoDB TTL requires epoch seconds.
|
|
334
|
+
* A named alias makes intent clear at the call site.
|
|
335
|
+
*/
|
|
336
|
+
export const TTL = DateEpochSeconds;
|
|
337
|
+
// ---------------------------------------------------------------------------
|
|
338
|
+
// storedAs modifier
|
|
339
|
+
// ---------------------------------------------------------------------------
|
|
340
|
+
/**
|
|
341
|
+
* Override the DynamoDB storage format for a date field.
|
|
342
|
+
*
|
|
343
|
+
* `storedAs` reads the DynamoEncoding annotation from the target storage schema
|
|
344
|
+
* and applies its storage format to the field schema. The domain type must match
|
|
345
|
+
* (enforced at the type level via the `A` constraint).
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* // Wire: ISO string, DynamoDB: epoch seconds (for TTL)
|
|
350
|
+
* DynamoModel.DateString.pipe(DynamoModel.storedAs(DynamoModel.DateEpochSeconds))
|
|
351
|
+
*
|
|
352
|
+
* // Wire: epoch ms, DynamoDB: ISO string
|
|
353
|
+
* DynamoModel.DateEpochMs.pipe(DynamoModel.storedAs(DynamoModel.DateString))
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
356
|
+
* Type-safe: incompatible domain types produce a compile error:
|
|
357
|
+
* ```typescript
|
|
358
|
+
* // Type error — DateTime.Zoned ≠ DateTime.Utc
|
|
359
|
+
* DynamoModel.DateTimeZoned.pipe(DynamoModel.storedAs(DynamoModel.DateEpochMs))
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
export const storedAs = (storageSchema) => {
|
|
363
|
+
const storageEncoding = getEncoding(storageSchema);
|
|
364
|
+
if (!storageEncoding) {
|
|
365
|
+
throw new Error("storedAs: target schema has no DynamoEncoding annotation");
|
|
366
|
+
}
|
|
367
|
+
return (fieldSchema) => {
|
|
368
|
+
const currentEncoding = getEncoding(fieldSchema);
|
|
369
|
+
return fieldSchema.pipe(Schema.annotate({
|
|
370
|
+
[DynamoEncodingKey]: {
|
|
371
|
+
storage: storageEncoding.storage,
|
|
372
|
+
domain: currentEncoding?.domain ?? storageEncoding.domain,
|
|
373
|
+
},
|
|
374
|
+
}));
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
// ---------------------------------------------------------------------------
|
|
378
|
+
// ConfiguredModel
|
|
379
|
+
// ---------------------------------------------------------------------------
|
|
380
|
+
/** Unique symbol identifying a ConfiguredModel wrapper */
|
|
381
|
+
export const ConfiguredModelTag = Symbol.for("effect-dynamodb/ConfiguredModel");
|
|
382
|
+
/** Brand symbol identifying a {@link SparseMapConfig} produced by {@link SparseMap}. */
|
|
383
|
+
const SparseMapTag = Symbol.for("effect-dynamodb/SparseMap");
|
|
384
|
+
/**
|
|
385
|
+
* Opt a `Schema.Record` field into sparse map storage.
|
|
386
|
+
*
|
|
387
|
+
* Each Record entry becomes an independently addressable top-level DynamoDB
|
|
388
|
+
* attribute (`<prefix>#<key>`) — concurrent writers to disjoint buckets
|
|
389
|
+
* never race, counters can `ADD` on a fresh item with no parent-map dance,
|
|
390
|
+
* and `attribute_exists`/`attribute_not_exists` work natively per entry.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* DynamoModel.configure(Page, {
|
|
395
|
+
* metrics: { storedAs: DynamoModel.SparseMap() },
|
|
396
|
+
* totals: { storedAs: DynamoModel.SparseMap({ prefix: "t" }) },
|
|
397
|
+
* })
|
|
398
|
+
* ```
|
|
399
|
+
*
|
|
400
|
+
* @param options.prefix - Override the top-level attribute name prefix.
|
|
401
|
+
* Defaults to the model field name. Distinct sparse fields on the same
|
|
402
|
+
* entity must have distinct prefixes (EDD-9023).
|
|
403
|
+
*
|
|
404
|
+
* See `DESIGN.md §7.5 Sparse Map Storage`.
|
|
405
|
+
*/
|
|
406
|
+
export const SparseMap = (options) => {
|
|
407
|
+
const cfg = { [SparseMapTag]: true };
|
|
408
|
+
if (options?.prefix !== undefined) {
|
|
409
|
+
return { ...cfg, prefix: options.prefix };
|
|
410
|
+
}
|
|
411
|
+
return cfg;
|
|
412
|
+
};
|
|
413
|
+
/** Type guard — returns true iff `value` is a {@link SparseMapConfig}. */
|
|
414
|
+
export const isSparseMapConfig = (value) => typeof value === "object" &&
|
|
415
|
+
value !== null &&
|
|
416
|
+
value[SparseMapTag] === true;
|
|
417
|
+
/**
|
|
418
|
+
* Check if a value is a ConfiguredModel.
|
|
419
|
+
*/
|
|
420
|
+
export const isConfiguredModel = (value) => typeof value === "object" &&
|
|
421
|
+
value !== null &&
|
|
422
|
+
value[ConfiguredModelTag] === true;
|
|
423
|
+
/**
|
|
424
|
+
* Resolve sparse-map configuration for every field on a model that is marked
|
|
425
|
+
* `storedAs: DynamoModel.SparseMap()` via {@link configure}.
|
|
426
|
+
*
|
|
427
|
+
* Returns `Record<fieldName, SparseConfig>`. Empty when no sparse fields are
|
|
428
|
+
* configured.
|
|
429
|
+
*
|
|
430
|
+
* Walks `ConfiguredModel.attributes` only — schema-level annotations are not
|
|
431
|
+
* supported for sparse (it's a deployment concern, not a domain one).
|
|
432
|
+
*/
|
|
433
|
+
export const getSparseFields = (model) => {
|
|
434
|
+
if (!isConfiguredModel(model))
|
|
435
|
+
return {};
|
|
436
|
+
const out = {};
|
|
437
|
+
for (const [name, attr] of Object.entries(model.attributes)) {
|
|
438
|
+
if (attr.sparse)
|
|
439
|
+
out[name] = attr.sparse;
|
|
440
|
+
}
|
|
441
|
+
return out;
|
|
442
|
+
};
|
|
443
|
+
/**
|
|
444
|
+
* Inspect a Schema field to determine whether it is shaped like a `Schema.Record`.
|
|
445
|
+
*
|
|
446
|
+
* Effect v4 `Schema.Record(K, V)` produces an AST `Objects` node with no
|
|
447
|
+
* `propertySignatures` and a single `indexSignatures` entry (string-keyed).
|
|
448
|
+
*
|
|
449
|
+
* Returns the value AST on match, otherwise `undefined`. Used by
|
|
450
|
+
* `Entity.make()` to validate sparse-map fields and detect nested sparse
|
|
451
|
+
* (a Record whose value is itself a Record).
|
|
452
|
+
*/
|
|
453
|
+
export const isRecordSchema = (schema) => {
|
|
454
|
+
const valueAst = recordValueAst(schema);
|
|
455
|
+
if (valueAst === undefined)
|
|
456
|
+
return undefined;
|
|
457
|
+
return { valueAst };
|
|
458
|
+
};
|
|
459
|
+
/** True iff `schema` is shaped like `Schema.Record(K, V)`. */
|
|
460
|
+
export const isRecord = (schema) => isRecordSchema(schema) !== undefined;
|
|
461
|
+
/** True iff `valueAst` (raw AST from a Record value position) is itself a Record AST. */
|
|
462
|
+
export const isRecordAst = (valueAst) => recordValueAstFromAst(valueAst) !== undefined;
|
|
463
|
+
/**
|
|
464
|
+
* Create a configured model with per-field DynamoDB overrides.
|
|
465
|
+
*
|
|
466
|
+
* Separates DynamoDB infrastructure (storage format, field renaming) from
|
|
467
|
+
* the domain model, enabling pure models that work across storage backends.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* class Order extends Schema.Class<Order>("Order")({
|
|
472
|
+
* orderId: Schema.String,
|
|
473
|
+
* placedAt: Schema.DateTimeUtcFromString,
|
|
474
|
+
* expiresAt: Schema.DateTimeUtcFromString,
|
|
475
|
+
* }) {}
|
|
476
|
+
*
|
|
477
|
+
* const OrderModel = DynamoModel.configure(Order, {
|
|
478
|
+
* expiresAt: { field: "ttl", storedAs: DynamoModel.DateEpochSeconds },
|
|
479
|
+
* })
|
|
480
|
+
* ```
|
|
481
|
+
*/
|
|
482
|
+
export const configure = (model, attributes) => {
|
|
483
|
+
const resolved = {};
|
|
484
|
+
for (const [key, config] of Object.entries(attributes)) {
|
|
485
|
+
const entry = {};
|
|
486
|
+
if (config.field)
|
|
487
|
+
entry.field = config.field;
|
|
488
|
+
if (config.immutable)
|
|
489
|
+
entry.immutable = true;
|
|
490
|
+
if (config.identifier)
|
|
491
|
+
entry.identifier = true;
|
|
492
|
+
if (config.ref)
|
|
493
|
+
entry.ref = true;
|
|
494
|
+
if (isSparseMapConfig(config.storedAs)) {
|
|
495
|
+
// Sparse Map storage: each entry is stored as a top-level attribute named
|
|
496
|
+
// `<prefix>#<key>`. Validation that the field is a Schema.Record happens
|
|
497
|
+
// at Entity.make() time (EDD-9020) — configure() can't introspect the
|
|
498
|
+
// model's schema field types reliably without committing to a single
|
|
499
|
+
// representation, so we keep configure() permissive and defer enforcement.
|
|
500
|
+
const prefix = config.storedAs.prefix ?? key;
|
|
501
|
+
if (typeof prefix !== "string" || prefix.length === 0) {
|
|
502
|
+
throw new Error(`DynamoModel.configure: sparse field "${key}" must have a non-empty string prefix`);
|
|
503
|
+
}
|
|
504
|
+
if (prefix.includes("#")) {
|
|
505
|
+
throw new Error(`DynamoModel.configure: sparse field "${key}" prefix "${prefix}" must not contain '#'`);
|
|
506
|
+
}
|
|
507
|
+
entry.sparse = { prefix };
|
|
508
|
+
}
|
|
509
|
+
else if (config.storedAs !== undefined) {
|
|
510
|
+
const encoding = getEncoding(config.storedAs);
|
|
511
|
+
if (!encoding) {
|
|
512
|
+
throw new Error(`DynamoModel.configure: storedAs schema for "${key}" has no DynamoEncoding annotation`);
|
|
513
|
+
}
|
|
514
|
+
entry.encoding = encoding;
|
|
515
|
+
}
|
|
516
|
+
resolved[key] = entry;
|
|
517
|
+
}
|
|
518
|
+
// Validate: no field rename targets collide with existing model field names
|
|
519
|
+
const modelFields = new Set();
|
|
520
|
+
const fields = getSchemaFields(model);
|
|
521
|
+
if (fields) {
|
|
522
|
+
for (const fieldName of Object.keys(fields)) {
|
|
523
|
+
modelFields.add(fieldName);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
if (modelFields.size > 0) {
|
|
527
|
+
for (const [sourceField, config] of Object.entries(resolved)) {
|
|
528
|
+
if (config.field && config.field !== sourceField && modelFields.has(config.field)) {
|
|
529
|
+
throw new Error(`[EDD-9007] DynamoModel.configure: renaming "${sourceField}" to "${config.field}" collides with existing model field "${config.field}". ` +
|
|
530
|
+
`This would cause both fields to map to the same DynamoDB attribute.`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
[ConfiguredModelTag]: true,
|
|
536
|
+
model,
|
|
537
|
+
_attributes: attributes,
|
|
538
|
+
attributes: resolved,
|
|
539
|
+
};
|
|
540
|
+
};
|
|
541
|
+
//# sourceMappingURL=DynamoModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DynamoModel.js","sourceRoot":"","sources":["../src/DynamoModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC/F,OAAO,EACL,eAAe,EACf,cAAc,EACd,qBAAqB,GACtB,MAAM,+BAA+B,CAAA;AAEtC,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E,kDAAkD;AAClD,MAAM,YAAY,GAAkB,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE5E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAuB,MAAS,EAAK,EAAE,CAC/D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAM,CAAA;AAE7D;;GAEG;AACH,MA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