@izara_project/izara-market-library-service-schemas 1.0.53 → 1.0.55

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 (59) hide show
  1. package/package.json +2 -2
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +1 -1
  3. package/src/reStructure/TemplateConfig.js +4 -1
  4. package/src/reStructure/TemplateData/Auth/generateAuthYml/data.js +58 -0
  5. package/src/reStructure/TemplateData/Auth/generateAuthYml/template.ejs +16 -0
  6. package/src/reStructure/TemplateData/Auth/generateTemplateData.js +51 -0
  7. package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -1
  8. package/src/reStructure/TemplateData/EndpointPerService/handler/dsq/template.ejs +2 -1
  9. package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -0
  10. package/src/reStructure/TemplateData/EndpointPerService/handler/sqs/template.ejs +2 -0
  11. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +78 -54
  12. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/delete/template.ejs +42 -22
  13. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +44 -9
  14. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/update/template.ejs +30 -10
  15. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +6 -3
  16. package/src/reStructure/TemplateData/EndpointPerService/yaml/template.ejs +12 -16
  17. package/src/reStructure/TemplateData/externalService/lambdaRole/data.js +22 -6
  18. package/src/reStructure/TemplateData/externalService/snsTopicSubscriptions/template.ejs +2 -2
  19. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +2 -2
  20. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +4 -0
  21. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/functionYaml/data.js +14 -11
  22. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/data.js +2 -47
  23. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/handler/template.ejs +4 -1
  24. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +9 -13
  25. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/data.js +6 -6
  26. package/src/reStructure/TemplateData/flowSchema/{flowSchemaOwnTopic/EndpointComponent/mainFunction → flowSchemaMainFunction}/template.ejs +11 -14
  27. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/functionYaml/data.js +12 -8
  28. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/handler/template.ejs +6 -2
  29. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/functionYaml/data.js +1 -1
  30. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +1 -1
  31. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -1
  32. package/src/reStructure/TemplateData/flowSchema/flowStep/functionYaml/data.js +1 -1
  33. package/src/reStructure/TemplateData/flowSchema/flowStep/handler/template.ejs +8 -1
  34. package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/data.js +2 -2
  35. package/src/reStructure/TemplateData/flowSchema/flowStep/mainFunction/template.ejs +2 -7
  36. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +22 -24
  37. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/data.js +11 -2
  38. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/functionYaml/template.ejs +11 -5
  39. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/handler/data.js +1 -1
  40. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/handler/template.ejs +27 -23
  41. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/functionYaml/data.js +1 -1
  42. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/data.js +1 -1
  43. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/handler/template.ejs +10 -4
  44. package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/storedCacheTemplate.ejs +3 -0
  45. package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/triggerCacheTemplate.ejs +3 -0
  46. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/functionYaml/data.js +0 -1
  47. package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/data.js +10 -2
  48. package/src/reStructure/TemplateData/perActionEndpoint/yaml/api/template.ejs +1 -1
  49. package/src/reStructure/TemplateData/relationshipPerAction/create/action/mainFunction/template.ejs +18 -2
  50. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/handler/sqs/template.ejs +2 -1
  51. package/src/reStructure/TemplateData/relationshipPerAction/create/complete/mainFunction/template.ejs +5 -1
  52. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/data.js +0 -75
  53. package/src/reStructure/TemplateData/flowSchema/externalTopic/Process/mainFunction/template.ejs +0 -98
  54. package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/sqsTemplate.ejs +0 -52
  55. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/mainFunction/data.js +0 -57
  56. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Api/mainFunction/template.ejs +0 -81
  57. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/mainFunction/data.js +0 -58
  58. package/src/reStructure/TemplateData/flowSchema/lambdaSync/Inv/mainFunction/template.ejs +0 -81
  59. /package/src/reStructure/TemplateData/flowSchema/{templateBystatusType → templateByStatusType}/statusFieldTemplate.ejs +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-market-library-service-schemas",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "description": "Schemas for Izara Market project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,7 +24,7 @@
24
24
  "@izara_project/izara-core-library-core": "^1.0.20",
25
25
  "@izara_project/izara-core-library-external-request": "^1.0.20",
26
26
  "@izara_project/izara-core-library-logger": "^1.0.7",
27
- "@izara_project/izara-core-library-service-schemas": "^1.0.83",
27
+ "@izara_project/izara-core-library-service-schemas": "^1.0.84",
28
28
  "@izara_project/izara-core-library-sns": "^1.0.6",
29
29
  "@izara_project/izara-core-library-sqs": "^1.0.4",
30
30
  "@izara_project/izara-shared": "^1.0.126",
@@ -108,7 +108,7 @@ async function validateSchemaPerRecord(
108
108
  lambdaFunctionName,
109
109
  objType,
110
110
  action,
111
- setting = { bucketName: consts.OBJECT_SCHEMA_BUCKET_NAME }
111
+ setting = { bucketName: consts.OBJECT_SCHEMA_BUCKET_NAME, specificFieldNames: [] }
112
112
  ) {
113
113
  try {
114
114
  record._izContext.logger.debug("validateSchemaPerRecord: ",
@@ -47,7 +47,10 @@ module.exports = {
47
47
  flowSchema: './TemplateData/flowSchema/generateTemplateData.js',
48
48
 
49
49
  // ** endpoint per service **
50
- endpointPerServiceConfig: './TemplateData/EndpointPerService/generateTemplateData.js'
50
+ endpointPerServiceConfig: './TemplateData/EndpointPerService/generateTemplateData.js',
51
+
52
+ // ** Auth **
53
+ auth: "./TemplateData/Auth/generateTemplateData.js"
51
54
  },
52
55
  Plugin: {
53
56
 
@@ -0,0 +1,58 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const path = require('path');
21
+ const fs = require('fs');
22
+ const yaml = require('yaml');
23
+ const { ACTIONS, HANDLER, STORAGE_TYPES } = require('@izara_project/izara-core-library-service-schemas/src/Consts');
24
+ const {
25
+ SOURCE_PATH,
26
+ } = require("../../../../MainLibs/src/Consts.js");
27
+ const {
28
+ firstLetterLowerCase: lowerCase,
29
+ firstLetterUpperCase: upperCase,
30
+ } = require('../../../../MainLibs/src/Utils.js');
31
+
32
+ const templatePath = path.join(__dirname, "./template.ejs")
33
+
34
+ /**
35
+ * receive objectSchema
36
+ * create data for hdrInv template
37
+ *
38
+ * @param {Object} objectSchema
39
+ * @return {{ templatePath, templateData, setting } }
40
+ */
41
+ function data(_izContext, srcPath) {
42
+ return {
43
+ templatePath: templatePath,
44
+ templateData: {},
45
+ setting: {
46
+ savePath: path.join(srcPath, SOURCE_PATH.appYaml),
47
+ saveFileName: "Authorizer",
48
+ fileExtension: '.yml',
49
+ isAppend: true
50
+ }
51
+ }
52
+
53
+ }
54
+
55
+
56
+
57
+
58
+ module.exports = data;
@@ -0,0 +1,16 @@
1
+ authorizerServiceSchema:
2
+ type: request
3
+ functionArn: ${self:custom.iz_authorizerServiceSchemaV2}
4
+ identitySource:
5
+ - $request.header.Authorization
6
+ - $context.routeKey
7
+ resultTtlInSeconds: 300
8
+
9
+ authorizerIdentifiers:
10
+ type: request
11
+ functionArn: ${self:custom.iz_authorizerServiceSchemaV2}
12
+ identitySource:
13
+ - $request.header.Authorization
14
+ - $context.routeKey
15
+ - $request.querystring.identifiers
16
+ resultTtlInSeconds: 300
@@ -0,0 +1,51 @@
1
+ /*
2
+ Copyright (C) 2020 Sven Mason <http://izara.io>
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const { join } = require('path');
21
+ const {
22
+ getAllLocalObjectSchemasWithHierarchy
23
+ } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
24
+ const NoRetryError = require('@izara_project/izara-core-library-core').NoRetryError
25
+ // Import handlers and generators
26
+ const generateAuth = require('./generateAuthYml/data')
27
+
28
+ // Import code libs generator
29
+ // const createGenerateCodeLibs = require('./libs/data');
30
+
31
+ /**
32
+ * Generates code from templates based on object schemas
33
+ * @param {Object} _izContext - Context object
34
+ * @param {string} objSchemaPath - Path to object schema
35
+ * @returns {Promise<Array>} - Array of parameter objects for code generation
36
+ */
37
+ async function generateCodeWithTemplate(_izContext, objSchemaPath) {
38
+ try {
39
+ const saveFilePath = join(objSchemaPath, `../`);
40
+ let authYamlFile = generateAuth(_izContext, saveFilePath)
41
+
42
+ const createSourceParams = [authYamlFile];
43
+
44
+ return createSourceParams;
45
+ } catch (error) {
46
+ _izContext.logger.error('Error generating code with template endpointPerService:', error);
47
+ return [];
48
+ }
49
+ }
50
+
51
+ module.exports = generateCodeWithTemplate;
@@ -48,8 +48,9 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
48
48
  let lambdaFunctionResponse = await <%- action %>Main(
49
49
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId/userId
50
50
  event.body,
51
+ //(<additionalParams>)
52
+ //(</additionalParams>)
51
53
  callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
52
-
53
54
  );
54
55
 
55
56
  // return error to client
@@ -89,7 +89,8 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
89
89
  //(</additionalParams>)
90
90
 
91
91
  passOnProperties.push(record.body.Message);
92
- passOnProperties.push(OBJTYPE);
92
+ //(<additionalParams>)
93
+ //(</additionalParams>)
93
94
  passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
94
95
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
95
96
 
@@ -56,6 +56,8 @@ module.exports.main = middleware.wrap(async (event, context, callback) => {
56
56
  return await <%- action %>Main(
57
57
  event._izContext, // correlationId/logger/integrationTestDetail/uniqueRequestId
58
58
  event,
59
+ //(<additionalParams>)
60
+ //(</additionalParams>)
59
61
  callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
60
62
  );
61
63
 
@@ -86,6 +86,8 @@ module.exports.main = middleware.wrap(async (event,context, callback) => {
86
86
  //(</additionalParams>)
87
87
 
88
88
  passOnProperties.push(record.body.Message);
89
+ //(<additionalParams>)
90
+ //(</additionalParams>)
89
91
  passOnProperties.push(callingFlowSharedLib.addCallingFlowToPassOnProperties(record.body.Message));
90
92
  record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
91
93
 
@@ -16,35 +16,49 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
+
20
+ // ──────────────────────── Core Node Modules ────────────────────────
21
+ const lodash = require("lodash");
22
+
23
+ // ──────────────────────── Shared Core Libraries ────────────────────────
24
+ const hash = require('@izara_project/izara-shared-core').objectHash;
25
+
26
+ // ──────────────────────── Izara Core Libraries ────────────────────────
19
27
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
20
28
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
21
29
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
22
30
  const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
23
31
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
32
+ const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
33
+ const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
24
34
 
35
+ // ──────────────────────── Middleware / External ────────────────────────
36
+ const middlewareConsts = require('@izara_project/izara-middleware').consts;
25
37
  const externalRequest = require('@izara_project/izara-core-library-external-request');
26
38
  const sns = externalRequest.sns;
27
- const lambda = externalRequest.lambda
28
39
 
29
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
30
- const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
40
+ // ──────────────────────── Service Schemas ────────────────────────
41
+ const { createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
42
+ const { createNodeLib, uploadUseCase, consts, getObjectSchema } = require('@izara_project/izara-core-library-service-schemas');
31
43
 
32
- const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
33
-
34
- const hash = require('@izara_project/izara-shared-core').objectHash;
35
- const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
36
- const path = require('path')
37
- const schemasPath = path.join(__dirname, '../schemas');
38
- const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
39
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
44
+ // ──────────────────────── Graph Service Libraries ────────────────────────
45
+ const graphSharedLibs = require('@izara_project/izara-core-library-graph-service');
40
46
 
47
+ // ──────────────────────── Market Library Service Schemas ────────────────────────
41
48
  const {
42
- generateDynamoDbIdentifiers,
43
49
  dynamoDbIdentifiersByStorageResource,
44
- collectGetData
50
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
51
+ const {
52
+ TOPIC_NAME_GENERATE_CODE,
53
+ TOPIC_NAME_GRAPH_HANDLER,
54
+ GRAPH_HANDLER_SERVICE_NAME,
55
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
56
+ const {
57
+ createDataDetailsLib,
45
58
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
46
59
 
47
-
60
+ //(<optionalRequire>)
61
+ //(</optionalRequire>)
48
62
 
49
63
  //-----------------------------------------------------------------------------------------------------------
50
64
  const PREFIX = {
@@ -54,15 +68,6 @@ const PREFIX = {
54
68
  CREATE_OBJECT_ASYNC_COMPLETE: "createObjectAsyncComplete"
55
69
  }
56
70
  //-----------------------------------------------------------------------------------------------------------
57
- const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER, GRAPH_HANDLER_SERVICE_NAME } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
58
- const { createDataDetailsLib } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
59
- const { createLinkTypeId, createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
60
- const { findLinksByObjTypes } = require("@izara_project/izara-core-library-service-schemas/src/libs/RelSchemaLib")
61
- const lodash = require("lodash")
62
- const { createRelTypeConcat } = require('@izara_project/izara-core-library-service-schemas').utils
63
- const createNodeLib = require('@izara_project/izara-core-library-service-schemas').createNodeLib
64
- //(<optionalRequire>)
65
- //(</optionalRequire>)
66
71
 
67
72
  /**
68
73
  *
@@ -74,7 +79,9 @@ const createNodeLib = require('@izara_project/izara-core-library-service-schemas
74
79
  module.exports.createMain = async (
75
80
  _izContext,
76
81
  requestParams,
77
- callingFlowConfig
82
+ //(<additionalParams>)
83
+ //(</additionalParams>)
84
+ callingFlowConfig = {}
78
85
  ) => {
79
86
  try {
80
87
  _izContext.logger.debug("function CreateMain:", {
@@ -117,12 +124,13 @@ module.exports.createMain = async (
117
124
  );
118
125
  _izContext.logger.debug("objectSchemas", objectSchemas);
119
126
 
120
-
127
+ let userAgent = _izContext.correlationIds.get(middlewareConsts.USER_AGENT)
128
+ _izContext.logger.debug("userAgent::", userAgent);
121
129
 
122
130
  let createDataDetails = await createDataDetailsLib(
123
131
  _izContext,
124
132
  objectSchemas,
125
- );
133
+ );
126
134
  _izContext.logger.debug("createDataDetails is =", createDataDetails);
127
135
 
128
136
 
@@ -132,11 +140,11 @@ module.exports.createMain = async (
132
140
  }
133
141
  errorsFound.push(
134
142
  ...await createNodeLib.validateRequiredOnCreateLinks(
135
- _izContext,
136
- objType,
137
- requestParams.relationships,
143
+ _izContext,
144
+ objType,
145
+ requestParams.relationships,
138
146
  )
139
- )
147
+ )
140
148
  _izContext.logger.debug("errorsFound", errorsFound)
141
149
 
142
150
  // end validate
@@ -306,7 +314,7 @@ module.exports.createMain = async (
306
314
  ...objInstanceFullForDynamoDb.fields
307
315
  }
308
316
  );
309
- // (<afterCreateRecordDynamo>)
317
+ //(<afterCreateRecordDynamo>)
310
318
  //(</afterCreateRecordDynamo>)
311
319
  } else if (createDataDetail.storageType == consts.STORAGE_TYPES.graph) {
312
320
  //(<beforeCreateNode>)
@@ -391,12 +399,14 @@ module.exports.createMain = async (
391
399
  return fields
392
400
  }
393
401
  /// step save awaitingMultipleStep of storageType graph ...........................................................
394
-
395
- await asyncFlowSharedLib.createAwaitingMultipleSteps(
396
- _izContext,
397
- allAwaitingStepsId,
398
- asyncFlowSharedLib.createPendingStepId((hash({ objType: objType, identifiers: objInstanceFull.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)
399
- );
402
+ if (!userAgent) {
403
+ _izContext.logger.debug("not api will create awaitingStep")
404
+ await asyncFlowSharedLib.createAwaitingMultipleSteps(
405
+ _izContext,
406
+ allAwaitingStepsId,
407
+ asyncFlowSharedLib.createPendingStepId((hash({ objType: objType, identifiers: objInstanceFull.identifiers })), PREFIX.CREATE_OBJECT_ASYNC_COMPLETE)
408
+ );
409
+ }
400
410
  //............................................................................................................
401
411
 
402
412
  // process storageType : graph
@@ -427,25 +437,39 @@ module.exports.createMain = async (
427
437
  settings: { updatePropertiesOnMatch: false },
428
438
  originTimestamp: Date.now(),
429
439
  });
430
-
431
- messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
432
- messageObject,
433
- callingFlowSharedLib.addParentCallingFlowConfig(
434
- callingFlowConfig, // receive parent callingFlowConfig.
435
- callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
436
- //(<callingFlowProperties>)
437
- await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createNodeComplete), {}
438
- //(</callingFlowProperties>)
439
- )
440
+ if (userAgent) {
441
+ _izContext.logger.debug("have userAgent will invoke GraphHandler")
442
+ let createNodeResult = await graphSharedLibs.createNodeV2(
443
+ _izContext,
444
+ graphServiceName,
445
+ objType,
446
+ objInstanceFullForGraph,
447
+ requestParams.relationships || [],
448
+ Date.now(),
449
+ { updatePropertiesOnMatch: false },
440
450
  )
441
- );
451
+ return createNodeResult
452
+ } else {
453
+ _izContext.logger.debug("not have userAgent will send Message to GraphHandler")
454
+ messageObject = callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
455
+ messageObject,
456
+ callingFlowSharedLib.addParentCallingFlowConfig(
457
+ callingFlowConfig, // receive parent callingFlowConfig.
458
+ callingFlowSharedLib.createCallingFlowConfig( // calling flow own service
459
+ //(<callingFlowProperties>)
460
+ await lambdaSharedLib.lambdaFunctionName(_izContext, TOPIC_NAME_GENERATE_CODE.createNodeComplete), {}
461
+ //(</callingFlowProperties>)
462
+ )
463
+ )
464
+ );
442
465
 
443
- let messageToCreateObject = {
444
- Message: JSON.stringify(messageObject),
445
- TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateNode, graphServiceName)
446
- };
447
- _izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
448
- await sns.publishAsync(_izContext, messageToCreateObject);
466
+ let messageToCreateObject = {
467
+ Message: JSON.stringify(messageObject),
468
+ TopicArn: await snsSharedLib.snsTopicArnByFlowSchema(_izContext, TOPIC_NAME_GRAPH_HANDLER.inCreateNode, graphServiceName)
469
+ };
470
+ _izContext.logger.debug("RequestParams before send to sqs messageToCreateObject ::::::: ", messageToCreateObject);
471
+ await sns.publishAsync(_izContext, messageToCreateObject);
472
+ }
449
473
 
450
474
  //(<afterSendMessageToGraph>)
451
475
  //(</afterSendMessageToGraph>)
@@ -16,42 +16,60 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
 
18
18
  'use strict';
19
- const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
20
- const snsSharedLib = require('@izara_project/izara-core-library-sns');
21
- const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
22
- const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
23
- const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
24
19
 
25
- const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
26
- const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
27
- const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
20
+ // ==================== Built-in Modules ====================
21
+ const path = require('path');
22
+ const schemasPath = path.join(__dirname, '../schemas');
28
23
 
29
- const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase')
30
24
 
25
+ // ==================== Shared Core Utilities ====================
31
26
  const hash = require('@izara_project/izara-shared-core').objectHash;
32
27
  const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
33
- const path = require('path')
34
- const schemasPath = path.join(__dirname, '../schemas');
28
+ const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
29
+
30
+
31
+ // ==================== Core Service Schemas ====================
32
+ const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
35
33
  const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
36
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
34
+ const { createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
35
+ const serviceConfigLib = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
36
+ const {
37
+ getGraphServiceTagWithCache,
38
+ getServiceNameWithCache,
39
+ } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
40
+ const uploadUseCase = require('@izara_project/izara-core-library-service-schemas/src/libs/UploadUseCase');
37
41
 
42
+
43
+ // ==================== Market Service Schemas ====================
38
44
  const {
39
45
  generateDynamoDbIdentifiers,
40
46
  dynamoDbIdentifiersByStorageResource,
41
- collectGetData
47
+ collectGetData,
48
+ createDeleteDataDetail,
42
49
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
43
50
 
44
51
  const {
45
- getGraphServiceTagWithCache,
46
- getServiceNameWithCache
47
- } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
52
+ TOPIC_NAME_GENERATE_CODE,
53
+ TOPIC_NAME_GRAPH_HANDLER,
54
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
55
+
56
+
57
+ // ==================== Shared Libraries ====================
58
+ const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
59
+ const snsSharedLib = require('@izara_project/izara-core-library-sns');
60
+ const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
61
+ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
62
+ const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
63
+
64
+
65
+ // ==================== External Resources ====================
66
+ const sns = require('@izara_project/izara-core-library-external-request/src/resources/Sns');
67
+
48
68
 
49
- const { TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts')
50
- const { createDeleteDataDetail } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs')
51
- const { createObjType } = require("@izara_project/izara-core-library-service-schemas/src/Utils");
69
+ // ==================== Optional Requires ====================
70
+ // (<optionalRequire>)
71
+ // (</optionalRequire>)
52
72
 
53
- //(<optionalRequire>)
54
- //(</optionalRequire>)
55
73
  /**
56
74
  *
57
75
  * @param {*} _izContext
@@ -62,7 +80,9 @@ const { createObjType } = require("@izara_project/izara-core-library-service-sch
62
80
  module.exports.deleteMain = async (
63
81
  _izContext,
64
82
  requestParams,
65
- callingFlowConfig
83
+ //(<additionalParams>)
84
+ //(</additionalParams>)
85
+ callingFlowConfig = {}
66
86
  ) => {
67
87
  try {
68
88
  _izContext.logger.debug("function:DeleteMain::", {
@@ -18,6 +18,7 @@ Copyright (C) 2020 Sven Mason <http: //izara.io>
18
18
 
19
19
  'use strict';
20
20
 
21
+ // ==================== Izara Core Service Schemas ====================
21
22
  const {
22
23
  getObjSchemaS3WithHierarchy,
23
24
  } = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema');
@@ -29,17 +30,33 @@ const {
29
30
  const consts = require('@izara_project/izara-core-library-service-schemas/src/Consts');
30
31
 
31
32
  const {
32
- objInstanceFromObjInstanceBase
33
+ objInstanceFromObjInstanceBase,
33
34
  } = require('@izara_project/izara-core-library-service-schemas/src/IdentifiersObject');
34
35
 
36
+ const {
37
+ createObjTypeConcat,
38
+ createObjType,
39
+ } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
40
+
41
+
42
+ // ==================== Izara Market Service Schemas ====================
35
43
  const {
36
44
  dynamoDbIdentifiersByStorageResource,
37
45
  collectGetData,
38
46
  createGetDataDetails,
39
47
  } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
40
48
 
41
- const { createObjTypeConcat, createObjType } = require('@izara_project/izara-core-library-service-schemas/src/Utils');
49
+ const {
50
+ TOPIC_NAME_GENERATE_CODE,
51
+ } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
52
+
42
53
 
54
+ // ==================== Shared Core Libraries ====================
55
+ const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
56
+ const coreConsts = require('@izara_project/izara-core-library-core/src/Consts');
57
+
58
+
59
+ // ==================== Shared Utility Libraries ====================
43
60
  const dynamodbSharedLib = require('@izara_project/izara-core-library-dynamodb');
44
61
  const snsSharedLib = require('@izara_project/izara-core-library-sns');
45
62
  const asyncFlowSharedLib = require('@izara_project/izara-core-library-asynchronous-flow');
@@ -47,14 +64,16 @@ const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-
47
64
  const lambdaSharedLib = require('@izara_project/izara-core-library-lambda');
48
65
  const graphSharedLib = require('@izara_project/izara-core-library-graph-service');
49
66
 
67
+
68
+ // ==================== External Services ====================
50
69
  const externalRequest = require('@izara_project/izara-core-library-external-request');
51
- const sns = externalRequest.sns
70
+ const sns = externalRequest.sns;
71
+
72
+
73
+ // ==================== Optional Requires ====================
74
+ // (<optionalRequire>)
75
+ // (</optionalRequire>)
52
76
 
53
- const NoRetryError = require('@izara_project/izara-core-library-core/src/NoRetryError');
54
- const { TOPIC_NAME_GENERATE_CODE } = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/Consts');
55
- const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
56
- //(<optionalRequire>)
57
- //(</optionalRequire>)
58
77
  /**
59
78
  *
60
79
  *
@@ -72,9 +91,9 @@ const coreConsts = require("@izara_project/izara-core-library-core/src/Consts");
72
91
  module.exports.getMain = async (
73
92
  _izContext,
74
93
  requestParams,
75
- callingFlowConfig = {},
76
94
  //(<additionalParams>)
77
95
  //(</additionalParams>)
96
+ callingFlowConfig = {},
78
97
  ) => {
79
98
  try {
80
99
  _izContext.logger.debug('function GetMain: ', {
@@ -87,6 +106,7 @@ module.exports.getMain = async (
87
106
 
88
107
  //(<beforeQuery>)
89
108
  //(</beforeQuery>)
109
+
90
110
  const objType = createObjType(requestParams.objectType)
91
111
  let objectSchema = await getObjSchemaS3WithHierarchy(
92
112
  _izContext,
@@ -95,6 +115,21 @@ module.exports.getMain = async (
95
115
 
96
116
  _izContext.logger.debug("objectSchema: ", objectSchema);
97
117
 
118
+ let userId;
119
+ let targetId;
120
+ if (objectSchema.generatedBy === "userGenerated") {
121
+ userId = _izContext.correlationIds.get(coreConsts.BASE_USER_ID);
122
+ targetId = _izContext.correlationIds.get(coreConsts.TARGET_ID)
123
+
124
+ if (!userId) {
125
+ errorsFound.push("Not have userId")
126
+ }
127
+
128
+ if (objectSchema.hasOwnProperty("belongTo") && !targetId) {
129
+ errorsFound.push('not have targetId')
130
+ }
131
+ }
132
+
98
133
  let getDataDetails = await createGetDataDetails(
99
134
  _izContext,
100
135
  objectSchema,