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.
package/dist/builders.cjs CHANGED
@@ -1,55 +1,56 @@
1
1
  'use strict';
2
2
 
3
- var chunkXYL43FDX_cjs = require('./chunk-XYL43FDX.cjs');
3
+ var chunkAHF4H42Q_cjs = require('./chunk-AHF4H42Q.cjs');
4
+ require('./chunk-ELULXDSB.cjs');
4
5
  require('./chunk-7UJJ7JXM.cjs');
5
6
 
6
7
 
7
8
 
8
9
  Object.defineProperty(exports, "BatchBuilder", {
9
10
  enumerable: true,
10
- get: function () { return chunkXYL43FDX_cjs.BatchBuilder; }
11
+ get: function () { return chunkAHF4H42Q_cjs.BatchBuilder; }
11
12
  });
12
13
  Object.defineProperty(exports, "ConditionCheckBuilder", {
13
14
  enumerable: true,
14
- get: function () { return chunkXYL43FDX_cjs.ConditionCheckBuilder; }
15
+ get: function () { return chunkAHF4H42Q_cjs.ConditionCheckBuilder; }
15
16
  });
16
17
  Object.defineProperty(exports, "DeleteBuilder", {
17
18
  enumerable: true,
18
- get: function () { return chunkXYL43FDX_cjs.DeleteBuilder; }
19
+ get: function () { return chunkAHF4H42Q_cjs.DeleteBuilder; }
19
20
  });
20
21
  Object.defineProperty(exports, "FilterBuilder", {
21
22
  enumerable: true,
22
- get: function () { return chunkXYL43FDX_cjs.FilterBuilder; }
23
+ get: function () { return chunkAHF4H42Q_cjs.FilterBuilder; }
23
24
  });
24
25
  Object.defineProperty(exports, "GetBuilder", {
25
26
  enumerable: true,
26
- get: function () { return chunkXYL43FDX_cjs.GetBuilder; }
27
+ get: function () { return chunkAHF4H42Q_cjs.GetBuilder; }
27
28
  });
28
29
  Object.defineProperty(exports, "Paginator", {
29
30
  enumerable: true,
30
- get: function () { return chunkXYL43FDX_cjs.Paginator; }
31
+ get: function () { return chunkAHF4H42Q_cjs.Paginator; }
31
32
  });
32
33
  Object.defineProperty(exports, "PutBuilder", {
33
34
  enumerable: true,
34
- get: function () { return chunkXYL43FDX_cjs.PutBuilder; }
35
+ get: function () { return chunkAHF4H42Q_cjs.PutBuilder; }
35
36
  });
36
37
  Object.defineProperty(exports, "QueryBuilder", {
37
38
  enumerable: true,
38
- get: function () { return chunkXYL43FDX_cjs.QueryBuilder; }
39
+ get: function () { return chunkAHF4H42Q_cjs.QueryBuilder; }
39
40
  });
40
41
  Object.defineProperty(exports, "ResultIterator", {
41
42
  enumerable: true,
42
- get: function () { return chunkXYL43FDX_cjs.ResultIterator; }
43
+ get: function () { return chunkAHF4H42Q_cjs.ResultIterator; }
43
44
  });
44
45
  Object.defineProperty(exports, "ScanBuilder", {
45
46
  enumerable: true,
46
- get: function () { return chunkXYL43FDX_cjs.ScanBuilder; }
47
+ get: function () { return chunkAHF4H42Q_cjs.ScanBuilder; }
47
48
  });
48
49
  Object.defineProperty(exports, "TransactionBuilder", {
49
50
  enumerable: true,
50
- get: function () { return chunkXYL43FDX_cjs.TransactionBuilder; }
51
+ get: function () { return chunkAHF4H42Q_cjs.TransactionBuilder; }
51
52
  });
52
53
  Object.defineProperty(exports, "UpdateBuilder", {
53
54
  enumerable: true,
54
- get: function () { return chunkXYL43FDX_cjs.UpdateBuilder; }
55
+ get: function () { return chunkAHF4H42Q_cjs.UpdateBuilder; }
55
56
  });
@@ -1,4 +1,4 @@
1
- export { n as BaseBuilderInterface, B as BatchBuilder, C as ConditionCheckBuilder, m as ConditionCheckCommandParams, D as DeleteBuilder, k as DeleteCommandParams, F as FilterBuilder, q as FilterBuilderInterface, G as GetBuilder, r as PaginationResult, j as Paginator, P as PutBuilder, l as PutCommandParams, Q as QueryBuilder, o as QueryBuilderInterface, R as ResultIterator, S as ScanBuilder, p as ScanBuilderInterface, T as TransactionBuilder, s as TransactionItem, U as UpdateBuilder, i as UpdateCommandParams } from './index-DlN8G9hd.cjs';
2
- export { s as Path, t as PathType } from './conditions-CcZL0sR2.cjs';
1
+ export { u as BaseBuilderInterface, B as BatchBuilder, C as ConditionCheckBuilder, t as ConditionCheckCommandParams, D as DeleteBuilder, r as DeleteCommandParams, F as FilterBuilder, x as FilterBuilderInterface, G as GetBuilder, y as PaginationResult, q as Paginator, P as PutBuilder, s as PutCommandParams, Q as QueryBuilder, v as QueryBuilderInterface, R as ResultIterator, S as ScanBuilder, w as ScanBuilderInterface, T as TransactionBuilder, z as TransactionItem, U as UpdateBuilder, p as UpdateCommandParams } from './index-BX-MSZHj.cjs';
2
+ export { s as Path, t as PathType } from './conditions-C8bM__Pn.cjs';
3
3
  import './types.cjs';
4
4
  import '@aws-sdk/lib-dynamodb';
@@ -1,4 +1,4 @@
1
- export { n as BaseBuilderInterface, B as BatchBuilder, C as ConditionCheckBuilder, m as ConditionCheckCommandParams, D as DeleteBuilder, k as DeleteCommandParams, F as FilterBuilder, q as FilterBuilderInterface, G as GetBuilder, r as PaginationResult, j as Paginator, P as PutBuilder, l as PutCommandParams, Q as QueryBuilder, o as QueryBuilderInterface, R as ResultIterator, S as ScanBuilder, p as ScanBuilderInterface, T as TransactionBuilder, s as TransactionItem, U as UpdateBuilder, i as UpdateCommandParams } from './index-2cbm07Bi.js';
2
- export { s as Path, t as PathType } from './conditions-D_w7vVYG.js';
1
+ export { u as BaseBuilderInterface, B as BatchBuilder, C as ConditionCheckBuilder, t as ConditionCheckCommandParams, D as DeleteBuilder, r as DeleteCommandParams, F as FilterBuilder, x as FilterBuilderInterface, G as GetBuilder, y as PaginationResult, q as Paginator, P as PutBuilder, s as PutCommandParams, Q as QueryBuilder, v as QueryBuilderInterface, R as ResultIterator, S as ScanBuilder, w as ScanBuilderInterface, T as TransactionBuilder, z as TransactionItem, U as UpdateBuilder, p as UpdateCommandParams } from './index-DdTolMJW.js';
2
+ export { s as Path, t as PathType } from './conditions-BSAcZswY.js';
3
3
  import './types.js';
4
4
  import '@aws-sdk/lib-dynamodb';
package/dist/builders.js CHANGED
@@ -1,2 +1,3 @@
1
- export { BatchBuilder, ConditionCheckBuilder, DeleteBuilder, FilterBuilder, GetBuilder, Paginator, PutBuilder, QueryBuilder, ResultIterator, ScanBuilder, TransactionBuilder, UpdateBuilder } from './chunk-DTFJJASK.js';
1
+ export { BatchBuilder, ConditionCheckBuilder, DeleteBuilder, FilterBuilder, GetBuilder, Paginator, PutBuilder, QueryBuilder, ResultIterator, ScanBuilder, TransactionBuilder, UpdateBuilder } from './chunk-GWHGUKAL.js';
2
+ import './chunk-FF7FYGDH.js';
2
3
  import './chunk-2WIBY7PZ.js';
@@ -1,10 +1,11 @@
1
- import { GetBuilder, PutBuilder, QueryBuilder, ScanBuilder, DeleteBuilder, UpdateBuilder, TransactionBuilder, BatchBuilder, ConditionCheckBuilder, buildExpression, generateAttributeName, debugCommand } from './chunk-DTFJJASK.js';
1
+ import { GetBuilder, PutBuilder, QueryBuilder, ScanBuilder, DeleteBuilder, UpdateBuilder, TransactionBuilder, BatchBuilder, ConditionCheckBuilder, buildExpression, generateAttributeName } from './chunk-GWHGUKAL.js';
2
+ import { ConfigurationErrors, OperationErrors } from './chunk-FF7FYGDH.js';
2
3
  import { eq, and, beginsWith, between, gte, gt, lte, lt } from './chunk-2WIBY7PZ.js';
3
4
 
4
5
  // src/utils/chunk-array.ts
5
6
  function* chunkArray(array, size) {
6
7
  if (size <= 0) {
7
- throw new Error("Chunk size must be greater than 0");
8
+ throw ConfigurationErrors.invalidChunkSize(size);
8
9
  }
9
10
  for (let i = 0; i < array.length; i += size) {
10
11
  yield array.slice(i, i + size);
@@ -40,7 +41,7 @@ var Table = class {
40
41
  const primaryCondition = { [this.partitionKey]: keyCondition.pk };
41
42
  if (this.sortKey) {
42
43
  if (!keyCondition.sk) {
43
- throw new Error("Sort key has not been provided but the Table has a sort key");
44
+ throw ConfigurationErrors.sortKeyRequired(this.tableName, this.partitionKey, this.sortKey);
44
45
  }
45
46
  primaryCondition[this.sortKey] = keyCondition.sk;
46
47
  }
@@ -94,8 +95,7 @@ var Table = class {
94
95
  item: result.Item ? result.Item : void 0
95
96
  };
96
97
  } catch (error) {
97
- console.error("Error getting item:", error);
98
- throw error;
98
+ throw OperationErrors.getFailed(params.tableName, keyCondition, error instanceof Error ? error : void 0);
99
99
  }
100
100
  };
101
101
  return new GetBuilder(executor, keyCondition, this.tableName);
@@ -135,8 +135,7 @@ var Table = class {
135
135
  }
136
136
  return result.Attributes;
137
137
  } catch (error) {
138
- console.error("Error creating item:", error);
139
- throw error;
138
+ throw OperationErrors.putFailed(params.tableName, params.item, error instanceof Error ? error : void 0);
140
139
  }
141
140
  };
142
141
  return new PutBuilder(executor, item, this.tableName);
@@ -151,7 +150,7 @@ var Table = class {
151
150
  let keyConditionExpression = eq(pkAttributeName, keyCondition.pk);
152
151
  if (keyCondition.sk) {
153
152
  if (!skAttributeName) {
154
- throw new Error("Sort key is not defined for Index");
153
+ throw ConfigurationErrors.sortKeyNotDefined(this.tableName, pkAttributeName);
155
154
  }
156
155
  const keyConditionOperator = {
157
156
  eq: (value) => eq(skAttributeName, value),
@@ -172,7 +171,7 @@ var Table = class {
172
171
  const gsiName = String(options.indexName);
173
172
  const gsi = this.gsis[gsiName];
174
173
  if (!gsi) {
175
- throw new Error(`GSI with name "${gsiName}" does not exist on table "${this.tableName}"`);
174
+ throw ConfigurationErrors.gsiNotFound(gsiName, this.tableName, Object.keys(this.gsis));
176
175
  }
177
176
  const gsiPkAttributeName = gsi.partitionKey;
178
177
  const gsiSkAttributeName = gsi.sortKey;
@@ -201,7 +200,7 @@ var Table = class {
201
200
  }
202
201
  }
203
202
  if (!pkValue) {
204
- throw new Error("Could not extract partition key value from key condition");
203
+ throw ConfigurationErrors.pkExtractionFailed(this.tableName, options.indexName, originalKeyCondition);
205
204
  }
206
205
  let gsiKeyCondition = eq(gsiPkAttributeName, pkValue);
207
206
  if (skValue && gsiSkAttributeName) {
@@ -252,9 +251,11 @@ var Table = class {
252
251
  lastEvaluatedKey: result.LastEvaluatedKey
253
252
  };
254
253
  } catch (error) {
255
- console.log(debugCommand(params));
256
- console.error("Error querying items:", error);
257
- throw error;
254
+ throw OperationErrors.queryFailed(
255
+ this.tableName,
256
+ { indexName, keyConditionExpression: keyConditionExpression2, filterExpression },
257
+ error instanceof Error ? error : void 0
258
+ );
258
259
  }
259
260
  };
260
261
  return new QueryBuilder(executor, keyConditionExpression);
@@ -300,9 +301,11 @@ var Table = class {
300
301
  lastEvaluatedKey: result.LastEvaluatedKey
301
302
  };
302
303
  } catch (error) {
303
- console.log(debugCommand(params));
304
- console.error("Error scanning items:", error);
305
- throw error;
304
+ throw OperationErrors.scanFailed(
305
+ this.tableName,
306
+ { indexName: options.indexName, filterExpression },
307
+ error instanceof Error ? error : void 0
308
+ );
306
309
  }
307
310
  };
308
311
  return new ScanBuilder(executor);
@@ -322,8 +325,7 @@ var Table = class {
322
325
  item: result.Attributes
323
326
  };
324
327
  } catch (error) {
325
- console.error("Error deleting item:", error);
326
- throw error;
328
+ throw OperationErrors.deleteFailed(params.tableName, keyCondition, error instanceof Error ? error : void 0);
327
329
  }
328
330
  };
329
331
  return new DeleteBuilder(executor, this.tableName, keyCondition);
@@ -350,8 +352,7 @@ var Table = class {
350
352
  item: result.Attributes
351
353
  };
352
354
  } catch (error) {
353
- console.error("Error updating item:", error);
354
- throw error;
355
+ throw OperationErrors.updateFailed(params.tableName, keyCondition, error instanceof Error ? error : void 0);
355
356
  }
356
357
  };
357
358
  return new UpdateBuilder(executor, this.tableName, keyCondition);
@@ -483,8 +484,11 @@ var Table = class {
483
484
  allUnprocessedKeys.push(...unprocessedKeys);
484
485
  }
485
486
  } catch (error) {
486
- console.error("Error in batch get operation:", error);
487
- throw error;
487
+ throw OperationErrors.batchGetFailed(
488
+ this.tableName,
489
+ { requestedKeys: keys.length },
490
+ error instanceof Error ? error : void 0
491
+ );
488
492
  }
489
493
  }
490
494
  return {
@@ -545,8 +549,11 @@ var Table = class {
545
549
  allUnprocessedItems.push(...unprocessedItems);
546
550
  }
547
551
  } catch (error) {
548
- console.error("Error in batch write operation:", error);
549
- throw error;
552
+ throw OperationErrors.batchWriteFailed(
553
+ this.tableName,
554
+ { requestedOperations: operations.length },
555
+ error instanceof Error ? error : void 0
556
+ );
550
557
  }
551
558
  }
552
559
  return {