@homecloud-platform/sdk 0.5.1 → 0.5.3

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/src/mq.js +8 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecloud-platform/sdk",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "HomeCloud Functions SDK for Node.js (ADR-033 / ADR-025e)",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/mq.js CHANGED
@@ -60,13 +60,13 @@ class MqAPI {
60
60
  return this._c.dataPlaneRequest("mq", "POST", reqPath, { json: payload });
61
61
  }
62
62
 
63
- async receive(queueName, { maxMessages = 1, waitSeconds = 20 } = {}) {
63
+ async receive(queueName, { maxMessages = 1, waitSeconds = 20, delete: shouldDelete = false } = {}) {
64
64
  this._c.requireAccessKey();
65
65
  const accountId = this._c.accountId;
66
66
  const reqPath = `/${accountId}/${queueName}/messages`;
67
- const data = await this._c.dataPlaneRequest("mq", "GET", reqPath, {
68
- params: { max_messages: maxMessages, wait_seconds: waitSeconds },
69
- });
67
+ const params = { max_messages: maxMessages, wait_seconds: waitSeconds };
68
+ if (shouldDelete) params.delete = "true";
69
+ const data = await this._c.dataPlaneRequest("mq", "GET", reqPath, { params });
70
70
  return data.items || [];
71
71
  }
72
72
 
@@ -84,13 +84,13 @@ class MqAPI {
84
84
  await this._c.dataPlaneRequest("mq", "POST", reqPath);
85
85
  }
86
86
 
87
- async receiveDlq(queueName, { maxMessages = 1, waitSeconds = 20 } = {}) {
87
+ async receiveDlq(queueName, { maxMessages = 1, waitSeconds = 20, delete: shouldDelete = false } = {}) {
88
88
  this._c.requireAccessKey();
89
89
  const accountId = this._c.accountId;
90
90
  const reqPath = `/${accountId}/${queueName}/dlq/messages`;
91
- const data = await this._c.dataPlaneRequest("mq", "GET", reqPath, {
92
- params: { max_messages: maxMessages, wait_seconds: waitSeconds },
93
- });
91
+ const params = { max_messages: maxMessages, wait_seconds: waitSeconds };
92
+ if (shouldDelete) params.delete = "true";
93
+ const data = await this._c.dataPlaneRequest("mq", "GET", reqPath, { params });
94
94
  return data.items || [];
95
95
  }
96
96