@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
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
const ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
|
|
12
12
|
const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-objects.yml';
|
|
13
13
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
14
|
+
const SHARED_TEMPLATE_URL = new URL('../shared/templates/', import.meta.url);
|
|
14
15
|
|
|
15
16
|
export async function emitCrudApplicationArtifacts({
|
|
16
17
|
objects,
|
|
@@ -102,7 +103,7 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
102
103
|
artifacts.push(
|
|
103
104
|
{
|
|
104
105
|
path: `${source}/Get_HdrInv.js`,
|
|
105
|
-
content: await
|
|
106
|
+
content: await renderShared('FlowHandler_HdrInv.ejs', {
|
|
106
107
|
...shared,
|
|
107
108
|
mainFileName,
|
|
108
109
|
functionName: 'Get',
|
|
@@ -111,7 +112,7 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
111
112
|
},
|
|
112
113
|
{
|
|
113
114
|
path: `${source}/Get_HdrApi.js`,
|
|
114
|
-
content: await
|
|
115
|
+
content: await renderShared('FlowHandler_HdrApi.ejs', {
|
|
115
116
|
...shared,
|
|
116
117
|
mainFileName,
|
|
117
118
|
functionName: 'Get',
|
|
@@ -128,7 +129,7 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
128
129
|
},
|
|
129
130
|
{
|
|
130
131
|
path: `${source}/GetRange_HdrApi.js`,
|
|
131
|
-
content: await
|
|
132
|
+
content: await renderShared('FlowHandler_HdrApi.ejs', {
|
|
132
133
|
...shared,
|
|
133
134
|
mainFileName: 'GetRange_Main',
|
|
134
135
|
functionName: 'GetRange',
|
|
@@ -185,7 +186,7 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
185
186
|
artifacts.push(
|
|
186
187
|
{
|
|
187
188
|
path: `${source}/${action}_HdrSqs.js`,
|
|
188
|
-
content: await
|
|
189
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
189
190
|
...shared,
|
|
190
191
|
mainFileName,
|
|
191
192
|
functionName: action,
|
|
@@ -237,7 +238,7 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
237
238
|
},
|
|
238
239
|
{
|
|
239
240
|
path: `${source}/${complete}_HdrSqs.js`,
|
|
240
|
-
content: await
|
|
241
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
241
242
|
...shared,
|
|
242
243
|
mainFileName: `${complete}_Main`,
|
|
243
244
|
functionName: complete,
|
|
@@ -263,7 +264,7 @@ async function emitAction(action, objects, flows, serviceTag) {
|
|
|
263
264
|
},
|
|
264
265
|
{
|
|
265
266
|
path: `${source}/${action}BeforeLogical_HdrSqs.js`,
|
|
266
|
-
content: await
|
|
267
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
267
268
|
...shared,
|
|
268
269
|
mainFileName: beforeMain,
|
|
269
270
|
functionName: `${action}BeforeLogicalMain`,
|
|
@@ -300,6 +301,11 @@ async function render(templateName, data) {
|
|
|
300
301
|
return ejsLib.render(template, data);
|
|
301
302
|
}
|
|
302
303
|
|
|
304
|
+
async function renderShared(templateName, data) {
|
|
305
|
+
const template = await readFile(new URL(templateName, SHARED_TEMPLATE_URL), 'utf8');
|
|
306
|
+
return ejsLib.render(template, data);
|
|
307
|
+
}
|
|
308
|
+
|
|
303
309
|
function renderFunction(descriptor) {
|
|
304
310
|
if (descriptor.type === 'api') return renderApiFunctionYaml(descriptor);
|
|
305
311
|
if (descriptor.type === 'inv') return renderInvFunctionYaml(descriptor);
|
|
@@ -58,7 +58,7 @@ import { sns } from '@izara_project/izara-core-library-external-request';
|
|
|
58
58
|
export default async function <%- flowTag %>(
|
|
59
59
|
_izContext,
|
|
60
60
|
requestParams,
|
|
61
|
-
callingFlowConfig = {}
|
|
61
|
+
callingFlowConfig = {},
|
|
62
62
|
//(<additionalParams>)
|
|
63
63
|
//(</additionalParams>)
|
|
64
64
|
) {
|
|
@@ -43,7 +43,7 @@ import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
|
43
43
|
export default async function <%- mainFileName %>(
|
|
44
44
|
_izContext,
|
|
45
45
|
requestParams,
|
|
46
|
-
callingFlowConfig = {}
|
|
46
|
+
callingFlowConfig = {},
|
|
47
47
|
//(<additionalParams>)
|
|
48
48
|
//(</additionalParams>)
|
|
49
49
|
) {
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
|
|
21
21
|
const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-schema.yml';
|
|
22
22
|
const TEMPLATE_URL = new URL('../crud/templates/', import.meta.url);
|
|
23
|
+
const SHARED_TEMPLATE_URL = new URL('../shared/templates/', import.meta.url);
|
|
23
24
|
const CUSTOM_TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
24
|
-
const DSQ_TEMPLATE_URL = new URL('../relationship/templates/', import.meta.url);
|
|
25
25
|
|
|
26
26
|
export async function emitCustomFlowApplicationArtifacts(
|
|
27
27
|
flows,
|
|
@@ -127,7 +127,7 @@ async function emitFlow(flow, objects) {
|
|
|
127
127
|
if (flow.event.includes('extTopic') && !flow.event.includes('ownTopic')) {
|
|
128
128
|
artifacts.push({
|
|
129
129
|
path: `${source}/${process}_HdrSqs.js`,
|
|
130
|
-
content: await
|
|
130
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
131
131
|
...shared,
|
|
132
132
|
queueName: `${process}HdrSqs`
|
|
133
133
|
})
|
|
@@ -165,7 +165,7 @@ async function emitFlow(flow, objects) {
|
|
|
165
165
|
if (flow.event.includes('lambdaSyncInv')) {
|
|
166
166
|
artifacts.push({
|
|
167
167
|
path: `${source}/${process}_HdrInv.js`,
|
|
168
|
-
content: await
|
|
168
|
+
content: await renderShared('FlowHandler_HdrInv.ejs', shared)
|
|
169
169
|
});
|
|
170
170
|
functions.push(
|
|
171
171
|
renderInvFunctionYaml({
|
|
@@ -180,7 +180,7 @@ async function emitFlow(flow, objects) {
|
|
|
180
180
|
if (flow.event.includes('lambdaSyncApi')) {
|
|
181
181
|
artifacts.push({
|
|
182
182
|
path: `${source}/${process}_HdrApi.js`,
|
|
183
|
-
content: await
|
|
183
|
+
content: await renderShared('FlowHandler_HdrApi.ejs', shared)
|
|
184
184
|
});
|
|
185
185
|
functions.push(
|
|
186
186
|
renderApiFunctionYaml({
|
|
@@ -195,7 +195,7 @@ async function emitFlow(flow, objects) {
|
|
|
195
195
|
if (flow.event.includes('eventBridge')) {
|
|
196
196
|
artifacts.push({
|
|
197
197
|
path: `${source}/${process}_HdrInv.js`,
|
|
198
|
-
content: await
|
|
198
|
+
content: await renderShared('FlowHandler_HdrInv.ejs', shared)
|
|
199
199
|
});
|
|
200
200
|
functions.push(
|
|
201
201
|
renderEventBridgeFunctionYaml({
|
|
@@ -334,7 +334,7 @@ async function emitExtTopicStep({ flow, step, flowTag, stepName }) {
|
|
|
334
334
|
const queueName = `${functionName}HdrSqs`;
|
|
335
335
|
artifacts.push({
|
|
336
336
|
path: `${source}/${functionName}_HdrSqs.js`,
|
|
337
|
-
content: await
|
|
337
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
338
338
|
flowTag: flow.flowTag,
|
|
339
339
|
flowStepName: step.stepName,
|
|
340
340
|
functionName,
|
|
@@ -428,7 +428,7 @@ async function emitOwnTopicRoot(flow, objects) {
|
|
|
428
428
|
},
|
|
429
429
|
{
|
|
430
430
|
path: `${source}/${tag}_HdrSqs.js`,
|
|
431
|
-
content: await
|
|
431
|
+
content: await renderShared('FlowHandler_HdrSqs.ejs', {
|
|
432
432
|
...shared,
|
|
433
433
|
functionName: mainFileName,
|
|
434
434
|
mainFileName,
|
|
@@ -437,14 +437,14 @@ async function emitOwnTopicRoot(flow, objects) {
|
|
|
437
437
|
},
|
|
438
438
|
{
|
|
439
439
|
path: `${source}/${wbsMainFileName}.js`,
|
|
440
|
-
content: await
|
|
440
|
+
content: await renderCrudTemplate('FlowMain_Wbs.ejs', {
|
|
441
441
|
...shared,
|
|
442
442
|
functionName: wbsMainFileName
|
|
443
443
|
})
|
|
444
444
|
},
|
|
445
445
|
{
|
|
446
446
|
path: `${source}/${tag}_HdrWbs.js`,
|
|
447
|
-
content: await
|
|
447
|
+
content: await renderCrudTemplate('FlowEndpoint_HdrWbs.ejs', {
|
|
448
448
|
...shared,
|
|
449
449
|
functionName: tag,
|
|
450
450
|
mainFileName: wbsMainFileName,
|
|
@@ -560,11 +560,16 @@ async function emitS3Flow(flow, source, handlerRoot) {
|
|
|
560
560
|
flowStepName: ''
|
|
561
561
|
});
|
|
562
562
|
} else if (type === 'sqs') {
|
|
563
|
+
let filterPatternFunctionName = descriptor.functionName;
|
|
564
|
+
if (action === 'CreatePreSignUrl') {
|
|
565
|
+
filterPatternFunctionName = 'CreatePresignUrlHdrSqs';
|
|
566
|
+
}
|
|
563
567
|
functionYaml = renderSqsFunctionYaml({
|
|
564
568
|
...descriptor,
|
|
565
569
|
queueName: descriptor.functionName,
|
|
566
570
|
flowTag: flow.flowTag,
|
|
567
|
-
flowStepName: ''
|
|
571
|
+
flowStepName: '',
|
|
572
|
+
filterPatternFunctionName
|
|
568
573
|
});
|
|
569
574
|
} else if (type === 's3') {
|
|
570
575
|
let bucketName = '';
|
|
@@ -705,9 +710,23 @@ async function render(templateName, data) {
|
|
|
705
710
|
);
|
|
706
711
|
}
|
|
707
712
|
|
|
713
|
+
async function renderShared(templateName, data) {
|
|
714
|
+
return ejsLib.render(
|
|
715
|
+
await readFile(new URL(templateName, SHARED_TEMPLATE_URL), 'utf8'),
|
|
716
|
+
data
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
async function renderCrudTemplate(templateName, data) {
|
|
721
|
+
return ejsLib.render(
|
|
722
|
+
await readFile(new URL(templateName, TEMPLATE_URL), 'utf8'),
|
|
723
|
+
data
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
|
|
708
727
|
async function renderDsq(templateName, data) {
|
|
709
728
|
return ejsLib.render(
|
|
710
|
-
await readFile(new URL(templateName,
|
|
729
|
+
await readFile(new URL(templateName, SHARED_TEMPLATE_URL), 'utf8'),
|
|
711
730
|
data
|
|
712
731
|
);
|
|
713
732
|
}
|
|
@@ -58,7 +58,7 @@ const { createFlowTypeConcat } = utils;
|
|
|
58
58
|
export default async function <%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %>(
|
|
59
59
|
_izContext,
|
|
60
60
|
requestParams,
|
|
61
|
-
callingFlowConfig = {}
|
|
61
|
+
callingFlowConfig = {},
|
|
62
62
|
//(<additionalParams>)
|
|
63
63
|
//(</additionalParams>)
|
|
64
64
|
) {
|
|
@@ -88,7 +88,7 @@ export default async function <%- typeof functionName !== 'undefined' ? function
|
|
|
88
88
|
createFlowTypeConcat(_izContext, {
|
|
89
89
|
flowTag: '<%= flowTag %>',
|
|
90
90
|
serviceTag: process.env.iz_serviceTag
|
|
91
|
-
})
|
|
91
|
+
}),
|
|
92
92
|
//(<storedCacheConfig>)
|
|
93
93
|
//(</storedCacheConfig>)
|
|
94
94
|
);
|
|
@@ -37,7 +37,7 @@ import { identifierUuid } from '@izara_project/izara-shared-core';
|
|
|
37
37
|
export default async function <%= functionName %>(
|
|
38
38
|
_izContext,
|
|
39
39
|
requestParams,
|
|
40
|
-
callingFlowConfig = {}
|
|
40
|
+
callingFlowConfig = {},
|
|
41
41
|
//(<additionalParams>)
|
|
42
42
|
//(</additionalParams>)
|
|
43
43
|
) {
|
|
@@ -56,7 +56,7 @@ export default async function reservedLimit(
|
|
|
56
56
|
objInstanceFull,
|
|
57
57
|
//(<additionalProperties>)
|
|
58
58
|
//(</additionalProperties>)
|
|
59
|
-
callingFlowConfig = {}
|
|
59
|
+
callingFlowConfig = {},
|
|
60
60
|
) {
|
|
61
61
|
try {
|
|
62
62
|
_izContext.logger.debug('----- reservedLimit event params ----- ', {
|
|
@@ -11,10 +11,10 @@ let perRecordsValidatorSchema = {
|
|
|
11
11
|
properties: {
|
|
12
12
|
<% startConfig.properties.forEach((prop, index) => { %> <%- prop.propertyName %>: {
|
|
13
13
|
type: '<%- prop.type || 'string' %>'
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
<% }) %>
|
|
16
16
|
},
|
|
17
|
-
required: [<%- startConfig.properties.filter(p => p.required
|
|
17
|
+
required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
18
18
|
<% } -%>
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -29,10 +29,10 @@ let messageAttributeValidatorSchema = {
|
|
|
29
29
|
Value: { type: '<%- prop.type || 'string' %>' }
|
|
30
30
|
},
|
|
31
31
|
required: ['Type', 'Value']
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
<% }) %>
|
|
34
34
|
},
|
|
35
|
-
required: [<%- startConfig.messageAttributes.filter(p => p.required
|
|
35
|
+
required: [<%- startConfig.messageAttributes.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
36
36
|
};
|
|
37
37
|
<% } else { -%>
|
|
38
38
|
let messageAttributeValidatorSchema = null;
|
|
@@ -48,7 +48,8 @@ export function renderSqsFunctionYaml({
|
|
|
48
48
|
queueName,
|
|
49
49
|
flowTag,
|
|
50
50
|
flowStepName,
|
|
51
|
-
targetCompleteStepName
|
|
51
|
+
targetCompleteStepName,
|
|
52
|
+
filterPatternFunctionName
|
|
52
53
|
}) {
|
|
53
54
|
if (
|
|
54
55
|
![functionName, handlerPath, roleName, queueName].every(
|
|
@@ -71,7 +72,9 @@ export function renderSqsFunctionYaml({
|
|
|
71
72
|
targetCompleteStepName
|
|
72
73
|
),
|
|
73
74
|
functionSetting: _functionSetting(functionName),
|
|
74
|
-
sqsFilterPatterns: _sqsFilterPatterns(
|
|
75
|
+
sqsFilterPatterns: _sqsFilterPatterns(
|
|
76
|
+
filterPatternFunctionName ?? functionName
|
|
77
|
+
)
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
80
|
|
|
@@ -18,6 +18,8 @@ const ACTIONS = [
|
|
|
18
18
|
];
|
|
19
19
|
const YAML_PATH = 'app/sls_yaml/generatedCode/source/flow-relationships.yml';
|
|
20
20
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
21
|
+
const SHARED_TEMPLATE_URL = new URL('../shared/templates/', import.meta.url);
|
|
22
|
+
const CRUD_TEMPLATE_URL = new URL('../crud/templates/', import.meta.url);
|
|
21
23
|
|
|
22
24
|
export async function emitRelationshipApplicationArtifacts({
|
|
23
25
|
relationships,
|
|
@@ -98,7 +100,7 @@ async function emitAction(action, relationships, flows, serviceTag) {
|
|
|
98
100
|
artifacts.push(
|
|
99
101
|
{
|
|
100
102
|
path: `${source}/${action}_WbsMain.js`,
|
|
101
|
-
content: await
|
|
103
|
+
content: await renderCrudTemplate('FlowMain_Wbs.ejs', {
|
|
102
104
|
flowTag: action,
|
|
103
105
|
upperCaseFlowTag: action,
|
|
104
106
|
functionName: action
|
|
@@ -106,7 +108,7 @@ async function emitAction(action, relationships, flows, serviceTag) {
|
|
|
106
108
|
},
|
|
107
109
|
{
|
|
108
110
|
path: `${source}/${action}_HdrWbs.js`,
|
|
109
|
-
content: await
|
|
111
|
+
content: await renderCrudTemplate('FlowEndpoint_HdrWbs.ejs', {
|
|
110
112
|
flowTag: action,
|
|
111
113
|
upperCaseFlowTag: action,
|
|
112
114
|
functionName: action,
|
|
@@ -137,7 +139,7 @@ async function emitAction(action, relationships, flows, serviceTag) {
|
|
|
137
139
|
if (!handler) continue;
|
|
138
140
|
artifacts.push({
|
|
139
141
|
path: `${source}/${handler.fileName}.js`,
|
|
140
|
-
content: await
|
|
142
|
+
content: await renderShared(handler.template, {
|
|
141
143
|
...shared,
|
|
142
144
|
queueName: handler.queueName
|
|
143
145
|
})
|
|
@@ -275,6 +277,14 @@ async function render(templateName, data) {
|
|
|
275
277
|
}
|
|
276
278
|
|
|
277
279
|
async function renderShared(templateName, data) {
|
|
280
|
+
const template = await readFile(
|
|
281
|
+
new URL(`../shared/templates/${templateName}`, import.meta.url),
|
|
282
|
+
'utf8'
|
|
283
|
+
);
|
|
284
|
+
return ejsLib.render(template, data);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function renderCrudTemplate(templateName, data) {
|
|
278
288
|
const template = await readFile(
|
|
279
289
|
new URL(`../crud/templates/${templateName}`, import.meta.url),
|
|
280
290
|
'utf8'
|
|
@@ -64,7 +64,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
|
64
64
|
export default async function <%- functionName %>(
|
|
65
65
|
_izContext,
|
|
66
66
|
requestParams,
|
|
67
|
-
callingFlowConfig = {}
|
|
67
|
+
callingFlowConfig = {},
|
|
68
68
|
//(<additionalParams>)
|
|
69
69
|
//(</additionalParams>)
|
|
70
70
|
) {
|
|
@@ -61,7 +61,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
|
61
61
|
export default async function createRelationship(
|
|
62
62
|
_izContext,
|
|
63
63
|
requestParams,
|
|
64
|
-
callingFlowConfig = {}
|
|
64
|
+
callingFlowConfig = {},
|
|
65
65
|
//(<additionalParams>)
|
|
66
66
|
//(</additionalParams>)
|
|
67
67
|
) {
|
|
@@ -61,7 +61,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
|
61
61
|
export default async function deleteRelationship(
|
|
62
62
|
_izContext,
|
|
63
63
|
requestParams,
|
|
64
|
-
callingFlowConfig = {}
|
|
64
|
+
callingFlowConfig = {},
|
|
65
65
|
//(<additionalParams>)
|
|
66
66
|
//(</additionalParams>)
|
|
67
67
|
) {
|
|
@@ -66,7 +66,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
|
66
66
|
export default async function getRelationship(
|
|
67
67
|
_izContext,
|
|
68
68
|
requestParams,
|
|
69
|
-
callingFlowConfig = {}
|
|
69
|
+
callingFlowConfig = {},
|
|
70
70
|
//(<additionalParams>)
|
|
71
71
|
//(</additionalParams>)
|
|
72
72
|
) {
|
|
@@ -69,7 +69,7 @@ import { consts as coreConsts } from '@izara_project/izara-core-library-core';
|
|
|
69
69
|
export default async function moveRelationship(
|
|
70
70
|
_izContext,
|
|
71
71
|
requestParams,
|
|
72
|
-
callingFlowConfig = {}
|
|
72
|
+
callingFlowConfig = {},
|
|
73
73
|
//(<additionalParams>)
|
|
74
74
|
//(</additionalParams>)
|
|
75
75
|
) {
|
|
@@ -62,7 +62,7 @@ const { PREFIX, TOPIC_NAME_GENERATE_CODE, TOPIC_NAME_GRAPH_HANDLER } = consts;
|
|
|
62
62
|
export default async function updateRelationship(
|
|
63
63
|
_izContext,
|
|
64
64
|
requestParams,
|
|
65
|
-
callingFlowConfig = {}
|
|
65
|
+
callingFlowConfig = {},
|
|
66
66
|
//(<additionalParams>)
|
|
67
67
|
//(</additionalParams>)
|
|
68
68
|
) {
|
|
@@ -107,7 +107,11 @@ export async function emitResourceArtifacts({
|
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
path: `${APP_ROOT}/generate-shared-resource.yml`,
|
|
110
|
-
content: normalizeYaml(iam)
|
|
110
|
+
content: normalizeYaml(iam.iamContent)
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
path: `${APP_ROOT}/role-name-config.yml`,
|
|
114
|
+
content: normalizeYaml(iam.roleNameConfigContent)
|
|
111
115
|
},
|
|
112
116
|
{
|
|
113
117
|
path: `${INITIAL_SETUP_ROOT}/generatedLambdaRoleServiceConfig.js`,
|
|
@@ -120,6 +124,12 @@ export async function emitResourceArtifacts({
|
|
|
120
124
|
content: normalizeYaml(s3)
|
|
121
125
|
});
|
|
122
126
|
}
|
|
127
|
+
if (state.hasHttpApi) {
|
|
128
|
+
artifacts.push({
|
|
129
|
+
path: `${APP_ROOT}/cors.yml`,
|
|
130
|
+
content: renderCorsYaml()
|
|
131
|
+
});
|
|
132
|
+
}
|
|
123
133
|
return artifacts;
|
|
124
134
|
}
|
|
125
135
|
|
|
@@ -129,7 +139,9 @@ export const resourceArtifactPaths = [
|
|
|
129
139
|
`${RESOURCE_ROOT}/generated-dynamoDB-table.yml`,
|
|
130
140
|
`${RESOURCE_ROOT}/generated-s3.yml`,
|
|
131
141
|
`${APP_ROOT}/generate-shared-resource.yml`,
|
|
132
|
-
`${
|
|
142
|
+
`${APP_ROOT}/role-name-config.yml`,
|
|
143
|
+
`${INITIAL_SETUP_ROOT}/generatedLambdaRoleServiceConfig.js`,
|
|
144
|
+
`${APP_ROOT}/cors.yml`
|
|
133
145
|
];
|
|
134
146
|
|
|
135
147
|
function createResourceState({ objects, relationships, flows }) {
|
|
@@ -273,11 +285,21 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
273
285
|
`Subscription${topicName}To${queueName}`;
|
|
274
286
|
return { subscriptionName, topicName, queueName };
|
|
275
287
|
});
|
|
288
|
+
const systemTables = [...SYSTEM_TABLES];
|
|
289
|
+
if (s3FlowTags.length > 0) {
|
|
290
|
+
systemTables.push('ReservedDataMain');
|
|
291
|
+
}
|
|
292
|
+
const hasHttpApi =
|
|
293
|
+
crud ||
|
|
294
|
+
relationships.length > 0 ||
|
|
295
|
+
rbac ||
|
|
296
|
+
flows.some((flow) => includesEvent(flow, 'lambdaSyncApi'));
|
|
276
297
|
return {
|
|
277
298
|
crud,
|
|
278
299
|
rbac,
|
|
279
300
|
s3Subscriptions,
|
|
280
301
|
s3FlowTags,
|
|
302
|
+
hasHttpApi,
|
|
281
303
|
relationships: relationships.length > 0,
|
|
282
304
|
ownTopics: [...ownTopics].filter(Boolean).sort(),
|
|
283
305
|
sqsQueues: [...sqsQueues].filter(Boolean).sort(),
|
|
@@ -308,7 +330,7 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
308
330
|
tableName,
|
|
309
331
|
...keys
|
|
310
332
|
})),
|
|
311
|
-
allTableNames: [...new Set([...
|
|
333
|
+
allTableNames: [...new Set([...systemTables, ...tableMap.keys()])].sort(),
|
|
312
334
|
objectTableNames,
|
|
313
335
|
relationshipTableNames,
|
|
314
336
|
externalDynamoTables,
|
|
@@ -395,7 +417,7 @@ async function renderOut(state) {
|
|
|
395
417
|
|
|
396
418
|
async function renderDynamo(state) {
|
|
397
419
|
const [system, ...tables] = await Promise.all([
|
|
398
|
-
render('SystemDynamoDB_Yaml.ejs', {}),
|
|
420
|
+
render('SystemDynamoDB_Yaml.ejs', { hasS3: state.s3FlowTags.length > 0 }),
|
|
399
421
|
...state.tables.map((table) => render('DynamoDBTable_Yaml.ejs', table))
|
|
400
422
|
]);
|
|
401
423
|
return `${system}\n${tables.join('\n')}`;
|
|
@@ -408,12 +430,16 @@ async function renderIam(state) {
|
|
|
408
430
|
if (state.rbac) roles.push('FlowRbacRole');
|
|
409
431
|
if (state.websocket) roles.push('WebSocketMainRole');
|
|
410
432
|
roles.push(...state.customRoles);
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
433
|
+
const sortedRoles = roles.sort();
|
|
434
|
+
return {
|
|
435
|
+
iamContent: await render('SharedResource_Yaml.ejs', {
|
|
436
|
+
roles: sortedRoles.map((roleName) => ({
|
|
437
|
+
roleName,
|
|
438
|
+
statements: roleStatements(state, roleName)
|
|
439
|
+
}))
|
|
440
|
+
}),
|
|
441
|
+
roleNameConfigContent: renderRoleNameConfigYaml(sortedRoles)
|
|
442
|
+
};
|
|
417
443
|
}
|
|
418
444
|
|
|
419
445
|
async function renderLambdaRoleConfig(state) {
|
|
@@ -508,7 +534,7 @@ function roleTableNames(state, roleName) {
|
|
|
508
534
|
const tables = [];
|
|
509
535
|
if (includesEvent(flow, 'ownTopic') || includesEvent(flow, 's3'))
|
|
510
536
|
tables.push('WebSocketTask');
|
|
511
|
-
if (includesEvent(flow, 's3')) tables.push('UserUploadRecords');
|
|
537
|
+
if (includesEvent(flow, 's3')) tables.push('UserUploadRecords', 'ReservedDataMain');
|
|
512
538
|
if (flow.statusType === 'storedCache') {
|
|
513
539
|
const object = state.objectTablesByType.get(flow.objType?.objectType);
|
|
514
540
|
if (object) tables.push(object);
|
|
@@ -756,6 +782,33 @@ function upperFirst(value) {
|
|
|
756
782
|
function normalizeYaml(content) {
|
|
757
783
|
return `${content.trimEnd()}\n`;
|
|
758
784
|
}
|
|
785
|
+
function renderCorsYaml() {
|
|
786
|
+
return `allowedOrigins:
|
|
787
|
+
- '*'
|
|
788
|
+
allowedHeaders:
|
|
789
|
+
- content-type
|
|
790
|
+
- x-amz-date
|
|
791
|
+
- authorization
|
|
792
|
+
- x-api-key
|
|
793
|
+
- x-amz-security-token
|
|
794
|
+
- x-amz-user-agent
|
|
795
|
+
- x-amzn-trace-id
|
|
796
|
+
allowedMethods:
|
|
797
|
+
- POST
|
|
798
|
+
- OPTIONS
|
|
799
|
+
maxAge: 0
|
|
800
|
+
allowCredentials: false
|
|
801
|
+
`;
|
|
802
|
+
}
|
|
803
|
+
function renderRoleNameConfigYaml(roles) {
|
|
804
|
+
return [
|
|
805
|
+
'# for createIamRole',
|
|
806
|
+
...roles.map(
|
|
807
|
+
(roleName) =>
|
|
808
|
+
`- arn:aws:iam::\${self:custom.iz_accountId}:role/\${self:custom.iz_resourcePrefix}${roleName}`
|
|
809
|
+
)
|
|
810
|
+
].join('\n');
|
|
811
|
+
}
|
|
759
812
|
async function render(templateName, data) {
|
|
760
813
|
return ejsLib.render(
|
|
761
814
|
await readFile(new URL(templateName, TEMPLATE_URL), 'utf8'),
|
|
@@ -200,3 +200,20 @@ Resources:
|
|
|
200
200
|
KeyType: HASH
|
|
201
201
|
- AttributeName: roleIdKey
|
|
202
202
|
KeyType: RANGE
|
|
203
|
+
<% if (hasS3) { %>
|
|
204
|
+
ReservedDataMainTable:
|
|
205
|
+
Type: "AWS::DynamoDB::Table"
|
|
206
|
+
Properties:
|
|
207
|
+
TableName: ${self:custom.iz_resourcePrefix}ReservedDataMain
|
|
208
|
+
BillingMode: PAY_PER_REQUEST
|
|
209
|
+
AttributeDefinitions:
|
|
210
|
+
- AttributeName: servicePendingId
|
|
211
|
+
AttributeType: S
|
|
212
|
+
- AttributeName: reservedDataId
|
|
213
|
+
AttributeType: S
|
|
214
|
+
KeySchema:
|
|
215
|
+
- AttributeName: servicePendingId
|
|
216
|
+
KeyType: HASH
|
|
217
|
+
- AttributeName: reservedDataId
|
|
218
|
+
KeyType: RANGE
|
|
219
|
+
<% } %>
|