vtlab-generic-functions 1.0.20 → 1.0.21

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 (2) hide show
  1. package/package.json +1 -1
  2. package/sqs/index.js +28 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vtlab-generic-functions",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "scripts": {
5
5
  "test": "jest"
6
6
  },
package/sqs/index.js CHANGED
@@ -78,8 +78,33 @@ const saveIntegrationMessages = async (document = {}) => {
78
78
  throw error;
79
79
  }
80
80
  };
81
+ /**
82
+ * Sends a ZPL message to an SQS queue.
83
+ * @async
84
+ * @function sendZplSqsMessage
85
+ * @param {Object} options - The options object.
86
+ * @param {string} options.s3PathOrigin - The S3 path of the origin.
87
+ * @param {string} options.s3PathDestination - The S3 path of the destination.
88
+ * @param {string} [options.type="pdf"] - The type of the message. Defaults to "pdf".
89
+ * @param {string} [options.size="4x6"] - The size of the message. Defaults to "4x6".
90
+ * @throws {Error} Throws an error if required parameters are missing.
91
+ * @returns {Promise<void>} A Promise that resolves when the message is sent.
92
+ */
93
+ const sendZplSqsMessage = async ({s3PathOrigin, s3PathDestination, type = "pdf", size = "4x6"}) => {
94
+ if (!s3PathOrigin || !s3PathDestination) {
95
+ throw {
96
+ message: 'Missing required parameters'
97
+ }
98
+ }
99
+ const queue = await config.get("microservices.sqs.zplQueue");
100
+ const environment = process.env.NODE_ENV || "develop";
101
+ const payload = {
102
+ s3PathOrigin, s3PathDestination, type, size, environment
103
+ };
104
+ const stageVariables = {environment}
105
+ return await sendSQSMessage({payload, stageVariables}, queue, true);
106
+ }
81
107
 
82
108
  module.exports = {
83
- saveJobEvent,
84
- saveIntegrationMessages
85
- };
109
+ saveJobEvent, saveIntegrationMessages, sendZplSqsMessage
110
+ };