@izara_project/izara-core-generate-service-code 1.0.66 → 1.0.68
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/.prettierrc +11 -0
- package/docs/TriggeredCache Flow.drawio +193 -0
- package/docs/TriggeredCacheFlow.mmd +47 -0
- package/package.json +16 -12
- package/scripts/format-ejs.js +105 -0
- package/src/compile/compileProject.js +16 -1
- package/src/compile/loadSchemas.js +108 -1
- package/src/emit/crud/emitCrudApplicationArtifacts.js +9 -5
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +300 -109
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +221 -143
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +150 -38
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +57 -31
- package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +6 -3
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +407 -252
- package/src/emit/custom/customFlows.js +112 -31
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +89 -77
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +49 -37
- package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
- package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
- package/src/emit/function/functionYamlArtifact.js +46 -12
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +179 -66
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
- package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +6 -5
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +260 -144
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
- package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
- package/src/emit/resource/emitResourceArtifacts.js +499 -108
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
- package/src/emit/system/emitSystemWebSocketArtifacts.js +2 -1
- package/src/generate.js +8 -4
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/crudApplicationArtifacts.test.js +1 -1
- package/test/customFlowApplicationArtifacts.test.js +71 -43
- package/test/dynamicCrudFlowSchemas.test.js +6 -6
- package/test/dynamicRbacFlowSchemas.test.js +8 -12
- package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
- package/test/publicApi.test.js +11 -13
- package/test/resourceArtifacts.test.js +13 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
|
@@ -16,17 +16,17 @@ along with this program. If not, see
|
|
|
16
16
|
<http: //www.gnu.org/licenses />.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
19
|
import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
|
|
22
|
-
|
|
23
20
|
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
24
21
|
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
25
22
|
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
26
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
sns,
|
|
25
|
+
webSocket
|
|
26
|
+
} from '@izara_project/izara-core-library-external-request';
|
|
27
27
|
|
|
28
28
|
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
29
|
-
import { consts as coreConsts } from
|
|
29
|
+
import { consts as coreConsts } from '@izara_project/izara-middleware';
|
|
30
30
|
const { postToConnection } = webSocket;
|
|
31
31
|
|
|
32
32
|
//(<optionalRequire>)
|
|
@@ -51,58 +51,73 @@ export default async function <%- typeof functionName !== 'undefined' ? function
|
|
|
51
51
|
requestParams,
|
|
52
52
|
//(<additionalParams>)
|
|
53
53
|
//(</additionalParams>)
|
|
54
|
-
callingFlowConfig = {}
|
|
54
|
+
callingFlowConfig = {}
|
|
55
55
|
) {
|
|
56
|
-
|
|
57
56
|
try {
|
|
58
|
-
_izContext.logger.debug(
|
|
59
|
-
_izContext.logger.debug(
|
|
60
|
-
_izContext.logger.debug(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
_izContext.logger.debug('<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %> _izContext', _izContext);
|
|
58
|
+
_izContext.logger.debug('<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %> requestParams', requestParams);
|
|
59
|
+
_izContext.logger.debug(
|
|
60
|
+
'<%- typeof functionName !== 'undefined' ? functionName : upperCaseFlowTag %> callingFlowConfig',
|
|
61
|
+
callingFlowConfig
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(
|
|
65
|
+
_izContext,
|
|
66
|
+
{
|
|
67
|
+
flowTag: '<%- flowTag %>',
|
|
68
|
+
serviceTag: process.env.iz_serviceTag
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
_izContext.logger.debug('flowSchema', flowSchema);
|
|
68
73
|
|
|
69
74
|
if (flowSchema.initiateBy === 'user') {
|
|
70
75
|
_izContext.correlationIds.set(coreConsts.USER_AGENT, 'webSocket');
|
|
71
|
-
}
|
|
76
|
+
}
|
|
72
77
|
|
|
73
78
|
let connectionId = _izContext.correlationIds.get(coreConsts.CONNECTION_ID);
|
|
74
79
|
|
|
75
80
|
if (!flowSchema) {
|
|
76
|
-
await postToConnection(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
await postToConnection(
|
|
82
|
+
{
|
|
83
|
+
message: {
|
|
84
|
+
error: `flowTag not found ${requestParams.action}`
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
connectionId
|
|
88
|
+
);
|
|
81
89
|
throw new NoRetryError(`flowTag not found ${requestParams.action}`);
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
let messageObject = requestParams
|
|
92
|
+
let messageObject = requestParams;
|
|
85
93
|
|
|
86
94
|
// create callingFlow
|
|
87
|
-
messageObject =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
messageObject =
|
|
96
|
+
callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
97
|
+
messageObject,
|
|
98
|
+
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
99
|
+
callingFlowConfig,
|
|
100
|
+
callingFlowSharedLib.createCallingFlowConfig(
|
|
101
|
+
await lambdaSharedLib.lambdaFunctionName(
|
|
102
|
+
_izContext,
|
|
103
|
+
'WebSocketComplete'
|
|
104
|
+
),
|
|
105
|
+
{}
|
|
106
|
+
)
|
|
93
107
|
)
|
|
94
|
-
)
|
|
95
|
-
)
|
|
108
|
+
);
|
|
96
109
|
|
|
97
110
|
let sendMessageToEndpoint = {
|
|
98
111
|
Message: JSON.stringify(messageObject),
|
|
99
|
-
TopicArn:
|
|
100
|
-
|
|
101
|
-
|
|
112
|
+
TopicArn: snsSharedLib.snsTopicArnByFlowSchema(
|
|
113
|
+
_izContext,
|
|
114
|
+
'<%- upperCaseFlowTag %>_In'
|
|
115
|
+
)
|
|
116
|
+
};
|
|
117
|
+
_izContext.logger.debug('sendMessageToEndpoint', sendMessageToEndpoint);
|
|
102
118
|
await sns.publishAsync(_izContext, sendMessageToEndpoint);
|
|
103
|
-
|
|
104
119
|
} catch (err) {
|
|
105
|
-
_izContext.logger.error('error WebSocketInvoke: ', err)
|
|
106
|
-
throw
|
|
120
|
+
_izContext.logger.error('error WebSocketInvoke: ', err);
|
|
121
|
+
throw err;
|
|
107
122
|
}
|
|
108
123
|
}
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
utils,
|
|
26
26
|
dataDetailsLib
|
|
27
27
|
} from '@izara_project/izara-core-library-service-schemas';
|
|
28
|
-
const {
|
|
28
|
+
const { getObjectSchemaCombineFieldNamesWithCache } = getObjectSchema;
|
|
29
29
|
const { getGraphServiceTagWithCache } = serviceConfig;
|
|
30
30
|
const { objInstanceFromObjInstanceBase, dynamoDbIdentifiersByStorageResource } =
|
|
31
31
|
identifiersObject;
|
|
@@ -81,7 +81,10 @@ export default async function <%- flowTag %>(
|
|
|
81
81
|
const objType = createObjType(requestParams.objectType);
|
|
82
82
|
|
|
83
83
|
// ── Load schema ───────────────────────────────────────────────────────────
|
|
84
|
-
const objectSchema = await
|
|
84
|
+
const objectSchema = await getObjectSchemaCombineFieldNamesWithCache(
|
|
85
|
+
_izContext,
|
|
86
|
+
objType
|
|
87
|
+
);
|
|
85
88
|
_izContext.logger.debug('objectSchema:', objectSchema);
|
|
86
89
|
|
|
87
90
|
// ── Build getDataDetails ──────────────────────────────────────────────────
|
|
@@ -208,7 +211,7 @@ export default async function <%- flowTag %>(
|
|
|
208
211
|
callingFlowConfig,
|
|
209
212
|
{}
|
|
210
213
|
);
|
|
211
|
-
const topicArn =
|
|
214
|
+
const topicArn = snsSharedLib.snsTopicArnByFlowSchema(
|
|
212
215
|
_izContext,
|
|
213
216
|
TOPIC_NAME_GENERATE_CODE.outGetNodeComplete
|
|
214
217
|
);
|
|
@@ -64,7 +64,7 @@ export default async function <%- mainFileName %>(
|
|
|
64
64
|
_izContext.logger.debug('getDataDetails:', getDataDetails);
|
|
65
65
|
|
|
66
66
|
const { pk, sk, itemNum } = requestParams;
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
if (!pk) {
|
|
69
69
|
throw new Error('Partition key (pk) is required for getRange');
|
|
70
70
|
}
|
|
@@ -110,7 +110,7 @@ export default async function <%- mainFileName %>(
|
|
|
110
110
|
queryElements
|
|
111
111
|
);
|
|
112
112
|
_izContext.logger.debug('dataFromDynamoDb:', dataFromDynamoDb);
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
queryResult = dataFromDynamoDb;
|
|
115
115
|
|
|
116
116
|
//(<afterGetRangeDynamoDb>)
|