@izara_project/izara-core-library-asynchronous-flow 1.0.4 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-library-asynchronous-flow",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Shared asynchronous flow logic",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,10 +20,10 @@
20
20
  "testEnvironment": "node"
21
21
  },
22
22
  "dependencies": {
23
- "@izara_project/izara-core-library-core": "^1.0.16",
24
- "@izara_project/izara-core-library-dynamodb": "^1.0.2",
25
- "@izara_project/izara-core-library-external-request": "^1.0.17",
26
- "@izara_project/izara-core-library-logger": "^1.0.6",
27
- "@izara_project/izara-core-library-sqs": "^1.0.2"
23
+ "@izara_project/izara-core-library-core": "^1.0.18",
24
+ "@izara_project/izara-core-library-dynamodb": "^1.0.4",
25
+ "@izara_project/izara-core-library-external-request": "^1.0.18",
26
+ "@izara_project/izara-core-library-logger": "^1.0.7",
27
+ "@izara_project/izara-core-library-sqs": "^1.0.4"
28
28
  }
29
29
  }
@@ -712,18 +712,24 @@ module.exports.checkAndGetTimeCacheComplete = async (
712
712
  }
713
713
 
714
714
  // check if exist and match with initail create not changing in flow.
715
- if (!getTimeCacheComplete[uniqueRequestIdFieldName]
716
- // || !getTimeCacheComplete[cacheCompleteFieldName]
717
- || (getTimeCacheComplete[cacheCompleteFieldName]
718
- && getTimeCacheComplete[cacheCompleteFieldName] !== timeCacheComplete
719
- && getTimeCacheComplete[statusFieldName] != "complete")
715
+ // if (!getTimeCacheComplete[uniqueRequestIdFieldName]
716
+ // // || !getTimeCacheComplete[cacheCompleteFieldName]
717
+ // || (getTimeCacheComplete[cacheCompleteFieldName]
718
+ // && getTimeCacheComplete[cacheCompleteFieldName] !== timeCacheComplete
719
+ // && getTimeCacheComplete[statusFieldName] != "complete")
720
+ // ) {
721
+ // return [false, getTimeCacheComplete[cacheCompleteFieldName]];
722
+ // } else {
723
+ // return [true, getTimeCacheComplete[cacheCompleteFieldName], getTimeCacheComplete[uniqueRequestIdFieldName]];
724
+ // }
725
+
726
+ if (getTimeCacheComplete[cacheCompleteFieldName]
727
+ && getTimeCacheComplete[cacheCompleteFieldName] !== timeCacheComplete
720
728
  ) {
721
729
  return [false, getTimeCacheComplete[cacheCompleteFieldName]];
722
730
  } else {
723
731
  return [true, getTimeCacheComplete[cacheCompleteFieldName], getTimeCacheComplete[uniqueRequestIdFieldName]];
724
732
  }
725
-
726
-
727
733
  }
728
734
 
729
735
 
@@ -811,21 +817,24 @@ module.exports.validateStartKeyParam = (
811
817
  _izContext,
812
818
  startKey,
813
819
  partitionKeyFieldName,
814
- sortKeyFieldName = null
820
+ sortKeyFieldName
815
821
  ) => {
822
+ const stringNotEmptyRegex = /^[A-Za-z0-9_-]+$/;
823
+
824
+ if (
825
+ !partitionKeyFieldName || !sortKeyFieldName
826
+ || !stringNotEmptyRegex.test(partitionKeyFieldName)
827
+ || !stringNotEmptyRegex.test(sortKeyFieldName)
828
+ ) {
829
+ throw new NoRetryError("validateStartKeyParam: Invalid partitionKeyFieldName or sortKeyFieldName");
830
+ }
816
831
 
817
832
  if (startKey && Object.keys(startKey).length != 0) {
818
- if (
819
- startKey.constructor !== Object ||
820
- !startKey[partitionKeyFieldName]
821
- ) {
822
- startKey = false; // we can type check for false to see if invalid
823
- }
824
- if (sortKeyFieldName !== null && sortKeyFieldName !== undefined && !startKey[sortKeyFieldName]) {
825
- startKey = false;
833
+ if (!startKey[partitionKeyFieldName] || !startKey[sortKeyFieldName]) {
834
+ throw new NoRetryError("validateStartKeyParam: Invalid startKey, missing partitionKeyFieldName or sortKeyFieldName");
826
835
  }
827
836
  } else {
828
- startKey = null; // if empty set to null so lib functions process correctly (not want empty object)
837
+ startKey = null; // if empty set to null so lib functions process correctly
829
838
  }
830
839
 
831
840
  return startKey;