jaypie 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -97,6 +97,30 @@ _A `@jaypie/cdk` package is intended_
97
97
 
98
98
  ### AWS
99
99
 
100
+ ```javascript
101
+ import {
102
+ getMessages,
103
+ getSecret,
104
+ sendBatchMessages,
105
+ sendMessage,
106
+ } from "jaypie";
107
+ ```
108
+
109
+ #### `getMessages(event)`
110
+
111
+ Return an array of message bodies from an SQS event.
112
+
113
+ ```javascript
114
+ import { getMessages } from '@jaypie/aws';
115
+
116
+ const messages = getMessages(event);
117
+ // messages = [{ salutation: "Hello, world!" }, { salutation: "Hola, dushi!" }]
118
+ ```
119
+
120
+ #### `getSecret(secretName: string)`
121
+
122
+ Retrieve a secret from AWS Secrets Manager using the secret name.
123
+
100
124
  ```javascript
101
125
  import { getSecret } from '@jaypie/aws';
102
126
 
@@ -104,6 +128,51 @@ const secret = await getSecret("MongoConnectionStringN0NC3-nSg1bR1sh");
104
128
  // secret = "mongodb+srv://username:password@env-project.n0nc3.mongodb.net/app?retryWrites=true&w=majority";
105
129
  ```
106
130
 
131
+ #### `sendBatchMessages({ messages, queueUrl })`
132
+
133
+ Batch and send messages to an SQS queue. If more than ten messages are provided, the function will batch them into groups of ten or less (per AWS).
134
+
135
+ ```javascript
136
+ import { sendBatchMessages } from '@jaypie/aws';
137
+
138
+ const messages = [
139
+ { salutation: "Hello, world!" },
140
+ { salutation: "Hola, dushi!" },
141
+ ];
142
+ const queueUrl = "https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue";
143
+
144
+ await sendBatchMessages({ messages, queueUrl });
145
+ ```
146
+
147
+ | Parameter | Type | Required | Description |
148
+ | --------- | ---- | -------- | ----------- |
149
+ | `delaySeconds` | `number` | No | Seconds to delay message delivery; default `0` |
150
+ | `messages` | `Array` | Yes | Array of message objects (or strings) |
151
+ | `messageAttributes` | `object` | No | Message attributes |
152
+ | `messageGroupId` | `string` | No | Custom message group for FIFO queues; default provided |
153
+ | `queueUrl` | `string` | Yes | URL of the SQS queue |
154
+
155
+ #### `sendMessage({ body, queueUrl })`
156
+
157
+ Send a single message to an SQS queue.
158
+
159
+ ```javascript
160
+ import { sendMessage } from '@jaypie/aws';
161
+
162
+ const body = "Hello, world!";
163
+ const queueUrl = "https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue";
164
+
165
+ const response = await sendMessage({ body, queueUrl });
166
+ ```
167
+
168
+ | Parameter | Type | Required | Description |
169
+ | --------- | ---- | -------- | ----------- |
170
+ | `body` | `string` | Yes | Message body |
171
+ | `delaySeconds` | `number` | No | Seconds to delay message delivery; default `0` |
172
+ | `messageAttributes` | `object` | No | Message attributes |
173
+ | `messageGroupId` | `string` | No | Custom message group for FIFO queues; default provided |
174
+ | `queueUrl` | `string` | Yes | URL of the SQS queue |
175
+
107
176
  ### Constants
108
177
 
109
178
  ```javascript
@@ -464,6 +533,28 @@ log.lib().trace();
464
533
  log.lib({ lib: "myLib" }).trace();
465
534
  ```
466
535
 
536
+ ##### log.tag(key, value) or log.tag({ key: value })
537
+
538
+ Permanently add the key-value pair to the logger's tags, or at least until `log.untag(key)` is called.
539
+
540
+ ```javascript
541
+ import { log } from "jaypie";
542
+
543
+ log.tag("myTag", "myValue");
544
+ log.tag({ myTag: "myValue" });
545
+ ```
546
+
547
+ ##### log.untag(key) or log.untag([key1, key2, ...])
548
+
549
+ Remove the key-value pair from the logger's tags.
550
+
551
+ ```javascript
552
+ import { log } from "jaypie";
553
+
554
+ log.untag("myTag");
555
+ log.untag(["myTag1", "myTag2"]);
556
+ ```
557
+
467
558
  ##### log.var(key, value) or log.var({ key: value })
468
559
 
469
560
  Log a key-value pair. In the `json` format, the key will be tagged as `var` and the value will be the value. Logging marker variables this way can be useful for debugging.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaypie",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "author": "Finlayson Studio",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -20,7 +20,7 @@
20
20
  "@jaypie/core": "^1.0.2"
21
21
  },
22
22
  "devDependencies": {
23
- "@jaypie/testkit": "^1.0.3",
23
+ "@jaypie/testkit": "^1.0.4",
24
24
  "eslint": "^8.57.0",
25
25
  "eslint-config-prettier": "^9.1.0",
26
26
  "eslint-plugin-import": "^2.29.1",
@@ -33,9 +33,9 @@
33
33
  "vitest": "^1.4.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@jaypie/aws": "^1.0.0",
37
- "@jaypie/lambda": "^1.0.0",
38
- "@jaypie/mongoose": "^1.0.0"
36
+ "@jaypie/aws": "^1.0.1",
37
+ "@jaypie/lambda": "^1.0.1",
38
+ "@jaypie/mongoose": "^1.0.1"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@jaypie/aws": {
@@ -6,7 +6,8 @@ import dynamicExport from "./dynamicExport.function.js";
6
6
  // Export
7
7
  //
8
8
 
9
- export const { getSecret } = await dynamicExport({
10
- functions: ["getSecret"],
11
- moduleImport: JAYPIE.LIB.AWS,
12
- });
9
+ export const { getMessages, getSecret, sendBatchMessages, sendMessage } =
10
+ await dynamicExport({
11
+ functions: ["getMessages", "getSecret", "sendBatchMessages", "sendMessage"],
12
+ moduleImport: JAYPIE.LIB.AWS,
13
+ });