dyno-table 0.2.0-0 → 1.0.0-alpha.1

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 (96) hide show
  1. package/README.md +182 -577
  2. package/dist/{table.cjs → index.cjs} +175 -87
  3. package/dist/index.d.cts +2971 -0
  4. package/dist/index.d.ts +2971 -0
  5. package/dist/{table.js → index.js} +127 -86
  6. package/package.json +10 -77
  7. package/dist/builder-types-C_PDZhnP.d.ts +0 -118
  8. package/dist/builder-types-DtwbqMeF.d.cts +0 -118
  9. package/dist/builders/condition-check-builder.cjs +0 -394
  10. package/dist/builders/condition-check-builder.cjs.map +0 -1
  11. package/dist/builders/condition-check-builder.d.cts +0 -157
  12. package/dist/builders/condition-check-builder.d.ts +0 -157
  13. package/dist/builders/condition-check-builder.js +0 -392
  14. package/dist/builders/condition-check-builder.js.map +0 -1
  15. package/dist/builders/delete-builder.cjs +0 -405
  16. package/dist/builders/delete-builder.cjs.map +0 -1
  17. package/dist/builders/delete-builder.d.cts +0 -166
  18. package/dist/builders/delete-builder.d.ts +0 -166
  19. package/dist/builders/delete-builder.js +0 -403
  20. package/dist/builders/delete-builder.js.map +0 -1
  21. package/dist/builders/paginator.cjs +0 -199
  22. package/dist/builders/paginator.cjs.map +0 -1
  23. package/dist/builders/paginator.d.cts +0 -179
  24. package/dist/builders/paginator.d.ts +0 -179
  25. package/dist/builders/paginator.js +0 -197
  26. package/dist/builders/paginator.js.map +0 -1
  27. package/dist/builders/put-builder.cjs +0 -476
  28. package/dist/builders/put-builder.cjs.map +0 -1
  29. package/dist/builders/put-builder.d.cts +0 -274
  30. package/dist/builders/put-builder.d.ts +0 -274
  31. package/dist/builders/put-builder.js +0 -474
  32. package/dist/builders/put-builder.js.map +0 -1
  33. package/dist/builders/query-builder.cjs +0 -674
  34. package/dist/builders/query-builder.cjs.map +0 -1
  35. package/dist/builders/query-builder.d.cts +0 -6
  36. package/dist/builders/query-builder.d.ts +0 -6
  37. package/dist/builders/query-builder.js +0 -672
  38. package/dist/builders/query-builder.js.map +0 -1
  39. package/dist/builders/transaction-builder.cjs +0 -894
  40. package/dist/builders/transaction-builder.cjs.map +0 -1
  41. package/dist/builders/transaction-builder.d.cts +0 -511
  42. package/dist/builders/transaction-builder.d.ts +0 -511
  43. package/dist/builders/transaction-builder.js +0 -892
  44. package/dist/builders/transaction-builder.js.map +0 -1
  45. package/dist/builders/update-builder.cjs +0 -627
  46. package/dist/builders/update-builder.cjs.map +0 -1
  47. package/dist/builders/update-builder.d.cts +0 -365
  48. package/dist/builders/update-builder.d.ts +0 -365
  49. package/dist/builders/update-builder.js +0 -625
  50. package/dist/builders/update-builder.js.map +0 -1
  51. package/dist/conditions--ld9a78i.d.ts +0 -331
  52. package/dist/conditions-ChhQWd6z.d.cts +0 -331
  53. package/dist/conditions.cjs +0 -59
  54. package/dist/conditions.cjs.map +0 -1
  55. package/dist/conditions.d.cts +0 -3
  56. package/dist/conditions.d.ts +0 -3
  57. package/dist/conditions.js +0 -43
  58. package/dist/conditions.js.map +0 -1
  59. package/dist/entity.cjs +0 -228
  60. package/dist/entity.cjs.map +0 -1
  61. package/dist/entity.d.cts +0 -149
  62. package/dist/entity.d.ts +0 -149
  63. package/dist/entity.js +0 -224
  64. package/dist/entity.js.map +0 -1
  65. package/dist/query-builder-Csror9Iu.d.ts +0 -507
  66. package/dist/query-builder-D2FM9rsu.d.cts +0 -507
  67. package/dist/standard-schema.cjs +0 -4
  68. package/dist/standard-schema.cjs.map +0 -1
  69. package/dist/standard-schema.d.cts +0 -57
  70. package/dist/standard-schema.d.ts +0 -57
  71. package/dist/standard-schema.js +0 -3
  72. package/dist/standard-schema.js.map +0 -1
  73. package/dist/table-BEhBPy2G.d.cts +0 -364
  74. package/dist/table-BW3cmUqr.d.ts +0 -364
  75. package/dist/table.cjs.map +0 -1
  76. package/dist/table.d.cts +0 -12
  77. package/dist/table.d.ts +0 -12
  78. package/dist/table.js.map +0 -1
  79. package/dist/types.cjs +0 -4
  80. package/dist/types.cjs.map +0 -1
  81. package/dist/types.d.cts +0 -22
  82. package/dist/types.d.ts +0 -22
  83. package/dist/types.js +0 -3
  84. package/dist/types.js.map +0 -1
  85. package/dist/utils/partition-key-template.cjs +0 -19
  86. package/dist/utils/partition-key-template.cjs.map +0 -1
  87. package/dist/utils/partition-key-template.d.cts +0 -32
  88. package/dist/utils/partition-key-template.d.ts +0 -32
  89. package/dist/utils/partition-key-template.js +0 -17
  90. package/dist/utils/partition-key-template.js.map +0 -1
  91. package/dist/utils/sort-key-template.cjs +0 -19
  92. package/dist/utils/sort-key-template.cjs.map +0 -1
  93. package/dist/utils/sort-key-template.d.cts +0 -35
  94. package/dist/utils/sort-key-template.d.ts +0 -35
  95. package/dist/utils/sort-key-template.js +0 -17
  96. package/dist/utils/sort-key-template.js.map +0 -1
@@ -861,14 +861,6 @@ var PutBuilder = class {
861
861
  returnValues: "NONE"
862
862
  };
863
863
  }
864
- set(valuesOrPath, value) {
865
- if (typeof valuesOrPath === "object") {
866
- Object.assign(this.item, valuesOrPath);
867
- } else {
868
- this.item[valuesOrPath] = value;
869
- }
870
- return this;
871
- }
872
864
  /**
873
865
  * Adds a condition that must be satisfied for the put operation to succeed.
874
866
  * Use this method when you need to:
@@ -1113,6 +1105,10 @@ var DeleteBuilder = class {
1113
1105
  }
1114
1106
  /**
1115
1107
  * Adds a condition that must be satisfied for the delete operation to succeed.
1108
+ * Use this method when you need to:
1109
+ * - Ensure safe removal conditions
1110
+ * - Verify habitat status before deletion
1111
+ * - Implement safety protocols
1116
1112
  *
1117
1113
  * @example
1118
1114
  * ```typescript
@@ -1164,6 +1160,10 @@ var DeleteBuilder = class {
1164
1160
  }
1165
1161
  /**
1166
1162
  * Sets whether to return the item's attribute values before deletion.
1163
+ * Use this method when you need to:
1164
+ * - Archive removed dinosaur data
1165
+ * - Track habitat decommissioning history
1166
+ * - Maintain removal audit logs
1167
1167
  *
1168
1168
  * @example
1169
1169
  * ```ts
@@ -1204,6 +1204,10 @@ var DeleteBuilder = class {
1204
1204
  }
1205
1205
  /**
1206
1206
  * Adds this delete operation to a transaction.
1207
+ * Use this method when you need to:
1208
+ * - Coordinate dinosaur transfers
1209
+ * - Manage habitat decommissioning
1210
+ * - Handle species relocations
1207
1211
  *
1208
1212
  * @example
1209
1213
  * ```ts
@@ -1254,6 +1258,11 @@ var DeleteBuilder = class {
1254
1258
  /**
1255
1259
  * Gets a human-readable representation of the delete command
1256
1260
  * with all expression placeholders replaced by their actual values.
1261
+ * Use this method when you need to:
1262
+ * - Debug complex deletion conditions
1263
+ * - Verify safety checks
1264
+ * - Log removal operations
1265
+ * - Troubleshoot failed deletions
1257
1266
  *
1258
1267
  * @example
1259
1268
  * ```ts
@@ -1312,6 +1321,10 @@ var UpdateBuilder = class {
1312
1321
  }
1313
1322
  /**
1314
1323
  * Removes an attribute from the item.
1324
+ * Use this method when you need to:
1325
+ * - Delete attributes completely
1326
+ * - Remove nested attributes
1327
+ * - Clean up deprecated fields
1315
1328
  *
1316
1329
  * @example
1317
1330
  * ```typescript
@@ -1338,6 +1351,10 @@ var UpdateBuilder = class {
1338
1351
  }
1339
1352
  /**
1340
1353
  * Adds a value to a number attribute or adds elements to a set.
1354
+ * Use this method when you need to:
1355
+ * - Increment counters
1356
+ * - Add elements to a set atomically
1357
+ * - Update numerical statistics
1341
1358
  *
1342
1359
  * @example
1343
1360
  * ```typescript
@@ -1366,6 +1383,10 @@ var UpdateBuilder = class {
1366
1383
  }
1367
1384
  /**
1368
1385
  * Removes elements from a set attribute.
1386
+ * Use this method when you need to:
1387
+ * - Remove specific elements from a set
1388
+ * - Update set-based attributes atomically
1389
+ * - Maintain set membership
1369
1390
  *
1370
1391
  * @example
1371
1392
  * ```typescript
@@ -1375,7 +1396,7 @@ var UpdateBuilder = class {
1375
1396
  * ['JUNGLE', 'COASTAL']
1376
1397
  * );
1377
1398
  *
1378
- * // Remove from sets using Set DynamoItems
1399
+ * // Remove from sets using Set objects
1379
1400
  * builder.deleteElementsFromSet(
1380
1401
  * 'knownBehaviors',
1381
1402
  * new Set(['NOCTURNAL', 'TERRITORIAL'])
@@ -1408,6 +1429,11 @@ var UpdateBuilder = class {
1408
1429
  }
1409
1430
  /**
1410
1431
  * Adds a condition that must be satisfied for the update to succeed.
1432
+ * Use this method when you need to:
1433
+ * - Implement optimistic locking
1434
+ * - Ensure item state before update
1435
+ * - Validate business rules
1436
+ * - Prevent concurrent modifications
1411
1437
  *
1412
1438
  * @example
1413
1439
  * ```typescript
@@ -1439,7 +1465,7 @@ var UpdateBuilder = class {
1439
1465
  * );
1440
1466
  * ```
1441
1467
  *
1442
- * @param condition - Either a Condition DynamoItem or a callback function that builds the condition
1468
+ * @param condition - Either a Condition object or a callback function that builds the condition
1443
1469
  * @returns The builder instance for method chaining
1444
1470
  */
1445
1471
  condition(condition) {
@@ -1468,6 +1494,11 @@ var UpdateBuilder = class {
1468
1494
  }
1469
1495
  /**
1470
1496
  * Sets which item attributes to include in the response.
1497
+ * Use this method when you need to:
1498
+ * - Get the complete updated item
1499
+ * - Track changes to specific attributes
1500
+ * - Compare old and new values
1501
+ * - Monitor attribute modifications
1471
1502
  *
1472
1503
  * Available options:
1473
1504
  * - ALL_NEW: All attributes after the update
@@ -1595,6 +1626,10 @@ var UpdateBuilder = class {
1595
1626
  }
1596
1627
  /**
1597
1628
  * Adds this update operation to a transaction.
1629
+ * Use this method when you need to:
1630
+ * - Update items as part of a larger transaction
1631
+ * - Ensure multiple updates are atomic
1632
+ * - Coordinate updates across multiple items
1598
1633
  *
1599
1634
  * @example
1600
1635
  * ```typescript
@@ -1624,6 +1659,11 @@ var UpdateBuilder = class {
1624
1659
  }
1625
1660
  /**
1626
1661
  * Gets a human-readable representation of the update command.
1662
+ * Use this method when you need to:
1663
+ * - Debug complex update expressions
1664
+ * - Verify attribute names and values
1665
+ * - Log update operations
1666
+ * - Troubleshoot condition expressions
1627
1667
  *
1628
1668
  * @example
1629
1669
  * ```typescript
@@ -1650,6 +1690,10 @@ var UpdateBuilder = class {
1650
1690
  }
1651
1691
  /**
1652
1692
  * Executes the update operation against DynamoDB.
1693
+ * Use this method when you need to:
1694
+ * - Apply updates immediately
1695
+ * - Get the updated item values
1696
+ * - Handle conditional update failures
1653
1697
  *
1654
1698
  * @example
1655
1699
  * ```typescript
@@ -1684,7 +1728,7 @@ var UpdateBuilder = class {
1684
1728
  * }
1685
1729
  * ```
1686
1730
  *
1687
- * @returns A promise that resolves to an DynamoItem containing the updated item (if returnValues is set)
1731
+ * @returns A promise that resolves to an object containing the updated item (if returnValues is set)
1688
1732
  * @throws {ConditionalCheckFailedException} If the condition check fails
1689
1733
  * @throws {Error} If the update operation fails for other reasons
1690
1734
  */
@@ -1738,7 +1782,7 @@ var TransactionBuilder = class {
1738
1782
  */
1739
1783
  checkForDuplicateItem(tableName, newItem) {
1740
1784
  const pkName = this.indexConfig.partitionKey;
1741
- const skName = this.indexConfig.sortKey ?? "";
1785
+ const skName = this.indexConfig.sortKey || "";
1742
1786
  const pkValue = newItem[pkName];
1743
1787
  const skValue = skName ? newItem[skName] : void 0;
1744
1788
  if (!pkValue) {
@@ -1779,18 +1823,6 @@ var TransactionBuilder = class {
1779
1823
  );
1780
1824
  }
1781
1825
  }
1782
- createKeyForPrimaryIndex(key) {
1783
- const keyCondition = {
1784
- [this.indexConfig.partitionKey]: key.pk
1785
- };
1786
- if (this.indexConfig.sortKey) {
1787
- if (key.sk === void 0) {
1788
- throw new Error("Sort key is required for delete operation");
1789
- }
1790
- keyCondition[this.indexConfig.sortKey] = key.sk;
1791
- }
1792
- return keyCondition;
1793
- }
1794
1826
  /**
1795
1827
  * Adds a put operation to the transaction.
1796
1828
  * Use this method when you need to:
@@ -1930,13 +1962,15 @@ var TransactionBuilder = class {
1930
1962
  * @throws {Error} If a duplicate item is detected in the transaction
1931
1963
  */
1932
1964
  delete(tableName, key, condition) {
1933
- const keyCondition = this.createKeyForPrimaryIndex(key);
1934
- this.checkForDuplicateItem(tableName, keyCondition);
1965
+ this.checkForDuplicateItem(tableName, key);
1935
1966
  const transactionItem = {
1936
1967
  type: "Delete",
1937
1968
  params: {
1938
1969
  tableName,
1939
- key: keyCondition
1970
+ key: {
1971
+ pk: key.pk,
1972
+ sk: key.sk
1973
+ }
1940
1974
  }
1941
1975
  };
1942
1976
  if (condition) {
@@ -1978,14 +2012,10 @@ var TransactionBuilder = class {
1978
2012
  * @see DeleteBuilder for creating delete commands
1979
2013
  */
1980
2014
  deleteWithCommand(command) {
1981
- const keyCondition = this.createKeyForPrimaryIndex(command.key);
1982
- this.checkForDuplicateItem(command.tableName, keyCondition);
2015
+ this.checkForDuplicateItem(command.tableName, command.key);
1983
2016
  const transactionItem = {
1984
2017
  type: "Delete",
1985
- params: {
1986
- ...command,
1987
- key: keyCondition
1988
- }
2018
+ params: command
1989
2019
  };
1990
2020
  this.items.push(transactionItem);
1991
2021
  return this;
@@ -2045,13 +2075,15 @@ var TransactionBuilder = class {
2045
2075
  * @throws {Error} If a duplicate item is detected in the transaction
2046
2076
  */
2047
2077
  update(tableName, key, updateExpression, expressionAttributeNames, expressionAttributeValues, condition) {
2048
- const keyCondition = this.createKeyForPrimaryIndex(key);
2049
- this.checkForDuplicateItem(tableName, keyCondition);
2078
+ this.checkForDuplicateItem(tableName, key);
2050
2079
  const transactionItem = {
2051
2080
  type: "Update",
2052
2081
  params: {
2053
2082
  tableName,
2054
- key: keyCondition,
2083
+ key: {
2084
+ pk: key.pk,
2085
+ sk: key.sk
2086
+ },
2055
2087
  updateExpression,
2056
2088
  expressionAttributeNames,
2057
2089
  expressionAttributeValues
@@ -2105,14 +2137,10 @@ var TransactionBuilder = class {
2105
2137
  * @see UpdateBuilder for creating update commands
2106
2138
  */
2107
2139
  updateWithCommand(command) {
2108
- const keyCondition = this.createKeyForPrimaryIndex(command.key);
2109
- this.checkForDuplicateItem(command.tableName, keyCondition);
2140
+ this.checkForDuplicateItem(command.tableName, command.key);
2110
2141
  const transactionItem = {
2111
2142
  type: "Update",
2112
- params: {
2113
- ...command,
2114
- key: keyCondition
2115
- }
2143
+ params: command
2116
2144
  };
2117
2145
  this.items.push(transactionItem);
2118
2146
  return this;
@@ -2169,8 +2197,7 @@ var TransactionBuilder = class {
2169
2197
  * @throws {Error} If condition expression generation fails
2170
2198
  */
2171
2199
  conditionCheck(tableName, key, condition) {
2172
- const keyCondition = this.createKeyForPrimaryIndex(key);
2173
- this.checkForDuplicateItem(tableName, keyCondition);
2200
+ this.checkForDuplicateItem(tableName, key);
2174
2201
  const { expression, names, values } = prepareExpressionParams(condition);
2175
2202
  if (!expression) {
2176
2203
  throw new Error("Failed to generate condition expression");
@@ -2179,7 +2206,10 @@ var TransactionBuilder = class {
2179
2206
  type: "ConditionCheck",
2180
2207
  params: {
2181
2208
  tableName,
2182
- key: keyCondition,
2209
+ key: {
2210
+ pk: key.pk,
2211
+ sk: key.sk
2212
+ },
2183
2213
  conditionExpression: expression,
2184
2214
  expressionAttributeNames: names,
2185
2215
  expressionAttributeValues: values
@@ -2219,14 +2249,10 @@ var TransactionBuilder = class {
2219
2249
  * @see ConditionCheckBuilder for creating condition check commands
2220
2250
  */
2221
2251
  conditionCheckWithCommand(command) {
2222
- const keyCondition = this.createKeyForPrimaryIndex(command.key);
2223
- this.checkForDuplicateItem(command.tableName, keyCondition);
2252
+ this.checkForDuplicateItem(command.tableName, command.key);
2224
2253
  const transactionItem = {
2225
2254
  type: "ConditionCheck",
2226
- params: {
2227
- ...command,
2228
- key: keyCondition
2229
- }
2255
+ params: command
2230
2256
  };
2231
2257
  this.items.push(transactionItem);
2232
2258
  return this;
@@ -2459,7 +2485,7 @@ var ConditionCheckBuilder = class {
2459
2485
  * );
2460
2486
  * ```
2461
2487
  *
2462
- * @param condition - Either a Condition DynamoItem or a callback function that builds the condition
2488
+ * @param condition - Either a Condition object or a callback function that builds the condition
2463
2489
  * @returns The builder instance for method chaining
2464
2490
  */
2465
2491
  condition(condition) {
@@ -2685,18 +2711,18 @@ var GetBuilder = class {
2685
2711
  * - item: The retrieved dinosaur or undefined if not found
2686
2712
  */
2687
2713
  async execute() {
2688
- const expressionParams = {
2689
- expressionAttributeNames: {},
2690
- expressionAttributeValues: {},
2691
- valueCounter: { count: 0 }
2692
- };
2693
- const projectionExpression = Array.from(this.selectedFields).map((p) => generateAttributeName(expressionParams, p)).join(", ");
2694
- const { expressionAttributeNames } = expressionParams;
2695
- return this.executor({
2696
- ...this.params,
2697
- projectionExpression: projectionExpression.length > 0 ? projectionExpression : void 0,
2698
- expressionAttributeNames: Object.keys(expressionAttributeNames).length > 0 ? expressionAttributeNames : void 0
2699
- });
2714
+ if (this.selectedFields.size > 0) {
2715
+ const expressionAttributeNames = {};
2716
+ const projectionParts = [];
2717
+ for (const path of this.selectedFields) {
2718
+ const attrName = `#attr${projectionParts.length}`;
2719
+ expressionAttributeNames[attrName] = path;
2720
+ projectionParts.push(attrName);
2721
+ }
2722
+ this.params.projectionExpression = projectionParts.join(", ");
2723
+ this.params.expressionAttributeNames = expressionAttributeNames;
2724
+ }
2725
+ return this.executor(this.params);
2700
2726
  }
2701
2727
  };
2702
2728
 
@@ -2791,16 +2817,6 @@ var Table = class {
2791
2817
  this.sortKey = config.indexes.sortKey;
2792
2818
  this.gsis = config.indexes.gsis || {};
2793
2819
  }
2794
- createKeyForPrimaryIndex(keyCondition) {
2795
- const primaryCondition = { [this.partitionKey]: keyCondition.pk };
2796
- if (this.sortKey) {
2797
- if (!keyCondition.sk) {
2798
- throw new Error("Sort key has not been provided but the Table has a sort key");
2799
- }
2800
- primaryCondition[this.sortKey] = keyCondition.sk;
2801
- }
2802
- return primaryCondition;
2803
- }
2804
2820
  /**
2805
2821
  * Creates a new item in the table, it will fail if the item already exists
2806
2822
  *
@@ -2815,7 +2831,7 @@ var Table = class {
2815
2831
  try {
2816
2832
  const result = await this.dynamoClient.get({
2817
2833
  TableName: params.tableName,
2818
- Key: this.createKeyForPrimaryIndex(keyCondition),
2834
+ Key: params.key,
2819
2835
  ProjectionExpression: params.projectionExpression,
2820
2836
  ExpressionAttributeNames: params.expressionAttributeNames,
2821
2837
  ConsistentRead: params.consistentRead
@@ -2850,12 +2866,13 @@ var Table = class {
2850
2866
  ReturnValues: params.returnValues === "CONSISTENT" ? "NONE" : params.returnValues
2851
2867
  });
2852
2868
  if (params.returnValues === "CONSISTENT") {
2869
+ const key = {
2870
+ pk: params.item[this.partitionKey],
2871
+ ...this.sortKey && { sk: params.item[this.sortKey] }
2872
+ };
2853
2873
  const getResult = await this.dynamoClient.get({
2854
2874
  TableName: params.tableName,
2855
- Key: this.createKeyForPrimaryIndex({
2856
- pk: params.item[this.partitionKey],
2857
- ...this.sortKey && { sk: params.item[this.sortKey] }
2858
- }),
2875
+ Key: key,
2859
2876
  ConsistentRead: true
2860
2877
  });
2861
2878
  return getResult.Item;
@@ -3039,7 +3056,7 @@ var Table = class {
3039
3056
  try {
3040
3057
  const result = await this.dynamoClient.delete({
3041
3058
  TableName: params.tableName,
3042
- Key: this.createKeyForPrimaryIndex(keyCondition),
3059
+ Key: params.key,
3043
3060
  ConditionExpression: params.conditionExpression,
3044
3061
  ExpressionAttributeNames: params.expressionAttributeNames,
3045
3062
  ExpressionAttributeValues: params.expressionAttributeValues,
@@ -3066,7 +3083,7 @@ var Table = class {
3066
3083
  try {
3067
3084
  const result = await this.dynamoClient.update({
3068
3085
  TableName: params.tableName,
3069
- Key: this.createKeyForPrimaryIndex(keyCondition),
3086
+ Key: params.key,
3070
3087
  UpdateExpression: params.updateExpression,
3071
3088
  ConditionExpression: params.conditionExpression,
3072
3089
  ExpressionAttributeNames: params.expressionAttributeNames,
@@ -3194,7 +3211,10 @@ var Table = class {
3194
3211
  }
3195
3212
  return {
3196
3213
  DeleteRequest: {
3197
- Key: this.createKeyForPrimaryIndex(operation.key)
3214
+ Key: {
3215
+ [this.partitionKey]: operation.key.pk,
3216
+ ...this.sortKey ? { [this.sortKey]: operation.key.sk } : {}
3217
+ }
3198
3218
  }
3199
3219
  };
3200
3220
  });
@@ -3237,7 +3257,28 @@ var Table = class {
3237
3257
  };
3238
3258
  }
3239
3259
  };
3240
-
3241
- export { Table };
3242
- //# sourceMappingURL=table.js.map
3243
- //# sourceMappingURL=table.js.map
3260
+ export {
3261
+ ConditionCheckBuilder,
3262
+ DeleteBuilder,
3263
+ Paginator,
3264
+ PutBuilder,
3265
+ QueryBuilder,
3266
+ Table,
3267
+ TransactionBuilder,
3268
+ UpdateBuilder,
3269
+ and,
3270
+ attributeExists,
3271
+ attributeNotExists,
3272
+ beginsWith,
3273
+ between,
3274
+ contains,
3275
+ createComparisonCondition,
3276
+ eq,
3277
+ gt,
3278
+ gte,
3279
+ lt,
3280
+ lte,
3281
+ ne,
3282
+ not,
3283
+ or
3284
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dyno-table",
3
- "version": "0.2.0-0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "A TypeScript library to simplify working with DynamoDB",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -11,80 +11,10 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
- },
15
- "./table": {
16
- "types": "./dist/table.d.ts",
17
- "import": "./dist/table.js",
18
- "require": "./dist/table.cjs"
19
- },
20
- "./entity": {
21
- "types": "./dist/entity.d.ts",
22
- "import": "./dist/entity.js",
23
- "require": "./dist/entity.cjs"
24
- },
25
- "./conditions": {
26
- "types": "./dist/conditions.d.ts",
27
- "import": "./dist/conditions.js",
28
- "require": "./dist/conditions.cjs"
29
- },
30
- "./types": {
31
- "types": "./dist/types.d.ts",
32
- "import": "./dist/types.js",
33
- "require": "./dist/types.cjs"
34
- },
35
- "./standard-schema": {
36
- "types": "./dist/standard-schema.d.ts",
37
- "import": "./dist/standard-schema.js",
38
- "require": "./dist/standard-schema.cjs"
39
- },
40
- "./utils/partition-key-template": {
41
- "types": "./dist/utils/partition-key-template.d.ts",
42
- "import": "./dist/utils/partition-key-template.js",
43
- "require": "./dist/utils/partition-key-template.cjs"
44
- },
45
- "./utils/sort-key-template": {
46
- "types": "./dist/utils/sort-key-template.d.ts",
47
- "import": "./dist/utils/sort-key-template.js",
48
- "require": "./dist/utils/sort-key-template.cjs"
49
- },
50
- "./builders/query-builder": {
51
- "types": "./dist/builders/query-builder.d.ts",
52
- "import": "./dist/builders/query-builder.js",
53
- "require": "./dist/builders/query-builder.cjs"
54
- },
55
- "./builders/paginator": {
56
- "types": "./dist/builders/paginator.d.ts",
57
- "import": "./dist/builders/paginator.js",
58
- "require": "./dist/builders/paginator.cjs"
59
- },
60
- "./builders/put-builder": {
61
- "types": "./dist/builders/put-builder.d.ts",
62
- "import": "./dist/builders/put-builder.js",
63
- "require": "./dist/builders/put-builder.cjs"
64
- },
65
- "./builders/update-builder": {
66
- "types": "./dist/builders/update-builder.d.ts",
67
- "import": "./dist/builders/update-builder.js",
68
- "require": "./dist/builders/update-builder.cjs"
69
- },
70
- "./builders/delete-builder": {
71
- "types": "./dist/builders/delete-builder.d.ts",
72
- "import": "./dist/builders/delete-builder.js",
73
- "require": "./dist/builders/delete-builder.cjs"
74
- },
75
- "./builders/transaction-builder": {
76
- "types": "./dist/builders/transaction-builder.d.ts",
77
- "import": "./dist/builders/transaction-builder.js",
78
- "require": "./dist/builders/transaction-builder.cjs"
79
- },
80
- "./builders/condition-check-builder": {
81
- "types": "./dist/builders/condition-check-builder.d.ts",
82
- "import": "./dist/builders/condition-check-builder.js",
83
- "require": "./dist/builders/condition-check-builder.cjs"
84
14
  }
85
15
  },
86
16
  "scripts": {
87
- "build": "tsup --config tsup.config.ts",
17
+ "build": "tsup src/index.ts --format esm,cjs --dts",
88
18
  "clean": "rm -rf dist",
89
19
  "test": "vitest run",
90
20
  "test:w": "vitest watch",
@@ -111,11 +41,14 @@
111
41
  "devDependencies": {
112
42
  "@babel/preset-typescript": "^7.26.0",
113
43
  "@biomejs/biome": "1.9.4",
114
- "@types/node": "^20.17.11",
115
- "rimraf": "^5.0.10",
116
- "tsup": "^8.3.5",
117
- "typescript": "^5.7.2",
118
- "vitest": "3.0.5"
44
+ "@semantic-release/changelog": "^6.0.3",
45
+ "@semantic-release/git": "^10.0.1",
46
+ "@types/node": "^20.0.0",
47
+ "rimraf": "^5.0.0",
48
+ "semantic-release": "24.2.3",
49
+ "tsup": "^8.0.0",
50
+ "typescript": "^5.0.0",
51
+ "vitest": "^2.1.8"
119
52
  },
120
53
  "peerDependencies": {
121
54
  "@aws-sdk/client-dynamodb": "^3.0.0",
@@ -1,118 +0,0 @@
1
- import { DynamoItem, TableConfig } from './types.js';
2
-
3
- /**
4
- * Interface for DynamoDB command objects that can contain expressions
5
- */
6
- interface DynamoCommandWithExpressions {
7
- conditionExpression?: string;
8
- updateExpression?: string;
9
- filterExpression?: string;
10
- keyConditionExpression?: string;
11
- projectionExpression?: string;
12
- expressionAttributeNames?: Record<string, string>;
13
- expressionAttributeValues?: Record<string, unknown>;
14
- [key: string]: unknown;
15
- }
16
-
17
- interface DeleteCommandParams extends DynamoCommandWithExpressions {
18
- tableName: string;
19
- key: Record<string, unknown>;
20
- conditionExpression?: string;
21
- expressionAttributeNames?: Record<string, string>;
22
- expressionAttributeValues?: DynamoItem;
23
- returnValues?: "ALL_OLD";
24
- }
25
- /**
26
- * Parameters for the DynamoDB put command.
27
- *
28
- * These parameters are used when executing the operation against DynamoDB.
29
- *
30
- * The `returnValues` property can be:
31
- * - `"ALL_OLD"`: Return the attributes of the item as they were before the operation
32
- * - `"NONE"`: Return nothing
33
- * - `"CONSISTENT"`: Triggers a GET operation after the put to retrieve the updated item state
34
- */
35
- interface PutCommandParams extends DynamoCommandWithExpressions {
36
- tableName: string;
37
- item: DynamoItem;
38
- conditionExpression?: string;
39
- expressionAttributeNames?: Record<string, string>;
40
- expressionAttributeValues?: Record<string, unknown>;
41
- returnValues?: "ALL_OLD" | "NONE" | "CONSISTENT";
42
- }
43
- /**
44
- * Parameters for the DynamoDB update command.
45
- * These parameters are used when executing the operation against DynamoDB.
46
- */
47
- interface UpdateCommandParams extends DynamoCommandWithExpressions {
48
- /** The name of the DynamoDB table */
49
- tableName: string;
50
- /** The primary key of the item to update */
51
- key: Record<string, unknown>;
52
- /** The update expression (SET, REMOVE, ADD, DELETE clauses) */
53
- updateExpression: string;
54
- /** Optional condition expression that must be satisfied */
55
- conditionExpression?: string;
56
- /** Map of expression attribute name placeholders to actual names */
57
- expressionAttributeNames?: Record<string, string>;
58
- /** Map of expression attribute value placeholders to actual values */
59
- expressionAttributeValues?: DynamoItem;
60
- /** Which item attributes to include in the response */
61
- returnValues?: "ALL_NEW" | "UPDATED_NEW" | "ALL_OLD" | "UPDATED_OLD" | "NONE";
62
- }
63
- interface ConditionCheckCommandParams extends DynamoCommandWithExpressions {
64
- tableName: string;
65
- key: Record<string, unknown>;
66
- conditionExpression: string;
67
- expressionAttributeNames?: Record<string, string>;
68
- expressionAttributeValues?: DynamoItem;
69
- }
70
- /**
71
- * Base interface for all builder classes that support pagination
72
- * to be used by Paginator without creating circular dependencies.
73
- */
74
- interface BaseBuilderInterface<T extends DynamoItem, TConfig extends TableConfig = TableConfig, B = unknown> {
75
- clone(): B;
76
- limit(limit: number): B;
77
- getLimit(): number | undefined;
78
- startFrom(lastEvaluatedKey: DynamoItem): B;
79
- execute(): Promise<{
80
- items: T[];
81
- lastEvaluatedKey?: DynamoItem;
82
- }>;
83
- }
84
- /**
85
- * Interface for the QueryBuilder class to be used by Paginator
86
- * without creating a circular dependency.
87
- */
88
- interface QueryBuilderInterface<T extends DynamoItem, TConfig extends TableConfig = TableConfig> extends BaseBuilderInterface<T, TConfig, QueryBuilderInterface<T, TConfig>> {
89
- }
90
- /**
91
- * Interface for the ScanBuilder class to be used by Paginator
92
- * without creating a circular dependency.
93
- */
94
- interface ScanBuilderInterface<T extends DynamoItem, TConfig extends TableConfig = TableConfig> extends BaseBuilderInterface<T, TConfig, ScanBuilderInterface<T, TConfig>> {
95
- }
96
- /**
97
- * Interface for the FilterBuilder class to be used by Paginator
98
- * without creating a circular dependency.
99
- */
100
- interface FilterBuilderInterface<T extends DynamoItem, TConfig extends TableConfig = TableConfig> extends BaseBuilderInterface<T, TConfig, FilterBuilderInterface<T, TConfig>> {
101
- }
102
- /**
103
- * Represents the result of a single page query operation.
104
- * This interface provides all necessary information about the current page
105
- * and the availability of subsequent pages.
106
- */
107
- interface PaginationResult<T> {
108
- /** The items (dinosaurs, habitats, etc.) retrieved for the current page */
109
- items: T[];
110
- /** DynamoDB's last evaluated key, used internally for pagination */
111
- lastEvaluatedKey?: DynamoItem;
112
- /** Indicates whether there are more pages available */
113
- hasNextPage: boolean;
114
- /** The current page number (1-indexed) */
115
- page: number;
116
- }
117
-
118
- export type { ConditionCheckCommandParams as C, DeleteCommandParams as D, FilterBuilderInterface as F, PaginationResult as P, QueryBuilderInterface as Q, ScanBuilderInterface as S, UpdateCommandParams as U, PutCommandParams as a };