dyno-table 2.3.2 → 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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,273 @@
1
- export { B as BatchBuilder, a as BatchError, b as BatchResult, D as DeleteBuilder, c as DeleteOptions, P as PutBuilder, d as PutOptions, Q as QueryBuilder, e as QueryOptions, T as TransactionBuilder, f as TransactionOptions, U as UpdateBuilder, g as UpdateOptions } from './index-2cbm07Bi.js';
2
- export { C as ComparisonOperator, a as Condition, b as ConditionOperator, E as ExpressionParams, K as KeyConditionOperator, L as LogicalOperator, P as PrimaryKey, c as PrimaryKeyWithoutExpression, d as and, e as attributeExists, f as attributeNotExists, g as beginsWith, h as between, i as contains, j as eq, k as gt, l as gte, m as inArray, n as lt, o as lte, p as ne, q as not, r as or } from './conditions-D_w7vVYG.js';
1
+ import { c as BatchError, d as ConfigurationError, E as ExpressionError, e as EntityValidationError, K as KeyGenerationError, I as IndexGenerationError, O as OperationError, f as TransactionError, V as ValidationError, g as DynoTableError, h as EntityError } from './index-DdTolMJW.js';
2
+ export { B as BatchBuilder, i as BatchResult, D as DeleteBuilder, j as DeleteOptions, o as ErrorCode, n as ErrorCodes, P as PutBuilder, k as PutOptions, Q as QueryBuilder, l as QueryOptions, T as TransactionBuilder, a as TransactionOptions, U as UpdateBuilder, m as UpdateOptions } from './index-DdTolMJW.js';
3
+ export { C as ComparisonOperator, b as Condition, c as ConditionOperator, E as ExpressionParams, K as KeyConditionOperator, L as LogicalOperator, a as PrimaryKey, P as PrimaryKeyWithoutExpression, d as and, e as attributeExists, f as attributeNotExists, g as beginsWith, h as between, i as contains, j as eq, k as gt, l as gte, m as inArray, n as lt, o as lte, p as ne, q as not, r as or } from './conditions-BSAcZswY.js';
3
4
  export { EntityConfig, EntityRepository, IndexDefinition, QueryEntity, QueryRecord, createIndex, createQueries, defineEntity } from './entity.js';
4
5
  export { Table } from './table.js';
5
6
  export { partitionKey, sortKey } from './utils.js';
6
7
  import './types.js';
7
8
  import '@aws-sdk/lib-dynamodb';
8
9
  import './standard-schema.js';
10
+
11
+ /**
12
+ * Factory functions for Expression errors
13
+ */
14
+ declare const ExpressionErrors: {
15
+ missingAttribute: (conditionType: string, condition: unknown) => ExpressionError;
16
+ missingValue: (conditionType: string, condition: unknown) => ExpressionError;
17
+ invalidCondition: (conditionType: string, condition: unknown, suggestion?: string) => ExpressionError;
18
+ emptyArray: (conditionType: string, providedValue: unknown) => ExpressionError;
19
+ unknownType: (conditionType: string, condition: unknown) => ExpressionError;
20
+ };
21
+ /**
22
+ * Factory functions for Validation errors
23
+ */
24
+ declare const ValidationErrors: {
25
+ indexSchemaValidationFailed: (validationIssues: unknown, keyType: "partition" | "sort" | "both") => ValidationError;
26
+ noUpdateActions: (tableName: string, key: Record<string, unknown>) => ValidationError;
27
+ conditionRequired: (tableName: string, key: Record<string, unknown>) => ValidationError;
28
+ queryInputValidationFailed: (entityName: string, queryName: string, validationIssues: unknown, providedInput: unknown) => ValidationError;
29
+ undefinedValue: (path: string, tableName: string, key: Record<string, unknown>) => ValidationError;
30
+ };
31
+ /**
32
+ * Factory functions for Configuration errors
33
+ */
34
+ declare const ConfigurationErrors: {
35
+ invalidChunkSize: (size: number) => ConfigurationError;
36
+ sortKeyRequired: (tableName: string, partitionKey: string, sortKey?: string) => ConfigurationError;
37
+ sortKeyNotDefined: (tableName: string, partitionKey: string, indexName?: string) => ConfigurationError;
38
+ gsiNotFound: (indexName: string, tableName: string, availableIndexes: string[]) => ConfigurationError;
39
+ primaryKeyMissing: (tableName: string, partitionKeyName: string, providedItem: unknown) => ConfigurationError;
40
+ pkExtractionFailed: (tableName: string, indexName: string, item: unknown, cause?: Error) => ConfigurationError;
41
+ conditionGenerationFailed: (condition: unknown, suggestion?: string) => ExpressionError;
42
+ };
43
+ /**
44
+ * Factory functions for Operation errors
45
+ */
46
+ declare const OperationErrors: {
47
+ queryFailed: (tableName: string, context: Record<string, unknown>, cause?: Error) => OperationError;
48
+ scanFailed: (tableName: string, context: Record<string, unknown>, cause?: Error) => OperationError;
49
+ getFailed: (tableName: string, key: Record<string, unknown>, cause?: Error) => OperationError;
50
+ putFailed: (tableName: string, item: unknown, cause?: Error) => OperationError;
51
+ updateFailed: (tableName: string, key: Record<string, unknown>, cause?: Error) => OperationError;
52
+ deleteFailed: (tableName: string, key: Record<string, unknown>, cause?: Error) => OperationError;
53
+ batchGetFailed: (tableName: string, context: Record<string, unknown>, cause?: Error) => OperationError;
54
+ batchWriteFailed: (tableName: string, context: Record<string, unknown>, cause?: Error) => OperationError;
55
+ };
56
+ /**
57
+ * Factory functions for Transaction errors
58
+ */
59
+ declare const TransactionErrors: {
60
+ transactionFailed: (itemCount: number, context: Record<string, unknown>, cause?: Error) => TransactionError;
61
+ duplicateItem: (tableName: string, partitionKey: {
62
+ name: string;
63
+ value: unknown;
64
+ }, sortKey?: {
65
+ name: string;
66
+ value: unknown;
67
+ }) => TransactionError;
68
+ transactionEmpty: () => TransactionError;
69
+ unsupportedType: (item: unknown) => TransactionError;
70
+ };
71
+ /**
72
+ * Factory functions for Batch errors
73
+ */
74
+ declare const BatchErrors: {
75
+ batchEmpty: (operation: "write" | "read") => BatchError;
76
+ unsupportedType: (operation: "write" | "read", item: unknown) => BatchError;
77
+ batchWriteFailed: (unprocessedItems: unknown[], context: Record<string, unknown>, cause?: Error) => BatchError;
78
+ batchGetFailed: (unprocessedItems: unknown[], context: Record<string, unknown>, cause?: Error) => BatchError;
79
+ };
80
+ /**
81
+ * Factory functions for Entity errors
82
+ */
83
+ declare const EntityErrors: {
84
+ validationFailed: (entityName: string, operation: string, validationIssues: unknown, providedData: unknown) => EntityValidationError;
85
+ queryInputValidationFailed: (entityName: string, queryName: string, validationIssues: unknown, providedInput: unknown) => EntityValidationError;
86
+ asyncValidationNotSupported: (entityName: string, operation: string) => EntityValidationError;
87
+ keyGenerationFailed: (entityName: string, operation: string, providedData: unknown, requiredAttributes?: string[], cause?: Error) => KeyGenerationError;
88
+ keyInvalidFormat: (entityName: string, operation: string, providedData: unknown, generatedKey: unknown) => KeyGenerationError;
89
+ keyMissingAttributes: (entityName: string, operation: string, missingAttributes: string[], providedData: unknown) => KeyGenerationError;
90
+ };
91
+ /**
92
+ * Factory functions for Index errors
93
+ */
94
+ declare const IndexErrors: {
95
+ generationFailed: (indexName: string, operation: string, providedItem: unknown, partitionKeyAttribute?: string, sortKeyAttribute?: string, cause?: Error) => IndexGenerationError;
96
+ missingAttributes: (indexName: string, operation: string, missingAttributes: string[], providedData: unknown, isReadOnly: boolean) => IndexGenerationError;
97
+ undefinedValues: (indexName: string, operation: string, generatedKey: unknown, providedItem: unknown) => IndexGenerationError;
98
+ notFound: (requestedIndexes: string[], availableIndexes: string[], entityName?: string, tableName?: string) => IndexGenerationError;
99
+ readonlyUpdateFailed: (indexName: string, operation: string, providedData: unknown) => IndexGenerationError;
100
+ };
101
+
102
+ /**
103
+ * Utility functions for error handling
104
+ *
105
+ * This module provides helper functions for wrapping AWS SDK errors,
106
+ * extracting information from errors, and formatting error context.
107
+ */
108
+
109
+ /**
110
+ * Checks if an error is a DynamoDB conditional check failure
111
+ *
112
+ * @param error - The error to check
113
+ * @returns true if the error is a conditional check failure
114
+ */
115
+ declare function isConditionalCheckFailed(error: unknown): boolean;
116
+ /**
117
+ * Checks if an error is a DynamoDB transaction cancellation
118
+ *
119
+ * @param error - The error to check
120
+ * @returns true if the error is a transaction cancellation
121
+ */
122
+ declare function isTransactionCanceled(error: unknown): boolean;
123
+ /**
124
+ * Checks if an error is a DynamoDB validation exception
125
+ *
126
+ * @param error - The error to check
127
+ * @returns true if the error is a validation exception
128
+ */
129
+ declare function isValidationException(error: unknown): boolean;
130
+ /**
131
+ * Checks if an error is a DynamoDB provisioned throughput exceeded exception
132
+ *
133
+ * @param error - The error to check
134
+ * @returns true if the error is a throughput exceeded exception
135
+ */
136
+ declare function isProvisionedThroughputExceeded(error: unknown): boolean;
137
+ /**
138
+ * Checks if an error is a retryable error
139
+ *
140
+ * Retryable errors include:
141
+ * - ProvisionedThroughputExceededException
142
+ * - ThrottlingException
143
+ * - RequestLimitExceeded
144
+ * - InternalServerError
145
+ * - ServiceUnavailable
146
+ *
147
+ * @param error - The error to check
148
+ * @returns true if the error is retryable
149
+ */
150
+ declare function isRetryableError(error: unknown): boolean;
151
+ /**
152
+ * Extracts the AWS error code from an error
153
+ *
154
+ * @param error - The error to extract the code from
155
+ * @returns The error code, or undefined if not found
156
+ */
157
+ declare function getAwsErrorCode(error: unknown): string | undefined;
158
+ /**
159
+ * Extracts the AWS error message from an error
160
+ *
161
+ * @param error - The error to extract the message from
162
+ * @returns The error message, or undefined if not found
163
+ */
164
+ declare function getAwsErrorMessage(error: unknown): string | undefined;
165
+ /**
166
+ * Attempts to extract required attribute names from an error message
167
+ *
168
+ * This is a best-effort function that looks for common patterns in error
169
+ * messages to identify which attributes are missing or required.
170
+ *
171
+ * @param error - The error to extract attributes from
172
+ * @returns Array of attribute names, or undefined if none found
173
+ */
174
+ declare function extractRequiredAttributes(error: unknown): string[] | undefined;
175
+ /**
176
+ * Formats error context for logging
177
+ *
178
+ * Converts the error context object to a readable string format,
179
+ * handling special types like arrays and nested objects.
180
+ *
181
+ * @param context - The error context to format
182
+ * @param indent - The indentation level (for nested objects)
183
+ * @returns Formatted context string
184
+ */
185
+ declare function formatErrorContext(context: Record<string, unknown>, indent?: number): string;
186
+ /**
187
+ * Creates a detailed error summary including context
188
+ *
189
+ * Useful for logging or displaying error information to developers.
190
+ *
191
+ * @param error - The DynoTableError to summarize
192
+ * @returns Formatted error summary
193
+ */
194
+ declare function getErrorSummary(error: DynoTableError): string;
195
+ /**
196
+ * Type guard to check if an error is a DynoTableError
197
+ *
198
+ * @param error - The error to check
199
+ * @returns true if the error is a DynoTableError
200
+ */
201
+ declare function isDynoTableError(error: unknown): error is DynoTableError;
202
+ /**
203
+ * Type guard to check if an error is a ValidationError
204
+ *
205
+ * @param error - The error to check
206
+ * @returns true if the error is a ValidationError
207
+ */
208
+ declare function isValidationError(error: unknown): error is ValidationError;
209
+ /**
210
+ * Type guard to check if an error is an OperationError
211
+ *
212
+ * @param error - The error to check
213
+ * @returns true if the error is an OperationError
214
+ */
215
+ declare function isOperationError(error: unknown): error is OperationError;
216
+ /**
217
+ * Type guard to check if an error is a TransactionError
218
+ *
219
+ * @param error - The error to check
220
+ * @returns true if the error is a TransactionError
221
+ */
222
+ declare function isTransactionError(error: unknown): error is TransactionError;
223
+ /**
224
+ * Type guard to check if an error is a BatchError
225
+ *
226
+ * @param error - The error to check
227
+ * @returns true if the error is a BatchError
228
+ */
229
+ declare function isBatchError(error: unknown): error is BatchError;
230
+ /**
231
+ * Type guard to check if an error is an ExpressionError
232
+ *
233
+ * @param error - The error to check
234
+ * @returns true if the error is an ExpressionError
235
+ */
236
+ declare function isExpressionError(error: unknown): error is ExpressionError;
237
+ /**
238
+ * Type guard to check if an error is a ConfigurationError
239
+ *
240
+ * @param error - The error to check
241
+ * @returns true if the error is a ConfigurationError
242
+ */
243
+ declare function isConfigurationError(error: unknown): error is ConfigurationError;
244
+ /**
245
+ * Type guard to check if an error is an EntityError
246
+ *
247
+ * @param error - The error to check
248
+ * @returns true if the error is an EntityError
249
+ */
250
+ declare function isEntityError(error: unknown): error is EntityError;
251
+ /**
252
+ * Type guard to check if an error is a KeyGenerationError
253
+ *
254
+ * @param error - The error to check
255
+ * @returns true if the error is a KeyGenerationError
256
+ */
257
+ declare function isKeyGenerationError(error: unknown): error is KeyGenerationError;
258
+ /**
259
+ * Type guard to check if an error is an IndexGenerationError
260
+ *
261
+ * @param error - The error to check
262
+ * @returns true if the error is an IndexGenerationError
263
+ */
264
+ declare function isIndexGenerationError(error: unknown): error is IndexGenerationError;
265
+ /**
266
+ * Type guard to check if an error is an EntityValidationError
267
+ *
268
+ * @param error - The error to check
269
+ * @returns true if the error is an EntityValidationError
270
+ */
271
+ declare function isEntityValidationError(error: unknown): error is EntityValidationError;
272
+
273
+ export { BatchError, BatchErrors, ConfigurationError, ConfigurationErrors, DynoTableError, EntityError, EntityErrors, EntityValidationError, ExpressionError, ExpressionErrors, IndexErrors, IndexGenerationError, KeyGenerationError, OperationError, OperationErrors, TransactionError, TransactionErrors, ValidationError, ValidationErrors, extractRequiredAttributes, formatErrorContext, getAwsErrorCode, getAwsErrorMessage, getErrorSummary, isBatchError, isConditionalCheckFailed, isConfigurationError, isDynoTableError, isEntityError, isEntityValidationError, isExpressionError, isIndexGenerationError, isKeyGenerationError, isOperationError, isProvisionedThroughputExceeded, isRetryableError, isTransactionCanceled, isTransactionError, isValidationError, isValidationException };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- export { Table } from './chunk-EODPMYPE.js';
2
- export { createIndex, createQueries, defineEntity } from './chunk-2EWNZOUK.js';
1
+ export { Table } from './chunk-64DG2EEI.js';
2
+ export { createIndex, createQueries, defineEntity, extractRequiredAttributes, formatErrorContext, getAwsErrorCode, getAwsErrorMessage, getErrorSummary, isBatchError, isConditionalCheckFailed, isConfigurationError, isDynoTableError, isEntityError, isEntityValidationError, isExpressionError, isIndexGenerationError, isKeyGenerationError, isOperationError, isProvisionedThroughputExceeded, isRetryableError, isTransactionCanceled, isTransactionError, isValidationError, isValidationException } from './chunk-U6MQGB6Y.js';
3
3
  export { partitionKey, sortKey } from './chunk-QVRMYGC4.js';
4
- export { BatchBuilder, BatchError, DeleteBuilder, PutBuilder, QueryBuilder, TransactionBuilder, UpdateBuilder } from './chunk-DTFJJASK.js';
4
+ export { BatchBuilder, DeleteBuilder, PutBuilder, QueryBuilder, TransactionBuilder, UpdateBuilder } from './chunk-GWHGUKAL.js';
5
+ export { BatchError, BatchErrors, ConfigurationError, ConfigurationErrors, DynoTableError, EntityError, EntityErrors, EntityValidationError, ErrorCodes, ExpressionError, ExpressionErrors, IndexErrors, IndexGenerationError, KeyGenerationError, OperationError, OperationErrors, TransactionError, TransactionErrors, ValidationError, ValidationErrors } from './chunk-FF7FYGDH.js';
5
6
  export { and, attributeExists, attributeNotExists, beginsWith, between, contains, eq, gt, gte, inArray, lt, lte, ne, not, or } from './chunk-2WIBY7PZ.js';
package/dist/table.cjs CHANGED
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkKA3VPIPS_cjs = require('./chunk-KA3VPIPS.cjs');
4
- require('./chunk-XYL43FDX.cjs');
3
+ var chunkOLURZQ7R_cjs = require('./chunk-OLURZQ7R.cjs');
4
+ require('./chunk-AHF4H42Q.cjs');
5
+ require('./chunk-ELULXDSB.cjs');
5
6
  require('./chunk-7UJJ7JXM.cjs');
6
7
 
7
8
 
8
9
 
9
10
  Object.defineProperty(exports, "Table", {
10
11
  enumerable: true,
11
- get: function () { return chunkKA3VPIPS_cjs.Table; }
12
+ get: function () { return chunkOLURZQ7R_cjs.Table; }
12
13
  });
package/dist/table.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PutBuilder, G as GetBuilder, Q as QueryBuilder, S as ScanBuilder, D as DeleteBuilder, U as UpdateBuilder, T as TransactionBuilder, B as BatchBuilder, f as TransactionOptions, C as ConditionCheckBuilder, h as BatchWriteOperation } from './index-DlN8G9hd.cjs';
2
- import { c as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-CcZL0sR2.cjs';
1
+ import { P as PutBuilder, G as GetBuilder, Q as QueryBuilder, S as ScanBuilder, D as DeleteBuilder, U as UpdateBuilder, T as TransactionBuilder, B as BatchBuilder, a as TransactionOptions, C as ConditionCheckBuilder, b as BatchWriteOperation } from './index-BX-MSZHj.cjs';
2
+ import { P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions-C8bM__Pn.cjs';
3
3
  import { TableConfig, Index, DynamoItem } from './types.cjs';
4
4
  import '@aws-sdk/lib-dynamodb';
5
5
 
package/dist/table.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PutBuilder, G as GetBuilder, Q as QueryBuilder, S as ScanBuilder, D as DeleteBuilder, U as UpdateBuilder, T as TransactionBuilder, B as BatchBuilder, f as TransactionOptions, C as ConditionCheckBuilder, h as BatchWriteOperation } from './index-2cbm07Bi.js';
2
- import { c as PrimaryKeyWithoutExpression, P as PrimaryKey } from './conditions-D_w7vVYG.js';
1
+ import { P as PutBuilder, G as GetBuilder, Q as QueryBuilder, S as ScanBuilder, D as DeleteBuilder, U as UpdateBuilder, T as TransactionBuilder, B as BatchBuilder, a as TransactionOptions, C as ConditionCheckBuilder, b as BatchWriteOperation } from './index-DdTolMJW.js';
2
+ import { P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions-BSAcZswY.js';
3
3
  import { TableConfig, Index, DynamoItem } from './types.js';
4
4
  import '@aws-sdk/lib-dynamodb';
5
5
 
package/dist/table.js CHANGED
@@ -1,3 +1,4 @@
1
- export { Table } from './chunk-EODPMYPE.js';
2
- import './chunk-DTFJJASK.js';
1
+ export { Table } from './chunk-64DG2EEI.js';
2
+ import './chunk-GWHGUKAL.js';
3
+ import './chunk-FF7FYGDH.js';
3
4
  import './chunk-2WIBY7PZ.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dyno-table",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "description": "A TypeScript library to simplify working with DynamoDB",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",