@awsless/dynamodb-server 0.1.0 → 0.1.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 (2) hide show
  1. package/dist/index.js +2 -30
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -41,7 +41,7 @@ function createJavaServer(port, region) {
41
41
  const ping = async () => {
42
42
  const client = getClient();
43
43
  try {
44
- const response = await client.send(new ListTablesCommand({}));
44
+ const response = await client.send(new ListTablesCommand({}), { requestTimeout: 250 });
45
45
  return Array.isArray(response.TableNames);
46
46
  } catch {
47
47
  return false;
@@ -838,7 +838,6 @@ function compareValues(a, b) {
838
838
  }
839
839
 
840
840
  // src/store/item.ts
841
- import { createHash } from "crypto";
842
841
  function extractKey(item, keySchema) {
843
842
  const key = {};
844
843
  for (const element of keySchema) {
@@ -889,16 +888,6 @@ function deepClone(obj) {
889
888
  function estimateItemSize(item) {
890
889
  return JSON.stringify(item).length;
891
890
  }
892
- function extractRawValue(value) {
893
- if ("S" in value) return value.S;
894
- if ("N" in value) return value.N;
895
- if ("B" in value) return value.B;
896
- return serializeAttributeValue(value);
897
- }
898
- function hashAttributeValue(value) {
899
- const raw = extractRawValue(value);
900
- return createHash("md5").update("Outliers" + raw).digest("hex");
901
- }
902
891
 
903
892
  // src/expressions/key-condition.ts
904
893
  function parseKeyCondition(expression, keySchema, context) {
@@ -2579,7 +2568,7 @@ var Table = class {
2579
2568
  const hashA = a[hashAttr];
2580
2569
  const hashB = b[hashAttr];
2581
2570
  if (hashA && hashB) {
2582
- const hashCmp = hashAttributeValue(hashA).localeCompare(hashAttributeValue(hashB));
2571
+ const hashCmp = this.compareAttributes(hashA, hashB);
2583
2572
  if (hashCmp !== 0) return hashCmp;
2584
2573
  }
2585
2574
  if (rangeAttr) {
@@ -2735,29 +2724,12 @@ var Table = class {
2735
2724
  throw new Error(`Index ${indexName} not found`);
2736
2725
  }
2737
2726
  const indexHashAttr = getHashKey(indexData.keySchema);
2738
- const indexRangeAttr = getRangeKey(indexData.keySchema);
2739
2727
  const matchingItems = [];
2740
2728
  for (const item of this.items.values()) {
2741
2729
  if (item[indexHashAttr]) {
2742
2730
  matchingItems.push(deepClone(item));
2743
2731
  }
2744
2732
  }
2745
- matchingItems.sort((a, b) => {
2746
- const hashA = a[indexHashAttr];
2747
- const hashB = b[indexHashAttr];
2748
- if (hashA && hashB) {
2749
- const hashCmp = hashAttributeValue(hashA).localeCompare(hashAttributeValue(hashB));
2750
- if (hashCmp !== 0) return hashCmp;
2751
- }
2752
- if (indexRangeAttr) {
2753
- const rangeA = a[indexRangeAttr];
2754
- const rangeB = b[indexRangeAttr];
2755
- if (rangeA && rangeB) {
2756
- return this.compareAttributes(rangeA, rangeB);
2757
- }
2758
- }
2759
- return 0;
2760
- });
2761
2733
  let startIdx = 0;
2762
2734
  if (exclusiveStartKey) {
2763
2735
  const startKey = serializeKey(exclusiveStartKey, this.keySchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/dynamodb-server",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",