@walkeros/server-destination-aws 0.1.2 → 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.
- package/dist/examples/index.d.mts +23 -0
- package/dist/examples/index.d.ts +23 -0
- package/dist/examples/index.js +34 -0
- package/dist/examples/index.mjs +40 -0
- package/dist/index.d.mts +31 -14
- package/dist/index.d.ts +31 -14
- 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/package.json +2 -2
|
@@ -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 };
|
package/dist/examples/index.js
CHANGED
|
@@ -26,6 +26,40 @@ 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
|
+
});
|
|
32
|
+
|
|
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
|
+
};
|
|
29
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
64
|
0 && (module.exports = {
|
|
31
65
|
firehose
|
package/dist/examples/index.mjs
CHANGED
|
@@ -1,5 +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
|
+
});
|
|
12
|
+
|
|
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
|
+
};
|
|
3
43
|
export {
|
|
4
44
|
examples_exports as firehose
|
|
5
45
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,21 +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
|
-
interface Destination extends DestinationServer.Destination<Settings, Mapping> {
|
|
6
|
-
init: DestinationServer.InitFn<Settings, Mapping>;
|
|
7
|
-
}
|
|
8
|
-
type Config = {
|
|
9
|
-
settings: Settings;
|
|
10
|
-
} & DestinationServer.Config<Settings, Mapping>;
|
|
11
5
|
interface Settings {
|
|
12
6
|
firehose?: FirehoseConfig;
|
|
13
7
|
}
|
|
14
8
|
interface Mapping {
|
|
15
9
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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>;
|
|
19
26
|
type PushEvents = DestinationServer.PushEvents<Mapping>;
|
|
20
27
|
type Rule = Mapping$1.Rule<Mapping>;
|
|
21
28
|
type Rules = Mapping$1.Rules<Rule>;
|
|
@@ -28,6 +35,7 @@ interface FirehoseConfig {
|
|
|
28
35
|
|
|
29
36
|
type index$2_Config = Config;
|
|
30
37
|
type index$2_Destination = Destination;
|
|
38
|
+
type index$2_Env = Env;
|
|
31
39
|
type index$2_FirehoseConfig = FirehoseConfig;
|
|
32
40
|
type index$2_InitFn = InitFn;
|
|
33
41
|
type index$2_Mapping = Mapping;
|
|
@@ -37,16 +45,25 @@ type index$2_PushFn = PushFn;
|
|
|
37
45
|
type index$2_Rule = Rule;
|
|
38
46
|
type index$2_Rules = Rules;
|
|
39
47
|
type index$2_Settings = Settings;
|
|
48
|
+
type index$2_Types = Types;
|
|
40
49
|
declare namespace index$2 {
|
|
41
|
-
export type { index$2_Config as Config, index$2_Destination as Destination, 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 };
|
|
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 };
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
declare const
|
|
53
|
+
declare const push: Env;
|
|
54
|
+
|
|
55
|
+
declare const env_push: typeof push;
|
|
56
|
+
declare namespace env {
|
|
57
|
+
export { env_push as push };
|
|
58
|
+
}
|
|
45
59
|
|
|
60
|
+
declare const index$1_env: typeof env;
|
|
46
61
|
declare namespace index$1 {
|
|
47
|
-
export {
|
|
62
|
+
export { index$1_env as env };
|
|
48
63
|
}
|
|
49
64
|
|
|
65
|
+
declare const destinationFirehose: Destination;
|
|
66
|
+
|
|
50
67
|
declare namespace index {
|
|
51
68
|
export { index$1 as firehose };
|
|
52
69
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +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
|
-
interface Destination extends DestinationServer.Destination<Settings, Mapping> {
|
|
6
|
-
init: DestinationServer.InitFn<Settings, Mapping>;
|
|
7
|
-
}
|
|
8
|
-
type Config = {
|
|
9
|
-
settings: Settings;
|
|
10
|
-
} & DestinationServer.Config<Settings, Mapping>;
|
|
11
5
|
interface Settings {
|
|
12
6
|
firehose?: FirehoseConfig;
|
|
13
7
|
}
|
|
14
8
|
interface Mapping {
|
|
15
9
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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>;
|
|
19
26
|
type PushEvents = DestinationServer.PushEvents<Mapping>;
|
|
20
27
|
type Rule = Mapping$1.Rule<Mapping>;
|
|
21
28
|
type Rules = Mapping$1.Rules<Rule>;
|
|
@@ -28,6 +35,7 @@ interface FirehoseConfig {
|
|
|
28
35
|
|
|
29
36
|
type index$2_Config = Config;
|
|
30
37
|
type index$2_Destination = Destination;
|
|
38
|
+
type index$2_Env = Env;
|
|
31
39
|
type index$2_FirehoseConfig = FirehoseConfig;
|
|
32
40
|
type index$2_InitFn = InitFn;
|
|
33
41
|
type index$2_Mapping = Mapping;
|
|
@@ -37,16 +45,25 @@ type index$2_PushFn = PushFn;
|
|
|
37
45
|
type index$2_Rule = Rule;
|
|
38
46
|
type index$2_Rules = Rules;
|
|
39
47
|
type index$2_Settings = Settings;
|
|
48
|
+
type index$2_Types = Types;
|
|
40
49
|
declare namespace index$2 {
|
|
41
|
-
export type { index$2_Config as Config, index$2_Destination as Destination, 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 };
|
|
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 };
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
declare const
|
|
53
|
+
declare const push: Env;
|
|
54
|
+
|
|
55
|
+
declare const env_push: typeof push;
|
|
56
|
+
declare namespace env {
|
|
57
|
+
export { env_push as push };
|
|
58
|
+
}
|
|
45
59
|
|
|
60
|
+
declare const index$1_env: typeof env;
|
|
46
61
|
declare namespace index$1 {
|
|
47
|
-
export {
|
|
62
|
+
export { index$1_env as env };
|
|
48
63
|
}
|
|
49
64
|
|
|
65
|
+
declare const destinationFirehose: Destination;
|
|
66
|
+
|
|
50
67
|
declare namespace index {
|
|
51
68
|
export { index$1 as firehose };
|
|
52
69
|
}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t
|
|
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/examples/
|
|
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,S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G,UAAU,GAAG;AAErD;AACF;;;ACTA;;;ACAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA,cAAAC;AAAA;AAUA,IAAM,qBAAN,MAAyB;AAAA,EAGvB,YAAY,QAAkB;AAC5B,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAM,KAAK,SAAkB;AAE3B,WAAO;AAAA,MACL,UAAU;AAAA,MACV,kBAAkB;AAAA,QAChB,WAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;AAGA,IAAM,4BAAN,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":["examples_exports","push","examples_exports"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e
|
|
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
|
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","../src/examples/
|
|
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,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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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.
|
|
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.
|
|
34
|
+
"@walkeros/server-core": "0.2.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {},
|
|
37
37
|
"repository": {
|