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