dyno-table 1.3.0 → 1.4.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 (66) hide show
  1. package/README.md +3 -6
  2. package/dist/{builder-types-C_PDZhnP.d.ts → builder-types-B_tCpn9F.d.ts} +2 -1
  3. package/dist/{builder-types-DtwbqMeF.d.cts → builder-types-DlaUSc-b.d.cts} +2 -1
  4. package/dist/builders/condition-check-builder.cjs +22 -0
  5. package/dist/builders/condition-check-builder.cjs.map +1 -1
  6. package/dist/builders/condition-check-builder.d.cts +2 -2
  7. package/dist/builders/condition-check-builder.d.ts +2 -2
  8. package/dist/builders/condition-check-builder.js +22 -0
  9. package/dist/builders/condition-check-builder.js.map +1 -1
  10. package/dist/builders/delete-builder.cjs +22 -0
  11. package/dist/builders/delete-builder.cjs.map +1 -1
  12. package/dist/builders/delete-builder.d.cts +2 -2
  13. package/dist/builders/delete-builder.d.ts +2 -2
  14. package/dist/builders/delete-builder.js +22 -0
  15. package/dist/builders/delete-builder.js.map +1 -1
  16. package/dist/builders/paginator.d.cts +1 -1
  17. package/dist/builders/paginator.d.ts +1 -1
  18. package/dist/builders/put-builder.cjs +30 -2
  19. package/dist/builders/put-builder.cjs.map +1 -1
  20. package/dist/builders/put-builder.d.cts +14 -7
  21. package/dist/builders/put-builder.d.ts +14 -7
  22. package/dist/builders/put-builder.js +30 -2
  23. package/dist/builders/put-builder.js.map +1 -1
  24. package/dist/builders/query-builder.cjs +6 -0
  25. package/dist/builders/query-builder.cjs.map +1 -1
  26. package/dist/builders/query-builder.d.cts +3 -3
  27. package/dist/builders/query-builder.d.ts +3 -3
  28. package/dist/builders/query-builder.js +6 -0
  29. package/dist/builders/query-builder.js.map +1 -1
  30. package/dist/builders/transaction-builder.cjs +16 -0
  31. package/dist/builders/transaction-builder.cjs.map +1 -1
  32. package/dist/builders/transaction-builder.d.cts +2 -2
  33. package/dist/builders/transaction-builder.d.ts +2 -2
  34. package/dist/builders/transaction-builder.js +16 -0
  35. package/dist/builders/transaction-builder.js.map +1 -1
  36. package/dist/builders/update-builder.cjs +22 -0
  37. package/dist/builders/update-builder.cjs.map +1 -1
  38. package/dist/builders/update-builder.d.cts +2 -2
  39. package/dist/builders/update-builder.d.ts +2 -2
  40. package/dist/builders/update-builder.js +22 -0
  41. package/dist/builders/update-builder.js.map +1 -1
  42. package/dist/conditions-BIpBkh4m.d.ts +729 -0
  43. package/dist/conditions-x6kGWMR7.d.cts +729 -0
  44. package/dist/conditions.cjs +6 -0
  45. package/dist/conditions.cjs.map +1 -1
  46. package/dist/conditions.d.cts +1 -1
  47. package/dist/conditions.d.ts +1 -1
  48. package/dist/conditions.js +6 -1
  49. package/dist/conditions.js.map +1 -1
  50. package/dist/entity.cjs.map +1 -1
  51. package/dist/entity.d.cts +4 -4
  52. package/dist/entity.d.ts +4 -4
  53. package/dist/entity.js.map +1 -1
  54. package/dist/{query-builder-D2FM9rsu.d.cts → query-builder-Dg9Loeco.d.cts} +2 -2
  55. package/dist/{query-builder-Csror9Iu.d.ts → query-builder-H9Dn0qaS.d.ts} +2 -2
  56. package/dist/{table-CM56NptV.d.cts → table-CmIQe-jD.d.cts} +30 -5
  57. package/dist/{table-B3fvMnkB.d.ts → table-TI4ULfra.d.ts} +30 -5
  58. package/dist/table.cjs +68 -8
  59. package/dist/table.cjs.map +1 -1
  60. package/dist/table.d.cts +4 -4
  61. package/dist/table.d.ts +4 -4
  62. package/dist/table.js +68 -8
  63. package/dist/table.js.map +1 -1
  64. package/package.json +1 -1
  65. package/dist/conditions--ld9a78i.d.ts +0 -331
  66. package/dist/conditions-ChhQWd6z.d.cts +0 -331
@@ -0,0 +1,729 @@
1
+ import { DynamoItem } from './types.js';
2
+
3
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
4
+ type IsEqual<T1, T2> = T1 extends T2 ? (<G>() => G extends T1 ? 1 : 2) extends <G>() => G extends T2 ? 1 : 2 ? true : false : false;
5
+ interface File extends Blob {
6
+ readonly lastModified: number;
7
+ readonly name: string;
8
+ }
9
+ interface FileList {
10
+ readonly length: number;
11
+ item(index: number): File | null;
12
+ [index: number]: File;
13
+ }
14
+ type BrowserNativeObject = Date | FileList | File;
15
+ type IsTuple<T extends ReadonlyArray<any>> = number extends T["length"] ? false : true;
16
+ type TupleKeys<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
17
+ type AnyIsEqual<T1, T2> = T1 extends T2 ? (IsEqual<T1, T2> extends true ? true : never) : never;
18
+ type PathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? `${K}` : true extends AnyIsEqual<TraversedTypes, V> ? `${K}` : `${K}` | `${K}.${PathInternal<V, TraversedTypes | V>}`;
19
+ type ArrayKey = number;
20
+ type PathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
21
+ [K in TupleKeys<T>]-?: PathImpl<K & string, T[K], TraversedTypes>;
22
+ }[TupleKeys<T>] : PathImpl<ArrayKey, V, TraversedTypes> : {
23
+ [K in keyof T]-?: PathImpl<K & string, T[K], TraversedTypes>;
24
+ }[keyof T];
25
+ type Path<T> = T extends any ? PathInternal<T> : never;
26
+ type PathType<T, K extends keyof any> = K extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends keyof any ? PathType<T[Key], Rest> : never : never : K extends keyof T ? T[K] : never;
27
+
28
+ /**
29
+ * Supported comparison operators for DynamoDB conditions.
30
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html AWS DynamoDB - Comparison Operator Reference}
31
+ *
32
+ * - eq: Equals (=)
33
+ * - ne: Not equals (≠ / <>)
34
+ * - lt: Less than (<)
35
+ * - lte: Less than or equal to (≤)
36
+ * - gt: Greater than (>)
37
+ * - gte: Greater than or equal to (≥)
38
+ * - between: Between two values (inclusive)
39
+ * - in: Checks if attribute value is in a list of values
40
+ * - beginsWith: Checks if string attribute begins with specified substring
41
+ * - contains: Checks if string/set attribute contains specified value
42
+ * - attributeExists: Checks if attribute exists
43
+ * - attributeNotExists: Checks if attribute does not exist
44
+ */
45
+ type ComparisonOperator = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "between" | "in" | "beginsWith" | "contains" | "attributeExists" | "attributeNotExists";
46
+ /**
47
+ * Logical operators for combining multiple conditions.
48
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - Logical Operator Reference}
49
+ *
50
+ * - and: Evaluates to true if all conditions are true
51
+ * - or: Evaluates to true if any condition is true
52
+ * - not: Negate the result of a condition
53
+ */
54
+ type LogicalOperator = "and" | "or" | "not";
55
+ /**
56
+ * Represents a DynamoDB condition expression.
57
+ * Can be either a comparison condition or a logical combination of conditions.
58
+ *
59
+ * @example
60
+ * // Simple comparison condition
61
+ * const condition: Condition = {
62
+ * type: "eq",
63
+ * attr: "status",
64
+ * value: "ACTIVE"
65
+ * };
66
+ *
67
+ * @example
68
+ * // Logical combination of conditions
69
+ * const condition: Condition = {
70
+ * type: "and",
71
+ * conditions: [
72
+ * { type: "eq", attr: "status", value: "ACTIVE" },
73
+ * { type: "gt", attr: "age", value: 5 }
74
+ * ]
75
+ * };
76
+ */
77
+ interface Condition {
78
+ /** The type of condition (comparison or logical operator) */
79
+ type: ComparisonOperator | LogicalOperator;
80
+ /** The attribute name for comparison conditions */
81
+ attr?: string;
82
+ /** The value to compare against for comparison conditions */
83
+ value?: unknown;
84
+ /** Array of conditions for logical operators (and/or) */
85
+ conditions?: Condition[];
86
+ /** Single condition for the 'not' operator */
87
+ condition?: Condition;
88
+ }
89
+ /**
90
+ * Parameters used to build DynamoDB expression strings.
91
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html Expression Attribute Names}
92
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeValues.html Expression Attribute Values}
93
+ */
94
+ interface ExpressionParams {
95
+ /** Map of attribute name placeholders to actual attribute names */
96
+ expressionAttributeNames: Record<string, string>;
97
+ /** Map of value placeholders to actual values */
98
+ expressionAttributeValues: DynamoItem;
99
+ /** Counter for generating unique value placeholders */
100
+ valueCounter: {
101
+ count: number;
102
+ };
103
+ }
104
+ /**
105
+ * Creates a comparison condition builder function for the specified operator.
106
+ * @internal
107
+ */
108
+ declare const createComparisonCondition: (type: ComparisonOperator) => (attr: string, value: unknown) => Condition;
109
+ /**
110
+ * Creates an equals (=) condition
111
+ * @example
112
+ * eq("status", "ACTIVE") // status = "ACTIVE"
113
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}
114
+ */
115
+ declare const eq: (attr: string, value: unknown) => Condition;
116
+ /**
117
+ * Creates a not equals (≠) condition
118
+ * @example
119
+ * ne("status", "DELETED") // status <> "DELETED"
120
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}
121
+ */
122
+ declare const ne: (attr: string, value: unknown) => Condition;
123
+ /**
124
+ * Creates a less than (<) condition
125
+ * @example
126
+ * lt("age", 18) // age < 18
127
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}
128
+ */
129
+ declare const lt: (attr: string, value: unknown) => Condition;
130
+ /**
131
+ * Creates a less than or equal to (≤) condition
132
+ * @example
133
+ * lte("age", 18) // age <= 18
134
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}
135
+ */
136
+ declare const lte: (attr: string, value: unknown) => Condition;
137
+ /**
138
+ * Creates a greater than (>) condition
139
+ * @example
140
+ * gt("price", 100) // price > 100
141
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}
142
+ */
143
+ declare const gt: (attr: string, value: unknown) => Condition;
144
+ /**
145
+ * Creates a greater than or equal to (≥) condition
146
+ * @example
147
+ * gte("price", 100) // price >= 100
148
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}
149
+ */
150
+ declare const gte: (attr: string, value: unknown) => Condition;
151
+ /**
152
+ * Creates a between condition that checks if a value is within a range (inclusive)
153
+ * @example
154
+ * between("age", 18, 65) // age BETWEEN 18 AND 65
155
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - BETWEEN}
156
+ */
157
+ declare const between: (attr: string, lower: unknown, upper: unknown) => Condition;
158
+ /**
159
+ * Creates an in condition that checks if a value is in a list of values
160
+ * @example
161
+ * inArray("status", ["ACTIVE", "PENDING", "PROCESSING"]) // status IN ("ACTIVE", "PENDING", "PROCESSING")
162
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - IN}
163
+ */
164
+ declare const inArray: (attr: string, values: unknown[]) => Condition;
165
+ /**
166
+ * Creates a begins_with condition that checks if a string attribute starts with a substring
167
+ * @example
168
+ * beginsWith("email", "@example.com") // begins_with(email, "@example.com")
169
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - begins_with}
170
+ */
171
+ declare const beginsWith: (attr: string, value: unknown) => Condition;
172
+ /**
173
+ * Creates a contains condition that checks if a string contains a substring or if a set contains an element
174
+ * @example
175
+ * contains("tags", "important") // contains(tags, "important")
176
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - contains}
177
+ */
178
+ declare const contains: (attr: string, value: unknown) => Condition;
179
+ /**
180
+ * Creates a condition that checks if an attribute exists
181
+ * @example
182
+ * attributeExists("email") // attribute_exists(email)
183
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_exists}
184
+ */
185
+ declare const attributeExists: (attr: string) => Condition;
186
+ /**
187
+ * Creates a condition that checks if an attribute does not exist
188
+ * @example
189
+ * attributeNotExists("deletedAt") // attribute_not_exists(deletedAt)
190
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_not_exists}
191
+ */
192
+ declare const attributeNotExists: (attr: string) => Condition;
193
+ /**
194
+ * Combines multiple conditions with AND operator
195
+ * @example
196
+ * and(
197
+ * eq("status", "ACTIVE"),
198
+ * gt("age", 18)
199
+ * ) // status = "ACTIVE" AND age > 18
200
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - AND}
201
+ */
202
+ declare const and: (...conditions: Condition[]) => Condition;
203
+ /**
204
+ * Combines multiple conditions with OR operator
205
+ * @example
206
+ * or(
207
+ * eq("status", "PENDING"),
208
+ * eq("status", "PROCESSING")
209
+ * ) // status = "PENDING" OR status = "PROCESSING"
210
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - OR}
211
+ */
212
+ declare const or: (...conditions: Condition[]) => Condition;
213
+ /**
214
+ * Negates a condition
215
+ * @example
216
+ * not(eq("status", "DELETED")) // NOT status = "DELETED"
217
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - NOT}
218
+ */
219
+ declare const not: (condition: Condition) => Condition;
220
+ /**
221
+ * Type-safe operators for building key conditions in DynamoDB queries.
222
+ * Only includes operators that are valid for key conditions.
223
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions AWS DynamoDB - Key Condition Expressions}
224
+ *
225
+ * @example
226
+ * // Using with sort key conditions
227
+ * table.query({
228
+ * pk: "USER#123",
229
+ * sk: op => op.beginsWith("ORDER#")
230
+ * })
231
+ */
232
+ type KeyConditionOperator = {
233
+ /** Equals comparison for key attributes */
234
+ eq: (value: unknown) => Condition;
235
+ /** Less than comparison for key attributes */
236
+ lt: (value: unknown) => Condition;
237
+ /** Less than or equal comparison for key attributes */
238
+ lte: (value: unknown) => Condition;
239
+ /** Greater than comparison for key attributes */
240
+ gt: (value: unknown) => Condition;
241
+ /** Greater than or equal comparison for key attributes */
242
+ gte: (value: unknown) => Condition;
243
+ /** Between range comparison for key attributes */
244
+ between: (lower: unknown, upper: unknown) => Condition;
245
+ /** Begins with comparison for key attributes */
246
+ beginsWith: (value: unknown) => Condition;
247
+ /** Combines multiple key conditions with AND */
248
+ and: (...conditions: Condition[]) => Condition;
249
+ };
250
+ /**
251
+ * Type-safe operators for building conditions in DynamoDB operations.
252
+ * Includes all available condition operators with proper type inference.
253
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html AWS DynamoDB - Condition Expressions}
254
+ *
255
+ * @example
256
+ * // Using with type-safe conditions
257
+ * interface User {
258
+ * status: string;
259
+ * age: number;
260
+ * email?: string;
261
+ * }
262
+ *
263
+ * table.scan<User>()
264
+ * .where(op => op.and(
265
+ * op.eq("status", "ACTIVE"),
266
+ * op.gt("age", 18),
267
+ * op.attributeExists("email")
268
+ * ))
269
+ *
270
+ * @template T The type of the item being operated on
271
+ */
272
+ type ConditionOperator<T extends DynamoItem> = {
273
+ /**
274
+ * Creates an equals (=) condition for type-safe attribute comparison.
275
+ * Tests if the specified attribute equals the provided value.
276
+ *
277
+ * @param attr - The attribute path to compare (with full type safety)
278
+ * @param value - The value to compare against (must match attribute type)
279
+ * @returns A condition that evaluates to true when attr equals value
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * interface User { status: string; age: number; }
284
+ *
285
+ * // String comparison
286
+ * op.eq("status", "ACTIVE") // status = "ACTIVE"
287
+ *
288
+ * // Numeric comparison
289
+ * op.eq("age", 25) // age = 25
290
+ *
291
+ * // Nested attribute
292
+ * op.eq("profile.role", "admin") // profile.role = "admin"
293
+ * ```
294
+ *
295
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}
296
+ */
297
+ eq: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;
298
+ /**
299
+ * Creates a not equals (≠ / <>) condition for type-safe attribute comparison.
300
+ * Tests if the specified attribute does not equal the provided value.
301
+ *
302
+ * @param attr - The attribute path to compare (with full type safety)
303
+ * @param value - The value to compare against (must match attribute type)
304
+ * @returns A condition that evaluates to true when attr does not equal value
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * interface User { status: string; priority: number; }
309
+ *
310
+ * // String comparison
311
+ * op.ne("status", "DELETED") // status <> "DELETED"
312
+ *
313
+ * // Numeric comparison
314
+ * op.ne("priority", 0) // priority <> 0
315
+ *
316
+ * // Useful for filtering out specific values
317
+ * op.ne("category", "ARCHIVED") // category <> "ARCHIVED"
318
+ * ```
319
+ *
320
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}
321
+ */
322
+ ne: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;
323
+ /**
324
+ * Creates a less than (<) condition for type-safe attribute comparison.
325
+ * Tests if the specified attribute is less than the provided value.
326
+ * Works with numbers, strings (lexicographic), and dates.
327
+ *
328
+ * @param attr - The attribute path to compare (with full type safety)
329
+ * @param value - The value to compare against (must match attribute type)
330
+ * @returns A condition that evaluates to true when attr is less than value
331
+ *
332
+ * @example
333
+ * ```typescript
334
+ * interface Product { price: number; name: string; createdAt: string; }
335
+ *
336
+ * // Numeric comparison
337
+ * op.lt("price", 100) // price < 100
338
+ *
339
+ * // String comparison (lexicographic)
340
+ * op.lt("name", "M") // name < "M" (names starting with A-L)
341
+ *
342
+ * // Date comparison (ISO strings)
343
+ * op.lt("createdAt", "2024-01-01") // createdAt < "2024-01-01"
344
+ * ```
345
+ *
346
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}
347
+ */
348
+ lt: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;
349
+ /**
350
+ * Creates a less than or equal to (≤) condition for type-safe attribute comparison.
351
+ * Tests if the specified attribute is less than or equal to the provided value.
352
+ * Works with numbers, strings (lexicographic), and dates.
353
+ *
354
+ * @param attr - The attribute path to compare (with full type safety)
355
+ * @param value - The value to compare against (must match attribute type)
356
+ * @returns A condition that evaluates to true when attr is less than or equal to value
357
+ *
358
+ * @example
359
+ * ```typescript
360
+ * interface Order { total: number; priority: number; dueDate: string; }
361
+ *
362
+ * // Numeric comparison
363
+ * op.lte("total", 1000) // total <= 1000
364
+ *
365
+ * // Priority levels
366
+ * op.lte("priority", 3) // priority <= 3 (low to medium priority)
367
+ *
368
+ * // Date deadlines
369
+ * op.lte("dueDate", "2024-12-31") // dueDate <= "2024-12-31"
370
+ * ```
371
+ *
372
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}
373
+ */
374
+ lte: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;
375
+ /**
376
+ * Creates a greater than (>) condition for type-safe attribute comparison.
377
+ * Tests if the specified attribute is greater than the provided value.
378
+ * Works with numbers, strings (lexicographic), and dates.
379
+ *
380
+ * @param attr - The attribute path to compare (with full type safety)
381
+ * @param value - The value to compare against (must match attribute type)
382
+ * @returns A condition that evaluates to true when attr is greater than value
383
+ *
384
+ * @example
385
+ * ```typescript
386
+ * interface User { age: number; score: number; lastLogin: string; }
387
+ *
388
+ * // Age restrictions
389
+ * op.gt("age", 18) // age > 18 (adults only)
390
+ *
391
+ * // Performance thresholds
392
+ * op.gt("score", 85) // score > 85 (high performers)
393
+ *
394
+ * // Recent activity
395
+ * op.gt("lastLogin", "2024-01-01") // lastLogin > "2024-01-01"
396
+ * ```
397
+ *
398
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}
399
+ */
400
+ gt: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;
401
+ /**
402
+ * Creates a greater than or equal to (≥) condition for type-safe attribute comparison.
403
+ * Tests if the specified attribute is greater than or equal to the provided value.
404
+ * Works with numbers, strings (lexicographic), and dates.
405
+ *
406
+ * @param attr - The attribute path to compare (with full type safety)
407
+ * @param value - The value to compare against (must match attribute type)
408
+ * @returns A condition that evaluates to true when attr is greater than or equal to value
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * interface Product { rating: number; version: string; releaseDate: string; }
413
+ *
414
+ * // Minimum ratings
415
+ * op.gte("rating", 4.0) // rating >= 4.0 (highly rated)
416
+ *
417
+ * // Version requirements
418
+ * op.gte("version", "2.0.0") // version >= "2.0.0"
419
+ *
420
+ * // Release date filters
421
+ * op.gte("releaseDate", "2024-01-01") // releaseDate >= "2024-01-01"
422
+ * ```
423
+ *
424
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}
425
+ */
426
+ gte: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;
427
+ /**
428
+ * Creates a between condition for type-safe range comparison.
429
+ * Tests if the specified attribute value falls within the inclusive range [lower, upper].
430
+ * Works with numbers, strings (lexicographic), and dates.
431
+ *
432
+ * @param attr - The attribute path to compare (with full type safety)
433
+ * @param lower - The lower bound of the range (inclusive, must match attribute type)
434
+ * @param upper - The upper bound of the range (inclusive, must match attribute type)
435
+ * @returns A condition that evaluates to true when lower ≤ attr ≤ upper
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * interface Event { price: number; date: string; priority: number; }
440
+ *
441
+ * // Price range
442
+ * op.between("price", 50, 200) // price BETWEEN 50 AND 200
443
+ *
444
+ * // Date range
445
+ * op.between("date", "2024-01-01", "2024-12-31") // date BETWEEN "2024-01-01" AND "2024-12-31"
446
+ *
447
+ * // Priority levels
448
+ * op.between("priority", 1, 5) // priority BETWEEN 1 AND 5
449
+ * ```
450
+ *
451
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - BETWEEN}
452
+ */
453
+ between: <K extends Path<T>>(attr: K, lower: PathType<T, K>, upper: PathType<T, K>) => Condition;
454
+ /**
455
+ * Creates an IN condition for type-safe list membership testing.
456
+ * Tests if the specified attribute value matches any value in the provided list.
457
+ * Supports up to 100 values in the list as per DynamoDB limitations.
458
+ *
459
+ * @param attr - The attribute path to compare (with full type safety)
460
+ * @param values - Array of values to test against (must match attribute type, max 100 items)
461
+ * @returns A condition that evaluates to true when attr matches any value in the list
462
+ *
463
+ * @example
464
+ * ```typescript
465
+ * interface User { status: string; role: string; priority: number; }
466
+ *
467
+ * // Status filtering
468
+ * op.inArray("status", ["ACTIVE", "PENDING", "PROCESSING"]) // status IN ("ACTIVE", "PENDING", "PROCESSING")
469
+ *
470
+ * // Role-based access
471
+ * op.inArray("role", ["admin", "moderator", "editor"]) // role IN ("admin", "moderator", "editor")
472
+ *
473
+ * // Priority levels
474
+ * op.inArray("priority", [1, 2, 3]) // priority IN (1, 2, 3)
475
+ * ```
476
+ *
477
+ * @throws {Error} When values array is empty or contains more than 100 items
478
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - IN}
479
+ */
480
+ inArray: <K extends Path<T>>(attr: K, values: PathType<T, K>[]) => Condition;
481
+ /**
482
+ * Creates a begins_with condition for type-safe string prefix testing.
483
+ * Tests if the specified string attribute starts with the provided substring.
484
+ * Only works with string attributes - will fail on other data types.
485
+ *
486
+ * @param attr - The string attribute path to test (with full type safety)
487
+ * @param value - The prefix string to test for (must match attribute type)
488
+ * @returns A condition that evaluates to true when attr starts with value
489
+ *
490
+ * @example
491
+ * ```typescript
492
+ * interface User { email: string; name: string; id: string; }
493
+ *
494
+ * // Email domain filtering
495
+ * op.beginsWith("email", "admin@") // begins_with(email, "admin@")
496
+ *
497
+ * // Name prefix search
498
+ * op.beginsWith("name", "John") // begins_with(name, "John")
499
+ *
500
+ * // ID pattern matching
501
+ * op.beginsWith("id", "USER#") // begins_with(id, "USER#")
502
+ * ```
503
+ *
504
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - begins_with}
505
+ */
506
+ beginsWith: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;
507
+ /**
508
+ * Creates a contains condition for type-safe substring or set membership testing.
509
+ * For strings: tests if the attribute contains the specified substring.
510
+ * For sets: tests if the set contains the specified element.
511
+ *
512
+ * @param attr - The attribute path to test (with full type safety)
513
+ * @param value - The substring or element to search for (must match attribute type)
514
+ * @returns A condition that evaluates to true when attr contains value
515
+ *
516
+ * @example
517
+ * ```typescript
518
+ * interface Post { content: string; tags: Set<string>; categories: string[]; }
519
+ *
520
+ * // Substring search in content
521
+ * op.contains("content", "important") // contains(content, "important")
522
+ *
523
+ * // Tag membership (for DynamoDB String Sets)
524
+ * op.contains("tags", "featured") // contains(tags, "featured")
525
+ *
526
+ * // Category search (for string arrays stored as lists)
527
+ * op.contains("categories", "technology") // contains(categories, "technology")
528
+ * ```
529
+ *
530
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - contains}
531
+ */
532
+ contains: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;
533
+ /**
534
+ * Creates an attribute_exists condition for type-safe attribute presence testing.
535
+ * Tests if the specified attribute exists in the item, regardless of its value.
536
+ * Useful for filtering items that have optional attributes populated.
537
+ *
538
+ * @param attr - The attribute path to test for existence (with full type safety)
539
+ * @returns A condition that evaluates to true when the attribute exists
540
+ *
541
+ * @example
542
+ * ```typescript
543
+ * interface User { email: string; phone?: string; profile?: { avatar?: string; }; }
544
+ *
545
+ * // Check for optional fields
546
+ * op.attributeExists("phone") // attribute_exists(phone)
547
+ *
548
+ * // Check for nested optional attributes
549
+ * op.attributeExists("profile.avatar") // attribute_exists(profile.avatar)
550
+ *
551
+ * // Useful in combination with other conditions
552
+ * op.and(
553
+ * op.eq("status", "ACTIVE"),
554
+ * op.attributeExists("email") // Only active users with email
555
+ * )
556
+ * ```
557
+ *
558
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_exists}
559
+ */
560
+ attributeExists: <K extends Path<T>>(attr: K) => Condition;
561
+ /**
562
+ * Creates an attribute_not_exists condition for type-safe attribute absence testing.
563
+ * Tests if the specified attribute does not exist in the item.
564
+ * Useful for conditional writes to prevent overwriting existing data.
565
+ *
566
+ * @param attr - The attribute path to test for absence (with full type safety)
567
+ * @returns A condition that evaluates to true when the attribute does not exist
568
+ *
569
+ * @example
570
+ * ```typescript
571
+ * interface User { id: string; email: string; deletedAt?: string; }
572
+ *
573
+ * // Ensure item hasn't been soft-deleted
574
+ * op.attributeNotExists("deletedAt") // attribute_not_exists(deletedAt)
575
+ *
576
+ * // Prevent duplicate creation
577
+ * op.attributeNotExists("id") // attribute_not_exists(id)
578
+ *
579
+ * // Conditional updates
580
+ * op.and(
581
+ * op.eq("status", "PENDING"),
582
+ * op.attributeNotExists("processedAt") // Only unprocessed items
583
+ * )
584
+ * ```
585
+ *
586
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_not_exists}
587
+ */
588
+ attributeNotExists: <K extends Path<T>>(attr: K) => Condition;
589
+ /**
590
+ * Combines multiple conditions with logical AND operator.
591
+ * All provided conditions must evaluate to true for the AND condition to be true.
592
+ * Supports any number of conditions as arguments.
593
+ *
594
+ * @param conditions - Variable number of conditions to combine with AND
595
+ * @returns A condition that evaluates to true when all input conditions are true
596
+ *
597
+ * @example
598
+ * ```typescript
599
+ * interface User { status: string; age: number; role: string; verified: boolean; }
600
+ *
601
+ * // Multiple criteria
602
+ * op.and(
603
+ * op.eq("status", "ACTIVE"),
604
+ * op.gt("age", 18),
605
+ * op.eq("verified", true)
606
+ * ) // status = "ACTIVE" AND age > 18 AND verified = true
607
+ *
608
+ * // Complex business logic
609
+ * op.and(
610
+ * op.inArray("role", ["admin", "moderator"]),
611
+ * op.attributeExists("permissions"),
612
+ * op.ne("status", "SUSPENDED")
613
+ * )
614
+ * ```
615
+ *
616
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - AND}
617
+ */
618
+ and: (...conditions: Condition[]) => Condition;
619
+ /**
620
+ * Combines multiple conditions with logical OR operator.
621
+ * At least one of the provided conditions must evaluate to true for the OR condition to be true.
622
+ * Supports any number of conditions as arguments.
623
+ *
624
+ * @param conditions - Variable number of conditions to combine with OR
625
+ * @returns A condition that evaluates to true when any input condition is true
626
+ *
627
+ * @example
628
+ * ```typescript
629
+ * interface Order { status: string; priority: string; urgent: boolean; }
630
+ *
631
+ * // Alternative statuses
632
+ * op.or(
633
+ * op.eq("status", "PENDING"),
634
+ * op.eq("status", "PROCESSING"),
635
+ * op.eq("status", "SHIPPED")
636
+ * ) // status = "PENDING" OR status = "PROCESSING" OR status = "SHIPPED"
637
+ *
638
+ * // High priority items
639
+ * op.or(
640
+ * op.eq("priority", "HIGH"),
641
+ * op.eq("urgent", true)
642
+ * )
643
+ * ```
644
+ *
645
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - OR}
646
+ */
647
+ or: (...conditions: Condition[]) => Condition;
648
+ /**
649
+ * Negates a condition with logical NOT operator.
650
+ * Inverts the boolean result of the provided condition.
651
+ *
652
+ * @param condition - The condition to negate
653
+ * @returns A condition that evaluates to true when the input condition is false
654
+ *
655
+ * @example
656
+ * ```typescript
657
+ * interface User { status: string; role: string; banned: boolean; }
658
+ *
659
+ * // Exclude specific status
660
+ * op.not(op.eq("status", "DELETED")) // NOT status = "DELETED"
661
+ *
662
+ * // Complex negation
663
+ * op.not(
664
+ * op.and(
665
+ * op.eq("role", "guest"),
666
+ * op.eq("banned", true)
667
+ * )
668
+ * ) // NOT (role = "guest" AND banned = true)
669
+ *
670
+ * // Exclude multiple values
671
+ * op.not(op.inArray("status", ["DELETED", "ARCHIVED"]))
672
+ * ```
673
+ *
674
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - NOT}
675
+ */
676
+ not: (condition: Condition) => Condition;
677
+ };
678
+ /**
679
+ * Primary key type for QUERY operations.
680
+ * Allows building complex key conditions for the sort key.
681
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html AWS DynamoDB - Query Operations}
682
+ *
683
+ * @example
684
+ * // Query items with a specific partition key and sort key prefix
685
+ * table.query({
686
+ * pk: "USER#123",
687
+ * sk: op => op.beginsWith("ORDER#2023")
688
+ * })
689
+ *
690
+ * @example
691
+ * // Query items within a specific sort key range
692
+ * table.query({
693
+ * pk: "USER#123",
694
+ * sk: op => op.between("ORDER#2023-01", "ORDER#2023-12")
695
+ * })
696
+ */
697
+ type PrimaryKey = {
698
+ /** Partition key value */
699
+ pk: string;
700
+ /** Optional sort key condition builder */
701
+ sk?: (op: KeyConditionOperator) => Condition;
702
+ };
703
+ /**
704
+ * Primary key type for GET and DELETE operations.
705
+ * Used when you need to specify exact key values without conditions.
706
+ * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html AWS DynamoDB - Working with Items}
707
+ *
708
+ * @example
709
+ * // Get a specific item by its complete primary key
710
+ * table.get({
711
+ * pk: "USER#123",
712
+ * sk: "PROFILE#123"
713
+ * })
714
+ *
715
+ * @example
716
+ * // Delete a specific item by its complete primary key
717
+ * table.delete({
718
+ * pk: "USER#123",
719
+ * sk: "ORDER#456"
720
+ * })
721
+ */
722
+ type PrimaryKeyWithoutExpression = {
723
+ /** Partition key value */
724
+ pk: string;
725
+ /** Optional sort key value */
726
+ sk?: string;
727
+ };
728
+
729
+ export { type Condition as C, type ExpressionParams as E, type KeyConditionOperator as K, type LogicalOperator as L, type PrimaryKeyWithoutExpression as P, type PrimaryKey as a, type ConditionOperator as b, type Path as c, type PathType as d, type ComparisonOperator as e, createComparisonCondition as f, eq as g, lte as h, gt as i, gte as j, between as k, lt as l, inArray as m, ne as n, beginsWith as o, contains as p, attributeExists as q, attributeNotExists as r, and as s, or as t, not as u };