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