dyno-table 2.5.2 → 2.6.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 (76) 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.cjs +3648 -43
  18. package/dist/builders.d.ts +1 -4
  19. package/dist/builders.js +3648 -3
  20. package/dist/conditions.cjs +60 -67
  21. package/dist/conditions.d.ts +705 -3
  22. package/dist/conditions.js +46 -1
  23. package/dist/entity/ddb-indexing.d.ts +45 -0
  24. package/dist/entity/entity.d.ts +188 -0
  25. package/dist/entity/index-utils.d.ts +24 -0
  26. package/dist/entity.cjs +1126 -15
  27. package/dist/entity.d.ts +1 -261
  28. package/dist/entity.js +1127 -3
  29. package/dist/errors.d.ts +212 -0
  30. package/dist/expression.d.ts +9 -0
  31. package/dist/index-definition.d.ts +10 -0
  32. package/dist/index.cjs +5388 -270
  33. package/dist/index.d.ts +16 -273
  34. package/dist/index.js +5332 -6
  35. package/dist/operation-types.d.ts +8 -0
  36. package/dist/standard-schema.d.ts +2 -4
  37. package/dist/table.cjs +4311 -7
  38. package/dist/table.d.ts +13 -8
  39. package/dist/table.js +4315 -4
  40. package/dist/types.d.ts +6 -9
  41. package/dist/utils/chunk-array.d.ts +9 -0
  42. package/dist/utils/debug-expression.d.ts +32 -0
  43. package/dist/utils/debug-transaction.d.ts +17 -0
  44. package/dist/utils/error-factory.d.ts +162 -0
  45. package/dist/utils/error-utils.d.ts +170 -0
  46. package/dist/utils/index.d.ts +7 -0
  47. package/dist/utils/partition-key-template.d.ts +30 -0
  48. package/dist/utils/sort-key-template.d.ts +33 -0
  49. package/dist/utils.cjs +28 -10
  50. package/dist/utils.d.ts +1 -66
  51. package/dist/utils.js +29 -1
  52. package/package.json +53 -66
  53. package/dist/builders.d.cts +0 -4
  54. package/dist/chunk-2WIBY7PZ.js +0 -46
  55. package/dist/chunk-3DR6VOFW.cjs +0 -3349
  56. package/dist/chunk-42LH2UEM.js +0 -577
  57. package/dist/chunk-7UJJ7JXM.cjs +0 -63
  58. package/dist/chunk-ELULXDSB.cjs +0 -564
  59. package/dist/chunk-FF7FYGDH.js +0 -543
  60. package/dist/chunk-G5ERTQFX.cjs +0 -843
  61. package/dist/chunk-NYJGW3XH.js +0 -3334
  62. package/dist/chunk-PB7BBCZO.cjs +0 -32
  63. package/dist/chunk-QVRMYGC4.js +0 -29
  64. package/dist/chunk-RNX2DAHA.js +0 -818
  65. package/dist/chunk-ZUBCW3LA.cjs +0 -579
  66. package/dist/conditions-BSAcZswY.d.ts +0 -731
  67. package/dist/conditions-C8bM__Pn.d.cts +0 -731
  68. package/dist/conditions.d.cts +0 -3
  69. package/dist/entity.d.cts +0 -261
  70. package/dist/index-Bc-ra0im.d.ts +0 -3042
  71. package/dist/index-CPCmWsEv.d.cts +0 -3042
  72. package/dist/index.d.cts +0 -273
  73. package/dist/standard-schema.d.cts +0 -57
  74. package/dist/table.d.cts +0 -165
  75. package/dist/types.d.cts +0 -29
  76. package/dist/utils.d.cts +0 -66
@@ -0,0 +1,191 @@
1
+ import type { PrimaryKeyWithoutExpression } from "../conditions";
2
+ import type { DynamoItem } from "../types";
3
+ import type { BatchBuilder } from "./batch-builder";
4
+ import type { Path } from "./types";
5
+ /**
6
+ * Configuration options for DynamoDB get operations.
7
+ */
8
+ export interface GetOptions {
9
+ /** List of attributes to return in the result */
10
+ projection?: string[];
11
+ /** Whether to use strongly consistent reads */
12
+ consistentRead?: boolean;
13
+ }
14
+ /**
15
+ * Parameters for the DynamoDB get command.
16
+ */
17
+ export interface GetCommandParams {
18
+ /** The name of the DynamoDB table */
19
+ tableName: string;
20
+ /** The primary key of the item to get */
21
+ key: PrimaryKeyWithoutExpression;
22
+ /** Comma-separated list of attributes to return */
23
+ projectionExpression?: string;
24
+ /** Map of expression attribute name placeholders to actual names */
25
+ expressionAttributeNames?: Record<string, string>;
26
+ /** Whether to use strongly consistent reads */
27
+ consistentRead?: boolean;
28
+ }
29
+ /**
30
+ * Function type for executing DynamoDB get operations.
31
+ * @typeParam T - The type of item being retrieved
32
+ */
33
+ type GetExecutor<T extends DynamoItem> = (params: GetCommandParams) => Promise<{
34
+ item: T | undefined;
35
+ }>;
36
+ /**
37
+ * Builder for creating DynamoDB get operations.
38
+ * Use this builder when you need to:
39
+ * - Retrieve a single dinosaur by its primary key
40
+ * - Project specific dinosaur attributes
41
+ * - Use consistent reads for critical dinosaur data
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Simple get
46
+ * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
47
+ * .execute();
48
+ *
49
+ * // Get with projection and consistent read
50
+ * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
51
+ * .select(['species', 'name', 'diet'])
52
+ * .consistentRead()
53
+ * .execute();
54
+ * ```
55
+ *
56
+ * @typeParam T - The type of item being retrieved
57
+ */
58
+ export declare class GetBuilder<T extends DynamoItem> {
59
+ private readonly executor;
60
+ private readonly params;
61
+ private options;
62
+ private selectedFields;
63
+ private includeIndexAttributes;
64
+ private readonly indexAttributeNames;
65
+ /**
66
+ * Creates a new GetBuilder instance.
67
+ *
68
+ * @param executor - Function that executes the get operation
69
+ * @param key - Primary key of the item to retrieve
70
+ * @param tableName - Name of the DynamoDB table
71
+ */
72
+ constructor(executor: GetExecutor<T>, key: PrimaryKeyWithoutExpression, tableName: string, indexAttributeNames?: string[]);
73
+ /**
74
+ * Specifies which attributes to return in the get results.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * // Select single attribute
79
+ * builder.select('species')
80
+ *
81
+ * // Select multiple attributes
82
+ * builder.select(['id', 'species', 'diet'])
83
+ *
84
+ * // Chain multiple select calls
85
+ * builder
86
+ * .select('id')
87
+ * .select(['species', 'diet'])
88
+ * ```
89
+ *
90
+ * @param fields - A single field name or an array of field names to return
91
+ * @returns The builder instance for method chaining
92
+ */
93
+ select<K extends Path<T>>(fields: K | K[]): GetBuilder<T>;
94
+ /**
95
+ * Ensures index attributes are included in the result.
96
+ * By default, index attributes are removed from get responses.
97
+ */
98
+ includeIndexes(): GetBuilder<T>;
99
+ /**
100
+ * Sets whether to use strongly consistent reads for the get operation.
101
+ * Use this method when you need:
102
+ * - The most up-to-date dinosaur data
103
+ * - To ensure you're reading the latest dinosaur status
104
+ * - Critical safety information about dangerous species
105
+ *
106
+ * Note: Consistent reads consume twice the throughput
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * // Get the latest T-Rex data
111
+ * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
112
+ * .consistentRead()
113
+ * .execute();
114
+ * ```
115
+ *
116
+ * @param consistentRead - Whether to use consistent reads (defaults to true)
117
+ * @returns The builder instance for method chaining
118
+ */
119
+ consistentRead(consistentRead?: boolean): GetBuilder<T>;
120
+ /**
121
+ * Adds this get operation to a batch with optional entity type information.
122
+ *
123
+ * @example Basic Usage
124
+ * ```ts
125
+ * const batch = table.batchBuilder();
126
+ *
127
+ * // Add multiple get operations to batch
128
+ * dinosaurRepo.get({ id: 'dino-1' }).withBatch(batch);
129
+ * dinosaurRepo.get({ id: 'dino-2' }).withBatch(batch);
130
+ * dinosaurRepo.get({ id: 'dino-3' }).withBatch(batch);
131
+ *
132
+ * // Execute all gets efficiently
133
+ * const results = await batch.execute();
134
+ * ```
135
+ *
136
+ * @example Typed Usage
137
+ * ```ts
138
+ * const batch = table.batchBuilder<{
139
+ * User: UserEntity;
140
+ * Order: OrderEntity;
141
+ * }>();
142
+ *
143
+ * // Add operations with type information
144
+ * userRepo.get({ id: 'user-1' }).withBatch(batch, 'User');
145
+ * orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
146
+ *
147
+ * // Execute and get typed results
148
+ * const result = await batch.execute();
149
+ * const users: UserEntity[] = result.reads.itemsByType.User;
150
+ * const orders: OrderEntity[] = result.reads.itemsByType.Order;
151
+ * ```
152
+ *
153
+ * @param batch - The batch builder to add this operation to
154
+ * @param entityType - Optional entity type key for type tracking
155
+ */
156
+ withBatch<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>, K extends keyof TEntities = keyof TEntities>(batch: BatchBuilder<TEntities>, entityType?: K): void;
157
+ /**
158
+ * Converts the builder configuration to a DynamoDB command
159
+ */
160
+ private toDynamoCommand;
161
+ private addIndexAttributesToSelection;
162
+ private omitIndexAttributes;
163
+ /**
164
+ * Executes the get operation against DynamoDB.
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * try {
169
+ * const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
170
+ * .select(['species', 'name', 'diet'])
171
+ * .consistentRead()
172
+ * .execute();
173
+ *
174
+ * if (result.item) {
175
+ * console.log('Dinosaur found:', result.item);
176
+ * } else {
177
+ * console.log('Dinosaur not found');
178
+ * }
179
+ * } catch (error) {
180
+ * console.error('Error getting dinosaur:', error);
181
+ * }
182
+ * ```
183
+ *
184
+ * @returns A promise that resolves to an object containing:
185
+ * - item: The retrieved dinosaur or undefined if not found
186
+ */
187
+ execute(): Promise<{
188
+ item: T | undefined;
189
+ }>;
190
+ }
191
+ export {};
@@ -0,0 +1,14 @@
1
+ export { BatchBuilder } from "./batch-builder.js";
2
+ export type * from "./builder-types.js";
3
+ export { ConditionCheckBuilder } from "./condition-check-builder.js";
4
+ export { DeleteBuilder } from "./delete-builder.js";
5
+ export { FilterBuilder } from "./filter-builder.js";
6
+ export { GetBuilder } from "./get-builder.js";
7
+ export { Paginator } from "./paginator.js";
8
+ export { PutBuilder } from "./put-builder.js";
9
+ export { QueryBuilder } from "./query-builder.js";
10
+ export { ResultIterator } from "./result-iterator.js";
11
+ export { ScanBuilder } from "./scan-builder.js";
12
+ export { TransactionBuilder } from "./transaction-builder.js";
13
+ export type * from "./types.js";
14
+ export { UpdateBuilder } from "./update-builder.js";
@@ -0,0 +1,151 @@
1
+ import type { DynamoItem, TableConfig } from "../types";
2
+ import type { PaginationResult, QueryBuilderInterface } from "./builder-types";
3
+ /**
4
+ * A utility class for handling DynamoDB pagination.
5
+ * Use this class when you need to:
6
+ * - Browse large collections of dinosaurs
7
+ * - Review extensive security logs
8
+ * - Analyze habitat inspection history
9
+ * - Process feeding schedules
10
+ *
11
+ * The paginator maintains internal state and automatically handles:
12
+ * - Page boundaries
13
+ * - Result set limits
14
+ * - Continuation tokens
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // List all velociraptors with pagination
19
+ * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))
20
+ * .filter(op => op.eq('status', 'ACTIVE'))
21
+ * .paginate(10);
22
+ *
23
+ * // Process each page of dinosaurs
24
+ * while (paginator.hasNextPage()) {
25
+ * const page = await paginator.getNextPage();
26
+ * console.log(`Processing page ${page.page} of velociraptors`);
27
+ *
28
+ * for (const raptor of page.items) {
29
+ * console.log(`- ${raptor.id}: Health=${raptor.stats.health}`);
30
+ * }
31
+ * }
32
+ * ```
33
+ *
34
+ * @typeParam T - The type of items being paginated
35
+ * @typeParam TConfig - The table configuration type
36
+ */
37
+ export declare class Paginator<T extends DynamoItem, TConfig extends TableConfig = TableConfig> {
38
+ private queryBuilder;
39
+ private readonly pageSize?;
40
+ private currentPage;
41
+ private lastEvaluatedKey?;
42
+ private hasMorePages;
43
+ private totalItemsRetrieved;
44
+ private readonly overallLimit?;
45
+ constructor(queryBuilder: QueryBuilderInterface<T, TConfig>, pageSize?: number);
46
+ /**
47
+ * Gets the current page number (1-indexed).
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const paginator = new QueryBuilder(executor, eq('species', 'Tyrannosaurus'))
52
+ * .paginate(5);
53
+ *
54
+ * await paginator.getNextPage();
55
+ * console.log(`Reviewing T-Rex group ${paginator.getCurrentPage()}`);
56
+ * ```
57
+ *
58
+ * @returns The current page number, starting from 1
59
+ */
60
+ getCurrentPage(): number;
61
+ /**
62
+ * Checks if there are more pages of dinosaurs or habitats to process.
63
+ *
64
+ * This method takes into account both:
65
+ * - DynamoDB's lastEvaluatedKey mechanism
66
+ * - Any overall limit set on the query
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * // Process all security incidents
71
+ * const paginator = new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
72
+ * .sortDescending()
73
+ * .paginate(10);
74
+ *
75
+ * while (paginator.hasNextPage()) {
76
+ * const page = await paginator.getNextPage();
77
+ * for (const incident of page.items) {
78
+ * await processSecurityBreach(incident);
79
+ * }
80
+ * console.log(`Processed incidents page ${page.page}`);
81
+ * }
82
+ * ```
83
+ *
84
+ * @returns true if there are more pages available, false otherwise
85
+ */
86
+ hasNextPage(): boolean;
87
+ /**
88
+ * Retrieves the next page of dinosaurs or habitats from DynamoDB.
89
+ *
90
+ * This method handles:
91
+ * - Automatic continuation between groups
92
+ * - Respect for park capacity limits
93
+ * - Group size adjustments for safety
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))
98
+ * .filter(op => op.eq('status', 'ACTIVE'))
99
+ * .paginate(5);
100
+ *
101
+ * // Check first raptor group
102
+ * const page1 = await paginator.getNextPage();
103
+ * console.log(`Found ${page1.items.length} active raptors`);
104
+ *
105
+ * // Continue inspection if more groups exist
106
+ * if (page1.hasNextPage) {
107
+ * const page2 = await paginator.getNextPage();
108
+ * console.log(`Inspecting raptor group ${page2.page}`);
109
+ *
110
+ * for (const raptor of page2.items) {
111
+ * await performHealthCheck(raptor);
112
+ * }
113
+ * }
114
+ * ```
115
+ *
116
+ * @returns A promise that resolves to a PaginationResult containing:
117
+ * - items: The dinosaurs/habitats for this page
118
+ * - hasNextPage: Whether more groups exist
119
+ * - page: The current group number
120
+ * - lastEvaluatedKey: DynamoDB's continuation token
121
+ */
122
+ getNextPage(): Promise<PaginationResult<T>>;
123
+ /**
124
+ * Gets all remaining dinosaurs or habitats and combines them into a single array.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * // Get complete carnivore inventory
129
+ * const paginator = new QueryBuilder(executor, eq('diet', 'CARNIVORE'))
130
+ * .filter(op => op.eq('status', 'ACTIVE'))
131
+ * .paginate(10);
132
+ *
133
+ * try {
134
+ * const allCarnivores = await paginator.getAllPages();
135
+ * console.log(`Park contains ${allCarnivores.length} active carnivores`);
136
+ *
137
+ * // Calculate total threat level
138
+ * const totalThreat = allCarnivores.reduce(
139
+ * (sum, dino) => sum + dino.stats.threatLevel,
140
+ * 0
141
+ * );
142
+ * console.log(`Total threat level: ${totalThreat}`);
143
+ * } catch (error) {
144
+ * console.error('Failed to complete carnivore census:', error);
145
+ * }
146
+ * ```
147
+ *
148
+ * @returns A promise that resolves to an array containing all remaining items
149
+ */
150
+ getAllPages(): Promise<T[]>;
151
+ }
@@ -0,0 +1,317 @@
1
+ import type { Condition, ConditionOperator } from "../conditions";
2
+ import type { DynamoItem } from "../types";
3
+ import type { BatchBuilder } from "./batch-builder";
4
+ import type { PutCommandParams } from "./builder-types";
5
+ import type { TransactionBuilder } from "./transaction-builder";
6
+ import type { Path, PathType } from "./types";
7
+ /**
8
+ * Configuration options for DynamoDB put operations.
9
+ */
10
+ export interface PutOptions {
11
+ /** Optional condition that must be satisfied for the put operation to succeed */
12
+ condition?: Condition;
13
+ /** Determines how to handle the return value of the put operation
14
+ * @options
15
+ * - NONE: No return value
16
+ * - ALL_OLD: Returns the item's previous state if it existed
17
+ * - CONSISTENT: Performs a GET operation after the put to retrieve the item's new state
18
+ * - INPUT: Returns the input values that were passed to the operation
19
+ */
20
+ returnValues?: "ALL_OLD" | "NONE" | "CONSISTENT" | "INPUT";
21
+ }
22
+ type PutExecutor<T extends DynamoItem> = (params: PutCommandParams) => Promise<T>;
23
+ /**
24
+ * Builder for creating DynamoDB put operations.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // Add new dinosaur
29
+ * const result = await new PutBuilder(executor, {
30
+ * id: 'RAPTOR-001',
31
+ * species: 'Velociraptor',
32
+ * status: 'ACTIVE',
33
+ * stats: {
34
+ * health: 100,
35
+ * age: 5,
36
+ * threatLevel: 8
37
+ * }
38
+ * }, 'dinosaurs').execute();
39
+ *
40
+ * // Create new habitat with conditions
41
+ * const result = await new PutBuilder(executor, {
42
+ * id: 'PADDOCK-C',
43
+ * type: 'CARNIVORE',
44
+ * securityLevel: 'MAXIMUM',
45
+ * capacity: 3,
46
+ * environmentType: 'TROPICAL'
47
+ * }, 'habitats')
48
+ * .condition(op => op.attributeNotExists('id'))
49
+ * .execute();
50
+ * ```
51
+ *
52
+ * @typeParam T - The type of item being put into the table
53
+ */
54
+ export declare class PutBuilder<T extends DynamoItem> {
55
+ private readonly item;
56
+ private options;
57
+ private readonly executor;
58
+ private readonly tableName;
59
+ constructor(executor: PutExecutor<T>, item: T, tableName: string);
60
+ /**
61
+ * Sets multiple attributes of an item using an DynamoItem.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Update multiple attributes
66
+ * builder.set({
67
+ * species: 'Tyrannosaurus Rex',
68
+ * height: 20,
69
+ * diet: 'CARNIVORE',
70
+ * 'stats.threatLevel': 10
71
+ * });
72
+ * ```
73
+ */
74
+ set(values: Partial<T>): this;
75
+ /**
76
+ * Sets a single attribute to a specific value.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * // Set simple attributes
81
+ * builder
82
+ * .set('status', 'SLEEPING')
83
+ * .set('lastFeeding', new Date().toISOString());
84
+ *
85
+ * // Set nested attributes
86
+ * builder
87
+ * .set('location.zone', 'RESTRICTED')
88
+ * .set('stats.health', 100);
89
+ * ```
90
+ */
91
+ set<K extends Path<T>>(path: K, value: PathType<T, K>): this;
92
+ /**
93
+ * Adds a condition that must be satisfied for the put operation to succeed.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * // Ensure item doesn't exist (insert only)
98
+ * builder.condition(op => op.attributeNotExists('id'))
99
+ *
100
+ * // Complex condition with version check
101
+ * builder.condition(op =>
102
+ * op.and([
103
+ * op.attributeExists('id'),
104
+ * op.eq('version', currentVersion),
105
+ * op.eq('status', 'ACTIVE')
106
+ * ])
107
+ * )
108
+ * ```
109
+ *
110
+ * @param condition - Either a Condition object or a callback function that builds the condition
111
+ * @returns The builder instance for method chaining
112
+ */
113
+ /**
114
+ * Adds a condition that must be satisfied for the put operation to succeed.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * // Ensure unique dinosaur ID
119
+ * builder.condition(op =>
120
+ * op.attributeNotExists('id')
121
+ * );
122
+ *
123
+ * // Verify habitat requirements
124
+ * builder.condition(op =>
125
+ * op.and([
126
+ * op.eq('securityStatus', 'READY'),
127
+ * op.attributeExists('lastInspection'),
128
+ * op.gt('securityLevel', 5)
129
+ * ])
130
+ * );
131
+ *
132
+ * // Check breeding facility conditions
133
+ * builder.condition(op =>
134
+ * op.and([
135
+ * op.between('temperature', 25, 30),
136
+ * op.between('humidity', 60, 80),
137
+ * op.eq('quarantineStatus', 'CLEAR')
138
+ * ])
139
+ * );
140
+ * ```
141
+ *
142
+ * @param condition - Either a Condition object or a callback function that builds the condition
143
+ * @returns The builder instance for method chaining
144
+ */
145
+ condition(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
146
+ /**
147
+ * Sets whether to return the item's previous values (if it existed).
148
+ *
149
+ * @options
150
+ * - NONE: No return value
151
+ * - ALL_OLD: Returns the item's previous state if it existed, no read capacity units are consumed
152
+ * - CONSISTENT: Performs a GET operation after the put to retrieve the item's new state
153
+ * - INPUT: Returns the input values that were passed to the operation
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * // Get previous dinosaur state
158
+ * const result = await builder
159
+ * .returnValues('ALL_OLD')
160
+ * .execute();
161
+ *
162
+ * if (result) {
163
+ * console.log('Previous profile:', {
164
+ * species: result.species,
165
+ * status: result.status,
166
+ * stats: {
167
+ * health: result.stats.health,
168
+ * threatLevel: result.stats.threatLevel
169
+ * }
170
+ * });
171
+ * }
172
+ *
173
+ * // Return input values for create operations
174
+ * const createResult = await builder
175
+ * .returnValues('INPUT')
176
+ * .execute();
177
+ * ```
178
+ *
179
+ * @param returnValues - Use 'ALL_OLD' to return previous values, 'INPUT' to return input values, 'CONSISTENT' for fresh data, or 'NONE' (default).
180
+ * @returns The builder instance for method chaining
181
+ */
182
+ returnValues(returnValues: "ALL_OLD" | "NONE" | "CONSISTENT" | "INPUT"): this;
183
+ /**
184
+ * Generate the DynamoDB command parameters
185
+ */
186
+ private toDynamoCommand;
187
+ /**
188
+ * Adds this put operation to a transaction.
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * const transaction = new TransactionBuilder();
193
+ *
194
+ * // Add dinosaur to new habitat
195
+ * new PutBuilder(executor, {
196
+ * id: 'TREX-002',
197
+ * location: 'PADDOCK-B',
198
+ * status: 'ACTIVE',
199
+ * transferDate: new Date().toISOString()
200
+ * }, 'dinosaurs')
201
+ * .withTransaction(transaction);
202
+ *
203
+ * // Update habitat records
204
+ * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-B' })
205
+ * .add('occupants', 1)
206
+ * .set('lastTransfer', new Date().toISOString())
207
+ * .withTransaction(transaction);
208
+ *
209
+ * // Execute transfer atomically
210
+ * await transaction.execute();
211
+ * ```
212
+ *
213
+ * @param transaction - The transaction builder to add this operation to
214
+ * @returns The builder instance for method chaining
215
+ */
216
+ withTransaction(transaction: TransactionBuilder): this;
217
+ /**
218
+ * Adds this put operation to a batch with optional entity type information.
219
+ *
220
+ * @example Basic Usage
221
+ * ```ts
222
+ * const batch = table.batchBuilder();
223
+ *
224
+ * // Add multiple dinosaurs to batch
225
+ * dinosaurRepo.create(newDino1).withBatch(batch);
226
+ * dinosaurRepo.create(newDino2).withBatch(batch);
227
+ * dinosaurRepo.create(newDino3).withBatch(batch);
228
+ *
229
+ * // Execute all operations efficiently
230
+ * await batch.execute();
231
+ * ```
232
+ *
233
+ * @example Typed Usage
234
+ * ```ts
235
+ * const batch = table.batchBuilder<{
236
+ * User: UserEntity;
237
+ * Order: OrderEntity;
238
+ * }>();
239
+ *
240
+ * // Add operations with type information
241
+ * userRepo.create(newUser).withBatch(batch, 'User');
242
+ * orderRepo.create(newOrder).withBatch(batch, 'Order');
243
+ *
244
+ * // Execute and get typed results
245
+ * const result = await batch.execute();
246
+ * const users: UserEntity[] = result.reads.itemsByType.User;
247
+ * ```
248
+ *
249
+ * @param batch - The batch builder to add this operation to
250
+ * @param entityType - Optional entity type key for type tracking
251
+ */
252
+ withBatch<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>, K extends keyof TEntities = keyof TEntities>(batch: BatchBuilder<TEntities>, entityType?: K): void;
253
+ /**
254
+ * Executes the put operation against DynamoDB.
255
+ *
256
+ * @example
257
+ * ```ts
258
+ * try {
259
+ * // Put with condition and return old values
260
+ * const result = await new PutBuilder(executor, newItem, 'myTable')
261
+ * .condition(op => op.eq('version', 1))
262
+ * .returnValues('ALL_OLD')
263
+ * .execute();
264
+ *
265
+ * console.log('Put successful, old item:', result);
266
+ * } catch (error) {
267
+ * // Handle condition check failure or other errors
268
+ * console.error('Put failed:', error);
269
+ * }
270
+ * ```
271
+ *
272
+ * @returns A promise that resolves to the operation result (type depends on returnValues setting)
273
+ * @throws Will throw an error if the condition check fails or other DynamoDB errors occur
274
+ */
275
+ execute(): Promise<T | undefined>;
276
+ /**
277
+ * Gets a human-readable representation of the put command
278
+ * with all expression placeholders replaced by their actual values.
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * const debugInfo = new PutBuilder(executor, {
283
+ * id: 'RAPTOR-003',
284
+ * species: 'Velociraptor',
285
+ * status: 'QUARANTINE',
286
+ * stats: {
287
+ * health: 100,
288
+ * aggressionLevel: 7,
289
+ * age: 2
290
+ * }
291
+ * }, 'dinosaurs')
292
+ * .condition(op =>
293
+ * op.and([
294
+ * op.attributeNotExists('id'),
295
+ * op.eq('quarantineStatus', 'READY'),
296
+ * op.gt('securityLevel', 8)
297
+ * ])
298
+ * )
299
+ * .debug();
300
+ *
301
+ * console.log('Dinosaur transfer command:', debugInfo);
302
+ * ```
303
+ *
304
+ * @returns A readable representation of the put command with resolved expressions
305
+ */
306
+ debug(): {
307
+ raw: PutCommandParams;
308
+ readable: {
309
+ conditionExpression?: string;
310
+ updateExpression?: string;
311
+ filterExpression?: string;
312
+ keyConditionExpression?: string;
313
+ projectionExpression?: string;
314
+ };
315
+ };
316
+ }
317
+ export {};