effect-dynamodb 0.1.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 (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -0
  3. package/dist/Aggregate.d.ts +210 -0
  4. package/dist/Aggregate.d.ts.map +1 -0
  5. package/dist/Aggregate.js +1169 -0
  6. package/dist/Aggregate.js.map +1 -0
  7. package/dist/Batch.d.ts +62 -0
  8. package/dist/Batch.d.ts.map +1 -0
  9. package/dist/Batch.js +218 -0
  10. package/dist/Batch.js.map +1 -0
  11. package/dist/Collection.d.ts +58 -0
  12. package/dist/Collection.d.ts.map +1 -0
  13. package/dist/Collection.js +195 -0
  14. package/dist/Collection.js.map +1 -0
  15. package/dist/Collections.d.ts +121 -0
  16. package/dist/Collections.d.ts.map +1 -0
  17. package/dist/Collections.js +121 -0
  18. package/dist/Collections.js.map +1 -0
  19. package/dist/DynamoClient.d.ts +317 -0
  20. package/dist/DynamoClient.d.ts.map +1 -0
  21. package/dist/DynamoClient.js +653 -0
  22. package/dist/DynamoClient.js.map +1 -0
  23. package/dist/DynamoModel.d.ts +278 -0
  24. package/dist/DynamoModel.d.ts.map +1 -0
  25. package/dist/DynamoModel.js +453 -0
  26. package/dist/DynamoModel.js.map +1 -0
  27. package/dist/DynamoSchema.d.ts +137 -0
  28. package/dist/DynamoSchema.d.ts.map +1 -0
  29. package/dist/DynamoSchema.js +188 -0
  30. package/dist/DynamoSchema.js.map +1 -0
  31. package/dist/Entity.d.ts +628 -0
  32. package/dist/Entity.d.ts.map +1 -0
  33. package/dist/Entity.js +2371 -0
  34. package/dist/Entity.js.map +1 -0
  35. package/dist/Errors.d.ts +227 -0
  36. package/dist/Errors.d.ts.map +1 -0
  37. package/dist/Errors.js +93 -0
  38. package/dist/Errors.js.map +1 -0
  39. package/dist/EventStore.d.ts +208 -0
  40. package/dist/EventStore.d.ts.map +1 -0
  41. package/dist/EventStore.js +333 -0
  42. package/dist/EventStore.js.map +1 -0
  43. package/dist/Expression.d.ts +50 -0
  44. package/dist/Expression.d.ts.map +1 -0
  45. package/dist/Expression.js +170 -0
  46. package/dist/Expression.js.map +1 -0
  47. package/dist/KeyComposer.d.ts +125 -0
  48. package/dist/KeyComposer.d.ts.map +1 -0
  49. package/dist/KeyComposer.js +257 -0
  50. package/dist/KeyComposer.js.map +1 -0
  51. package/dist/Marshaller.d.ts +30 -0
  52. package/dist/Marshaller.d.ts.map +1 -0
  53. package/dist/Marshaller.js +115 -0
  54. package/dist/Marshaller.js.map +1 -0
  55. package/dist/Projection.d.ts +28 -0
  56. package/dist/Projection.d.ts.map +1 -0
  57. package/dist/Projection.js +39 -0
  58. package/dist/Projection.js.map +1 -0
  59. package/dist/Query.d.ts +214 -0
  60. package/dist/Query.d.ts.map +1 -0
  61. package/dist/Query.js +397 -0
  62. package/dist/Query.js.map +1 -0
  63. package/dist/Table.d.ts +178 -0
  64. package/dist/Table.d.ts.map +1 -0
  65. package/dist/Table.js +211 -0
  66. package/dist/Table.js.map +1 -0
  67. package/dist/Transaction.d.ts +79 -0
  68. package/dist/Transaction.d.ts.map +1 -0
  69. package/dist/Transaction.js +215 -0
  70. package/dist/Transaction.js.map +1 -0
  71. package/dist/_AggregateCursor.d.ts +44 -0
  72. package/dist/_AggregateCursor.d.ts.map +1 -0
  73. package/dist/_AggregateCursor.js +18 -0
  74. package/dist/_AggregateCursor.js.map +1 -0
  75. package/dist/_AggregateEdges.d.ts +77 -0
  76. package/dist/_AggregateEdges.d.ts.map +1 -0
  77. package/dist/_AggregateEdges.js +41 -0
  78. package/dist/_AggregateEdges.js.map +1 -0
  79. package/dist/_AggregateSchemas.d.ts +69 -0
  80. package/dist/_AggregateSchemas.d.ts.map +1 -0
  81. package/dist/_AggregateSchemas.js +194 -0
  82. package/dist/_AggregateSchemas.js.map +1 -0
  83. package/dist/_AggregateTypes.d.ts +94 -0
  84. package/dist/_AggregateTypes.d.ts.map +1 -0
  85. package/dist/_AggregateTypes.js +7 -0
  86. package/dist/_AggregateTypes.js.map +1 -0
  87. package/dist/_EntityCombinators.d.ts +155 -0
  88. package/dist/_EntityCombinators.d.ts.map +1 -0
  89. package/dist/_EntityCombinators.js +158 -0
  90. package/dist/_EntityCombinators.js.map +1 -0
  91. package/dist/_EntityConfig.d.ts +100 -0
  92. package/dist/_EntityConfig.d.ts.map +1 -0
  93. package/dist/_EntityConfig.js +7 -0
  94. package/dist/_EntityConfig.js.map +1 -0
  95. package/dist/_EntityOps.d.ts +205 -0
  96. package/dist/_EntityOps.d.ts.map +1 -0
  97. package/dist/_EntityOps.js +137 -0
  98. package/dist/_EntityOps.js.map +1 -0
  99. package/dist/_EntitySchemas.d.ts +57 -0
  100. package/dist/_EntitySchemas.d.ts.map +1 -0
  101. package/dist/_EntitySchemas.js +298 -0
  102. package/dist/_EntitySchemas.js.map +1 -0
  103. package/dist/_EntityTypes.d.ts +81 -0
  104. package/dist/_EntityTypes.d.ts.map +1 -0
  105. package/dist/_EntityTypes.js +7 -0
  106. package/dist/_EntityTypes.js.map +1 -0
  107. package/dist/_sparse_check.d.ts +2 -0
  108. package/dist/_sparse_check.d.ts.map +1 -0
  109. package/dist/_sparse_check.js +193 -0
  110. package/dist/_sparse_check.js.map +1 -0
  111. package/dist/index.d.ts +35 -0
  112. package/dist/index.d.ts.map +1 -0
  113. package/dist/index.js +20 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/internal/AggregateCursor.d.ts +44 -0
  116. package/dist/internal/AggregateCursor.d.ts.map +1 -0
  117. package/dist/internal/AggregateCursor.js +18 -0
  118. package/dist/internal/AggregateCursor.js.map +1 -0
  119. package/dist/internal/AggregateEdges.d.ts +77 -0
  120. package/dist/internal/AggregateEdges.d.ts.map +1 -0
  121. package/dist/internal/AggregateEdges.js +41 -0
  122. package/dist/internal/AggregateEdges.js.map +1 -0
  123. package/dist/internal/AggregateSchemas.d.ts +69 -0
  124. package/dist/internal/AggregateSchemas.d.ts.map +1 -0
  125. package/dist/internal/AggregateSchemas.js +193 -0
  126. package/dist/internal/AggregateSchemas.js.map +1 -0
  127. package/dist/internal/AggregateTypes.d.ts +94 -0
  128. package/dist/internal/AggregateTypes.d.ts.map +1 -0
  129. package/dist/internal/AggregateTypes.js +7 -0
  130. package/dist/internal/AggregateTypes.js.map +1 -0
  131. package/dist/internal/BoundQuery.d.ts +107 -0
  132. package/dist/internal/BoundQuery.d.ts.map +1 -0
  133. package/dist/internal/BoundQuery.js +111 -0
  134. package/dist/internal/BoundQuery.js.map +1 -0
  135. package/dist/internal/EntityCombinators.d.ts +173 -0
  136. package/dist/internal/EntityCombinators.d.ts.map +1 -0
  137. package/dist/internal/EntityCombinators.js +183 -0
  138. package/dist/internal/EntityCombinators.js.map +1 -0
  139. package/dist/internal/EntityConfig.d.ts +100 -0
  140. package/dist/internal/EntityConfig.d.ts.map +1 -0
  141. package/dist/internal/EntityConfig.js +7 -0
  142. package/dist/internal/EntityConfig.js.map +1 -0
  143. package/dist/internal/EntityOps.d.ts +268 -0
  144. package/dist/internal/EntityOps.d.ts.map +1 -0
  145. package/dist/internal/EntityOps.js +153 -0
  146. package/dist/internal/EntityOps.js.map +1 -0
  147. package/dist/internal/EntitySchemas.d.ts +57 -0
  148. package/dist/internal/EntitySchemas.d.ts.map +1 -0
  149. package/dist/internal/EntitySchemas.js +299 -0
  150. package/dist/internal/EntitySchemas.js.map +1 -0
  151. package/dist/internal/EntityTypes.d.ts +128 -0
  152. package/dist/internal/EntityTypes.d.ts.map +1 -0
  153. package/dist/internal/EntityTypes.js +7 -0
  154. package/dist/internal/EntityTypes.js.map +1 -0
  155. package/dist/internal/Expr.d.ts +141 -0
  156. package/dist/internal/Expr.d.ts.map +1 -0
  157. package/dist/internal/Expr.js +332 -0
  158. package/dist/internal/Expr.js.map +1 -0
  159. package/dist/internal/PathBuilder.d.ts +88 -0
  160. package/dist/internal/PathBuilder.d.ts.map +1 -0
  161. package/dist/internal/PathBuilder.js +100 -0
  162. package/dist/internal/PathBuilder.js.map +1 -0
  163. package/dist/internal/TransactableOps.d.ts +25 -0
  164. package/dist/internal/TransactableOps.d.ts.map +1 -0
  165. package/dist/internal/TransactableOps.js +58 -0
  166. package/dist/internal/TransactableOps.js.map +1 -0
  167. package/dist/internal/sparse_check.d.ts +2 -0
  168. package/dist/internal/sparse_check.d.ts.map +1 -0
  169. package/dist/internal/sparse_check.js +196 -0
  170. package/dist/internal/sparse_check.js.map +1 -0
  171. package/package.json +71 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Justin Menga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # effect-dynamodb
2
+
3
+ Schema-driven DynamoDB ORM for [Effect TS](https://effect.website). Single-table design as a first-class pattern with type-safe entities, composite key composition, Stream-based pagination, and Layer-based dependency injection.
4
+
5
+ [![npm](https://img.shields.io/npm/v/effect-dynamodb)](https://www.npmjs.com/package/effect-dynamodb)
6
+ [![license](https://img.shields.io/npm/l/effect-dynamodb)](./LICENSE)
7
+
8
+ **Documentation:** https://jmenga.github.io/effect-dynamodb
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pnpm add effect-dynamodb effect @aws-sdk/client-dynamodb @aws-sdk/util-dynamodb
14
+ ```
15
+
16
+ `effect` is a peer dependency — install the version your application uses.
17
+
18
+ ## Quick start
19
+
20
+ ```typescript
21
+ import { Effect, Schema } from "effect"
22
+ import { DynamoSchema, Entity, Table, DynamoClient } from "effect-dynamodb"
23
+
24
+ class Task extends Schema.Class<Task>("Task")({
25
+ taskId: Schema.String,
26
+ projectId: Schema.String,
27
+ title: Schema.NonEmptyString,
28
+ status: Schema.Literals(["todo", "active", "done"]),
29
+ }) {}
30
+
31
+ const AppSchema = DynamoSchema.make({ name: "myapp", version: 1 })
32
+
33
+ const Tasks = Entity.make({
34
+ model: Task,
35
+ entityType: "Task",
36
+ primaryKey: {
37
+ pk: { field: "pk", composite: ["taskId"] },
38
+ sk: { field: "sk", composite: [] },
39
+ },
40
+ indexes: {
41
+ byProject: {
42
+ name: "gsi1",
43
+ pk: { field: "gsi1pk", composite: ["projectId"] },
44
+ sk: { field: "gsi1sk", composite: ["status", "taskId"] },
45
+ },
46
+ },
47
+ })
48
+
49
+ const MainTable = Table.make({ schema: AppSchema, entities: { Tasks } })
50
+
51
+ const program = Effect.gen(function* () {
52
+ const db = yield* DynamoClient.make({ entities: { Tasks }, tables: { MainTable } })
53
+
54
+ yield* db.entities.Tasks.put({
55
+ taskId: "t-1", projectId: "p-1", title: "Ship v1", status: "active",
56
+ })
57
+
58
+ const active = yield* db.entities.Tasks
59
+ .byProject({ projectId: "p-1" })
60
+ .filter((t, { eq }) => eq(t.status, "active"))
61
+ .collect()
62
+ })
63
+ ```
64
+
65
+ See the [full documentation](https://jmenga.github.io/effect-dynamodb) for guides, tutorials, and API reference.
66
+
67
+ ## License
68
+
69
+ [MIT](./LICENSE)
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Aggregate — Graph-based composite domain model for DynamoDB.
3
+ *
4
+ * An Aggregate binds a Schema.Class hierarchy to a graph of underlying entities
5
+ * sharing a partition key. The read path queries the collection, discriminates
6
+ * items by entity type + discriminators, and assembles them leaves-to-root into
7
+ * a Schema.Class instance.
8
+ *
9
+ * Created via {@link make}. Sub-aggregates compose recursively via `.with()`.
10
+ */
11
+ import { type Context, Effect, Schema } from "effect";
12
+ import { DynamoClient, type DynamoClientError } from "./DynamoClient.js";
13
+ import type * as DynamoSchemaModule from "./DynamoSchema.js";
14
+ import { AggregateAssemblyError, type AggregateDecompositionError, AggregateTransactionOverflow, type ItemNotFound, RefNotFound, TransactionCancelled, ValidationError } from "./Errors.js";
15
+ import type { Table, TableConfig } from "./Table.js";
16
+ export type { Cursor, DiscriminatorConfig, UpdateContext } from "./internal/AggregateCursor.js";
17
+ export { type AggregateEdge, isManyEdge, isOneEdge, isRefEdge, type ManyEdge, type ManyEdgeConfig, many, type OneEdge, one, type RefEdge, type RefEntity, ref, } from "./internal/AggregateEdges.js";
18
+ export { type DerivedAggregateSchemas, deriveAggregateSchemas, deriveElementInputSchema, deriveEntityFieldName, extractArrayElement, getSchemaFields, isFieldOptional, isSchemaMatchingEntity, unwrapModel, } from "./internal/AggregateSchemas.js";
19
+ export type { AggregateInputType, BoundSubAggregate, Input, Key, SubAggregate, Type, UpdateFn, } from "./internal/AggregateTypes.js";
20
+ import { type UpdateContext } from "./internal/AggregateCursor.js";
21
+ import type { AggregateEdge } from "./internal/AggregateEdges.js";
22
+ import type { AggregateInputType, BoundSubAggregate, SubAggregate } from "./internal/AggregateTypes.js";
23
+ export declare const TypeId: unique symbol;
24
+ export type TypeId = typeof TypeId;
25
+ /** Options for paginated list queries */
26
+ export interface ListOptions {
27
+ /** Maximum number of root items (aggregates) to return */
28
+ readonly limit?: number | undefined;
29
+ /** Opaque cursor from a previous list call to resume pagination */
30
+ readonly cursor?: string | undefined;
31
+ }
32
+ /** Result of a paginated list query */
33
+ export interface ListResult<T> {
34
+ /** The assembled aggregates for this page */
35
+ readonly data: Array<T>;
36
+ /** Opaque cursor for the next page, or null if no more results */
37
+ readonly cursor: string | null;
38
+ }
39
+ /** Error union for aggregate write operations */
40
+ type AggregateWriteError = AggregateAssemblyError | AggregateDecompositionError | AggregateTransactionOverflow | DynamoClientError | ValidationError | RefNotFound | ItemNotFound | TransactionCancelled;
41
+ /**
42
+ * An operational aggregate — returned by `Aggregate.make` with full config.
43
+ * Provides `get`, `create`, `update`, and `delete` for full CRUD lifecycle.
44
+ */
45
+ export interface Aggregate<TSchema extends Schema.Top, TKey extends Record<string, unknown>, TInput = unknown> {
46
+ readonly [TypeId]: TypeId;
47
+ readonly _tag: "Aggregate";
48
+ readonly schema: TSchema;
49
+ /**
50
+ * @internal Tag of the table this aggregate is bound to. Used by
51
+ * `DynamoClient.make()` to group aggregates with their table for
52
+ * `db.tables.X.create()` GSI derivation.
53
+ */
54
+ readonly _tableTag: Context.Service<TableConfig, TableConfig>;
55
+ /** Primary key field name (e.g., "pk") */
56
+ readonly pkField: string;
57
+ /** Collection GSI config — used for assembling aggregates by partition key */
58
+ readonly collection: {
59
+ readonly index: string;
60
+ readonly sk: {
61
+ readonly field: string;
62
+ };
63
+ };
64
+ /** List GSI config — used for listing/paginating aggregates. Undefined when not configured. */
65
+ readonly listIndex: {
66
+ readonly index: string;
67
+ readonly pk: {
68
+ readonly field: string;
69
+ };
70
+ readonly sk: {
71
+ readonly field: string;
72
+ };
73
+ } | undefined;
74
+ /** Fetch and assemble the aggregate by its partition key composites */
75
+ readonly get: (key: TKey) => Effect.Effect<Schema.Schema.Type<TSchema>, AggregateAssemblyError | DynamoClientError | ValidationError, DynamoClient | TableConfig>;
76
+ /**
77
+ * Create a new aggregate from input data.
78
+ * Ref fields accept IDs (e.g., `venueId` instead of `venue: Venue`).
79
+ * Refs are hydrated automatically via the `refs` config.
80
+ * Items are written via sub-aggregate transaction groups.
81
+ */
82
+ readonly create: (input: Record<string, unknown>) => Effect.Effect<Schema.Schema.Type<TSchema>, AggregateWriteError, DynamoClient | TableConfig>;
83
+ /**
84
+ * Update an aggregate: fetch current state, apply mutation, diff, write changes.
85
+ * Only changed sub-aggregate transaction groups are rewritten.
86
+ * Context field changes propagate to all member items.
87
+ *
88
+ * The mutation function receives an {@link UpdateContext} with:
89
+ * - `state` — current state as a plain object
90
+ * - `cursor` — pre-bound optic for navigating and transforming (`cursor.key("x").replace(v)`)
91
+ * - `optic` — composable optic for use with externally-defined lenses (pass `state` explicitly)
92
+ * - `current` — the Schema.Class instance (rarely needed)
93
+ *
94
+ * Return either a class instance or a plain object — the schema decode handles both.
95
+ */
96
+ readonly update: (key: TKey, mutationFn: (context: UpdateContext<TSchema["Iso"], Schema.Schema.Type<TSchema>>) => Schema.Schema.Type<TSchema> | TSchema["Iso"]) => Effect.Effect<Schema.Schema.Type<TSchema>, AggregateWriteError, DynamoClient | TableConfig>;
97
+ /** Delete an aggregate — removes all items in the partition. */
98
+ readonly delete: (key: TKey) => Effect.Effect<void, AggregateAssemblyError | DynamoClientError, DynamoClient | TableConfig>;
99
+ /**
100
+ * List aggregates by querying a list collection GSI for root items and assembling each.
101
+ *
102
+ * Requires `list` config on the aggregate. Queries the list collection GSI using
103
+ * filter as key composites. PK composites are required (or empty for shared
104
+ * partition), SK composites enable prefix filtering.
105
+ *
106
+ * Supports cursor-based pagination via `options.limit` and `options.cursor`.
107
+ * When `limit` is specified, returns at most that many aggregates plus a cursor
108
+ * for the next page. Without `limit`, returns all matching aggregates.
109
+ */
110
+ readonly list: (filter?: Record<string, unknown>, options?: ListOptions) => Effect.Effect<ListResult<Schema.Schema.Type<TSchema>>, AggregateAssemblyError | DynamoClientError | ValidationError, DynamoClient | TableConfig>;
111
+ /**
112
+ * Derived input schema for `create()`.
113
+ *
114
+ * Automatically transforms the domain model for use as an HTTP payload:
115
+ * - Ref fields become `${field}Id: string` (e.g., `venue: Venue` → `venueId: string`)
116
+ * - Date fields accept ISO 8601 strings (via `Schema.toCodecJson`)
117
+ * - PK composites (auto-generated) are omitted
118
+ * - Sub-aggregates and many-edges are recursed
119
+ */
120
+ readonly inputSchema: Schema.Codec<TInput>;
121
+ /** Alias for `inputSchema` — consistent with `Entity.createSchema`. */
122
+ readonly createSchema: Schema.Codec<TInput>;
123
+ /**
124
+ * Derived update schema — all `inputSchema` fields made optional.
125
+ *
126
+ * Use as the payload schema for HTTP update endpoints. The handler
127
+ * receives a validated partial payload and applies it inside the
128
+ * mutation function.
129
+ */
130
+ readonly updateSchema: Schema.Codec<Partial<TInput>>;
131
+ }
132
+ /**
133
+ * An Aggregate whose operations have `DynamoClient` and `TableConfig` already
134
+ * resolved, so all methods return `Effect<A, E, never>`.
135
+ *
136
+ * Created via {@link bind}. Use in service layers to avoid leaking infrastructure
137
+ * requirements through service method signatures.
138
+ */
139
+ export interface BoundAggregate<TSchema extends Schema.Top, TKey extends Record<string, unknown>, TInput = unknown> {
140
+ readonly schema: TSchema;
141
+ readonly get: (key: TKey) => Effect.Effect<Schema.Schema.Type<TSchema>, AggregateAssemblyError | DynamoClientError | ValidationError, never>;
142
+ readonly create: (input: Record<string, unknown>) => Effect.Effect<Schema.Schema.Type<TSchema>, AggregateWriteError, never>;
143
+ readonly update: (key: TKey, mutationFn: (context: UpdateContext<TSchema["Iso"], Schema.Schema.Type<TSchema>>) => Schema.Schema.Type<TSchema> | TSchema["Iso"]) => Effect.Effect<Schema.Schema.Type<TSchema>, AggregateWriteError, never>;
144
+ readonly delete: (key: TKey) => Effect.Effect<void, AggregateAssemblyError | DynamoClientError, never>;
145
+ readonly list: (filter?: Record<string, unknown>, options?: ListOptions) => Effect.Effect<ListResult<Schema.Schema.Type<TSchema>>, AggregateAssemblyError | DynamoClientError | ValidationError, never>;
146
+ readonly inputSchema: Schema.Codec<TInput>;
147
+ /** Alias for `inputSchema` — consistent with `Entity.createSchema`. */
148
+ readonly createSchema: Schema.Codec<TInput>;
149
+ /** Derived update schema — all `inputSchema` fields made optional. */
150
+ readonly updateSchema: Schema.Codec<Partial<TInput>>;
151
+ /** Eliminate DynamoClient | TableConfig from any effect using the pre-resolved context. */
152
+ readonly provide: <A, E>(effect: Effect.Effect<A, E, DynamoClient | TableConfig>) => Effect.Effect<A, E, never>;
153
+ }
154
+ interface SubAggregateConfig<TEdges extends Record<string, AggregateEdge | BoundSubAggregate<any, any>> = Record<string, AggregateEdge | BoundSubAggregate<any, any>>> {
155
+ readonly root: {
156
+ readonly entityType: string;
157
+ };
158
+ readonly edges: TEdges;
159
+ }
160
+ interface CollectionConfig {
161
+ readonly index: string;
162
+ readonly name: string;
163
+ readonly sk: {
164
+ readonly field: string;
165
+ readonly composite: ReadonlyArray<string>;
166
+ };
167
+ }
168
+ interface ListCollectionConfig extends CollectionConfig {
169
+ readonly pk: {
170
+ readonly field: string;
171
+ readonly composite: ReadonlyArray<string>;
172
+ };
173
+ readonly cardinality?: number | undefined;
174
+ }
175
+ interface AggregateConfig<_TSchema extends Schema.Top, TEdges extends Record<string, AggregateEdge | BoundSubAggregate<any, any>> = Record<string, AggregateEdge | BoundSubAggregate<any, any>>, TPK extends ReadonlyArray<string> = ReadonlyArray<string>> {
176
+ readonly table: Table;
177
+ readonly schema: DynamoSchemaModule.DynamoSchema;
178
+ readonly pk: {
179
+ readonly field: string;
180
+ readonly composite: TPK;
181
+ };
182
+ readonly collection: CollectionConfig;
183
+ readonly list?: ListCollectionConfig | undefined;
184
+ readonly context?: ReadonlyArray<string> | undefined;
185
+ readonly root: {
186
+ readonly entityType: string;
187
+ };
188
+ readonly edges: TEdges;
189
+ }
190
+ /**
191
+ * Create an aggregate definition.
192
+ *
193
+ * **Sub-aggregate form** — `Aggregate.make(Schema, { root, edges })`:
194
+ * Returns a composable SubAggregate with `.with()` for discriminator binding.
195
+ *
196
+ * **Top-level form** — `Aggregate.make(Schema, { table, schema, pk, collection, ... })`:
197
+ * Returns an operational Aggregate with `.get()` for reading.
198
+ */
199
+ export declare function make<TSchema extends Schema.Top, const TEdges extends Record<string, AggregateEdge | BoundSubAggregate<any, any>>>(schema: TSchema, config: SubAggregateConfig<TEdges> & {
200
+ readonly table?: undefined;
201
+ }): SubAggregate<TSchema, TEdges>;
202
+ export declare function make<TSchema extends Schema.Top, const TEdges extends Record<string, AggregateEdge | BoundSubAggregate<any, any>>, const TPK extends ReadonlyArray<string>>(schema: TSchema, config: AggregateConfig<TSchema, TEdges, TPK>): Aggregate<TSchema, Record<string, unknown>, AggregateInputType<Schema.Schema.Type<TSchema>, TEdges, TPK>>;
203
+ /**
204
+ * Bind an Aggregate to resolved `DynamoClient` and `TableConfig` services.
205
+ * Returns a {@link BoundAggregate} where all operations have `R = never`.
206
+ *
207
+ * @internal Used by `DynamoClient.make()` to bind aggregates.
208
+ */
209
+ export declare const bind: <TSchema extends Schema.Top, TKey extends Record<string, unknown>, TInput>(aggregate: Aggregate<TSchema, TKey, TInput>) => Effect.Effect<BoundAggregate<TSchema, TKey, TInput>, never, DynamoClient | TableConfig>;
210
+ //# sourceMappingURL=Aggregate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Aggregate.d.ts","sourceRoot":"","sources":["../src/Aggregate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAc,MAAM,EAAa,MAAM,QAAQ,CAAA;AAE5E,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAA4B,MAAM,mBAAmB,CAAA;AAGlG,OAAO,KAAK,KAAK,kBAAkB,MAAM,mBAAmB,CAAA;AAG5D,OAAO,EACL,sBAAsB,EACtB,KAAK,2BAA2B,EAChC,4BAA4B,EAC5B,KAAK,YAAY,EACjB,WAAW,EACX,oBAAoB,EACpB,eAAe,EAChB,MAAM,aAAa,CAAA;AASpB,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEpD,YAAY,EAAE,MAAM,EAAE,mBAAmB,EAAE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