@izara_project/izara-core-generate-service-code 1.0.41 → 1.0.42

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-generate-service-code",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "Code for locally generating per service files",
5
5
  "author": "Sven Mason <thebarbariansven@gmail.com>",
6
6
  "license": "AGPL-3.0-or-later",
@@ -31,7 +31,7 @@ const templateSendPlugin = path.join(__dirname, './templateByConfig/templateSend
31
31
  const templateAwaitingStep = path.join(__dirname, './templateByConfig/awaitingSteps.ejs');
32
32
 
33
33
  async function data(_izContext, data, appPath) {
34
-
34
+ console.log("dataInMain", data)
35
35
  const [mainFlow] = await getLocalOrS3FlowSchema(
36
36
  _izContext,
37
37
  {
@@ -42,25 +42,10 @@ async function data(_izContext, data, appPath) {
42
42
  appPath, './src/schemas')
43
43
  );
44
44
 
45
- const [childFlow] = await getLocalOrS3FlowSchema(
46
- _izContext,
47
- data.childFlow,
48
- path.join(
49
- appPath, './src/schemas')
50
- );
51
-
52
45
  if (mainFlow.hasOwnProperty('objType')) {
53
46
  data['mainObjType'] = mainFlow.objType;
54
47
  };
55
48
 
56
- if (!childFlow) {
57
- throw new NoRetryError(`can't get ${childFlow} from s3 or local`);
58
- };
59
-
60
- if (childFlow && childFlow.hasOwnProperty('objType')) {
61
- data['childObjType'] = childFlow.objType;
62
- };
63
-
64
49
 
65
50
  return {
66
51
  templatePath: templatePath,
@@ -58,7 +58,7 @@ export default async function <%- functionName %>(
58
58
  //(<hookCode>)
59
59
 
60
60
  <% if (handleLogic === 'awaitingMultipleSteps') { %>
61
- <%- include(templateAwaitingStep, { childFlow, mainObjType, childObjType }) %>
61
+ <%- include(templateAwaitingStep, { childFlow, mainObjType }) %>
62
62
  <% } %>
63
63
  <% if (havePlugIn) { -%>
64
64
  <%- include(templateSendPlugin, {havePlugIn: havePlugIn, invokeType: invokeType, targetUrl: targetUrl}) %>
@@ -52,10 +52,6 @@ await asyncFlowSharedLib.createAwaitingMultipleStepsWithAdditionalAttributes(
52
52
  )
53
53
  );
54
54
 
55
- await sns.publishAsync(_izContext, {
56
- Message: JSON.stringify(messageObject),
57
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, "<%- childFlow.flowTag %>_In", "<%- childFlow.serviceTag %>")
58
- });
59
55
  //(</afterCreateAwatingSteps>)
60
56
 
61
57
  <%_ function firstLetterUpperCase(text) {
@@ -137,10 +137,6 @@ async function generatePlunIg(
137
137
  if (flowStepConfig.plugInHooks?.length) {
138
138
  for (let i = 0; i < flowStepConfig.plugInHooks.length; i++) {
139
139
  if (i === 0) {
140
- if (flowStepConfig.hasOwnProperty("settings")) {
141
- data["handleLogic"] = flowStepConfig.settings.handleLogic;
142
- data["childFlow"] = flowStepConfig.settings.flowType;
143
- };
144
140
  const firstResults = await buildFirstPluginHookResources(
145
141
  _izContext,
146
142
  data,
@@ -159,14 +155,10 @@ async function generatePlunIg(
159
155
  allCreateSourceParams.push(...afterResults);
160
156
  }
161
157
  } else {
162
- if (flowStepConfig.hasOwnProperty("settings")) {
163
- data["handleLogic"] = flowStepConfig.settings.handleLogic;
164
- data["childFlow"] = flowStepConfig.settings.flowType;
165
- };
166
-
167
158
  const noHookResults = await buildNoPluginHookResources(
168
159
  _izContext,
169
160
  data,
161
+ flowStepConfig,
170
162
  appPath
171
163
  );
172
164
  allCreateSourceParams.push(...noHookResults);
@@ -224,10 +216,9 @@ async function generatePlunIg(
224
216
  export default generatePlunIg;
225
217
 
226
218
 
227
- async function buildNoPluginHookResources(_izContext, data, appPath) {
219
+ async function buildNoPluginHookResources(_izContext, data, flowStepConfig, appPath) {
228
220
  const results = [];
229
221
 
230
-
231
222
  const yamlRes = await yamlFlowStep(
232
223
  _izContext,
233
224
  data,
@@ -253,7 +244,13 @@ async function buildNoPluginHookResources(_izContext, data, appPath) {
253
244
 
254
245
  const mainRes = await mainFunctionFlowStep(
255
246
  _izContext,
256
- { ...data, havePlugIn: false }, appPath);
247
+ {
248
+ ...data,
249
+ havePlugIn: false,
250
+ handleLogic: flowStepConfig.settings?.handleLogic || 'none'
251
+ },
252
+ appPath
253
+ );
257
254
 
258
255
  results.push(mainRes,
259
256
  // snsOutRes,
@@ -322,6 +319,7 @@ async function buildFirstPluginHookResources(_izContext, data, flowStepConfig, a
322
319
  havePlugIn: true,
323
320
  invokeType: targetPlugIn.invocationType,
324
321
  targetUrl,
322
+ handleLogic: flowStepConfig.settings?.handleLogic || 'none'
325
323
  };
326
324
  }
327
325
  }
@@ -138,8 +138,6 @@ export async function createMainLogical(
138
138
 
139
139
  // ── DynamoDB ──────────────────────────────────────────────────────────
140
140
  if (createDataDetail.storageType === consts.STORAGE_TYPES.dynamoDB) {
141
- //(<beforeCreateRecordDynamo>)
142
- //(</beforeCreateRecordDynamo>)
143
141
  _izContext.logger.debug('::::::DynamoDB::::::', { storageTag, objInstanceFull });
144
142
 
145
143
  if (parentObject && createDataDetail.tableName.includes(firstLetterUpperCase(`${parentObject.objectType}Records`))) {
@@ -152,25 +150,45 @@ export async function createMainLogical(
152
150
  _izContext.logger.debug('objInstanceFull before create item in dynamoDB', objInstanceFullForDynamoDb);
153
151
 
154
152
  const identifiersForCreateData = await dynamoDbIdentifiersByStorageResource(
155
- _izContext, objectSchema, createDataDetails, objInstanceFullForDynamoDb.identifiers
153
+ _izContext,
154
+ objectSchema,
155
+ createDataDetails,
156
+ objInstanceFullForDynamoDb.identifiers
156
157
  );
157
158
  _izContext.logger.debug('identifiersForCreateData', identifiersForCreateData);
158
159
 
159
- // await dynamodbSharedLib.putItem(
160
- // _izContext,
161
- // await dynamodbSharedLib.tableName(_izContext, createDataDetail.tableName, createDataDetail.serviceTag),
162
- // { ...identifiersForCreateData, ...objInstanceFullForDynamoDb.fields }
163
- // );
160
+ //(<beforeCreateRecordDynamo>)
161
+ //(</beforeCreateRecordDynamo>)
164
162
 
165
- listOfRecords.push({
166
- [createDataDetail.tableName]: {
167
- serviceTag: createDataDetail.serviceTag,
168
- objInstanceFull: {
169
- identifiers: identifiersForCreateData,
170
- fields: objInstanceFullForDynamoDb.fields
163
+ if (Object.values(createDataDetails).some(
164
+ createDataDetail => createDataDetail.storageType === consts.STORAGE_TYPES.graph)) {
165
+ _izContext.logger.debug('must process graph first');
166
+ listOfRecords.push({
167
+ [createDataDetail.tableName]: {
168
+ serviceTag: createDataDetail.serviceTag,
169
+ objInstanceFull: {
170
+ identifiers: identifiersForCreateData,
171
+ fields: objInstanceFullForDynamoDb.fields
172
+ }
171
173
  }
172
- }
173
- })
174
+ })
175
+ } else {
176
+ _izContext.logger.debug('can process record dynamo')
177
+ await dynamodbSharedLib.putItem(
178
+ _izContext,
179
+ dynamodbSharedLib.tableName(_izContext,
180
+ createDataDetail.tableName,
181
+ createDataDetail.serviceTag
182
+ ),
183
+ {
184
+ ...identifiersForCreateData,
185
+ ...objInstanceFullForDynamoDb.fields
186
+ }
187
+ );
188
+
189
+ objInstanceFullForDynamoDb.fields = {}
190
+ }
191
+
174
192
  //(<afterCreateRecordDynamo>)
175
193
  //(</afterCreateRecordDynamo>)
176
194
 
@@ -338,10 +356,17 @@ export async function createMainLogical(
338
356
 
339
357
  // ── DynamoDB-only complete path ───────────────────────────────────────────
340
358
  if (allAwaitingStepsId.length === 0 && listOfObjectForCreates.length === 0) {
341
- const outMessage = callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
342
- callingFlowConfig,
343
- { objType, objInstanceFull: { identifiers: objInstanceFullForDynamoDb.identifiers, fields: objInstanceFullForDynamoDb.fields } }
344
- );
359
+ const outMessage =
360
+ callingFlowSharedLib.addPassBackPropertiesToSnsResponseMessageObject(
361
+ callingFlowConfig,
362
+ {
363
+ objType: objType,
364
+ objInstanceFull: {
365
+ identifiers: objInstanceFullForDynamoDb.identifiers,
366
+ fields: objInstanceFullForDynamoDb.fields
367
+ }
368
+ }
369
+ );
345
370
 
346
371
  if (callingFlowConfig[callingFlowSharedLib.consts.CALLINGFLOW_PROPERTYNAME]) {
347
372
  _izContext.logger.debug('HAVE CallingFlow');
@@ -358,7 +383,10 @@ export async function createMainLogical(
358
383
 
359
384
  return {
360
385
  objType,
361
- objInstanceFull: objInstanceFullForDynamoDb,
386
+ objInstanceFull: {
387
+ identifiers: objInstanceFullForDynamoDb.identifiers,
388
+ fields: objInstanceFullForDynamoDb.fields
389
+ },
362
390
  relationships: requestParams.relationships || [],
363
391
  status: 'complete',
364
392
  errorsFound