@walkeros/server-destination-aws 4.7.0-next-1790722899482 → 4.7.0
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/CHANGELOG.md +21 -3
- package/README.md +16 -3
- package/dist/dev.d.mts +76 -50
- package/dist/dev.d.ts +76 -50
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.d.mts +47 -35
- package/dist/examples/index.d.ts +47 -35
- package/dist/examples/index.js +181 -102
- package/dist/examples/index.mjs +179 -100
- package/dist/index.d.mts +161 -60
- package/dist/index.d.ts +161 -60
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/schemas.js +1 -1
- package/dist/schemas.js.map +1 -1
- package/dist/schemas.mjs +1 -1
- package/dist/schemas.mjs.map +1 -1
- package/dist/walkerOS.json +1331 -129
- package/package.json +4 -3
package/dist/examples/index.mjs
CHANGED
|
@@ -17,19 +17,27 @@ __export(env_exports, {
|
|
|
17
17
|
push: () => push,
|
|
18
18
|
simulation: () => simulation
|
|
19
19
|
});
|
|
20
|
+
function hasRecords(value) {
|
|
21
|
+
return typeof value === "object" && value !== null && "Records" in value && Array.isArray(value.Records);
|
|
22
|
+
}
|
|
20
23
|
var MockFirehoseClient = class {
|
|
21
24
|
config;
|
|
22
25
|
constructor(config) {
|
|
23
26
|
this.config = config;
|
|
24
27
|
}
|
|
25
|
-
async send(
|
|
28
|
+
async send(command) {
|
|
29
|
+
const input = "input" in command ? command.input : void 0;
|
|
30
|
+
const records = hasRecords(input) ? input.Records : [];
|
|
26
31
|
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
FailedPutCount: 0,
|
|
33
|
+
Encrypted: false,
|
|
34
|
+
RequestResponses: records.map((_, index) => ({
|
|
35
|
+
RecordId: `mock-record-id-${index}`
|
|
36
|
+
}))
|
|
31
37
|
};
|
|
32
38
|
}
|
|
39
|
+
destroy() {
|
|
40
|
+
}
|
|
33
41
|
};
|
|
34
42
|
var MockPutRecordBatchCommand = class {
|
|
35
43
|
input;
|
|
@@ -41,7 +49,6 @@ var MockPutRecordBatchCommand = class {
|
|
|
41
49
|
}
|
|
42
50
|
};
|
|
43
51
|
var push = {
|
|
44
|
-
// Environment for push operations
|
|
45
52
|
AWS: {
|
|
46
53
|
FirehoseClient: MockFirehoseClient,
|
|
47
54
|
PutRecordBatchCommand: MockPutRecordBatchCommand
|
|
@@ -53,110 +60,122 @@ var simulation = ["call:AWS.FirehoseClient.send"];
|
|
|
53
60
|
var step_exports = {};
|
|
54
61
|
__export(step_exports, {
|
|
55
62
|
firehoseRecord: () => firehoseRecord,
|
|
63
|
+
init: () => init,
|
|
64
|
+
mappedRecord: () => mappedRecord,
|
|
56
65
|
orderEvent: () => orderEvent,
|
|
57
66
|
userSignupEvent: () => userSignupEvent
|
|
58
67
|
});
|
|
59
68
|
import { getEvent } from "@walkeros/core";
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
|
|
70
|
+
// src/lib/payload.ts
|
|
71
|
+
import { isObject } from "@walkeros/core";
|
|
72
|
+
|
|
73
|
+
// src/firehose/lib/records.ts
|
|
74
|
+
function toRecordData(payload, newline = true) {
|
|
75
|
+
const json = JSON.stringify(payload);
|
|
76
|
+
if (typeof json !== "string")
|
|
77
|
+
throw new TypeError("The payload does not serialize to JSON.");
|
|
78
|
+
return Buffer.from(newline ? `${json}
|
|
79
|
+
` : json);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/firehose/examples/step.ts
|
|
83
|
+
var STREAM = "walkeros-events";
|
|
84
|
+
var init = {
|
|
85
|
+
title: "Initialization",
|
|
86
|
+
description: "Init builds one FirehoseClient for the stream region with the credentials from config.credentials and a 2500 ms per-attempt timeout. Nothing is sent until the first event.",
|
|
87
|
+
in: {
|
|
88
|
+
settings: { streamName: STREAM, region: "eu-central-1" },
|
|
89
|
+
credentials: {
|
|
90
|
+
accessKeyId: "$secret.AWS_ACCESS_KEY_ID",
|
|
91
|
+
secretAccessKey: "$secret.AWS_SECRET_ACCESS_KEY"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
70
94
|
out: [
|
|
71
95
|
[
|
|
72
|
-
"
|
|
96
|
+
"new FirehoseClient",
|
|
73
97
|
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
id: "ev-1700001000",
|
|
81
|
-
timestamp: 1700001e3,
|
|
82
|
-
data: { title: "Home", url: "https://example.com/" },
|
|
83
|
-
source: { type: "express", platform: "server" }
|
|
84
|
-
})
|
|
85
|
-
)
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
]
|
|
98
|
+
region: "eu-central-1",
|
|
99
|
+
credentials: {
|
|
100
|
+
accessKeyId: "$secret.AWS_ACCESS_KEY_ID",
|
|
101
|
+
secretAccessKey: "$secret.AWS_SECRET_ACCESS_KEY"
|
|
102
|
+
},
|
|
103
|
+
requestHandler: { requestTimeout: 2500, throwOnRequestTimeout: true }
|
|
89
104
|
}
|
|
90
105
|
]
|
|
91
106
|
]
|
|
92
107
|
};
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
var pageEvent = getEvent("page view", {
|
|
109
|
+
id: "ev-1700001000",
|
|
110
|
+
timestamp: 1700001e3,
|
|
111
|
+
data: { title: "Home", url: "https://example.com/" },
|
|
112
|
+
source: { type: "express", platform: "server" }
|
|
113
|
+
});
|
|
114
|
+
var orderEvt = getEvent("order complete", {
|
|
115
|
+
id: "ev-1700001001",
|
|
116
|
+
timestamp: 1700001001,
|
|
117
|
+
data: { id: "ORD-400", total: 99.99, currency: "EUR" },
|
|
118
|
+
source: { type: "express", platform: "server" }
|
|
119
|
+
});
|
|
120
|
+
var signupEvt = getEvent("user signup", {
|
|
121
|
+
id: "ev-1700001002",
|
|
122
|
+
timestamp: 1700001002,
|
|
123
|
+
data: { plan: "pro", source: "landing-page" },
|
|
124
|
+
user: { id: "usr-789", email: "new@example.com" },
|
|
125
|
+
source: { type: "express", platform: "server" }
|
|
126
|
+
});
|
|
127
|
+
function sent(payload) {
|
|
128
|
+
return [
|
|
104
129
|
[
|
|
105
130
|
"client.send",
|
|
106
131
|
{
|
|
107
|
-
DeliveryStreamName:
|
|
108
|
-
Records: [
|
|
109
|
-
{
|
|
110
|
-
Data: Buffer.from(
|
|
111
|
-
JSON.stringify(
|
|
112
|
-
getEvent("order complete", {
|
|
113
|
-
id: "ev-1700001001",
|
|
114
|
-
timestamp: 1700001001,
|
|
115
|
-
data: { id: "ORD-400", total: 99.99, currency: "EUR" },
|
|
116
|
-
source: { type: "express", platform: "server" }
|
|
117
|
-
})
|
|
118
|
-
)
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
]
|
|
132
|
+
DeliveryStreamName: STREAM,
|
|
133
|
+
Records: [{ Data: toRecordData(payload) }]
|
|
122
134
|
}
|
|
123
135
|
]
|
|
124
|
-
]
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
var firehoseRecord = {
|
|
139
|
+
title: "Page view record",
|
|
140
|
+
description: "A page view is sent to Firehose as one record: the full event as JSON followed by a newline.",
|
|
141
|
+
in: pageEvent,
|
|
142
|
+
mapping: void 0,
|
|
143
|
+
out: sent(pageEvent)
|
|
144
|
+
};
|
|
145
|
+
var orderEvent = {
|
|
146
|
+
title: "Order record",
|
|
147
|
+
description: "An order complete event is serialized and delivered to Firehose as one newline-terminated record.",
|
|
148
|
+
in: orderEvt,
|
|
149
|
+
mapping: void 0,
|
|
150
|
+
out: sent(orderEvt)
|
|
125
151
|
};
|
|
126
152
|
var userSignupEvent = {
|
|
127
153
|
title: "User signup record",
|
|
128
154
|
description: "A user signup event including user fields is streamed to Firehose as a JSON record.",
|
|
129
|
-
in:
|
|
130
|
-
id: "ev-1700001002",
|
|
131
|
-
timestamp: 1700001002,
|
|
132
|
-
data: { plan: "pro", source: "landing-page" },
|
|
133
|
-
user: { id: "usr-789", email: "new@example.com" },
|
|
134
|
-
source: { type: "express", platform: "server" }
|
|
135
|
-
}),
|
|
155
|
+
in: signupEvt,
|
|
136
156
|
mapping: void 0,
|
|
137
|
-
out:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
user: { id: "usr-789", email: "new@example.com" },
|
|
151
|
-
source: { type: "express", platform: "server" }
|
|
152
|
-
})
|
|
153
|
-
)
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
+
out: sent(signupEvt)
|
|
158
|
+
};
|
|
159
|
+
var mappedRecord = {
|
|
160
|
+
title: "Mapped record",
|
|
161
|
+
description: "A mapping that produces an object sends that object as the record instead of the full event. Keep the event id in it for deduplication.",
|
|
162
|
+
in: orderEvt,
|
|
163
|
+
mapping: {
|
|
164
|
+
data: {
|
|
165
|
+
map: {
|
|
166
|
+
id: "id",
|
|
167
|
+
name: "name",
|
|
168
|
+
order_id: "data.id",
|
|
169
|
+
total: "data.total"
|
|
157
170
|
}
|
|
158
|
-
|
|
159
|
-
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
out: sent({
|
|
174
|
+
id: "ev-1700001001",
|
|
175
|
+
name: "order complete",
|
|
176
|
+
order_id: "ORD-400",
|
|
177
|
+
total: 99.99
|
|
178
|
+
})
|
|
160
179
|
};
|
|
161
180
|
|
|
162
181
|
// src/sns/examples/index.ts
|
|
@@ -216,6 +235,8 @@ var MockSNSClient = class {
|
|
|
216
235
|
return { MessageId: "mock-message-id" };
|
|
217
236
|
return {};
|
|
218
237
|
}
|
|
238
|
+
destroy() {
|
|
239
|
+
}
|
|
219
240
|
};
|
|
220
241
|
var MockSTSClient = class {
|
|
221
242
|
constructor(config) {
|
|
@@ -223,7 +244,12 @@ var MockSTSClient = class {
|
|
|
223
244
|
}
|
|
224
245
|
config;
|
|
225
246
|
async send() {
|
|
226
|
-
return {
|
|
247
|
+
return {
|
|
248
|
+
Account: "123456789012",
|
|
249
|
+
Arn: "arn:aws:iam::123456789012:user/walkeros"
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
destroy() {
|
|
227
253
|
}
|
|
228
254
|
};
|
|
229
255
|
var push2 = {
|
|
@@ -243,17 +269,45 @@ var simulation2 = ["call:AWS.SNSClient.send"];
|
|
|
243
269
|
var step_exports2 = {};
|
|
244
270
|
__export(step_exports2, {
|
|
245
271
|
attributedPublish: () => attributedPublish,
|
|
272
|
+
init: () => init2,
|
|
273
|
+
mappedMessage: () => mappedMessage,
|
|
246
274
|
orderEvent: () => orderEvent2,
|
|
247
275
|
pageView: () => pageView
|
|
248
276
|
});
|
|
249
277
|
import { getEvent as getEvent2 } from "@walkeros/core";
|
|
250
|
-
var
|
|
278
|
+
var TOPIC_ARN2 = "arn:aws:sns:eu-central-1:123456789012:walkeros-events";
|
|
279
|
+
var FIFO_ARN = "arn:aws:sns:eu-central-1:123456789012:walkeros-events.fifo";
|
|
280
|
+
var init2 = {
|
|
281
|
+
title: "Initialization",
|
|
282
|
+
description: "Init builds one SNSClient in the region of the topic ARN with the credentials from config.credentials and a 2500 ms per-attempt timeout. No topic is created and nothing is sent until the first event.",
|
|
283
|
+
in: {
|
|
284
|
+
settings: { topicArn: TOPIC_ARN2 },
|
|
285
|
+
credentials: {
|
|
286
|
+
accessKeyId: "$secret.AWS_ACCESS_KEY_ID",
|
|
287
|
+
secretAccessKey: "$secret.AWS_SECRET_ACCESS_KEY"
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
out: [
|
|
291
|
+
[
|
|
292
|
+
"new SNSClient",
|
|
293
|
+
{
|
|
294
|
+
region: "eu-central-1",
|
|
295
|
+
credentials: {
|
|
296
|
+
accessKeyId: "$secret.AWS_ACCESS_KEY_ID",
|
|
297
|
+
secretAccessKey: "$secret.AWS_SECRET_ACCESS_KEY"
|
|
298
|
+
},
|
|
299
|
+
requestHandler: { requestTimeout: 2500, throwOnRequestTimeout: true }
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
]
|
|
303
|
+
};
|
|
304
|
+
var pageEvent2 = getEvent2("page view", {
|
|
251
305
|
id: "ev-1700001000",
|
|
252
306
|
timestamp: 1700001e3,
|
|
253
307
|
data: { title: "Home", url: "https://example.com/" },
|
|
254
308
|
source: { type: "express", platform: "server" }
|
|
255
309
|
});
|
|
256
|
-
var
|
|
310
|
+
var orderEvt2 = getEvent2("order complete", {
|
|
257
311
|
id: "ev-1700001001",
|
|
258
312
|
timestamp: 1700001001,
|
|
259
313
|
data: { id: "ORD-400", total: 99.99, currency: "EUR" },
|
|
@@ -269,30 +323,31 @@ var productViewEvt = getEvent2("product view", {
|
|
|
269
323
|
var pageView = {
|
|
270
324
|
title: "Page view publish",
|
|
271
325
|
description: "A page view event is JSON-stringified and published as the Message of an SNS Publish call.",
|
|
272
|
-
in:
|
|
326
|
+
in: pageEvent2,
|
|
273
327
|
mapping: void 0,
|
|
274
328
|
out: [
|
|
275
329
|
[
|
|
276
330
|
"client.send",
|
|
277
331
|
{
|
|
278
|
-
TopicArn:
|
|
279
|
-
Message: JSON.stringify(
|
|
332
|
+
TopicArn: TOPIC_ARN2,
|
|
333
|
+
Message: JSON.stringify(pageEvent2)
|
|
280
334
|
}
|
|
281
335
|
]
|
|
282
336
|
]
|
|
283
337
|
};
|
|
284
338
|
var orderEvent2 = {
|
|
285
339
|
title: "Order publish with FIFO group (path-resolved)",
|
|
286
|
-
description: 'An order complete event is published
|
|
287
|
-
in:
|
|
340
|
+
description: 'An order complete event is published to a FIFO topic with a messageGroupId resolved from the event via the mapping path "user.id". The deduplication id defaults to the event id.',
|
|
341
|
+
in: orderEvt2,
|
|
288
342
|
mapping: { settings: { messageGroupId: "user.id" } },
|
|
289
343
|
out: [
|
|
290
344
|
[
|
|
291
345
|
"client.send",
|
|
292
346
|
{
|
|
293
|
-
TopicArn:
|
|
294
|
-
Message: JSON.stringify(
|
|
295
|
-
MessageGroupId: "usr-789"
|
|
347
|
+
TopicArn: FIFO_ARN,
|
|
348
|
+
Message: JSON.stringify(orderEvt2),
|
|
349
|
+
MessageGroupId: "usr-789",
|
|
350
|
+
MessageDeduplicationId: "ev-1700001001"
|
|
296
351
|
}
|
|
297
352
|
]
|
|
298
353
|
]
|
|
@@ -313,7 +368,7 @@ var attributedPublish = {
|
|
|
313
368
|
[
|
|
314
369
|
"client.send",
|
|
315
370
|
{
|
|
316
|
-
TopicArn:
|
|
371
|
+
TopicArn: TOPIC_ARN2,
|
|
317
372
|
Message: JSON.stringify(productViewEvt),
|
|
318
373
|
MessageAttributes: {
|
|
319
374
|
schema_version: { DataType: "String", StringValue: "v4" },
|
|
@@ -323,6 +378,30 @@ var attributedPublish = {
|
|
|
323
378
|
]
|
|
324
379
|
]
|
|
325
380
|
};
|
|
381
|
+
var mappedMessage = {
|
|
382
|
+
title: "Mapped message",
|
|
383
|
+
description: "A mapping that produces an object publishes that object as the Message instead of the full event. Keep the event id in it for deduplication.",
|
|
384
|
+
in: orderEvt2,
|
|
385
|
+
mapping: {
|
|
386
|
+
data: {
|
|
387
|
+
map: { id: "id", name: "name", order_id: "data.id", total: "data.total" }
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
out: [
|
|
391
|
+
[
|
|
392
|
+
"client.send",
|
|
393
|
+
{
|
|
394
|
+
TopicArn: TOPIC_ARN2,
|
|
395
|
+
Message: JSON.stringify({
|
|
396
|
+
id: "ev-1700001001",
|
|
397
|
+
name: "order complete",
|
|
398
|
+
order_id: "ORD-400",
|
|
399
|
+
total: 99.99
|
|
400
|
+
})
|
|
401
|
+
}
|
|
402
|
+
]
|
|
403
|
+
]
|
|
404
|
+
};
|
|
326
405
|
export {
|
|
327
406
|
env_exports as env,
|
|
328
407
|
examples_exports as firehose,
|