dyno-table 2.5.1 → 2.6.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.
Files changed (58) 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.d.ts +1 -4
  18. package/dist/{chunk-U6MQGB6Y.js → chunk-JZB6TYST.js} +133 -136
  19. package/dist/{chunk-ZXM6LPRV.cjs → chunk-Z334X72N.cjs} +133 -136
  20. package/dist/conditions.d.ts +705 -3
  21. package/dist/entity/ddb-indexing.d.ts +45 -0
  22. package/dist/entity/entity.d.ts +188 -0
  23. package/dist/entity/index-utils.d.ts +24 -0
  24. package/dist/entity.cjs +4 -4
  25. package/dist/entity.d.ts +1 -261
  26. package/dist/entity.js +1 -1
  27. package/dist/errors.d.ts +212 -0
  28. package/dist/expression.d.ts +9 -0
  29. package/dist/index-definition.d.ts +10 -0
  30. package/dist/index.cjs +25 -25
  31. package/dist/index.d.ts +16 -273
  32. package/dist/index.js +1 -1
  33. package/dist/operation-types.d.ts +8 -0
  34. package/dist/standard-schema.d.ts +2 -4
  35. package/dist/table.d.ts +13 -8
  36. package/dist/types.d.ts +6 -9
  37. package/dist/utils/chunk-array.d.ts +9 -0
  38. package/dist/utils/debug-expression.d.ts +32 -0
  39. package/dist/utils/debug-transaction.d.ts +17 -0
  40. package/dist/utils/error-factory.d.ts +162 -0
  41. package/dist/utils/error-utils.d.ts +170 -0
  42. package/dist/utils/index.d.ts +7 -0
  43. package/dist/utils/partition-key-template.d.ts +30 -0
  44. package/dist/utils/sort-key-template.d.ts +33 -0
  45. package/dist/utils.d.ts +1 -66
  46. package/package.json +12 -10
  47. package/dist/builders.d.cts +0 -4
  48. package/dist/conditions-BSAcZswY.d.ts +0 -731
  49. package/dist/conditions-C8bM__Pn.d.cts +0 -731
  50. package/dist/conditions.d.cts +0 -3
  51. package/dist/entity.d.cts +0 -261
  52. package/dist/index-Bc-ra0im.d.ts +0 -3042
  53. package/dist/index-CPCmWsEv.d.cts +0 -3042
  54. package/dist/index.d.cts +0 -273
  55. package/dist/standard-schema.d.cts +0 -57
  56. package/dist/table.d.cts +0 -165
  57. package/dist/types.d.cts +0 -29
  58. package/dist/utils.d.cts +0 -66
@@ -3,6 +3,136 @@
3
3
  var chunkELULXDSB_cjs = require('./chunk-ELULXDSB.cjs');
4
4
  var chunk7UJJ7JXM_cjs = require('./chunk-7UJJ7JXM.cjs');
5
5
 
6
+ // src/utils/error-utils.ts
7
+ function isConditionalCheckFailed(error) {
8
+ if (typeof error === "object" && error !== null && "name" in error) {
9
+ return error.name === "ConditionalCheckFailedException";
10
+ }
11
+ return false;
12
+ }
13
+ function isTransactionCanceled(error) {
14
+ if (typeof error === "object" && error !== null && "name" in error) {
15
+ return error.name === "TransactionCanceledException";
16
+ }
17
+ return false;
18
+ }
19
+ function isValidationException(error) {
20
+ if (typeof error === "object" && error !== null && "name" in error) {
21
+ return error.name === "ValidationException";
22
+ }
23
+ return false;
24
+ }
25
+ function isProvisionedThroughputExceeded(error) {
26
+ if (typeof error === "object" && error !== null && "name" in error) {
27
+ return error.name === "ProvisionedThroughputExceededException";
28
+ }
29
+ return false;
30
+ }
31
+ function isRetryableError(error) {
32
+ if (typeof error === "object" && error !== null && "name" in error) {
33
+ const errorName = error.name;
34
+ return errorName === "ProvisionedThroughputExceededException" || errorName === "ThrottlingException" || errorName === "RequestLimitExceeded" || errorName === "InternalServerError" || errorName === "ServiceUnavailable";
35
+ }
36
+ return false;
37
+ }
38
+ function getAwsErrorCode(error) {
39
+ if (typeof error === "object" && error !== null && "name" in error) {
40
+ return error.name;
41
+ }
42
+ return void 0;
43
+ }
44
+ function getAwsErrorMessage(error) {
45
+ if (error instanceof Error) {
46
+ return error.message;
47
+ }
48
+ if (typeof error === "object" && error !== null && "message" in error) {
49
+ return String(error.message);
50
+ }
51
+ return void 0;
52
+ }
53
+ function extractRequiredAttributes(error) {
54
+ const message = getAwsErrorMessage(error);
55
+ if (!message) return void 0;
56
+ const patterns = [
57
+ /(?:missing|required)\s+(?:attribute|field|property)(?:s)?[:\s]+([a-zA-Z0-9_,\s]+)/i,
58
+ /(?:attribute|field|property)[:\s]+([a-zA-Z0-9_]+)\s+is\s+(?:missing|required)/i,
59
+ /"([a-zA-Z0-9_]+)"\s+is\s+(?:missing|required)/i
60
+ ];
61
+ for (const pattern of patterns) {
62
+ const match = message.match(pattern);
63
+ if (match?.[1]) {
64
+ return match[1].split(",").map((attr) => attr.trim()).filter((attr) => attr.length > 0);
65
+ }
66
+ }
67
+ return void 0;
68
+ }
69
+ function formatErrorContext(context, indent = 0) {
70
+ const indentStr = " ".repeat(indent);
71
+ const lines = [];
72
+ for (const [key, value] of Object.entries(context)) {
73
+ if (value === void 0 || value === null) {
74
+ lines.push(`${indentStr}${key}: ${value}`);
75
+ } else if (Array.isArray(value)) {
76
+ lines.push(`${indentStr}${key}: [${value.map((v) => JSON.stringify(v)).join(", ")}]`);
77
+ } else if (typeof value === "object") {
78
+ lines.push(`${indentStr}${key}:`);
79
+ lines.push(formatErrorContext(value, indent + 1));
80
+ } else if (typeof value === "string" && value.length > 100) {
81
+ lines.push(`${indentStr}${key}: ${value.substring(0, 100)}...`);
82
+ } else {
83
+ lines.push(`${indentStr}${key}: ${JSON.stringify(value)}`);
84
+ }
85
+ }
86
+ return lines.join("\n");
87
+ }
88
+ function getErrorSummary(error) {
89
+ const parts = [];
90
+ parts.push(`Error: ${error.name}`);
91
+ parts.push(`Code: ${error.code}`);
92
+ parts.push(`Message: ${error.message}`);
93
+ if (Object.keys(error.context).length > 0) {
94
+ parts.push("Context:");
95
+ parts.push(formatErrorContext(error.context, 1));
96
+ }
97
+ if (error.cause) {
98
+ parts.push(`Caused by: ${error.cause.name}: ${error.cause.message}`);
99
+ }
100
+ return parts.join("\n");
101
+ }
102
+ function isDynoTableError(error) {
103
+ return typeof error === "object" && error !== null && "code" in error && "context" in error && error instanceof Error;
104
+ }
105
+ function isValidationError(error) {
106
+ return error instanceof Error && error.name === "ValidationError";
107
+ }
108
+ function isOperationError(error) {
109
+ return error instanceof Error && error.name === "OperationError";
110
+ }
111
+ function isTransactionError(error) {
112
+ return error instanceof Error && error.name === "TransactionError";
113
+ }
114
+ function isBatchError(error) {
115
+ return error instanceof Error && error.name === "BatchError";
116
+ }
117
+ function isExpressionError(error) {
118
+ return error instanceof Error && error.name === "ExpressionError";
119
+ }
120
+ function isConfigurationError(error) {
121
+ return error instanceof Error && error.name === "ConfigurationError";
122
+ }
123
+ function isEntityError(error) {
124
+ return error instanceof Error && error.name === "EntityError";
125
+ }
126
+ function isKeyGenerationError(error) {
127
+ return error instanceof Error && error.name === "KeyGenerationError";
128
+ }
129
+ function isIndexGenerationError(error) {
130
+ return error instanceof Error && error.name === "IndexGenerationError";
131
+ }
132
+ function isEntityValidationError(error) {
133
+ return error instanceof Error && error.name === "EntityValidationError";
134
+ }
135
+
6
136
  // src/builders/entity-aware-builders.ts
7
137
  function createEntityAwareBuilder(builder, entityName) {
8
138
  return new Proxy(builder, {
@@ -159,136 +289,6 @@ function createEntityAwareUpdateBuilder(builder, entityName) {
159
289
  return new EntityAwareUpdateBuilder(builder, entityName);
160
290
  }
161
291
 
162
- // src/utils/error-utils.ts
163
- function isConditionalCheckFailed(error) {
164
- if (typeof error === "object" && error !== null && "name" in error) {
165
- return error.name === "ConditionalCheckFailedException";
166
- }
167
- return false;
168
- }
169
- function isTransactionCanceled(error) {
170
- if (typeof error === "object" && error !== null && "name" in error) {
171
- return error.name === "TransactionCanceledException";
172
- }
173
- return false;
174
- }
175
- function isValidationException(error) {
176
- if (typeof error === "object" && error !== null && "name" in error) {
177
- return error.name === "ValidationException";
178
- }
179
- return false;
180
- }
181
- function isProvisionedThroughputExceeded(error) {
182
- if (typeof error === "object" && error !== null && "name" in error) {
183
- return error.name === "ProvisionedThroughputExceededException";
184
- }
185
- return false;
186
- }
187
- function isRetryableError(error) {
188
- if (typeof error === "object" && error !== null && "name" in error) {
189
- const errorName = error.name;
190
- return errorName === "ProvisionedThroughputExceededException" || errorName === "ThrottlingException" || errorName === "RequestLimitExceeded" || errorName === "InternalServerError" || errorName === "ServiceUnavailable";
191
- }
192
- return false;
193
- }
194
- function getAwsErrorCode(error) {
195
- if (typeof error === "object" && error !== null && "name" in error) {
196
- return error.name;
197
- }
198
- return void 0;
199
- }
200
- function getAwsErrorMessage(error) {
201
- if (error instanceof Error) {
202
- return error.message;
203
- }
204
- if (typeof error === "object" && error !== null && "message" in error) {
205
- return String(error.message);
206
- }
207
- return void 0;
208
- }
209
- function extractRequiredAttributes(error) {
210
- const message = getAwsErrorMessage(error);
211
- if (!message) return void 0;
212
- const patterns = [
213
- /(?:missing|required)\s+(?:attribute|field|property)(?:s)?[:\s]+([a-zA-Z0-9_,\s]+)/i,
214
- /(?:attribute|field|property)[:\s]+([a-zA-Z0-9_]+)\s+is\s+(?:missing|required)/i,
215
- /"([a-zA-Z0-9_]+)"\s+is\s+(?:missing|required)/i
216
- ];
217
- for (const pattern of patterns) {
218
- const match = message.match(pattern);
219
- if (match?.[1]) {
220
- return match[1].split(",").map((attr) => attr.trim()).filter((attr) => attr.length > 0);
221
- }
222
- }
223
- return void 0;
224
- }
225
- function formatErrorContext(context, indent = 0) {
226
- const indentStr = " ".repeat(indent);
227
- const lines = [];
228
- for (const [key, value] of Object.entries(context)) {
229
- if (value === void 0 || value === null) {
230
- lines.push(`${indentStr}${key}: ${value}`);
231
- } else if (Array.isArray(value)) {
232
- lines.push(`${indentStr}${key}: [${value.map((v) => JSON.stringify(v)).join(", ")}]`);
233
- } else if (typeof value === "object") {
234
- lines.push(`${indentStr}${key}:`);
235
- lines.push(formatErrorContext(value, indent + 1));
236
- } else if (typeof value === "string" && value.length > 100) {
237
- lines.push(`${indentStr}${key}: ${value.substring(0, 100)}...`);
238
- } else {
239
- lines.push(`${indentStr}${key}: ${JSON.stringify(value)}`);
240
- }
241
- }
242
- return lines.join("\n");
243
- }
244
- function getErrorSummary(error) {
245
- const parts = [];
246
- parts.push(`Error: ${error.name}`);
247
- parts.push(`Code: ${error.code}`);
248
- parts.push(`Message: ${error.message}`);
249
- if (Object.keys(error.context).length > 0) {
250
- parts.push("Context:");
251
- parts.push(formatErrorContext(error.context, 1));
252
- }
253
- if (error.cause) {
254
- parts.push(`Caused by: ${error.cause.name}: ${error.cause.message}`);
255
- }
256
- return parts.join("\n");
257
- }
258
- function isDynoTableError(error) {
259
- return typeof error === "object" && error !== null && "code" in error && "context" in error && error instanceof Error;
260
- }
261
- function isValidationError(error) {
262
- return error instanceof Error && error.name === "ValidationError";
263
- }
264
- function isOperationError(error) {
265
- return error instanceof Error && error.name === "OperationError";
266
- }
267
- function isTransactionError(error) {
268
- return error instanceof Error && error.name === "TransactionError";
269
- }
270
- function isBatchError(error) {
271
- return error instanceof Error && error.name === "BatchError";
272
- }
273
- function isExpressionError(error) {
274
- return error instanceof Error && error.name === "ExpressionError";
275
- }
276
- function isConfigurationError(error) {
277
- return error instanceof Error && error.name === "ConfigurationError";
278
- }
279
- function isEntityError(error) {
280
- return error instanceof Error && error.name === "EntityError";
281
- }
282
- function isKeyGenerationError(error) {
283
- return error instanceof Error && error.name === "KeyGenerationError";
284
- }
285
- function isIndexGenerationError(error) {
286
- return error instanceof Error && error.name === "IndexGenerationError";
287
- }
288
- function isEntityValidationError(error) {
289
- return error instanceof Error && error.name === "EntityValidationError";
290
- }
291
-
292
292
  // src/entity/ddb-indexing.ts
293
293
  var IndexBuilder = class {
294
294
  /**
@@ -657,12 +657,9 @@ function defineEntity(config) {
657
657
  };
658
658
  const originalExecute = builder.execute;
659
659
  builder.execute = async () => {
660
- await prepareValidatedItemAsync();
661
- const result = await originalExecute.call(builder);
662
- if (!result) {
663
- throw chunkELULXDSB_cjs.OperationErrors.putFailed(config.name, {}, void 0);
664
- }
665
- return result;
660
+ const validatedItem = await prepareValidatedItemAsync();
661
+ await originalExecute.call(builder);
662
+ return validatedItem;
666
663
  };
667
664
  const originalWithTransaction = builder.withTransaction;
668
665
  if (originalWithTransaction) {