@izara_project/izara-core-library-asynchronous-flow 1.0.37 → 1.0.39

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
@@ -3,42 +3,33 @@
3
3
  "author": "Sven Mason <thebarbariansven@gmail.com>",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "homepage": "https://bitbucket.org/izara-core-libraries/izara-core-library-asynchronous-flow#readme",
6
- "version": "1.0.37",
6
+ "version": "1.0.39",
7
7
  "description": "Shared asynchronous flow logic",
8
8
  "type": "module",
9
9
  "main": "index.js",
10
10
  "exports": {
11
11
  ".": "./index.js"
12
12
  },
13
- "scripts": {
14
- "test": "jest"
15
- },
16
13
  "repository": {
17
14
  "type": "git",
18
15
  "url": "git+ssh://git@bitbucket.org/izara-core-libraries/izara-core-library-asynchronous-flow.git"
19
16
  },
20
- "jest": {
21
- "testEnvironment": "node"
22
- },
23
17
  "devDependencies": {
24
- "jest": "^30.4.2",
25
18
  "@izara_project/izara-core-library-core": "^1.0.32",
26
- "@izara_project/izara-core-library-dynamodb": "^1.0.19",
19
+ "@izara_project/izara-core-library-dynamodb": "^1.0.20",
27
20
  "@izara_project/izara-core-library-external-request": "^1.0.30",
28
21
  "@izara_project/izara-core-library-logger": "^1.0.9",
29
- "@izara_project/izara-core-library-sqs": "^1.0.7",
30
22
  "@izara_project/izara-core-library-sns": "^1.0.8",
31
- "@izara_project/izara-shared-core": "^1.0.12"
23
+ "@izara_project/izara-core-library-sqs": "^1.0.7",
24
+ "@izara_project/izara-shared-core": "^1.0.13"
32
25
  },
33
26
  "peerDependencies": {
34
27
  "@izara_project/izara-core-library-core": "^1.0.32",
35
28
  "@izara_project/izara-core-library-dynamodb": "^1.0.19",
36
29
  "@izara_project/izara-core-library-external-request": "^1.0.30",
37
30
  "@izara_project/izara-core-library-logger": "^1.0.9",
38
- "@izara_project/izara-core-library-sqs": "^1.0.7",
39
31
  "@izara_project/izara-core-library-sns": "^1.0.8",
32
+ "@izara_project/izara-core-library-sqs": "^1.0.7",
40
33
  "@izara_project/izara-shared-core": "^1.0.12"
41
- },
42
- "peerDependenciesMeta": {},
43
- "dependencies": {}
34
+ }
44
35
  }
@@ -66,26 +66,6 @@ export function createConcatenatedPendingStepId(parentId, childId) {
66
66
  return parentId + '_' + childId;
67
67
  }
68
68
 
69
- /**
70
- * Create a simple awaitingStepId (prefix + partitionKey).
71
- * @param {string} partitionKey
72
- * @param {string} [prefix=""]
73
- * @returns {string}
74
- */
75
- export function createAwaitingStepId(partitionKey, prefix = '') {
76
- return prefix + partitionKey;
77
- }
78
-
79
- /**
80
- * Create a simple pendingStepId (prefix + identifierId).
81
- * @param {string} identifierId
82
- * @param {string} [prefix=""]
83
- * @returns {string}
84
- */
85
- export function createPendingStepId(identifierId, prefix = '') {
86
- return prefix + identifierId;
87
- }
88
-
89
69
  /**
90
70
  * Create parent Flow Id.
91
71
  * @async
@@ -117,24 +97,6 @@ export function explodePendingStepId(pendingStepId, prefix = '') {
117
97
  }
118
98
 
119
99
  // copy from izara-core-library-trigger-cache
120
- /**
121
- * Build the field name that stores "cache complete" marker.
122
- * @param {string} [prefix='cache']
123
- * @returns {string}
124
- */
125
- export function createFieldNameCacheComplete(prefix = 'cache') {
126
- return prefix + 'CacheComplete';
127
- }
128
-
129
- /**
130
- * Build the field name that stores a cache "status".
131
- * @param {string} [prefix='cache']
132
- * @returns {string}
133
- */
134
- export function createFieldNameStatus(prefix = 'cache') {
135
- return prefix + 'Status';
136
- }
137
-
138
100
  /**
139
101
  * Checks if record has uniqueRequestId set, if not set to this requests uniqueRequestId and continue to process
140
102
  * if already set check if matches this request uniqueRequestId, if yes continue to process, if not then stop processing
@@ -333,8 +295,8 @@ export async function checkAndGetTimeCacheComplete(
333
295
  );
334
296
 
335
297
  const uniqueRequestIdFieldName = createFieldNameUniqueRequestId('cache');
336
- const cacheCompleteFieldName = createFieldNameCacheComplete(prefix);
337
- const statusFieldName = createFieldNameStatus(prefix);
298
+ const cacheCompleteFieldName = prefix + 'CacheComplete';
299
+ const statusFieldName = prefix + 'Status';
338
300
 
339
301
  let getTimeCacheComplete = await dynamodbSharedLib.getItem(
340
302
  _izContext,
@@ -95,10 +95,10 @@ async function _queryAwaitingStepsByPendingStepId(_izContext, pendingStepId) {
95
95
  export async function createAwaitingMultipleSteps(
96
96
  _izContext,
97
97
  pendingStepId,
98
+ records = [],
98
99
  options = {}
99
100
  ) {
100
101
  const {
101
- records = [],
102
102
  prefix = '',
103
103
  additionalAttributes = {},
104
104
  publishConfig = null
@@ -109,6 +109,16 @@ export async function createAwaitingMultipleSteps(
109
109
  options
110
110
  });
111
111
 
112
+ const formattedPrefix = prefix
113
+ ? prefix.endsWith('_')
114
+ ? prefix
115
+ : `${prefix}_`
116
+ : '';
117
+ const finalPendingStepId =
118
+ formattedPrefix && !pendingStepId.startsWith(formattedPrefix)
119
+ ? formattedPrefix + pendingStepId
120
+ : pendingStepId;
121
+
112
122
  let finalRecords = records;
113
123
 
114
124
  if (finalRecords.length === 0 && !publishConfig) {
@@ -152,7 +162,7 @@ export async function createAwaitingMultipleSteps(
152
162
  awaitingStepId,
153
163
  additionalAttributes: itemAttrs
154
164
  })),
155
- pendingStepId,
165
+ finalPendingStepId,
156
166
  {
157
167
  complete: false,
158
168
  errorsFound: []
@@ -180,42 +190,30 @@ export async function createAwaitingMultipleSteps(
180
190
  return finalRecords[0]?.awaitingStepId;
181
191
  }
182
192
 
183
- export async function createAwaitingMultipleStepsWithAdditionalAttributes(
184
- _izContext,
185
- records,
186
- pendingStepId
187
- ) {
188
- return createAwaitingMultipleSteps(_izContext, pendingStepId, { records });
189
- }
190
-
191
- export async function createAwaitingMultipleStep(
193
+ export async function updateAwaitingMultipleStep(
192
194
  _izContext,
195
+ awaitingStepId,
193
196
  pendingStepId,
194
- prefix = '',
195
- additionalAttributes = {}
197
+ data
196
198
  ) {
197
- return createAwaitingMultipleSteps(_izContext, pendingStepId, {
198
- prefix,
199
- additionalAttributes
200
- });
201
- }
199
+ const tableSteps = dynamodbSharedLib.tableName(
200
+ _izContext,
201
+ 'AwaitingMultipleSteps'
202
+ );
202
203
 
203
- export async function createAwaitingMultipleStepsWithAdditionalAttributesAndPublish(
204
- _izContext,
205
- messages,
206
- prefix = '',
207
- flowType = {},
208
- additionalAttributes = {},
209
- pendingStepId
210
- ) {
211
- return createAwaitingMultipleSteps(_izContext, pendingStepId, {
212
- prefix,
213
- additionalAttributes,
214
- publishConfig: {
215
- messages,
216
- flowType
217
- }
204
+ await dynamodbSharedLib.updateItem(
205
+ _izContext,
206
+ tableSteps,
207
+ { awaitingStepId, pendingStepId },
208
+ data
209
+ );
210
+
211
+ _izContext.logger.debug('[Lib:updateAwaitingMultipleStep] Output', {
212
+ awaitingStepId,
213
+ data
218
214
  });
215
+
216
+ return { ...data, awaitingStepId };
219
217
  }
220
218
 
221
219
  export async function findPendingStepAwaitingMultipleSteps(
@@ -80,26 +80,8 @@ export async function createAwaitingStep(
80
80
  );
81
81
  }
82
82
 
83
- export async function findPendingStepIdAwaitingStep(
84
- _izContext,
85
- awaitingStepId
86
- ) {
87
- const item = await _findSinglePendingStep(_izContext, awaitingStepId);
88
- return item.pendingStepId;
89
- }
90
-
91
83
  export async function findPendingStep(_izContext, awaitingStepId) {
92
- return _findSinglePendingStep(_izContext, awaitingStepId);
93
- }
94
-
95
- export async function findPendingStepAwaitingStepWithCallingFlow(
96
- _izContext,
97
- awaitingStepId
98
- ) {
99
- const awaitingStep = await findPendingStep(_izContext, awaitingStepId);
100
- const { callingFlowConfig = null, ...restAwaitingStep } = awaitingStep;
101
-
102
- return [restAwaitingStep, callingFlowConfig];
84
+ return _findSinglePendingStep(_izContext, awaitingStepId);
103
85
  }
104
86
 
105
87
  export async function removeAwaitingStep(