@izara_project/izara-core-generate-service-code 1.0.99 → 1.0.101
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/compileProject.js +16 -5
- package/src/compile/flowValidator.js +3 -1
- package/src/compile/loadSchemas.js +18 -4
- package/src/compile/schemaValidatorSetup.js +16 -0
- package/src/emit/application/coreFunction/emitCoreFunctionArtifacts.js +108 -108
- package/src/emit/application/coreFunction/templates/InitialSetupRunner.ejs +2 -2
- package/src/emit/application/crud/templates/CreateComplete_Main.ejs +2 -0
- package/src/emit/application/crud/templates/CreateLogicalLib.ejs +20 -7
- package/src/emit/application/crud/templates/DeleteComplete_Main.ejs +2 -0
- package/src/emit/application/crud/templates/FlowEndpoint_HdrWbs.ejs +7 -5
- package/src/emit/application/crud/templates/UpdateComplete_Main.ejs +2 -0
- package/src/emit/application/custom/customFlowPaths.js +13 -16
- package/src/emit/application/custom/customFlowS3.js +456 -63
- package/src/emit/application/custom/customFlows.js +131 -0
- package/src/emit/application/custom/emitCustomFlowApplicationArtifacts.js +7 -4
- package/src/emit/application/custom/templates/s3/ConfirmAfterUpload_HdrSqs.ejs +111 -0
- package/src/emit/application/custom/templates/s3/ConfirmAfterUpload_Main.ejs +89 -0
- package/src/emit/application/custom/templates/s3/ConfirmComplete_HdrSqs.ejs +111 -0
- package/src/emit/application/custom/templates/s3/ConfirmComplete_Main.ejs +100 -0
- package/src/emit/application/custom/templates/s3/CreateObject_HdrWbs.ejs +2 -1
- package/src/emit/application/custom/templates/s3/CreateObject_Main.ejs +4 -0
- package/src/emit/application/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +42 -0
- package/src/emit/application/custom/templates/s3/CreatePreSignUrl_Main.ejs +23 -0
- package/src/emit/application/custom/templates/s3/ProcessS3File_Main.ejs +240 -27
- package/src/emit/application/custom/templates/s3/Start_Main.ejs +216 -0
- package/src/emit/application/rbac/emitDynamicRbacFlowSchemas.js +5 -1
- package/src/emit/application/rbac/emitRbacApplicationArtifacts.js +67 -60
- package/src/emit/application/rbac/templates/ReservedDynamicUsage_Main.ejs +27 -9
- package/src/emit/application/rbac/templates/UserRbacFlow_Main.ejs +4 -3
- package/src/emit/application/system/templates/Register_HdrWbs.ejs +2 -1
- package/src/emit/infrastructure/functions/functionYamlArtifact.js +3 -8
- package/src/emit/infrastructure/functions/templates/S3Function_Yaml.ejs +2 -3
- package/src/emit/infrastructure/resources/iamResourceArtifacts.js +22 -0
- package/src/emit/infrastructure/resources/resourceState.js +15 -5
- package/src/emit/infrastructure/resources/s3ResourceArtifacts.js +19 -3
- package/src/emit/infrastructure/resources/templates/S3Bucket_Yaml.ejs +1 -1
- package/src/emit/infrastructure/resources/templates/SystemDynamoDB_Yaml.ejs +2 -2
- package/src/emit/schemas/error/emitErrorSchemas.js +120 -10
- package/src/emit/schemas/error/templates/errorConsts.ejs +12 -0
- package/src/generate.js +32 -30
- package/src/plan/domainRegistry.js +2 -1
- package/test/integration/publicApi.test.js +33 -24
- package/test/unit/application/createTargetRoleHandler.test.js +33 -10
- package/test/unit/application/customFlowApplicationArtifacts.test.js +6 -6
- package/test/unit/application/customFlowS3.test.js +858 -0
- package/test/unit/infrastructure/functionYamlArtifact.test.js +6 -4
- package/test/unit/infrastructure/resourceArtifacts.test.js +51 -0
- package/test/unit/schemas/dynamicRbacFlowSchemas.test.js +8 -6
- package/test/unit/schemas/dynamicRelationshipFlowSchemas.test.js +51 -0
- package/test/unit/schemas/errorSchemas.test.js +84 -5
|
@@ -35,7 +35,7 @@ export { customFlowApplicationManagedPaths };
|
|
|
35
35
|
|
|
36
36
|
export async function emitCustomFlowApplicationArtifacts(
|
|
37
37
|
flows,
|
|
38
|
-
{ objects = [] } = {}
|
|
38
|
+
{ objects = [], relationships = [] } = {}
|
|
39
39
|
) {
|
|
40
40
|
const customFlows = supportedCustomFlows(flows);
|
|
41
41
|
const generatedRoots = generatedOwnTopicFlows(flows);
|
|
@@ -51,7 +51,7 @@ export async function emitCustomFlowApplicationArtifacts(
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const emitted = await Promise.all(
|
|
54
|
-
customFlows.map((flow) => emitFlow(flow, objects))
|
|
54
|
+
customFlows.map((flow) => emitFlow(flow, objects, relationships))
|
|
55
55
|
);
|
|
56
56
|
const roots = await Promise.all(
|
|
57
57
|
generatedRoots.map((flow) => emitOwnTopicRoot(flow, objects))
|
|
@@ -77,7 +77,7 @@ export async function emitCustomFlowApplicationArtifacts(
|
|
|
77
77
|
];
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
async function emitFlow(flow, objects) {
|
|
80
|
+
async function emitFlow(flow, objects, relationships = []) {
|
|
81
81
|
const tag = upperFirst(flow.flowTag);
|
|
82
82
|
const process = tag;
|
|
83
83
|
const source = `app/src/generatedCode/FlowSchemas/${tag}/source`;
|
|
@@ -201,7 +201,10 @@ async function emitFlow(flow, objects) {
|
|
|
201
201
|
functions.push(...root.functions);
|
|
202
202
|
}
|
|
203
203
|
if (flow.event.includes('s3')) {
|
|
204
|
-
const s3Artifacts = await emitS3Flow(flow, source, handlerRoot
|
|
204
|
+
const s3Artifacts = await emitS3Flow(flow, source, handlerRoot, {
|
|
205
|
+
objects,
|
|
206
|
+
relationships
|
|
207
|
+
});
|
|
205
208
|
artifacts.push(...s3Artifacts.artifacts);
|
|
206
209
|
functions.push(...s3Artifacts.functions);
|
|
207
210
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2026 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
|
+
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
20
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
21
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
22
|
+
|
|
23
|
+
import <%= functionName %> from './<%= functionName %>_Main.js';
|
|
24
|
+
|
|
25
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
26
|
+
|
|
27
|
+
let perRecordsValidatorSchema = {
|
|
28
|
+
type: 'object',
|
|
29
|
+
required: ['objType', 'objInstanceFull'],
|
|
30
|
+
properties: {
|
|
31
|
+
objType: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
required: ['objectType', 'serviceTag'],
|
|
34
|
+
properties: {
|
|
35
|
+
objectType: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
pattern: '^[a-zA-Z0-9_-]+$'
|
|
38
|
+
},
|
|
39
|
+
serviceTag: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
pattern: '^[a-zA-Z0-9_-]+$'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
objInstanceFull: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
identifiers: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
minProperties: 1
|
|
51
|
+
},
|
|
52
|
+
fields: {
|
|
53
|
+
type: 'object'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
perRecordsValidatorSchema =
|
|
61
|
+
callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(
|
|
62
|
+
perRecordsValidatorSchema
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export const main = middleware.wrap(async (event, context) => {
|
|
66
|
+
try {
|
|
67
|
+
let recordPromises = [];
|
|
68
|
+
|
|
69
|
+
await Promise.all(
|
|
70
|
+
event.Records.map(async (record) => {
|
|
71
|
+
let passOnProperties = [];
|
|
72
|
+
record._izContext.logger.debug('record <%= functionName %><%= handlerType %>', record);
|
|
73
|
+
|
|
74
|
+
await recordHandlerSharedLib.validateRecord(
|
|
75
|
+
record,
|
|
76
|
+
'<%= functionName %><%= handlerType %>',
|
|
77
|
+
perRecordsValidatorSchema
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
passOnProperties.push(record.body.Message.objType);
|
|
81
|
+
passOnProperties.push(record.body.Message.objInstanceFull);
|
|
82
|
+
//(<additionalProperties>)
|
|
83
|
+
//(</additionalProperties>)
|
|
84
|
+
passOnProperties.push(
|
|
85
|
+
callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(
|
|
86
|
+
record.body.Message
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
record._izContext.logger.debug(
|
|
91
|
+
'passOnProperties in <%= functionName %><%= handlerType %>',
|
|
92
|
+
passOnProperties
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
let returnPromise = await recordHandlerSharedLib.recordHandler(
|
|
96
|
+
record,
|
|
97
|
+
<%= functionName %>,
|
|
98
|
+
'<%= functionName %><%= handlerType %>',
|
|
99
|
+
passOnProperties
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
recordPromises.push(returnPromise);
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
return await Promise.all(recordPromises);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
Logger.error('Error <%= functionName %><%= handlerType %>: ', err);
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2026 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 dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
19
|
+
import { webSocket } from '@izara_project/izara-core-library-external-request';
|
|
20
|
+
const { postToConnection } = webSocket;
|
|
21
|
+
import { utils } from '@izara_project/izara-core-library-service-schemas';
|
|
22
|
+
const { createFlowTypeConcat } = utils;
|
|
23
|
+
|
|
24
|
+
//(<optionalRequired>)
|
|
25
|
+
//(</optionalRequired>)
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Step 3: ConfirmAfterUpload (Deferred-Node S3 Pipeline - ADR-016)
|
|
29
|
+
* SQS handler receiving objInstanceFull from OutCreate SNS topic.
|
|
30
|
+
* Confirms storage quota, queries WebSocketTask, and notifies client via WebSocket.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} _izContext
|
|
33
|
+
* @param {Object} objType
|
|
34
|
+
* @param {Object} objInstanceFull
|
|
35
|
+
* @param {Object} passBackProperties
|
|
36
|
+
* @returns {Promise<Object>}
|
|
37
|
+
*/
|
|
38
|
+
export default async function <%- functionName %>(
|
|
39
|
+
_izContext,
|
|
40
|
+
objType,
|
|
41
|
+
objInstanceFull,
|
|
42
|
+
//(<additionalProperties>)
|
|
43
|
+
//(</additionalProperties>)
|
|
44
|
+
passBackProperties = {}
|
|
45
|
+
) {
|
|
46
|
+
try {
|
|
47
|
+
_izContext.logger.debug('----- <%- functionName %> started -----', {
|
|
48
|
+
objType,
|
|
49
|
+
objInstanceFull,
|
|
50
|
+
passBackProperties
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const targetId =
|
|
54
|
+
objInstanceFull.identifiers?.<%- objectType %>Id ||
|
|
55
|
+
Object.values(objInstanceFull.identifiers || {})[0];
|
|
56
|
+
|
|
57
|
+
//(<confirmUsageHook>)
|
|
58
|
+
//(</confirmUsageHook>)
|
|
59
|
+
|
|
60
|
+
const taskKey = `${createFlowTypeConcat(_izContext, { flowTag: '<%- flowTag %>', serviceTag: process.env.iz_serviceTag })}${targetId}`;
|
|
61
|
+
const taskRecord = await dynamodbSharedLib.getItem(
|
|
62
|
+
_izContext,
|
|
63
|
+
await dynamodbSharedLib.tableName(_izContext, 'WebSocketTask'),
|
|
64
|
+
{ taskKey: taskKey }
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
if (taskRecord && taskRecord.connectionId) {
|
|
68
|
+
await postToConnection(
|
|
69
|
+
_izContext,
|
|
70
|
+
{
|
|
71
|
+
status: 'completed',
|
|
72
|
+
data: {
|
|
73
|
+
<%- objectType %>Id: targetId,
|
|
74
|
+
objInstanceFull: objInstanceFull
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
taskRecord.connectionId
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
status: 'completed',
|
|
83
|
+
objInstanceFull: objInstanceFull
|
|
84
|
+
};
|
|
85
|
+
} catch (err) {
|
|
86
|
+
_izContext.logger.error('Error in <%- functionName %>: ', err);
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2026 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
|
+
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
20
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
21
|
+
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
22
|
+
|
|
23
|
+
import <%= functionName %> from './<%= functionName %>_Main.js';
|
|
24
|
+
|
|
25
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
26
|
+
|
|
27
|
+
let perRecordsValidatorSchema = {
|
|
28
|
+
type: 'object',
|
|
29
|
+
required: ['objType', 'objInstanceFull'],
|
|
30
|
+
properties: {
|
|
31
|
+
objType: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
required: ['objectType', 'serviceTag'],
|
|
34
|
+
properties: {
|
|
35
|
+
objectType: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
pattern: '^[a-zA-Z0-9_-]+$'
|
|
38
|
+
},
|
|
39
|
+
serviceTag: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
pattern: '^[a-zA-Z0-9_-]+$'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
objInstanceFull: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
identifiers: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
minProperties: 1
|
|
51
|
+
},
|
|
52
|
+
fields: {
|
|
53
|
+
type: 'object'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
perRecordsValidatorSchema =
|
|
61
|
+
callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(
|
|
62
|
+
perRecordsValidatorSchema
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export const main = middleware.wrap(async (event, context) => {
|
|
66
|
+
try {
|
|
67
|
+
let recordPromises = [];
|
|
68
|
+
|
|
69
|
+
await Promise.all(
|
|
70
|
+
event.Records.map(async (record) => {
|
|
71
|
+
let passOnProperties = [];
|
|
72
|
+
record._izContext.logger.debug('record <%= functionName %><%= handlerType %>', record);
|
|
73
|
+
|
|
74
|
+
await recordHandlerSharedLib.validateRecord(
|
|
75
|
+
record,
|
|
76
|
+
'<%= functionName %><%= handlerType %>',
|
|
77
|
+
perRecordsValidatorSchema
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
passOnProperties.push(record.body.Message.objType);
|
|
81
|
+
passOnProperties.push(record.body.Message.objInstanceFull);
|
|
82
|
+
//(<additionalProperties>)
|
|
83
|
+
//(</additionalProperties>)
|
|
84
|
+
passOnProperties.push(
|
|
85
|
+
callingFlowSharedLib.addPassBackPropertiesToPassOnProperties(
|
|
86
|
+
record.body.Message
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
record._izContext.logger.debug(
|
|
91
|
+
'passOnProperties in <%= functionName %><%= handlerType %>',
|
|
92
|
+
passOnProperties
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
let returnPromise = await recordHandlerSharedLib.recordHandler(
|
|
96
|
+
record,
|
|
97
|
+
<%= functionName %>,
|
|
98
|
+
'<%= functionName %><%= handlerType %>',
|
|
99
|
+
passOnProperties
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
recordPromises.push(returnPromise);
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
return await Promise.all(recordPromises);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
Logger.error('Error <%= functionName %><%= handlerType %>: ', err);
|
|
109
|
+
throw err;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2026 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 dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
19
|
+
import { webSocket } from '@izara_project/izara-core-library-external-request';
|
|
20
|
+
const { postToConnection } = webSocket;
|
|
21
|
+
import { utils } from '@izara_project/izara-core-library-service-schemas';
|
|
22
|
+
const { createFlowTypeConcat } = utils;
|
|
23
|
+
|
|
24
|
+
//(<optionalRequired>)
|
|
25
|
+
//(</optionalRequired>)
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Step 3: ConfirmComplete (Deferred-Node S3 Pipeline - ADR-016)
|
|
29
|
+
* SQS handler receiving objInstanceFull from OutCreate SNS topic.
|
|
30
|
+
* Confirms storage quota, queries WebSocketTask, and notifies client via WebSocket.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} _izContext
|
|
33
|
+
* @param {Object} objType
|
|
34
|
+
* @param {Object} objInstanceFull
|
|
35
|
+
* @param {Object} passBackProperties
|
|
36
|
+
* @returns {Promise<Object>}
|
|
37
|
+
*/
|
|
38
|
+
export default async function <%- functionName %>(
|
|
39
|
+
_izContext,
|
|
40
|
+
objType,
|
|
41
|
+
objInstanceFull,
|
|
42
|
+
//(<additionalProperties>)
|
|
43
|
+
//(</additionalProperties>)
|
|
44
|
+
passBackProperties = {}
|
|
45
|
+
) {
|
|
46
|
+
try {
|
|
47
|
+
_izContext.logger.debug('----- <%- functionName %> started -----', {
|
|
48
|
+
objType,
|
|
49
|
+
objInstanceFull,
|
|
50
|
+
passBackProperties
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
let targetId =
|
|
54
|
+
passBackProperties.rawId ||
|
|
55
|
+
passBackProperties.<%- objectType %>Id ||
|
|
56
|
+
passBackProperties.parentPassBackProperties?.rawId ||
|
|
57
|
+
passBackProperties.parentPassBackProperties?.<%- objectType %>Id ||
|
|
58
|
+
objInstanceFull?.identifiers?.<%- objectType %>Id;
|
|
59
|
+
|
|
60
|
+
if (!targetId && objInstanceFull?.identifiers) {
|
|
61
|
+
targetId = Object.values(objInstanceFull.identifiers)[0];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//(<confirmUsageHook>)
|
|
65
|
+
//(</confirmUsageHook>)
|
|
66
|
+
|
|
67
|
+
const taskKey = `${createFlowTypeConcat(_izContext, { flowTag: '<%- flowTag %>', serviceTag: process.env.iz_serviceTag })}${targetId}`;
|
|
68
|
+
const tasks = await dynamodbSharedLib.query(
|
|
69
|
+
_izContext,
|
|
70
|
+
await dynamodbSharedLib.tableName(_izContext, 'WebSocketTask'),
|
|
71
|
+
{ taskKey }
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (tasks && tasks.Items && tasks.Items.length > 0) {
|
|
75
|
+
for (const taskRecord of tasks.Items) {
|
|
76
|
+
if (taskRecord.connectionId) {
|
|
77
|
+
await postToConnection(
|
|
78
|
+
_izContext,
|
|
79
|
+
{
|
|
80
|
+
status: 'completed',
|
|
81
|
+
data: {
|
|
82
|
+
<%- objectType %>Id: targetId,
|
|
83
|
+
objInstanceFull: objInstanceFull
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
taskRecord.connectionId
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
status: 'completed',
|
|
94
|
+
objInstanceFull: objInstanceFull
|
|
95
|
+
};
|
|
96
|
+
} catch (err) {
|
|
97
|
+
_izContext.logger.error('Error in <%- functionName %>: ', err);
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -57,7 +57,8 @@ export const main = middleware.wrap(async (event, context) => {
|
|
|
57
57
|
),
|
|
58
58
|
{
|
|
59
59
|
taskKey: `${createFlowTypeConcat(event._izContext, { flowTag: '<%- route %>', serviceTag: process.env.iz_serviceTag })}${identifiers}`,
|
|
60
|
-
connectionId: connectionId
|
|
60
|
+
connectionId: connectionId,
|
|
61
|
+
expirationTime: Math.floor(Date.now() / 1000) + 7200
|
|
61
62
|
}
|
|
62
63
|
);
|
|
63
64
|
|
|
@@ -127,7 +127,11 @@ export default async function createObject(
|
|
|
127
127
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
128
128
|
await lambdaSharedLib.lambdaFunctionName(
|
|
129
129
|
_izContext,
|
|
130
|
+
<% if (typeof nextStepFunctionName === 'string' && nextStepFunctionName) { -%>
|
|
131
|
+
'<%- nextStepFunctionName %>'
|
|
132
|
+
<% } else { -%>
|
|
130
133
|
TOPIC_NAME_GENERATE_CODE.createNodeComplete
|
|
134
|
+
<% } -%>
|
|
131
135
|
),
|
|
132
136
|
{}
|
|
133
137
|
)
|
|
@@ -26,6 +26,40 @@ import <%= functionName %> from './<%= functionName %>_Main.js';
|
|
|
26
26
|
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
27
27
|
|
|
28
28
|
// set schema for record.body.Message
|
|
29
|
+
<% if (isSimplifiedS3) { -%>
|
|
30
|
+
let perRecordsValidatorSchema = {
|
|
31
|
+
type: 'object',
|
|
32
|
+
required: ['objType', 'objInstanceFull'],
|
|
33
|
+
properties: {
|
|
34
|
+
objType: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
required: ['objectType', 'serviceTag'],
|
|
37
|
+
properties: {
|
|
38
|
+
objectType: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
pattern: '^[a-zA-Z0-9_-]+$'
|
|
41
|
+
},
|
|
42
|
+
serviceTag: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
pattern: '^[a-zA-Z0-9_-]+$'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
objInstanceFull: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
identifiers: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
minProperties: 1
|
|
54
|
+
},
|
|
55
|
+
fields: {
|
|
56
|
+
type: 'object'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
<% } else { -%>
|
|
29
63
|
let perRecordsValidatorSchema = {
|
|
30
64
|
type: 'object',
|
|
31
65
|
required: ['returnMessage', 'foundErrors', 'passStatus'],
|
|
@@ -41,6 +75,7 @@ let perRecordsValidatorSchema = {
|
|
|
41
75
|
}
|
|
42
76
|
}
|
|
43
77
|
};
|
|
78
|
+
<% } -%>
|
|
44
79
|
|
|
45
80
|
// set schema for record.body.MessageAttributes
|
|
46
81
|
// const messageAttributeValidatorSchema = {
|
|
@@ -82,9 +117,16 @@ export const main = middleware.wrap(async (event, context) => {
|
|
|
82
117
|
);
|
|
83
118
|
|
|
84
119
|
// add argument (to invoke lambda) to passOnProperties[]
|
|
120
|
+
<% if (isSimplifiedS3) { -%>
|
|
121
|
+
passOnProperties.push(record.body.Message.objType);
|
|
122
|
+
passOnProperties.push(record.body.Message.objInstanceFull);
|
|
123
|
+
passOnProperties.push(record.body.Message.status || 'complete');
|
|
124
|
+
passOnProperties.push(record.body.Message.foundErrors || []);
|
|
125
|
+
<% } else { -%>
|
|
85
126
|
passOnProperties.push(record.body.Message.returnMessage);
|
|
86
127
|
passOnProperties.push(record.body.Message.foundErrors);
|
|
87
128
|
passOnProperties.push(record.body.Message.passStatus);
|
|
129
|
+
<% } -%>
|
|
88
130
|
//(<additionalProperties>)
|
|
89
131
|
//(</additionalProperties>)
|
|
90
132
|
passOnProperties.push(
|
|
@@ -60,14 +60,30 @@ const { createFlowTypeConcat } = utils;
|
|
|
60
60
|
|
|
61
61
|
export default async function createPreSignUrl(
|
|
62
62
|
_izContext,
|
|
63
|
+
<% if (isSimplifiedS3) { -%>
|
|
64
|
+
objType,
|
|
65
|
+
objInstanceFull,
|
|
66
|
+
status = 'complete',
|
|
67
|
+
foundErrors = [],
|
|
68
|
+
<% } else { -%>
|
|
63
69
|
returnMessage,
|
|
64
70
|
foundErrors,
|
|
65
71
|
passStatus,
|
|
72
|
+
<% } -%>
|
|
66
73
|
//(<additionalProperties>)
|
|
67
74
|
//(</additionalProperties>)
|
|
68
75
|
passBackProperties = {}
|
|
69
76
|
) {
|
|
70
77
|
try {
|
|
78
|
+
<% if (isSimplifiedS3) { -%>
|
|
79
|
+
_izContext.logger.debug('----- createPreSignUrl event params -----', {
|
|
80
|
+
objType: objType,
|
|
81
|
+
objInstanceFull: objInstanceFull,
|
|
82
|
+
status: status,
|
|
83
|
+
foundErrors: foundErrors,
|
|
84
|
+
passBackProperties: passBackProperties
|
|
85
|
+
});
|
|
86
|
+
<% } else { -%>
|
|
71
87
|
_izContext.logger.debug('----- createPreSignUrl event params -----', {
|
|
72
88
|
returnMessage: returnMessage,
|
|
73
89
|
foundErrors: foundErrors,
|
|
@@ -80,6 +96,7 @@ export default async function createPreSignUrl(
|
|
|
80
96
|
const reservedDataId =
|
|
81
97
|
passBackProperties.passBackProperties.identifier.reservedDataId;
|
|
82
98
|
const objType = passBackProperties.passBackProperties.objType;
|
|
99
|
+
<% } -%>
|
|
83
100
|
|
|
84
101
|
const correlationId = _izContext.correlationIds.get(
|
|
85
102
|
consts.X_CORRELATION_ID
|
|
@@ -100,6 +117,7 @@ export default async function createPreSignUrl(
|
|
|
100
117
|
//(<afterGetResult>)
|
|
101
118
|
//(</afterGetResult>)
|
|
102
119
|
|
|
120
|
+
<% if (!isSimplifiedS3) { -%>
|
|
103
121
|
let uniqueIdentify = getNestObject(_izContext, returnMessage, [
|
|
104
122
|
'limitFound',
|
|
105
123
|
'runningTotal',
|
|
@@ -194,6 +212,7 @@ export default async function createPreSignUrl(
|
|
|
194
212
|
|
|
195
213
|
return 'reserved not pass';
|
|
196
214
|
}
|
|
215
|
+
<% } -%>
|
|
197
216
|
|
|
198
217
|
//(<createKeyForUploadFile>)
|
|
199
218
|
const Key = `${fileName}.${importType}`;
|
|
@@ -250,7 +269,11 @@ export default async function createPreSignUrl(
|
|
|
250
269
|
callingFlowSharedLib.addCallingFlowToSnsRequestMessageObject(
|
|
251
270
|
messageObject,
|
|
252
271
|
callingFlowSharedLib.addParentCallingFlowConfig(
|
|
272
|
+
<% if (isSimplifiedS3) { -%>
|
|
273
|
+
passBackProperties,
|
|
274
|
+
<% } else { -%>
|
|
253
275
|
returnMessage, // resive parent callingFlowConfig.
|
|
276
|
+
<% } -%>
|
|
254
277
|
callingFlowSharedLib.createCallingFlowConfig(
|
|
255
278
|
// calling flow own service
|
|
256
279
|
await lambdaSharedLib.lambdaFunctionName(
|