@walkeros/server-destination-aws 0.4.0 → 0.4.1

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/index.d.mts CHANGED
@@ -5,6 +5,7 @@ import { FirehoseClient, FirehoseClientConfig, PutRecordBatchCommand } from '@aw
5
5
  interface Settings {
6
6
  firehose?: FirehoseConfig;
7
7
  }
8
+ type InitSettings = Partial<Settings>;
8
9
  interface Mapping {
9
10
  }
10
11
  interface Env extends DestinationServer.Env {
@@ -13,7 +14,7 @@ interface Env extends DestinationServer.Env {
13
14
  PutRecordBatchCommand: typeof PutRecordBatchCommand;
14
15
  };
15
16
  }
16
- type Types = Destination$1.Types<Settings, Mapping, Env>;
17
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
17
18
  interface Destination extends DestinationServer.Destination<Types> {
18
19
  init: DestinationServer.InitFn<Types>;
19
20
  }
@@ -38,6 +39,7 @@ type index_Destination = Destination;
38
39
  type index_Env = Env;
39
40
  type index_FirehoseConfig = FirehoseConfig;
40
41
  type index_InitFn = InitFn;
42
+ type index_InitSettings = InitSettings;
41
43
  type index_Mapping = Mapping;
42
44
  type index_PartialConfig = PartialConfig;
43
45
  type index_PushEvents = PushEvents;
@@ -47,7 +49,7 @@ type index_Rules = Rules;
47
49
  type index_Settings = Settings;
48
50
  type index_Types = Types;
49
51
  declare namespace index {
50
- export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_FirehoseConfig as FirehoseConfig, index_InitFn as InitFn, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
52
+ export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_FirehoseConfig as FirehoseConfig, index_InitFn as InitFn, index_InitSettings as InitSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
51
53
  }
52
54
 
53
55
  declare const destinationFirehose: Destination;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { FirehoseClient, FirehoseClientConfig, PutRecordBatchCommand } from '@aw
5
5
  interface Settings {
6
6
  firehose?: FirehoseConfig;
7
7
  }
8
+ type InitSettings = Partial<Settings>;
8
9
  interface Mapping {
9
10
  }
10
11
  interface Env extends DestinationServer.Env {
@@ -13,7 +14,7 @@ interface Env extends DestinationServer.Env {
13
14
  PutRecordBatchCommand: typeof PutRecordBatchCommand;
14
15
  };
15
16
  }
16
- type Types = Destination$1.Types<Settings, Mapping, Env>;
17
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
17
18
  interface Destination extends DestinationServer.Destination<Types> {
18
19
  init: DestinationServer.InitFn<Types>;
19
20
  }
@@ -38,6 +39,7 @@ type index_Destination = Destination;
38
39
  type index_Env = Env;
39
40
  type index_FirehoseConfig = FirehoseConfig;
40
41
  type index_InitFn = InitFn;
42
+ type index_InitSettings = InitSettings;
41
43
  type index_Mapping = Mapping;
42
44
  type index_PartialConfig = PartialConfig;
43
45
  type index_PushEvents = PushEvents;
@@ -47,7 +49,7 @@ type index_Rules = Rules;
47
49
  type index_Settings = Settings;
48
50
  type index_Types = Types;
49
51
  declare namespace index {
50
- export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_FirehoseConfig as FirehoseConfig, index_InitFn as InitFn, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
52
+ export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_FirehoseConfig as FirehoseConfig, index_InitFn as InitFn, index_InitSettings as InitSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types };
51
53
  }
52
54
 
53
55
  declare const destinationFirehose: Destination;
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","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","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 }) {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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;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;AACF;;;AClEO,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,EAAE,QAAQ,WAAW,IAAI,GAAG;AAC7E,QAAM,EAAE,SAAS,IAAI,OAAO,YAAY,CAAC;AAEzC,MAAI,SAAU,cAAa,CAAC,EAAE,MAAM,CAAC,GAAG,UAAU,GAAG;AAErD;AACF;;;ACTA;;;ACQO,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;","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/index.ts"],"sourcesContent":["// AWS Firehose\nexport { destinationFirehose } from './firehose';\nexport * as DestinationFirehose from './firehose/types';\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 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 }) {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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,g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EzC,MAAI,SAAU,cAAa,CAAC,EAAE,MAAM,CAAC,GAAG,UAAU,GAAG;AAErD;AACF;;;ACTA;;;ACQO,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;","names":[]}
@@ -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 } 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","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 }) {\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"],"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,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;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;AACF;;;AClEO,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,EAAE,QAAQ,WAAW,IAAI,GAAG;AAC7E,QAAM,EAAE,SAAS,IAAI,OAAO,YAAY,CAAC;AAEzC,MAAI,SAAU,cAAa,CAAC,EAAE,MAAM,CAAC,GAAG,UAAU,GAAG;AAErD;AACF;;;ACTA;;;ACQO,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;","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/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 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 }) {\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"],"mappings":";;;;;;;;;AAKA,SAAS,i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