effect-dynamodb 1.8.2 → 1.9.1
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 +9 -9
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js +9 -9
- package/dist/Aggregate.js.map +1 -1
- package/dist/Batch.d.ts +1 -1
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +1 -1
- package/dist/Batch.js.map +1 -1
- package/dist/Collection.d.ts +3 -3
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +3 -3
- package/dist/Collection.js.map +1 -1
- package/dist/Collections.d.ts +1 -1
- package/dist/Collections.d.ts.map +1 -1
- package/dist/Collections.js +1 -1
- package/dist/Collections.js.map +1 -1
- package/dist/DynamoClient.d.ts +12 -8
- package/dist/DynamoClient.d.ts.map +1 -1
- package/dist/DynamoClient.js +23 -7
- package/dist/DynamoClient.js.map +1 -1
- package/dist/Entity.d.ts +41 -19
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +185 -58
- package/dist/Entity.js.map +1 -1
- package/dist/EventStore.d.ts +1 -1
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +6 -5
- package/dist/EventStore.js.map +1 -1
- package/dist/Marshaller.d.ts +1 -1
- package/dist/Marshaller.d.ts.map +1 -1
- package/dist/Query.d.ts +1 -1
- package/dist/Query.d.ts.map +1 -1
- package/dist/Query.js +1 -1
- package/dist/Query.js.map +1 -1
- package/dist/Table.d.ts +2 -2
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js.map +1 -1
- package/dist/Transaction.d.ts +1 -1
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +1 -1
- package/dist/Transaction.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/BoundQuery.d.ts +1 -1
- package/dist/internal/BoundQuery.d.ts.map +1 -1
- package/dist/internal/BoundQuery.js.map +1 -1
- package/dist/internal/EntityCombinators.d.ts +1 -1
- package/dist/internal/EntityCombinators.d.ts.map +1 -1
- package/dist/internal/EntityCombinators.js.map +1 -1
- package/dist/internal/EntityOps.d.ts +2 -2
- package/dist/internal/EntityOps.d.ts.map +1 -1
- package/dist/internal/EntityOps.js.map +1 -1
- package/dist/internal/TransactableOps.d.ts +16 -4
- package/dist/internal/TransactableOps.d.ts.map +1 -1
- package/dist/internal/TransactableOps.js +24 -13
- package/dist/internal/TransactableOps.js.map +1 -1
- package/package.json +16 -15
- package/dist/DynamoModel.d.ts +0 -370
- package/dist/DynamoModel.d.ts.map +0 -1
- package/dist/DynamoModel.js +0 -562
- package/dist/DynamoModel.js.map +0 -1
- package/dist/DynamoSchema.d.ts +0 -137
- package/dist/DynamoSchema.d.ts.map +0 -1
- package/dist/DynamoSchema.js +0 -188
- package/dist/DynamoSchema.js.map +0 -1
- package/dist/Errors.d.ts +0 -387
- package/dist/Errors.d.ts.map +0 -1
- package/dist/Errors.js +0 -218
- package/dist/Errors.js.map +0 -1
- package/dist/KeyComposer.d.ts +0 -264
- package/dist/KeyComposer.d.ts.map +0 -1
- package/dist/KeyComposer.js +0 -516
- package/dist/KeyComposer.js.map +0 -1
- package/dist/Projection.d.ts +0 -28
- package/dist/Projection.d.ts.map +0 -1
- package/dist/Projection.js +0 -39
- package/dist/Projection.js.map +0 -1
- package/dist/internal/AggregateCursor.d.ts +0 -44
- package/dist/internal/AggregateCursor.d.ts.map +0 -1
- package/dist/internal/AggregateCursor.js +0 -18
- package/dist/internal/AggregateCursor.js.map +0 -1
- package/dist/internal/AggregateEdges.d.ts +0 -77
- package/dist/internal/AggregateEdges.d.ts.map +0 -1
- package/dist/internal/AggregateEdges.js +0 -41
- package/dist/internal/AggregateEdges.js.map +0 -1
- package/dist/internal/AggregateSchemas.d.ts +0 -60
- package/dist/internal/AggregateSchemas.d.ts.map +0 -1
- package/dist/internal/AggregateSchemas.js +0 -201
- package/dist/internal/AggregateSchemas.js.map +0 -1
- package/dist/internal/AggregateTypes.d.ts +0 -94
- package/dist/internal/AggregateTypes.d.ts.map +0 -1
- package/dist/internal/AggregateTypes.js +0 -7
- package/dist/internal/AggregateTypes.js.map +0 -1
- package/dist/internal/EntityConfig.d.ts +0 -134
- package/dist/internal/EntityConfig.d.ts.map +0 -1
- package/dist/internal/EntityConfig.js +0 -7
- package/dist/internal/EntityConfig.js.map +0 -1
- package/dist/internal/EntitySchemas.d.ts +0 -190
- package/dist/internal/EntitySchemas.d.ts.map +0 -1
- package/dist/internal/EntitySchemas.js +0 -794
- package/dist/internal/EntitySchemas.js.map +0 -1
- package/dist/internal/EntityTypes.d.ts +0 -208
- package/dist/internal/EntityTypes.d.ts.map +0 -1
- package/dist/internal/EntityTypes.js +0 -7
- package/dist/internal/EntityTypes.js.map +0 -1
package/dist/DynamoModel.d.ts
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
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, Schema } from "effect";
|
|
16
|
-
/**
|
|
17
|
-
* Mark a schema field as the primary identifier for ref resolution.
|
|
18
|
-
*
|
|
19
|
-
* Entities that can be referenced via `DynamoModel.ref` must annotate exactly
|
|
20
|
-
* one field with `identifier`. The annotated field should be a string or
|
|
21
|
-
* branded string type.
|
|
22
|
-
*/
|
|
23
|
-
export declare const identifier: <S extends Schema.Top>(schema: S) => S;
|
|
24
|
-
/**
|
|
25
|
-
* Check if a schema field has the Identifier annotation.
|
|
26
|
-
*/
|
|
27
|
-
export declare const isIdentifier: (schema: Schema.Top) => boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Find the identifier field in a schema with `.fields` (Schema.Class or Schema.Struct).
|
|
30
|
-
* Checks both schema-level `DynamoModel.identifier` annotations and ConfiguredModel
|
|
31
|
-
* `identifier: true` overrides.
|
|
32
|
-
*
|
|
33
|
-
* Returns the field name and schema, or undefined if no field has the identifier annotation.
|
|
34
|
-
*/
|
|
35
|
-
export declare const getIdentifierField: (model: Schema.Top) => {
|
|
36
|
-
readonly name: string;
|
|
37
|
-
readonly schema: Schema.Top;
|
|
38
|
-
} | undefined;
|
|
39
|
-
/** Annotation metadata stored on ref-annotated fields */
|
|
40
|
-
export interface RefAnnotation {
|
|
41
|
-
readonly _tag: "Ref";
|
|
42
|
-
/** Schema.Class identifier of the referenced type (e.g., "Team", "Player") */
|
|
43
|
-
readonly refSchemaId?: string | undefined;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Mark a schema field as a denormalized reference to another entity.
|
|
47
|
-
*
|
|
48
|
-
* Ref fields:
|
|
49
|
-
* - In `Entity.Input`, become ID fields (e.g., `team: Team` → `teamId: string`)
|
|
50
|
-
* - In `Entity.Record`, remain the full entity domain type
|
|
51
|
-
* - In `Entity.Update`, become optional ID fields
|
|
52
|
-
* - In DynamoDB, store the entity's core domain data as an embedded map
|
|
53
|
-
*
|
|
54
|
-
* The referenced entity's model must have exactly one `DynamoModel.identifier`-annotated field.
|
|
55
|
-
*/
|
|
56
|
-
export declare const ref: <S extends Schema.Top>(schema: S) => S;
|
|
57
|
-
/**
|
|
58
|
-
* Check if a schema field has the Ref annotation.
|
|
59
|
-
*/
|
|
60
|
-
export declare const isRef: (schema: Schema.Top) => boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Check if a field is a ref, considering both schema-level annotations and
|
|
63
|
-
* ConfiguredModel overrides. Use this when you have access to the configured model.
|
|
64
|
-
*/
|
|
65
|
-
export declare const isRefField: (fieldName: string, model: Schema.Top) => boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Get the full Ref annotation metadata from a schema field.
|
|
68
|
-
* Returns undefined if the field is not ref-annotated.
|
|
69
|
-
*/
|
|
70
|
-
export declare const getRefAnnotation: (schema: Schema.Top) => RefAnnotation | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Mark a schema field as hidden from default decode modes (asModel, asRecord).
|
|
73
|
-
*
|
|
74
|
-
* Hidden fields:
|
|
75
|
-
* - Stored in DynamoDB normally
|
|
76
|
-
* - Visible in asItem and asNative decode modes
|
|
77
|
-
* - Stripped from asModel and asRecord decode modes
|
|
78
|
-
*
|
|
79
|
-
* Use for internal/infrastructure fields that shouldn't leak into application code.
|
|
80
|
-
*/
|
|
81
|
-
export declare const Hidden: <S extends Schema.Top>(schema: S) => S;
|
|
82
|
-
/**
|
|
83
|
-
* Check if a schema field has the Hidden annotation.
|
|
84
|
-
*/
|
|
85
|
-
export declare const isHidden: (schema: Schema.Top) => boolean;
|
|
86
|
-
/** Unique symbol for the DynamoEncoding annotation */
|
|
87
|
-
export declare const DynamoEncodingKey: unique symbol;
|
|
88
|
-
/**
|
|
89
|
-
* Describes how a date field is stored in DynamoDB.
|
|
90
|
-
* - `storage` — the DynamoDB attribute format
|
|
91
|
-
* - `domain` — the domain type (for deserialization dispatch)
|
|
92
|
-
*/
|
|
93
|
-
export interface DynamoEncoding {
|
|
94
|
-
readonly storage: "string" | "epochMs" | "epochSeconds";
|
|
95
|
-
readonly domain: "DateTime.Utc" | "DateTime.Zoned" | "Date";
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Read the DynamoEncoding annotation from a schema, if present.
|
|
99
|
-
*/
|
|
100
|
-
export declare const getEncoding: (schema: Schema.Top) => DynamoEncoding | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* Wire: ISO 8601 string ↔ Domain: DateTime.Utc
|
|
103
|
-
*
|
|
104
|
-
* Default storage: ISO string (`S`).
|
|
105
|
-
* This is a thin wrapper around `Schema.DateTimeUtcFromString` with the DynamoEncoding annotation.
|
|
106
|
-
*/
|
|
107
|
-
export declare const DateString: Schema.DateTimeUtcFromString;
|
|
108
|
-
/**
|
|
109
|
-
* Wire: epoch milliseconds (number) ↔ Domain: DateTime.Utc
|
|
110
|
-
*
|
|
111
|
-
* Default storage: epoch ms (`N`).
|
|
112
|
-
*/
|
|
113
|
-
export declare const DateEpochMs: Schema.decodeTo<Schema.DateTimeUtc, Schema.Number, never, never>;
|
|
114
|
-
/**
|
|
115
|
-
* Wire: epoch seconds (number) ↔ Domain: DateTime.Utc
|
|
116
|
-
*
|
|
117
|
-
* Default storage: epoch seconds (`N`).
|
|
118
|
-
* DynamoDB TTL requires this format.
|
|
119
|
-
*/
|
|
120
|
-
export declare const DateEpochSeconds: Schema.decodeTo<Schema.DateTimeUtc, Schema.Number, never, never>;
|
|
121
|
-
/**
|
|
122
|
-
* Wire: auto-detect epoch ms or seconds ↔ Domain: DateTime.Utc
|
|
123
|
-
*
|
|
124
|
-
* Uses a minimum threshold to disambiguate: if the value interpreted as ms
|
|
125
|
-
* produces a date before `minimum`, it tries seconds instead.
|
|
126
|
-
*
|
|
127
|
-
* @param options.minimum - Threshold date for disambiguation
|
|
128
|
-
* @param options.encode - Epoch schema for wire encoding (default: DateEpochMs)
|
|
129
|
-
*/
|
|
130
|
-
export declare const DateEpoch: (options: {
|
|
131
|
-
readonly minimum: string | DateTime.DateTime.Input;
|
|
132
|
-
readonly encode?: typeof DateEpochMs | typeof DateEpochSeconds;
|
|
133
|
-
}) => Schema.decodeTo<Schema.DateTimeUtc, Schema.Number, never, never>;
|
|
134
|
-
/**
|
|
135
|
-
* Wire: ISO 8601 string with offset/zone ↔ Domain: DateTime.Zoned
|
|
136
|
-
*
|
|
137
|
-
* Default storage: extended ISO with zone (`S`).
|
|
138
|
-
* Format: `2024-01-01T15:00:00+09:00[Asia/Tokyo]`
|
|
139
|
-
*
|
|
140
|
-
* Cannot use epoch storage — timezone information would be lost (enforced at type level via storedAs).
|
|
141
|
-
*/
|
|
142
|
-
export declare const DateTimeZoned: Schema.decodeTo<Schema.DateTimeZoned, Schema.String, never, never>;
|
|
143
|
-
/**
|
|
144
|
-
* Wire: ISO 8601 string ↔ Domain: native Date (mutable)
|
|
145
|
-
*
|
|
146
|
-
* Default storage: ISO string (`S`).
|
|
147
|
-
* For interop with non-Effect code that expects native JS Date objects.
|
|
148
|
-
*/
|
|
149
|
-
export declare const UnsafeDateString: Schema.decodeTo<Schema.DateValid, Schema.String, never, never>;
|
|
150
|
-
/**
|
|
151
|
-
* Wire: epoch milliseconds (number) ↔ Domain: native Date (mutable)
|
|
152
|
-
*
|
|
153
|
-
* Default storage: epoch ms (`N`).
|
|
154
|
-
*/
|
|
155
|
-
export declare const UnsafeDateEpochMs: Schema.decodeTo<Schema.DateValid, Schema.Number, never, never>;
|
|
156
|
-
/**
|
|
157
|
-
* Wire: epoch seconds (number) ↔ Domain: native Date (mutable)
|
|
158
|
-
*
|
|
159
|
-
* Default storage: epoch seconds (`N`).
|
|
160
|
-
*/
|
|
161
|
-
export declare const UnsafeDateEpochSeconds: Schema.decodeTo<Schema.DateValid, Schema.Number, never, never>;
|
|
162
|
-
/**
|
|
163
|
-
* Alias for `DateEpochSeconds`. DynamoDB TTL requires epoch seconds.
|
|
164
|
-
* A named alias makes intent clear at the call site.
|
|
165
|
-
*/
|
|
166
|
-
export declare const TTL: Schema.decodeTo<Schema.DateTimeUtc, Schema.Number, never, never>;
|
|
167
|
-
/**
|
|
168
|
-
* Override the DynamoDB storage format for a date field.
|
|
169
|
-
*
|
|
170
|
-
* `storedAs` reads the DynamoEncoding annotation from the target storage schema
|
|
171
|
-
* and applies its storage format to the field schema. The domain type must match
|
|
172
|
-
* (enforced at the type level via the `A` constraint).
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* ```typescript
|
|
176
|
-
* // Wire: ISO string, DynamoDB: epoch seconds (for TTL)
|
|
177
|
-
* DynamoModel.DateString.pipe(DynamoModel.storedAs(DynamoModel.DateEpochSeconds))
|
|
178
|
-
*
|
|
179
|
-
* // Wire: epoch ms, DynamoDB: ISO string
|
|
180
|
-
* DynamoModel.DateEpochMs.pipe(DynamoModel.storedAs(DynamoModel.DateString))
|
|
181
|
-
* ```
|
|
182
|
-
*
|
|
183
|
-
* Type-safe: incompatible domain types produce a compile error:
|
|
184
|
-
* ```typescript
|
|
185
|
-
* // Type error — DateTime.Zoned ≠ DateTime.Utc
|
|
186
|
-
* DynamoModel.DateTimeZoned.pipe(DynamoModel.storedAs(DynamoModel.DateEpochMs))
|
|
187
|
-
* ```
|
|
188
|
-
*/
|
|
189
|
-
export declare const storedAs: <A>(storageSchema: Schema.Schema<A>) => (<S extends Schema.Schema<A>>(fieldSchema: S) => S);
|
|
190
|
-
/** Unique symbol identifying a ConfiguredModel wrapper */
|
|
191
|
-
export declare const ConfiguredModelTag: unique symbol;
|
|
192
|
-
/**
|
|
193
|
-
* Sparse-map configuration carried on a `ConfiguredModel` attribute when the
|
|
194
|
-
* field is marked `storedAs: DynamoModel.SparseMap()`.
|
|
195
|
-
*
|
|
196
|
-
* - `prefix` — top-level attribute name prefix; defaults to the model field name.
|
|
197
|
-
* Each Record entry is stored as a separate top-level attribute named
|
|
198
|
-
* `<prefix>#<key>`. The default prefix can be overridden by passing
|
|
199
|
-
* `{ prefix }` to {@link SparseMap}.
|
|
200
|
-
*/
|
|
201
|
-
export interface SparseConfig {
|
|
202
|
-
readonly prefix: string;
|
|
203
|
-
}
|
|
204
|
-
/** Brand symbol identifying a {@link SparseMapConfig} produced by {@link SparseMap}. */
|
|
205
|
-
declare const SparseMapTag: unique symbol;
|
|
206
|
-
/**
|
|
207
|
-
* Typed config object returned by {@link SparseMap}. Pass as the `storedAs`
|
|
208
|
-
* value on a `Schema.Record` field in {@link configure} to opt into sparse
|
|
209
|
-
* map storage — each Record entry is flattened into a top-level DynamoDB
|
|
210
|
-
* attribute named `<prefix>#<key>`.
|
|
211
|
-
*/
|
|
212
|
-
export interface SparseMapConfig {
|
|
213
|
-
readonly [SparseMapTag]: true;
|
|
214
|
-
readonly prefix?: string | undefined;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Opt a `Schema.Record` field into sparse map storage.
|
|
218
|
-
*
|
|
219
|
-
* Each Record entry becomes an independently addressable top-level DynamoDB
|
|
220
|
-
* attribute (`<prefix>#<key>`) — concurrent writers to disjoint buckets
|
|
221
|
-
* never race, counters can `ADD` on a fresh item with no parent-map dance,
|
|
222
|
-
* and `attribute_exists`/`attribute_not_exists` work natively per entry.
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* ```ts
|
|
226
|
-
* DynamoModel.configure(Page, {
|
|
227
|
-
* metrics: { storedAs: DynamoModel.SparseMap() },
|
|
228
|
-
* totals: { storedAs: DynamoModel.SparseMap({ prefix: "t" }) },
|
|
229
|
-
* })
|
|
230
|
-
* ```
|
|
231
|
-
*
|
|
232
|
-
* @param options.prefix - Override the top-level attribute name prefix.
|
|
233
|
-
* Defaults to the model field name. Distinct sparse fields on the same
|
|
234
|
-
* entity must have distinct prefixes (EDD-9023).
|
|
235
|
-
*
|
|
236
|
-
* See `DESIGN.md §7.5 Sparse Map Storage`.
|
|
237
|
-
*/
|
|
238
|
-
export declare const SparseMap: (options?: {
|
|
239
|
-
readonly prefix?: string | undefined;
|
|
240
|
-
}) => SparseMapConfig;
|
|
241
|
-
/** Type guard — returns true iff `value` is a {@link SparseMapConfig}. */
|
|
242
|
-
export declare const isSparseMapConfig: (value: unknown) => value is SparseMapConfig;
|
|
243
|
-
/**
|
|
244
|
-
* A model wrapped with DynamoDB-specific attribute overrides.
|
|
245
|
-
*
|
|
246
|
-
* Carries the original model plus per-field configuration:
|
|
247
|
-
* - `field` — rename domain field → DynamoDB attribute name
|
|
248
|
-
* - `storedAs` — override DynamoDB storage encoding (resolved to DynamoEncoding)
|
|
249
|
-
* OR a {@link SparseMapConfig} (via {@link SparseMap}) to
|
|
250
|
-
* flatten a `Schema.Record` field into per-entry top-level
|
|
251
|
-
* attributes (see {@link SparseConfig}).
|
|
252
|
-
* - `immutable` — mark field as read-only after creation (excluded from Entity.Update)
|
|
253
|
-
* - `identifier` — mark field as the identity field for ref resolution
|
|
254
|
-
* - `ref` — mark field as a denormalized reference to another entity
|
|
255
|
-
*/
|
|
256
|
-
export interface ConfiguredModel<M extends Schema.Top, A extends ConfigureAttributes<M> = ConfigureAttributes<M>> {
|
|
257
|
-
readonly [ConfiguredModelTag]: true;
|
|
258
|
-
readonly model: M;
|
|
259
|
-
readonly _attributes: A;
|
|
260
|
-
readonly attributes: globalThis.Record<string, {
|
|
261
|
-
readonly field?: string;
|
|
262
|
-
readonly encoding?: DynamoEncoding;
|
|
263
|
-
readonly immutable?: boolean;
|
|
264
|
-
readonly identifier?: boolean;
|
|
265
|
-
readonly ref?: boolean;
|
|
266
|
-
readonly sparse?: SparseConfig;
|
|
267
|
-
}>;
|
|
268
|
-
}
|
|
269
|
-
/** Extract the identifier field name from a ConfiguredModel's attributes type. */
|
|
270
|
-
export type ExtractIdentifier<Model> = Model extends ConfiguredModel<any, infer A> ? {
|
|
271
|
-
[K in keyof A & string]: A[K] extends {
|
|
272
|
-
readonly identifier: true;
|
|
273
|
-
} ? K : never;
|
|
274
|
-
}[keyof A & string] : undefined;
|
|
275
|
-
/**
|
|
276
|
-
* Check if a value is a ConfiguredModel.
|
|
277
|
-
*/
|
|
278
|
-
export declare const isConfiguredModel: (value: unknown) => value is ConfiguredModel<Schema.Top, any>;
|
|
279
|
-
/**
|
|
280
|
-
* Resolve sparse-map configuration for every field on a model that is marked
|
|
281
|
-
* `storedAs: DynamoModel.SparseMap()` via {@link configure}.
|
|
282
|
-
*
|
|
283
|
-
* Returns `Record<fieldName, SparseConfig>`. Empty when no sparse fields are
|
|
284
|
-
* configured.
|
|
285
|
-
*
|
|
286
|
-
* Walks `ConfiguredModel.attributes` only — schema-level annotations are not
|
|
287
|
-
* supported for sparse (it's a deployment concern, not a domain one).
|
|
288
|
-
*/
|
|
289
|
-
export declare const getSparseFields: (model: Schema.Top) => globalThis.Record<string, SparseConfig>;
|
|
290
|
-
/**
|
|
291
|
-
* Inspect a Schema field to determine whether it is shaped like a `Schema.Record`.
|
|
292
|
-
*
|
|
293
|
-
* Effect v4 `Schema.Record(K, V)` produces an AST `Objects` node with no
|
|
294
|
-
* `propertySignatures` and a single `indexSignatures` entry (string-keyed).
|
|
295
|
-
*
|
|
296
|
-
* Returns the value AST on match, otherwise `undefined`. Used by
|
|
297
|
-
* `Entity.make()` to validate sparse-map fields and detect nested sparse
|
|
298
|
-
* (a Record whose value is itself a Record).
|
|
299
|
-
*/
|
|
300
|
-
export declare const isRecordSchema: (schema: Schema.Top) => {
|
|
301
|
-
readonly valueAst: unknown;
|
|
302
|
-
} | undefined;
|
|
303
|
-
/** True iff `schema` is shaped like `Schema.Record(K, V)`. */
|
|
304
|
-
export declare const isRecord: (schema: Schema.Top) => boolean;
|
|
305
|
-
/** True iff `valueAst` (raw AST from a Record value position) is itself a Record AST. */
|
|
306
|
-
export declare const isRecordAst: (valueAst: unknown) => boolean;
|
|
307
|
-
/**
|
|
308
|
-
* Attribute override for a single field in `DynamoModel.configure`.
|
|
309
|
-
*
|
|
310
|
-
* - `field` — Rename the domain field to a different DynamoDB attribute name.
|
|
311
|
-
* - `storedAs` — Override DynamoDB storage format via a DynamoModel date schema,
|
|
312
|
-
* or {@link SparseMap}() to flatten a `Schema.Record` into
|
|
313
|
-
* per-entry top-level attributes (see {@link SparseConfig}).
|
|
314
|
-
* - `immutable` — Mark as read-only after creation (excluded from Entity.Update).
|
|
315
|
-
* - `identifier` — Mark as the identity field for ref resolution.
|
|
316
|
-
* - `ref` — Mark as a denormalized reference field.
|
|
317
|
-
*
|
|
318
|
-
* Note: the `prefix` option moved into the {@link SparseMap} config in 1.6 —
|
|
319
|
-
* pass `storedAs: DynamoModel.SparseMap({ prefix })` instead of declaring
|
|
320
|
-
* `prefix` as a sibling here. The sibling form had no meaning for non-sparse
|
|
321
|
-
* `storedAs` values and was a footgun.
|
|
322
|
-
*/
|
|
323
|
-
type AttributeConfig<A> = {
|
|
324
|
-
readonly field?: string;
|
|
325
|
-
readonly storedAs?: Schema.Schema<A> | SparseMapConfig;
|
|
326
|
-
readonly immutable?: boolean;
|
|
327
|
-
readonly identifier?: boolean;
|
|
328
|
-
readonly ref?: boolean;
|
|
329
|
-
};
|
|
330
|
-
/**
|
|
331
|
-
* Type-safe attribute overrides map: keys constrained to model fields,
|
|
332
|
-
* `storedAs` constrained to matching domain type.
|
|
333
|
-
*/
|
|
334
|
-
type ConfigureAttributes<M extends Schema.Top> = {
|
|
335
|
-
readonly [K in keyof Schema.Schema.Type<M>]?: AttributeConfig<Schema.Schema.Type<M>[K]>;
|
|
336
|
-
};
|
|
337
|
-
/**
|
|
338
|
-
* Compile-time validation: detects `field` rename targets that collide
|
|
339
|
-
* with existing model field names. Replaces the `field` type with an
|
|
340
|
-
* error tuple to produce a readable type error at the call site.
|
|
341
|
-
*/
|
|
342
|
-
type ValidateFieldRenames<Fields extends string, A> = {
|
|
343
|
-
[K in keyof A]: A[K] extends {
|
|
344
|
-
readonly field: infer F extends string;
|
|
345
|
-
} ? F extends Exclude<Fields, K & string> ? {
|
|
346
|
-
readonly field: [`EDD-9007: "${F}" collides with existing model field`];
|
|
347
|
-
} & Omit<A[K], "field"> : A[K] : A[K];
|
|
348
|
-
};
|
|
349
|
-
/**
|
|
350
|
-
* Create a configured model with per-field DynamoDB overrides.
|
|
351
|
-
*
|
|
352
|
-
* Separates DynamoDB infrastructure (storage format, field renaming) from
|
|
353
|
-
* the domain model, enabling pure models that work across storage backends.
|
|
354
|
-
*
|
|
355
|
-
* @example
|
|
356
|
-
* ```typescript
|
|
357
|
-
* class Order extends Schema.Class<Order>("Order")({
|
|
358
|
-
* orderId: Schema.String,
|
|
359
|
-
* placedAt: Schema.DateTimeUtcFromString,
|
|
360
|
-
* expiresAt: Schema.DateTimeUtcFromString,
|
|
361
|
-
* }) {}
|
|
362
|
-
*
|
|
363
|
-
* const OrderModel = DynamoModel.configure(Order, {
|
|
364
|
-
* expiresAt: { field: "ttl", storedAs: DynamoModel.DateEpochSeconds },
|
|
365
|
-
* })
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
|
-
export declare const configure: <M extends Schema.Top, const A extends ConfigureAttributes<M>>(model: M, attributes: A & ValidateFieldRenames<keyof Schema.Schema.Type<M> & string, A>) => ConfiguredModel<M, A>;
|
|
369
|
-
export {};
|
|
370
|
-
//# sourceMappingURL=DynamoModel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DynamoModel.d.ts","sourceRoot":"","sources":["../src/DynamoModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAkB,MAAM,EAAwC,MAAM,QAAQ,CAAA;AAS/F;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAG,CACA,CAAA;AAE7D;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,CAAC,GAAG,KAAG,OAG1B,CAAA;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,CAAC,GAAG,KAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAA;CAAE,GAAG,SAkC3D,CAAA;AASD,yDAAyD;AACz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