dyno-table 2.3.3 → 2.5.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.cjs +14 -13
- package/dist/builders.d.cts +2 -2
- package/dist/builders.d.ts +2 -2
- package/dist/builders.js +2 -1
- package/dist/{chunk-XYL43FDX.cjs → chunk-3DR6VOFW.cjs} +233 -101
- package/dist/{chunk-EODPMYPE.js → chunk-42LH2UEM.js} +45 -26
- package/dist/chunk-ELULXDSB.cjs +564 -0
- package/dist/chunk-FF7FYGDH.js +543 -0
- package/dist/{chunk-DTFJJASK.js → chunk-NYJGW3XH.js} +230 -96
- package/dist/{chunk-M5Y6JQJN.js → chunk-U6MQGB6Y.js} +239 -39
- package/dist/{chunk-KA3VPIPS.cjs → chunk-ZUBCW3LA.cjs} +58 -39
- package/dist/{chunk-3J5DY7KG.cjs → chunk-ZXM6LPRV.cjs} +259 -38
- package/dist/{conditions-D_w7vVYG.d.ts → conditions-BSAcZswY.d.ts} +1 -1
- package/dist/{conditions-CcZL0sR2.d.cts → conditions-C8bM__Pn.d.cts} +1 -1
- package/dist/conditions.d.cts +1 -1
- package/dist/conditions.d.ts +1 -1
- package/dist/entity.cjs +5 -4
- package/dist/entity.d.cts +2 -2
- package/dist/entity.d.ts +2 -2
- package/dist/entity.js +2 -1
- package/dist/{index-2cbm07Bi.d.ts → index-C9KOQdSC.d.ts} +258 -13
- package/dist/{index-DlN8G9hd.d.cts → index-Ca76PpXj.d.cts} +258 -13
- package/dist/index.cjs +178 -17
- package/dist/index.d.cts +267 -2
- package/dist/index.d.ts +267 -2
- package/dist/index.js +4 -3
- package/dist/table.cjs +4 -3
- package/dist/table.d.cts +3 -2
- package/dist/table.d.ts +3 -2
- package/dist/table.js +3 -2
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkELULXDSB_cjs = require('./chunk-ELULXDSB.cjs');
|
|
3
4
|
var chunk7UJJ7JXM_cjs = require('./chunk-7UJJ7JXM.cjs');
|
|
4
5
|
|
|
5
6
|
// src/builders/entity-aware-builders.ts
|
|
@@ -114,9 +115,6 @@ var EntityAwareUpdateBuilder = class {
|
|
|
114
115
|
if (typeof valuesOrPath === "object") {
|
|
115
116
|
this.builder.set(valuesOrPath);
|
|
116
117
|
} else {
|
|
117
|
-
if (value === void 0) {
|
|
118
|
-
throw new Error("Value is required when setting a single path");
|
|
119
|
-
}
|
|
120
118
|
this.builder.set(valuesOrPath, value);
|
|
121
119
|
}
|
|
122
120
|
return this;
|
|
@@ -161,6 +159,136 @@ function createEntityAwareUpdateBuilder(builder, entityName) {
|
|
|
161
159
|
return new EntityAwareUpdateBuilder(builder, entityName);
|
|
162
160
|
}
|
|
163
161
|
|
|
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
|
+
|
|
164
292
|
// src/entity/ddb-indexing.ts
|
|
165
293
|
var IndexBuilder = class {
|
|
166
294
|
/**
|
|
@@ -186,10 +314,26 @@ var IndexBuilder = class {
|
|
|
186
314
|
if (options.excludeReadOnly && indexDef.isReadOnly) {
|
|
187
315
|
continue;
|
|
188
316
|
}
|
|
189
|
-
|
|
317
|
+
let key;
|
|
318
|
+
try {
|
|
319
|
+
key = indexDef.generateKey(item);
|
|
320
|
+
if (this.hasUndefinedValues(key)) {
|
|
321
|
+
throw chunkELULXDSB_cjs.IndexErrors.undefinedValues(indexName, "create", key, item);
|
|
322
|
+
}
|
|
323
|
+
} catch (error) {
|
|
324
|
+
if (error instanceof chunkELULXDSB_cjs.DynoTableError) throw error;
|
|
325
|
+
throw chunkELULXDSB_cjs.IndexErrors.generationFailed(
|
|
326
|
+
indexName,
|
|
327
|
+
"create",
|
|
328
|
+
item,
|
|
329
|
+
indexDef.partitionKey,
|
|
330
|
+
indexDef.sortKey,
|
|
331
|
+
error instanceof Error ? error : void 0
|
|
332
|
+
);
|
|
333
|
+
}
|
|
190
334
|
const gsiConfig = this.table.gsis[indexName];
|
|
191
335
|
if (!gsiConfig) {
|
|
192
|
-
throw
|
|
336
|
+
throw chunkELULXDSB_cjs.ConfigurationErrors.gsiNotFound(indexName, this.table.tableName, Object.keys(this.table.gsis));
|
|
193
337
|
}
|
|
194
338
|
if (key.pk) {
|
|
195
339
|
attributes[gsiConfig.partitionKey] = key.pk;
|
|
@@ -214,9 +358,7 @@ var IndexBuilder = class {
|
|
|
214
358
|
if (options.forceRebuildIndexes && options.forceRebuildIndexes.length > 0) {
|
|
215
359
|
const invalidIndexes = options.forceRebuildIndexes.filter((indexName) => !this.indexes[indexName]);
|
|
216
360
|
if (invalidIndexes.length > 0) {
|
|
217
|
-
throw
|
|
218
|
-
`Cannot force rebuild unknown indexes: ${invalidIndexes.join(", ")}. Available indexes: ${Object.keys(this.indexes).join(", ")}`
|
|
219
|
-
);
|
|
361
|
+
throw chunkELULXDSB_cjs.IndexErrors.notFound(invalidIndexes, Object.keys(this.indexes), void 0, this.table.tableName);
|
|
220
362
|
}
|
|
221
363
|
}
|
|
222
364
|
for (const [indexName, indexDef] of Object.entries(this.indexes)) {
|
|
@@ -243,19 +385,22 @@ var IndexBuilder = class {
|
|
|
243
385
|
try {
|
|
244
386
|
key = indexDef.generateKey(updatedItem);
|
|
245
387
|
} catch (error) {
|
|
246
|
-
if (error instanceof
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
388
|
+
if (error instanceof chunkELULXDSB_cjs.DynoTableError) throw error;
|
|
389
|
+
throw chunkELULXDSB_cjs.IndexErrors.missingAttributes(
|
|
390
|
+
indexName,
|
|
391
|
+
"update",
|
|
392
|
+
[],
|
|
393
|
+
// We don't know which specific attributes are missing from the error
|
|
394
|
+
updates,
|
|
395
|
+
indexDef.isReadOnly
|
|
396
|
+
);
|
|
250
397
|
}
|
|
251
398
|
if (this.hasUndefinedValues(key)) {
|
|
252
|
-
throw
|
|
253
|
-
`Missing attributes: Cannot update entity: insufficient data to regenerate index "${indexName}". All attributes required by the index must be provided in the update operation, or the index must be marked as readOnly.`
|
|
254
|
-
);
|
|
399
|
+
throw chunkELULXDSB_cjs.IndexErrors.undefinedValues(indexName, "update", key, updates);
|
|
255
400
|
}
|
|
256
401
|
const gsiConfig = this.table.gsis[indexName];
|
|
257
402
|
if (!gsiConfig) {
|
|
258
|
-
throw
|
|
403
|
+
throw chunkELULXDSB_cjs.ConfigurationErrors.gsiNotFound(indexName, this.table.tableName, Object.keys(this.table.gsis));
|
|
259
404
|
}
|
|
260
405
|
if (key.pk) {
|
|
261
406
|
attributes[gsiConfig.partitionKey] = key.pk;
|
|
@@ -342,13 +487,28 @@ function defineEntity(config) {
|
|
|
342
487
|
const prepareValidatedItemAsync = async () => {
|
|
343
488
|
const validatedData = await config.schema["~standard"].validate(data);
|
|
344
489
|
if ("issues" in validatedData && validatedData.issues) {
|
|
345
|
-
throw
|
|
490
|
+
throw chunkELULXDSB_cjs.EntityErrors.validationFailed(config.name, "create", validatedData.issues, data);
|
|
346
491
|
}
|
|
347
492
|
const dataForKeyGeneration = {
|
|
348
493
|
...validatedData.value,
|
|
349
494
|
...generateTimestamps(["createdAt", "updatedAt"], validatedData.value)
|
|
350
495
|
};
|
|
351
|
-
|
|
496
|
+
let primaryKey;
|
|
497
|
+
try {
|
|
498
|
+
primaryKey = config.primaryKey.generateKey(dataForKeyGeneration);
|
|
499
|
+
if (primaryKey.pk === void 0 || primaryKey.pk === null) {
|
|
500
|
+
throw chunkELULXDSB_cjs.EntityErrors.keyInvalidFormat(config.name, "create", dataForKeyGeneration, primaryKey);
|
|
501
|
+
}
|
|
502
|
+
} catch (error) {
|
|
503
|
+
if (error instanceof chunkELULXDSB_cjs.DynoTableError) throw error;
|
|
504
|
+
throw chunkELULXDSB_cjs.EntityErrors.keyGenerationFailed(
|
|
505
|
+
config.name,
|
|
506
|
+
"create",
|
|
507
|
+
dataForKeyGeneration,
|
|
508
|
+
extractRequiredAttributes(error),
|
|
509
|
+
error instanceof Error ? error : void 0
|
|
510
|
+
);
|
|
511
|
+
}
|
|
352
512
|
const indexes = buildIndexes(dataForKeyGeneration, table, config.indexes, false);
|
|
353
513
|
const validatedItem = {
|
|
354
514
|
...dataForKeyGeneration,
|
|
@@ -363,18 +523,31 @@ function defineEntity(config) {
|
|
|
363
523
|
const prepareValidatedItemSync = () => {
|
|
364
524
|
const validationResult = config.schema["~standard"].validate(data);
|
|
365
525
|
if (validationResult instanceof Promise) {
|
|
366
|
-
throw
|
|
367
|
-
"Async validation is not supported in withBatch or withTransaction. The schema must support synchronous validation for compatibility."
|
|
368
|
-
);
|
|
526
|
+
throw chunkELULXDSB_cjs.EntityErrors.asyncValidationNotSupported(config.name, "create");
|
|
369
527
|
}
|
|
370
528
|
if ("issues" in validationResult && validationResult.issues) {
|
|
371
|
-
throw
|
|
529
|
+
throw chunkELULXDSB_cjs.EntityErrors.validationFailed(config.name, "create", validationResult.issues, data);
|
|
372
530
|
}
|
|
373
531
|
const dataForKeyGeneration = {
|
|
374
532
|
...validationResult.value,
|
|
375
533
|
...generateTimestamps(["createdAt", "updatedAt"], validationResult.value)
|
|
376
534
|
};
|
|
377
|
-
|
|
535
|
+
let primaryKey;
|
|
536
|
+
try {
|
|
537
|
+
primaryKey = config.primaryKey.generateKey(dataForKeyGeneration);
|
|
538
|
+
if (primaryKey.pk === void 0 || primaryKey.pk === null) {
|
|
539
|
+
throw chunkELULXDSB_cjs.EntityErrors.keyInvalidFormat(config.name, "create", dataForKeyGeneration, primaryKey);
|
|
540
|
+
}
|
|
541
|
+
} catch (error) {
|
|
542
|
+
if (error instanceof chunkELULXDSB_cjs.DynoTableError) throw error;
|
|
543
|
+
throw chunkELULXDSB_cjs.EntityErrors.keyGenerationFailed(
|
|
544
|
+
config.name,
|
|
545
|
+
"create",
|
|
546
|
+
dataForKeyGeneration,
|
|
547
|
+
extractRequiredAttributes(error),
|
|
548
|
+
error instanceof Error ? error : void 0
|
|
549
|
+
);
|
|
550
|
+
}
|
|
378
551
|
const indexes = buildIndexes(dataForKeyGeneration, table, config.indexes, false);
|
|
379
552
|
const validatedItem = {
|
|
380
553
|
...dataForKeyGeneration,
|
|
@@ -410,13 +583,28 @@ function defineEntity(config) {
|
|
|
410
583
|
const prepareValidatedItemAsync = async () => {
|
|
411
584
|
const validatedData = await config.schema["~standard"].validate(data);
|
|
412
585
|
if ("issues" in validatedData && validatedData.issues) {
|
|
413
|
-
throw
|
|
586
|
+
throw chunkELULXDSB_cjs.EntityErrors.validationFailed(config.name, "upsert", validatedData.issues, data);
|
|
414
587
|
}
|
|
415
588
|
const dataForKeyGeneration = {
|
|
416
589
|
...validatedData.value,
|
|
417
590
|
...generateTimestamps(["createdAt", "updatedAt"], validatedData.value)
|
|
418
591
|
};
|
|
419
|
-
|
|
592
|
+
let primaryKey;
|
|
593
|
+
try {
|
|
594
|
+
primaryKey = config.primaryKey.generateKey(dataForKeyGeneration);
|
|
595
|
+
if (primaryKey.pk === void 0 || primaryKey.pk === null) {
|
|
596
|
+
throw chunkELULXDSB_cjs.EntityErrors.keyInvalidFormat(config.name, "upsert", dataForKeyGeneration, primaryKey);
|
|
597
|
+
}
|
|
598
|
+
} catch (error) {
|
|
599
|
+
if (error instanceof chunkELULXDSB_cjs.DynoTableError) throw error;
|
|
600
|
+
throw chunkELULXDSB_cjs.EntityErrors.keyGenerationFailed(
|
|
601
|
+
config.name,
|
|
602
|
+
"upsert",
|
|
603
|
+
dataForKeyGeneration,
|
|
604
|
+
extractRequiredAttributes(error),
|
|
605
|
+
error instanceof Error ? error : void 0
|
|
606
|
+
);
|
|
607
|
+
}
|
|
420
608
|
const indexes = buildIndexes2(dataForKeyGeneration, table, false);
|
|
421
609
|
const validatedItem = {
|
|
422
610
|
[table.partitionKey]: primaryKey.pk,
|
|
@@ -431,18 +619,31 @@ function defineEntity(config) {
|
|
|
431
619
|
const prepareValidatedItemSync = () => {
|
|
432
620
|
const validationResult = config.schema["~standard"].validate(data);
|
|
433
621
|
if (validationResult instanceof Promise) {
|
|
434
|
-
throw
|
|
435
|
-
"Async validation is not supported in withTransaction or withBatch. Use execute() instead."
|
|
436
|
-
);
|
|
622
|
+
throw chunkELULXDSB_cjs.EntityErrors.asyncValidationNotSupported(config.name, "upsert");
|
|
437
623
|
}
|
|
438
624
|
if ("issues" in validationResult && validationResult.issues) {
|
|
439
|
-
throw
|
|
625
|
+
throw chunkELULXDSB_cjs.EntityErrors.validationFailed(config.name, "upsert", validationResult.issues, data);
|
|
440
626
|
}
|
|
441
627
|
const dataForKeyGeneration = {
|
|
442
628
|
...validationResult.value,
|
|
443
629
|
...generateTimestamps(["createdAt", "updatedAt"], validationResult.value)
|
|
444
630
|
};
|
|
445
|
-
|
|
631
|
+
let primaryKey;
|
|
632
|
+
try {
|
|
633
|
+
primaryKey = config.primaryKey.generateKey(dataForKeyGeneration);
|
|
634
|
+
if (primaryKey.pk === void 0 || primaryKey.pk === null) {
|
|
635
|
+
throw chunkELULXDSB_cjs.EntityErrors.keyInvalidFormat(config.name, "upsert", dataForKeyGeneration, primaryKey);
|
|
636
|
+
}
|
|
637
|
+
} catch (error) {
|
|
638
|
+
if (error instanceof chunkELULXDSB_cjs.DynoTableError) throw error;
|
|
639
|
+
throw chunkELULXDSB_cjs.EntityErrors.keyGenerationFailed(
|
|
640
|
+
config.name,
|
|
641
|
+
"upsert",
|
|
642
|
+
dataForKeyGeneration,
|
|
643
|
+
extractRequiredAttributes(error),
|
|
644
|
+
error instanceof Error ? error : void 0
|
|
645
|
+
);
|
|
646
|
+
}
|
|
446
647
|
const indexes = buildIndexes(dataForKeyGeneration, table, config.indexes, false);
|
|
447
648
|
const validatedItem = {
|
|
448
649
|
[table.partitionKey]: primaryKey.pk,
|
|
@@ -459,7 +660,7 @@ function defineEntity(config) {
|
|
|
459
660
|
await prepareValidatedItemAsync();
|
|
460
661
|
const result = await originalExecute.call(builder);
|
|
461
662
|
if (!result) {
|
|
462
|
-
throw
|
|
663
|
+
throw chunkELULXDSB_cjs.OperationErrors.putFailed(config.name, {}, void 0);
|
|
463
664
|
}
|
|
464
665
|
return result;
|
|
465
666
|
};
|
|
@@ -478,7 +679,8 @@ function defineEntity(config) {
|
|
|
478
679
|
return createEntityAwarePutBuilder(builder, config.name);
|
|
479
680
|
},
|
|
480
681
|
get: (key) => {
|
|
481
|
-
|
|
682
|
+
const builder = table.get(config.primaryKey.generateKey(key));
|
|
683
|
+
return createEntityAwareGetBuilder(builder, config.name);
|
|
482
684
|
},
|
|
483
685
|
update: (key, data) => {
|
|
484
686
|
const primaryKeyObj = config.primaryKey.generateKey(key);
|
|
@@ -524,15 +726,13 @@ function defineEntity(config) {
|
|
|
524
726
|
if (schema?.["~standard"]?.validate && typeof schema["~standard"].validate === "function") {
|
|
525
727
|
const validationResult = schema["~standard"].validate(input);
|
|
526
728
|
if ("issues" in validationResult && validationResult.issues) {
|
|
527
|
-
throw
|
|
528
|
-
`Validation failed: ${validationResult.issues.map((issue) => issue.message).join(", ")}`
|
|
529
|
-
);
|
|
729
|
+
throw chunkELULXDSB_cjs.EntityErrors.queryInputValidationFailed(config.name, key, validationResult.issues, input);
|
|
530
730
|
}
|
|
531
731
|
}
|
|
532
732
|
}
|
|
533
733
|
const result = await originalExecute.call(builder);
|
|
534
734
|
if (!result) {
|
|
535
|
-
throw
|
|
735
|
+
throw chunkELULXDSB_cjs.OperationErrors.queryFailed(config.name, { queryName: key }, void 0);
|
|
536
736
|
}
|
|
537
737
|
return result;
|
|
538
738
|
};
|
|
@@ -578,7 +778,7 @@ function createIndex() {
|
|
|
578
778
|
generateKey: (item) => {
|
|
579
779
|
const data = schema["~standard"].validate(item);
|
|
580
780
|
if ("issues" in data && data.issues) {
|
|
581
|
-
throw
|
|
781
|
+
throw chunkELULXDSB_cjs.ValidationErrors.indexSchemaValidationFailed(data.issues, "both");
|
|
582
782
|
}
|
|
583
783
|
const validData = "value" in data ? data.value : item;
|
|
584
784
|
return { pk: pkFn(validData), sk: skFn(validData) };
|
|
@@ -599,7 +799,7 @@ function createIndex() {
|
|
|
599
799
|
generateKey: (item) => {
|
|
600
800
|
const data = schema["~standard"].validate(item);
|
|
601
801
|
if ("issues" in data && data.issues) {
|
|
602
|
-
throw
|
|
802
|
+
throw chunkELULXDSB_cjs.ValidationErrors.indexSchemaValidationFailed(data.issues, "partition");
|
|
603
803
|
}
|
|
604
804
|
const validData = "value" in data ? data.value : item;
|
|
605
805
|
return { pk: pkFn(validData) };
|
|
@@ -623,3 +823,24 @@ function createIndex() {
|
|
|
623
823
|
exports.createIndex = createIndex;
|
|
624
824
|
exports.createQueries = createQueries;
|
|
625
825
|
exports.defineEntity = defineEntity;
|
|
826
|
+
exports.extractRequiredAttributes = extractRequiredAttributes;
|
|
827
|
+
exports.formatErrorContext = formatErrorContext;
|
|
828
|
+
exports.getAwsErrorCode = getAwsErrorCode;
|
|
829
|
+
exports.getAwsErrorMessage = getAwsErrorMessage;
|
|
830
|
+
exports.getErrorSummary = getErrorSummary;
|
|
831
|
+
exports.isBatchError = isBatchError;
|
|
832
|
+
exports.isConditionalCheckFailed = isConditionalCheckFailed;
|
|
833
|
+
exports.isConfigurationError = isConfigurationError;
|
|
834
|
+
exports.isDynoTableError = isDynoTableError;
|
|
835
|
+
exports.isEntityError = isEntityError;
|
|
836
|
+
exports.isEntityValidationError = isEntityValidationError;
|
|
837
|
+
exports.isExpressionError = isExpressionError;
|
|
838
|
+
exports.isIndexGenerationError = isIndexGenerationError;
|
|
839
|
+
exports.isKeyGenerationError = isKeyGenerationError;
|
|
840
|
+
exports.isOperationError = isOperationError;
|
|
841
|
+
exports.isProvisionedThroughputExceeded = isProvisionedThroughputExceeded;
|
|
842
|
+
exports.isRetryableError = isRetryableError;
|
|
843
|
+
exports.isTransactionCanceled = isTransactionCanceled;
|
|
844
|
+
exports.isTransactionError = isTransactionError;
|
|
845
|
+
exports.isValidationError = isValidationError;
|
|
846
|
+
exports.isValidationException = isValidationException;
|
|
@@ -728,4 +728,4 @@ type PrimaryKeyWithoutExpression = {
|
|
|
728
728
|
sk?: string;
|
|
729
729
|
};
|
|
730
730
|
|
|
731
|
-
export { type ComparisonOperator as C, type ExpressionParams as E, type KeyConditionOperator as K, type LogicalOperator as L, type
|
|
731
|
+
export { type ComparisonOperator as C, type ExpressionParams as E, type KeyConditionOperator as K, type LogicalOperator as L, type PrimaryKeyWithoutExpression as P, type PrimaryKey as a, type Condition as b, type ConditionOperator as c, and as d, attributeExists as e, attributeNotExists as f, beginsWith as g, between as h, contains as i, eq as j, gt as k, gte as l, inArray as m, lt as n, lte as o, ne as p, not as q, or as r, type Path as s, type PathType as t, createComparisonCondition as u };
|
|
@@ -728,4 +728,4 @@ type PrimaryKeyWithoutExpression = {
|
|
|
728
728
|
sk?: string;
|
|
729
729
|
};
|
|
730
730
|
|
|
731
|
-
export { type ComparisonOperator as C, type ExpressionParams as E, type KeyConditionOperator as K, type LogicalOperator as L, type
|
|
731
|
+
export { type ComparisonOperator as C, type ExpressionParams as E, type KeyConditionOperator as K, type LogicalOperator as L, type PrimaryKeyWithoutExpression as P, type PrimaryKey as a, type Condition as b, type ConditionOperator as c, and as d, attributeExists as e, attributeNotExists as f, beginsWith as g, between as h, contains as i, eq as j, gt as k, gte as l, inArray as m, lt as n, lte as o, ne as p, not as q, or as r, type Path as s, type PathType as t, createComparisonCondition as u };
|
package/dist/conditions.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as ComparisonOperator,
|
|
1
|
+
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, u as createComparisonCondition, 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-C8bM__Pn.cjs';
|
|
2
2
|
import './types.cjs';
|
|
3
3
|
import '@aws-sdk/lib-dynamodb';
|
package/dist/conditions.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as ComparisonOperator,
|
|
1
|
+
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, u as createComparisonCondition, 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';
|
|
2
2
|
import './types.js';
|
|
3
3
|
import '@aws-sdk/lib-dynamodb';
|
package/dist/entity.cjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkZXM6LPRV_cjs = require('./chunk-ZXM6LPRV.cjs');
|
|
4
|
+
require('./chunk-ELULXDSB.cjs');
|
|
4
5
|
require('./chunk-7UJJ7JXM.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
Object.defineProperty(exports, "createIndex", {
|
|
9
10
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkZXM6LPRV_cjs.createIndex; }
|
|
11
12
|
});
|
|
12
13
|
Object.defineProperty(exports, "createQueries", {
|
|
13
14
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkZXM6LPRV_cjs.createQueries; }
|
|
15
16
|
});
|
|
16
17
|
Object.defineProperty(exports, "defineEntity", {
|
|
17
18
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkZXM6LPRV_cjs.defineEntity; }
|
|
19
20
|
});
|
package/dist/entity.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as Path, t as PathType,
|
|
2
|
-
import { P as PutBuilder, G as GetBuilder, U as UpdateBuilder,
|
|
1
|
+
import { s as Path, t as PathType, b as Condition, c as ConditionOperator, P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions-C8bM__Pn.cjs';
|
|
2
|
+
import { P as PutBuilder, G as GetBuilder, U as UpdateBuilder, p as UpdateCommandParams, T as TransactionBuilder, D as DeleteBuilder, S as ScanBuilder, Q as QueryBuilder } from './index-Ca76PpXj.cjs';
|
|
3
3
|
import { StandardSchemaV1 } from './standard-schema.cjs';
|
|
4
4
|
import { Table } from './table.cjs';
|
|
5
5
|
import { DynamoItem, Index, TableConfig } from './types.cjs';
|
package/dist/entity.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as Path, t as PathType,
|
|
2
|
-
import { P as PutBuilder, G as GetBuilder, U as UpdateBuilder,
|
|
1
|
+
import { s as Path, t as PathType, b as Condition, c as ConditionOperator, P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions-BSAcZswY.js';
|
|
2
|
+
import { P as PutBuilder, G as GetBuilder, U as UpdateBuilder, p as UpdateCommandParams, T as TransactionBuilder, D as DeleteBuilder, S as ScanBuilder, Q as QueryBuilder } from './index-C9KOQdSC.js';
|
|
3
3
|
import { StandardSchemaV1 } from './standard-schema.js';
|
|
4
4
|
import { Table } from './table.js';
|
|
5
5
|
import { DynamoItem, Index, TableConfig } from './types.js';
|
package/dist/entity.js
CHANGED