dyno-table 1.6.0 → 1.7.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.
- package/README.md +52 -139
- package/dist/batch-builder-DNsz6zvh.d.cts +398 -0
- package/dist/batch-builder-Dz1yPGrJ.d.ts +398 -0
- package/dist/builders/condition-check-builder.cjs +0 -13
- package/dist/builders/condition-check-builder.cjs.map +1 -1
- package/dist/builders/condition-check-builder.d.cts +0 -13
- package/dist/builders/condition-check-builder.d.ts +0 -13
- package/dist/builders/condition-check-builder.js +0 -13
- package/dist/builders/condition-check-builder.js.map +1 -1
- package/dist/builders/delete-builder.cjs +38 -0
- package/dist/builders/delete-builder.cjs.map +1 -1
- package/dist/builders/delete-builder.d.cts +36 -0
- package/dist/builders/delete-builder.d.ts +36 -0
- package/dist/builders/delete-builder.js +38 -0
- package/dist/builders/delete-builder.js.map +1 -1
- package/dist/builders/paginator.cjs +0 -24
- package/dist/builders/paginator.cjs.map +1 -1
- package/dist/builders/paginator.d.cts +0 -24
- package/dist/builders/paginator.d.ts +0 -24
- package/dist/builders/paginator.js +0 -24
- package/dist/builders/paginator.js.map +1 -1
- package/dist/builders/put-builder.cjs +39 -8
- package/dist/builders/put-builder.cjs.map +1 -1
- package/dist/builders/put-builder.d.cts +37 -8
- package/dist/builders/put-builder.d.ts +37 -8
- package/dist/builders/put-builder.js +39 -8
- package/dist/builders/put-builder.js.map +1 -1
- package/dist/builders/query-builder.cjs +0 -53
- package/dist/builders/query-builder.cjs.map +1 -1
- package/dist/builders/query-builder.d.cts +1 -1
- package/dist/builders/query-builder.d.ts +1 -1
- package/dist/builders/query-builder.js +0 -53
- package/dist/builders/query-builder.js.map +1 -1
- package/dist/builders/transaction-builder.cjs +0 -47
- package/dist/builders/transaction-builder.cjs.map +1 -1
- package/dist/builders/transaction-builder.d.cts +0 -47
- package/dist/builders/transaction-builder.d.ts +0 -47
- package/dist/builders/transaction-builder.js +0 -47
- package/dist/builders/transaction-builder.js.map +1 -1
- package/dist/builders/update-builder.cjs +2 -2
- package/dist/builders/update-builder.cjs.map +1 -1
- package/dist/builders/update-builder.d.cts +2 -2
- package/dist/builders/update-builder.d.ts +2 -2
- package/dist/builders/update-builder.js +2 -2
- package/dist/builders/update-builder.js.map +1 -1
- package/dist/conditions.cjs.map +1 -1
- package/dist/conditions.js.map +1 -1
- package/dist/entity.cjs +69 -37
- package/dist/entity.cjs.map +1 -1
- package/dist/entity.d.cts +30 -10
- package/dist/entity.d.ts +30 -10
- package/dist/entity.js +69 -37
- package/dist/entity.js.map +1 -1
- package/dist/index.cjs +530 -182
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +529 -183
- package/dist/index.js.map +1 -1
- package/dist/{query-builder-CbHvimBk.d.cts → query-builder-BDuHHrb-.d.cts} +0 -34
- package/dist/{query-builder-BhrR31oO.d.ts → query-builder-C6XjVEFH.d.ts} +0 -34
- package/dist/{table-Des8C2od.d.ts → table-BWa4tx63.d.ts} +39 -151
- package/dist/{table-CY9byPEg.d.cts → table-DAKlzQsK.d.cts} +39 -151
- package/dist/table.cjs +459 -145
- package/dist/table.cjs.map +1 -1
- package/dist/table.d.cts +3 -2
- package/dist/table.d.ts +3 -2
- package/dist/table.js +459 -145
- package/dist/table.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -40,10 +40,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
40
40
|
protected selectedFields: Set<string>;
|
|
41
41
|
/**
|
|
42
42
|
* Sets the maximum number of items to return.
|
|
43
|
-
* Use this method when you need to:
|
|
44
|
-
* - Limit the number of dinosaurs returned
|
|
45
|
-
* - Control the size of habitat reports
|
|
46
|
-
* - Implement manual pagination of security logs
|
|
47
43
|
*
|
|
48
44
|
* Note: This limit applies to the items that match the key condition
|
|
49
45
|
* before any filter expressions are applied.
|
|
@@ -69,11 +65,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
69
65
|
getLimit(): number | undefined;
|
|
70
66
|
/**
|
|
71
67
|
* Specifies a Global Secondary Index (GSI) to use for the operation.
|
|
72
|
-
* Use this method when you need to:
|
|
73
|
-
* - Find dinosaurs by species or status
|
|
74
|
-
* - Search habitats by security level
|
|
75
|
-
* - Find incidents by date
|
|
76
|
-
* - List feeding schedules by time
|
|
77
68
|
*
|
|
78
69
|
* @example
|
|
79
70
|
* ```typescript
|
|
@@ -99,11 +90,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
99
90
|
useIndex<I extends GSINames<TConfig>>(indexName: I): this;
|
|
100
91
|
/**
|
|
101
92
|
* Sets whether to use strongly consistent reads for the operation.
|
|
102
|
-
* Use this method when you need to:
|
|
103
|
-
* - Get real-time dinosaur status updates
|
|
104
|
-
* - Monitor critical security systems
|
|
105
|
-
* - Track immediate habitat changes
|
|
106
|
-
* - Verify containment protocols
|
|
107
93
|
*
|
|
108
94
|
* Note:
|
|
109
95
|
* - Consistent reads are not available on GSIs
|
|
@@ -131,11 +117,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
131
117
|
consistentRead(consistentRead?: boolean): this;
|
|
132
118
|
/**
|
|
133
119
|
* Adds a filter expression to refine the operation results.
|
|
134
|
-
* Use this method when you need to:
|
|
135
|
-
* - Filter dinosaurs by behavior patterns
|
|
136
|
-
* - Find habitats with specific conditions
|
|
137
|
-
* - Search for security incidents
|
|
138
|
-
* - Monitor feeding patterns
|
|
139
120
|
*
|
|
140
121
|
* @example
|
|
141
122
|
* ```typescript
|
|
@@ -164,11 +145,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
164
145
|
filter(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
165
146
|
/**
|
|
166
147
|
* Specifies which attributes to return in the results.
|
|
167
|
-
* Use this method when you need to:
|
|
168
|
-
* - Get specific dinosaur attributes
|
|
169
|
-
* - Retrieve habitat statistics
|
|
170
|
-
* - Monitor security metrics
|
|
171
|
-
* - Optimize response size
|
|
172
148
|
*
|
|
173
149
|
* @example
|
|
174
150
|
* ```typescript
|
|
@@ -223,11 +199,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
223
199
|
paginate(pageSize: number): Paginator<T, TConfig>;
|
|
224
200
|
/**
|
|
225
201
|
* Sets the starting point using a previous lastEvaluatedKey.
|
|
226
|
-
* Use this method when you need to:
|
|
227
|
-
* - Implement manual dinosaur list pagination
|
|
228
|
-
* - Resume habitat inspection reviews
|
|
229
|
-
* - Continue security incident analysis
|
|
230
|
-
* - Store operation position between sessions
|
|
231
202
|
*
|
|
232
203
|
* Note: This method is typically used for manual pagination.
|
|
233
204
|
* For automatic pagination, use the paginate() method instead.
|
|
@@ -258,11 +229,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
258
229
|
startFrom(lastEvaluatedKey: DynamoItem): this;
|
|
259
230
|
/**
|
|
260
231
|
* Creates a deep clone of this builder instance.
|
|
261
|
-
* Use this method when you need to:
|
|
262
|
-
* - Query different dinosaur statuses
|
|
263
|
-
* - Check multiple habitat conditions
|
|
264
|
-
* - Monitor various security levels
|
|
265
|
-
* - Create report templates
|
|
266
232
|
*
|
|
267
233
|
* This is particularly useful when:
|
|
268
234
|
* - Implementing pagination (used internally by paginate())
|
|
@@ -40,10 +40,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
40
40
|
protected selectedFields: Set<string>;
|
|
41
41
|
/**
|
|
42
42
|
* Sets the maximum number of items to return.
|
|
43
|
-
* Use this method when you need to:
|
|
44
|
-
* - Limit the number of dinosaurs returned
|
|
45
|
-
* - Control the size of habitat reports
|
|
46
|
-
* - Implement manual pagination of security logs
|
|
47
43
|
*
|
|
48
44
|
* Note: This limit applies to the items that match the key condition
|
|
49
45
|
* before any filter expressions are applied.
|
|
@@ -69,11 +65,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
69
65
|
getLimit(): number | undefined;
|
|
70
66
|
/**
|
|
71
67
|
* Specifies a Global Secondary Index (GSI) to use for the operation.
|
|
72
|
-
* Use this method when you need to:
|
|
73
|
-
* - Find dinosaurs by species or status
|
|
74
|
-
* - Search habitats by security level
|
|
75
|
-
* - Find incidents by date
|
|
76
|
-
* - List feeding schedules by time
|
|
77
68
|
*
|
|
78
69
|
* @example
|
|
79
70
|
* ```typescript
|
|
@@ -99,11 +90,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
99
90
|
useIndex<I extends GSINames<TConfig>>(indexName: I): this;
|
|
100
91
|
/**
|
|
101
92
|
* Sets whether to use strongly consistent reads for the operation.
|
|
102
|
-
* Use this method when you need to:
|
|
103
|
-
* - Get real-time dinosaur status updates
|
|
104
|
-
* - Monitor critical security systems
|
|
105
|
-
* - Track immediate habitat changes
|
|
106
|
-
* - Verify containment protocols
|
|
107
93
|
*
|
|
108
94
|
* Note:
|
|
109
95
|
* - Consistent reads are not available on GSIs
|
|
@@ -131,11 +117,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
131
117
|
consistentRead(consistentRead?: boolean): this;
|
|
132
118
|
/**
|
|
133
119
|
* Adds a filter expression to refine the operation results.
|
|
134
|
-
* Use this method when you need to:
|
|
135
|
-
* - Filter dinosaurs by behavior patterns
|
|
136
|
-
* - Find habitats with specific conditions
|
|
137
|
-
* - Search for security incidents
|
|
138
|
-
* - Monitor feeding patterns
|
|
139
120
|
*
|
|
140
121
|
* @example
|
|
141
122
|
* ```typescript
|
|
@@ -164,11 +145,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
164
145
|
filter(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
165
146
|
/**
|
|
166
147
|
* Specifies which attributes to return in the results.
|
|
167
|
-
* Use this method when you need to:
|
|
168
|
-
* - Get specific dinosaur attributes
|
|
169
|
-
* - Retrieve habitat statistics
|
|
170
|
-
* - Monitor security metrics
|
|
171
|
-
* - Optimize response size
|
|
172
148
|
*
|
|
173
149
|
* @example
|
|
174
150
|
* ```typescript
|
|
@@ -223,11 +199,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
223
199
|
paginate(pageSize: number): Paginator<T, TConfig>;
|
|
224
200
|
/**
|
|
225
201
|
* Sets the starting point using a previous lastEvaluatedKey.
|
|
226
|
-
* Use this method when you need to:
|
|
227
|
-
* - Implement manual dinosaur list pagination
|
|
228
|
-
* - Resume habitat inspection reviews
|
|
229
|
-
* - Continue security incident analysis
|
|
230
|
-
* - Store operation position between sessions
|
|
231
202
|
*
|
|
232
203
|
* Note: This method is typically used for manual pagination.
|
|
233
204
|
* For automatic pagination, use the paginate() method instead.
|
|
@@ -258,11 +229,6 @@ declare abstract class FilterBuilder<T extends DynamoItem, TConfig extends Table
|
|
|
258
229
|
startFrom(lastEvaluatedKey: DynamoItem): this;
|
|
259
230
|
/**
|
|
260
231
|
* Creates a deep clone of this builder instance.
|
|
261
|
-
* Use this method when you need to:
|
|
262
|
-
* - Query different dinosaur statuses
|
|
263
|
-
* - Check multiple habitat conditions
|
|
264
|
-
* - Monitor various security levels
|
|
265
|
-
* - Create report templates
|
|
266
232
|
*
|
|
267
233
|
* This is particularly useful when:
|
|
268
234
|
* - Implementing pagination (used internally by paginate())
|
|
@@ -1,153 +1,14 @@
|
|
|
1
1
|
import { DynamoItem, TableConfig, Index } from './types.js';
|
|
2
2
|
import { r as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-BtynAviC.js';
|
|
3
|
-
import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-
|
|
3
|
+
import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-C6XjVEFH.js';
|
|
4
4
|
import { PutBuilder } from './builders/put-builder.js';
|
|
5
5
|
import { DeleteBuilder } from './builders/delete-builder.js';
|
|
6
6
|
import { UpdateBuilder } from './builders/update-builder.js';
|
|
7
7
|
import { TransactionBuilder, TransactionOptions } from './builders/transaction-builder.js';
|
|
8
|
+
import { G as GetBuilder, B as BatchBuilder, c as BatchWriteOperation } from './batch-builder-Dz1yPGrJ.js';
|
|
8
9
|
import { ConditionCheckBuilder } from './builders/condition-check-builder.js';
|
|
9
10
|
import { S as ScanBuilderInterface } from './builder-types-B_tCpn9F.js';
|
|
10
11
|
|
|
11
|
-
type BatchWriteOperation<T extends Record<string, unknown>> = {
|
|
12
|
-
type: "put";
|
|
13
|
-
item: T;
|
|
14
|
-
} | {
|
|
15
|
-
type: "delete";
|
|
16
|
-
key: PrimaryKeyWithoutExpression;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Parameters for the DynamoDB get command.
|
|
21
|
-
*/
|
|
22
|
-
interface GetCommandParams {
|
|
23
|
-
/** The name of the DynamoDB table */
|
|
24
|
-
tableName: string;
|
|
25
|
-
/** The primary key of the item to get */
|
|
26
|
-
key: PrimaryKeyWithoutExpression;
|
|
27
|
-
/** Comma-separated list of attributes to return */
|
|
28
|
-
projectionExpression?: string;
|
|
29
|
-
/** Map of expression attribute name placeholders to actual names */
|
|
30
|
-
expressionAttributeNames?: Record<string, string>;
|
|
31
|
-
/** Whether to use strongly consistent reads */
|
|
32
|
-
consistentRead?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Function type for executing DynamoDB get operations.
|
|
36
|
-
* @typeParam T - The type of item being retrieved
|
|
37
|
-
*/
|
|
38
|
-
type GetExecutor<T extends DynamoItem> = (params: GetCommandParams) => Promise<{
|
|
39
|
-
item: T | undefined;
|
|
40
|
-
}>;
|
|
41
|
-
/**
|
|
42
|
-
* Builder for creating DynamoDB get operations.
|
|
43
|
-
* Use this builder when you need to:
|
|
44
|
-
* - Retrieve a single dinosaur by its primary key
|
|
45
|
-
* - Project specific dinosaur attributes
|
|
46
|
-
* - Use consistent reads for critical dinosaur data
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* // Simple get
|
|
51
|
-
* const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
|
|
52
|
-
* .execute();
|
|
53
|
-
*
|
|
54
|
-
* // Get with projection and consistent read
|
|
55
|
-
* const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
|
|
56
|
-
* .select(['species', 'name', 'diet'])
|
|
57
|
-
* .consistentRead()
|
|
58
|
-
* .execute();
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* @typeParam T - The type of item being retrieved
|
|
62
|
-
*/
|
|
63
|
-
declare class GetBuilder<T extends DynamoItem> {
|
|
64
|
-
private readonly executor;
|
|
65
|
-
private readonly params;
|
|
66
|
-
private options;
|
|
67
|
-
private selectedFields;
|
|
68
|
-
/**
|
|
69
|
-
* Creates a new GetBuilder instance.
|
|
70
|
-
*
|
|
71
|
-
* @param executor - Function that executes the get operation
|
|
72
|
-
* @param key - Primary key of the item to retrieve
|
|
73
|
-
* @param tableName - Name of the DynamoDB table
|
|
74
|
-
*/
|
|
75
|
-
constructor(executor: GetExecutor<T>, key: PrimaryKeyWithoutExpression, tableName: string);
|
|
76
|
-
/**
|
|
77
|
-
* Specifies which attributes to return in the get results.
|
|
78
|
-
* Use this method when you need to:
|
|
79
|
-
* - Reduce data transfer by selecting specific dinosaur attributes
|
|
80
|
-
* - Optimize response size for dinosaur records
|
|
81
|
-
* - Focus on relevant dinosaur characteristics only
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```typescript
|
|
85
|
-
* // Select single attribute
|
|
86
|
-
* builder.select('species')
|
|
87
|
-
*
|
|
88
|
-
* // Select multiple attributes
|
|
89
|
-
* builder.select(['id', 'species', 'diet'])
|
|
90
|
-
*
|
|
91
|
-
* // Chain multiple select calls
|
|
92
|
-
* builder
|
|
93
|
-
* .select('id')
|
|
94
|
-
* .select(['species', 'diet'])
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* @param fields - A single field name or an array of field names to return
|
|
98
|
-
* @returns The builder instance for method chaining
|
|
99
|
-
*/
|
|
100
|
-
select(fields: string | string[]): GetBuilder<T>;
|
|
101
|
-
/**
|
|
102
|
-
* Sets whether to use strongly consistent reads for the get operation.
|
|
103
|
-
* Use this method when you need:
|
|
104
|
-
* - The most up-to-date dinosaur data
|
|
105
|
-
* - To ensure you're reading the latest dinosaur status
|
|
106
|
-
* - Critical safety information about dangerous species
|
|
107
|
-
*
|
|
108
|
-
* Note: Consistent reads consume twice the throughput
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* // Get the latest T-Rex data
|
|
113
|
-
* const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
|
|
114
|
-
* .consistentRead()
|
|
115
|
-
* .execute();
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* @param consistentRead - Whether to use consistent reads (defaults to true)
|
|
119
|
-
* @returns The builder instance for method chaining
|
|
120
|
-
*/
|
|
121
|
-
consistentRead(consistentRead?: boolean): GetBuilder<T>;
|
|
122
|
-
/**
|
|
123
|
-
* Executes the get operation against DynamoDB.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* try {
|
|
128
|
-
* const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
|
|
129
|
-
* .select(['species', 'name', 'diet'])
|
|
130
|
-
* .consistentRead()
|
|
131
|
-
* .execute();
|
|
132
|
-
*
|
|
133
|
-
* if (result.item) {
|
|
134
|
-
* console.log('Dinosaur found:', result.item);
|
|
135
|
-
* } else {
|
|
136
|
-
* console.log('Dinosaur not found');
|
|
137
|
-
* }
|
|
138
|
-
* } catch (error) {
|
|
139
|
-
* console.error('Error getting dinosaur:', error);
|
|
140
|
-
* }
|
|
141
|
-
* ```
|
|
142
|
-
*
|
|
143
|
-
* @returns A promise that resolves to an object containing:
|
|
144
|
-
* - item: The retrieved dinosaur or undefined if not found
|
|
145
|
-
*/
|
|
146
|
-
execute(): Promise<{
|
|
147
|
-
item: T | undefined;
|
|
148
|
-
}>;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
12
|
/**
|
|
152
13
|
* Configuration options for DynamoDB scan operations.
|
|
153
14
|
* Extends the base FilterOptions.
|
|
@@ -211,21 +72,12 @@ declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = Ta
|
|
|
211
72
|
constructor(executor: ScanExecutor<T>);
|
|
212
73
|
/**
|
|
213
74
|
* Creates a deep clone of this ScanBuilder instance.
|
|
214
|
-
* Use this method when you need to:
|
|
215
|
-
* - Create scan templates
|
|
216
|
-
* - Run multiple variations of a scan
|
|
217
|
-
* - Implement pagination (used internally by paginate())
|
|
218
75
|
*
|
|
219
76
|
* @returns A new ScanBuilder instance with the same configuration
|
|
220
77
|
*/
|
|
221
78
|
clone(): ScanBuilder<T, TConfig>;
|
|
222
79
|
/**
|
|
223
80
|
* Executes the scan against DynamoDB.
|
|
224
|
-
* Use this method when you need to:
|
|
225
|
-
* - Search across the entire table
|
|
226
|
-
* - Find items matching specific criteria
|
|
227
|
-
* - Perform full table analysis
|
|
228
|
-
* - Generate reports across all data
|
|
229
81
|
*
|
|
230
82
|
* The method returns both the matched items and, if there are more results,
|
|
231
83
|
* a lastEvaluatedKey that can be used with startFrom() to continue the scan.
|
|
@@ -348,6 +200,42 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
|
|
|
348
200
|
* Creates a transaction builder for performing multiple operations atomically
|
|
349
201
|
*/
|
|
350
202
|
transactionBuilder(): TransactionBuilder;
|
|
203
|
+
/**
|
|
204
|
+
* Creates a batch builder for performing multiple operations efficiently with optional type inference
|
|
205
|
+
*
|
|
206
|
+
* @example Basic Usage
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const batch = table.batchBuilder();
|
|
209
|
+
*
|
|
210
|
+
* // Add operations
|
|
211
|
+
* userRepo.create(newUser).withBatch(batch);
|
|
212
|
+
* orderRepo.get({ id: 'order-1' }).withBatch(batch);
|
|
213
|
+
*
|
|
214
|
+
* // Execute operations
|
|
215
|
+
* const result = await batch.execute();
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @example Typed Usage
|
|
219
|
+
* ```typescript
|
|
220
|
+
* // Define entity types for the batch
|
|
221
|
+
* const batch = table.batchBuilder<{
|
|
222
|
+
* User: UserEntity;
|
|
223
|
+
* Order: OrderEntity;
|
|
224
|
+
* Product: ProductEntity;
|
|
225
|
+
* }>();
|
|
226
|
+
*
|
|
227
|
+
* // Add operations with type information
|
|
228
|
+
* userRepo.create(newUser).withBatch(batch, 'User');
|
|
229
|
+
* orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
|
|
230
|
+
* productRepo.delete({ id: 'old-product' }).withBatch(batch, 'Product');
|
|
231
|
+
*
|
|
232
|
+
* // Execute and get typed results
|
|
233
|
+
* const result = await batch.execute();
|
|
234
|
+
* const users: UserEntity[] = result.reads.itemsByType.User;
|
|
235
|
+
* const orders: OrderEntity[] = result.reads.itemsByType.Order;
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
batchBuilder<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>>(): BatchBuilder<TEntities>;
|
|
351
239
|
/**
|
|
352
240
|
* Executes a transaction using a callback function
|
|
353
241
|
*
|
|
@@ -386,4 +274,4 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
|
|
|
386
274
|
}>;
|
|
387
275
|
}
|
|
388
276
|
|
|
389
|
-
export {
|
|
277
|
+
export { ScanBuilder as S, Table as T };
|
|
@@ -1,153 +1,14 @@
|
|
|
1
1
|
import { DynamoItem, TableConfig, Index } from './types.cjs';
|
|
2
2
|
import { r as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-3ae5znV_.cjs';
|
|
3
|
-
import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-
|
|
3
|
+
import { F as FilterBuilder, b as FilterOptions, Q as QueryBuilder } from './query-builder-BDuHHrb-.cjs';
|
|
4
4
|
import { PutBuilder } from './builders/put-builder.cjs';
|
|
5
5
|
import { DeleteBuilder } from './builders/delete-builder.cjs';
|
|
6
6
|
import { UpdateBuilder } from './builders/update-builder.cjs';
|
|
7
7
|
import { TransactionBuilder, TransactionOptions } from './builders/transaction-builder.cjs';
|
|
8
|
+
import { G as GetBuilder, B as BatchBuilder, c as BatchWriteOperation } from './batch-builder-DNsz6zvh.cjs';
|
|
8
9
|
import { ConditionCheckBuilder } from './builders/condition-check-builder.cjs';
|
|
9
10
|
import { S as ScanBuilderInterface } from './builder-types-DlaUSc-b.cjs';
|
|
10
11
|
|
|
11
|
-
type BatchWriteOperation<T extends Record<string, unknown>> = {
|
|
12
|
-
type: "put";
|
|
13
|
-
item: T;
|
|
14
|
-
} | {
|
|
15
|
-
type: "delete";
|
|
16
|
-
key: PrimaryKeyWithoutExpression;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Parameters for the DynamoDB get command.
|
|
21
|
-
*/
|
|
22
|
-
interface GetCommandParams {
|
|
23
|
-
/** The name of the DynamoDB table */
|
|
24
|
-
tableName: string;
|
|
25
|
-
/** The primary key of the item to get */
|
|
26
|
-
key: PrimaryKeyWithoutExpression;
|
|
27
|
-
/** Comma-separated list of attributes to return */
|
|
28
|
-
projectionExpression?: string;
|
|
29
|
-
/** Map of expression attribute name placeholders to actual names */
|
|
30
|
-
expressionAttributeNames?: Record<string, string>;
|
|
31
|
-
/** Whether to use strongly consistent reads */
|
|
32
|
-
consistentRead?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Function type for executing DynamoDB get operations.
|
|
36
|
-
* @typeParam T - The type of item being retrieved
|
|
37
|
-
*/
|
|
38
|
-
type GetExecutor<T extends DynamoItem> = (params: GetCommandParams) => Promise<{
|
|
39
|
-
item: T | undefined;
|
|
40
|
-
}>;
|
|
41
|
-
/**
|
|
42
|
-
* Builder for creating DynamoDB get operations.
|
|
43
|
-
* Use this builder when you need to:
|
|
44
|
-
* - Retrieve a single dinosaur by its primary key
|
|
45
|
-
* - Project specific dinosaur attributes
|
|
46
|
-
* - Use consistent reads for critical dinosaur data
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* // Simple get
|
|
51
|
-
* const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
|
|
52
|
-
* .execute();
|
|
53
|
-
*
|
|
54
|
-
* // Get with projection and consistent read
|
|
55
|
-
* const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
|
|
56
|
-
* .select(['species', 'name', 'diet'])
|
|
57
|
-
* .consistentRead()
|
|
58
|
-
* .execute();
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* @typeParam T - The type of item being retrieved
|
|
62
|
-
*/
|
|
63
|
-
declare class GetBuilder<T extends DynamoItem> {
|
|
64
|
-
private readonly executor;
|
|
65
|
-
private readonly params;
|
|
66
|
-
private options;
|
|
67
|
-
private selectedFields;
|
|
68
|
-
/**
|
|
69
|
-
* Creates a new GetBuilder instance.
|
|
70
|
-
*
|
|
71
|
-
* @param executor - Function that executes the get operation
|
|
72
|
-
* @param key - Primary key of the item to retrieve
|
|
73
|
-
* @param tableName - Name of the DynamoDB table
|
|
74
|
-
*/
|
|
75
|
-
constructor(executor: GetExecutor<T>, key: PrimaryKeyWithoutExpression, tableName: string);
|
|
76
|
-
/**
|
|
77
|
-
* Specifies which attributes to return in the get results.
|
|
78
|
-
* Use this method when you need to:
|
|
79
|
-
* - Reduce data transfer by selecting specific dinosaur attributes
|
|
80
|
-
* - Optimize response size for dinosaur records
|
|
81
|
-
* - Focus on relevant dinosaur characteristics only
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```typescript
|
|
85
|
-
* // Select single attribute
|
|
86
|
-
* builder.select('species')
|
|
87
|
-
*
|
|
88
|
-
* // Select multiple attributes
|
|
89
|
-
* builder.select(['id', 'species', 'diet'])
|
|
90
|
-
*
|
|
91
|
-
* // Chain multiple select calls
|
|
92
|
-
* builder
|
|
93
|
-
* .select('id')
|
|
94
|
-
* .select(['species', 'diet'])
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* @param fields - A single field name or an array of field names to return
|
|
98
|
-
* @returns The builder instance for method chaining
|
|
99
|
-
*/
|
|
100
|
-
select(fields: string | string[]): GetBuilder<T>;
|
|
101
|
-
/**
|
|
102
|
-
* Sets whether to use strongly consistent reads for the get operation.
|
|
103
|
-
* Use this method when you need:
|
|
104
|
-
* - The most up-to-date dinosaur data
|
|
105
|
-
* - To ensure you're reading the latest dinosaur status
|
|
106
|
-
* - Critical safety information about dangerous species
|
|
107
|
-
*
|
|
108
|
-
* Note: Consistent reads consume twice the throughput
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* // Get the latest T-Rex data
|
|
113
|
-
* const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
|
|
114
|
-
* .consistentRead()
|
|
115
|
-
* .execute();
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* @param consistentRead - Whether to use consistent reads (defaults to true)
|
|
119
|
-
* @returns The builder instance for method chaining
|
|
120
|
-
*/
|
|
121
|
-
consistentRead(consistentRead?: boolean): GetBuilder<T>;
|
|
122
|
-
/**
|
|
123
|
-
* Executes the get operation against DynamoDB.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* try {
|
|
128
|
-
* const result = await new GetBuilder(executor, { pk: 'dinosaur#123', sk: 'profile' })
|
|
129
|
-
* .select(['species', 'name', 'diet'])
|
|
130
|
-
* .consistentRead()
|
|
131
|
-
* .execute();
|
|
132
|
-
*
|
|
133
|
-
* if (result.item) {
|
|
134
|
-
* console.log('Dinosaur found:', result.item);
|
|
135
|
-
* } else {
|
|
136
|
-
* console.log('Dinosaur not found');
|
|
137
|
-
* }
|
|
138
|
-
* } catch (error) {
|
|
139
|
-
* console.error('Error getting dinosaur:', error);
|
|
140
|
-
* }
|
|
141
|
-
* ```
|
|
142
|
-
*
|
|
143
|
-
* @returns A promise that resolves to an object containing:
|
|
144
|
-
* - item: The retrieved dinosaur or undefined if not found
|
|
145
|
-
*/
|
|
146
|
-
execute(): Promise<{
|
|
147
|
-
item: T | undefined;
|
|
148
|
-
}>;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
12
|
/**
|
|
152
13
|
* Configuration options for DynamoDB scan operations.
|
|
153
14
|
* Extends the base FilterOptions.
|
|
@@ -211,21 +72,12 @@ declare class ScanBuilder<T extends DynamoItem, TConfig extends TableConfig = Ta
|
|
|
211
72
|
constructor(executor: ScanExecutor<T>);
|
|
212
73
|
/**
|
|
213
74
|
* Creates a deep clone of this ScanBuilder instance.
|
|
214
|
-
* Use this method when you need to:
|
|
215
|
-
* - Create scan templates
|
|
216
|
-
* - Run multiple variations of a scan
|
|
217
|
-
* - Implement pagination (used internally by paginate())
|
|
218
75
|
*
|
|
219
76
|
* @returns A new ScanBuilder instance with the same configuration
|
|
220
77
|
*/
|
|
221
78
|
clone(): ScanBuilder<T, TConfig>;
|
|
222
79
|
/**
|
|
223
80
|
* Executes the scan against DynamoDB.
|
|
224
|
-
* Use this method when you need to:
|
|
225
|
-
* - Search across the entire table
|
|
226
|
-
* - Find items matching specific criteria
|
|
227
|
-
* - Perform full table analysis
|
|
228
|
-
* - Generate reports across all data
|
|
229
81
|
*
|
|
230
82
|
* The method returns both the matched items and, if there are more results,
|
|
231
83
|
* a lastEvaluatedKey that can be used with startFrom() to continue the scan.
|
|
@@ -348,6 +200,42 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
|
|
|
348
200
|
* Creates a transaction builder for performing multiple operations atomically
|
|
349
201
|
*/
|
|
350
202
|
transactionBuilder(): TransactionBuilder;
|
|
203
|
+
/**
|
|
204
|
+
* Creates a batch builder for performing multiple operations efficiently with optional type inference
|
|
205
|
+
*
|
|
206
|
+
* @example Basic Usage
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const batch = table.batchBuilder();
|
|
209
|
+
*
|
|
210
|
+
* // Add operations
|
|
211
|
+
* userRepo.create(newUser).withBatch(batch);
|
|
212
|
+
* orderRepo.get({ id: 'order-1' }).withBatch(batch);
|
|
213
|
+
*
|
|
214
|
+
* // Execute operations
|
|
215
|
+
* const result = await batch.execute();
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @example Typed Usage
|
|
219
|
+
* ```typescript
|
|
220
|
+
* // Define entity types for the batch
|
|
221
|
+
* const batch = table.batchBuilder<{
|
|
222
|
+
* User: UserEntity;
|
|
223
|
+
* Order: OrderEntity;
|
|
224
|
+
* Product: ProductEntity;
|
|
225
|
+
* }>();
|
|
226
|
+
*
|
|
227
|
+
* // Add operations with type information
|
|
228
|
+
* userRepo.create(newUser).withBatch(batch, 'User');
|
|
229
|
+
* orderRepo.get({ id: 'order-1' }).withBatch(batch, 'Order');
|
|
230
|
+
* productRepo.delete({ id: 'old-product' }).withBatch(batch, 'Product');
|
|
231
|
+
*
|
|
232
|
+
* // Execute and get typed results
|
|
233
|
+
* const result = await batch.execute();
|
|
234
|
+
* const users: UserEntity[] = result.reads.itemsByType.User;
|
|
235
|
+
* const orders: OrderEntity[] = result.reads.itemsByType.Order;
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
batchBuilder<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>>(): BatchBuilder<TEntities>;
|
|
351
239
|
/**
|
|
352
240
|
* Executes a transaction using a callback function
|
|
353
241
|
*
|
|
@@ -386,4 +274,4 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
|
|
|
386
274
|
}>;
|
|
387
275
|
}
|
|
388
276
|
|
|
389
|
-
export {
|
|
277
|
+
export { ScanBuilder as S, Table as T };
|