dyno-table 0.1.8 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +35 -7
  2. package/package.json +13 -3
  3. package/dist/builders/condition-check-builder.cjs +0 -394
  4. package/dist/builders/condition-check-builder.cjs.map +0 -1
  5. package/dist/builders/condition-check-builder.js +0 -392
  6. package/dist/builders/condition-check-builder.js.map +0 -1
  7. package/dist/builders/delete-builder.cjs +0 -422
  8. package/dist/builders/delete-builder.cjs.map +0 -1
  9. package/dist/builders/delete-builder.js +0 -420
  10. package/dist/builders/delete-builder.js.map +0 -1
  11. package/dist/builders/paginator.cjs +0 -199
  12. package/dist/builders/paginator.cjs.map +0 -1
  13. package/dist/builders/paginator.js +0 -197
  14. package/dist/builders/paginator.js.map +0 -1
  15. package/dist/builders/put-builder.cjs +0 -468
  16. package/dist/builders/put-builder.cjs.map +0 -1
  17. package/dist/builders/put-builder.js +0 -466
  18. package/dist/builders/put-builder.js.map +0 -1
  19. package/dist/builders/query-builder.cjs +0 -674
  20. package/dist/builders/query-builder.cjs.map +0 -1
  21. package/dist/builders/query-builder.js +0 -672
  22. package/dist/builders/query-builder.js.map +0 -1
  23. package/dist/builders/transaction-builder.cjs +0 -876
  24. package/dist/builders/transaction-builder.cjs.map +0 -1
  25. package/dist/builders/transaction-builder.js +0 -874
  26. package/dist/builders/transaction-builder.js.map +0 -1
  27. package/dist/builders/update-builder.cjs +0 -662
  28. package/dist/builders/update-builder.cjs.map +0 -1
  29. package/dist/builders/update-builder.js +0 -660
  30. package/dist/builders/update-builder.js.map +0 -1
  31. package/dist/conditions.cjs +0 -59
  32. package/dist/conditions.cjs.map +0 -1
  33. package/dist/conditions.js +0 -43
  34. package/dist/conditions.js.map +0 -1
  35. package/dist/entity.cjs +0 -169
  36. package/dist/entity.cjs.map +0 -1
  37. package/dist/entity.js +0 -165
  38. package/dist/entity.js.map +0 -1
  39. package/dist/standard-schema.cjs +0 -4
  40. package/dist/standard-schema.cjs.map +0 -1
  41. package/dist/standard-schema.js +0 -3
  42. package/dist/standard-schema.js.map +0 -1
  43. package/dist/table.cjs +0 -3265
  44. package/dist/table.cjs.map +0 -1
  45. package/dist/table.js +0 -3263
  46. package/dist/table.js.map +0 -1
  47. package/dist/types.cjs +0 -4
  48. package/dist/types.cjs.map +0 -1
  49. package/dist/types.js +0 -3
  50. package/dist/types.js.map +0 -1
  51. package/dist/utils/key-template.cjs +0 -19
  52. package/dist/utils/key-template.cjs.map +0 -1
  53. package/dist/utils/key-template.js +0 -17
  54. package/dist/utils/key-template.js.map +0 -1
  55. package/dist/utils/sort-key-template.cjs +0 -19
  56. package/dist/utils/sort-key-template.cjs.map +0 -1
  57. package/dist/utils/sort-key-template.js +0 -17
  58. package/dist/utils/sort-key-template.js.map +0 -1
@@ -1,420 +0,0 @@
1
- // src/conditions.ts
2
- var createComparisonCondition = (type) => (attr, value) => ({
3
- type,
4
- attr,
5
- value
6
- });
7
- var eq = createComparisonCondition("eq");
8
- var ne = createComparisonCondition("ne");
9
- var lt = createComparisonCondition("lt");
10
- var lte = createComparisonCondition("lte");
11
- var gt = createComparisonCondition("gt");
12
- var gte = createComparisonCondition("gte");
13
- var between = (attr, lower, upper) => ({
14
- type: "between",
15
- attr,
16
- value: [lower, upper]
17
- });
18
- var beginsWith = createComparisonCondition("beginsWith");
19
- var contains = createComparisonCondition("contains");
20
- var attributeExists = (attr) => ({
21
- type: "attributeExists",
22
- attr
23
- });
24
- var attributeNotExists = (attr) => ({
25
- type: "attributeNotExists",
26
- attr
27
- });
28
- var and = (...conditions) => ({
29
- type: "and",
30
- conditions
31
- });
32
- var or = (...conditions) => ({
33
- type: "or",
34
- conditions
35
- });
36
- var not = (condition) => ({
37
- type: "not",
38
- condition
39
- });
40
-
41
- // src/expression.ts
42
- var generateAttributeName = (params, attr) => {
43
- for (const [existingName, existingAttr] of Object.entries(params.expressionAttributeNames)) {
44
- if (existingAttr === attr) {
45
- return existingName;
46
- }
47
- }
48
- const attrName = `#${Object.keys(params.expressionAttributeNames).length}`;
49
- params.expressionAttributeNames[attrName] = attr;
50
- return attrName;
51
- };
52
- var generateValueName = (params, value) => {
53
- const valueName = `:${params.valueCounter.count++}`;
54
- params.expressionAttributeValues[valueName] = value;
55
- return valueName;
56
- };
57
- var validateCondition = (condition, requiresAttr = true, requiresValue = true) => {
58
- if (requiresAttr && !condition.attr) {
59
- throw new Error(`Attribute is required for ${condition.type} condition`);
60
- }
61
- if (requiresValue && condition.value === void 0) {
62
- throw new Error(`Value is required for ${condition.type} condition`);
63
- }
64
- };
65
- var buildComparisonExpression = (condition, operator, params) => {
66
- validateCondition(condition);
67
- if (!condition.attr) {
68
- throw new Error(`Attribute is required for ${condition.type} condition`);
69
- }
70
- const attrName = generateAttributeName(params, condition.attr);
71
- const valueName = generateValueName(params, condition.value);
72
- return `${attrName} ${operator} ${valueName}`;
73
- };
74
- var buildBetweenExpression = (condition, params) => {
75
- validateCondition(condition);
76
- if (!condition.attr) {
77
- throw new Error(`Attribute is required for ${condition.type} condition`);
78
- }
79
- if (!Array.isArray(condition.value) || condition.value.length !== 2) {
80
- throw new Error("Between condition requires an array of two values");
81
- }
82
- const attrName = generateAttributeName(params, condition.attr);
83
- const lowerName = generateValueName(params, condition.value[0]);
84
- const upperName = generateValueName(params, condition.value[1]);
85
- return `${attrName} BETWEEN ${lowerName} AND ${upperName}`;
86
- };
87
- var buildFunctionExpression = (functionName, condition, params) => {
88
- validateCondition(condition);
89
- if (!condition.attr) {
90
- throw new Error(`Attribute is required for ${condition.type} condition`);
91
- }
92
- const attrName = generateAttributeName(params, condition.attr);
93
- const valueName = generateValueName(params, condition.value);
94
- return `${functionName}(${attrName}, ${valueName})`;
95
- };
96
- var buildAttributeFunction = (functionName, condition, params) => {
97
- validateCondition(condition, true, false);
98
- if (!condition.attr) {
99
- throw new Error(`Attribute is required for ${condition.type} condition`);
100
- }
101
- const attrName = generateAttributeName(params, condition.attr);
102
- return `${functionName}(${attrName})`;
103
- };
104
- var buildLogicalExpression = (operator, conditions, params) => {
105
- if (!conditions || conditions.length === 0) {
106
- throw new Error(`At least one condition is required for ${operator} expression`);
107
- }
108
- const expressions = conditions.map((c) => buildExpression(c, params));
109
- return `(${expressions.join(` ${operator} `)})`;
110
- };
111
- var buildExpression = (condition, params) => {
112
- if (!condition) return "";
113
- try {
114
- const expressionBuilders = {
115
- eq: () => buildComparisonExpression(condition, "=", params),
116
- ne: () => buildComparisonExpression(condition, "<>", params),
117
- lt: () => buildComparisonExpression(condition, "<", params),
118
- lte: () => buildComparisonExpression(condition, "<=", params),
119
- gt: () => buildComparisonExpression(condition, ">", params),
120
- gte: () => buildComparisonExpression(condition, ">=", params),
121
- between: () => buildBetweenExpression(condition, params),
122
- beginsWith: () => buildFunctionExpression("begins_with", condition, params),
123
- contains: () => buildFunctionExpression("contains", condition, params),
124
- attributeExists: () => buildAttributeFunction("attribute_exists", condition, params),
125
- attributeNotExists: () => buildAttributeFunction("attribute_not_exists", condition, params),
126
- and: () => {
127
- if (!condition.conditions) {
128
- throw new Error("Conditions array is required for AND operator");
129
- }
130
- return buildLogicalExpression("AND", condition.conditions, params);
131
- },
132
- or: () => {
133
- if (!condition.conditions) {
134
- throw new Error("Conditions array is required for OR operator");
135
- }
136
- return buildLogicalExpression("OR", condition.conditions, params);
137
- },
138
- not: () => {
139
- if (!condition.condition) {
140
- throw new Error("Condition is required for NOT operator");
141
- }
142
- return `NOT (${buildExpression(condition.condition, params)})`;
143
- }
144
- };
145
- const builder = expressionBuilders[condition.type];
146
- if (!builder) {
147
- throw new Error(`Unknown condition type: ${condition.type}`);
148
- }
149
- return builder();
150
- } catch (error) {
151
- if (error instanceof Error) {
152
- console.error(`Error building expression for condition type ${condition.type}:`, error.message);
153
- } else {
154
- console.error(`Error building expression for condition type ${condition.type}:`, error);
155
- }
156
- throw error;
157
- }
158
- };
159
- var prepareExpressionParams = (condition) => {
160
- if (!condition) return {};
161
- const params = {
162
- expressionAttributeNames: {},
163
- expressionAttributeValues: {},
164
- valueCounter: { count: 0 }
165
- };
166
- const expression = buildExpression(condition, params);
167
- return {
168
- expression,
169
- names: Object.keys(params.expressionAttributeNames).length > 0 ? params.expressionAttributeNames : void 0,
170
- values: Object.keys(params.expressionAttributeValues).length > 0 ? params.expressionAttributeValues : void 0
171
- };
172
- };
173
-
174
- // src/utils/debug-expression.ts
175
- function debugCommand(command) {
176
- const result = {};
177
- function replaceAliases(expressionString) {
178
- if (!expressionString) {
179
- return expressionString;
180
- }
181
- let replacedString = expressionString;
182
- for (const alias in command.expressionAttributeNames) {
183
- const attributeName = command.expressionAttributeNames[alias];
184
- const regex = new RegExp(alias, "g");
185
- replacedString = replacedString.replace(regex, attributeName);
186
- }
187
- for (const alias in command.expressionAttributeValues) {
188
- let attributeValue = command.expressionAttributeValues[alias];
189
- if (attributeValue instanceof Set) {
190
- const array = Array.from(attributeValue);
191
- attributeValue = `Set(${array.length}){${array.map((v) => JSON.stringify(v)).join(", ")}}`;
192
- } else {
193
- attributeValue = JSON.stringify(attributeValue);
194
- }
195
- const regex = new RegExp(alias, "g");
196
- replacedString = replacedString.replace(regex, attributeValue);
197
- }
198
- return replacedString;
199
- }
200
- if (command.updateExpression) {
201
- result.updateExpression = replaceAliases(command.updateExpression);
202
- }
203
- if (command.conditionExpression) {
204
- result.conditionExpression = replaceAliases(command.conditionExpression);
205
- }
206
- if (command.filterExpression) {
207
- result.filterExpression = replaceAliases(command.filterExpression);
208
- }
209
- if (command.keyConditionExpression) {
210
- result.keyConditionExpression = replaceAliases(command.keyConditionExpression);
211
- }
212
- if (command.projectionExpression) {
213
- result.projectionExpression = replaceAliases(command.projectionExpression);
214
- }
215
- return {
216
- raw: command,
217
- readable: result
218
- };
219
- }
220
-
221
- // src/builders/delete-builder.ts
222
- var DeleteBuilder = class {
223
- options = {
224
- returnValues: "ALL_OLD"
225
- };
226
- executor;
227
- tableName;
228
- key;
229
- constructor(executor, tableName, key) {
230
- this.executor = executor;
231
- this.tableName = tableName;
232
- this.key = key;
233
- }
234
- /**
235
- * Adds a condition that must be satisfied for the delete operation to succeed.
236
- * Use this method when you need to:
237
- * - Ensure safe removal conditions
238
- * - Verify habitat status before deletion
239
- * - Implement safety protocols
240
- *
241
- * @example
242
- * ```typescript
243
- * // Ensure dinosaur can be safely removed
244
- * builder.condition(op =>
245
- * op.and([
246
- * op.eq('status', 'SEDATED'),
247
- * op.eq('location', 'MEDICAL_BAY'),
248
- * op.attributeExists('lastCheckup')
249
- * ])
250
- * );
251
- *
252
- * // Verify habitat is empty
253
- * builder.condition(op =>
254
- * op.and([
255
- * op.eq('occupants', 0),
256
- * op.eq('maintenanceStatus', 'COMPLETE'),
257
- * op.not(op.attributeExists('activeAlerts'))
258
- * ])
259
- * );
260
- * ```
261
- *
262
- * @param condition - Either a Condition object or a callback function that builds the condition
263
- * @returns The builder instance for method chaining
264
- */
265
- condition(condition) {
266
- if (typeof condition === "function") {
267
- const conditionOperator = {
268
- eq,
269
- ne,
270
- lt,
271
- lte,
272
- gt,
273
- gte,
274
- between,
275
- beginsWith,
276
- contains,
277
- attributeExists,
278
- attributeNotExists,
279
- and,
280
- or,
281
- not
282
- };
283
- this.options.condition = condition(conditionOperator);
284
- } else {
285
- this.options.condition = condition;
286
- }
287
- return this;
288
- }
289
- /**
290
- * Sets whether to return the item's attribute values before deletion.
291
- * Use this method when you need to:
292
- * - Archive removed dinosaur data
293
- * - Track habitat decommissioning history
294
- * - Maintain removal audit logs
295
- *
296
- * @example
297
- * ```ts
298
- * // Archive dinosaur data before removal
299
- * const result = await builder
300
- * .returnValues('ALL_OLD')
301
- * .execute();
302
- *
303
- * if (result.item) {
304
- * console.log('Removed dinosaur data:', {
305
- * species: result.item.species,
306
- * age: result.item.age,
307
- * lastLocation: result.item.location
308
- * });
309
- * }
310
- * ```
311
- *
312
- * @param returnValues - Use 'ALL_OLD' to return all attributes of the deleted item
313
- * @returns The builder instance for method chaining
314
- */
315
- returnValues(returnValues) {
316
- this.options.returnValues = returnValues;
317
- return this;
318
- }
319
- /**
320
- * Generate the DynamoDB command parameters
321
- */
322
- toDynamoCommand() {
323
- const { expression, names, values } = prepareExpressionParams(this.options.condition);
324
- return {
325
- tableName: this.tableName,
326
- key: this.key,
327
- conditionExpression: expression,
328
- expressionAttributeNames: names,
329
- expressionAttributeValues: values,
330
- returnValues: this.options.returnValues
331
- };
332
- }
333
- /**
334
- * Adds this delete operation to a transaction.
335
- * Use this method when you need to:
336
- * - Coordinate dinosaur transfers
337
- * - Manage habitat decommissioning
338
- * - Handle species relocations
339
- *
340
- * @example
341
- * ```ts
342
- * const transaction = new TransactionBuilder();
343
- *
344
- * // Remove dinosaur from old habitat
345
- * new DeleteBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
346
- * .condition(op => op.eq('status', 'SEDATED'))
347
- * .withTransaction(transaction);
348
- *
349
- * // Update old habitat occupancy
350
- * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
351
- * .add('occupants', -1)
352
- * .withTransaction(transaction);
353
- *
354
- * // Execute transfer atomically
355
- * await transaction.execute();
356
- * ```
357
- *
358
- * @param transaction - The transaction builder to add this operation to
359
- */
360
- withTransaction(transaction) {
361
- const command = this.toDynamoCommand();
362
- transaction.deleteWithCommand(command);
363
- }
364
- /**
365
- * Executes the delete operation against DynamoDB.
366
- *
367
- * @example
368
- * ```ts
369
- * // Delete with condition and retrieve old values
370
- * const result = await new DeleteBuilder(executor, 'myTable', { id: '123' })
371
- * .condition(op => op.eq('status', 'INACTIVE'))
372
- * .returnValues('ALL_OLD')
373
- * .execute();
374
- *
375
- * if (result.item) {
376
- * console.log('Deleted item:', result.item);
377
- * }
378
- * ```
379
- *
380
- * @returns A promise that resolves to an object containing the deleted item's attributes (if returnValues is 'ALL_OLD')
381
- */
382
- async execute() {
383
- const params = this.toDynamoCommand();
384
- return this.executor(params);
385
- }
386
- /**
387
- * Gets a human-readable representation of the delete command
388
- * with all expression placeholders replaced by their actual values.
389
- * Use this method when you need to:
390
- * - Debug complex deletion conditions
391
- * - Verify safety checks
392
- * - Log removal operations
393
- * - Troubleshoot failed deletions
394
- *
395
- * @example
396
- * ```ts
397
- * const debugInfo = new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
398
- * .condition(op => op.and([
399
- * op.eq('status', 'SEDATED'),
400
- * op.eq('location', 'MEDICAL_BAY'),
401
- * op.gt('sedationLevel', 8)
402
- * op.eq('version', 1),
403
- * op.attributeExists('status')
404
- * ]))
405
- * .debug();
406
- *
407
- * console.log('Delete command:', debugInfo);
408
- * ```
409
- *
410
- * @returns A readable representation of the delete command with resolved expressions
411
- */
412
- debug() {
413
- const command = this.toDynamoCommand();
414
- return debugCommand(command);
415
- }
416
- };
417
-
418
- export { DeleteBuilder };
419
- //# sourceMappingURL=delete-builder.js.map
420
- //# sourceMappingURL=delete-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/conditions.ts","../../src/expression.ts","../../src/utils/debug-expression.ts","../../src/builders/delete-builder.ts"],"names":[],"mappings":";AA8FO,IAAM,yBACX,GAAA,CAAC,IACD,KAAA,CAAC,MAAc,KAA+B,MAAA;AAAA,EAC5C,IAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA,CAAA;AAQK,IAAM,EAAA,GAAK,0BAA0B,IAAI,CAAA;AAQzC,IAAM,EAAA,GAAK,0BAA0B,IAAI,CAAA;AAQzC,IAAM,EAAA,GAAK,0BAA0B,IAAI,CAAA;AAQzC,IAAM,GAAA,GAAM,0BAA0B,KAAK,CAAA;AAQ3C,IAAM,EAAA,GAAK,0BAA0B,IAAI,CAAA;AAQzC,IAAM,GAAA,GAAM,0BAA0B,KAAK,CAAA;AAQ3C,IAAM,OAAU,GAAA,CAAC,IAAc,EAAA,KAAA,EAAgB,KAA+B,MAAA;AAAA,EACnF,IAAM,EAAA,SAAA;AAAA,EACN,IAAA;AAAA,EACA,KAAA,EAAO,CAAC,KAAA,EAAO,K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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BO,gBAAgB,WAAiC,EAAA;AACtD,IAAM,MAAA,OAAA,GAAU,KAAK,eAAgB,EAAA;AAErC,IAAA,WAAA,CAAY,kBAAkB,OAAO,CAAA;AAAA;AACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,MAAa,OAAuD,GAAA;AAClE,IAAM,MAAA,MAAA,GAAS,KAAK,eAAgB,EAAA;AACpC,IAAO,OAAA,IAAA,CAAK,SAAS,MAAM,CAAA;AAAA;AAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BA,KAAiC,GAAA;AAC/B,IAAM,MAAA,OAAA,GAAU,KAAK,eAAgB,EAAA;AACrC,IAAA,OAAO,aAAa,OAAO,CAAA;AAAA;AAE/B","file":"delete-builder.js","sourcesContent":["import type { Path, PathType } from \"./builders/types\";\n\n/**\n * Supported comparison operators for DynamoDB conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html AWS DynamoDB - Comparison Operator Reference}\n *\n * - eq: Equals (=)\n * - ne: Not equals (≠ / <>)\n * - lt: Less than (<)\n * - lte: Less than or equal to (≤)\n * - gt: Greater than (>)\n * - gte: Greater than or equal to (≥)\n * - between: Between two values (inclusive)\n * - beginsWith: Checks if string attribute begins with specified substring\n * - contains: Checks if string/set attribute contains specified value\n * - attributeExists: Checks if attribute exists\n * - attributeNotExists: Checks if attribute does not exist\n */\nexport type ComparisonOperator =\n | \"eq\"\n | \"ne\"\n | \"lt\"\n | \"lte\"\n | \"gt\"\n | \"gte\"\n | \"between\"\n | \"beginsWith\"\n | \"contains\"\n | \"attributeExists\"\n | \"attributeNotExists\";\n\n/**\n * Logical operators for combining multiple conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - Logical Operator Reference}\n *\n * - and: Evaluates to true if all conditions are true\n * - or: Evaluates to true if any condition is true\n * - not: Negate the result of a condition\n */\nexport type LogicalOperator = \"and\" | \"or\" | \"not\";\n\n/**\n * Represents a DynamoDB condition expression.\n * Can be either a comparison condition or a logical combination of conditions.\n *\n * @example\n * // Simple comparison condition\n * const condition: Condition = {\n * type: \"eq\",\n * attr: \"status\",\n * value: \"ACTIVE\"\n * };\n *\n * @example\n * // Logical combination of conditions\n * const condition: Condition = {\n * type: \"and\",\n * conditions: [\n * { type: \"eq\", attr: \"status\", value: \"ACTIVE\" },\n * { type: \"gt\", attr: \"age\", value: 5 }\n * ]\n * };\n */\nexport interface Condition {\n /** The type of condition (comparison or logical operator) */\n type: ComparisonOperator | LogicalOperator;\n /** The attribute name for comparison conditions */\n attr?: string;\n /** The value to compare against for comparison conditions */\n value?: unknown;\n /** Array of conditions for logical operators (and/or) */\n conditions?: Condition[];\n /** Single condition for the 'not' operator */\n condition?: Condition;\n}\n\n/**\n * Parameters used to build DynamoDB expression strings.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html Expression Attribute Names}\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeValues.html Expression Attribute Values}\n */\nexport interface ExpressionParams {\n /** Map of attribute name placeholders to actual attribute names */\n expressionAttributeNames: Record<string, string>;\n /** Map of value placeholders to actual values */\n expressionAttributeValues: Record<string, unknown>;\n /** Counter for generating unique value placeholders */\n valueCounter: { count: number };\n}\n\n/**\n * Creates a comparison condition builder function for the specified operator.\n * @internal\n */\nexport const createComparisonCondition =\n (type: ComparisonOperator) =>\n (attr: string, value: unknown): Condition => ({\n type,\n attr,\n value,\n });\n\n/**\n * Creates an equals (=) condition\n * @example\n * eq(\"status\", \"ACTIVE\") // status = \"ACTIVE\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const eq = createComparisonCondition(\"eq\");\n\n/**\n * Creates a not equals (≠) condition\n * @example\n * ne(\"status\", \"DELETED\") // status <> \"DELETED\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const ne = createComparisonCondition(\"ne\");\n\n/**\n * Creates a less than (<) condition\n * @example\n * lt(\"age\", 18) // age < 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const lt = createComparisonCondition(\"lt\");\n\n/**\n * Creates a less than or equal to (≤) condition\n * @example\n * lte(\"age\", 18) // age <= 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const lte = createComparisonCondition(\"lte\");\n\n/**\n * Creates a greater than (>) condition\n * @example\n * gt(\"price\", 100) // price > 100\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const gt = createComparisonCondition(\"gt\");\n\n/**\n * Creates a greater than or equal to (≥) condition\n * @example\n * gte(\"price\", 100) // price >= 100\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const gte = createComparisonCondition(\"gte\");\n\n/**\n * Creates a between condition that checks if a value is within a range (inclusive)\n * @example\n * between(\"age\", 18, 65) // age BETWEEN 18 AND 65\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - BETWEEN}\n */\nexport const between = (attr: string, lower: unknown, upper: unknown): Condition => ({\n type: \"between\",\n attr,\n value: [lower, upper],\n});\n\n/**\n * Creates a begins_with condition that checks if a string attribute starts with a substring\n * @example\n * beginsWith(\"email\", \"@example.com\") // begins_with(email, \"@example.com\")\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - begins_with}\n */\nexport const beginsWith = createComparisonCondition(\"beginsWith\");\n\n/**\n * Creates a contains condition that checks if a string contains a substring or if a set contains an element\n * @example\n * contains(\"tags\", \"important\") // contains(tags, \"important\")\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - contains}\n */\nexport const contains = createComparisonCondition(\"contains\");\n\n/**\n * Creates a condition that checks if an attribute exists\n * @example\n * attributeExists(\"email\") // attribute_exists(email)\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_exists}\n */\nexport const attributeExists = (attr: string): Condition => ({\n type: \"attributeExists\",\n attr,\n});\n\n/**\n * Creates a condition that checks if an attribute does not exist\n * @example\n * attributeNotExists(\"deletedAt\") // attribute_not_exists(deletedAt)\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_not_exists}\n */\nexport const attributeNotExists = (attr: string): Condition => ({\n type: \"attributeNotExists\",\n attr,\n});\n\n// --- Logical Operators ---\n\n/**\n * Combines multiple conditions with AND operator\n * @example\n * and(\n * eq(\"status\", \"ACTIVE\"),\n * gt(\"age\", 18)\n * ) // status = \"ACTIVE\" AND age > 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - AND}\n */\nexport const and = (...conditions: Condition[]): Condition => ({\n type: \"and\",\n conditions,\n});\n\n/**\n * Combines multiple conditions with OR operator\n * @example\n * or(\n * eq(\"status\", \"PENDING\"),\n * eq(\"status\", \"PROCESSING\")\n * ) // status = \"PENDING\" OR status = \"PROCESSING\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - OR}\n */\nexport const or = (...conditions: Condition[]): Condition => ({\n type: \"or\",\n conditions,\n});\n\n/**\n * Negates a condition\n * @example\n * not(eq(\"status\", \"DELETED\")) // NOT status = \"DELETED\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - NOT}\n */\nexport const not = (condition: Condition): Condition => ({\n type: \"not\",\n condition,\n});\n\n/**\n * Type-safe operators for building key conditions in DynamoDB queries.\n * Only includes operators that are valid for key conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions AWS DynamoDB - Key Condition Expressions}\n *\n * @example\n * // Using with sort key conditions\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.beginsWith(\"ORDER#\")\n * })\n */\nexport type KeyConditionOperator = {\n /** Equals comparison for key attributes */\n eq: (value: unknown) => Condition;\n /** Less than comparison for key attributes */\n lt: (value: unknown) => Condition;\n /** Less than or equal comparison for key attributes */\n lte: (value: unknown) => Condition;\n /** Greater than comparison for key attributes */\n gt: (value: unknown) => Condition;\n /** Greater than or equal comparison for key attributes */\n gte: (value: unknown) => Condition;\n /** Between range comparison for key attributes */\n between: (lower: unknown, upper: unknown) => Condition;\n /** Begins with comparison for key attributes */\n beginsWith: (value: unknown) => Condition;\n /** Combines multiple key conditions with AND */\n and: (...conditions: Condition[]) => Condition;\n};\n\n/**\n * Type-safe operators for building conditions in DynamoDB operations.\n * Includes all available condition operators with proper type inference.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html AWS DynamoDB - Condition Expressions}\n *\n * @example\n * // Using with type-safe conditions\n * interface User {\n * status: string;\n * age: number;\n * email?: string;\n * }\n *\n * table.scan<User>()\n * .where(op => op.and(\n * op.eq(\"status\", \"ACTIVE\"),\n * op.gt(\"age\", 18),\n * op.attributeExists(\"email\")\n * ))\n *\n * @template T The type of the item being operated on\n */\nexport type ConditionOperator<T extends Record<string, unknown>> = {\n eq: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n ne: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n lt: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n lte: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n gt: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n gte: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n between: <K extends Path<T>>(attr: K, lower: PathType<T, K>, upper: PathType<T, K>) => Condition;\n beginsWith: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n contains: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n attributeExists: <K extends Path<T>>(attr: K) => Condition;\n attributeNotExists: <K extends Path<T>>(attr: K) => Condition;\n and: (...conditions: Condition[]) => Condition;\n or: (...conditions: Condition[]) => Condition;\n not: (condition: Condition) => Condition;\n};\n\n/**\n * Primary key type for QUERY operations.\n * Allows building complex key conditions for the sort key.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html AWS DynamoDB - Query Operations}\n *\n * @example\n * // Query items with a specific partition key and sort key prefix\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.beginsWith(\"ORDER#2023\")\n * })\n *\n * @example\n * // Query items within a specific sort key range\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.between(\"ORDER#2023-01\", \"ORDER#2023-12\")\n * })\n */\nexport type PrimaryKey = {\n /** Partition key value */\n pk: string;\n /** Optional sort key condition builder */\n sk?: (op: KeyConditionOperator) => Condition;\n};\n\n/**\n * Primary key type for GET and DELETE operations.\n * Used when you need to specify exact key values without conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html AWS DynamoDB - Working with Items}\n *\n * @example\n * // Get a specific item by its complete primary key\n * table.get({\n * pk: \"USER#123\",\n * sk: \"PROFILE#123\"\n * })\n *\n * @example\n * // Delete a specific item by its complete primary key\n * table.delete({\n * pk: \"USER#123\",\n * sk: \"ORDER#456\"\n * })\n */\nexport type PrimaryKeyWithoutExpression = {\n /** Partition key value */\n pk: string;\n /** Optional sort key value */\n sk?: string;\n};\n","import type { ComparisonOperator, Condition, ExpressionParams, LogicalOperator } from \"./conditions\";\n\nexport const generateAttributeName = (params: ExpressionParams, attr: string): string => {\n // Check if the attribute already exists in the expressionAttributeNames\n for (const [existingName, existingAttr] of Object.entries(params.expressionAttributeNames)) {\n if (existingAttr === attr) {\n return existingName;\n }\n }\n\n // If not found, create a new attribute name\n const attrName = `#${Object.keys(params.expressionAttributeNames).length}`;\n params.expressionAttributeNames[attrName] = attr;\n return attrName;\n};\n\nexport const generateValueName = (params: ExpressionParams, value: unknown): string => {\n const valueName = `:${params.valueCounter.count++}`;\n params.expressionAttributeValues[valueName] = value;\n return valueName;\n};\n\nconst validateCondition = (condition: Condition, requiresAttr = true, requiresValue = true): void => {\n if (requiresAttr && !condition.attr) {\n throw new Error(`Attribute is required for ${condition.type} condition`);\n }\n\n if (requiresValue && condition.value === undefined) {\n throw new Error(`Value is required for ${condition.type} condition`);\n }\n};\n\nconst buildComparisonExpression = (condition: Condition, operator: string, params: ExpressionParams): string => {\n validateCondition(condition);\n\n if (!condition.attr) {\n throw new Error(`Attribute is required for ${condition.type} condition`);\n }\n\n const attrName = generateAttributeName(params, condition.attr);\n const valueName = generateValueName(params, condition.value);\n\n return `${attrName} ${operator} ${valueName}`;\n};\n\nconst buildBetweenExpression = (condition: Condition, params: ExpressionParams): string => {\n validateCondition(condition);\n\n if (!condition.attr) {\n throw new Error(`Attribute is required for ${condition.type} condition`);\n }\n\n if (!Array.isArray(condition.value) || condition.value.length !== 2) {\n throw new Error(\"Between condition requires an array of two values\");\n }\n\n const attrName = generateAttributeName(params, condition.attr);\n const lowerName = generateValueName(params, condition.value[0]);\n const upperName = generateValueName(params, condition.value[1]);\n\n return `${attrName} BETWEEN ${lowerName} AND ${upperName}`;\n};\n\nconst buildFunctionExpression = (functionName: string, condition: Condition, params: ExpressionParams): string => {\n validateCondition(condition);\n\n if (!condition.attr) {\n throw new Error(`Attribute is required for ${condition.type} condition`);\n }\n\n const attrName = generateAttributeName(params, condition.attr);\n const valueName = generateValueName(params, condition.value);\n\n return `${functionName}(${attrName}, ${valueName})`;\n};\n\nconst buildAttributeFunction = (functionName: string, condition: Condition, params: ExpressionParams): string => {\n validateCondition(condition, true, false);\n\n if (!condition.attr) {\n throw new Error(`Attribute is required for ${condition.type} condition`);\n }\n\n const attrName = generateAttributeName(params, condition.attr);\n return `${functionName}(${attrName})`;\n};\n\nconst buildLogicalExpression = (operator: string, conditions: Condition[], params: ExpressionParams): string => {\n if (!conditions || conditions.length === 0) {\n throw new Error(`At least one condition is required for ${operator} expression`);\n }\n\n const expressions = conditions.map((c) => buildExpression(c, params));\n return `(${expressions.join(` ${operator} `)})`;\n};\n\nexport const buildExpression = (condition: Condition, params: ExpressionParams): string => {\n if (!condition) return \"\";\n\n try {\n // Map of condition types to their expression builders\n const expressionBuilders: Record<ComparisonOperator | LogicalOperator, () => string> = {\n eq: () => buildComparisonExpression(condition, \"=\", params),\n ne: () => buildComparisonExpression(condition, \"<>\", params),\n lt: () => buildComparisonExpression(condition, \"<\", params),\n lte: () => buildComparisonExpression(condition, \"<=\", params),\n gt: () => buildComparisonExpression(condition, \">\", params),\n gte: () => buildComparisonExpression(condition, \">=\", params),\n between: () => buildBetweenExpression(condition, params),\n beginsWith: () => buildFunctionExpression(\"begins_with\", condition, params),\n contains: () => buildFunctionExpression(\"contains\", condition, params),\n attributeExists: () => buildAttributeFunction(\"attribute_exists\", condition, params),\n attributeNotExists: () => buildAttributeFunction(\"attribute_not_exists\", condition, params),\n and: () => {\n if (!condition.conditions) {\n throw new Error(\"Conditions array is required for AND operator\");\n }\n return buildLogicalExpression(\"AND\", condition.conditions, params);\n },\n or: () => {\n if (!condition.conditions) {\n throw new Error(\"Conditions array is required for OR operator\");\n }\n return buildLogicalExpression(\"OR\", condition.conditions, params);\n },\n not: () => {\n if (!condition.condition) {\n throw new Error(\"Condition is required for NOT operator\");\n }\n return `NOT (${buildExpression(condition.condition, params)})`;\n },\n };\n\n const builder = expressionBuilders[condition.type];\n if (!builder) {\n throw new Error(`Unknown condition type: ${condition.type}`);\n }\n\n return builder();\n } catch (error: unknown) {\n if (error instanceof Error) {\n console.error(`Error building expression for condition type ${condition.type}:`, error.message);\n } else {\n console.error(`Error building expression for condition type ${condition.type}:`, error);\n }\n throw error;\n }\n};\n\nexport const prepareExpressionParams = (\n condition?: Condition,\n): {\n expression?: string;\n names?: Record<string, string>;\n values?: Record<string, unknown>;\n} => {\n if (!condition) return {};\n\n const params: ExpressionParams = {\n expressionAttributeNames: {},\n expressionAttributeValues: {},\n valueCounter: { count: 0 },\n };\n\n const expression = buildExpression(condition, params);\n\n return {\n expression,\n names: Object.keys(params.expressionAttributeNames).length > 0 ? params.expressionAttributeNames : undefined,\n values: Object.keys(params.expressionAttributeValues).length > 0 ? params.expressionAttributeValues : undefined,\n };\n};\n","/**\n * Interface for DynamoDB command objects that can contain expressions\n */\nexport interface DynamoCommandWithExpressions {\n conditionExpression?: string;\n updateExpression?: string;\n filterExpression?: string;\n keyConditionExpression?: string;\n projectionExpression?: string;\n expressionAttributeNames?: Record<string, string>;\n expressionAttributeValues?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\ntype ReadableDynamoCommand = {\n conditionExpression?: string;\n updateExpression?: string;\n filterExpression?: string;\n keyConditionExpression?: string;\n projectionExpression?: string;\n};\n\n/**\n * Utility function to debug a DynamoDB command by replacing all placeholders\n * in expressions with their actual values.\n *\n * @param command Any DynamoDB command with expressions and attribute maps\n * @returns An object with the same structure but with readable expressions\n */\nexport function debugCommand<T extends DynamoCommandWithExpressions>(\n command: T,\n): {\n raw: T;\n readable: ReadableDynamoCommand;\n} {\n // Create a copy of the command\n const result: ReadableDynamoCommand = {};\n\n function replaceAliases(expressionString: string) {\n if (!expressionString) {\n return expressionString;\n }\n\n let replacedString = expressionString;\n for (const alias in command.expressionAttributeNames) {\n const attributeName = command.expressionAttributeNames[alias];\n const regex = new RegExp(alias, \"g\");\n\n replacedString = replacedString.replace(regex, attributeName as string);\n }\n\n for (const alias in command.expressionAttributeValues) {\n let attributeValue = command.expressionAttributeValues[alias];\n\n // Handle Set objects for better readability\n if (attributeValue instanceof Set) {\n const array = Array.from(attributeValue);\n attributeValue = `Set(${array.length}){${array.map((v) => JSON.stringify(v)).join(\", \")}}`;\n } else {\n // Stringify other values for display\n attributeValue = JSON.stringify(attributeValue);\n }\n\n const regex = new RegExp(alias, \"g\");\n replacedString = replacedString.replace(regex, attributeValue as string);\n }\n\n return replacedString;\n }\n\n if (command.updateExpression) {\n result.updateExpression = replaceAliases(command.updateExpression);\n }\n if (command.conditionExpression) {\n result.conditionExpression = replaceAliases(command.conditionExpression);\n }\n if (command.filterExpression) {\n result.filterExpression = replaceAliases(command.filterExpression);\n }\n if (command.keyConditionExpression) {\n result.keyConditionExpression = replaceAliases(command.keyConditionExpression);\n }\n if (command.projectionExpression) {\n result.projectionExpression = replaceAliases(command.projectionExpression);\n }\n\n return {\n raw: command,\n readable: result,\n };\n}\n","import type { Condition, ConditionOperator, PrimaryKeyWithoutExpression } from \"../conditions\";\nimport {\n eq,\n ne,\n lt,\n lte,\n gt,\n gte,\n between,\n beginsWith,\n contains,\n attributeExists,\n attributeNotExists,\n and,\n or,\n not,\n} from \"../conditions\";\nimport type { TransactionBuilder } from \"./transaction-builder\";\nimport { prepareExpressionParams } from \"../expression\";\nimport { debugCommand } from \"../utils/debug-expression\";\nimport type { DeleteCommandParams } from \"./builder-types\";\n\nexport interface DeleteOptions {\n condition?: Condition;\n returnValues?: \"ALL_OLD\";\n}\n\ntype DeleteExecutor = (params: DeleteCommandParams) => Promise<{ item?: Record<string, unknown> }>;\n\n/**\n * Builder for creating DynamoDB delete operations.\n * Use this builder when you need to:\n * - Remove dinosaurs from the registry\n * - Clean up abandoned habitats\n * - Delete historical tracking data\n * - Remove deprecated classifications\n *\n * @example\n * ```typescript\n * // Simple delete\n * const result = await new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })\n * .execute();\n *\n * // Conditional delete with old value retrieval\n * const result = await new DeleteBuilder(executor, 'habitats', { id: 'PADDOCK-A' })\n * .condition(op =>\n * op.and([\n * op.eq('status', 'DECOMMISSIONED'),\n * op.eq('occupants', 0),\n * op.lt('securityIncidents', 1)\n * ])\n * )\n * .returnValues('ALL_OLD')\n * .execute();\n * ```\n */\nexport class DeleteBuilder {\n private options: DeleteOptions = {\n returnValues: \"ALL_OLD\",\n };\n private readonly executor: DeleteExecutor;\n private readonly tableName: string;\n private readonly key: PrimaryKeyWithoutExpression;\n\n constructor(executor: DeleteExecutor, tableName: string, key: PrimaryKeyWithoutExpression) {\n this.executor = executor;\n this.tableName = tableName;\n this.key = key;\n }\n\n /**\n * Adds a condition that must be satisfied for the delete operation to succeed.\n * Use this method when you need to:\n * - Ensure safe removal conditions\n * - Verify habitat status before deletion\n * - Implement safety protocols\n *\n * @example\n * ```typescript\n * // Ensure dinosaur can be safely removed\n * builder.condition(op =>\n * op.and([\n * op.eq('status', 'SEDATED'),\n * op.eq('location', 'MEDICAL_BAY'),\n * op.attributeExists('lastCheckup')\n * ])\n * );\n *\n * // Verify habitat is empty\n * builder.condition(op =>\n * op.and([\n * op.eq('occupants', 0),\n * op.eq('maintenanceStatus', 'COMPLETE'),\n * op.not(op.attributeExists('activeAlerts'))\n * ])\n * );\n * ```\n *\n * @param condition - Either a Condition object or a callback function that builds the condition\n * @returns The builder instance for method chaining\n */\n public condition<T extends Record<string, unknown>>(\n condition: Condition | ((op: ConditionOperator<T>) => Condition),\n ): DeleteBuilder {\n if (typeof condition === \"function\") {\n const conditionOperator: ConditionOperator<T> = {\n eq,\n ne,\n lt,\n lte,\n gt,\n gte,\n between,\n beginsWith,\n contains,\n attributeExists,\n attributeNotExists,\n and,\n or,\n not,\n };\n this.options.condition = condition(conditionOperator);\n } else {\n this.options.condition = condition;\n }\n return this;\n }\n\n /**\n * Sets whether to return the item's attribute values before deletion.\n * Use this method when you need to:\n * - Archive removed dinosaur data\n * - Track habitat decommissioning history\n * - Maintain removal audit logs\n *\n * @example\n * ```ts\n * // Archive dinosaur data before removal\n * const result = await builder\n * .returnValues('ALL_OLD')\n * .execute();\n *\n * if (result.item) {\n * console.log('Removed dinosaur data:', {\n * species: result.item.species,\n * age: result.item.age,\n * lastLocation: result.item.location\n * });\n * }\n * ```\n *\n * @param returnValues - Use 'ALL_OLD' to return all attributes of the deleted item\n * @returns The builder instance for method chaining\n */\n public returnValues(returnValues: \"ALL_OLD\"): DeleteBuilder {\n this.options.returnValues = returnValues;\n return this;\n }\n\n /**\n * Generate the DynamoDB command parameters\n */\n private toDynamoCommand(): DeleteCommandParams {\n const { expression, names, values } = prepareExpressionParams(this.options.condition);\n\n return {\n tableName: this.tableName,\n key: this.key,\n conditionExpression: expression,\n expressionAttributeNames: names,\n expressionAttributeValues: values,\n returnValues: this.options.returnValues,\n };\n }\n\n /**\n * Adds this delete operation to a transaction.\n * Use this method when you need to:\n * - Coordinate dinosaur transfers\n * - Manage habitat decommissioning\n * - Handle species relocations\n *\n * @example\n * ```ts\n * const transaction = new TransactionBuilder();\n *\n * // Remove dinosaur from old habitat\n * new DeleteBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })\n * .condition(op => op.eq('status', 'SEDATED'))\n * .withTransaction(transaction);\n *\n * // Update old habitat occupancy\n * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })\n * .add('occupants', -1)\n * .withTransaction(transaction);\n *\n * // Execute transfer atomically\n * await transaction.execute();\n * ```\n *\n * @param transaction - The transaction builder to add this operation to\n */\n public withTransaction(transaction: TransactionBuilder) {\n const command = this.toDynamoCommand();\n\n transaction.deleteWithCommand(command);\n }\n\n /**\n * Executes the delete operation against DynamoDB.\n *\n * @example\n * ```ts\n * // Delete with condition and retrieve old values\n * const result = await new DeleteBuilder(executor, 'myTable', { id: '123' })\n * .condition(op => op.eq('status', 'INACTIVE'))\n * .returnValues('ALL_OLD')\n * .execute();\n *\n * if (result.item) {\n * console.log('Deleted item:', result.item);\n * }\n * ```\n *\n * @returns A promise that resolves to an object containing the deleted item's attributes (if returnValues is 'ALL_OLD')\n */\n public async execute(): Promise<{ item?: Record<string, unknown> }> {\n const params = this.toDynamoCommand();\n return this.executor(params);\n }\n\n /**\n * Gets a human-readable representation of the delete command\n * with all expression placeholders replaced by their actual values.\n * Use this method when you need to:\n * - Debug complex deletion conditions\n * - Verify safety checks\n * - Log removal operations\n * - Troubleshoot failed deletions\n *\n * @example\n * ```ts\n * const debugInfo = new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })\n * .condition(op => op.and([\n * op.eq('status', 'SEDATED'),\n * op.eq('location', 'MEDICAL_BAY'),\n * op.gt('sedationLevel', 8)\n * op.eq('version', 1),\n * op.attributeExists('status')\n * ]))\n * .debug();\n *\n * console.log('Delete command:', debugInfo);\n * ```\n *\n * @returns A readable representation of the delete command with resolved expressions\n */\n debug(): Record<string, unknown> {\n const command = this.toDynamoCommand();\n return debugCommand(command);\n }\n}\n"]}