@walkeros/server-destination-aws 0.1.1 → 0.2.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.
@@ -0,0 +1,23 @@
1
+ import { DestinationServer } from '@walkeros/server-core';
2
+ import { FirehoseClient, PutRecordBatchCommand } from '@aws-sdk/client-firehose';
3
+
4
+ interface Env extends DestinationServer.Env {
5
+ AWS: {
6
+ FirehoseClient: typeof FirehoseClient;
7
+ PutRecordBatchCommand: typeof PutRecordBatchCommand;
8
+ };
9
+ }
10
+
11
+ declare const push: Env;
12
+
13
+ declare const env_push: typeof push;
14
+ declare namespace env {
15
+ export { env_push as push };
16
+ }
17
+
18
+ declare const index_env: typeof env;
19
+ declare namespace index {
20
+ export { index_env as env };
21
+ }
22
+
23
+ export { index as firehose };
@@ -0,0 +1,23 @@
1
+ import { DestinationServer } from '@walkeros/server-core';
2
+ import { FirehoseClient, PutRecordBatchCommand } from '@aws-sdk/client-firehose';
3
+
4
+ interface Env extends DestinationServer.Env {
5
+ AWS: {
6
+ FirehoseClient: typeof FirehoseClient;
7
+ PutRecordBatchCommand: typeof PutRecordBatchCommand;
8
+ };
9
+ }
10
+
11
+ declare const push: Env;
12
+
13
+ declare const env_push: typeof push;
14
+ declare namespace env {
15
+ export { env_push as push };
16
+ }
17
+
18
+ declare const index_env: typeof env;
19
+ declare namespace index {
20
+ export { index_env as env };
21
+ }
22
+
23
+ export { index as firehose };
@@ -20,16 +20,47 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/examples/index.ts
21
21
  var examples_exports2 = {};
22
22
  __export(examples_exports2, {
23
- destinationFirehoseExamples: () => destinationFirehoseExamples
23
+ firehose: () => examples_exports
24
24
  });
25
25
  module.exports = __toCommonJS(examples_exports2);
26
26
 
27
27
  // src/firehose/examples/index.ts
28
28
  var examples_exports = {};
29
+ __export(examples_exports, {
30
+ env: () => env_exports
31
+ });
29
32
 
30
- // src/examples/index.ts
31
- var destinationFirehoseExamples = examples_exports;
33
+ // src/firehose/examples/env.ts
34
+ var env_exports = {};
35
+ __export(env_exports, {
36
+ push: () => push
37
+ });
38
+ var MockFirehoseClient = class {
39
+ constructor(config) {
40
+ this.config = config;
41
+ }
42
+ async send(command) {
43
+ return {
44
+ RecordId: "mock-record-id",
45
+ ResponseMetadata: {
46
+ RequestId: "mock-request-id"
47
+ }
48
+ };
49
+ }
50
+ };
51
+ var MockPutRecordBatchCommand = class {
52
+ constructor(input) {
53
+ this.input = input;
54
+ }
55
+ };
56
+ var push = {
57
+ // Environment for push operations
58
+ AWS: {
59
+ FirehoseClient: MockFirehoseClient,
60
+ PutRecordBatchCommand: MockPutRecordBatchCommand
61
+ }
62
+ };
32
63
  // Annotate the CommonJS export names for ESM import in node:
33
64
  0 && (module.exports = {
34
- destinationFirehoseExamples
65
+ firehose
35
66
  });
@@ -1,8 +1,45 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // src/firehose/examples/index.ts
2
8
  var examples_exports = {};
9
+ __export(examples_exports, {
10
+ env: () => env_exports
11
+ });
3
12
 
4
- // src/examples/index.ts
5
- var destinationFirehoseExamples = examples_exports;
13
+ // src/firehose/examples/env.ts
14
+ var env_exports = {};
15
+ __export(env_exports, {
16
+ push: () => push
17
+ });
18
+ var MockFirehoseClient = class {
19
+ constructor(config) {
20
+ this.config = config;
21
+ }
22
+ async send(command) {
23
+ return {
24
+ RecordId: "mock-record-id",
25
+ ResponseMetadata: {
26
+ RequestId: "mock-request-id"
27
+ }
28
+ };
29
+ }
30
+ };
31
+ var MockPutRecordBatchCommand = class {
32
+ constructor(input) {
33
+ this.input = input;
34
+ }
35
+ };
36
+ var push = {
37
+ // Environment for push operations
38
+ AWS: {
39
+ FirehoseClient: MockFirehoseClient,
40
+ PutRecordBatchCommand: MockPutRecordBatchCommand
41
+ }
42
+ };
6
43
  export {
7
- destinationFirehoseExamples
44
+ examples_exports as firehose
8
45
  };
package/dist/index.d.mts CHANGED
@@ -1,27 +1,28 @@
1
1
  import { DestinationServer } from '@walkeros/server-core';
2
- import { Mapping as Mapping$1 } from '@walkeros/core';
3
- import { FirehoseClient, FirehoseClientConfig } from '@aws-sdk/client-firehose';
2
+ import { Destination as Destination$1, Mapping as Mapping$1 } from '@walkeros/core';
3
+ import { FirehoseClient, FirehoseClientConfig, PutRecordBatchCommand } from '@aws-sdk/client-firehose';
4
4
 
5
- declare global {
6
- namespace WalkerOS {
7
- interface Elb extends Elb.RegisterDestination<Destination, Config> {
8
- }
9
- }
10
- }
11
- interface Destination extends DestinationServer.Destination<Settings, Mapping> {
12
- init: DestinationServer.InitFn<Settings, Mapping>;
13
- }
14
- type Config = {
15
- settings: Settings;
16
- } & DestinationServer.Config<Settings, Mapping>;
17
5
  interface Settings {
18
6
  firehose?: FirehoseConfig;
19
7
  }
20
8
  interface Mapping {
21
9
  }
22
- type InitFn = DestinationServer.InitFn<Settings, Mapping>;
23
- type PushFn = DestinationServer.PushFn<Settings, Mapping>;
24
- type PartialConfig = DestinationServer.PartialConfig<Settings, Mapping>;
10
+ interface Env extends DestinationServer.Env {
11
+ AWS: {
12
+ FirehoseClient: typeof FirehoseClient;
13
+ PutRecordBatchCommand: typeof PutRecordBatchCommand;
14
+ };
15
+ }
16
+ type Types = Destination$1.Types<Settings, Mapping, Env>;
17
+ interface Destination extends DestinationServer.Destination<Types> {
18
+ init: DestinationServer.InitFn<Types>;
19
+ }
20
+ type Config = {
21
+ settings: Settings;
22
+ } & DestinationServer.Config<Types>;
23
+ type InitFn = DestinationServer.InitFn<Types>;
24
+ type PushFn = DestinationServer.PushFn<Types>;
25
+ type PartialConfig = DestinationServer.PartialConfig<Types>;
25
26
  type PushEvents = DestinationServer.PushEvents<Mapping>;
26
27
  type Rule = Mapping$1.Rule<Mapping>;
27
28
  type Rules = Mapping$1.Rules<Rule>;
@@ -32,25 +33,39 @@ interface FirehoseConfig {
32
33
  config?: FirehoseClientConfig;
33
34
  }
34
35
 
35
- type index$1_Config = Config;
36
- type index$1_Destination = Destination;
37
- type index$1_FirehoseConfig = FirehoseConfig;
38
- type index$1_InitFn = InitFn;
39
- type index$1_Mapping = Mapping;
40
- type index$1_PartialConfig = PartialConfig;
41
- type index$1_PushEvents = PushEvents;
42
- type index$1_PushFn = PushFn;
43
- type index$1_Rule = Rule;
44
- type index$1_Rules = Rules;
45
- type index$1_Settings = Settings;
36
+ type index$2_Config = Config;
37
+ type index$2_Destination = Destination;
38
+ type index$2_Env = Env;
39
+ type index$2_FirehoseConfig = FirehoseConfig;
40
+ type index$2_InitFn = InitFn;
41
+ type index$2_Mapping = Mapping;
42
+ type index$2_PartialConfig = PartialConfig;
43
+ type index$2_PushEvents = PushEvents;
44
+ type index$2_PushFn = PushFn;
45
+ type index$2_Rule = Rule;
46
+ type index$2_Rules = Rules;
47
+ type index$2_Settings = Settings;
48
+ type index$2_Types = Types;
49
+ declare namespace index$2 {
50
+ export type { index$2_Config as Config, index$2_Destination as Destination, index$2_Env as Env, index$2_FirehoseConfig as FirehoseConfig, index$2_InitFn as InitFn, index$2_Mapping as Mapping, index$2_PartialConfig as PartialConfig, index$2_PushEvents as PushEvents, index$2_PushFn as PushFn, index$2_Rule as Rule, index$2_Rules as Rules, index$2_Settings as Settings, index$2_Types as Types };
51
+ }
52
+
53
+ declare const push: Env;
54
+
55
+ declare const env_push: typeof push;
56
+ declare namespace env {
57
+ export { env_push as push };
58
+ }
59
+
60
+ declare const index$1_env: typeof env;
46
61
  declare namespace index$1 {
47
- export type { index$1_Config as Config, index$1_Destination as Destination, index$1_FirehoseConfig as FirehoseConfig, index$1_InitFn as InitFn, index$1_Mapping as Mapping, index$1_PartialConfig as PartialConfig, index$1_PushEvents as PushEvents, index$1_PushFn as PushFn, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings };
62
+ export { index$1_env as env };
48
63
  }
49
64
 
50
65
  declare const destinationFirehose: Destination;
51
66
 
52
67
  declare namespace index {
53
- export { };
68
+ export { index$1 as firehose };
54
69
  }
55
70
 
56
- export { index$1 as DestinationFirehose, destinationFirehose, index as destinationFirehoseExamples };
71
+ export { index$2 as DestinationFirehose, destinationFirehose, index as examples };
package/dist/index.d.ts CHANGED
@@ -1,27 +1,28 @@
1
1
  import { DestinationServer } from '@walkeros/server-core';
2
- import { Mapping as Mapping$1 } from '@walkeros/core';
3
- import { FirehoseClient, FirehoseClientConfig } from '@aws-sdk/client-firehose';
2
+ import { Destination as Destination$1, Mapping as Mapping$1 } from '@walkeros/core';
3
+ import { FirehoseClient, FirehoseClientConfig, PutRecordBatchCommand } from '@aws-sdk/client-firehose';
4
4
 
5
- declare global {
6
- namespace WalkerOS {
7
- interface Elb extends Elb.RegisterDestination<Destination, Config> {
8
- }
9
- }
10
- }
11
- interface Destination extends DestinationServer.Destination<Settings, Mapping> {
12
- init: DestinationServer.InitFn<Settings, Mapping>;
13
- }
14
- type Config = {
15
- settings: Settings;
16
- } & DestinationServer.Config<Settings, Mapping>;
17
5
  interface Settings {
18
6
  firehose?: FirehoseConfig;
19
7
  }
20
8
  interface Mapping {
21
9
  }
22
- type InitFn = DestinationServer.InitFn<Settings, Mapping>;
23
- type PushFn = DestinationServer.PushFn<Settings, Mapping>;
24
- type PartialConfig = DestinationServer.PartialConfig<Settings, Mapping>;
10
+ interface Env extends DestinationServer.Env {
11
+ AWS: {
12
+ FirehoseClient: typeof FirehoseClient;
13
+ PutRecordBatchCommand: typeof PutRecordBatchCommand;
14
+ };
15
+ }
16
+ type Types = Destination$1.Types<Settings, Mapping, Env>;
17
+ interface Destination extends DestinationServer.Destination<Types> {
18
+ init: DestinationServer.InitFn<Types>;
19
+ }
20
+ type Config = {
21
+ settings: Settings;
22
+ } & DestinationServer.Config<Types>;
23
+ type InitFn = DestinationServer.InitFn<Types>;
24
+ type PushFn = DestinationServer.PushFn<Types>;
25
+ type PartialConfig = DestinationServer.PartialConfig<Types>;
25
26
  type PushEvents = DestinationServer.PushEvents<Mapping>;
26
27
  type Rule = Mapping$1.Rule<Mapping>;
27
28
  type Rules = Mapping$1.Rules<Rule>;
@@ -32,25 +33,39 @@ interface FirehoseConfig {
32
33
  config?: FirehoseClientConfig;
33
34
  }
34
35
 
35
- type index$1_Config = Config;
36
- type index$1_Destination = Destination;
37
- type index$1_FirehoseConfig = FirehoseConfig;
38
- type index$1_InitFn = InitFn;
39
- type index$1_Mapping = Mapping;
40
- type index$1_PartialConfig = PartialConfig;
41
- type index$1_PushEvents = PushEvents;
42
- type index$1_PushFn = PushFn;
43
- type index$1_Rule = Rule;
44
- type index$1_Rules = Rules;
45
- type index$1_Settings = Settings;
36
+ type index$2_Config = Config;
37
+ type index$2_Destination = Destination;
38
+ type index$2_Env = Env;
39
+ type index$2_FirehoseConfig = FirehoseConfig;
40
+ type index$2_InitFn = InitFn;
41
+ type index$2_Mapping = Mapping;
42
+ type index$2_PartialConfig = PartialConfig;
43
+ type index$2_PushEvents = PushEvents;
44
+ type index$2_PushFn = PushFn;
45
+ type index$2_Rule = Rule;
46
+ type index$2_Rules = Rules;
47
+ type index$2_Settings = Settings;
48
+ type index$2_Types = Types;
49
+ declare namespace index$2 {
50
+ export type { index$2_Config as Config, index$2_Destination as Destination, index$2_Env as Env, index$2_FirehoseConfig as FirehoseConfig, index$2_InitFn as InitFn, index$2_Mapping as Mapping, index$2_PartialConfig as PartialConfig, index$2_PushEvents as PushEvents, index$2_PushFn as PushFn, index$2_Rule as Rule, index$2_Rules as Rules, index$2_Settings as Settings, index$2_Types as Types };
51
+ }
52
+
53
+ declare const push: Env;
54
+
55
+ declare const env_push: typeof push;
56
+ declare namespace env {
57
+ export { env_push as push };
58
+ }
59
+
60
+ declare const index$1_env: typeof env;
46
61
  declare namespace index$1 {
47
- export type { index$1_Config as Config, index$1_Destination as Destination, index$1_FirehoseConfig as FirehoseConfig, index$1_InitFn as InitFn, index$1_Mapping as Mapping, index$1_PartialConfig as PartialConfig, index$1_PushEvents as PushEvents, index$1_PushFn as PushFn, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings };
62
+ export { index$1_env as env };
48
63
  }
49
64
 
50
65
  declare const destinationFirehose: Destination;
51
66
 
52
67
  declare namespace index {
53
- export { };
68
+ export { index$1 as firehose };
54
69
  }
55
70
 
56
- export { index$1 as DestinationFirehose, destinationFirehose, index as destinationFirehoseExamples };
71
+ export { index$2 as DestinationFirehose, destinationFirehose, index as examples };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t,r,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(a,{DestinationFirehose:()=>d,destinationFirehose:()=>g,destinationFirehoseExamples:()=>y}),module.exports=(e=a,((e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of o(t))i.call(e,c)||c===r||n(e,c,{get:()=>t[c],enumerable:!(a=s(t,c))||a.enumerable});return e})(n({},"__esModule",{value:!0}),e));var c=Object.getOwnPropertyNames,l=(t={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.1",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return r||(0,t[c(t)[0]])((r={exports:{}}).exports,r),r.exports});var{version:u}=l();var p=require("@aws-sdk/client-firehose");function m(e){const{streamName:t,region:r="eu-central-1",config:n={}}=e;t||function(e){throw new Error(String(e))}("Firehose: Config custom streamName missing"),n.region||(n.region=r);return{streamName:t,client:e.client||new p.FirehoseClient(n),region:r}}var f=async function(e,{config:t,collector:r,env:n}){const{firehose:s}=t.settings||{};s&&async function(e,t){const{client:r,streamName:n}=t;if(!r)return{queue:e};const s=e.map(({event:e})=>({Data:Buffer.from(JSON.stringify(e))}));await r.send(new p.PutRecordBatchCommand({DeliveryStreamName:n,Records:s}))}([{event:e}],s)},d={},g={type:"aws-firehose",config:{},async init({config:e}){const t=function(e={}){const t=e.settings||{};return t.firehose&&(t.firehose=m(t.firehose)),{settings:t}}(e);return typeof t.settings==typeof{}&&t},push:async(e,{config:t,collector:r,env:n})=>await f(e,{config:t,collector:r,env:n})},y={};//# sourceMappingURL=index.js.map
1
+ "use strict";Object.create;var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=(Object.getPrototypeOf,Object.prototype.hasOwnProperty),i=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},s=(e,i,s,c)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let a of o(i))r.call(e,a)||a===s||t(e,a,{get:()=>i[a],enumerable:!(c=n(i,a))||c.enumerable});return e},c={};function a(e){var t;return Boolean(e&&"object"==typeof e&&"AWS"in e&&(null==(t=e.AWS)?void 0:t.FirehoseClient))}function f(e,t){const{streamName:n,region:o="eu-central-1",config:r={}}=e;n||function(e){throw new Error(String(e))}("Firehose: Config custom streamName missing"),r.region||(r.region=o);let i=e.client;return!i&&a(t)&&(i=new t.AWS.FirehoseClient(r)),{streamName:n,client:i,region:o}}i(c,{DestinationFirehose:()=>l,destinationFirehose:()=>h,examples:()=>p}),module.exports=(e=c,s(t({},"__esModule",{value:!0}),e));var u=async function(e,{config:t,collector:n,env:o}){const{firehose:r}=t.settings||{};r&&async function(e,t,n){const{client:o,streamName:r}=t;if(!o)return{queue:e};const i=e.map(({event:e})=>({Data:Buffer.from(JSON.stringify(e))}));if(a(n))await o.send(new n.AWS.PutRecordBatchCommand({DeliveryStreamName:r,Records:i}));else{const{PutRecordBatchCommand:e}=await import("@aws-sdk/client-firehose");await o.send(new e({DeliveryStreamName:r,Records:i}))}}([{event:e}],r,o)},l={},m={};i(m,{env:()=>d});var d={};i(d,{push:()=>g});var g={AWS:{FirehoseClient:class{constructor(e){this.config=e}async send(e){return{RecordId:"mock-record-id",ResponseMetadata:{RequestId:"mock-request-id"}}}},PutRecordBatchCommand:class{constructor(e){this.input=e}}}},h={type:"aws-firehose",config:{},async init({config:e,env:t}){const n=function(e={},t){const n=e.settings||{};return n.firehose&&(n.firehose=f(n.firehose,t)),{settings:n}}(e,t);return typeof n.settings==typeof{}&&n},push:async(e,{config:t,collector:n,env:o})=>await u(e,{config:t,collector:n,env:o})},p={};i(p,{firehose:()=>m});//# 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","../src/firehose/examples/index.ts"],"sourcesContent":["// AWS Firehose\nexport { destinationFirehose } from './firehose';\nexport * as DestinationFirehose from './firehose/types';\n\n// Examples\nexport * as destinationFirehoseExamples from './firehose/examples';\n","import type { Destination } from '@walkeros/core';\nimport type { FirehoseConfig } from '../types';\nimport { throwError } from '@walkeros/core';\nimport {\n FirehoseClient,\n PutRecordBatchCommand,\n} from '@aws-sdk/client-firehose';\n\nexport function getConfigFirehose(\n firehoseConfig: Partial<FirehoseConfig>,\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 const client = firehoseConfig.client || new FirehoseClient(config);\n\n return {\n streamName,\n client,\n region,\n };\n}\n\nexport async function pushFirehose(\n pushEvents: Destination.PushEvents,\n config: FirehoseConfig,\n) {\n const { client, streamName } = config;\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 await client.send(\n new PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n}\n","import type { Config, Settings, PartialConfig } from './types';\nimport { getConfigFirehose } from './lib/firehose';\n\nexport function getConfig(partialConfig: PartialConfig = {}): Config {\n const settings = partialConfig.settings || ({} as Settings);\n\n if (settings.firehose)\n settings.firehose = getConfigFirehose(settings.firehose);\n\n return { settings };\n}\n","import type { PushFn } from './types';\nimport { pushFirehose } from './lib/firehose';\n\nexport const push: PushFn = async function (event, { config, collector, env }) {\n const { firehose } = config.settings || {};\n\n if (firehose) pushFirehose([{ event }], firehose);\n\n return;\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type { Mapping as WalkerOSMapping, Elb } from '@walkeros/core';\nimport type {\n FirehoseClient,\n FirehoseClientConfig,\n} from '@aws-sdk/client-firehose';\n\ndeclare global {\n // Augment the global WalkerOS namespace with destination-specific types\n namespace WalkerOS {\n interface Elb extends Elb.RegisterDestination<Destination, Config> {}\n }\n}\n\nexport interface Destination\n extends DestinationServer.Destination<Settings, Mapping> {\n init: DestinationServer.InitFn<Settings, Mapping>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Settings, Mapping>;\n\nexport interface Settings {\n firehose?: FirehoseConfig;\n}\n\nexport interface Mapping {\n // Custom destination event mapping properties\n}\n\nexport type InitFn = DestinationServer.InitFn<Settings, Mapping>;\nexport type PushFn = DestinationServer.PushFn<Settings, Mapping>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Settings, Mapping>;\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 }) {\n const config = getConfig(partialConfig);\n\n if (!isSameType(config.settings, {} as Settings)) return false;\n\n return config;\n },\n\n async push(event, { config, collector, env }) {\n return await push(event, { config, collector, env });\n },\n};\n\nexport default destinationFirehose;\n","export {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A;;;;;;;;;;;;;;;;;;;ACGA,6BAGO;AAEA,SAAS,kBACd,gBACgB;AAChB,QAAM,EAAE,YAAY,SAAS,gBAAgB,SAAS,CAAC,EAAE,IAAI;AAE7D,MAAI,CAAC,WAAY,IAAW,4CAA4C;AAExE,MAAI,CAAC,OAAO,OAAQ,QAAO,SAAS;AAEpC,QAAM,SAAS,eAAe,UAAU,IAAI,sCAAe,MAAM;AAEjE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,eAAsB,aACpB,YACA,QACA;AACA,QAAM,EAAE,QAAQ,WAAW,IAAI;AAE/B,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,QAAM,OAAO;AAAA,IACX,IAAI,6CAAsB;AAAA,MACxB,oBAAoB;AAAA,MACpB,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;;;AC1CO,SAAS,UAAU,gBAA+B,CAAC,GAAW;AACnE,QAAM,WAAW,cAAc,YAAa,CAAC;AAE7C,MAAI,SAAS;AACX,aAAS,WAAW,kBAAkB,SAAS,QAAQ;AAEzD,SAAO,EAAE,SAAS;AACpB;;;ACPO,IAAM,OAAe,eAAgB,OAAO,EAAE,QAAQ,WAAW,IAAI,GAAG;AAC7E,QAAM,EAAE,SAAS,IAAI,OAAO,YAAY,CAAC;AAEzC,MAAI,SAAU,cAAa,CAAC,EAAE,MAAM,CAAC,GAAG,QAAQ;AAEhD;AACF;;;ACTA;;;ACQO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,cAAc,GAAG;AACpC,UAAM,SAAS,UAAU,aAAa;AAEtC,QAAI,CAAC,EAAW,OAAO,UAAU,CAAC,CAAa,EAAG,QAAO;AAEzD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,EAAE,QAAQ,WAAW,IAAI,GAAG;AAC5C,WAAO,MAAM,KAAK,OAAO,EAAE,QAAQ,WAAW,IAAI,CAAC;AAAA,EACrD;AACF;;;ACxBA;","names":[]}
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/examples/index.ts","../src/firehose/examples/env.ts","../src/firehose/index.ts","../src/examples/index.ts"],"sourcesContent":["// AWS Firehose\nexport { destinationFirehose } from './firehose';\nexport * as DestinationFirehose from './firehose/types';\n\n// Examples\nexport * as examples from './examples';\n","import type { Destination } 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 env?: unknown,\n) {\n const { client, streamName } = config;\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 // 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","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, { config, collector, env }) {\n const { firehose } = config.settings || {};\n\n if (firehose) pushFirehose([{ event }], firehose, env);\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 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>;\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","export * as env from './env';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for AWS Firehose destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual AWS SDK dependencies.\n */\n\n// Mock FirehoseClient class\nclass MockFirehoseClient {\n config: unknown;\n\n constructor(config?: unknown) {\n this.config = config;\n }\n\n async send(command: unknown) {\n // Simulate successful response\n return {\n RecordId: 'mock-record-id',\n ResponseMetadata: {\n RequestId: 'mock-request-id',\n },\n };\n }\n}\n\n// Mock PutRecordBatchCommand class\nclass MockPutRecordBatchCommand {\n input: unknown;\n\n constructor(input: unknown) {\n this.input = input;\n }\n}\n\nexport const push: Env = {\n // Environment for push operations\n AWS: {\n FirehoseClient:\n MockFirehoseClient as unknown as Env['AWS']['FirehoseClient'],\n PutRecordBatchCommand:\n MockPutRecordBatchCommand as unknown as Env['AWS']['PutRecordBatchCommand'],\n },\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\n// Examples\nexport * as examples from './examples';\n\nexport const destinationFirehose: Destination = {\n type: 'aws-firehose',\n\n config: {},\n\n async init({ config: partialConfig, env }) {\n const config = getConfig(partialConfig, env);\n\n if (!isSameType(config.settings, {} as Settings)) return false;\n\n return config;\n },\n\n async push(event, { config, collector, env }) {\n return await push(event, { config, collector, env });\n },\n};\n\nexport default destinationFirehose;\n","export * as firehose from '../firehose/examples';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAAA;AAAA;AAAA;A;;;;;;;;;;ACKA,SAAS,iBAAiB,KAA0B;AALpD;AAME,SAAO;AAAA,IACL,OACE,OAAO,QAAQ,YACf,SAAS,SACR,SAAY,QAAZ,mBAAiB;AAAA,EACtB;AACF;AAEO,SAAS,kBACd,gBACA,KACgB;AAChB,QAAM,EAAE,YAAY,SAAS,gBAAgB,SAAS,CAAC,EAAE,IAAI;AAE7D,MAAI,CAAC,WAAY,IAAW,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,KACA;AACA,QAAM,EAAE,QAAQ,WAAW,IAAI;AAE/B,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;AAGF,MAAI,iBAAiB,GAAG,GAAG;AACzB,UAAM,OAAO;AAAA,MACX,IAAI,IAAI,IAAI,sBAAsB;AAAA,QAChC,oBAAoB;AA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AG;AAE3C,QAAI,CAAC,EAAW,OAAO,UAAU,CAAC,CAAa,EAAG,QAAO;AAEzD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,EAAE,QAAQ,WAAW,IAAI,GAAG;AAC5C,WAAO,MAAM,KAAK,OAAO,EAAE,QAAQ,WAAW,IAAI,CAAC;AAAA,EACrD;AACF;;;AC3BA,IAAAC,oBAAA;AAAA,SAAAA,mBAAA;AAAA;AAAA;","names":["examples_exports","push","examples_exports"]}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var e,t,s=Object.getOwnPropertyNames,r=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.1",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[s(e)[0]])((t={exports:{}}).exports,t),t.exports});var{version:n}=r();import{FirehoseClient as i,PutRecordBatchCommand as o}from"@aws-sdk/client-firehose";function a(e){const{streamName:t,region:s="eu-central-1",config:r={}}=e;t||function(e){throw new Error(String(e))}("Firehose: Config custom streamName missing"),r.region||(r.region=s);return{streamName:t,client:e.client||new i(r),region:s}}var c=async function(e,{config:t,collector:s,env:r}){const{firehose:n}=t.settings||{};n&&async function(e,t){const{client:s,streamName:r}=t;if(!s)return{queue:e};const n=e.map(({event:e})=>({Data:Buffer.from(JSON.stringify(e))}));await s.send(new o({DeliveryStreamName:r,Records:n}))}([{event:e}],n)},l={},p={type:"aws-firehose",config:{},async init({config:e}){const t=function(e={}){const t=e.settings||{};return t.firehose&&(t.firehose=a(t.firehose)),{settings:t}}(e);return typeof t.settings==typeof{}&&t},push:async(e,{config:t,collector:s,env:r})=>await c(e,{config:t,collector:s,env:r})},u={};export{l as DestinationFirehose,p as destinationFirehose,u as destinationFirehoseExamples};//# sourceMappingURL=index.mjs.map
1
+ var e=Object.defineProperty,n=(n,t)=>{for(var o in t)e(n,o,{get:t[o],enumerable:!0})};function t(e){var n;return Boolean(e&&"object"==typeof e&&"AWS"in e&&(null==(n=e.AWS)?void 0:n.FirehoseClient))}function o(e,n){const{streamName:o,region:r="eu-central-1",config:i={}}=e;o||function(e){throw new Error(String(e))}("Firehose: Config custom streamName missing"),i.region||(i.region=r);let s=e.client;return!s&&t(n)&&(s=new n.AWS.FirehoseClient(i)),{streamName:o,client:s,region:r}}var r=async function(e,{config:n,collector:o,env:r}){const{firehose:i}=n.settings||{};i&&async function(e,n,o){const{client:r,streamName:i}=n;if(!r)return{queue:e};const s=e.map(({event:e})=>({Data:Buffer.from(JSON.stringify(e))}));if(t(o))await r.send(new o.AWS.PutRecordBatchCommand({DeliveryStreamName:i,Records:s}));else{const{PutRecordBatchCommand:e}=await import("@aws-sdk/client-firehose");await r.send(new e({DeliveryStreamName:i,Records:s}))}}([{event:e}],i,r)},i={},s={};n(s,{env:()=>c});var c={};n(c,{push:()=>a});var a={AWS:{FirehoseClient:class{constructor(e){this.config=e}async send(e){return{RecordId:"mock-record-id",ResponseMetadata:{RequestId:"mock-request-id"}}}},PutRecordBatchCommand:class{constructor(e){this.input=e}}}},f={type:"aws-firehose",config:{},async init({config:e,env:n}){const t=function(e={},n){const t=e.settings||{};return t.firehose&&(t.firehose=o(t.firehose,n)),{settings:t}}(e,n);return typeof t.settings==typeof{}&&t},push:async(e,{config:n,collector:t,env:o})=>await r(e,{config:n,collector:t,env:o})},u={};n(u,{firehose:()=>s});export{i as DestinationFirehose,f as destinationFirehose,u as examples};//# sourceMappingURL=index.mjs.map
@@ -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","../src/firehose/examples/index.ts"],"sourcesContent":["import type { Destination } from '@walkeros/core';\nimport type { FirehoseConfig } from '../types';\nimport { throwError } from '@walkeros/core';\nimport {\n FirehoseClient,\n PutRecordBatchCommand,\n} from '@aws-sdk/client-firehose';\n\nexport function getConfigFirehose(\n firehoseConfig: Partial<FirehoseConfig>,\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 const client = firehoseConfig.client || new FirehoseClient(config);\n\n return {\n streamName,\n client,\n region,\n };\n}\n\nexport async function pushFirehose(\n pushEvents: Destination.PushEvents,\n config: FirehoseConfig,\n) {\n const { client, streamName } = config;\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 await client.send(\n new PutRecordBatchCommand({\n DeliveryStreamName: streamName,\n Records: records,\n }),\n );\n}\n","import type { Config, Settings, PartialConfig } from './types';\nimport { getConfigFirehose } from './lib/firehose';\n\nexport function getConfig(partialConfig: PartialConfig = {}): Config {\n const settings = partialConfig.settings || ({} as Settings);\n\n if (settings.firehose)\n settings.firehose = getConfigFirehose(settings.firehose);\n\n return { settings };\n}\n","import type { PushFn } from './types';\nimport { pushFirehose } from './lib/firehose';\n\nexport const push: PushFn = async function (event, { config, collector, env }) {\n const { firehose } = config.settings || {};\n\n if (firehose) pushFirehose([{ event }], firehose);\n\n return;\n};\n","import type { DestinationServer } from '@walkeros/server-core';\nimport type { Mapping as WalkerOSMapping, Elb } from '@walkeros/core';\nimport type {\n FirehoseClient,\n FirehoseClientConfig,\n} from '@aws-sdk/client-firehose';\n\ndeclare global {\n // Augment the global WalkerOS namespace with destination-specific types\n namespace WalkerOS {\n interface Elb extends Elb.RegisterDestination<Destination, Config> {}\n }\n}\n\nexport interface Destination\n extends DestinationServer.Destination<Settings, Mapping> {\n init: DestinationServer.InitFn<Settings, Mapping>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Settings, Mapping>;\n\nexport interface Settings {\n firehose?: FirehoseConfig;\n}\n\nexport interface Mapping {\n // Custom destination event mapping properties\n}\n\nexport type InitFn = DestinationServer.InitFn<Settings, Mapping>;\nexport type PushFn = DestinationServer.PushFn<Settings, Mapping>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Settings, Mapping>;\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 }) {\n const config = getConfig(partialConfig);\n\n if (!isSameType(config.settings, {} as Settings)) return false;\n\n return config;\n },\n\n async push(event, { config, collector, env }) {\n return await push(event, { config, collector, env });\n },\n};\n\nexport default destinationFirehose;\n","export {};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAGA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEA,SAAS,kBACd,gBACgB;AAChB,QAAM,EAAE,YAAY,SAAS,gBAAgB,SAAS,CAAC,EAAE,IAAI;AAE7D,MAAI,CAAC,WAAY,IAAW,4CAA4C;AAExE,MAAI,CAAC,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;ACxBA;","names":[]}
1
+ {"version":3,"sources":["../src/firehose/lib/firehose.ts","../src/firehose/config.ts","../src/firehose/push.ts","../src/firehose/types/index.ts","../src/firehose/examples/index.ts","../src/firehose/examples/env.ts","../src/firehose/index.ts","../src/examples/index.ts"],"sourcesContent":["import type { Destination } 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 env?: unknown,\n) {\n const { client, streamName } = config;\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 // 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","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, { config, collector, env }) {\n const { firehose } = config.settings || {};\n\n if (firehose) pushFirehose([{ event }], firehose, env);\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 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>;\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","export * as env from './env';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for AWS Firehose destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual AWS SDK dependencies.\n */\n\n// Mock FirehoseClient class\nclass MockFirehoseClient {\n config: unknown;\n\n constructor(config?: unknown) {\n this.config = config;\n }\n\n async send(command: unknown) {\n // Simulate successful response\n return {\n RecordId: 'mock-record-id',\n ResponseMetadata: {\n RequestId: 'mock-request-id',\n },\n };\n }\n}\n\n// Mock PutRecordBatchCommand class\nclass MockPutRecordBatchCommand {\n input: unknown;\n\n constructor(input: unknown) {\n this.input = input;\n }\n}\n\nexport const push: Env = {\n // Environment for push operations\n AWS: {\n FirehoseClient:\n MockFirehoseClient as unknown as Env['AWS']['FirehoseClient'],\n PutRecordBatchCommand:\n MockPutRecordBatchCommand as unknown as Env['AWS']['PutRecordBatchCommand'],\n },\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\n// Examples\nexport * as examples from './examples';\n\nexport const destinationFirehose: Destination = {\n type: 'aws-firehose',\n\n config: {},\n\n async init({ config: partialConfig, env }) {\n const config = getConfig(partialConfig, env);\n\n if (!isSameType(config.settings, {} as Settings)) return false;\n\n return config;\n },\n\n async push(event, { config, collector, env }) {\n return await push(event, { config, collector, env });\n },\n};\n\nexport default destinationFirehose;\n","export * as firehose from '../firehose/examples';\n"],"mappings":";;;;;;;;;;;;;;;AAKA,SAAS,iBAAiB,KAA0B;AALpD;AAME,SAAO;AAAA,IACL,OACE,OAAO,QAAQ,YACf,SAAS,SACR,SAAY,QAAZ,mBAAiB;AAAA,EACtB;AACF;AAEO,SAAS,kBACd,gBACA,KACgB;AAChB,QAAM,EAAE,YAAY,SAAS,gBAAgB,SAAS,CAAC,EAAE,IAAI;AAE7D,MAAI,CAAC,WAAY,IAAW,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,KACA;AACA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AN,MAAgC;AAAA,EAG9B,YAAY,OAAgB;AAC1B,SAAK,QAAQ;AAAA,EACf;AACF;AAEO,IAAMA,QAAY;AAAA;AAAA,EAEvB,KAAK;AAAA,IACH,gBACE;AAAA,IACF,uBACE;AAAA,EACJ;AACF;;;AClCO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,IAAI,GAAG;AACzC,UAAM,SAAS,UAAU,eAAe,GAAG;AAE3C,QAAI,CAAC,EAAW,OAAO,UAAU,CAAC,CAAa,EAAG,QAAO;AAEzD,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,EAAE,QAAQ,WAAW,IAAI,GAAG;AAC5C,WAAO,MAAM,KAAK,OAAO,EAAE,QAAQ,WAAW,IAAI,CAAC;AAAA,EACrD;AACF;;;AC3BA,IAAAC,oBAAA;AAAA,SAAAA,mBAAA;AAAA;AAAA;","names":["push","examples_exports"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/server-destination-aws",
3
3
  "description": "AWS server destination for walkerOS",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@aws-sdk/client-firehose": "^3.606.0",
34
- "@walkeros/server-core": "0.1.1"
34
+ "@walkeros/server-core": "0.2.0"
35
35
  },
36
36
  "devDependencies": {},
37
37
  "repository": {