@izara_project/izara-core-generate-service-code 1.0.71 → 1.0.73

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 (67) hide show
  1. package/package.json +4 -3
  2. package/src/compile/loadSchemas.js +69 -1
  3. package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +171 -44
  4. package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +4 -1
  5. package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +4 -1
  6. package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +4 -1
  7. package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +10 -2
  8. package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +17 -17
  9. package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +6 -6
  10. package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +12 -12
  11. package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +195 -58
  12. package/src/emit/coreFunction/templates/InitialSetupRunner.ejs +177 -0
  13. package/src/emit/coreFunction/templates/InitialSetupRunner_initialSetup.ejs +9 -0
  14. package/src/emit/coreFunction/templates/InitialSetupRunner_seedDynamo.ejs +22 -0
  15. package/src/emit/coreFunction/templates/InitialSetupRunner_seedGraph.ejs +8 -0
  16. package/src/emit/coreFunction/templates/InitialSetupRunner_seedRemove.ejs +5 -0
  17. package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +33 -0
  18. package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +9 -11
  19. package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +1 -3
  20. package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +1 -1
  21. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
  22. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
  23. package/src/emit/crud/templates/FlowMain_Wbs.ejs +1 -2
  24. package/src/emit/crud/templates/GetEndpoint_Main.ejs +1 -1
  25. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
  26. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
  27. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +26 -6
  28. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
  29. package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
  30. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
  31. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
  32. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +13 -9
  33. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
  34. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
  35. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
  36. package/src/emit/relationship/templates/GetRelationship_Main.ejs +53 -32
  37. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
  38. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
  39. package/src/emit/resource/emitResourceArtifacts.js +58 -17
  40. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
  41. package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
  42. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +9 -10
  43. package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
  44. package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
  45. package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
  46. package/src/emit/resource/templates/S3Bucket_Yaml.ejs +0 -1
  47. package/src/emit/resource/templates/S3Subscription_Yaml.ejs +6 -6
  48. package/src/emit/resource/templates/SharedResource_Yaml.ejs +4 -4
  49. package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +115 -115
  50. package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +6 -6
  51. package/src/emit/shared/templates/FindData_HdrSqs.ejs +1 -1
  52. package/src/emit/shared/templates/FlowHandler_HdrApi.ejs +9 -7
  53. package/src/emit/shared/templates/FlowHandler_HdrDsq.ejs +19 -12
  54. package/src/emit/shared/templates/FlowHandler_HdrInv.ejs +9 -7
  55. package/src/emit/shared/templates/FlowHandler_HdrSqs.ejs +19 -12
  56. package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +1 -1
  57. package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +1 -1
  58. package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +2 -2
  59. package/src/emit/shared/templates/ProcessLogical_HdrSqs.ejs +1 -1
  60. package/src/generate.js +26 -5
  61. package/src/output/mergeHooks.js +13 -13
  62. package/src/output/validateArtifacts.js +10 -1
  63. package/test/customFlowApplicationArtifacts.test.js +71 -0
  64. package/test/publicApi.test.js +2 -2
  65. package/test/resourceArtifacts.test.js +8 -18
  66. package/docs/TriggeredCache Flow.drawio +0 -193
  67. package/docs/TriggeredCacheFlow.mmd +0 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
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": {
@@ -26,12 +26,13 @@
26
26
  "@izara_project/izara-shared-core": "^1.0.13",
27
27
  "ejs": "^6.0.1",
28
28
  "js-beautify": "^2.0.3",
29
+ "ws": "^8.21.2",
29
30
  "yaml": "^2.9.0"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@izara_project/izara-core-library-logger": "^1.0.11",
33
- "@izara_project/izara-core-library-service-schemas": "1.0.158",
34
- "@izara_project/izara-shared-service-schemas": "^1.0.67",
34
+ "@izara_project/izara-core-library-service-schemas": "1.0.161",
35
+ "@izara_project/izara-shared-service-schemas": "^1.0.70",
35
36
  "jest": "^30.4.2",
36
37
  "prettier": "^3.9.6",
37
38
  "prettier-plugin-ejs": "^1.0.3"
@@ -5,6 +5,7 @@ import {
5
5
  getObjectSchema,
6
6
  utils
7
7
  } from '@izara_project/izara-core-library-service-schemas';
8
+ import { s3 } from '@izara_project/izara-core-library-s3';
8
9
  import Logger from '@izara_project/izara-core-library-logger';
9
10
 
10
11
  export async function loadLocalSchemaDirectory(project, directoryName) {
@@ -129,7 +130,9 @@ export async function resolveExtendedObjectSchemas(
129
130
  for (const [key, resource] of Object.entries(mergedStorageResources)) {
130
131
  if (
131
132
  resource &&
132
- resource.storageType === 'dynamoDB' &&
133
+ (resource.storageType === 'dynamo' ||
134
+ resource.storageType === 'dynamoDB' ||
135
+ !resource.storageType) &&
133
136
  !childStorageResourceKeys.has(key)
134
137
  ) {
135
138
  externalDynamoResources.push({
@@ -196,3 +199,68 @@ export async function resolveExtendedObjectSchemas(
196
199
  }
197
200
  return resolvedSchemas;
198
201
  }
202
+
203
+ export async function resolveGraphServiceTags(
204
+ schemas,
205
+ bucketName = process.env.iz_serviceSchemaBucketName
206
+ ) {
207
+ if (!Array.isArray(schemas) || schemas.length === 0) {
208
+ return [];
209
+ }
210
+
211
+ const graphServerTags = new Set();
212
+ for (const schema of schemas) {
213
+ if (!schema || typeof schema !== 'object') continue;
214
+ let targetObjs = [];
215
+ if (schema.storageResources) {
216
+ targetObjs = [schema];
217
+ } else {
218
+ targetObjs = Object.values(schema).filter(
219
+ (val) => val && typeof val === 'object' && val.storageResources
220
+ );
221
+ }
222
+
223
+ for (const targetObj of targetObjs) {
224
+ const resources = targetObj.storageResources;
225
+ if (resources && typeof resources === 'object') {
226
+ for (const res of Object.values(resources)) {
227
+ if (res?.storageType === 'graph' && res.graphServerTag) {
228
+ graphServerTags.add(res.graphServerTag);
229
+ }
230
+ }
231
+ }
232
+ }
233
+ }
234
+
235
+ if (graphServerTags.size === 0) {
236
+ return [];
237
+ }
238
+
239
+ let graphServerTagsMap = {};
240
+ if (bucketName) {
241
+ try {
242
+ const _izContext = { logger: Logger };
243
+ const s3Data = await s3.getObjectS3(_izContext, {
244
+ Bucket: bucketName,
245
+ Key: 'serviceConfig/GraphServerTags.json'
246
+ });
247
+ if (s3Data && typeof s3Data === 'object') {
248
+ graphServerTagsMap = s3Data;
249
+ }
250
+ } catch (error) {
251
+ Logger.debug?.(
252
+ `[DEBUG] [resolveGraphServiceTags] Could not fetch GraphServerTags.json from bucket=${bucketName}`,
253
+ error
254
+ );
255
+ }
256
+ }
257
+
258
+ const resolvedTags = new Set();
259
+ for (const tag of graphServerTags) {
260
+ const serviceTag = graphServerTagsMap[tag] || tag || 'GraphHandler';
261
+ resolvedTags.add(serviceTag);
262
+ }
263
+
264
+ return Array.from(resolvedTags);
265
+ }
266
+
@@ -4,33 +4,101 @@ import { readFile } from 'node:fs/promises';
4
4
  const TEMPLATE_URL = new URL('./templates/', import.meta.url);
5
5
  const APP_ROOT = 'app/sls_yaml/generatedCode/source';
6
6
  const SRC_ROOT = 'app/src/generatedCode/CoreFunctions';
7
+ const INITIAL_SETUP_ROOT = 'app/initial_setup/generatedCode/source';
8
+ const INITIAL_SETUP_DATA_ROOT = 'app/initial_setup/generatedCode/data';
9
+
10
+ function _extractDynamoTableNames(objects = []) {
11
+ const dynamoTableNames = new Set();
12
+ for (const obj of objects || []) {
13
+ if (obj && obj.storageResources) {
14
+ for (const res of Object.values(obj.storageResources)) {
15
+ if (
16
+ res &&
17
+ res.tableName &&
18
+ (res.storageType === 'dynamo' ||
19
+ res.storageType === 'dynamoDB' ||
20
+ !res.storageType)
21
+ ) {
22
+ dynamoTableNames.add(res.tableName);
23
+ }
24
+ }
25
+ }
26
+ }
27
+ return dynamoTableNames;
28
+ }
29
+
30
+ export function coreFunctionManagedPaths(
31
+ objects = [],
32
+ objectGraphServiceTags = [],
33
+ relationshipGraphServiceTags = []
34
+ ) {
35
+ const dynamoTableNames = _extractDynamoTableNames(objects);
36
+ const graphTags = new Set([
37
+ ...(objectGraphServiceTags || []),
38
+ ...(relationshipGraphServiceTags || [])
39
+ ]);
40
+
41
+ const paths = [
42
+ `${APP_ROOT}/core-function.yml`,
43
+ `${APP_ROOT}/core-resource.yml`,
44
+ `${SRC_ROOT}/UploadSchema_HdrInv.js`,
45
+ `${SRC_ROOT}/UploadSchema_Main.js`,
46
+ `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
47
+ `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
48
+ `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
49
+ `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
50
+ `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
51
+ `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
52
+ `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
53
+ `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
54
+ `${SRC_ROOT}/InitialSetup_HdrInv.js`,
55
+ `${SRC_ROOT}/InitialSetup_Main.js`,
56
+ `${SRC_ROOT}/InitialSetupConfig.js`,
57
+ `${INITIAL_SETUP_ROOT}/InitialSetupConfig.js`,
58
+ `${INITIAL_SETUP_ROOT}/runner.js`,
59
+ `${INITIAL_SETUP_ROOT}/commands/initialSetup.js`,
60
+ `${INITIAL_SETUP_ROOT}/commands/seedDynamo.js`,
61
+ `${INITIAL_SETUP_ROOT}/commands/seedRemove.js`,
62
+ `${INITIAL_SETUP_ROOT}/commands/seedGraph.js`,
63
+ `${INITIAL_SETUP_ROOT}/commands/uploadSchema.js`,
64
+ `${INITIAL_SETUP_DATA_ROOT}/dynamo/test/Config.json`
65
+ ];
66
+
67
+ for (const tableName of dynamoTableNames) {
68
+ paths.push(`${INITIAL_SETUP_DATA_ROOT}/dynamo/test/${tableName}.json`);
69
+ }
70
+
71
+ for (const tag of graphTags) {
72
+ paths.push(`${INITIAL_SETUP_DATA_ROOT}/graph/${tag}/nodeConfig/.gitkeep`);
73
+ paths.push(`${INITIAL_SETUP_DATA_ROOT}/graph/${tag}/relationshipConfig/.gitkeep`);
74
+ }
75
+
76
+ return paths;
77
+ }
78
+
79
+ export async function emitCoreFunctionArtifacts({ project, objects = [], relationships = [], flows = [], objectGraphServiceTags = [], relationshipGraphServiceTags = [] }) {
80
+ const crud = objects.length > 0;
81
+ const hasRelationships = relationships.length > 0;
82
+ const s3Flows = (flows || [])
83
+ .filter((flow) => Array.isArray(flow?.event) && flow.event.includes('s3'))
84
+ .map((flow) => {
85
+ let roleName = '';
86
+ if (typeof flow.flowTag === 'string' && flow.flowTag) {
87
+ roleName = flow.flowTag[0].toUpperCase() + flow.flowTag.slice(1);
88
+ }
89
+ return { roleName };
90
+ });
7
91
 
8
- export const coreFunctionManagedPaths = [
9
- `${APP_ROOT}/core-function.yml`,
10
- `${APP_ROOT}/core-resource.yml`,
11
- `${SRC_ROOT}/UploadSchema_HdrInv.js`,
12
- `${SRC_ROOT}/UploadSchema_Main.js`,
13
- `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
14
- `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
15
- `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
16
- `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
17
- `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
18
- `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
19
- `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
20
- `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
21
- `${SRC_ROOT}/InitialSetup_HdrInv.js`,
22
- `${SRC_ROOT}/InitialSetup_Main.js`,
23
- `${SRC_ROOT}/generated/GeneratedTableConfigs.js`,
24
- `${SRC_ROOT}/generated/GeneratedGraphNodeSchemas.js`,
25
- `${SRC_ROOT}/generated/GeneratedGraphRelSchemas.js`,
26
- `${SRC_ROOT}/InitialSetupConfig.js`
27
- ];
28
-
29
- export async function emitCoreFunctionArtifacts({ project, objects = [], relationships = [] }) {
30
92
  const state = {
31
93
  project,
32
94
  objects,
33
95
  relationships,
96
+ flows,
97
+ objectGraphServiceTags,
98
+ relationshipGraphServiceTags,
99
+ crud,
100
+ hasRelationships,
101
+ s3Flows,
34
102
  hasGenerateGraph: objects.length > 0 || relationships.length > 0
35
103
  };
36
104
 
@@ -47,12 +115,15 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
47
115
  generateSeedDataGraphDataMain,
48
116
  generateSeedDataGraphSchemaHdrInv,
49
117
  generateSeedDataGraphSchemaMain,
50
- generatedTableConfigs,
51
- generatedGraphNodeSchemas,
52
- generatedGraphRelSchemas,
53
- initialSetupConfig,
54
118
  initialSetupHdrInv,
55
- initialSetupMain
119
+ initialSetupMain,
120
+ initialSetupConfig,
121
+ initialSetupRunner,
122
+ commandInitialSetup,
123
+ commandSeedDynamo,
124
+ commandSeedRemove,
125
+ commandSeedGraph,
126
+ commandUploadSchema
56
127
  ] = await Promise.all([
57
128
  render('CoreFunction_Yaml.ejs', state),
58
129
  render('CoreResource_Yaml.ejs', state),
@@ -66,15 +137,18 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
66
137
  render('GenerateSeedDataGraphData_Main.ejs', state),
67
138
  render('GenerateSeedDataGraphSchema_HdrInv.ejs', state),
68
139
  render('GenerateSeedDataGraphSchema_Main.ejs', state),
69
- render('GeneratedTableConfigs.ejs', state),
70
- render('GeneratedGraphNodeSchemas.ejs', state),
71
- render('GeneratedGraphRelSchemas.ejs', state),
72
- render('InitialSetupConfig.ejs', state),
73
140
  render('InitialSetup_HdrInv.ejs', state),
74
- render('InitialSetup_Main.ejs', state)
141
+ render('InitialSetup_Main.ejs', state),
142
+ render('InitialSetupConfig.ejs', state),
143
+ render('InitialSetupRunner.ejs', state),
144
+ render('InitialSetupRunner_initialSetup.ejs', state),
145
+ render('InitialSetupRunner_seedDynamo.ejs', state),
146
+ render('InitialSetupRunner_seedRemove.ejs', state),
147
+ render('InitialSetupRunner_seedGraph.ejs', state),
148
+ render('InitialSetupRunner_uploadSchema.ejs', state)
75
149
  ]);
76
150
 
77
- return [
151
+ const baseArtifacts = [
78
152
  {
79
153
  path: `${APP_ROOT}/core-function.yml`,
80
154
  content: normalizeYaml(coreFunctionYaml)
@@ -124,31 +198,84 @@ export async function emitCoreFunctionArtifacts({ project, objects = [], relatio
124
198
  content: generateSeedDataGraphSchemaMain
125
199
  },
126
200
  {
127
- path: `${SRC_ROOT}/generated/GeneratedTableConfigs.js`,
128
- content: generatedTableConfigs
201
+ path: `${SRC_ROOT}/InitialSetup_HdrInv.js`,
202
+ content: initialSetupHdrInv
129
203
  },
130
204
  {
131
- path: `${SRC_ROOT}/generated/GeneratedGraphNodeSchemas.js`,
132
- content: generatedGraphNodeSchemas
205
+ path: `${SRC_ROOT}/InitialSetup_Main.js`,
206
+ content: initialSetupMain
133
207
  },
134
208
  {
135
- path: `${SRC_ROOT}/generated/GeneratedGraphRelSchemas.js`,
136
- content: generatedGraphRelSchemas
209
+ path: `${SRC_ROOT}/InitialSetupConfig.js`,
210
+ content: initialSetupConfig,
211
+ writeWhenFileExist: false
137
212
  },
138
213
  {
139
- path: `${SRC_ROOT}/InitialSetupConfig.js`,
214
+ path: `${INITIAL_SETUP_ROOT}/InitialSetupConfig.js`,
140
215
  content: initialSetupConfig,
141
216
  writeWhenFileExist: false // Don't overwrite the file that dev modifies
142
217
  },
143
218
  {
144
- path: `${SRC_ROOT}/InitialSetup_HdrInv.js`,
145
- content: initialSetupHdrInv
219
+ path: `${INITIAL_SETUP_ROOT}/runner.js`,
220
+ content: initialSetupRunner
146
221
  },
147
222
  {
148
- path: `${SRC_ROOT}/InitialSetup_Main.js`,
149
- content: initialSetupMain
223
+ path: `${INITIAL_SETUP_ROOT}/commands/initialSetup.js`,
224
+ content: commandInitialSetup
225
+ },
226
+ {
227
+ path: `${INITIAL_SETUP_ROOT}/commands/seedDynamo.js`,
228
+ content: commandSeedDynamo
229
+ },
230
+ {
231
+ path: `${INITIAL_SETUP_ROOT}/commands/seedRemove.js`,
232
+ content: commandSeedRemove
233
+ },
234
+ {
235
+ path: `${INITIAL_SETUP_ROOT}/commands/seedGraph.js`,
236
+ content: commandSeedGraph
237
+ },
238
+ {
239
+ path: `${INITIAL_SETUP_ROOT}/commands/uploadSchema.js`,
240
+ content: commandUploadSchema
150
241
  }
151
242
  ];
243
+
244
+ const defaultConfigContent = '[\n]\n';
245
+
246
+ baseArtifacts.push({
247
+ path: `${INITIAL_SETUP_DATA_ROOT}/dynamo/test/Config.json`,
248
+ content: defaultConfigContent,
249
+ writeWhenFileExist: false
250
+ });
251
+
252
+ const dynamoTableNames = _extractDynamoTableNames(objects);
253
+ for (const tableName of dynamoTableNames) {
254
+ baseArtifacts.push({
255
+ path: `${INITIAL_SETUP_DATA_ROOT}/dynamo/test/${tableName}.json`,
256
+ content: '[\n]\n',
257
+ writeWhenFileExist: false
258
+ });
259
+ }
260
+
261
+ const graphTags = new Set([
262
+ ...(objectGraphServiceTags || []),
263
+ ...(relationshipGraphServiceTags || [])
264
+ ]);
265
+ for (const tag of graphTags) {
266
+ baseArtifacts.push({
267
+ path: `${INITIAL_SETUP_DATA_ROOT}/graph/${tag}/nodeConfig/.gitkeep`,
268
+ content: '',
269
+ writeWhenFileExist: false
270
+ });
271
+ baseArtifacts.push({
272
+ path: `${INITIAL_SETUP_DATA_ROOT}/graph/${tag}/relationshipConfig/.gitkeep`,
273
+ content: '',
274
+ writeWhenFileExist: false
275
+ });
276
+ }
277
+
278
+ return baseArtifacts;
152
279
  }
153
280
 
154
281
  function normalizeYaml(content) {
@@ -8,7 +8,10 @@ const main = middleware.wrap(async (event, context, callback) => {
8
8
  try {
9
9
  return await generateMain.generateSeedDataDynamo(event);
10
10
  } catch (err) {
11
- event._izContext.logger.error('Error, GenerateSeedDataDynamo_HdrInv: ', err);
11
+ event._izContext.logger.error(
12
+ 'Error, GenerateSeedDataDynamo_HdrInv: ',
13
+ err
14
+ );
12
15
  throw err;
13
16
  }
14
17
  });
@@ -8,7 +8,10 @@ const main = middleware.wrap(async (event, context, callback) => {
8
8
  try {
9
9
  return await generateMain.generateSeedDataGraphData(event);
10
10
  } catch (err) {
11
- event._izContext.logger.error('Error, GenerateSeedDataGraphData_HdrInv: ', err);
11
+ event._izContext.logger.error(
12
+ 'Error, GenerateSeedDataGraphData_HdrInv: ',
13
+ err
14
+ );
12
15
  throw err;
13
16
  }
14
17
  });
@@ -8,7 +8,10 @@ const main = middleware.wrap(async (event, context, callback) => {
8
8
  try {
9
9
  return await generateMain.generateSeedDataGraphSchema(event);
10
10
  } catch (err) {
11
- event._izContext.logger.error('Error, GenerateSeedDataGraphSchema_HdrInv: ', err);
11
+ event._izContext.logger.error(
12
+ 'Error, GenerateSeedDataGraphSchema_HdrInv: ',
13
+ err
14
+ );
12
15
  throw err;
13
16
  }
14
17
  });
@@ -25,7 +25,11 @@ const generateSeedDataGraphSchema = async (event) => {
25
25
  console.log('====== Start refresh Seed Data: graph schema ======');
26
26
 
27
27
  // for production env
28
- await initialSetupSharedLib.generateSchema(_izContext, nodeSchemas(), 'node'); // node schema
28
+ await initialSetupSharedLib.generateSchema(
29
+ _izContext,
30
+ nodeSchemas(),
31
+ 'node'
32
+ ); // node schema
29
33
  await initialSetupSharedLib.generateSchema(
30
34
  _izContext,
31
35
  relationshipSchemas(),
@@ -43,7 +47,11 @@ const generateSeedDataGraphSchema = async (event) => {
43
47
  ); // relationship version data schema
44
48
 
45
49
  // for test env
46
- await initialSetupSharedLib.generateSchema(_izContext, config.graphNodeSchemas(), 'node'); // node schema
50
+ await initialSetupSharedLib.generateSchema(
51
+ _izContext,
52
+ config.graphNodeSchemas(),
53
+ 'node'
54
+ ); // node schema
47
55
  await initialSetupSharedLib.generateSchema(
48
56
  _izContext,
49
57
  config.graphRelationshipSchemas(),
@@ -5,43 +5,43 @@
5
5
  export function generatedGraphNodeSchemas() {
6
6
  const schemas = {};
7
7
 
8
- <% objects.forEach(obj => { -%>
9
- <% if (obj.storageResources && obj.storageResources.graph) { -%>
8
+ <% objects.forEach(obj => { -%>
9
+ <% if (obj.storageResources && obj.storageResources.graph) { -%>
10
10
  const serverTag_<%= obj.objectType %> = '<%= obj.storageResources.graph.graphServerTag %>';
11
11
  if (!schemas[serverTag_<%= obj.objectType %>]) {
12
12
  schemas[serverTag_<%= obj.objectType %>] = {};
13
13
  }
14
-
14
+
15
15
  schemas[serverTag_<%= obj.objectType %>].<%= obj.objectType %> = {
16
16
  identifier: true,
17
17
  immutable: false,
18
18
  restrictProperties: false,
19
19
  restrictRelationships: false,
20
20
  properties: {
21
- <% if (obj.identifiers && obj.identifiers.length > 0) { -%>
22
- <% obj.identifiers.forEach(id => { -%>
21
+ <% if (obj.identifiers && obj.identifiers.length > 0) { -%>
22
+ <% obj.identifiers.forEach(id => { -%>
23
23
  <%= id.fieldName %>: {
24
24
  identifier: true,
25
25
  immutable: true
26
26
  },
27
- <% }); -%>
28
- <% } -%>
29
- <% if (obj.fieldNames) { -%>
30
- <% Object.keys(obj.fieldNames).forEach(fieldName => { -%>
31
- <% const isId = obj.identifiers && obj.identifiers.some(i => i.fieldName === fieldName); -%>
32
- <% if (!isId) { -%>
27
+ <% }); -%>
28
+ <% } -%>
29
+ <% if (obj.fieldNames) { -%>
30
+ <% Object.keys(obj.fieldNames).forEach(fieldName => { -%>
31
+ <% const isId = obj.identifiers && obj.identifiers.some(i => i.fieldName === fieldName); -%>
32
+ <% if (!isId) { -%>
33
33
  <%= fieldName %>: {
34
34
  identifier: false,
35
35
  immutable: <%= obj.fieldNames[fieldName].canUpdate === false ? 'true' : 'false' %>
36
- },
37
- <% } -%>
38
- <% }); -%>
39
- <% } -%>
36
+ }
37
+ <% } -%>
38
+ <% }); -%>
39
+ <% } -%>
40
40
  }
41
41
  };
42
42
 
43
- <% } -%>
44
- <% }); -%>
43
+ <% } -%>
44
+ <% }); -%>
45
45
 
46
46
  return schemas;
47
47
  }
@@ -5,10 +5,10 @@
5
5
  export function generatedGraphRelationshipSchemas() {
6
6
  const schemas = {};
7
7
 
8
- <% relationships.forEach(relObj => { -%>
9
- <% const relName = Object.keys(relObj)[0]; -%>
10
- <% const relData = relObj[relName]; -%>
11
- <% if (relData && relData.storageResources && relData.storageResources.graph) { -%>
8
+ <% relationships.forEach(relObj => { -%>
9
+ <% const relName = Object.keys(relObj)[0]; -%>
10
+ <% const relData = relObj[relName]; -%>
11
+ <% if (relData && relData.storageResources && relData.storageResources.graph) { -%>
12
12
  const serverTag_<%= relName %> = '<%= relData.storageResources.graph.graphServerTag %>';
13
13
  if (!schemas[serverTag_<%= relName %>]) {
14
14
  schemas[serverTag_<%= relName %>] = {};
@@ -20,8 +20,8 @@ export function generatedGraphRelationshipSchemas() {
20
20
  properties: {}
21
21
  };
22
22
 
23
- <% } -%>
24
- <% }); -%>
23
+ <% } -%>
24
+ <% }); -%>
25
25
 
26
26
  return schemas;
27
27
  }
@@ -4,12 +4,12 @@
4
4
 
5
5
  // Prod table configs (ตารางที่ Service นี้เป็นเจ้าของ)
6
6
  export const prodTableConfigs = {
7
- Config: {}
8
- <% objects.forEach(obj => { -%>
9
- <% if (obj.storageResources && obj.storageResources.dynamo) { -%>
10
- , <%= obj.storageResources.dynamo.tableName %>: {}
11
- <% } -%>
12
- <% }); -%>
7
+ Config: {},
8
+ <% objects.forEach(obj => { -%>
9
+ <% if (obj.storageResources && obj.storageResources.dynamo) { -%>
10
+ <%= obj.storageResources.dynamo.tableName %>: {}
11
+ <% } -%>
12
+ <% }); -%>
13
13
  };
14
14
 
15
15
  // Test table configs (flag สำหรับ refresh seed data)
@@ -23,12 +23,12 @@ export const testTableConfigs = {
23
23
  },
24
24
  GraphHandlerRelationshipSchema: {
25
25
  clearDataWhenRefresh: true
26
- }
27
- <% objects.forEach(obj => { -%>
28
- <% if (obj.storageResources && obj.storageResources.dynamo) { -%>
29
- , <%= obj.storageResources.dynamo.tableName %>: {
26
+ },
27
+ <% objects.forEach(obj => { -%>
28
+ <% if (obj.storageResources && obj.storageResources.dynamo) { -%>
29
+ <%= obj.storageResources.dynamo.tableName %>: {
30
30
  clearDataWhenRefresh: true
31
31
  }
32
- <% } -%>
33
- <% }); -%>
32
+ <% } -%>
33
+ <% }); -%>
34
34
  };