@statefarmins/destringify-any-json 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 +22 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,31 +6,31 @@
|
|
|
6
6
|
## What is the destringify function?
|
|
7
7
|
The problem:
|
|
8
8
|
When AWS microservices pass an event from one service to the next; the service
|
|
9
|
-
wraps the event in
|
|
10
|
-
resource is passed.
|
|
11
|
-
get continually passed through
|
|
9
|
+
wraps the event in metadata and stringifies it. This is repeated each time a
|
|
10
|
+
resource is passed. As a result, structures that have variable levels of stringification
|
|
11
|
+
can get continually passed through a distributed AWS flow.
|
|
12
12
|
|
|
13
13
|
An example of a log with single and triple levels of stringification.
|
|
14
14
|
|
|
15
|
-
"data":{"Records":[{"messageId":"
|
|
16
|
-
\"Notification\",\n \"MessageId\" : \"fd8e5d6c-fa6a-
|
|
17
|
-
\"TopicArn\" : \"arn:aws:sns:us-east-1:6:
|
|
18
|
-
{\\\"event_code\\\":\\\"EE4220\\\",\\\"event_name\\\":\\\"
|
|
19
|
-
\\\"source\\\":\\\"EnrollmentLambda-
|
|
20
|
-
\\\"
|
|
21
|
-
\\\"
|
|
22
|
-
\\\"
|
|
23
|
-
\\\"
|
|
24
|
-
\\\"enrollment_stop_date\\\":\\\"9999-
|
|
25
|
-
\\\"enrollment_consent_date\\\":\\\"2025-
|
|
15
|
+
"data":{"Records":[{"messageId":"9999-99999-9999-9999","receiptHandle":"AQEB95j==","body":"{\n \"Type\" :
|
|
16
|
+
\"Notification\",\n \"MessageId\" : \"fd8e5d6c-fa6a-ttttt-ttttt-tttt\",\n \"SequenceNumber\" : \"1000000\",\n
|
|
17
|
+
\"TopicArn\" : \"arn:aws:sns:us-east-1:6:trace-topic.fifo\",\n \"Message\" : \"
|
|
18
|
+
{\\\"event_code\\\":\\\"EE4220\\\",\\\"event_name\\\":\\\"Reminder-40\\\",
|
|
19
|
+
\\\"source\\\":\\\"EnrollmentLambda-Whatever\\\",\\\"enroll_id\\\":\\\"xxxxx\\\",
|
|
20
|
+
\\\"obj_id\\\":\\\"xxxxxx\\\",\\\"index\\\":\\\"xxxxxxxxxx\\\",
|
|
21
|
+
\\\"book_id\\\":\\\"xxxxxxx\\\",\\\"product_code\\\":\\\"xx\\\",\\\"product_name\\\":\\\"XXXX\\\",
|
|
22
|
+
\\\"reason_code\\\":\\\"XX-999999\\\",\\\"start\\\":\\\"1700-12-20\\\",
|
|
23
|
+
\\\"eff_date\\\":\\\"1700-01-99\\\",\\\"end_date\\\":\\\"1600-xx-xx\\\",
|
|
24
|
+
\\\"enrollment_stop_date\\\":\\\"9999-xx-xx\\\",\\\"complete_date\\\":\\\"2025-xx-xx\\\",
|
|
25
|
+
\\\"enrollment_consent_date\\\":\\\"2025-xx-xx\\\",\\\"id\\\":\\\"6591cdaa-4672-b6d5-2ae5393700d2\\\",
|
|
26
26
|
\\\"timestamp\\\":1738260015994}\",\n \"Timestamp\" : \"2025-01-30T18:00:16.004Z\",\n \"UnsubscribeURL\" :
|
|
27
27
|
\"https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&
|
|
28
|
-
SubscriptionArn=arn:aws:sns:us-east-1::
|
|
28
|
+
SubscriptionArn=arn:aws:sns:us-east-1::trace-test5-enrollment.fifo:c62aa\",\n
|
|
29
29
|
\"MessageAttributes\" : {\n \"eventTypeCode\" : {\"Type\":\"String\",\"Value\":\"E20\"},\n \"groupId\" :
|
|
30
30
|
{\"Type\":\"String\",\"Value\":\"Registration Reminder-40\"}\n }\n}","attributes":{"ApproximateReceiveCount":"3",
|
|
31
|
-
"AWSTraceHeader":"Root=1-679bbe24-
|
|
32
|
-
"SentTimestamp":"
|
|
33
|
-
"MessageDeduplicationId":"
|
|
31
|
+
"AWSTraceHeader":"Root=1-679bbe24-xx;Parent=xx;Sampled=1;Lineage=2:xx:0",
|
|
32
|
+
"SentTimestamp":"1738","SequenceNumber":"xxxxx","MessageGroupId":"m1","SenderId":"eeeeeee",
|
|
33
|
+
"MessageDeduplicationId":"xxxxxxx"....
|
|
34
34
|
|
|
35
35
|
Due to the distributed nature of AWS microservice infrastructure, there are a lot of logs/events like this.
|
|
36
36
|
Logs can be single, double, triple, quadrupled, ect.. stringified at different levels within a json
|
|
@@ -50,14 +50,13 @@
|
|
|
50
50
|
1. Include this code in a script that can take a “wall of text" as input and convert it into
|
|
51
51
|
something that is readable and editable.
|
|
52
52
|
|
|
53
|
-
2. Called at the beginning of a lambda so that stringification is
|
|
53
|
+
2. Called at the beginning of a lambda so that stringification is ignored.
|
|
54
54
|
This is especially useful when creating custom input for testing purposes. The test input does not need
|
|
55
55
|
to be stringified or destringified before being sent into the app. This applies to unit/integration/manual
|
|
56
56
|
testing.
|
|
57
57
|
|
|
58
|
-
3. An
|
|
59
|
-
Especially if the
|
|
60
|
-
future events is unknown.
|
|
58
|
+
3. An application that has multiple sources of input that contain variable levels of strigification.
|
|
59
|
+
Especially if the service can be subscribed to and the level of stringification that will be received is unknown.
|
|
61
60
|
|
|
62
61
|
```javascript
|
|
63
62
|
// Example:
|
|
@@ -70,4 +69,4 @@ const destringifiedJSON = destringify(jsonStructure);
|
|
|
70
69
|
|
|
71
70
|
## Contacts
|
|
72
71
|
- Eric Schaumburg(Blaane15)
|
|
73
|
-
- Matthew Walden(mwalden2004)
|
|
72
|
+
- Matthew Walden(mwalden2004)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statefarmins/destringify-any-json",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A one size fits all solution to destringification. Handles any level of stringification in JSON objects.",
|
|
5
5
|
"main": "src/destringify.js",
|
|
6
6
|
"type": "module",
|