@izara_project/izara-market-library-service-schemas 1.0.56 → 1.0.58

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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +4 -28
  3. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +5 -6
  4. package/src/reStructure/TemplateData/EndpointPerService/mainFunction/get/template.ejs +6 -4
  5. package/src/reStructure/TemplateData/EndpointPerService/yaml/data.js +4 -22
  6. package/src/reStructure/TemplateData/flowSchema/components/upload/confirmReserved/mainFunction/template.ejs +3 -1
  7. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/functionYaml/data.js +2 -1
  8. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/handler/template.ejs +12 -8
  9. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/data.js +0 -14
  10. package/src/reStructure/TemplateData/flowSchema/components/upload/createObject/mainFunction/template.ejs +19 -13
  11. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/data.js +3 -1
  12. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/createPresignUrl/mainFunction/template.ejs +26 -16
  13. package/src/reStructure/TemplateData/flowSchema/components/upload/preSignUrl/reservedLimit/mainFunction/template.ejs +9 -12
  14. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrS3/template.ejs +0 -3
  15. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/data.js +4 -1
  16. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/S3/template.ejs +1 -1
  17. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/libs/template.ejs +4 -47
  18. package/src/reStructure/TemplateData/flowSchema/components/upload/relate/sns-out/data.js +75 -0
  19. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/functionYaml/data.js +1 -1
  20. package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +18 -0
  21. package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/ttlDynamoTemplate.ejs +32 -0
  22. package/src/reStructure/TemplateData/flowSchema/components/websocket/dynamoDb/userUploadRecords.js +58 -0
  23. package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/handler/template.ejs +3 -2
  24. package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +23 -15
  25. package/src/reStructure/TemplateData/flowSchema/webSocketComplete/mainFunction/template.ejs +7 -6
  26. package/src/reStructure/TemplateData/perActionComplete/update/mainFunction/template.ejs +4 -4
  27. package/src/reStructure/TemplateData/processLogical/mainFunction/template.ejs +2 -2
  28. package/src/reStructure/TemplateData/resourceYaml/dynamodb/mainResourcePerObjectSchemaData.js +1 -1
  29. package/src/reStructure/TemplateData/resourceYaml/filterGenerateResource/data.js +22 -2
  30. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrDsq/data.js +0 -87
  31. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/functionYml/HdrDsq/template.ejs +0 -30
  32. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerDsq/data.js +0 -45
  33. package/src/reStructure/TemplateData/flowSchema/components/upload/processFile/handler/handlerDsq/template.ejs +0 -151
  34. package/src/reStructure/TemplateData/resourceYaml/dynamodb/request.json +0 -7
@@ -1,151 +0,0 @@
1
- /*
2
- Copyright (C) 2021 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
- 'use strict';
19
-
20
- // const AWS = require('aws-sdk');
21
- // const sqs = new AWS.SQS({ apiVersion: '2012-11-05' });
22
-
23
- const izara = require("@izara_project/izara-middleware");
24
- const middleware = izara.middlewareHandler;
25
- const recordHandlerSharedLib = require("@izara_project/izara-shared").recordHandlerSharedLib;
26
- const Logger = require('@izara_project/izara-core-library-logger');
27
- const izaraShared = require('@izara_project/izara-shared');
28
- const callingFlowSharedLib = izaraShared.callingFlowSharedLib;
29
-
30
- const processAfterUpload = require('./ProcessAfterUploadS3_Main')
31
-
32
- // validate event properties in body.Message of sqs event
33
- middleware.setValidatorSchema(
34
- recordHandlerSharedLib.baseValidatorSchema({
35
- type: 'object',
36
- required: ['body', 'messageAttributes'],
37
- properties: {
38
- body: {
39
- type: 'object',
40
- },
41
- messageAttributes: {
42
- type: 'object',
43
- },
44
- },
45
- })
46
- );
47
-
48
- // set schema for record.body.Message
49
- let perRecordsValidatorSchema = {
50
- type: "object",
51
- required: [
52
- 'bucket',
53
- 'field',
54
- 'importBy'
55
- ],
56
- properties: {
57
- bucket: {
58
- type: "string"
59
- },
60
- field: {
61
- type: "object"
62
- },
63
- importBy: {
64
- type: "string"
65
- },
66
- imageImportId: {
67
- type: "string"
68
- },
69
- realImageSize: {
70
- type: "number",
71
- default: 0
72
- }
73
- }
74
- };
75
-
76
- // set schema for record.body.MessageAttributes
77
- // const messageAttributeValidatorSchema = {
78
- // type: "object",
79
- // required: ['msgAtrrParam1', 'msgAtrrParam2'],
80
- // properties: {
81
- // msgAtrrParam1: {
82
- // type: "string"
83
- // },
84
- // msgAtrrParam2: {
85
- // type: "object"
86
- // }
87
- // }
88
- // };
89
-
90
- perRecordsValidatorSchema = callingFlowSharedLib.addOptionalPassBackPropertiesToValidatorSchema(perRecordsValidatorSchema)
91
-
92
- module.exports.main = middleware.wrap(async (event, context, callback) => {
93
-
94
- try {
95
-
96
- let recordPromises = []; // final return
97
-
98
- // loop each record and send to mainFunction
99
- await Promise.all(event.Records.map(async record => { // promise.all for map() function
100
-
101
- // --- reforming record.body for Dsq request
102
- record = recordHandlerSharedLib.reformatDsqMessage(record._izContext, record);
103
- record._izContext.logger.debug('record GetSignedUrlS3HdrDsq after reform', record);
104
-
105
- let passOnProperties = []
106
-
107
- // validate message (and MessageAttributes)
108
- await recordHandlerSharedLib.validateRecord(
109
- record, // one record will send to mainFunction
110
- "ProcessAfterUploadHdrDsq", // queue name that need to retry or send to dlq
111
- perRecordsValidatorSchema, // schema for record.Message
112
- // messageAttributeValidatorSchema // ----- for msgAttr default is null -> do not send this parameter if not want to validate msgAtt
113
- );
114
-
115
- // add argument (to invoke lambda) to passOnProperties[]
116
- passOnProperties.push(record.body.Message.bucket),
117
- passOnProperties.push(record.body.Message.field),
118
- passOnProperties.push(record.body.Message.importBy),
119
- passOnProperties.push(record.body.Message.imageImportId),
120
- passOnProperties.push(record.body.Message.realImageSize),
121
- passOnProperties.push(record.body.Message.passBackProperties),
122
- record._izContext.logger.debug('passOnProperties in handler', passOnProperties);
123
-
124
- // call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
125
- let recordPromise = recordHandlerSharedLib.recordHandler(
126
- record, // one record will send to mainFunction
127
- processAfterUpload.processAfterUpload, // mainFunction that need to invoke.
128
- "ProcessAfterUploadHdrDsq", // queue name that need to retry or send to dlq
129
- passOnProperties, // all parameters that mainFunction needed.
130
- );
131
- record._izContext.logger.debug('after recordPromise in handler');
132
- recordPromises.push(recordPromise); // push promise to recordPromises
133
- }))
134
-
135
- Logger.debug('before Promise.all(recordPromises) in handler');
136
- try {
137
- // --- main await all promises
138
- await Promise.all(recordPromises); // await all promises
139
-
140
- return event.Records // return all for local test
141
-
142
- } catch {
143
- Logger.debug('Promise.all(recordPromises) in handler threw error (at least one record did no resolve)');
144
- }
145
- Logger.debug('after Promise.all(recordPromises) in handler');
146
-
147
- } catch (err) {
148
- Logger.error('Unhandled Error, processImageAfterUpload: ', err);
149
- throw (err);
150
- }
151
- });
@@ -1,7 +0,0 @@
1
- {
2
- "tableName": "xxx",
3
- "attributes": {
4
- "partitionKey": "xxx",
5
- "sortKey": "optional"
6
- }
7
- }