@izara_project/izara-core-generate-service-code 1.0.74 → 1.0.76
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/src/compile/loadSchemas.js +36 -30
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +2 -4
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +12 -2
- package/src/emit/coreFunction/templates/InitialSetupRunner.ejs +5 -3
- package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +13 -6
- package/src/emit/coreFunction/templates/InitialSetup_HdrInv.ejs +1 -1
- package/src/emit/crud/emitCrudApplicationArtifacts.js +2 -2
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +43 -2
- package/src/emit/crud/templates/CreateComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/CreateComplete_Main.ejs +188 -0
- package/src/emit/crud/templates/DeleteComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/DeleteComplete_Main.ejs +188 -0
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateComplete_HdrSqs.ejs +99 -0
- package/src/emit/crud/templates/UpdateComplete_Main.ejs +188 -0
- package/src/emit/custom/customFlows.js +15 -1
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +2 -0
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +1 -1
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +20 -5
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +58 -43
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +68 -20
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +69 -20
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +69 -20
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +21 -1
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +1 -1
- package/src/emit/relationship/templates/ChangeRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +91 -87
- package/src/emit/relationship/templates/CreateRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +90 -86
- package/src/emit/relationship/templates/DeleteRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +85 -81
- package/src/emit/relationship/templates/GetRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +2 -0
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +2 -20
- package/src/emit/relationship/templates/MoveRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +93 -89
- package/src/emit/relationship/templates/UpdateRelationshipComplete_HdrSqs.ejs +99 -0
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +85 -81
- package/src/emit/resource/emitResourceArtifacts.js +36 -2
- package/src/emit/shared/templates/FindData_Main.ejs +1 -1
- package/src/emit/system/emitSystemWebSocketArtifacts.js +54 -2
- package/src/emit/system/templates/RegisterComplete_HdrSqs.ejs +64 -0
- package/src/emit/system/templates/RegisterComplete_Main.ejs +154 -0
- package/src/emit/system/templates/RegisterComplete_Yaml.ejs +17 -0
- package/src/emit/system/templates/RegisterWbs_Yaml.ejs +7 -0
- package/src/emit/system/templates/Register_HdrWbs.ejs +56 -0
- package/src/emit/system/templates/Register_Main.ejs +148 -0
- package/src/output/mergeHooks.js +4 -3
- package/test/customFlowApplicationArtifacts.test.js +16 -5
- package/test/publicApi.test.js +21 -0
- package/test/relationshipApplicationArtifacts.test.js +1 -1
- package/test/resourceArtifacts.test.js +20 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
2
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
3
|
+
import { getObjectSchema, identifiersObject } from '@izara_project/izara-core-library-service-schemas';
|
|
4
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
5
|
+
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
6
|
+
import { lambda, webSocket } from '@izara_project/izara-core-library-external-request';
|
|
7
|
+
const { postToConnection } = webSocket;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Register complete main handler
|
|
11
|
+
* @param {Object} _izContext
|
|
12
|
+
* @param {string} topicArn
|
|
13
|
+
* @param {Object} requestParams
|
|
14
|
+
* @param {Object} callingFlowConfig
|
|
15
|
+
*/
|
|
16
|
+
export default async function registerCompleteMain(
|
|
17
|
+
_izContext,
|
|
18
|
+
topicArn,
|
|
19
|
+
requestParams,
|
|
20
|
+
callingFlowConfig = {}
|
|
21
|
+
) {
|
|
22
|
+
try {
|
|
23
|
+
_izContext.logger.debug('WebSocketInvoke _izContext', _izContext);
|
|
24
|
+
_izContext.logger.debug('WebSocketInvoke requestParams', requestParams);
|
|
25
|
+
_izContext.logger.debug('WebSocketInvoke callingFlowConfig', callingFlowConfig);
|
|
26
|
+
|
|
27
|
+
if (!topicArn) {
|
|
28
|
+
throw new NoRetryError('invalid not have topicArn to get flowSchema');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let topicName = topicArn.split(':')[5].split('_');
|
|
32
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
33
|
+
flowTag: topicName[2],
|
|
34
|
+
serviceTag: topicName[0]
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!flowSchema) {
|
|
38
|
+
throw new NoRetryError('not have flowSchema in S3');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let identifiersTask = '';
|
|
42
|
+
|
|
43
|
+
if (!requestParams.identifiersTask && flowSchema.objType) {
|
|
44
|
+
identifiersTask = await identifiersObject.identifiersConcatFromIdentifiers(
|
|
45
|
+
_izContext,
|
|
46
|
+
flowSchema.objType,
|
|
47
|
+
requestParams
|
|
48
|
+
);
|
|
49
|
+
_izContext.logger.debug('identifiersTask from request params', identifiersTask);
|
|
50
|
+
|
|
51
|
+
Object.assign(requestParams, {
|
|
52
|
+
identifiersTask: identifiersTask
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!requestParams.identifiersTask) {
|
|
57
|
+
_izContext.logger.warn('invalid identifiersTask');
|
|
58
|
+
return 'invalid identifiersTask';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const getResult = async (objType) => {
|
|
62
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
63
|
+
_izContext,
|
|
64
|
+
{
|
|
65
|
+
objectType: objType.objectType,
|
|
66
|
+
serviceTag: objType.serviceTag
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
_izContext.logger.debug('==> objectSchema', objectSchema);
|
|
71
|
+
|
|
72
|
+
let tasks = await dynamodbSharedLib.query(
|
|
73
|
+
_izContext,
|
|
74
|
+
await dynamodbSharedLib.tableName(_izContext, 'RegisterRecords'),
|
|
75
|
+
{
|
|
76
|
+
identifiersTask: identifiersTask
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (tasks.Items && tasks.Items.length > 0) {
|
|
81
|
+
const result = await lambda.invokeSync(
|
|
82
|
+
_izContext,
|
|
83
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, 'GetHdrInv'),
|
|
84
|
+
{
|
|
85
|
+
identifiers: await identifiersObject.identifiersFromIdentifiersConcat(
|
|
86
|
+
_izContext,
|
|
87
|
+
objType,
|
|
88
|
+
requestParams.identifiersTask
|
|
89
|
+
),
|
|
90
|
+
objectType: objType.objectType
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
await Promise.all(
|
|
94
|
+
tasks.Items.map(async (task) => {
|
|
95
|
+
if (!result) {
|
|
96
|
+
await postToConnection({ message: 'not have record' }, task.connectionId);
|
|
97
|
+
} else {
|
|
98
|
+
await postToConnection({ message: result }, task.connectionId);
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
switch (flowSchema.statusType) {
|
|
106
|
+
case 'statusField':
|
|
107
|
+
await getResult(flowSchema.objType);
|
|
108
|
+
break;
|
|
109
|
+
case 'storedCache':
|
|
110
|
+
await getResult(flowSchema.objType);
|
|
111
|
+
break;
|
|
112
|
+
case 'triggerCache':
|
|
113
|
+
await getResult(flowSchema.objType);
|
|
114
|
+
break;
|
|
115
|
+
case 'none': {
|
|
116
|
+
let identifier = {};
|
|
117
|
+
if (
|
|
118
|
+
requestParams.hasOwnProperty('identifiersField') &&
|
|
119
|
+
Array.isArray(requestParams.identifiersField)
|
|
120
|
+
) {
|
|
121
|
+
for (const fieldNames of requestParams.identifiersField) {
|
|
122
|
+
Object.assign(identifier, {
|
|
123
|
+
[fieldNames]: requestParams[fieldNames]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
identifier = requestParams;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
let tasks = await dynamodbSharedLib.query(
|
|
131
|
+
_izContext,
|
|
132
|
+
await dynamodbSharedLib.tableName(_izContext, 'RegisterRecords'),
|
|
133
|
+
{
|
|
134
|
+
identifiersTask: hash(identifier)
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
if (tasks.Items && tasks.Items.length > 0) {
|
|
139
|
+
await Promise.all(
|
|
140
|
+
tasks.Items.map(async (task) => {
|
|
141
|
+
await postToConnection({ message: task }, task.connectionId);
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
default:
|
|
148
|
+
throw new NoRetryError(`statusType not found ${flowSchema.statusType}`);
|
|
149
|
+
}
|
|
150
|
+
} catch (err) {
|
|
151
|
+
_izContext.logger.error('error WebSocketInvoke: ', err);
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
RegisterCompleteHdrSqs:
|
|
2
|
+
handler: src/generatedCode/SystemFlowSchemas/Register/source/RegisterComplete_HdrSqs.main
|
|
3
|
+
name: ${self:custom.iz_resourcePrefix}RegisterCompleteHdrSqs
|
|
4
|
+
role: RegisterRole
|
|
5
|
+
events:
|
|
6
|
+
- sqs:
|
|
7
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}RegisterComplete
|
|
8
|
+
batchSize: 10
|
|
9
|
+
|
|
10
|
+
RegisterCompleteDsq:
|
|
11
|
+
handler: src/generatedCode/SystemFlowSchemas/Register/source/RegisterComplete_HdrDsq.main
|
|
12
|
+
name: ${self:custom.iz_resourcePrefix}RegisterCompleteDsq
|
|
13
|
+
role: RegisterRole
|
|
14
|
+
events:
|
|
15
|
+
- sqs:
|
|
16
|
+
arn: arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}RegisterCompleteDLQ
|
|
17
|
+
batchSize: 10
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { middlewareHandler as middleware, consts, response } from '@izara_project/izara-middleware';
|
|
2
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
3
|
+
import registerMain from './Register_Main.js';
|
|
4
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
5
|
+
import { webSocket } from '@izara_project/izara-core-library-external-request';
|
|
6
|
+
const { postToConnection } = webSocket;
|
|
7
|
+
|
|
8
|
+
export const main = middleware.wrap(async (event, context) => {
|
|
9
|
+
event._izContext.logger.debug('Event:', event);
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
if (event.requestContext) {
|
|
13
|
+
const route = event.requestContext.routeKey;
|
|
14
|
+
const connectionId = event.requestContext.connectionId;
|
|
15
|
+
let correlationId = event._izContext.correlationIds.get(consts.X_CORRELATION_ID);
|
|
16
|
+
|
|
17
|
+
switch (route) {
|
|
18
|
+
case '$default':
|
|
19
|
+
console.log('Received unknown route:', route);
|
|
20
|
+
break;
|
|
21
|
+
case 'register':
|
|
22
|
+
console.log('event in route register', event);
|
|
23
|
+
let eventParams = JSON.parse(event.body);
|
|
24
|
+
|
|
25
|
+
await dynamodbSharedLib.putItem(
|
|
26
|
+
event._izContext,
|
|
27
|
+
await dynamodbSharedLib.tableName(event._izContext, 'WebSocketTask'),
|
|
28
|
+
{
|
|
29
|
+
taskKey: correlationId,
|
|
30
|
+
connectionId: connectionId
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
let callingFlow = eventParams?.callingFlow ? eventParams.callingFlow : {};
|
|
35
|
+
|
|
36
|
+
await registerMain(
|
|
37
|
+
event._izContext,
|
|
38
|
+
eventParams,
|
|
39
|
+
callingFlowSharedLib.addCallingFlowToPassOnProperties(callingFlow)
|
|
40
|
+
);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
const connId = event.connId;
|
|
45
|
+
await postToConnection({ message: event.message }, connId);
|
|
46
|
+
}
|
|
47
|
+
return response.webSocketSuccess();
|
|
48
|
+
} catch (err) {
|
|
49
|
+
const connId = event.requestContext?.connectionId;
|
|
50
|
+
event._izContext.logger.error('Error, WebSocket: ', err);
|
|
51
|
+
if (connId) {
|
|
52
|
+
await postToConnection({ message: err.message }, connId);
|
|
53
|
+
}
|
|
54
|
+
return response.failure(err);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { objectHash as hash } from '@izara_project/izara-shared-core';
|
|
2
|
+
import { getObjectSchema, identifiersObject } from '@izara_project/izara-core-library-service-schemas';
|
|
3
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
4
|
+
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
5
|
+
import { lambda, webSocket } from '@izara_project/izara-core-library-external-request';
|
|
6
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
7
|
+
import { consts } from '@izara_project/izara-middleware';
|
|
8
|
+
const { postToConnection } = webSocket;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Register main handler
|
|
12
|
+
* @param {Object} _izContext
|
|
13
|
+
* @param {Object} requestParams
|
|
14
|
+
* @param {Object} callingFlowConfig
|
|
15
|
+
*/
|
|
16
|
+
export default async function registerMain(
|
|
17
|
+
_izContext,
|
|
18
|
+
requestParams,
|
|
19
|
+
callingFlowConfig = {}
|
|
20
|
+
) {
|
|
21
|
+
try {
|
|
22
|
+
let connectionId = _izContext.correlationIds.get(consts.CONNECTION_ID);
|
|
23
|
+
let flowSchema = await getObjectSchema.getFlowSchemaS3WithCache(_izContext, {
|
|
24
|
+
flowTag: requestParams.flowTag,
|
|
25
|
+
serviceTag: process.env.iz_serviceTag
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
_izContext.logger.debug('flowSchema', flowSchema);
|
|
29
|
+
if (!flowSchema) {
|
|
30
|
+
throw new NoRetryError(`flowTag not found ${requestParams.flowTag}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const getResult = async (objType) => {
|
|
34
|
+
const objectSchema = await getObjectSchema.getObjSchemaS3WithCache(
|
|
35
|
+
_izContext,
|
|
36
|
+
{
|
|
37
|
+
objectType: objType.objectType,
|
|
38
|
+
serviceTag: objType.serviceTag
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
_izContext.logger.debug('==> objectSchema', objectSchema);
|
|
43
|
+
|
|
44
|
+
const result = await lambda.invokeSync(
|
|
45
|
+
_izContext,
|
|
46
|
+
await lambdaSharedLib.lambdaFunctionName(_izContext, 'GetHdrInv'),
|
|
47
|
+
{
|
|
48
|
+
identifiers: await identifiersObject.identifiersFromIdentifiersConcat(
|
|
49
|
+
_izContext,
|
|
50
|
+
objType,
|
|
51
|
+
requestParams.identifiersTask
|
|
52
|
+
),
|
|
53
|
+
objectType: objType.objectType
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (!result) {
|
|
58
|
+
await postToConnection({ message: 'not have record' }, connectionId);
|
|
59
|
+
} else {
|
|
60
|
+
for (const [fieldName, fieldNameSetting] of Object.entries(
|
|
61
|
+
objectSchema.fieldNames
|
|
62
|
+
)) {
|
|
63
|
+
if (
|
|
64
|
+
fieldNameSetting.hasOwnProperty('statusField') &&
|
|
65
|
+
fieldNameSetting.statusField === true
|
|
66
|
+
) {
|
|
67
|
+
if (
|
|
68
|
+
result.fields[fieldName] !== 'complete' &&
|
|
69
|
+
result.fields[fieldName] !== 'error'
|
|
70
|
+
) {
|
|
71
|
+
await dynamodbSharedLib.putItem(
|
|
72
|
+
_izContext,
|
|
73
|
+
await dynamodbSharedLib.tableName(_izContext, 'RegisterRecords'),
|
|
74
|
+
{
|
|
75
|
+
identifiersTask: requestParams.identifiersTask,
|
|
76
|
+
connectionId: connectionId
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
} else {
|
|
80
|
+
await postToConnection({ message: result }, connectionId);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
switch (flowSchema.statusType) {
|
|
88
|
+
case 'statusField':
|
|
89
|
+
await getResult(flowSchema.objType);
|
|
90
|
+
break;
|
|
91
|
+
case 'storedCache':
|
|
92
|
+
await getResult(flowSchema.objType);
|
|
93
|
+
break;
|
|
94
|
+
case 'triggerCache':
|
|
95
|
+
await getResult(flowSchema.objType);
|
|
96
|
+
break;
|
|
97
|
+
case 'none': {
|
|
98
|
+
let identifier = {};
|
|
99
|
+
if (
|
|
100
|
+
requestParams.hasOwnProperty('identifiersField') &&
|
|
101
|
+
Array.isArray(requestParams.identifiersField)
|
|
102
|
+
) {
|
|
103
|
+
for (const fieldNames of requestParams.identifiersField) {
|
|
104
|
+
Object.assign(identifier, {
|
|
105
|
+
[fieldNames]: requestParams[fieldNames]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
let pureRequestParams = structuredClone(requestParams);
|
|
110
|
+
delete pureRequestParams.flowTag;
|
|
111
|
+
identifier = pureRequestParams;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let tasks = await dynamodbSharedLib.query(
|
|
115
|
+
_izContext,
|
|
116
|
+
await dynamodbSharedLib.tableName(_izContext, 'RegisterRecords'),
|
|
117
|
+
{
|
|
118
|
+
identifiersTask: hash(identifier)
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
if (tasks.Items && tasks.Items.length > 0) {
|
|
122
|
+
await Promise.all(
|
|
123
|
+
tasks.Items.map(async (task) => {
|
|
124
|
+
await postToConnection({ message: task }, task.connectionId);
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
await postToConnection({ message: tasks.Items[0] }, connectionId);
|
|
128
|
+
return tasks.Items[0];
|
|
129
|
+
} else {
|
|
130
|
+
await dynamodbSharedLib.putItem(
|
|
131
|
+
_izContext,
|
|
132
|
+
await dynamodbSharedLib.tableName(_izContext, 'RegisterRecords'),
|
|
133
|
+
{
|
|
134
|
+
identifiersTask: hash(identifier),
|
|
135
|
+
connectionId: connectionId
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
default:
|
|
142
|
+
throw new NoRetryError(`statusType not found ${flowSchema.statusType}`);
|
|
143
|
+
}
|
|
144
|
+
} catch (err) {
|
|
145
|
+
_izContext.logger.error('error WebSocketInvoke: ', err);
|
|
146
|
+
throw err;
|
|
147
|
+
}
|
|
148
|
+
}
|
package/src/output/mergeHooks.js
CHANGED
|
@@ -39,7 +39,8 @@ async function mergeHook(outputRoot, artifact) {
|
|
|
39
39
|
|
|
40
40
|
return artifact.content.replace(
|
|
41
41
|
matchers.anyTag,
|
|
42
|
-
(_match,
|
|
42
|
+
(_match, p1, _body1, p2) => {
|
|
43
|
+
const tagName = p1 || p2;
|
|
43
44
|
const hookBlock = sourceContent.match(matchers.tagPattern(tagName))?.[0];
|
|
44
45
|
return hookBlock ?? _match;
|
|
45
46
|
}
|
|
@@ -49,10 +50,10 @@ async function mergeHook(outputRoot, artifact) {
|
|
|
49
50
|
function hookMatchers(filePath) {
|
|
50
51
|
if (filePath.endsWith('.js')) {
|
|
51
52
|
return {
|
|
52
|
-
anyTag:
|
|
53
|
+
anyTag: /(?:\/\/\(<(\w+)>\)([\s\S]*?)\/\/\(<\/\1>\)|\/\/\s*<#(\w+)#>([\s\S]*?)\/\/\s*<#\/\3#>)/gm,
|
|
53
54
|
tagPattern: (name) =>
|
|
54
55
|
new RegExp(
|
|
55
|
-
|
|
56
|
+
`(?:\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)|\\/\\/\\s*<#${name}#>([\\s\\S]*?)\\/\\/\\s*<#\\/${name}#>)`,
|
|
56
57
|
'gm'
|
|
57
58
|
)
|
|
58
59
|
};
|
|
@@ -36,7 +36,17 @@ test('emits handlers, function YAML, and IAM roles for supported custom flow eve
|
|
|
36
36
|
const result = await generateCustomFlowApplicationArtifacts(rootPath);
|
|
37
37
|
await generateResourceArtifacts(rootPath);
|
|
38
38
|
|
|
39
|
-
assert.equal(result.files.length,
|
|
39
|
+
assert.equal(result.files.length, 43);
|
|
40
|
+
assert.match(
|
|
41
|
+
await readFile(
|
|
42
|
+
join(
|
|
43
|
+
rootPath,
|
|
44
|
+
'app/src/generatedCode/SystemFlowSchemas/Register/source/Register_Main.js'
|
|
45
|
+
),
|
|
46
|
+
'utf8'
|
|
47
|
+
),
|
|
48
|
+
/registerMain/
|
|
49
|
+
);
|
|
40
50
|
assert.match(
|
|
41
51
|
await readFile(
|
|
42
52
|
join(
|
|
@@ -794,17 +804,18 @@ test('renders nextSteps IAM permissions in InitialSetupConfig', async () => {
|
|
|
794
804
|
),
|
|
795
805
|
'utf8'
|
|
796
806
|
);
|
|
797
|
-
assert.match(initialSetupConfigContent, /roleName: '
|
|
807
|
+
assert.match(initialSetupConfigContent, /roleName: 'Reservations'/);
|
|
798
808
|
assert.match(
|
|
799
809
|
initialSetupConfigContent,
|
|
800
|
-
/
|
|
810
|
+
/ReservationsPublishNextStepsTopics/
|
|
801
811
|
);
|
|
802
812
|
assert.match(
|
|
803
813
|
initialSetupConfigContent,
|
|
804
|
-
|
|
814
|
+
/\/\/\(<createReservationsRole>\)/
|
|
805
815
|
);
|
|
806
816
|
assert.match(
|
|
807
817
|
initialSetupConfigContent,
|
|
808
|
-
|
|
818
|
+
/\/\/\(<\/createReservationsRole>\)/
|
|
809
819
|
);
|
|
810
820
|
});
|
|
821
|
+
|
package/test/publicApi.test.js
CHANGED
|
@@ -99,6 +99,27 @@ test('generate commits the system WebSocket completion path for own-topic flows'
|
|
|
99
99
|
'app/src/generatedCode/SystemFlowSchemas/WebSocketMain/source/WebSocketComplete_HdrSqs.js'
|
|
100
100
|
)
|
|
101
101
|
);
|
|
102
|
+
assert.ok(
|
|
103
|
+
result.files.some(
|
|
104
|
+
(file) =>
|
|
105
|
+
file.path ===
|
|
106
|
+
'app/src/generatedCode/SystemFlowSchemas/Register/source/Register_Main.js'
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
assert.ok(
|
|
110
|
+
result.files.some(
|
|
111
|
+
(file) =>
|
|
112
|
+
file.path ===
|
|
113
|
+
'app/src/generatedCode/SystemFlowSchemas/Register/source/Register_HdrWbs.js'
|
|
114
|
+
)
|
|
115
|
+
);
|
|
116
|
+
assert.ok(
|
|
117
|
+
result.files.some(
|
|
118
|
+
(file) =>
|
|
119
|
+
file.path ===
|
|
120
|
+
'app/src/generatedCode/SystemFlowSchemas/Register/source/RegisterComplete_Main.js'
|
|
121
|
+
)
|
|
122
|
+
);
|
|
102
123
|
assert.ok(
|
|
103
124
|
result.files.some(
|
|
104
125
|
(file) =>
|
|
@@ -115,7 +115,7 @@ test('emits relationship action and complete handlers with data-first function Y
|
|
|
115
115
|
);
|
|
116
116
|
assert.match(
|
|
117
117
|
createCompleteContent,
|
|
118
|
-
/const {\s*returnValue,\s*status,\s*errorsFound,\s*graphServiceTag\s*} = requestParams;/
|
|
118
|
+
/const {\s*returnValue,\s*parentFlowId,\s*status,\s*errorsFound,\s*graphServiceTag\s*} = requestParams;/
|
|
119
119
|
);
|
|
120
120
|
assert.doesNotMatch(
|
|
121
121
|
createCompleteContent,
|
|
@@ -237,6 +237,26 @@ test('emits DynamoDB tables and hooks defined in flowSchemas storageResources',
|
|
|
237
237
|
assert.match(dynamoYaml, /#<#\/FlowCustomTableTableSetting#>/);
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
+
test('emits IAM role for generated DSQ flows in generate-shared-resource.yml', async () => {
|
|
241
|
+
const rootPath = await createProject();
|
|
242
|
+
const schemas = join(rootPath, 'app/src/schemas');
|
|
243
|
+
await writeFile(
|
|
244
|
+
join(schemas, 'FlowSchemas/GeneratedDsq.js'),
|
|
245
|
+
"export default { flowTag: 'generatedDsq', generatedCodeConfig: {}, event: ['dsq'] };\n"
|
|
246
|
+
);
|
|
247
|
+
await generateResourceArtifacts(rootPath);
|
|
248
|
+
|
|
249
|
+
const iam = await readFile(
|
|
250
|
+
join(
|
|
251
|
+
rootPath,
|
|
252
|
+
'app/sls_yaml/generatedCode/source/generate-shared-resource.yml'
|
|
253
|
+
),
|
|
254
|
+
'utf8'
|
|
255
|
+
);
|
|
256
|
+
const role = roleBlock(iam, 'GeneratedDsqRole');
|
|
257
|
+
assert.match(role, /GeneratedDsqHdrDsq/);
|
|
258
|
+
});
|
|
259
|
+
|
|
240
260
|
function roleBlock(iam, roleName) {
|
|
241
261
|
const match = iam.match(
|
|
242
262
|
new RegExp(
|