dyno-table 2.3.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,564 @@
1
+ 'use strict';
2
+
3
+ // src/errors.ts
4
+ var DynoTableError = class extends Error {
5
+ /**
6
+ * Machine-readable error code for programmatic error handling
7
+ * @example "KEY_GENERATION_FAILED", "VALIDATION_ERROR", etc.
8
+ */
9
+ code;
10
+ /**
11
+ * Additional context about the error
12
+ * Contains operation-specific details like entity names, table names,
13
+ * expressions, conditions, and other relevant debugging information
14
+ */
15
+ context;
16
+ /**
17
+ * The original error that caused this error (if wrapping another error)
18
+ * Useful for preserving AWS SDK errors or other underlying errors
19
+ */
20
+ cause;
21
+ constructor(message, code, context = {}, cause) {
22
+ super(message);
23
+ this.name = "DynoTableError";
24
+ this.code = code;
25
+ this.context = context;
26
+ this.cause = cause;
27
+ if (Error.captureStackTrace) {
28
+ Error.captureStackTrace(this, this.constructor);
29
+ }
30
+ }
31
+ };
32
+ var ValidationError = class extends DynoTableError {
33
+ constructor(message, code, context = {}, cause) {
34
+ super(message, code, context, cause);
35
+ this.name = "ValidationError";
36
+ }
37
+ };
38
+ var OperationError = class extends DynoTableError {
39
+ constructor(message, code, context = {}, cause) {
40
+ super(message, code, context, cause);
41
+ this.name = "OperationError";
42
+ }
43
+ };
44
+ var TransactionError = class extends DynoTableError {
45
+ constructor(message, code, context = {}, cause) {
46
+ super(message, code, context, cause);
47
+ this.name = "TransactionError";
48
+ }
49
+ };
50
+ var BatchError = class extends DynoTableError {
51
+ /**
52
+ * The type of batch operation that failed
53
+ */
54
+ operation;
55
+ /**
56
+ * The items that were not processed during the batch operation
57
+ */
58
+ unprocessedItems;
59
+ constructor(message, code, operation, unprocessedItems = [], context = {}, cause) {
60
+ super(message, code, context, cause);
61
+ this.name = "BatchError";
62
+ this.operation = operation;
63
+ this.unprocessedItems = unprocessedItems;
64
+ }
65
+ };
66
+ var ExpressionError = class extends DynoTableError {
67
+ constructor(message, code, context = {}, cause) {
68
+ super(message, code, context, cause);
69
+ this.name = "ExpressionError";
70
+ }
71
+ };
72
+ var ConfigurationError = class extends DynoTableError {
73
+ constructor(message, code, context = {}, cause) {
74
+ super(message, code, context, cause);
75
+ this.name = "ConfigurationError";
76
+ }
77
+ };
78
+ var EntityError = class extends DynoTableError {
79
+ constructor(message, code, context = {}, cause) {
80
+ super(message, code, context, cause);
81
+ this.name = "EntityError";
82
+ }
83
+ };
84
+ var KeyGenerationError = class extends EntityError {
85
+ constructor(message, code, context = {}, cause) {
86
+ super(message, code, context, cause);
87
+ this.name = "KeyGenerationError";
88
+ }
89
+ };
90
+ var IndexGenerationError = class extends EntityError {
91
+ constructor(message, code, context = {}, cause) {
92
+ super(message, code, context, cause);
93
+ this.name = "IndexGenerationError";
94
+ }
95
+ };
96
+ var EntityValidationError = class extends ValidationError {
97
+ constructor(message, code, context = {}, cause) {
98
+ super(message, code, context, cause);
99
+ this.name = "EntityValidationError";
100
+ }
101
+ };
102
+ var ErrorCodes = {
103
+ // Key Generation Errors
104
+ KEY_GENERATION_FAILED: "KEY_GENERATION_FAILED",
105
+ KEY_MISSING_ATTRIBUTES: "KEY_MISSING_ATTRIBUTES",
106
+ KEY_INVALID_FORMAT: "KEY_INVALID_FORMAT",
107
+ // Index Errors
108
+ INDEX_GENERATION_FAILED: "INDEX_GENERATION_FAILED",
109
+ INDEX_MISSING_ATTRIBUTES: "INDEX_MISSING_ATTRIBUTES",
110
+ INDEX_NOT_FOUND: "INDEX_NOT_FOUND",
111
+ INDEX_READONLY_UPDATE_FAILED: "INDEX_READONLY_UPDATE_FAILED",
112
+ INDEX_UNDEFINED_VALUES: "INDEX_UNDEFINED_VALUES",
113
+ // Validation Errors
114
+ ENTITY_VALIDATION_FAILED: "ENTITY_VALIDATION_FAILED",
115
+ ASYNC_VALIDATION_NOT_SUPPORTED: "ASYNC_VALIDATION_NOT_SUPPORTED",
116
+ QUERY_INPUT_VALIDATION_FAILED: "QUERY_INPUT_VALIDATION_FAILED",
117
+ VALIDATION_ERROR: "VALIDATION_ERROR",
118
+ VALIDATION_FAILED: "VALIDATION_FAILED",
119
+ SCHEMA_VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED",
120
+ INVALID_PARAMETER: "INVALID_PARAMETER",
121
+ MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD",
122
+ UNDEFINED_VALUE: "UNDEFINED_VALUE",
123
+ // Expression Errors
124
+ EXPRESSION_MISSING_ATTRIBUTE: "EXPRESSION_MISSING_ATTRIBUTE",
125
+ EXPRESSION_MISSING_VALUE: "EXPRESSION_MISSING_VALUE",
126
+ EXPRESSION_INVALID_CONDITION: "EXPRESSION_INVALID_CONDITION",
127
+ EXPRESSION_EMPTY_ARRAY: "EXPRESSION_EMPTY_ARRAY",
128
+ EXPRESSION_UNKNOWN_TYPE: "EXPRESSION_UNKNOWN_TYPE",
129
+ EXPRESSION_INVALID: "EXPRESSION_INVALID",
130
+ EXPRESSION_INVALID_OPERATOR: "EXPRESSION_INVALID_OPERATOR",
131
+ // Operation Errors
132
+ QUERY_FAILED: "QUERY_FAILED",
133
+ SCAN_FAILED: "SCAN_FAILED",
134
+ GET_FAILED: "GET_FAILED",
135
+ PUT_FAILED: "PUT_FAILED",
136
+ DELETE_FAILED: "DELETE_FAILED",
137
+ UPDATE_FAILED: "UPDATE_FAILED",
138
+ BATCH_GET_FAILED: "BATCH_GET_FAILED",
139
+ BATCH_WRITE_FAILED: "BATCH_WRITE_FAILED",
140
+ NO_UPDATE_ACTIONS: "NO_UPDATE_ACTIONS",
141
+ CONDITIONAL_CHECK_FAILED: "CONDITIONAL_CHECK_FAILED",
142
+ // Transaction Errors
143
+ TRANSACTION_FAILED: "TRANSACTION_FAILED",
144
+ TRANSACTION_DUPLICATE_ITEM: "TRANSACTION_DUPLICATE_ITEM",
145
+ TRANSACTION_EMPTY: "TRANSACTION_EMPTY",
146
+ TRANSACTION_UNSUPPORTED_TYPE: "TRANSACTION_UNSUPPORTED_TYPE",
147
+ TRANSACTION_ITEM_LIMIT: "TRANSACTION_ITEM_LIMIT",
148
+ TRANSACTION_CANCELLED: "TRANSACTION_CANCELLED",
149
+ // Batch Errors
150
+ BATCH_EMPTY: "BATCH_EMPTY",
151
+ BATCH_UNSUPPORTED_TYPE: "BATCH_UNSUPPORTED_TYPE",
152
+ BATCH_UNPROCESSED_ITEMS: "BATCH_UNPROCESSED_ITEMS",
153
+ BATCH_SIZE_EXCEEDED: "BATCH_SIZE_EXCEEDED",
154
+ // Configuration Errors
155
+ GSI_NOT_FOUND: "GSI_NOT_FOUND",
156
+ SORT_KEY_REQUIRED: "SORT_KEY_REQUIRED",
157
+ SORT_KEY_NOT_DEFINED: "SORT_KEY_NOT_DEFINED",
158
+ PRIMARY_KEY_MISSING: "PRIMARY_KEY_MISSING",
159
+ INVALID_CHUNK_SIZE: "INVALID_CHUNK_SIZE",
160
+ CONDITION_REQUIRED: "CONDITION_REQUIRED",
161
+ CONDITION_GENERATION_FAILED: "CONDITION_GENERATION_FAILED",
162
+ PK_EXTRACTION_FAILED: "PK_EXTRACTION_FAILED",
163
+ CONFIGURATION_INVALID: "CONFIGURATION_INVALID",
164
+ CONFIGURATION_MISSING_SORT_KEY: "CONFIGURATION_MISSING_SORT_KEY",
165
+ CONFIGURATION_INVALID_GSI: "CONFIGURATION_INVALID_GSI"
166
+ };
167
+
168
+ // src/utils/error-factory.ts
169
+ var ExpressionErrors = {
170
+ missingAttribute: (conditionType, condition) => new ExpressionError(
171
+ `Attribute is required for ${conditionType} condition`,
172
+ ErrorCodes.EXPRESSION_MISSING_ATTRIBUTE,
173
+ {
174
+ conditionType,
175
+ condition,
176
+ suggestion: "Ensure the condition includes an attribute name"
177
+ }
178
+ ),
179
+ missingValue: (conditionType, condition) => new ExpressionError(`Value is required for ${conditionType} condition`, ErrorCodes.EXPRESSION_MISSING_VALUE, {
180
+ conditionType,
181
+ condition,
182
+ suggestion: "Provide a value for the condition"
183
+ }),
184
+ invalidCondition: (conditionType, condition, suggestion) => new ExpressionError(`Invalid condition for ${conditionType}`, ErrorCodes.EXPRESSION_INVALID_CONDITION, {
185
+ conditionType,
186
+ condition,
187
+ suggestion: suggestion || "Check that the condition is properly formed"
188
+ }),
189
+ emptyArray: (conditionType, providedValue) => new ExpressionError(
190
+ `${conditionType} condition requires a non-empty array of values`,
191
+ ErrorCodes.EXPRESSION_EMPTY_ARRAY,
192
+ {
193
+ conditionType,
194
+ providedValue,
195
+ suggestion: "Provide at least one value in the array"
196
+ }
197
+ ),
198
+ unknownType: (conditionType, condition) => new ExpressionError(`Unknown condition type: ${conditionType}`, ErrorCodes.EXPRESSION_UNKNOWN_TYPE, {
199
+ conditionType,
200
+ condition,
201
+ suggestion: "Use a supported condition type from the query builder"
202
+ })
203
+ };
204
+ var ValidationErrors = {
205
+ indexSchemaValidationFailed: (validationIssues, keyType) => {
206
+ const keyLabel = keyType === "partition" ? "partition key" : keyType === "sort" ? "sort key" : "partition/sort key";
207
+ return new ValidationError(
208
+ `Index validation failed while generating ${keyLabel}: missing required attribute(s) or invalid values.`,
209
+ ErrorCodes.SCHEMA_VALIDATION_FAILED,
210
+ {
211
+ keyType,
212
+ validationIssues,
213
+ suggestion: `Provide the required attributes to construct the index ${keyLabel}`
214
+ }
215
+ );
216
+ },
217
+ noUpdateActions: (tableName, key) => new ValidationError("No update actions specified", ErrorCodes.NO_UPDATE_ACTIONS, {
218
+ tableName,
219
+ key,
220
+ suggestion: "Use set(), remove(), add(), or delete() to specify update actions"
221
+ }),
222
+ conditionRequired: (tableName, key) => new ValidationError("Condition is required for condition check operations", ErrorCodes.CONDITION_REQUIRED, {
223
+ tableName,
224
+ key,
225
+ suggestion: "Use the condition() method to specify a condition"
226
+ }),
227
+ queryInputValidationFailed: (entityName, queryName, validationIssues, providedInput) => new ValidationError(
228
+ `Query input validation failed for "${queryName}" on entity "${entityName}"`,
229
+ ErrorCodes.QUERY_INPUT_VALIDATION_FAILED,
230
+ {
231
+ entityName,
232
+ queryName,
233
+ validationIssues,
234
+ providedInput,
235
+ suggestion: "Ensure the query input matches the expected schema"
236
+ }
237
+ ),
238
+ undefinedValue: (path, tableName, key) => new ValidationError(`Cannot set undefined value for attribute "${path}"`, ErrorCodes.UNDEFINED_VALUE, {
239
+ path,
240
+ tableName,
241
+ key,
242
+ suggestion: "DynamoDB does not support undefined values. Use remove() to delete an attribute, or provide a valid value (null, string, number, etc.)"
243
+ })
244
+ };
245
+ var ConfigurationErrors = {
246
+ invalidChunkSize: (size) => new ConfigurationError("Chunk size must be greater than 0", ErrorCodes.INVALID_CHUNK_SIZE, {
247
+ size,
248
+ suggestion: "Provide a chunk size greater than 0"
249
+ }),
250
+ sortKeyRequired: (tableName, partitionKey, sortKey) => new ConfigurationError("Sort key is required for this operation", ErrorCodes.SORT_KEY_REQUIRED, {
251
+ tableName,
252
+ partitionKey,
253
+ sortKey,
254
+ suggestion: "Provide a sort key value or use a table with only a partition key"
255
+ }),
256
+ sortKeyNotDefined: (tableName, partitionKey, indexName) => new ConfigurationError("Sort key is not defined for this table/index", ErrorCodes.SORT_KEY_NOT_DEFINED, {
257
+ tableName,
258
+ partitionKey,
259
+ indexName,
260
+ suggestion: "This operation requires a table/index with a sort key defined"
261
+ }),
262
+ gsiNotFound: (indexName, tableName, availableIndexes) => new ConfigurationError(`GSI "${indexName}" not found in table configuration`, ErrorCodes.GSI_NOT_FOUND, {
263
+ indexName,
264
+ tableName,
265
+ availableIndexes,
266
+ suggestion: `Use one of the available indexes: ${availableIndexes.join(", ")}`
267
+ }),
268
+ primaryKeyMissing: (tableName, partitionKeyName, providedItem) => new ConfigurationError(`Primary key value for '${partitionKeyName}' is missing`, ErrorCodes.PRIMARY_KEY_MISSING, {
269
+ tableName,
270
+ partitionKeyName,
271
+ providedItem,
272
+ suggestion: `Ensure the item includes a value for '${partitionKeyName}'`
273
+ }),
274
+ pkExtractionFailed: (tableName, indexName, item, cause) => new ConfigurationError(
275
+ `Failed to extract partition key from item for index "${indexName}"`,
276
+ ErrorCodes.PK_EXTRACTION_FAILED,
277
+ {
278
+ tableName,
279
+ indexName,
280
+ item,
281
+ suggestion: "Ensure the item has the required partition key attribute"
282
+ },
283
+ cause
284
+ ),
285
+ conditionGenerationFailed: (condition, suggestion) => new ExpressionError("Failed to generate condition expression", ErrorCodes.CONDITION_GENERATION_FAILED, {
286
+ condition,
287
+ suggestion: suggestion || "Check that the condition is properly formed"
288
+ })
289
+ };
290
+ var OperationErrors = {
291
+ queryFailed: (tableName, context, cause) => new OperationError(
292
+ `Query operation failed on table "${tableName}"`,
293
+ ErrorCodes.QUERY_FAILED,
294
+ {
295
+ tableName,
296
+ operation: "query",
297
+ ...context
298
+ },
299
+ cause
300
+ ),
301
+ scanFailed: (tableName, context, cause) => new OperationError(
302
+ `Scan operation failed on table "${tableName}"`,
303
+ ErrorCodes.SCAN_FAILED,
304
+ {
305
+ tableName,
306
+ operation: "scan",
307
+ ...context
308
+ },
309
+ cause
310
+ ),
311
+ getFailed: (tableName, key, cause) => new OperationError(
312
+ `Get operation failed on table "${tableName}"`,
313
+ ErrorCodes.GET_FAILED,
314
+ {
315
+ tableName,
316
+ operation: "get",
317
+ key
318
+ },
319
+ cause
320
+ ),
321
+ putFailed: (tableName, item, cause) => new OperationError(
322
+ `Put operation failed on table "${tableName}"`,
323
+ ErrorCodes.PUT_FAILED,
324
+ {
325
+ tableName,
326
+ operation: "put",
327
+ item
328
+ },
329
+ cause
330
+ ),
331
+ updateFailed: (tableName, key, cause) => new OperationError(
332
+ `Update operation failed on table "${tableName}"`,
333
+ ErrorCodes.UPDATE_FAILED,
334
+ {
335
+ tableName,
336
+ operation: "update",
337
+ key
338
+ },
339
+ cause
340
+ ),
341
+ deleteFailed: (tableName, key, cause) => new OperationError(
342
+ `Delete operation failed on table "${tableName}"`,
343
+ ErrorCodes.DELETE_FAILED,
344
+ {
345
+ tableName,
346
+ operation: "delete",
347
+ key
348
+ },
349
+ cause
350
+ ),
351
+ batchGetFailed: (tableName, context, cause) => new OperationError(
352
+ `Batch get operation failed on table "${tableName}"`,
353
+ ErrorCodes.BATCH_GET_FAILED,
354
+ {
355
+ tableName,
356
+ operation: "batchGet",
357
+ ...context
358
+ },
359
+ cause
360
+ ),
361
+ batchWriteFailed: (tableName, context, cause) => new OperationError(
362
+ `Batch write operation failed on table "${tableName}"`,
363
+ ErrorCodes.BATCH_WRITE_FAILED,
364
+ {
365
+ tableName,
366
+ operation: "batchWrite",
367
+ ...context
368
+ },
369
+ cause
370
+ )
371
+ };
372
+ var TransactionErrors = {
373
+ transactionFailed: (itemCount, context, cause) => new TransactionError(
374
+ `Transaction failed with ${itemCount} item(s)`,
375
+ ErrorCodes.TRANSACTION_FAILED,
376
+ {
377
+ itemCount,
378
+ ...context
379
+ },
380
+ cause
381
+ ),
382
+ duplicateItem: (tableName, partitionKey, sortKey) => new TransactionError("Duplicate item detected in transaction", ErrorCodes.TRANSACTION_DUPLICATE_ITEM, {
383
+ tableName,
384
+ partitionKey,
385
+ sortKey,
386
+ suggestion: "Each item in a transaction must be unique. Check for duplicate keys in your transaction items."
387
+ }),
388
+ transactionEmpty: () => new TransactionError("No transaction items specified", ErrorCodes.TRANSACTION_EMPTY, {
389
+ suggestion: "Add at least one operation using put(), delete(), update(), or conditionCheck()"
390
+ }),
391
+ unsupportedType: (item) => new TransactionError("Unsupported transaction item type", ErrorCodes.TRANSACTION_UNSUPPORTED_TYPE, {
392
+ item,
393
+ suggestion: "Transaction items must be created using put(), delete(), update(), or conditionCheck()"
394
+ })
395
+ };
396
+ var BatchErrors = {
397
+ batchEmpty: (operation) => new BatchError(`No items specified for batch ${operation} operation`, ErrorCodes.BATCH_EMPTY, operation, [], {
398
+ suggestion: operation === "write" ? "Use put() or delete() to add items to the batch" : "Use get() to add keys to the batch"
399
+ }),
400
+ unsupportedType: (operation, item) => new BatchError(`Unsupported batch ${operation} item type`, ErrorCodes.BATCH_UNSUPPORTED_TYPE, operation, [], {
401
+ item,
402
+ suggestion: operation === "write" ? "Batch items must be put or delete operations" : "Batch items must be get operations"
403
+ }),
404
+ batchWriteFailed: (unprocessedItems, context, cause) => new BatchError(
405
+ `Batch write failed with ${unprocessedItems.length} unprocessed item(s)`,
406
+ ErrorCodes.BATCH_WRITE_FAILED,
407
+ "write",
408
+ unprocessedItems,
409
+ context,
410
+ cause
411
+ ),
412
+ batchGetFailed: (unprocessedItems, context, cause) => new BatchError(
413
+ `Batch get failed with ${unprocessedItems.length} unprocessed item(s)`,
414
+ ErrorCodes.BATCH_GET_FAILED,
415
+ "read",
416
+ unprocessedItems,
417
+ context,
418
+ cause
419
+ )
420
+ };
421
+ var EntityErrors = {
422
+ validationFailed: (entityName, operation, validationIssues, providedData) => new EntityValidationError(
423
+ `Validation failed for entity "${entityName}" during ${operation} operation`,
424
+ ErrorCodes.ENTITY_VALIDATION_FAILED,
425
+ {
426
+ entityName,
427
+ operation,
428
+ validationIssues,
429
+ providedData,
430
+ suggestion: "Check that all required fields are provided and match the schema"
431
+ }
432
+ ),
433
+ queryInputValidationFailed: (entityName, queryName, validationIssues, providedInput) => new EntityValidationError(
434
+ `Query input validation failed for "${queryName}" on entity "${entityName}"`,
435
+ ErrorCodes.QUERY_INPUT_VALIDATION_FAILED,
436
+ {
437
+ entityName,
438
+ queryName,
439
+ validationIssues,
440
+ providedInput,
441
+ suggestion: "Ensure the query input matches the expected schema"
442
+ }
443
+ ),
444
+ asyncValidationNotSupported: (entityName, operation) => new EntityValidationError(
445
+ `Entity "${entityName}" uses async validation which is not supported in transactions/batches`,
446
+ ErrorCodes.ASYNC_VALIDATION_NOT_SUPPORTED,
447
+ {
448
+ entityName,
449
+ operation,
450
+ suggestion: "Use .execute() for async validation or switch to synchronous schema validation"
451
+ }
452
+ ),
453
+ keyGenerationFailed: (entityName, operation, providedData, requiredAttributes, cause) => new KeyGenerationError(
454
+ `Failed to generate primary key for entity "${entityName}"`,
455
+ ErrorCodes.KEY_GENERATION_FAILED,
456
+ {
457
+ entityName,
458
+ operation,
459
+ providedData,
460
+ requiredAttributes,
461
+ suggestion: requiredAttributes ? `Ensure these attributes are provided: ${requiredAttributes.join(", ")}` : "Check that all required attributes for key generation are provided"
462
+ },
463
+ cause
464
+ ),
465
+ keyInvalidFormat: (entityName, operation, providedData, generatedKey) => new KeyGenerationError(
466
+ `Primary key generation for entity "${entityName}" produced undefined/null partition key`,
467
+ ErrorCodes.KEY_INVALID_FORMAT,
468
+ {
469
+ entityName,
470
+ operation,
471
+ providedData,
472
+ generatedKey,
473
+ suggestion: "Ensure the key generation function returns valid pk (and sk if applicable) values"
474
+ }
475
+ ),
476
+ keyMissingAttributes: (entityName, operation, missingAttributes, providedData) => new KeyGenerationError(
477
+ `Missing required attributes for key generation in entity "${entityName}": ${missingAttributes.join(", ")}`,
478
+ ErrorCodes.KEY_MISSING_ATTRIBUTES,
479
+ {
480
+ entityName,
481
+ operation,
482
+ missingAttributes,
483
+ providedData,
484
+ suggestion: `Provide the following attributes: ${missingAttributes.join(", ")}`
485
+ }
486
+ )
487
+ };
488
+ var IndexErrors = {
489
+ generationFailed: (indexName, operation, providedItem, partitionKeyAttribute, sortKeyAttribute, cause) => new IndexGenerationError(
490
+ `Failed to generate key for index "${indexName}"`,
491
+ ErrorCodes.INDEX_GENERATION_FAILED,
492
+ {
493
+ indexName,
494
+ operation,
495
+ providedItem,
496
+ partitionKeyAttribute,
497
+ sortKeyAttribute,
498
+ suggestion: "Ensure all attributes required by the index are present in the item"
499
+ },
500
+ cause
501
+ ),
502
+ missingAttributes: (indexName, operation, missingAttributes, providedData, isReadOnly) => new IndexGenerationError(
503
+ `Cannot regenerate readonly index "${indexName}" - missing required attributes: ${missingAttributes.join(", ")}`,
504
+ ErrorCodes.INDEX_MISSING_ATTRIBUTES,
505
+ {
506
+ indexName,
507
+ operation,
508
+ missingAttributes,
509
+ providedData,
510
+ isReadOnly,
511
+ suggestion: isReadOnly ? "For readonly indexes, provide all attributes or use forceIndexRebuild() with complete data" : `Provide the following attributes: ${missingAttributes.join(", ")}`
512
+ }
513
+ ),
514
+ undefinedValues: (indexName, operation, generatedKey, providedItem) => new IndexGenerationError(`Index "${indexName}" generated undefined values`, ErrorCodes.INDEX_UNDEFINED_VALUES, {
515
+ indexName,
516
+ operation,
517
+ generatedKey,
518
+ providedItem,
519
+ suggestion: "Ensure all attributes required by the index are present in the item"
520
+ }),
521
+ notFound: (requestedIndexes, availableIndexes, entityName, tableName) => new IndexGenerationError(
522
+ `Requested indexes not found: ${requestedIndexes.join(", ")}`,
523
+ ErrorCodes.INDEX_NOT_FOUND,
524
+ {
525
+ requestedIndexes,
526
+ availableIndexes,
527
+ entityName,
528
+ tableName,
529
+ suggestion: `Available indexes are: ${availableIndexes.join(", ")}`
530
+ }
531
+ ),
532
+ readonlyUpdateFailed: (indexName, operation, providedData) => new IndexGenerationError(
533
+ `Cannot update readonly index "${indexName}" without forcing rebuild`,
534
+ ErrorCodes.INDEX_READONLY_UPDATE_FAILED,
535
+ {
536
+ indexName,
537
+ operation,
538
+ providedData,
539
+ isReadOnly: true,
540
+ suggestion: "Use forceIndexRebuild() to update readonly indexes, or provide all required attributes"
541
+ }
542
+ )
543
+ };
544
+
545
+ exports.BatchError = BatchError;
546
+ exports.BatchErrors = BatchErrors;
547
+ exports.ConfigurationError = ConfigurationError;
548
+ exports.ConfigurationErrors = ConfigurationErrors;
549
+ exports.DynoTableError = DynoTableError;
550
+ exports.EntityError = EntityError;
551
+ exports.EntityErrors = EntityErrors;
552
+ exports.EntityValidationError = EntityValidationError;
553
+ exports.ErrorCodes = ErrorCodes;
554
+ exports.ExpressionError = ExpressionError;
555
+ exports.ExpressionErrors = ExpressionErrors;
556
+ exports.IndexErrors = IndexErrors;
557
+ exports.IndexGenerationError = IndexGenerationError;
558
+ exports.KeyGenerationError = KeyGenerationError;
559
+ exports.OperationError = OperationError;
560
+ exports.OperationErrors = OperationErrors;
561
+ exports.TransactionError = TransactionError;
562
+ exports.TransactionErrors = TransactionErrors;
563
+ exports.ValidationError = ValidationError;
564
+ exports.ValidationErrors = ValidationErrors;