@izara_project/izara-core-generate-service-code 1.0.99 → 1.0.100

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 (50) hide show
  1. package/package.json +1 -1
  2. package/src/compile/compileProject.js +16 -5
  3. package/src/compile/flowValidator.js +3 -1
  4. package/src/compile/loadSchemas.js +18 -4
  5. package/src/compile/schemaValidatorSetup.js +16 -0
  6. package/src/emit/application/coreFunction/emitCoreFunctionArtifacts.js +108 -108
  7. package/src/emit/application/coreFunction/templates/InitialSetupRunner.ejs +2 -2
  8. package/src/emit/application/crud/templates/CreateComplete_Main.ejs +2 -0
  9. package/src/emit/application/crud/templates/CreateLogicalLib.ejs +14 -7
  10. package/src/emit/application/crud/templates/DeleteComplete_Main.ejs +2 -0
  11. package/src/emit/application/crud/templates/FlowEndpoint_HdrWbs.ejs +7 -5
  12. package/src/emit/application/crud/templates/UpdateComplete_Main.ejs +2 -0
  13. package/src/emit/application/custom/customFlowPaths.js +13 -16
  14. package/src/emit/application/custom/customFlowS3.js +274 -63
  15. package/src/emit/application/custom/customFlows.js +131 -0
  16. package/src/emit/application/custom/emitCustomFlowApplicationArtifacts.js +3 -1
  17. package/src/emit/application/custom/templates/s3/ConfirmAfterUpload_HdrSqs.ejs +110 -0
  18. package/src/emit/application/custom/templates/s3/ConfirmAfterUpload_Main.ejs +89 -0
  19. package/src/emit/application/custom/templates/s3/ConfirmComplete_HdrSqs.ejs +110 -0
  20. package/src/emit/application/custom/templates/s3/ConfirmComplete_Main.ejs +89 -0
  21. package/src/emit/application/custom/templates/s3/CreateObject_HdrWbs.ejs +2 -1
  22. package/src/emit/application/custom/templates/s3/CreateObject_Main.ejs +4 -0
  23. package/src/emit/application/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +42 -0
  24. package/src/emit/application/custom/templates/s3/CreatePreSignUrl_Main.ejs +23 -0
  25. package/src/emit/application/custom/templates/s3/ProcessS3File_Main.ejs +135 -27
  26. package/src/emit/application/custom/templates/s3/Start_Main.ejs +197 -0
  27. package/src/emit/application/rbac/emitDynamicRbacFlowSchemas.js +5 -1
  28. package/src/emit/application/rbac/emitRbacApplicationArtifacts.js +67 -60
  29. package/src/emit/application/rbac/templates/ReservedDynamicUsage_Main.ejs +27 -9
  30. package/src/emit/application/rbac/templates/UserRbacFlow_Main.ejs +4 -3
  31. package/src/emit/application/system/templates/Register_HdrWbs.ejs +2 -1
  32. package/src/emit/infrastructure/functions/functionYamlArtifact.js +3 -8
  33. package/src/emit/infrastructure/functions/templates/S3Function_Yaml.ejs +2 -3
  34. package/src/emit/infrastructure/resources/iamResourceArtifacts.js +22 -0
  35. package/src/emit/infrastructure/resources/resourceState.js +15 -5
  36. package/src/emit/infrastructure/resources/s3ResourceArtifacts.js +19 -3
  37. package/src/emit/infrastructure/resources/templates/S3Bucket_Yaml.ejs +1 -1
  38. package/src/emit/infrastructure/resources/templates/SystemDynamoDB_Yaml.ejs +2 -2
  39. package/src/emit/schemas/error/emitErrorSchemas.js +120 -10
  40. package/src/emit/schemas/error/templates/errorConsts.ejs +12 -0
  41. package/src/generate.js +32 -30
  42. package/test/integration/publicApi.test.js +33 -24
  43. package/test/unit/application/createTargetRoleHandler.test.js +33 -10
  44. package/test/unit/application/customFlowApplicationArtifacts.test.js +6 -6
  45. package/test/unit/application/customFlowS3.test.js +730 -0
  46. package/test/unit/infrastructure/functionYamlArtifact.test.js +6 -4
  47. package/test/unit/infrastructure/resourceArtifacts.test.js +51 -0
  48. package/test/unit/schemas/dynamicRbacFlowSchemas.test.js +8 -6
  49. package/test/unit/schemas/dynamicRelationshipFlowSchemas.test.js +51 -0
  50. package/test/unit/schemas/errorSchemas.test.js +84 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.99",
3
+ "version": "1.0.100",
4
4
  "description": "Code for locally generating per service files",
5
5
  "homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
6
6
  "repository": {
@@ -20,15 +20,25 @@ export function compileProject(request = {}) {
20
20
  }
21
21
 
22
22
  let serviceTag = request.serviceTag;
23
- if (!serviceTag && existsSync(configPath)) {
23
+ let schemaBucketName = request.schemaBucketName;
24
+ if (existsSync(configPath)) {
24
25
  try {
25
26
  const configContent = readFileSync(configPath, 'utf8');
26
27
  const parsedConfig = parseYaml(configContent);
27
28
  if (parsedConfig && parsedConfig.main_config) {
28
- if (parsedConfig.main_config.iz_serviceTag) {
29
- serviceTag = parsedConfig.main_config.iz_serviceTag;
30
- } else if (parsedConfig.main_config.iz_serviceName) {
31
- serviceTag = parsedConfig.main_config.iz_serviceName;
29
+ if (!serviceTag) {
30
+ if (parsedConfig.main_config.iz_serviceTag) {
31
+ serviceTag = parsedConfig.main_config.iz_serviceTag;
32
+ } else if (parsedConfig.main_config.iz_serviceName) {
33
+ serviceTag = parsedConfig.main_config.iz_serviceName;
34
+ }
35
+ }
36
+ if (
37
+ !schemaBucketName &&
38
+ parsedConfig.main_config.iz_serviceSchemaBucketName
39
+ ) {
40
+ schemaBucketName =
41
+ parsedConfig.main_config.iz_serviceSchemaBucketName;
32
42
  }
33
43
  }
34
44
  } catch (err) {
@@ -49,6 +59,7 @@ export function compileProject(request = {}) {
49
59
  configPath,
50
60
  schemaRoot: join(rootPath, 'app', 'src', 'schemas'),
51
61
  serviceTag,
62
+ schemaBucketName,
52
63
  schemaTemplateConfig
53
64
  });
54
65
  }
@@ -6,6 +6,7 @@ export const VALID_EVENT_ENUM = [
6
6
  'ownTopic',
7
7
  's3',
8
8
  'dsq',
9
+ 'dss',
9
10
  'generateCode'
10
11
  ];
11
12
 
@@ -14,7 +15,8 @@ export const VALID_S3_STEP_NAMES = [
14
15
  'ReservedLimit',
15
16
  'CreatePreSignUrl',
16
17
  'ProcessAfterUpload',
17
- 'ConfirmAfterUpload'
18
+ 'ConfirmAfterUpload',
19
+ 'ConfirmComplete'
18
20
  ];
19
21
 
20
22
 
@@ -1,5 +1,5 @@
1
1
  import { readdir, stat } from 'node:fs/promises';
2
- import { join } from 'node:path';
2
+ import { join, relative, sep } from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
4
  import { utils } from '@izara_project/izara-core-library-service-schemas';
5
5
  import { validateFlowSchema } from './flowValidator.js';
@@ -59,6 +59,13 @@ export async function loadLocalSchemaDirectory(
59
59
  return false;
60
60
  }
61
61
  }
62
+ if (directoryName === 'ErrorSchemas') {
63
+ const parentDir = entry.parentPath || entry.path || directoryPath;
64
+ const relDir = relative(directoryPath, parentDir);
65
+ if (relDir.split(sep).includes('generateCode')) {
66
+ return false;
67
+ }
68
+ }
62
69
  return true;
63
70
  });
64
71
  validEntries.sort((a, b) => {
@@ -416,10 +423,13 @@ export async function loadLocalSchemaDirectory(
416
423
  schema
417
424
  );
418
425
  }
426
+ const relTag = Object.keys(schema || {})[0];
427
+ const relGeneratedBy =
428
+ schema?.[relTag]?.generatedBy || schema?.generatedBy;
419
429
  if (
420
430
  !status &&
421
431
  Array.isArray(errors) &&
422
- VALID_GENERATED_BY_ENUM.includes(schema?.generatedBy)
432
+ VALID_GENERATED_BY_ENUM.includes(relGeneratedBy)
423
433
  ) {
424
434
  errors = errors.filter(
425
435
  (err) =>
@@ -429,7 +439,7 @@ export async function loadLocalSchemaDirectory(
429
439
  ) &&
430
440
  !(
431
441
  err.includes('should be one of enum') &&
432
- err.includes(schema?.generatedBy)
442
+ err.includes(relGeneratedBy)
433
443
  )
434
444
  );
435
445
  if (errors.length === 0) {
@@ -527,7 +537,11 @@ export async function loadLocalSchemaDirectory(
527
537
  );
528
538
  });
529
539
  }
530
- if (errors.length === 0) {
540
+ const remainingActionableErrors = errors.filter(
541
+ (err) => err && !err.trim().startsWith('FlowTag:')
542
+ );
543
+ if (remainingActionableErrors.length === 0) {
544
+ errors = [];
531
545
  status = true;
532
546
  }
533
547
  }
@@ -9,6 +9,7 @@ export const VALID_EVENT_ENUM = [
9
9
  'lambdaSyncInv',
10
10
  'lambdaSyncApi',
11
11
  'dsq',
12
+ 'dss',
12
13
  'generateCode'
13
14
  ];
14
15
  export const VALID_CODE_HOOK_TAG_ENUM = ['before', 'after'];
@@ -110,6 +111,21 @@ export function setupBasicValidatorSchema(targetSchema = basicValidatorSchema) {
110
111
  VALID_GENERATED_BY_ENUM;
111
112
  }
112
113
 
114
+ if (targetSchema.relationshipBasicSchema?.patternProperties) {
115
+ for (const patternSchema of Object.values(
116
+ targetSchema.relationshipBasicSchema.patternProperties
117
+ )) {
118
+ if (patternSchema?.properties?.generatedBy) {
119
+ patternSchema.properties.generatedBy.enum = Array.from(
120
+ new Set([
121
+ ...(patternSchema.properties.generatedBy.enum || []),
122
+ ...VALID_GENERATED_BY_ENUM
123
+ ])
124
+ );
125
+ }
126
+ }
127
+ }
128
+
113
129
  const objectSchemasToPatch = [
114
130
  targetSchema.basicObjectSchema,
115
131
  targetSchema.basicExtendObjectSchema
@@ -5,8 +5,8 @@ import { customFlowNextSteps } from '../custom/customFlows.js';
5
5
  import { createCrudActionPlans } from '../crud/crudActionPlan.js';
6
6
 
7
7
  const TEMPLATE_URL = new URL('./templates/', import.meta.url);
8
- const APP_ROOT = 'app/sls_yaml/generatedCode/source';
9
- const SRC_ROOT = 'app/src/generatedCode/CoreFunctions';
8
+ // const APP_ROOT = 'app/sls_yaml/generatedCode/source';
9
+ // const SRC_ROOT = 'app/src/generatedCode/CoreFunctions';
10
10
  const INITIAL_SETUP_ROOT = 'app/initial_setup/generatedCode/source';
11
11
  const INITIAL_SETUP_DATA_ROOT = 'app/initial_setup/generatedCode/data';
12
12
 
@@ -159,21 +159,21 @@ export function coreFunctionManagedPaths(
159
159
  ]);
160
160
 
161
161
  const paths = [
162
- `${APP_ROOT}/core-function.yml`,
163
- `${APP_ROOT}/core-resource.yml`,
164
- `${SRC_ROOT}/UploadSchema_HdrInv.js`,
165
- `${SRC_ROOT}/UploadSchema_Main.js`,
166
- `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
167
- `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
168
- `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
169
- `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
170
- `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
171
- `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
172
- `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
173
- `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
174
- `${SRC_ROOT}/InitialSetup_HdrInv.js`,
175
- `${SRC_ROOT}/InitialSetup_Main.js`,
176
- `${SRC_ROOT}/InitialSetupConfig.js`,
162
+ // `${APP_ROOT}/core-function.yml`,
163
+ // `${APP_ROOT}/core-resource.yml`,
164
+ // `${SRC_ROOT}/UploadSchema_HdrInv.js`,
165
+ // `${SRC_ROOT}/UploadSchema_Main.js`,
166
+ // `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
167
+ // `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
168
+ // `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
169
+ // `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
170
+ // `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
171
+ // `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
172
+ // `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
173
+ // `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
174
+ // `${SRC_ROOT}/InitialSetup_HdrInv.js`,
175
+ // `${SRC_ROOT}/InitialSetup_Main.js`,
176
+ // `${SRC_ROOT}/InitialSetupConfig.js`,
177
177
  `${INITIAL_SETUP_ROOT}/InitialSetupConfig.js`,
178
178
  `${INITIAL_SETUP_ROOT}/runner.js`,
179
179
  `${INITIAL_SETUP_ROOT}/commands/initialSetup.js`,
@@ -253,20 +253,20 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
253
253
  };
254
254
 
255
255
  const [
256
- coreFunctionYaml,
257
- coreResourceYaml,
258
- uploadSchemaHdrInv,
259
- uploadSchemaMain,
260
- generateSeedDataDynamoHdrInv,
261
- generateSeedDataDynamoMain,
262
- removeSeedDataDynamoHdrInv,
263
- removeSeedDataDynamoMain,
264
- generateSeedDataGraphDataHdrInv,
265
- generateSeedDataGraphDataMain,
266
- generateSeedDataGraphSchemaHdrInv,
267
- generateSeedDataGraphSchemaMain,
268
- initialSetupHdrInv,
269
- initialSetupMain,
256
+ // coreFunctionYaml,
257
+ // coreResourceYaml,
258
+ // uploadSchemaHdrInv,
259
+ // uploadSchemaMain,
260
+ // generateSeedDataDynamoHdrInv,
261
+ // generateSeedDataDynamoMain,
262
+ // removeSeedDataDynamoHdrInv,
263
+ // removeSeedDataDynamoMain,
264
+ // generateSeedDataGraphDataHdrInv,
265
+ // generateSeedDataGraphDataMain,
266
+ // generateSeedDataGraphSchemaHdrInv,
267
+ // generateSeedDataGraphSchemaMain,
268
+ // initialSetupHdrInv,
269
+ // initialSetupMain,
270
270
  initialSetupConfig,
271
271
  initialSetupRunner,
272
272
  commandInitialSetup,
@@ -275,20 +275,20 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
275
275
  commandSeedGraph,
276
276
  commandUploadSchema
277
277
  ] = await Promise.all([
278
- render('CoreFunction_Yaml.ejs', state),
279
- render('CoreResource_Yaml.ejs', state),
280
- render('UploadSchema_HdrInv.ejs', state),
281
- render('UploadSchema_Main.ejs', state),
282
- render('GenerateSeedDataDynamo_HdrInv.ejs', state),
283
- render('GenerateSeedDataDynamo_Main.ejs', state),
284
- render('RemoveSeedDataDynamo_HdrInv.ejs', state),
285
- render('RemoveSeedDataDynamo_Main.ejs', state),
286
- render('GenerateSeedDataGraphData_HdrInv.ejs', state),
287
- render('GenerateSeedDataGraphData_Main.ejs', state),
288
- render('GenerateSeedDataGraphSchema_HdrInv.ejs', state),
289
- render('GenerateSeedDataGraphSchema_Main.ejs', state),
290
- render('InitialSetup_HdrInv.ejs', state),
291
- render('InitialSetup_Main.ejs', state),
278
+ // render('CoreFunction_Yaml.ejs', state),
279
+ // render('CoreResource_Yaml.ejs', state),
280
+ // render('UploadSchema_HdrInv.ejs', state),
281
+ // render('UploadSchema_Main.ejs', state),
282
+ // render('GenerateSeedDataDynamo_HdrInv.ejs', state),
283
+ // render('GenerateSeedDataDynamo_Main.ejs', state),
284
+ // render('RemoveSeedDataDynamo_HdrInv.ejs', state),
285
+ // render('RemoveSeedDataDynamo_Main.ejs', state),
286
+ // render('GenerateSeedDataGraphData_HdrInv.ejs', state),
287
+ // render('GenerateSeedDataGraphData_Main.ejs', state),
288
+ // render('GenerateSeedDataGraphSchema_HdrInv.ejs', state),
289
+ // render('GenerateSeedDataGraphSchema_Main.ejs', state),
290
+ // render('InitialSetup_HdrInv.ejs', state),
291
+ // render('InitialSetup_Main.ejs', state),
292
292
  render('InitialSetupConfig.ejs', state),
293
293
  render('InitialSetupRunner.ejs', state),
294
294
  render('InitialSetupRunner_initialSetup.ejs', state),
@@ -299,66 +299,66 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
299
299
  ]);
300
300
 
301
301
  const baseArtifacts = [
302
- {
303
- path: `${APP_ROOT}/core-function.yml`,
304
- content: normalizeYaml(coreFunctionYaml)
305
- },
306
- {
307
- path: `${APP_ROOT}/core-resource.yml`,
308
- content: normalizeYaml(coreResourceYaml)
309
- },
310
- {
311
- path: `${SRC_ROOT}/UploadSchema_HdrInv.js`,
312
- content: uploadSchemaHdrInv
313
- },
314
- {
315
- path: `${SRC_ROOT}/UploadSchema_Main.js`,
316
- content: uploadSchemaMain
317
- },
318
- {
319
- path: `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
320
- content: generateSeedDataDynamoHdrInv
321
- },
322
- {
323
- path: `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
324
- content: generateSeedDataDynamoMain
325
- },
326
- {
327
- path: `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
328
- content: removeSeedDataDynamoHdrInv
329
- },
330
- {
331
- path: `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
332
- content: removeSeedDataDynamoMain
333
- },
334
- {
335
- path: `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
336
- content: generateSeedDataGraphDataHdrInv
337
- },
338
- {
339
- path: `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
340
- content: generateSeedDataGraphDataMain
341
- },
342
- {
343
- path: `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
344
- content: generateSeedDataGraphSchemaHdrInv
345
- },
346
- {
347
- path: `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
348
- content: generateSeedDataGraphSchemaMain
349
- },
350
- {
351
- path: `${SRC_ROOT}/InitialSetup_HdrInv.js`,
352
- content: initialSetupHdrInv
353
- },
354
- {
355
- path: `${SRC_ROOT}/InitialSetup_Main.js`,
356
- content: initialSetupMain
357
- },
358
- {
359
- path: `${SRC_ROOT}/InitialSetupConfig.js`,
360
- content: initialSetupConfig
361
- },
302
+ // {
303
+ // path: `${APP_ROOT}/core-function.yml`,
304
+ // content: normalizeYaml(coreFunctionYaml)
305
+ // },
306
+ // {
307
+ // path: `${APP_ROOT}/core-resource.yml`,
308
+ // content: normalizeYaml(coreResourceYaml)
309
+ // },
310
+ // {
311
+ // path: `${SRC_ROOT}/UploadSchema_HdrInv.js`,
312
+ // content: uploadSchemaHdrInv
313
+ // },
314
+ // {
315
+ // path: `${SRC_ROOT}/UploadSchema_Main.js`,
316
+ // content: uploadSchemaMain
317
+ // },
318
+ // {
319
+ // path: `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
320
+ // content: generateSeedDataDynamoHdrInv
321
+ // },
322
+ // {
323
+ // path: `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
324
+ // content: generateSeedDataDynamoMain
325
+ // },
326
+ // {
327
+ // path: `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
328
+ // content: removeSeedDataDynamoHdrInv
329
+ // },
330
+ // {
331
+ // path: `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
332
+ // content: removeSeedDataDynamoMain
333
+ // },
334
+ // {
335
+ // path: `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
336
+ // content: generateSeedDataGraphDataHdrInv
337
+ // },
338
+ // {
339
+ // path: `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
340
+ // content: generateSeedDataGraphDataMain
341
+ // },
342
+ // {
343
+ // path: `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
344
+ // content: generateSeedDataGraphSchemaHdrInv
345
+ // },
346
+ // {
347
+ // path: `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
348
+ // content: generateSeedDataGraphSchemaMain
349
+ // },
350
+ // {
351
+ // path: `${SRC_ROOT}/InitialSetup_HdrInv.js`,
352
+ // content: initialSetupHdrInv
353
+ // },
354
+ // {
355
+ // path: `${SRC_ROOT}/InitialSetup_Main.js`,
356
+ // content: initialSetupMain
357
+ // },
358
+ // {
359
+ // path: `${SRC_ROOT}/InitialSetupConfig.js`,
360
+ // content: initialSetupConfig
361
+ // },
362
362
  {
363
363
  path: `${INITIAL_SETUP_ROOT}/InitialSetupConfig.js`,
364
364
  content: initialSetupConfig
@@ -432,9 +432,9 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
432
432
  return baseArtifacts;
433
433
  }
434
434
 
435
- function normalizeYaml(content) {
436
- return `${content.trimEnd()}\n`;
437
- }
435
+ // function normalizeYaml(content) {
436
+ // return `${content.trimEnd()}\n`;
437
+ // }
438
438
 
439
439
  async function render(templateName, data) {
440
440
  return ejsLib.render(
@@ -14,13 +14,13 @@
14
14
  */
15
15
 
16
16
  import fs from 'fs';
17
- import yaml from 'yaml';
17
+ import { readYamlFileSync } from 'read-yaml-file';
18
18
  import { join } from 'path';
19
19
 
20
20
  // 1. Parse serverless config and set environment variables
21
21
  const configPath = join(process.cwd(), '..', 'config', 'serverless.config.yml');
22
22
  if (fs.existsSync(configPath)) {
23
- const serverlessConfig = yaml.parse(fs.readFileSync(configPath, 'utf8'));
23
+ const serverlessConfig = readYamlFileSync(configPath);
24
24
  const izConfig = serverlessConfig.main_config || {};
25
25
  process.env.iz_stage = izConfig.iz_stage || process.env.iz_stage;
26
26
  process.env.iz_region = izConfig.iz_region || process.env.iz_region;
@@ -145,6 +145,8 @@ export default async function CreateComplete(
145
145
  }
146
146
  const callingFlowConfig =
147
147
  result?.additionalAttributes?.callingFlowConfig ||
148
+ requestParams?.passBackProperties?.parentPassBackProperties ||
149
+ passBackProperties?.passBackProperties?.parentPassBackProperties ||
148
150
  passBackProperties;
149
151
  const actionData = {
150
152
  objType: returnValue.requestParams.objType,
@@ -170,13 +170,20 @@ export async function resolveAndGenerateIdentifiers(
170
170
  objectSchemas
171
171
  );
172
172
 
173
- foundErrors.push(
174
- ...(await createNodeLib.validateRequiredOnCreateLinks(
175
- _izContext,
176
- objType,
177
- requestParams.relationships
178
- ))
179
- );
173
+ try {
174
+ foundErrors.push(
175
+ ...(await createNodeLib.validateRequiredOnCreateLinks(
176
+ _izContext,
177
+ objType,
178
+ requestParams.relationships
179
+ ))
180
+ );
181
+ } catch (err) {
182
+ _izContext.logger.warn(
183
+ `[${process.env.iz_serviceTag}:<%- flowTag %>] validateRequiredOnCreateLinks warning:`,
184
+ err.message
185
+ );
186
+ }
180
187
  _izContext.logger.debug(
181
188
  `[${process.env.iz_serviceTag}:<%- flowTag %>] foundErrors:`,
182
189
  foundErrors
@@ -145,6 +145,8 @@ export default async function DeleteComplete(
145
145
  }
146
146
  const callingFlowConfig =
147
147
  result?.additionalAttributes?.callingFlowConfig ||
148
+ requestParams?.passBackProperties?.parentPassBackProperties ||
149
+ passBackProperties?.passBackProperties?.parentPassBackProperties ||
148
150
  passBackProperties;
149
151
  const actionData = {
150
152
  objType: returnValue.requestParams.objType,
@@ -89,10 +89,10 @@ export const main = middleware.wrap(async (event, context) => {
89
89
  flowSchema.statusType === 'triggerCache'
90
90
  ) {
91
91
  const taskKey = `${createFlowTypeConcat(event._izContext, { flowTag: '<%- flowTag %>', serviceTag: process.env.iz_serviceTag })}${identifiers}`;
92
- event._izContext.logger.debug('[FlowEndpoint_HdrWbs] registering WebSocketTask with ttl', {
92
+ event._izContext.logger.debug('[FlowEndpoint_HdrWbs] registering WebSocketTask with expirationTime', {
93
93
  taskKey,
94
94
  connectionId,
95
- ttl: 600
95
+ expirationTime: Math.floor(Date.now() / 1000) + 7200
96
96
  });
97
97
  await dynamodbSharedLib.putItem(
98
98
  event._izContext,
@@ -103,14 +103,15 @@ export const main = middleware.wrap(async (event, context) => {
103
103
  {
104
104
  taskKey,
105
105
  connectionId: connectionId,
106
- ttl: 600
106
+ expirationTime: Math.floor(Date.now() / 1000) + 7200
107
107
  }
108
108
  );
109
109
  } else if (flowSchema.statusType === 'none') {
110
110
  const taskKey = `${createFlowTypeConcat(event._izContext, { flowTag: '<%- flowTag %>', serviceTag: process.env.iz_serviceTag })}${correlationId}`;
111
111
  event._izContext.logger.debug('[FlowEndpoint_HdrWbs] registering WebSocketTask for status none', {
112
112
  taskKey,
113
- connectionId
113
+ connectionId,
114
+ expirationTime: Math.floor(Date.now() / 1000) + 7200
114
115
  });
115
116
  await dynamodbSharedLib.putItem(
116
117
  event._izContext,
@@ -120,7 +121,8 @@ export const main = middleware.wrap(async (event, context) => {
120
121
  ),
121
122
  {
122
123
  taskKey,
123
- connectionId: connectionId
124
+ connectionId: connectionId,
125
+ expirationTime: Math.floor(Date.now() / 1000) + 7200
124
126
  }
125
127
  );
126
128
  }
@@ -145,6 +145,8 @@ export default async function UpdateComplete(
145
145
  }
146
146
  const callingFlowConfig =
147
147
  result?.additionalAttributes?.callingFlowConfig ||
148
+ requestParams?.passBackProperties?.parentPassBackProperties ||
149
+ passBackProperties?.passBackProperties?.parentPassBackProperties ||
148
150
  passBackProperties;
149
151
 
150
152
  const actionData = {
@@ -4,7 +4,8 @@ import {
4
4
  generatedDsqFlows,
5
5
  generatedOwnTopicFlows,
6
6
  supportedCustomFlows,
7
- upperFirst
7
+ upperFirst,
8
+ resolveS3Parts
8
9
  } from './customFlows.js';
9
10
 
10
11
  export const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-schema.yml';
@@ -70,23 +71,19 @@ export function flowPaths(flow, objects = []) {
70
71
  paths.push(...ownTopicRootPaths(flow, objects));
71
72
  }
72
73
  if (flow.event.includes('s3')) {
73
- const s3Actions = [
74
- 'ConfirmAfterUpload',
75
- 'CreateObject',
76
- 'CreatePreSignUrl',
77
- 'ProcessAfterUpload',
78
- 'ReservedLimit'
79
- ];
80
- for (const action of s3Actions) {
81
- let handler = 'HdrSqs';
82
- if (action === 'CreateObject') {
83
- handler = 'HdrWbs';
84
- } else if (action === 'ProcessAfterUpload') {
85
- handler = 'HdrS3';
74
+ const parts = resolveS3Parts(flow);
75
+ for (const { action, handler } of parts) {
76
+ let isStart = false;
77
+ if (typeof action === 'string' && action.toLowerCase() === 'start') {
78
+ isStart = true;
79
+ }
80
+ let baseName = `${tag}${action}`;
81
+ if (isStart) {
82
+ baseName = tag;
86
83
  }
87
84
  paths.push(
88
- `${source}/${tag}${action}_Main.js`,
89
- `${source}/${tag}${action}_${handler}.js`
85
+ `${source}/${baseName}_Main.js`,
86
+ `${source}/${baseName}_${handler}.js`
90
87
  );
91
88
  }
92
89
  }