@aurios/mizzle 1.1.1 → 1.1.3

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 (116) hide show
  1. package/.turbo/turbo-build.log +37 -0
  2. package/LICENSE +21 -0
  3. package/README.md +57 -0
  4. package/dist/chunk-AQVECMXP.js +1 -0
  5. package/dist/chunk-DU7UPWBW.js +1 -0
  6. package/dist/chunk-GPYZK4WY.js +1 -0
  7. package/dist/chunk-NPPZW6VT.js +1 -0
  8. package/dist/chunk-TOYV2M4M.js +1 -0
  9. package/dist/chunk-UM3YF5EC.js +1 -0
  10. package/dist/columns.d.ts +1 -0
  11. package/dist/columns.js +1 -0
  12. package/dist/db-zHIHBm1E.d.ts +815 -0
  13. package/dist/db.d.ts +3 -0
  14. package/dist/db.js +1 -0
  15. package/dist/diff.d.ts +18 -0
  16. package/dist/diff.js +1 -0
  17. package/dist/index.d.ts +42 -0
  18. package/dist/index.js +1 -0
  19. package/dist/introspection.d.ts +7 -0
  20. package/dist/introspection.js +1 -0
  21. package/dist/operators-BVreW0ky.d.ts +719 -0
  22. package/dist/snapshot.d.ts +24 -0
  23. package/dist/snapshot.js +1 -0
  24. package/dist/table.d.ts +1 -0
  25. package/dist/table.js +1 -0
  26. package/dist/transaction-RE7LXTGV.js +1 -0
  27. package/package.json +73 -24
  28. package/src/builders/base.ts +53 -56
  29. package/src/builders/batch-get.ts +63 -58
  30. package/src/builders/batch-write.ts +81 -78
  31. package/src/builders/delete.ts +46 -53
  32. package/src/builders/insert.ts +158 -150
  33. package/src/builders/query-promise.ts +26 -35
  34. package/src/builders/relational-builder.ts +214 -191
  35. package/src/builders/select.ts +250 -238
  36. package/src/builders/transaction.ts +170 -151
  37. package/src/builders/update.ts +198 -191
  38. package/src/columns/binary-set.ts +29 -38
  39. package/src/columns/binary.ts +25 -35
  40. package/src/columns/boolean.ts +25 -30
  41. package/src/columns/date.ts +57 -64
  42. package/src/columns/index.ts +15 -15
  43. package/src/columns/json.ts +39 -48
  44. package/src/columns/list.ts +26 -36
  45. package/src/columns/map.ts +26 -34
  46. package/src/columns/number-set.ts +29 -38
  47. package/src/columns/number.ts +33 -40
  48. package/src/columns/string-set.ts +38 -47
  49. package/src/columns/string.ts +37 -49
  50. package/src/columns/uuid.ts +26 -33
  51. package/src/core/client.ts +9 -9
  52. package/src/core/column-builder.ts +194 -220
  53. package/src/core/column.ts +127 -135
  54. package/src/core/diff.ts +40 -34
  55. package/src/core/errors.ts +20 -17
  56. package/src/core/introspection.ts +62 -58
  57. package/src/core/operations.ts +17 -23
  58. package/src/core/parser.ts +82 -88
  59. package/src/core/relations.ts +165 -152
  60. package/src/core/retry.ts +52 -52
  61. package/src/core/snapshot.ts +131 -130
  62. package/src/core/strategies.ts +222 -214
  63. package/src/core/table.ts +189 -202
  64. package/src/core/validation.ts +52 -52
  65. package/src/db.ts +216 -213
  66. package/src/expressions/actions.ts +26 -26
  67. package/src/expressions/builder.ts +62 -54
  68. package/src/expressions/operators.ts +48 -48
  69. package/src/expressions/update-builder.ts +79 -75
  70. package/src/index.ts +2 -1
  71. package/src/indexes.ts +8 -8
  72. package/test/batch-resilience.test.ts +138 -0
  73. package/test/builders/delete.test.ts +100 -0
  74. package/test/builders/insert.test.ts +216 -0
  75. package/test/builders/relational-types.test.ts +55 -0
  76. package/test/builders/relational.integration.test.ts +291 -0
  77. package/test/builders/relational.test.ts +66 -0
  78. package/test/builders/select.test.ts +411 -0
  79. package/test/builders/transaction-errors.test.ts +46 -0
  80. package/test/builders/transaction-execution.test.ts +99 -0
  81. package/test/builders/transaction-proxy.test.ts +41 -0
  82. package/test/builders/update-expression.test.ts +106 -0
  83. package/test/builders/update.test.ts +179 -0
  84. package/test/core/diff.test.ts +152 -0
  85. package/test/core/expressions.test.ts +64 -0
  86. package/test/core/introspection.test.ts +47 -0
  87. package/test/core/parser.test.ts +69 -0
  88. package/test/core/snapshot-gen.test.ts +155 -0
  89. package/test/core/snapshot.test.ts +52 -0
  90. package/test/date-column.test.ts +159 -0
  91. package/test/fluent-writes.integration.test.ts +148 -0
  92. package/test/integration-retry.test.ts +77 -0
  93. package/test/integration.test.ts +105 -0
  94. package/test/item-size-error.test.ts +16 -0
  95. package/test/item-size-validation.test.ts +82 -0
  96. package/test/item-size.test.ts +47 -0
  97. package/test/iterator-pagination.integration.test.ts +132 -0
  98. package/test/jsdoc-builders.test.ts +55 -0
  99. package/test/jsdoc-schema.test.ts +107 -0
  100. package/test/json-column.test.ts +51 -0
  101. package/test/metadata.test.ts +54 -0
  102. package/test/mizzle-package.test.ts +20 -0
  103. package/test/relational-centralized.test.ts +83 -0
  104. package/test/relational-definition.test.ts +75 -0
  105. package/test/relational-init.test.ts +30 -0
  106. package/test/relational-proxy.test.ts +52 -0
  107. package/test/relations.test.ts +45 -0
  108. package/test/resilience-config.test.ts +34 -0
  109. package/test/retry-handler.test.ts +63 -0
  110. package/test/transaction.integration.test.ts +153 -0
  111. package/test/unified-select.integration.test.ts +153 -0
  112. package/test/unified-update.integration.test.ts +139 -0
  113. package/test/update.integration.test.ts +132 -0
  114. package/tsconfig.json +12 -9
  115. package/tsup.config.ts +11 -11
  116. package/vitest.config.ts +8 -0
package/src/db.ts CHANGED
@@ -3,6 +3,7 @@ import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
3
3
  import { InsertBuilder } from "./builders/insert";
4
4
  import { RelationnalQueryBuilder } from "./builders/relational-builder";
5
5
  import { SelectBuilder, type SelectedFields } from "./builders/select";
6
+ import type { BaseBuilder } from "./builders/base";
6
7
  import type { Entity, InferInsertModel, InferSelectModel } from "./core/table";
7
8
  import { UpdateBuilder } from "./builders/update";
8
9
  import { DeleteBuilder } from "./builders/delete";
@@ -13,259 +14,261 @@ import { extractMetadata, type InternalRelationalSchema } from "./core/relations
13
14
  import { RetryHandler, type RetryConfig } from "./core/retry";
14
15
  import { MizzleClient, type IMizzleClient } from "./core/client";
15
16
 
16
- export type QuerySchema<TSchema extends Record<string, unknown>> = {
17
- [K in keyof TSchema as TSchema[K] extends Entity ? K : never]: RelationnalQueryBuilder<TSchema[K] extends Entity ? TSchema[K] : never>;
17
+ export type QuerySchema<TSchema extends Record<string, any>> = {
18
+ [K in keyof TSchema as TSchema[K] extends Entity ? K : never]: RelationnalQueryBuilder<
19
+ TSchema[K] extends Entity ? TSchema[K] : never
20
+ >;
18
21
  };
19
22
 
20
23
  /**
21
24
  * DynamoDB database instance.
22
25
  */
23
- export class DynamoDB<TSchema extends Record<string, unknown> = Record<string, unknown>> {
24
- private docClient: IMizzleClient;
25
- private schema?: InternalRelationalSchema;
26
- private retryConfig: RetryConfig;
26
+ export class DynamoDB<TSchema extends Record<string, any> = Record<string, any>> {
27
+ private docClient: IMizzleClient;
28
+ private schema?: InternalRelationalSchema;
29
+ private retryConfig: RetryConfig;
27
30
 
28
- /**
29
- * Access relational queries for entities defined in the schema.
30
- *
31
- * @example
32
- * ```ts
33
- * const users = await db.query.users.findMany();
34
- * ```
35
- */
36
- public readonly query: QuerySchema<TSchema>;
31
+ /**
32
+ * Access relational queries for entities defined in the schema.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const users = await db.query.users.findMany();
37
+ * ```
38
+ */
39
+ public readonly query: QuerySchema<TSchema>;
37
40
 
38
- constructor(client: DynamoDBClient, relations?: TSchema, retry?: Partial<RetryConfig>) {
39
- this.retryConfig = {
40
- maxAttempts: retry?.maxAttempts ?? 3,
41
- baseDelay: retry?.baseDelay ?? 100,
42
- };
43
- this.docClient = new MizzleClient(
44
- DynamoDBDocumentClient.from(client),
45
- new RetryHandler(this.retryConfig)
46
- );
47
-
48
- if (relations) {
49
- this.schema = extractMetadata(relations);
50
- }
41
+ constructor(client: DynamoDBClient, relations?: TSchema, retry?: Partial<RetryConfig>) {
42
+ this.retryConfig = {
43
+ maxAttempts: retry?.maxAttempts ?? 3,
44
+ baseDelay: retry?.baseDelay ?? 100,
45
+ };
46
+ this.docClient = new MizzleClient(
47
+ DynamoDBDocumentClient.from(client),
48
+ new RetryHandler(this.retryConfig),
49
+ );
51
50
 
52
- this.query = new Proxy({} as QuerySchema<TSchema>, {
53
- get: (_, prop) => {
54
- if (typeof prop !== 'string') return undefined;
51
+ if (relations) {
52
+ this.schema = extractMetadata(relations);
53
+ }
55
54
 
56
- if (!this.schema) {
57
- throw new Error("No relations defined. Initialize mizzle with a relations object to use db.query.");
58
- }
55
+ this.query = new Proxy({} as QuerySchema<TSchema>, {
56
+ get: (_, prop) => {
57
+ if (typeof prop !== "string") return undefined;
59
58
 
60
- const entityMetadata = this.schema.entities[prop];
61
- if (!entityMetadata) {
62
- throw new Error(`Entity ${prop} not found in relations schema.`);
63
- }
59
+ if (!this.schema) {
60
+ throw new Error(
61
+ "No relations defined. Initialize mizzle with a relations object to use db.query.",
62
+ );
63
+ }
64
64
 
65
- return new RelationnalQueryBuilder(this.docClient, entityMetadata.entity, this.schema, prop);
66
- }
67
- });
68
- }
65
+ const entityMetadata = this.schema.entities[prop];
66
+ if (!entityMetadata) {
67
+ throw new Error(`Entity ${prop} not found in relations schema.`);
68
+ }
69
69
 
70
- /**
71
- * Insert a new record into the database.
72
- *
73
- * @example
74
- * ```ts
75
- * await db.insert(users).values({ id: "1", name: "Alice" }).execute();
76
- * ```
77
- *
78
- * @param table The entity definition to insert into.
79
- * @returns An InsertBuilder instance.
80
- */
81
- insert<T extends Entity>(table: T): InsertBuilder<T> {
82
- return new InsertBuilder(table, this.docClient);
83
- }
70
+ return new RelationnalQueryBuilder(
71
+ this.docClient,
72
+ entityMetadata.entity,
73
+ this.schema,
74
+ prop,
75
+ );
76
+ },
77
+ });
78
+ }
84
79
 
85
- /**
86
- * Select records from the database.
87
- *
88
- * @example
89
- * ```ts
90
- * const results = await db.select().from(users).where(eq(users.id, "1")).execute();
91
- * ```
92
- *
93
- * @param fields Optional specific fields to select. If omitted, all fields are returned.
94
- * @returns A SelectBuilder instance.
95
- */
96
- select<TSelection extends SelectedFields>(
97
- fields?: TSelection,
98
- ): SelectBuilder<TSelection | undefined> {
99
- return new SelectBuilder(this.docClient, fields);
100
- }
80
+ /**
81
+ * Insert a new record into the database.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * await db.insert(users).values({ id: "1", name: "Alice" }).execute();
86
+ * ```
87
+ *
88
+ * @param table The entity definition to insert into.
89
+ * @returns An InsertBuilder instance.
90
+ */
91
+ insert<T extends Entity>(table: T): InsertBuilder<T> {
92
+ return new InsertBuilder(table, this.docClient);
93
+ }
101
94
 
102
- /**
103
- * Batch get multiple items from the database in a single request.
104
- *
105
- * @example
106
- * ```ts
107
- * const items = await db.batchGet(users, [{ id: "1" }, { id: "2" }]).execute();
108
- * ```
109
- *
110
- * @param entity The entity definition.
111
- * @param keys An array of primary key objects to fetch.
112
- * @returns A BatchGetBuilder instance.
113
- */
114
- batchGet<T extends Entity>(
115
- entity: T,
116
- keys: Partial<InferSelectModel<T>>[],
117
- ) {
118
- return new BatchGetBuilder(this.docClient).items(entity, keys);
119
- }
95
+ /**
96
+ * Select records from the database.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const results = await db.select().from(users).where(eq(users.id, "1")).execute();
101
+ * ```
102
+ *
103
+ * @param fields Optional specific fields to select. If omitted, all fields are returned.
104
+ * @returns A SelectBuilder instance.
105
+ */
106
+ select<TSelection extends SelectedFields>(
107
+ fields?: TSelection,
108
+ ): SelectBuilder<TSelection | undefined> {
109
+ return new SelectBuilder(this.docClient, fields);
110
+ }
120
111
 
121
- /**
122
- * Batch write (insert or delete) multiple items in a single request.
123
- *
124
- * @example
125
- * ```ts
126
- * await db.batchWrite(users, [
127
- * { type: "put", item: { id: "1", name: "Alice" } },
128
- * { type: "delete", key: { id: "2" } }
129
- * ]).execute();
130
- * ```
131
- *
132
- * @param entity The entity definition.
133
- * @param operations An array of batch operations.
134
- * @returns A BatchWriteBuilder instance.
135
- */
136
- batchWrite<T extends Entity>(
137
- entity: T,
138
- operations: BatchWriteOperation<T>[],
139
- ) {
140
- return new BatchWriteBuilder(this.docClient).operations(entity, operations);
141
- }
112
+ /**
113
+ * Batch get multiple items from the database in a single request.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const items = await db.batchGet(users, [{ id: "1" }, { id: "2" }]).execute();
118
+ * ```
119
+ *
120
+ * @param entity The entity definition.
121
+ * @param keys An array of primary key objects to fetch.
122
+ * @returns A BatchGetBuilder instance.
123
+ */
124
+ batchGet<T extends Entity>(entity: T, keys: Partial<InferSelectModel<T>>[]) {
125
+ return new BatchGetBuilder(this.docClient).items(entity, keys);
126
+ }
142
127
 
143
- /**
144
- * Start a relational query manually for a specific entity.
145
- * @internal
146
- */
147
- _query<T extends Entity>(table: T) {
148
- return new RelationnalQueryBuilder<T>(this.docClient, table);
149
- }
128
+ /**
129
+ * Batch write (insert or delete) multiple items in a single request.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * await db.batchWrite(users, [
134
+ * { type: "put", item: { id: "1", name: "Alice" } },
135
+ * { type: "delete", key: { id: "2" } }
136
+ * ]).execute();
137
+ * ```
138
+ *
139
+ * @param entity The entity definition.
140
+ * @param operations An array of batch operations.
141
+ * @returns A BatchWriteBuilder instance.
142
+ */
143
+ batchWrite<T extends Entity>(entity: T, operations: BatchWriteOperation<T>[]) {
144
+ return new BatchWriteBuilder(this.docClient).operations(entity, operations);
145
+ }
150
146
 
151
- /**
152
- * Update existing records in the database.
153
- *
154
- * @example
155
- * ```ts
156
- * await db.update(users).set({ name: "Bob" }).where(eq(users.id, "1")).execute();
157
- * ```
158
- *
159
- * @param table The entity definition to update.
160
- * @returns An UpdateBuilder instance.
161
- */
162
- update<T extends Entity>(table: T): UpdateBuilder<T> {
163
- return new UpdateBuilder(table, this.docClient);
164
- }
147
+ /**
148
+ * Start a relational query manually for a specific entity.
149
+ * @internal
150
+ */
151
+ _query<T extends Entity>(table: T) {
152
+ return new RelationnalQueryBuilder<T>(this.docClient, table);
153
+ }
165
154
 
166
- /**
167
- * Delete records from the database.
168
- *
169
- * @example
170
- * ```ts
171
- * await db.delete(users, { id: "1" }).execute();
172
- * ```
173
- *
174
- * @param table The entity definition to delete from.
175
- * @param keys The primary key(s) of the item to delete.
176
- * @returns A DeleteBuilder instance.
177
- */
178
- delete<T extends Entity>(
179
- table: T,
180
- keys: Partial<InferInsertModel<T>>,
181
- ): DeleteBuilder<T> {
182
- return new DeleteBuilder(table, this.docClient, keys as Record<string, unknown>);
183
- }
155
+ /**
156
+ * Update existing records in the database.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * await db.update(users).set({ name: "Bob" }).where(eq(users.id, "1")).execute();
161
+ * ```
162
+ *
163
+ * @param table The entity definition to update.
164
+ * @returns An UpdateBuilder instance.
165
+ */
166
+ update<T extends Entity>(table: T): UpdateBuilder<T> {
167
+ return new UpdateBuilder(table, this.docClient);
168
+ }
184
169
 
185
- /**
186
- * Execute multiple operations atomically in a single DynamoDB transaction.
187
- *
188
- * @example
189
- * ```ts
190
- * await db.transaction("unique-token", (tx) => [
191
- * tx.insert(users).values({ id: "1", name: "Alice" }),
192
- * tx.update(stats).set({ count: sql`${stats.count} + 1` }).where(eq(stats.id, "global"))
193
- * ]);
194
- * ```
195
- *
196
- * @param token A unique client request token for idempotency.
197
- * @param callback A function that receives a transaction proxy and returns an array of operations.
198
- * @returns A promise that resolves when the transaction completes.
199
- * @throws Error if the transaction is cancelled or fails.
200
- */
201
- async transaction(
202
- token: string,
203
- callback: (tx: TransactionProxy) => any[] | Promise<any[]>
204
- ): Promise<void> {
205
- const proxy = new TransactionProxy(this.docClient);
206
- const operations = await callback(proxy);
207
-
208
- if (operations.length === 0) return;
209
- if (operations.length > 100) {
210
- throw new Error("DynamoDB transactions are limited to 100 items.");
211
- }
170
+ /**
171
+ * Delete records from the database.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * await db.delete(users, { id: "1" }).execute();
176
+ * ```
177
+ *
178
+ * @param table The entity definition to delete from.
179
+ * @param keys The primary key(s) of the item to delete.
180
+ * @returns A DeleteBuilder instance.
181
+ */
182
+ delete<T extends Entity>(table: T, keys: Partial<InferInsertModel<T>>): DeleteBuilder<T> {
183
+ return new DeleteBuilder(table, this.docClient, keys as Record<string, unknown>);
184
+ }
185
+
186
+ /**
187
+ * Execute multiple operations atomically in a single DynamoDB transaction.
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * await db.transaction("unique-token", (tx) => [
192
+ * tx.insert(users).values({ id: "1", name: "Alice" }),
193
+ * tx.update(stats).set({ count: sql`${stats.count} + 1` }).where(eq(stats.id, "global"))
194
+ * ]);
195
+ * ```
196
+ *
197
+ * @param token A unique client request token for idempotency.
198
+ * @param callback A function that receives a transaction proxy and returns an array of operations.
199
+ * @returns A promise that resolves when the transaction completes.
200
+ * @throws Error if the transaction is cancelled or fails.
201
+ */
202
+ async transaction(
203
+ token: string,
204
+ callback: (
205
+ tx: TransactionProxy,
206
+ ) => BaseBuilder<Entity, unknown>[] | Promise<BaseBuilder<Entity, unknown>[]>,
207
+ ): Promise<void> {
208
+ const proxy = new TransactionProxy(this.docClient);
209
+ const operations = await callback(proxy);
212
210
 
213
- // Executor will be implemented in transaction.ts
214
- const { TransactionExecutor } = await import("./builders/transaction");
215
- const executor = new TransactionExecutor(this.docClient);
216
- await executor.execute(token, operations);
211
+ if (operations.length === 0) return;
212
+ if (operations.length > 100) {
213
+ throw new Error("DynamoDB transactions are limited to 100 items.");
217
214
  }
215
+
216
+ // Executor will be implemented in transaction.ts
217
+ const { TransactionExecutor } = await import("./builders/transaction");
218
+ const executor = new TransactionExecutor(this.docClient);
219
+ await executor.execute(token, operations);
220
+ }
218
221
  }
219
222
 
220
223
  /**
221
224
  * Configuration for initializing Mizzle.
222
225
  */
223
- export interface MizzleConfig<TSchema extends Record<string, unknown> = Record<string, unknown>> {
224
- /**
225
- * AWS DynamoDB Client instance from `@aws-sdk/client-dynamodb`.
226
- */
227
- client: DynamoDBClient;
228
- /**
229
- * Relational schema definition for using `db.query`.
230
- */
231
- relations?: TSchema;
232
- /**
233
- * Optional retry configuration for transient DynamoDB errors.
234
- */
235
- retry?: Partial<RetryConfig>;
226
+ export interface MizzleConfig<TSchema extends Record<string, any> = Record<string, any>> {
227
+ /**
228
+ * AWS DynamoDB Client instance from `@aws-sdk/client-dynamodb`.
229
+ */
230
+ client: DynamoDBClient;
231
+ /**
232
+ * Relational schema definition for using `db.query`.
233
+ */
234
+ relations?: TSchema;
235
+ /**
236
+ * Optional retry configuration for transient DynamoDB errors.
237
+ */
238
+ retry?: Partial<RetryConfig>;
236
239
  }
237
240
 
238
241
  /**
239
242
  * Initializes a Mizzle database instance.
240
- *
243
+ *
241
244
  * @example
242
245
  * ```ts
243
246
  * // Basic initialization
244
247
  * const db = mizzle(new DynamoDBClient({}));
245
- *
248
+ *
246
249
  * // Initialization with relational schema
247
- * const db = mizzle({
250
+ * const db = mizzle({
248
251
  * client: new DynamoDBClient({}),
249
- * relations: { users, posts }
252
+ * relations: { users, posts }
250
253
  * });
251
254
  * ```
252
- *
255
+ *
253
256
  * @param config A DynamoDBClient instance or a MizzleConfig object.
254
257
  * @returns A DynamoDB instance for performing database operations.
255
258
  */
256
- export function mizzle<TSchema extends Record<string, unknown> = Record<string, unknown>>(
257
- config: DynamoDBClient | MizzleConfig<TSchema>
259
+ export function mizzle<TSchema extends Record<string, any> = Record<string, any>>(
260
+ config: DynamoDBClient | MizzleConfig<TSchema>,
258
261
  ): DynamoDB<TSchema> {
259
- if (config instanceof DynamoDBClient) {
260
- return new DynamoDB(config);
261
- }
262
-
263
- if ("client" in config && config.client instanceof DynamoDBClient) {
264
- return new DynamoDB(config.client, config.relations, config.retry);
265
- }
266
- // Fallback for cases where instanceof might fail due to multiple SDK versions
267
- if ("client" in config && config.client) {
268
- return new DynamoDB(config.client as DynamoDBClient, config.relations, config.retry);
269
- }
270
- return new DynamoDB(config as unknown as DynamoDBClient);
262
+ if (config instanceof DynamoDBClient) {
263
+ return new DynamoDB(config);
264
+ }
265
+
266
+ if ("client" in config && config.client instanceof DynamoDBClient) {
267
+ return new DynamoDB(config.client, config.relations, config.retry);
268
+ }
269
+ // Fallback for cases where instanceof might fail due to multiple SDK versions
270
+ if ("client" in config && config.client) {
271
+ return new DynamoDB(config.client as DynamoDBClient, config.relations, config.retry);
272
+ }
273
+ return new DynamoDB(config as unknown as DynamoDBClient);
271
274
  }
@@ -1,66 +1,66 @@
1
1
  export type ActionType = "SET" | "ADD" | "REMOVE" | "DELETE";
2
2
 
3
3
  export abstract class UpdateAction {
4
- abstract readonly action: ActionType;
4
+ abstract readonly action: ActionType;
5
5
  }
6
6
 
7
7
  export class SetAction extends UpdateAction {
8
- readonly action = "SET";
9
- constructor(
10
- readonly value: unknown,
11
- readonly functionName?: "list_append" | "if_not_exists",
12
- readonly usePathAsFirstArg: boolean = false
13
- ) {
14
- super();
15
- }
8
+ readonly action = "SET";
9
+ constructor(
10
+ readonly value: unknown,
11
+ readonly functionName?: "list_append" | "if_not_exists",
12
+ readonly usePathAsFirstArg: boolean = false,
13
+ ) {
14
+ super();
15
+ }
16
16
  }
17
17
 
18
18
  export class AddAction extends UpdateAction {
19
- readonly action = "ADD";
20
- constructor(readonly value: unknown) {
21
- super();
22
- }
19
+ readonly action = "ADD";
20
+ constructor(readonly value: unknown) {
21
+ super();
22
+ }
23
23
  }
24
24
 
25
25
  export class RemoveAction extends UpdateAction {
26
- readonly action = "REMOVE";
26
+ readonly action = "REMOVE";
27
27
  }
28
28
 
29
29
  export class DeleteAction extends UpdateAction {
30
- readonly action = "DELETE";
31
- constructor(readonly value: unknown) {
32
- super();
33
- }
30
+ readonly action = "DELETE";
31
+ constructor(readonly value: unknown) {
32
+ super();
33
+ }
34
34
  }
35
35
 
36
36
  export function add(value: number | Set<unknown>) {
37
- return new AddAction(value);
37
+ return new AddAction(value);
38
38
  }
39
39
 
40
40
  /**
41
41
  * Maps to list_append(path, :value)
42
42
  */
43
43
  export function append(value: unknown[]) {
44
- return new SetAction(value, "list_append", true);
44
+ return new SetAction(value, "list_append", true);
45
45
  }
46
46
 
47
47
  /**
48
48
  * Maps to if_not_exists(path, :value)
49
49
  */
50
50
  export function ifNotExists(value: unknown) {
51
- return new SetAction(value, "if_not_exists", true);
51
+ return new SetAction(value, "if_not_exists", true);
52
52
  }
53
53
 
54
54
  export function remove() {
55
- return new RemoveAction();
55
+ return new RemoveAction();
56
56
  }
57
57
 
58
58
  export function addToSet(values: Set<unknown> | unknown[]) {
59
- const value = Array.isArray(values) ? new Set(values) : values;
60
- return new AddAction(value);
59
+ const value = Array.isArray(values) ? new Set(values) : values;
60
+ return new AddAction(value);
61
61
  }
62
62
 
63
63
  export function deleteFromSet(values: Set<unknown> | unknown[]) {
64
- const value = Array.isArray(values) ? new Set(values) : values;
65
- return new DeleteAction(value);
64
+ const value = Array.isArray(values) ? new Set(values) : values;
65
+ return new DeleteAction(value);
66
66
  }