@izara_project/izara-core-generate-service-code 1.0.69 → 1.0.70
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 +1 -1
- package/scripts/format-ejs.js +35 -30
- package/src/compile/loadSchemas.js +84 -45
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +163 -0
- package/src/emit/coreFunction/templates/CoreFunction_Yaml.ejs +38 -0
- package/src/emit/coreFunction/templates/CoreResource_Yaml.ejs +235 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_Main.ejs +38 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_Main.ejs +32 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +71 -0
- package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +47 -0
- package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +27 -0
- package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +34 -0
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +108 -0
- package/src/emit/coreFunction/templates/InitialSetup_HdrInv.ejs +12 -0
- package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +51 -0
- package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_Main.ejs +31 -0
- package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +37 -0
- package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +52 -0
- package/src/emit/crud/emitCrudApplicationArtifacts.js +12 -6
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +30 -11
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +4 -4
- package/src/emit/function/functionYamlArtifact.js +5 -2
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +13 -3
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
- package/src/emit/resource/emitResourceArtifacts.js +64 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +17 -0
- package/src/emit/shared/templates/FindData_HdrSqs.ejs +120 -0
- package/src/emit/shared/templates/FindData_Main.ejs +345 -0
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrApi.ejs +1 -1
- package/src/emit/{relationship → shared}/templates/FlowHandler_HdrDsq.ejs +4 -4
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrInv.ejs +1 -1
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrSqs.ejs +4 -4
- package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +162 -0
- package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +140 -0
- package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +268 -0
- package/src/emit/{relationship/templates/FlowHandler_HdrSqs.ejs → shared/templates/ProcessLogical_HdrSqs.ejs} +40 -55
- package/src/emit/shared/templates/ProcessLogical_Main.ejs +448 -0
- package/src/emit/system/emitSystemFindDataArtifacts.js +266 -0
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +27 -11
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +63 -18
- package/src/emit/system/templates/WebSocketConnect.ejs +26 -6
- package/src/generate.js +31 -4
- package/src/output/mergeHooks.js +18 -19
- package/test/core.test.js +4 -12
- package/test/crudApplicationArtifacts.test.js +14 -18
- package/test/publicApi.test.js +2 -2
- package/test/resourceArtifacts.test.js +1 -1
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +0 -59
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +0 -47
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
|
+
import generateMain from './GenerateSeedDataDynamo_Main.js';
|
|
3
|
+
|
|
4
|
+
const main = middleware.wrap(async (event, context, callback) => {
|
|
5
|
+
event._izContext.logger.debug('Event:', event);
|
|
6
|
+
event._izContext.logger.debug('context:', context);
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
return await generateMain.generateSeedDataDynamo(event);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
event._izContext.logger.error('Error, GenerateSeedDataDynamo_HdrInv: ', err);
|
|
12
|
+
throw err;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { main };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
2
|
+
import correlationIds from '@izara_project/izara-core-library-correlation-ids';
|
|
3
|
+
import initialSetupSharedLib from '@izara_project/izara-core-library-initial-setup';
|
|
4
|
+
import config from './InitialSetupConfig.js';
|
|
5
|
+
|
|
6
|
+
const generateSeedDataDynamo = async (params) => {
|
|
7
|
+
const _izContext = {
|
|
8
|
+
correlationIds: correlationIds,
|
|
9
|
+
logger: Logger
|
|
10
|
+
};
|
|
11
|
+
try {
|
|
12
|
+
Logger.debug('======== Start Generate Seed Data ========', { params });
|
|
13
|
+
|
|
14
|
+
// // === generate new seed data test env ===
|
|
15
|
+
// --- generate new both
|
|
16
|
+
// await initialSetupSharedLib.generateSeedData(initialSetupServiceConfig) // prod
|
|
17
|
+
await initialSetupSharedLib.generateSeedDataTestEnv(
|
|
18
|
+
_izContext,
|
|
19
|
+
// test env
|
|
20
|
+
config.tableConfigs,
|
|
21
|
+
config.tableConfigsTestEnv,
|
|
22
|
+
config.paths.seedDataFilepath,
|
|
23
|
+
params.folderName,
|
|
24
|
+
params.bucketS3
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// // ===== Generate all new initial setup =====
|
|
28
|
+
// await initialSetupSharedLib.removeUserAccountTestEnv()
|
|
29
|
+
// await initialSetupSharedLib.generateUserAccountTestEnv(initialSetupConfigTestEnv.seedUserFilepath)
|
|
30
|
+
|
|
31
|
+
console.log('-------- Finish GenerateSeedDataDynamoTestEnv --------');
|
|
32
|
+
return 'Finish GenerateSeedDataDynamoTestEnv';
|
|
33
|
+
} catch (err) {
|
|
34
|
+
console.log(err);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default { generateSeedDataDynamo };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
|
+
import generateMain from './GenerateSeedDataGraphData_Main.js';
|
|
3
|
+
|
|
4
|
+
const main = middleware.wrap(async (event, context, callback) => {
|
|
5
|
+
event._izContext.logger.debug('Event:', event);
|
|
6
|
+
event._izContext.logger.debug('context:', context);
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
return await generateMain.generateSeedDataGraphData(event);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
event._izContext.logger.error('Error, GenerateSeedDataGraphData_HdrInv: ', err);
|
|
12
|
+
throw err;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { main };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import CorrelationIds from '@izara_project/izara-core-library-correlation-ids';
|
|
2
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
3
|
+
import IntegrationTestDetail from '@izara_project/izara-core-library-integration-tests/src/IntegrationTests.js';
|
|
4
|
+
const _izContext = { CorrelationIds, Logger, IntegrationTestDetail };
|
|
5
|
+
import { consts } from '@izara_project/izara-core-library-core';
|
|
6
|
+
|
|
7
|
+
import initialSetupSharedLib from '@izara_project/izara-core-library-initial-setup';
|
|
8
|
+
import config from './InitialSetupConfig.js';
|
|
9
|
+
|
|
10
|
+
const generateSeedDataGraphData = async (event) => {
|
|
11
|
+
try {
|
|
12
|
+
_izContext.correlationIds = new CorrelationIds();
|
|
13
|
+
_izContext.correlationIds.set(consts.BASE_USER_ID, config.paths.userId);
|
|
14
|
+
_izContext.correlationIds.set(
|
|
15
|
+
consts.RESOURCE_USE_USER_ID,
|
|
16
|
+
config.paths.userId
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
await initialSetupSharedLib.generateSeedDataGraphHandler(
|
|
20
|
+
_izContext,
|
|
21
|
+
config.paths.seedGraphFilepath // path
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
console.log('-------- Finished createSeedDataToGraph --------');
|
|
25
|
+
return '-------- Finished createSeedDataToGraph --------';
|
|
26
|
+
} catch (err) {
|
|
27
|
+
console.log(err);
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default { generateSeedDataGraphData };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
|
+
import generateMain from './GenerateSeedDataGraphSchema_Main.js';
|
|
3
|
+
|
|
4
|
+
const main = middleware.wrap(async (event, context, callback) => {
|
|
5
|
+
event._izContext.logger.debug('Event:', event);
|
|
6
|
+
event._izContext.logger.debug('context:', context);
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
return await generateMain.generateSeedDataGraphSchema(event);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
event._izContext.logger.error('Error, GenerateSeedDataGraphSchema_HdrInv: ', err);
|
|
12
|
+
throw err;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { main };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import initialSetupSharedLib from '@izara_project/izara-core-library-initial-setup';
|
|
2
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
3
|
+
import correlationIds from '@izara_project/izara-core-library-correlation-ids';
|
|
4
|
+
|
|
5
|
+
// require schema from prod env
|
|
6
|
+
import nodeSchemas from '../../../DataSchema/GraphNodes.js';
|
|
7
|
+
import relationshipSchemas from '../../../DataSchema/GraphRelationships.js';
|
|
8
|
+
import versionedData from '../../../DataSchema/GraphVersionedData.js';
|
|
9
|
+
const [versionedDataNodeSchemas, versionedDataRelationshipSchemas] =
|
|
10
|
+
versionedData();
|
|
11
|
+
|
|
12
|
+
// require schema from test env
|
|
13
|
+
import config from './InitialSetupConfig.js';
|
|
14
|
+
const [
|
|
15
|
+
versionedDataNodeSchemasTestEnv,
|
|
16
|
+
versionedDataRelationshipSchemasTestEnv
|
|
17
|
+
] = config.graphVersionedDataSchemas();
|
|
18
|
+
|
|
19
|
+
const generateSeedDataGraphSchema = async (event) => {
|
|
20
|
+
const _izContext = {
|
|
21
|
+
correlationIds: correlationIds,
|
|
22
|
+
logger: Logger
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
console.log('====== Start refresh Seed Data: graph schema ======');
|
|
26
|
+
|
|
27
|
+
// for production env
|
|
28
|
+
await initialSetupSharedLib.generateSchema(_izContext, nodeSchemas(), 'node'); // node schema
|
|
29
|
+
await initialSetupSharedLib.generateSchema(
|
|
30
|
+
_izContext,
|
|
31
|
+
relationshipSchemas(),
|
|
32
|
+
'relationship'
|
|
33
|
+
); // relationship schema
|
|
34
|
+
await initialSetupSharedLib.generateSchema(
|
|
35
|
+
_izContext,
|
|
36
|
+
versionedDataNodeSchemas,
|
|
37
|
+
'node'
|
|
38
|
+
); // node version data schema
|
|
39
|
+
await initialSetupSharedLib.generateSchema(
|
|
40
|
+
_izContext,
|
|
41
|
+
versionedDataRelationshipSchemas,
|
|
42
|
+
'relationship'
|
|
43
|
+
); // relationship version data schema
|
|
44
|
+
|
|
45
|
+
// for test env
|
|
46
|
+
await initialSetupSharedLib.generateSchema(_izContext, config.graphNodeSchemas(), 'node'); // node schema
|
|
47
|
+
await initialSetupSharedLib.generateSchema(
|
|
48
|
+
_izContext,
|
|
49
|
+
config.graphRelationshipSchemas(),
|
|
50
|
+
'relationship'
|
|
51
|
+
); // relationship schema
|
|
52
|
+
await initialSetupSharedLib.generateSchema(
|
|
53
|
+
_izContext,
|
|
54
|
+
versionedDataNodeSchemasTestEnv,
|
|
55
|
+
'node'
|
|
56
|
+
); // node version data schema
|
|
57
|
+
await initialSetupSharedLib.generateSchema(
|
|
58
|
+
_izContext,
|
|
59
|
+
versionedDataRelationshipSchemasTestEnv,
|
|
60
|
+
'relationship'
|
|
61
|
+
); // relationship version data schema
|
|
62
|
+
|
|
63
|
+
console.log('-------- Finish GenerateSeedDataGraphSchemaTestEnv --------');
|
|
64
|
+
return 'Finish GenerateSeedDataGraphSchemaTestEnv';
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.log(err);
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default { generateSeedDataGraphSchema };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated by Code Generator — DO NOT EDIT
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export function generatedGraphNodeSchemas() {
|
|
6
|
+
const schemas = {};
|
|
7
|
+
|
|
8
|
+
<% objects.forEach(obj => { -%>
|
|
9
|
+
<% if (obj.storageResources && obj.storageResources.graph) { -%>
|
|
10
|
+
const serverTag_<%= obj.objectType %> = '<%= obj.storageResources.graph.graphServerTag %>';
|
|
11
|
+
if (!schemas[serverTag_<%= obj.objectType %>]) {
|
|
12
|
+
schemas[serverTag_<%= obj.objectType %>] = {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
schemas[serverTag_<%= obj.objectType %>].<%= obj.objectType %> = {
|
|
16
|
+
identifier: true,
|
|
17
|
+
immutable: false,
|
|
18
|
+
restrictProperties: false,
|
|
19
|
+
restrictRelationships: false,
|
|
20
|
+
properties: {
|
|
21
|
+
<% if (obj.identifiers && obj.identifiers.length > 0) { -%>
|
|
22
|
+
<% obj.identifiers.forEach(id => { -%>
|
|
23
|
+
<%= id.fieldName %>: {
|
|
24
|
+
identifier: true,
|
|
25
|
+
immutable: true
|
|
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) { -%>
|
|
33
|
+
<%= fieldName %>: {
|
|
34
|
+
identifier: false,
|
|
35
|
+
immutable: <%= obj.fieldNames[fieldName].canUpdate === false ? 'true' : 'false' %>
|
|
36
|
+
},
|
|
37
|
+
<% } -%>
|
|
38
|
+
<% }); -%>
|
|
39
|
+
<% } -%>
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
<% } -%>
|
|
44
|
+
<% }); -%>
|
|
45
|
+
|
|
46
|
+
return schemas;
|
|
47
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated by Code Generator — DO NOT EDIT
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export function generatedGraphRelationshipSchemas() {
|
|
6
|
+
const schemas = {};
|
|
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) { -%>
|
|
12
|
+
const serverTag_<%= relName %> = '<%= relData.storageResources.graph.graphServerTag %>';
|
|
13
|
+
if (!schemas[serverTag_<%= relName %>]) {
|
|
14
|
+
schemas[serverTag_<%= relName %>] = {};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
schemas[serverTag_<%= relName %>].<%= relName %> = {
|
|
18
|
+
immutable: false,
|
|
19
|
+
restrictProperties: false,
|
|
20
|
+
properties: {}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
<% } -%>
|
|
24
|
+
<% }); -%>
|
|
25
|
+
|
|
26
|
+
return schemas;
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated by Code Generator — DO NOT EDIT
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Prod table configs (ตารางที่ Service นี้เป็นเจ้าของ)
|
|
6
|
+
export const prodTableConfigs = {
|
|
7
|
+
Config: {}
|
|
8
|
+
<% objects.forEach(obj => { -%>
|
|
9
|
+
<% if (obj.storageResources && obj.storageResources.dynamo) { -%>
|
|
10
|
+
, <%= obj.storageResources.dynamo.tableName %>: {}
|
|
11
|
+
<% } -%>
|
|
12
|
+
<% }); -%>
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Test table configs (flag สำหรับ refresh seed data)
|
|
16
|
+
export const testTableConfigs = {
|
|
17
|
+
Config: {
|
|
18
|
+
clearDataWhenRefresh: true,
|
|
19
|
+
rawSource: false
|
|
20
|
+
},
|
|
21
|
+
GraphHandlerNodeSchema: {
|
|
22
|
+
clearDataWhenRefresh: true
|
|
23
|
+
},
|
|
24
|
+
GraphHandlerRelationshipSchema: {
|
|
25
|
+
clearDataWhenRefresh: true
|
|
26
|
+
}
|
|
27
|
+
<% objects.forEach(obj => { -%>
|
|
28
|
+
<% if (obj.storageResources && obj.storageResources.dynamo) { -%>
|
|
29
|
+
, <%= obj.storageResources.dynamo.tableName %>: {
|
|
30
|
+
clearDataWhenRefresh: true
|
|
31
|
+
}
|
|
32
|
+
<% } -%>
|
|
33
|
+
<% }); -%>
|
|
34
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
19
|
+
import graphSharedLib from '@izara_project/izara-core-library-graph-service';
|
|
20
|
+
|
|
21
|
+
// Auto-generated configurations
|
|
22
|
+
import { prodTableConfigs, testTableConfigs } from './generated/GeneratedTableConfigs.js';
|
|
23
|
+
import { generatedGraphNodeSchemas } from './generated/GeneratedGraphNodeSchemas.js';
|
|
24
|
+
import { generatedGraphRelationshipSchemas } from './generated/GeneratedGraphRelSchemas.js';
|
|
25
|
+
|
|
26
|
+
// ============================================================
|
|
27
|
+
// External Service Config
|
|
28
|
+
// ============================================================
|
|
29
|
+
// <#InitialSetupConfig_ExternalServices#>
|
|
30
|
+
const externalServices = {
|
|
31
|
+
serviceTagGraphHandler: 'GraphHandler',
|
|
32
|
+
serviceTagRbac: 'Rbac'
|
|
33
|
+
};
|
|
34
|
+
// <#/InitialSetupConfig_ExternalServices#>
|
|
35
|
+
|
|
36
|
+
// ============================================================
|
|
37
|
+
// Paths
|
|
38
|
+
// ============================================================
|
|
39
|
+
// <#InitialSetupConfig_Paths#>
|
|
40
|
+
const paths = {
|
|
41
|
+
seedGraphFilepath: './__test__/graph_seed_data/',
|
|
42
|
+
seedDataFilepath: './__test__/dynamodb_seed_data/default/',
|
|
43
|
+
seedUserFilepath: './__test__/userAccounts.json',
|
|
44
|
+
userId: ''
|
|
45
|
+
};
|
|
46
|
+
// <#/InitialSetupConfig_Paths#>
|
|
47
|
+
|
|
48
|
+
// ============================================================
|
|
49
|
+
// Table Configs (generated + manual merge)
|
|
50
|
+
// ============================================================
|
|
51
|
+
const tableConfigs = {
|
|
52
|
+
...prodTableConfigs
|
|
53
|
+
// <#InitialSetupConfig_ExtraProdTableConfigs#>
|
|
54
|
+
// <#/InitialSetupConfig_ExtraProdTableConfigs#>
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const tableConfigsTestEnv = {
|
|
58
|
+
...testTableConfigs
|
|
59
|
+
// <#InitialSetupConfig_ExtraTestTableConfigs#>
|
|
60
|
+
// <#/InitialSetupConfig_ExtraTestTableConfigs#>
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// ============================================================
|
|
64
|
+
// Graph Node Schemas (generated + manual merge)
|
|
65
|
+
// ============================================================
|
|
66
|
+
function graphNodeSchemas() {
|
|
67
|
+
let schemas = generatedGraphNodeSchemas();
|
|
68
|
+
// <#InitialSetupConfig_ExtraNodeSchemas#>
|
|
69
|
+
// <#/InitialSetupConfig_ExtraNodeSchemas#>
|
|
70
|
+
Logger.debug('nodeSchemas after merge', schemas);
|
|
71
|
+
return schemas;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ============================================================
|
|
75
|
+
// Graph Relationship Schemas (generated + manual merge)
|
|
76
|
+
// ============================================================
|
|
77
|
+
function graphRelationshipSchemas() {
|
|
78
|
+
let schemas = generatedGraphRelationshipSchemas();
|
|
79
|
+
// <#InitialSetupConfig_ExtraRelSchemas#>
|
|
80
|
+
// <#/InitialSetupConfig_ExtraRelSchemas#>
|
|
81
|
+
Logger.debug('relationshipSchemas after merge', schemas);
|
|
82
|
+
return schemas;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ============================================================
|
|
86
|
+
// Graph Versioned Data Schemas
|
|
87
|
+
// ============================================================
|
|
88
|
+
function graphVersionedDataSchemas() {
|
|
89
|
+
let versionedDataSchemas = {
|
|
90
|
+
// <#InitialSetupConfig_VersionedDataSchemas#>
|
|
91
|
+
// <#/InitialSetupConfig_VersionedDataSchemas#>
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
let [versionedDataNodeSchemas, versionedDataRelationshipSchemas] =
|
|
95
|
+
graphSharedLib.graphVersionedDataSchemaAll(versionedDataSchemas);
|
|
96
|
+
|
|
97
|
+
return [versionedDataNodeSchemas, versionedDataRelationshipSchemas];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default {
|
|
101
|
+
externalServices,
|
|
102
|
+
paths,
|
|
103
|
+
tableConfigs,
|
|
104
|
+
tableConfigsTestEnv,
|
|
105
|
+
graphNodeSchemas,
|
|
106
|
+
graphRelationshipSchemas,
|
|
107
|
+
graphVersionedDataSchemas
|
|
108
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import middlewareHandler from '@izara_project/izara-core-library-middleware';
|
|
2
|
+
import mainHandler from './InitialSetup_Main.js';
|
|
3
|
+
|
|
4
|
+
export const main = middlewareHandler.wrap(
|
|
5
|
+
{
|
|
6
|
+
useAuthorization: false,
|
|
7
|
+
useAuditLog: false
|
|
8
|
+
},
|
|
9
|
+
async (event, context, izContext) => {
|
|
10
|
+
return await mainHandler.initialSetup(event, context, izContext);
|
|
11
|
+
}
|
|
12
|
+
);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import initialSetupSharedLib from '@izara_project/izara-core-library-initial-setup';
|
|
2
|
+
import config from './InitialSetupConfig.js';
|
|
3
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
4
|
+
import correlationIds from '@izara_project/izara-core-library-correlation-ids';
|
|
5
|
+
|
|
6
|
+
const initialSetup = async (event, context, izContext) => {
|
|
7
|
+
const _izContext = {
|
|
8
|
+
correlationIds: correlationIds,
|
|
9
|
+
logger: Logger
|
|
10
|
+
};
|
|
11
|
+
try {
|
|
12
|
+
Logger.debug('======== InitialSetup start ========');
|
|
13
|
+
|
|
14
|
+
// ====== Generate IAM Role of function ======
|
|
15
|
+
await initialSetupSharedLib.generateIamRoleExternalService(
|
|
16
|
+
_izContext,
|
|
17
|
+
await config.roleConfigs() // If implemented in config
|
|
18
|
+
);
|
|
19
|
+
Logger.debug('-------- Finish generate role IAM --------');
|
|
20
|
+
|
|
21
|
+
// ====== Generate Seed Data ======
|
|
22
|
+
// await initialSetupSharedLib.generateSeedData(_izContext, config);
|
|
23
|
+
// Logger.debug('------ Finish InitialSetup generateSeedData ------');
|
|
24
|
+
|
|
25
|
+
// ====== Generate Subscriptions of SNS topic ======
|
|
26
|
+
await initialSetupSharedLib.generateTopicSubscriptions(
|
|
27
|
+
_izContext,
|
|
28
|
+
config.snsTopicSubscriptions // If implemented in config
|
|
29
|
+
);
|
|
30
|
+
Logger.debug('-------- Finish generate subscribe --------');
|
|
31
|
+
|
|
32
|
+
<% if (hasGenerateGraph) { -%>
|
|
33
|
+
// ====== Generate Schema for graphDb ======
|
|
34
|
+
// await initialSetupSharedLib.generateSchema(_izContext, config.graphNodeSchemas(), 'node');
|
|
35
|
+
// await initialSetupSharedLib.generateSchema(_izContext, config.graphRelationshipSchemas(), 'relationship');
|
|
36
|
+
|
|
37
|
+
// const [versionedDataNodeSchemas, versionedDataRelationshipSchemas] = config.graphVersionedDataSchemas();
|
|
38
|
+
// await initialSetupSharedLib.generateSchema(_izContext, versionedDataNodeSchemas, 'node');
|
|
39
|
+
// await initialSetupSharedLib.generateSchema(_izContext, versionedDataRelationshipSchemas, 'relationship');
|
|
40
|
+
|
|
41
|
+
// Logger.debug('-------- Finished generate main schema --------');
|
|
42
|
+
<% } -%>
|
|
43
|
+
|
|
44
|
+
return 'InitialSetup Complete';
|
|
45
|
+
} catch (err) {
|
|
46
|
+
Logger.error('Error InitialSetup (prod)', err);
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default { initialSetup };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
|
+
import removeMain from './RemoveSeedDataDynamo_Main.js';
|
|
3
|
+
|
|
4
|
+
const main = middleware.wrap(async (event, context, callback) => {
|
|
5
|
+
event._izContext.logger.debug('Event:', event);
|
|
6
|
+
event._izContext.logger.debug('context:', context);
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
return await removeMain.removeSeedDataDynamo(event);
|
|
10
|
+
} catch (err) {
|
|
11
|
+
event._izContext.logger.error('Error, RemoveSeedDataDynamo_HdrInv: ', err);
|
|
12
|
+
throw err;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export { main };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import initialSetupSharedLib from '@izara_project/izara-core-library-initial-setup';
|
|
2
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
3
|
+
import correlationIds from '@izara_project/izara-core-library-correlation-ids';
|
|
4
|
+
import config from './InitialSetupConfig.js';
|
|
5
|
+
|
|
6
|
+
const removeSeedDataDynamo = async (event) => {
|
|
7
|
+
const _izContext = {
|
|
8
|
+
correlationIds: correlationIds,
|
|
9
|
+
logger: Logger
|
|
10
|
+
};
|
|
11
|
+
try {
|
|
12
|
+
console.log('======== Start Refresh Seed Data ========');
|
|
13
|
+
|
|
14
|
+
// === generate new seed data test env ===
|
|
15
|
+
// remove both prod and test and create new just test env??
|
|
16
|
+
// NOTE: in refresh seed data flow will need to remove all dynamodb including graph schema
|
|
17
|
+
await initialSetupSharedLib.removeSeedDataDynamoTestEnv(
|
|
18
|
+
_izContext,
|
|
19
|
+
config.tableConfigs,
|
|
20
|
+
config.tableConfigsTestEnv
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
console.log('-------- Finish All RemoveSeedData --------');
|
|
24
|
+
return 'Finish RemoveSeedDataDynamo Test stage';
|
|
25
|
+
} catch (err) {
|
|
26
|
+
console.log(err);
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default { removeSeedDataDynamo };
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
19
|
+
|
|
20
|
+
import uploadSchema from './UploadSchema_Main.js';
|
|
21
|
+
|
|
22
|
+
const main = middleware.wrap(async (event, context, callback) => {
|
|
23
|
+
event._izContext.logger.debug('Event:', event);
|
|
24
|
+
event._izContext.logger.debug('context:', context);
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
// invoke LambdaFunction
|
|
28
|
+
return await uploadSchema.uploadSchema(
|
|
29
|
+
event._izContext
|
|
30
|
+
);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
event._izContext.logger.error('Error, LambdaFunctionHdrInv: ', err);
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export { main };
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
import { uploadObjSchema } from '@izara_project/izara-core-library-service-schemas';
|
|
19
|
+
|
|
20
|
+
const SERVICE_TAG = {
|
|
21
|
+
TRANSLATIONS: 'Translations',
|
|
22
|
+
GRAPH_HANDLER: 'GraphHandler',
|
|
23
|
+
TRANSLATE_IDS: 'TranslateIds',
|
|
24
|
+
USER_ACCOUNT: 'UserAccount',
|
|
25
|
+
MEDIA: 'Media'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const ignoreExternalServices = {
|
|
29
|
+
[SERVICE_TAG.TRANSLATIONS]: false,
|
|
30
|
+
[SERVICE_TAG.GRAPH_HANDLER]: false,
|
|
31
|
+
[SERVICE_TAG.USER_ACCOUNT]: false,
|
|
32
|
+
[SERVICE_TAG.TRANSLATE_IDS]: false,
|
|
33
|
+
[SERVICE_TAG.MEDIA]: false
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const uploadSchema = async _izContext => {
|
|
37
|
+
try {
|
|
38
|
+
_izContext.logger.debug('uploadSchema _izContext: ', _izContext);
|
|
39
|
+
|
|
40
|
+
await uploadObjSchema.uploadObjectSchemaByUseCase(_izContext, {
|
|
41
|
+
ignoreExternalServices: ignoreExternalServices
|
|
42
|
+
});
|
|
43
|
+
return 'upload successfully';
|
|
44
|
+
} catch (err) {
|
|
45
|
+
_izContext.logger.error('error LambdaFunction: ', err);
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
uploadSchema
|
|
52
|
+
};
|