@walkeros/server-destination-aws 3.4.2 → 4.0.0-next-1777463920154
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/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.js +38 -26
- package/dist/examples/index.mjs +38 -26
- 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 +1031 -1741
- package/package.json +2 -2
package/dist/examples/index.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(env_exports, {
|
|
|
40
40
|
simulation: () => simulation
|
|
41
41
|
});
|
|
42
42
|
var MockFirehoseClient = class {
|
|
43
|
+
config;
|
|
43
44
|
constructor(config) {
|
|
44
45
|
this.config = config;
|
|
45
46
|
}
|
|
@@ -53,6 +54,7 @@ var MockFirehoseClient = class {
|
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
var MockPutRecordBatchCommand = class {
|
|
57
|
+
input;
|
|
56
58
|
constructor(input) {
|
|
57
59
|
this.input = input;
|
|
58
60
|
}
|
|
@@ -76,42 +78,47 @@ __export(step_exports, {
|
|
|
76
78
|
|
|
77
79
|
// ../../../core/dist/index.mjs
|
|
78
80
|
var e = Object.defineProperty;
|
|
79
|
-
var
|
|
81
|
+
var a = {};
|
|
80
82
|
((t, n) => {
|
|
81
83
|
for (var o in n) e(t, o, { get: n[o], enumerable: true });
|
|
82
|
-
})(
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
function
|
|
86
|
-
n = { ...
|
|
84
|
+
})(a, { Level: () => c });
|
|
85
|
+
var c = ((e2) => (e2[e2.ERROR = 0] = "ERROR", e2[e2.WARN = 1] = "WARN", e2[e2.INFO = 2] = "INFO", e2[e2.DEBUG = 3] = "DEBUG", e2))(c || {});
|
|
86
|
+
var X = { merge: true, shallow: true, extend: true };
|
|
87
|
+
function G(e2, t = {}, n = {}) {
|
|
88
|
+
n = { ...X, ...n };
|
|
87
89
|
const o = Object.entries(t).reduce((t2, [o2, r]) => {
|
|
88
90
|
const i = e2[o2];
|
|
89
91
|
return n.merge && Array.isArray(i) && Array.isArray(r) ? t2[o2] = r.reduce((e3, t3) => e3.includes(t3) ? e3 : [...e3, t3], [...i]) : (n.extend || o2 in e2) && (t2[o2] = r), t2;
|
|
90
92
|
}, {});
|
|
91
93
|
return n.shallow ? { ...e2, ...o } : (Object.assign(e2, o), e2);
|
|
92
94
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
function he() {
|
|
96
|
+
let e2 = "";
|
|
97
|
+
for (let t = 0; t < 16; t++) e2 += (16 * Math.random() | 0).toString(16);
|
|
98
|
+
return e2;
|
|
99
|
+
}
|
|
100
|
+
function ve(e2 = {}) {
|
|
101
|
+
const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = G({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" } }], consent: { functional: true }, id: e2.id || he(), trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, source: { type: "collector", schema: "4" } }, e2, { merge: false });
|
|
96
102
|
if (e2.name) {
|
|
97
|
-
const [t2,
|
|
98
|
-
t2 &&
|
|
103
|
+
const [t2, o] = e2.name.split(" ") ?? [];
|
|
104
|
+
t2 && o && (n.entity = t2, n.action = o);
|
|
99
105
|
}
|
|
100
|
-
return
|
|
106
|
+
return n;
|
|
101
107
|
}
|
|
102
|
-
function
|
|
108
|
+
function we(e2 = "entity action", t = {}) {
|
|
103
109
|
const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), o = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, r = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
|
|
104
|
-
return
|
|
110
|
+
return ve({ ...{ "cart view": { data: { currency: "EUR", value: 2 * o.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", data: { ...o.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: o.data.price + r.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...o, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "product", ...r, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...r, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.walkeros.io/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...o, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...o, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...o.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e2], ...t, name: e2 });
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
// src/firehose/examples/step.ts
|
|
108
114
|
var firehoseRecord = {
|
|
109
115
|
title: "Page view record",
|
|
110
116
|
description: "A page view is sent to Kinesis Firehose as a single record with the full event JSON-stringified into the Data buffer.",
|
|
111
|
-
in:
|
|
117
|
+
in: we("page view", {
|
|
118
|
+
id: "ev-1700001000",
|
|
112
119
|
timestamp: 1700001e3,
|
|
113
120
|
data: { title: "Home", url: "https://example.com/" },
|
|
114
|
-
source: { type: "
|
|
121
|
+
source: { type: "express", platform: "server" }
|
|
115
122
|
}),
|
|
116
123
|
mapping: void 0,
|
|
117
124
|
out: [
|
|
@@ -123,10 +130,11 @@ var firehoseRecord = {
|
|
|
123
130
|
{
|
|
124
131
|
Data: Buffer.from(
|
|
125
132
|
JSON.stringify(
|
|
126
|
-
|
|
133
|
+
we("page view", {
|
|
134
|
+
id: "ev-1700001000",
|
|
127
135
|
timestamp: 1700001e3,
|
|
128
136
|
data: { title: "Home", url: "https://example.com/" },
|
|
129
|
-
source: { type: "
|
|
137
|
+
source: { type: "express", platform: "server" }
|
|
130
138
|
})
|
|
131
139
|
)
|
|
132
140
|
)
|
|
@@ -139,10 +147,11 @@ var firehoseRecord = {
|
|
|
139
147
|
var orderEvent = {
|
|
140
148
|
title: "Order record",
|
|
141
149
|
description: "An order complete event is serialized and delivered to Firehose as a batch record for downstream storage.",
|
|
142
|
-
in:
|
|
150
|
+
in: we("order complete", {
|
|
151
|
+
id: "ev-1700001001",
|
|
143
152
|
timestamp: 1700001001,
|
|
144
153
|
data: { id: "ORD-400", total: 99.99, currency: "EUR" },
|
|
145
|
-
source: { type: "
|
|
154
|
+
source: { type: "express", platform: "server" }
|
|
146
155
|
}),
|
|
147
156
|
mapping: void 0,
|
|
148
157
|
out: [
|
|
@@ -154,10 +163,11 @@ var orderEvent = {
|
|
|
154
163
|
{
|
|
155
164
|
Data: Buffer.from(
|
|
156
165
|
JSON.stringify(
|
|
157
|
-
|
|
166
|
+
we("order complete", {
|
|
167
|
+
id: "ev-1700001001",
|
|
158
168
|
timestamp: 1700001001,
|
|
159
169
|
data: { id: "ORD-400", total: 99.99, currency: "EUR" },
|
|
160
|
-
source: { type: "
|
|
170
|
+
source: { type: "express", platform: "server" }
|
|
161
171
|
})
|
|
162
172
|
)
|
|
163
173
|
)
|
|
@@ -170,11 +180,12 @@ var orderEvent = {
|
|
|
170
180
|
var userSignupEvent = {
|
|
171
181
|
title: "User signup record",
|
|
172
182
|
description: "A user signup event including user fields is streamed to Firehose as a JSON record.",
|
|
173
|
-
in:
|
|
183
|
+
in: we("user signup", {
|
|
184
|
+
id: "ev-1700001002",
|
|
174
185
|
timestamp: 1700001002,
|
|
175
186
|
data: { plan: "pro", source: "landing-page" },
|
|
176
187
|
user: { id: "usr-789", email: "new@example.com" },
|
|
177
|
-
source: { type: "
|
|
188
|
+
source: { type: "express", platform: "server" }
|
|
178
189
|
}),
|
|
179
190
|
mapping: void 0,
|
|
180
191
|
out: [
|
|
@@ -186,11 +197,12 @@ var userSignupEvent = {
|
|
|
186
197
|
{
|
|
187
198
|
Data: Buffer.from(
|
|
188
199
|
JSON.stringify(
|
|
189
|
-
|
|
200
|
+
we("user signup", {
|
|
201
|
+
id: "ev-1700001002",
|
|
190
202
|
timestamp: 1700001002,
|
|
191
203
|
data: { plan: "pro", source: "landing-page" },
|
|
192
204
|
user: { id: "usr-789", email: "new@example.com" },
|
|
193
|
-
source: { type: "
|
|
205
|
+
source: { type: "express", platform: "server" }
|
|
194
206
|
})
|
|
195
207
|
)
|
|
196
208
|
)
|
package/dist/examples/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ __export(env_exports, {
|
|
|
18
18
|
simulation: () => simulation
|
|
19
19
|
});
|
|
20
20
|
var MockFirehoseClient = class {
|
|
21
|
+
config;
|
|
21
22
|
constructor(config) {
|
|
22
23
|
this.config = config;
|
|
23
24
|
}
|
|
@@ -31,6 +32,7 @@ var MockFirehoseClient = class {
|
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
34
|
var MockPutRecordBatchCommand = class {
|
|
35
|
+
input;
|
|
34
36
|
constructor(input) {
|
|
35
37
|
this.input = input;
|
|
36
38
|
}
|
|
@@ -54,42 +56,47 @@ __export(step_exports, {
|
|
|
54
56
|
|
|
55
57
|
// ../../../core/dist/index.mjs
|
|
56
58
|
var e = Object.defineProperty;
|
|
57
|
-
var
|
|
59
|
+
var a = {};
|
|
58
60
|
((t, n) => {
|
|
59
61
|
for (var o in n) e(t, o, { get: n[o], enumerable: true });
|
|
60
|
-
})(
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
function
|
|
64
|
-
n = { ...
|
|
62
|
+
})(a, { Level: () => c });
|
|
63
|
+
var c = ((e2) => (e2[e2.ERROR = 0] = "ERROR", e2[e2.WARN = 1] = "WARN", e2[e2.INFO = 2] = "INFO", e2[e2.DEBUG = 3] = "DEBUG", e2))(c || {});
|
|
64
|
+
var X = { merge: true, shallow: true, extend: true };
|
|
65
|
+
function G(e2, t = {}, n = {}) {
|
|
66
|
+
n = { ...X, ...n };
|
|
65
67
|
const o = Object.entries(t).reduce((t2, [o2, r]) => {
|
|
66
68
|
const i = e2[o2];
|
|
67
69
|
return n.merge && Array.isArray(i) && Array.isArray(r) ? t2[o2] = r.reduce((e3, t3) => e3.includes(t3) ? e3 : [...e3, t3], [...i]) : (n.extend || o2 in e2) && (t2[o2] = r), t2;
|
|
68
70
|
}, {});
|
|
69
71
|
return n.shallow ? { ...e2, ...o } : (Object.assign(e2, o), e2);
|
|
70
72
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
function he() {
|
|
74
|
+
let e2 = "";
|
|
75
|
+
for (let t = 0; t < 16; t++) e2 += (16 * Math.random() | 0).toString(16);
|
|
76
|
+
return e2;
|
|
77
|
+
}
|
|
78
|
+
function ve(e2 = {}) {
|
|
79
|
+
const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = G({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" } }], consent: { functional: true }, id: e2.id || he(), trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, source: { type: "collector", schema: "4" } }, e2, { merge: false });
|
|
74
80
|
if (e2.name) {
|
|
75
|
-
const [t2,
|
|
76
|
-
t2 &&
|
|
81
|
+
const [t2, o] = e2.name.split(" ") ?? [];
|
|
82
|
+
t2 && o && (n.entity = t2, n.action = o);
|
|
77
83
|
}
|
|
78
|
-
return
|
|
84
|
+
return n;
|
|
79
85
|
}
|
|
80
|
-
function
|
|
86
|
+
function we(e2 = "entity action", t = {}) {
|
|
81
87
|
const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), o = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, r = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
|
|
82
|
-
return
|
|
88
|
+
return ve({ ...{ "cart view": { data: { currency: "EUR", value: 2 * o.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", data: { ...o.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: o.data.price + r.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...o, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "product", ...r, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...r, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.walkeros.io/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...o, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...o, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...o.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e2], ...t, name: e2 });
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
// src/firehose/examples/step.ts
|
|
86
92
|
var firehoseRecord = {
|
|
87
93
|
title: "Page view record",
|
|
88
94
|
description: "A page view is sent to Kinesis Firehose as a single record with the full event JSON-stringified into the Data buffer.",
|
|
89
|
-
in:
|
|
95
|
+
in: we("page view", {
|
|
96
|
+
id: "ev-1700001000",
|
|
90
97
|
timestamp: 1700001e3,
|
|
91
98
|
data: { title: "Home", url: "https://example.com/" },
|
|
92
|
-
source: { type: "
|
|
99
|
+
source: { type: "express", platform: "server" }
|
|
93
100
|
}),
|
|
94
101
|
mapping: void 0,
|
|
95
102
|
out: [
|
|
@@ -101,10 +108,11 @@ var firehoseRecord = {
|
|
|
101
108
|
{
|
|
102
109
|
Data: Buffer.from(
|
|
103
110
|
JSON.stringify(
|
|
104
|
-
|
|
111
|
+
we("page view", {
|
|
112
|
+
id: "ev-1700001000",
|
|
105
113
|
timestamp: 1700001e3,
|
|
106
114
|
data: { title: "Home", url: "https://example.com/" },
|
|
107
|
-
source: { type: "
|
|
115
|
+
source: { type: "express", platform: "server" }
|
|
108
116
|
})
|
|
109
117
|
)
|
|
110
118
|
)
|
|
@@ -117,10 +125,11 @@ var firehoseRecord = {
|
|
|
117
125
|
var orderEvent = {
|
|
118
126
|
title: "Order record",
|
|
119
127
|
description: "An order complete event is serialized and delivered to Firehose as a batch record for downstream storage.",
|
|
120
|
-
in:
|
|
128
|
+
in: we("order complete", {
|
|
129
|
+
id: "ev-1700001001",
|
|
121
130
|
timestamp: 1700001001,
|
|
122
131
|
data: { id: "ORD-400", total: 99.99, currency: "EUR" },
|
|
123
|
-
source: { type: "
|
|
132
|
+
source: { type: "express", platform: "server" }
|
|
124
133
|
}),
|
|
125
134
|
mapping: void 0,
|
|
126
135
|
out: [
|
|
@@ -132,10 +141,11 @@ var orderEvent = {
|
|
|
132
141
|
{
|
|
133
142
|
Data: Buffer.from(
|
|
134
143
|
JSON.stringify(
|
|
135
|
-
|
|
144
|
+
we("order complete", {
|
|
145
|
+
id: "ev-1700001001",
|
|
136
146
|
timestamp: 1700001001,
|
|
137
147
|
data: { id: "ORD-400", total: 99.99, currency: "EUR" },
|
|
138
|
-
source: { type: "
|
|
148
|
+
source: { type: "express", platform: "server" }
|
|
139
149
|
})
|
|
140
150
|
)
|
|
141
151
|
)
|
|
@@ -148,11 +158,12 @@ var orderEvent = {
|
|
|
148
158
|
var userSignupEvent = {
|
|
149
159
|
title: "User signup record",
|
|
150
160
|
description: "A user signup event including user fields is streamed to Firehose as a JSON record.",
|
|
151
|
-
in:
|
|
161
|
+
in: we("user signup", {
|
|
162
|
+
id: "ev-1700001002",
|
|
152
163
|
timestamp: 1700001002,
|
|
153
164
|
data: { plan: "pro", source: "landing-page" },
|
|
154
165
|
user: { id: "usr-789", email: "new@example.com" },
|
|
155
|
-
source: { type: "
|
|
166
|
+
source: { type: "express", platform: "server" }
|
|
156
167
|
}),
|
|
157
168
|
mapping: void 0,
|
|
158
169
|
out: [
|
|
@@ -164,11 +175,12 @@ var userSignupEvent = {
|
|
|
164
175
|
{
|
|
165
176
|
Data: Buffer.from(
|
|
166
177
|
JSON.stringify(
|
|
167
|
-
|
|
178
|
+
we("user signup", {
|
|
179
|
+
id: "ev-1700001002",
|
|
168
180
|
timestamp: 1700001002,
|
|
169
181
|
data: { plan: "pro", source: "landing-page" },
|
|
170
182
|
user: { id: "usr-789", email: "new@example.com" },
|
|
171
|
-
source: { type: "
|
|
183
|
+
source: { type: "express", platform: "server" }
|
|
172
184
|
})
|
|
173
185
|
)
|
|
174
186
|
)
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.create;var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=(Object.getPrototypeOf,Object.prototype.hasOwnProperty),__copyProps=(to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationFirehose:()=>types_exports,default:()=>destinationFirehose,destinationFirehose:()=>destinationFirehose}),module.exports=(mod=index_exports,__copyProps(__defProp({},"__esModule",{value:!0}),mod));var e=Object.defineProperty;((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{Level:()=>
|
|
1
|
+
"use strict";Object.create;var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=(Object.getPrototypeOf,Object.prototype.hasOwnProperty),__copyProps=(to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationFirehose:()=>types_exports,default:()=>destinationFirehose,destinationFirehose:()=>destinationFirehose}),module.exports=(mod=index_exports,__copyProps(__defProp({},"__esModule",{value:!0}),mod));var e=Object.defineProperty;((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{Level:()=>c});var e2,c=((e2=c||{})[e2.ERROR=0]="ERROR",e2[e2.WARN=1]="WARN",e2[e2.INFO=2]="INFO",e2[e2.DEBUG=3]="DEBUG",e2);function isAWSEnvironment(env){return Boolean(env&&"object"==typeof env&&"AWS"in env&&env.AWS?.FirehoseClient)}function getConfigFirehose(firehoseConfig,env){const{streamName:streamName,region:region="eu-central-1",config:config={}}=firehoseConfig;streamName||function(e2){throw new Error(String(e2))}("Firehose: Config custom streamName missing"),config.region||(config.region=region);let client=firehoseConfig.client;return!client&&isAWSEnvironment(env)&&(client=new env.AWS.FirehoseClient(config)),{streamName:streamName,client:client,region:region}}var push=async function(event,context){const{firehose:firehose}=context.config.settings||{};firehose&&async function(pushEvents,config,context){const{client:client,streamName:streamName}=config,{env:env,logger:logger}=context;if(!client)return{queue:pushEvents};const records=pushEvents.map(({event:event})=>({Data:Buffer.from(JSON.stringify(event))}));if(logger.debug("Calling AWS Firehose API",{stream:streamName,recordCount:records.length}),isAWSEnvironment(env))await client.send(new env.AWS.PutRecordBatchCommand({DeliveryStreamName:streamName,Records:records}));else{const{PutRecordBatchCommand:PutRecordBatchCommand}=await import("@aws-sdk/client-firehose");await client.send(new PutRecordBatchCommand({DeliveryStreamName:streamName,Records:records}))}logger?.debug("AWS Firehose API response",{ok:!0})}([{event:event}],firehose,context)},types_exports={},destinationFirehose={type:"aws-firehose",config:{},async init({config:partialConfig,env:env,logger:logger}){const config=function(partialConfig={},env){const settings=partialConfig.settings||{};return settings.firehose&&(settings.firehose=getConfigFirehose(settings.firehose,env)),{settings:settings}}(partialConfig,env);return function(e2,t){return typeof e2==typeof t}(config.settings,{})||logger.throw("Config settings invalid"),config},push:async(event,context)=>await push(event,context)};//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/firehose/lib/firehose.ts","../src/firehose/config.ts","../src/firehose/push.ts","../src/firehose/types/index.ts","../src/firehose/index.ts"],"sourcesContent":["// AWS Firehose\nexport { destinationFirehose } from './firehose';\nexport * as DestinationFirehose from './firehose/types';\n\nexport { destinationFirehose as default } from './firehose';\n","import type { Destination, Logger } from '@walkeros/core';\nimport type { FirehoseConfig, Env } from '../types';\nimport { throwError } from '@walkeros/core';\n\n// Type guard to check if environment has AWS SDK\nfunction isAWSEnvironment(env: unknown): env is Env {\n return Boolean(\n env &&\n typeof env === 'object' &&\n 'AWS' in env &&\n (env as Env).AWS?.FirehoseClient,\n );\n}\n\nexport function getConfigFirehose(\n firehoseConfig: Partial<FirehoseConfig>,\n env?: unknown,\n): FirehoseConfig {\n const { streamName, region = 'eu-central-1', config = {} } = firehoseConfig;\n\n if (!streamName) throwError('Firehose: Config custom streamName missing');\n\n if (!config.region) config.region = region;\n\n // Use environment-injected SDK or fall back to provided client\n let client = firehoseConfig.client;\n if (!client && isAWSEnvironment(env)) {\n client = new env.AWS.FirehoseClient(config);\n }\n\n return {\n streamName,\n client,\n region,\n };\n}\n\nexport async function pushFirehose(\n pushEvents: Destination.PushEvents,\n config: FirehoseConfig,\n context: Destination.PushContext,\n) {\n const { client, streamName } = config;\n const { env, logger } = context;\n\n if (!client) return { queue: pushEvents };\n\n // Up to 500 records per batch\n const records = pushEvents.map(({ event }) => ({\n Data: Buffer.from(JSON.stringify(event)),\n }));\n\n logger.debug('Calling AWS Firehose API', {\n stream: streamName,\n recordCount: records.length,\n });\n\n // Use environment-injected SDK command or fall back to direct import\n if (isAWSEnvironment(env)) {\n await client.send(\n new env.AWS.PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n } else {\n // Fall back to direct import for backward compatibility\n const { PutRecordBatchCommand } = await import('@aws-sdk/client-firehose');\n await client.send(\n new PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n }\n\n logger?.debug('AWS Firehose API response', { ok: true });\n}\n","import type { Config, Settings, PartialConfig, Env } from './types';\nimport { getConfigFirehose } from './lib/firehose';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n env?: unknown,\n): Config {\n const settings = partialConfig.settings || ({} as Settings);\n\n if (settings.firehose)\n settings.firehose = getConfigFirehose(settings.firehose, env);\n\n return { settings };\n}\n","import type { PushFn } from './types';\nimport { pushFirehose } from './lib/firehose';\n\nexport const push: PushFn = async function (event, context) {\n const { firehose } = context.config.settings || {};\n\n if (firehose) pushFirehose([{ event }], firehose, context);\n\n return;\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type {\n FirehoseClient,\n FirehoseClientConfig,\n PutRecordBatchCommand,\n} from '@aws-sdk/client-firehose';\n\nexport interface Settings {\n firehose?: FirehoseConfig;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n AWS: {\n FirehoseClient: typeof FirehoseClient;\n PutRecordBatchCommand: typeof PutRecordBatchCommand;\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface FirehoseConfig {\n streamName: string;\n client?: FirehoseClient;\n region?: string;\n config?: FirehoseClientConfig;\n}\n","import type { Settings, Destination } from './types';\nimport { isSameType } from '@walkeros/core';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationFirehose from './types';\n\nexport const destinationFirehose: Destination = {\n type: 'aws-firehose',\n\n config: {},\n\n async init({ config: partialConfig, env, logger }) {\n const config = getConfig(partialConfig, env);\n\n if (!isSameType(config.settings, {} as Settings))\n logger.throw('Config settings invalid');\n\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationFirehose;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A;;;;;;;;;;;;;;;;ACKA,SAAS,iBAAiB,KAA0B;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/firehose/lib/firehose.ts","../src/firehose/config.ts","../src/firehose/push.ts","../src/firehose/types/index.ts","../src/firehose/index.ts"],"sourcesContent":["// AWS Firehose\nexport { destinationFirehose } from './firehose';\nexport * as DestinationFirehose from './firehose/types';\n\nexport { destinationFirehose as default } from './firehose';\n","import type { Destination, Logger } from '@walkeros/core';\nimport type { FirehoseConfig, Env } from '../types';\nimport { throwError } from '@walkeros/core';\n\n// Type guard to check if environment has AWS SDK\nfunction isAWSEnvironment(env: unknown): env is Env {\n return Boolean(\n env &&\n typeof env === 'object' &&\n 'AWS' in env &&\n (env as Env).AWS?.FirehoseClient,\n );\n}\n\nexport function getConfigFirehose(\n firehoseConfig: Partial<FirehoseConfig>,\n env?: unknown,\n): FirehoseConfig {\n const { streamName, region = 'eu-central-1', config = {} } = firehoseConfig;\n\n if (!streamName) throwError('Firehose: Config custom streamName missing');\n\n if (!config.region) config.region = region;\n\n // Use environment-injected SDK or fall back to provided client\n let client = firehoseConfig.client;\n if (!client && isAWSEnvironment(env)) {\n client = new env.AWS.FirehoseClient(config);\n }\n\n return {\n streamName,\n client,\n region,\n };\n}\n\nexport async function pushFirehose(\n pushEvents: Destination.PushEvents,\n config: FirehoseConfig,\n context: Destination.PushContext,\n) {\n const { client, streamName } = config;\n const { env, logger } = context;\n\n if (!client) return { queue: pushEvents };\n\n // Up to 500 records per batch\n const records = pushEvents.map(({ event }) => ({\n Data: Buffer.from(JSON.stringify(event)),\n }));\n\n logger.debug('Calling AWS Firehose API', {\n stream: streamName,\n recordCount: records.length,\n });\n\n // Use environment-injected SDK command or fall back to direct import\n if (isAWSEnvironment(env)) {\n await client.send(\n new env.AWS.PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n } else {\n // Fall back to direct import for backward compatibility\n const { PutRecordBatchCommand } = await import('@aws-sdk/client-firehose');\n await client.send(\n new PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n }\n\n logger?.debug('AWS Firehose API response', { ok: true });\n}\n","import type { Config, Settings, PartialConfig, Env } from './types';\nimport { getConfigFirehose } from './lib/firehose';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n env?: unknown,\n): Config {\n const settings = partialConfig.settings || ({} as Settings);\n\n if (settings.firehose)\n settings.firehose = getConfigFirehose(settings.firehose, env);\n\n return { settings };\n}\n","import type { PushFn } from './types';\nimport { pushFirehose } from './lib/firehose';\n\nexport const push: PushFn = async function (event, context) {\n const { firehose } = context.config.settings || {};\n\n if (firehose) pushFirehose([{ event }], firehose, context);\n\n return;\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type {\n FirehoseClient,\n FirehoseClientConfig,\n PutRecordBatchCommand,\n} from '@aws-sdk/client-firehose';\n\nexport interface Settings {\n firehose?: FirehoseConfig;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n AWS: {\n FirehoseClient: typeof FirehoseClient;\n PutRecordBatchCommand: typeof PutRecordBatchCommand;\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface FirehoseConfig {\n streamName: string;\n client?: FirehoseClient;\n region?: string;\n config?: FirehoseClientConfig;\n}\n","import type { Settings, Destination } from './types';\nimport { isSameType } from '@walkeros/core';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationFirehose from './types';\n\nexport const destinationFirehose: Destination = {\n type: 'aws-firehose',\n\n config: {},\n\n async init({ config: partialConfig, env, logger }) {\n const config = getConfig(partialConfig, env);\n\n if (!isSameType(config.settings, {} as Settings))\n logger.throw('Config settings invalid');\n\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationFirehose;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A;;;;;;;;;;;;;;;;ACKA,SAAS,iBAAiB,KAA0B;AAClD,SAAO;AAAA,IACL,OACE,OAAO,QAAQ,YACf,SAAS,OACR,IAAY,KAAK;AAAA,EACtB;AACF;AAEO,SAAS,kBACd,gBACA,KACgB;AAChB,QAAM,EAAE,YAAY,SAAS,gBAAgB,SAAS,CAAC,EAAE,IAAI;AAE7D,MAAI,CAAC,WAAY,GAAW,4CAA4C;AAExE,MAAI,CAAC,OAAO,OAAQ,QAAO,SAAS;AAGpC,MAAI,SAAS,eAAe;AAC5B,MAAI,CAAC,UAAU,iBAAiB,GAAG,GAAG;AACpC,aAAS,IAAI,IAAI,IAAI,eAAe,MAAM;AAAA,EAC5C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,eAAsB,aACpB,YACA,QACA,SACA;AACA,QAAM,EAAE,QAAQ,WAAW,IAAI;AAC/B,QAAM,EAAE,KAAK,OAAO,IAAI;AAExB,MAAI,CAAC,OAAQ,QAAO,EAAE,OAAO,WAAW;AAGxC,QAAM,UAAU,WAAW,IAAI,CAAC,EAAE,MAAM,OAAO;AAAA,IAC7C,MAAM,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACzC,EAAE;AAEF,SAAO,MAAM,4BAA4B;AAAA,IACvC,QAAQ;AAAA,IACR,aAAa,QAAQ;AAAA,EACvB,CAAC;AAGD,MAAI,iBAAiB,GAAG,GAAG;AACzB,UAAM,OAAO;AAAA,MACX,IAAI,IAAI,IAAI,sBAAsB;AAAA,QAChC,oBAAoB;AAAA,QACpB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF,OAAO;AAEL,UAAM,EAAE,sBAAsB,IAAI,MAAM,OAAO,0BAA0B;AACzE,UAAM,OAAO;AAAA,MACX,IAAI,sBAAsB;AAAA,QACxB,oBAAoB;AAAA,QACpB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AAEA,UAAQ,MAAM,6BAA6B,EAAE,IAAI,KAAK,CAAC;AACzD;;;AC1EO,SAAS,UACd,gBAA+B,CAAC,GAChC,KACQ;AACR,QAAM,WAAW,cAAc,YAAa,CAAC;AAE7C,MAAI,SAAS;AACX,aAAS,WAAW,kBAAkB,SAAS,UAAU,GAAG;AAE9D,SAAO,EAAE,SAAS;AACpB;;;ACVO,IAAM,OAAe,eAAgB,OAAO,SAAS;AAC1D,QAAM,EAAE,SAAS,IAAI,QAAQ,OAAO,YAAY,CAAC;AAEjD,MAAI,SAAU,cAAa,CAAC,EAAE,MAAM,CAAC,GAAG,UAAU,OAAO;AAEzD;AACF;;;ACTA;;;ACQO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,KAAK,OAAO,GAAG;AACjD,UAAM,SAAS,UAAU,eAAe,GAAG;AAE3C,QAAI,CAAC,GAAW,OAAO,UAAU,CAAC,CAAa;AAC7C,aAAO,MAAM,yBAAyB;AAExC,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AACF;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty;((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{Level:()=>
|
|
1
|
+
var e=Object.defineProperty;((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})({},{Level:()=>c});var e2,c=((e2=c||{})[e2.ERROR=0]="ERROR",e2[e2.WARN=1]="WARN",e2[e2.INFO=2]="INFO",e2[e2.DEBUG=3]="DEBUG",e2);function isAWSEnvironment(env){return Boolean(env&&"object"==typeof env&&"AWS"in env&&env.AWS?.FirehoseClient)}function getConfigFirehose(firehoseConfig,env){const{streamName:streamName,region:region="eu-central-1",config:config={}}=firehoseConfig;streamName||function(e2){throw new Error(String(e2))}("Firehose: Config custom streamName missing"),config.region||(config.region=region);let client=firehoseConfig.client;return!client&&isAWSEnvironment(env)&&(client=new env.AWS.FirehoseClient(config)),{streamName:streamName,client:client,region:region}}var push=async function(event,context){const{firehose:firehose}=context.config.settings||{};firehose&&async function(pushEvents,config,context){const{client:client,streamName:streamName}=config,{env:env,logger:logger}=context;if(!client)return{queue:pushEvents};const records=pushEvents.map(({event:event})=>({Data:Buffer.from(JSON.stringify(event))}));if(logger.debug("Calling AWS Firehose API",{stream:streamName,recordCount:records.length}),isAWSEnvironment(env))await client.send(new env.AWS.PutRecordBatchCommand({DeliveryStreamName:streamName,Records:records}));else{const{PutRecordBatchCommand:PutRecordBatchCommand}=await import("@aws-sdk/client-firehose");await client.send(new PutRecordBatchCommand({DeliveryStreamName:streamName,Records:records}))}logger?.debug("AWS Firehose API response",{ok:!0})}([{event:event}],firehose,context)},types_exports={},destinationFirehose={type:"aws-firehose",config:{},async init({config:partialConfig,env:env,logger:logger}){const config=function(partialConfig={},env){const settings=partialConfig.settings||{};return settings.firehose&&(settings.firehose=getConfigFirehose(settings.firehose,env)),{settings:settings}}(partialConfig,env);return function(e2,t){return typeof e2==typeof t}(config.settings,{})||logger.throw("Config settings invalid"),config},push:async(event,context)=>await push(event,context)};export{types_exports as DestinationFirehose,destinationFirehose as default,destinationFirehose};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/firehose/lib/firehose.ts","../src/firehose/config.ts","../src/firehose/push.ts","../src/firehose/types/index.ts","../src/firehose/index.ts"],"sourcesContent":["import type { Destination, Logger } from '@walkeros/core';\nimport type { FirehoseConfig, Env } from '../types';\nimport { throwError } from '@walkeros/core';\n\n// Type guard to check if environment has AWS SDK\nfunction isAWSEnvironment(env: unknown): env is Env {\n return Boolean(\n env &&\n typeof env === 'object' &&\n 'AWS' in env &&\n (env as Env).AWS?.FirehoseClient,\n );\n}\n\nexport function getConfigFirehose(\n firehoseConfig: Partial<FirehoseConfig>,\n env?: unknown,\n): FirehoseConfig {\n const { streamName, region = 'eu-central-1', config = {} } = firehoseConfig;\n\n if (!streamName) throwError('Firehose: Config custom streamName missing');\n\n if (!config.region) config.region = region;\n\n // Use environment-injected SDK or fall back to provided client\n let client = firehoseConfig.client;\n if (!client && isAWSEnvironment(env)) {\n client = new env.AWS.FirehoseClient(config);\n }\n\n return {\n streamName,\n client,\n region,\n };\n}\n\nexport async function pushFirehose(\n pushEvents: Destination.PushEvents,\n config: FirehoseConfig,\n context: Destination.PushContext,\n) {\n const { client, streamName } = config;\n const { env, logger } = context;\n\n if (!client) return { queue: pushEvents };\n\n // Up to 500 records per batch\n const records = pushEvents.map(({ event }) => ({\n Data: Buffer.from(JSON.stringify(event)),\n }));\n\n logger.debug('Calling AWS Firehose API', {\n stream: streamName,\n recordCount: records.length,\n });\n\n // Use environment-injected SDK command or fall back to direct import\n if (isAWSEnvironment(env)) {\n await client.send(\n new env.AWS.PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n } else {\n // Fall back to direct import for backward compatibility\n const { PutRecordBatchCommand } = await import('@aws-sdk/client-firehose');\n await client.send(\n new PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n }\n\n logger?.debug('AWS Firehose API response', { ok: true });\n}\n","import type { Config, Settings, PartialConfig, Env } from './types';\nimport { getConfigFirehose } from './lib/firehose';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n env?: unknown,\n): Config {\n const settings = partialConfig.settings || ({} as Settings);\n\n if (settings.firehose)\n settings.firehose = getConfigFirehose(settings.firehose, env);\n\n return { settings };\n}\n","import type { PushFn } from './types';\nimport { pushFirehose } from './lib/firehose';\n\nexport const push: PushFn = async function (event, context) {\n const { firehose } = context.config.settings || {};\n\n if (firehose) pushFirehose([{ event }], firehose, context);\n\n return;\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type {\n FirehoseClient,\n FirehoseClientConfig,\n PutRecordBatchCommand,\n} from '@aws-sdk/client-firehose';\n\nexport interface Settings {\n firehose?: FirehoseConfig;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n AWS: {\n FirehoseClient: typeof FirehoseClient;\n PutRecordBatchCommand: typeof PutRecordBatchCommand;\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface FirehoseConfig {\n streamName: string;\n client?: FirehoseClient;\n region?: string;\n config?: FirehoseClientConfig;\n}\n","import type { Settings, Destination } from './types';\nimport { isSameType } from '@walkeros/core';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationFirehose from './types';\n\nexport const destinationFirehose: Destination = {\n type: 'aws-firehose',\n\n config: {},\n\n async init({ config: partialConfig, env, logger }) {\n const config = getConfig(partialConfig, env);\n\n if (!isSameType(config.settings, {} as Settings))\n logger.throw('Config settings invalid');\n\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationFirehose;\n"],"mappings":";;;;;;;;;;;;;;;AAKA,SAAS,iBAAiB,KAA0B;
|
|
1
|
+
{"version":3,"sources":["../src/firehose/lib/firehose.ts","../src/firehose/config.ts","../src/firehose/push.ts","../src/firehose/types/index.ts","../src/firehose/index.ts"],"sourcesContent":["import type { Destination, Logger } from '@walkeros/core';\nimport type { FirehoseConfig, Env } from '../types';\nimport { throwError } from '@walkeros/core';\n\n// Type guard to check if environment has AWS SDK\nfunction isAWSEnvironment(env: unknown): env is Env {\n return Boolean(\n env &&\n typeof env === 'object' &&\n 'AWS' in env &&\n (env as Env).AWS?.FirehoseClient,\n );\n}\n\nexport function getConfigFirehose(\n firehoseConfig: Partial<FirehoseConfig>,\n env?: unknown,\n): FirehoseConfig {\n const { streamName, region = 'eu-central-1', config = {} } = firehoseConfig;\n\n if (!streamName) throwError('Firehose: Config custom streamName missing');\n\n if (!config.region) config.region = region;\n\n // Use environment-injected SDK or fall back to provided client\n let client = firehoseConfig.client;\n if (!client && isAWSEnvironment(env)) {\n client = new env.AWS.FirehoseClient(config);\n }\n\n return {\n streamName,\n client,\n region,\n };\n}\n\nexport async function pushFirehose(\n pushEvents: Destination.PushEvents,\n config: FirehoseConfig,\n context: Destination.PushContext,\n) {\n const { client, streamName } = config;\n const { env, logger } = context;\n\n if (!client) return { queue: pushEvents };\n\n // Up to 500 records per batch\n const records = pushEvents.map(({ event }) => ({\n Data: Buffer.from(JSON.stringify(event)),\n }));\n\n logger.debug('Calling AWS Firehose API', {\n stream: streamName,\n recordCount: records.length,\n });\n\n // Use environment-injected SDK command or fall back to direct import\n if (isAWSEnvironment(env)) {\n await client.send(\n new env.AWS.PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n } else {\n // Fall back to direct import for backward compatibility\n const { PutRecordBatchCommand } = await import('@aws-sdk/client-firehose');\n await client.send(\n new PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n }\n\n logger?.debug('AWS Firehose API response', { ok: true });\n}\n","import type { Config, Settings, PartialConfig, Env } from './types';\nimport { getConfigFirehose } from './lib/firehose';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n env?: unknown,\n): Config {\n const settings = partialConfig.settings || ({} as Settings);\n\n if (settings.firehose)\n settings.firehose = getConfigFirehose(settings.firehose, env);\n\n return { settings };\n}\n","import type { PushFn } from './types';\nimport { pushFirehose } from './lib/firehose';\n\nexport const push: PushFn = async function (event, context) {\n const { firehose } = context.config.settings || {};\n\n if (firehose) pushFirehose([{ event }], firehose, context);\n\n return;\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type {\n FirehoseClient,\n FirehoseClientConfig,\n PutRecordBatchCommand,\n} from '@aws-sdk/client-firehose';\n\nexport interface Settings {\n firehose?: FirehoseConfig;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n AWS: {\n FirehoseClient: typeof FirehoseClient;\n PutRecordBatchCommand: typeof PutRecordBatchCommand;\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface FirehoseConfig {\n streamName: string;\n client?: FirehoseClient;\n region?: string;\n config?: FirehoseClientConfig;\n}\n","import type { Settings, Destination } from './types';\nimport { isSameType } from '@walkeros/core';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationFirehose from './types';\n\nexport const destinationFirehose: Destination = {\n type: 'aws-firehose',\n\n config: {},\n\n async init({ config: partialConfig, env, logger }) {\n const config = getConfig(partialConfig, env);\n\n if (!isSameType(config.settings, {} as Settings))\n logger.throw('Config settings invalid');\n\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationFirehose;\n"],"mappings":";;;;;;;;;;;;;;;AAKA,SAAS,iBAAiB,KAA0B;AAClD,SAAO;AAAA,IACL,OACE,OAAO,QAAQ,YACf,SAAS,OACR,IAAY,KAAK;AAAA,EACtB;AACF;AAEO,SAAS,kBACd,gBACA,KACgB;AAChB,QAAM,EAAE,YAAY,SAAS,gBAAgB,SAAS,CAAC,EAAE,IAAI;AAE7D,MAAI,CAAC,WAAY,GAAW,4CAA4C;AAExE,MAAI,CAAC,OAAO,OAAQ,QAAO,SAAS;AAGpC,MAAI,SAAS,eAAe;AAC5B,MAAI,CAAC,UAAU,iBAAiB,GAAG,GAAG;AACpC,aAAS,IAAI,IAAI,IAAI,eAAe,MAAM;AAAA,EAC5C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,eAAsB,aACpB,YACA,QACA,SACA;AACA,QAAM,EAAE,QAAQ,WAAW,IAAI;AAC/B,QAAM,EAAE,KAAK,OAAO,IAAI;AAExB,MAAI,CAAC,OAAQ,QAAO,EAAE,OAAO,WAAW;AAGxC,QAAM,UAAU,WAAW,IAAI,CAAC,EAAE,MAAM,OAAO;AAAA,IAC7C,MAAM,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,EACzC,EAAE;AAEF,SAAO,MAAM,4BAA4B;AAAA,IACvC,QAAQ;AAAA,IACR,aAAa,QAAQ;AAAA,EACvB,CAAC;AAGD,MAAI,iBAAiB,GAAG,GAAG;AACzB,UAAM,OAAO;AAAA,MACX,IAAI,IAAI,IAAI,sBAAsB;AAAA,QAChC,oBAAoB;AAAA,QACpB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF,OAAO;AAEL,UAAM,EAAE,sBAAsB,IAAI,MAAM,OAAO,0BAA0B;AACzE,UAAM,OAAO;AAAA,MACX,IAAI,sBAAsB;AAAA,QACxB,oBAAoB;AAAA,QACpB,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAAA,EACF;AAEA,UAAQ,MAAM,6BAA6B,EAAE,IAAI,KAAK,CAAC;AACzD;;;AC1EO,SAAS,UACd,gBAA+B,CAAC,GAChC,KACQ;AACR,QAAM,WAAW,cAAc,YAAa,CAAC;AAE7C,MAAI,SAAS;AACX,aAAS,WAAW,kBAAkB,SAAS,UAAU,GAAG;AAE9D,SAAO,EAAE,SAAS;AACpB;;;ACVO,IAAM,OAAe,eAAgB,OAAO,SAAS;AAC1D,QAAM,EAAE,SAAS,IAAI,QAAQ,OAAO,YAAY,CAAC;AAEjD,MAAI,SAAU,cAAa,CAAC,EAAE,MAAM,CAAC,GAAG,UAAU,OAAO;AAEzD;AACF;;;ACTA;;;ACQO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,KAAK,OAAO,GAAG;AACjD,UAAM,SAAS,UAAU,eAAe,GAAG;AAE3C,QAAI,CAAC,GAAW,OAAO,UAAU,CAAC,CAAa;AAC7C,aAAO,MAAM,yBAAyB;AAExC,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AACF;","names":[]}
|