@walkeros/server-destination-kafka 3.4.0-next-1776749829492
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/README.md +105 -0
- package/dist/dev.d.mts +276 -0
- package/dist/dev.d.ts +276 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/examples/index.d.mts +163 -0
- package/dist/examples/index.d.ts +163 -0
- package/dist/examples/index.js +234 -0
- package/dist/examples/index.mjs +212 -0
- package/dist/index.d.mts +154 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/dist/walkerOS.json +840 -0
- package/package.json +76 -0
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, KafkaSettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nconst SASLSchema = z.object({\n mechanism: z\n .enum(['plain', 'scram-sha-256', 'scram-sha-512', 'aws', 'oauthbearer'])\n .describe('SASL authentication mechanism.'),\n username: z\n .string()\n .optional()\n .describe('Username for plain/scram mechanisms.'),\n password: z\n .string()\n .optional()\n .describe('Password for plain/scram mechanisms.'),\n accessKeyId: z\n .string()\n .optional()\n .describe('AWS access key ID for IAM auth (mechanism: aws).'),\n secretAccessKey: z\n .string()\n .optional()\n .describe('AWS secret access key for IAM auth (mechanism: aws).'),\n sessionToken: z\n .string()\n .optional()\n .describe('AWS session token for temporary credentials (mechanism: aws).'),\n authorizationIdentity: z\n .string()\n .optional()\n .describe('AWS authorization identity (mechanism: aws).'),\n});\n\nconst RetrySchema = z.object({\n maxRetryTime: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Max total retry wait in ms. Default: 30000.'),\n initialRetryTime: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('First retry delay in ms. Default: 300.'),\n retries: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Max retry count. Default: 5.'),\n});\n\nexport const KafkaSettingsSchema = z.object({\n brokers: z\n .array(z.string().min(1))\n .min(1)\n .describe('Kafka broker addresses (host:port). At least one required.'),\n clientId: z\n .string()\n .optional()\n .describe('Kafka client ID. Default: walkeros.'),\n ssl: z\n .union([z.boolean(), z.record(z.string(), z.unknown())])\n .optional()\n .describe(\n 'TLS configuration. Set true for default TLS, or provide a tls.ConnectionOptions object for mTLS.',\n ),\n sasl: SASLSchema.optional().describe(\n 'SASL authentication config. Required for Confluent Cloud, AWS MSK with IAM, etc.',\n ),\n connectionTimeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Connection timeout in ms. Default: 1000.'),\n requestTimeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Request timeout in ms. Default: 30000.'),\n topic: z.string().min(1).describe('Target Kafka topic name.'),\n acks: z\n .number()\n .int()\n .min(-1)\n .max(1)\n .optional()\n .describe(\n 'Acknowledgement level. -1 = all replicas, 0 = fire-and-forget, 1 = leader only. Default: -1.',\n ),\n timeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Broker response timeout in ms. Default: 30000.'),\n compression: z\n .enum(['none', 'gzip', 'snappy', 'lz4', 'zstd'])\n .optional()\n .describe(\n 'Message compression codec. Default: gzip. Snappy/LZ4/ZSTD require additional npm packages.',\n ),\n idempotent: z\n .boolean()\n .optional()\n .describe(\n 'Enable idempotent producer for exactly-once delivery. Default: false.',\n ),\n allowAutoTopicCreation: z\n .boolean()\n .optional()\n .describe('Allow auto-creation of topics on the broker. Default: false.'),\n key: z\n .string()\n .optional()\n .describe(\n 'Mapping value path for message key derivation (e.g. user.id, data.userId). Default: entity_action.',\n ),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe('Static headers added to every message.'),\n retry: RetrySchema.optional().describe(\n 'Retry configuration for transient failures.',\n ),\n});\n\nexport const SettingsSchema = z.object({\n kafka: KafkaSettingsSchema.describe(\n 'Kafka connection and producer settings.',\n ),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n key: z\n .string()\n .optional()\n .describe(\n 'Override message key mapping path for this rule (e.g. data.id). Takes precedence over settings.kafka.key.',\n ),\n topic: z\n .string()\n .optional()\n .describe(\n 'Override Kafka topic for this rule. Takes precedence over settings.kafka.topic.',\n ),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type {\n Env,\n KafkaClientConstructor,\n KafkaClientMock,\n KafkaProducerMock,\n ProducerRecord,\n ProducerConfig,\n KafkaClientConfig,\n CompressionTypesMap,\n} from '../types';\n\n// Narrow helper type aliases so the mock SDK is typed explicitly without `any`.\ntype ProducerConnect = () => Promise<void>;\ntype ProducerDisconnect = () => Promise<void>;\ntype ProducerSend = (record: ProducerRecord) => Promise<unknown>;\ntype KafkaProducerFactory = (config?: ProducerConfig) => KafkaProducerMock;\n\nconst asyncConnect: ProducerConnect = () => Promise.resolve();\nconst asyncDisconnect: ProducerDisconnect = () => Promise.resolve();\nconst asyncSend: ProducerSend = () => Promise.resolve([]);\n\nfunction createMockProducer(): KafkaProducerMock {\n return {\n connect: asyncConnect,\n disconnect: asyncDisconnect,\n send: asyncSend,\n };\n}\n\nconst mockProducerFactory: KafkaProducerFactory = () => createMockProducer();\n\nclass MockKafkaClient implements KafkaClientMock {\n constructor(_config: KafkaClientConfig) {}\n producer(config?: ProducerConfig): KafkaProducerMock {\n return mockProducerFactory(config);\n }\n}\n\nconst MockKafkaConstructor: KafkaClientConstructor = MockKafkaClient;\n\nconst MockCompressionTypes: CompressionTypesMap = {\n None: 0,\n GZIP: 1,\n Snappy: 2,\n LZ4: 3,\n ZSTD: 4,\n};\n\nexport const push: Env = {\n Kafka: {\n Kafka: MockKafkaConstructor,\n CompressionTypes: MockCompressionTypes,\n },\n};\n\nexport const simulation = ['call:producer.send'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Extended step example that may carry destination-level settings overrides.\n */\nexport type KafkaStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n};\n\n/**\n * Default event -- full WalkerOS.Event serialized as JSON to the configured\n * topic. Message key defaults to entity_action when no key path is set.\n */\nexport const defaultEvent: KafkaStepExample = {\n in: getEvent('page view', {\n timestamp: 1700000100,\n }),\n out: [\n [\n 'producer.send',\n {\n topic: 'walkeros-events',\n messages: [\n {\n key: 'page_view',\n value: 'json:event',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000100',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Mapped event name -- rule.name renames the event, which also changes the\n * default message key when no key mapping is configured.\n */\nexport const mappedEventName: KafkaStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000101,\n }),\n mapping: {\n name: 'purchase',\n },\n out: [\n [\n 'producer.send',\n {\n topic: 'walkeros-events',\n messages: [\n {\n key: 'purchase',\n value: 'json:event',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000101',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Mapped data -- data.map transforms the event payload. Value is the mapped\n * object serialized as JSON.\n */\nexport const mappedData: KafkaStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000102,\n data: { id: 'ORD-400', total: 99.99, currency: 'EUR' },\n }),\n mapping: {\n name: 'purchase',\n data: {\n map: {\n order_id: 'data.id',\n revenue: 'data.total',\n currency: 'data.currency',\n },\n },\n },\n out: [\n [\n 'producer.send',\n {\n topic: 'walkeros-events',\n messages: [\n {\n key: 'purchase',\n value: 'json:data',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000102',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Key from user -- settings.kafka.key path resolves the message key from\n * the event (here user.id).\n */\nexport const keyFromUser: KafkaStepExample = {\n in: getEvent('user signup', {\n timestamp: 1700000103,\n user: { id: 'usr-789' },\n data: { plan: 'pro' },\n }),\n settings: {\n kafka: {\n brokers: ['localhost:9092'],\n topic: 'walkeros-events',\n key: 'user.id',\n },\n },\n out: [\n [\n 'producer.send',\n {\n topic: 'walkeros-events',\n messages: [\n {\n key: 'usr-789',\n value: 'json:event',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000103',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Topic override -- rule.settings.topic routes this rule to a different\n * topic than the destination default.\n */\nexport const topicOverride: KafkaStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000104,\n data: { id: 'ORD-500', total: 42 },\n }),\n mapping: {\n settings: {\n topic: 'orders-stream',\n },\n },\n out: [\n [\n 'producer.send',\n {\n topic: 'orders-stream',\n messages: [\n {\n key: 'order_complete',\n value: 'json:event',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000104',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Ignored event -- mapping.ignore: true produces no producer.send call.\n */\nexport const ignoredEvent: KafkaStepExample = {\n in: getEvent('debug noise', {\n timestamp: 1700000105,\n }),\n mapping: { ignore: true },\n out: [],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AA,MACP,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,QACE,OAAO;AAAA,QACP,UAAU;AAAA,UACR;AAAA,YACE,KAAK;AAAA,YACL,OAAO;AAAA,YACP,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,YAC9C,WAAW;AAAA,UACb;AAAA,QACF;AAAA,QACA,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,gBAAkC;AAAA,EAC7C,QAAI,sBAAS,kBAAkB;AAAA,IAC7B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,GAAG;AAAA,EACnC,CAAC;AAAA,EACD,SAAS;AAAA,IACP,UAAU;AAAA,MACR,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,QACE,OAAO;AAAA,QACP,UAAU;AAAA,UACR;AAAA,YACE,KAAK;AAAA,YACL,OAAO;AAAA,YACP,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,YAC9C,WAAW;AAAA,UACb;AAAA,QACF;AAAA,QACA,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,eAAiC;AAAA,EAC5C,QAAI,sBAAS,eAAe;AAAA,IAC1B,WAAW;AAAA,EACb,CAAC;AAAA,EACD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;","names":["import_dev","import_dev"]}
|
package/dist/dev.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,a)=>{for(var o in a)e(t,o,{get:a[o],enumerable:!0})},a={};t(a,{KafkaSettingsSchema:()=>n,MappingSchema:()=>m,SettingsSchema:()=>c,mapping:()=>l,settings:()=>d});import{zodToSchema as o}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var i=s.object({mechanism:s.enum(["plain","scram-sha-256","scram-sha-512","aws","oauthbearer"]).describe("SASL authentication mechanism."),username:s.string().optional().describe("Username for plain/scram mechanisms."),password:s.string().optional().describe("Password for plain/scram mechanisms."),accessKeyId:s.string().optional().describe("AWS access key ID for IAM auth (mechanism: aws)."),secretAccessKey:s.string().optional().describe("AWS secret access key for IAM auth (mechanism: aws)."),sessionToken:s.string().optional().describe("AWS session token for temporary credentials (mechanism: aws)."),authorizationIdentity:s.string().optional().describe("AWS authorization identity (mechanism: aws).")}),r=s.object({maxRetryTime:s.number().int().positive().optional().describe("Max total retry wait in ms. Default: 30000."),initialRetryTime:s.number().int().positive().optional().describe("First retry delay in ms. Default: 300."),retries:s.number().int().min(0).optional().describe("Max retry count. Default: 5.")}),n=s.object({brokers:s.array(s.string().min(1)).min(1).describe("Kafka broker addresses (host:port). At least one required."),clientId:s.string().optional().describe("Kafka client ID. Default: walkeros."),ssl:s.union([s.boolean(),s.record(s.string(),s.unknown())]).optional().describe("TLS configuration. Set true for default TLS, or provide a tls.ConnectionOptions object for mTLS."),sasl:i.optional().describe("SASL authentication config. Required for Confluent Cloud, AWS MSK with IAM, etc."),connectionTimeout:s.number().int().positive().optional().describe("Connection timeout in ms. Default: 1000."),requestTimeout:s.number().int().positive().optional().describe("Request timeout in ms. Default: 30000."),topic:s.string().min(1).describe("Target Kafka topic name."),acks:s.number().int().min(-1).max(1).optional().describe("Acknowledgement level. -1 = all replicas, 0 = fire-and-forget, 1 = leader only. Default: -1."),timeout:s.number().int().positive().optional().describe("Broker response timeout in ms. Default: 30000."),compression:s.enum(["none","gzip","snappy","lz4","zstd"]).optional().describe("Message compression codec. Default: gzip. Snappy/LZ4/ZSTD require additional npm packages."),idempotent:s.boolean().optional().describe("Enable idempotent producer for exactly-once delivery. Default: false."),allowAutoTopicCreation:s.boolean().optional().describe("Allow auto-creation of topics on the broker. Default: false."),key:s.string().optional().describe("Mapping value path for message key derivation (e.g. user.id, data.userId). Default: entity_action."),headers:s.record(s.string(),s.string()).optional().describe("Static headers added to every message."),retry:r.optional().describe("Retry configuration for transient failures.")}),c=s.object({kafka:n.describe("Kafka connection and producer settings.")});import{z as p}from"@walkeros/core/dev";var m=p.object({key:p.string().optional().describe("Override message key mapping path for this rule (e.g. data.id). Takes precedence over settings.kafka.key."),topic:p.string().optional().describe("Override Kafka topic for this rule. Takes precedence over settings.kafka.topic.")}),d=o(c),l=o(m),u={};t(u,{env:()=>g,step:()=>w});var g={};t(g,{push:()=>y,simulation:()=>h});var k=()=>Promise.resolve(),f=()=>Promise.resolve(),b=()=>Promise.resolve([]);var v=()=>({connect:k,disconnect:f,send:b}),y={Kafka:{Kafka:class{constructor(e){}producer(e){return v()}},CompressionTypes:{None:0,GZIP:1,Snappy:2,LZ4:3,ZSTD:4}}},h=["call:producer.send"],w={};t(w,{defaultEvent:()=>D,ignoredEvent:()=>I,keyFromUser:()=>T,mappedData:()=>A,mappedEventName:()=>j,topicOverride:()=>K});import{getEvent as S}from"@walkeros/core";var D={in:S("page view",{timestamp:1700000100}),out:[["producer.send",{topic:"walkeros-events",messages:[{key:"page_view",value:"json:event",headers:{"content-type":"application/json"},timestamp:"1700000100"}],acks:-1,compression:1}]]},j={in:S("order complete",{timestamp:1700000101}),mapping:{name:"purchase"},out:[["producer.send",{topic:"walkeros-events",messages:[{key:"purchase",value:"json:event",headers:{"content-type":"application/json"},timestamp:"1700000101"}],acks:-1,compression:1}]]},A={in:S("order complete",{timestamp:1700000102,data:{id:"ORD-400",total:99.99,currency:"EUR"}}),mapping:{name:"purchase",data:{map:{order_id:"data.id",revenue:"data.total",currency:"data.currency"}}},out:[["producer.send",{topic:"walkeros-events",messages:[{key:"purchase",value:"json:data",headers:{"content-type":"application/json"},timestamp:"1700000102"}],acks:-1,compression:1}]]},T={in:S("user signup",{timestamp:1700000103,user:{id:"usr-789"},data:{plan:"pro"}}),settings:{kafka:{brokers:["localhost:9092"],topic:"walkeros-events",key:"user.id"}},out:[["producer.send",{topic:"walkeros-events",messages:[{key:"usr-789",value:"json:event",headers:{"content-type":"application/json"},timestamp:"1700000103"}],acks:-1,compression:1}]]},K={in:S("order complete",{timestamp:1700000104,data:{id:"ORD-500",total:42}}),mapping:{settings:{topic:"orders-stream"}},out:[["producer.send",{topic:"orders-stream",messages:[{key:"order_complete",value:"json:event",headers:{"content-type":"application/json"},timestamp:"1700000104"}],acks:-1,compression:1}]]},I={in:S("debug noise",{timestamp:1700000105}),mapping:{ignore:!0},out:[]};export{u as examples,a as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, KafkaSettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nconst SASLSchema = z.object({\n mechanism: z\n .enum(['plain', 'scram-sha-256', 'scram-sha-512', 'aws', 'oauthbearer'])\n .describe('SASL authentication mechanism.'),\n username: z\n .string()\n .optional()\n .describe('Username for plain/scram mechanisms.'),\n password: z\n .string()\n .optional()\n .describe('Password for plain/scram mechanisms.'),\n accessKeyId: z\n .string()\n .optional()\n .describe('AWS access key ID for IAM auth (mechanism: aws).'),\n secretAccessKey: z\n .string()\n .optional()\n .describe('AWS secret access key for IAM auth (mechanism: aws).'),\n sessionToken: z\n .string()\n .optional()\n .describe('AWS session token for temporary credentials (mechanism: aws).'),\n authorizationIdentity: z\n .string()\n .optional()\n .describe('AWS authorization identity (mechanism: aws).'),\n});\n\nconst RetrySchema = z.object({\n maxRetryTime: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Max total retry wait in ms. Default: 30000.'),\n initialRetryTime: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('First retry delay in ms. Default: 300.'),\n retries: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Max retry count. Default: 5.'),\n});\n\nexport const KafkaSettingsSchema = z.object({\n brokers: z\n .array(z.string().min(1))\n .min(1)\n .describe('Kafka broker addresses (host:port). At least one required.'),\n clientId: z\n .string()\n .optional()\n .describe('Kafka client ID. Default: walkeros.'),\n ssl: z\n .union([z.boolean(), z.record(z.string(), z.unknown())])\n .optional()\n .describe(\n 'TLS configuration. Set true for default TLS, or provide a tls.ConnectionOptions object for mTLS.',\n ),\n sasl: SASLSchema.optional().describe(\n 'SASL authentication config. Required for Confluent Cloud, AWS MSK with IAM, etc.',\n ),\n connectionTimeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Connection timeout in ms. Default: 1000.'),\n requestTimeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Request timeout in ms. Default: 30000.'),\n topic: z.string().min(1).describe('Target Kafka topic name.'),\n acks: z\n .number()\n .int()\n .min(-1)\n .max(1)\n .optional()\n .describe(\n 'Acknowledgement level. -1 = all replicas, 0 = fire-and-forget, 1 = leader only. Default: -1.',\n ),\n timeout: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Broker response timeout in ms. Default: 30000.'),\n compression: z\n .enum(['none', 'gzip', 'snappy', 'lz4', 'zstd'])\n .optional()\n .describe(\n 'Message compression codec. Default: gzip. Snappy/LZ4/ZSTD require additional npm packages.',\n ),\n idempotent: z\n .boolean()\n .optional()\n .describe(\n 'Enable idempotent producer for exactly-once delivery. Default: false.',\n ),\n allowAutoTopicCreation: z\n .boolean()\n .optional()\n .describe('Allow auto-creation of topics on the broker. Default: false.'),\n key: z\n .string()\n .optional()\n .describe(\n 'Mapping value path for message key derivation (e.g. user.id, data.userId). Default: entity_action.',\n ),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe('Static headers added to every message.'),\n retry: RetrySchema.optional().describe(\n 'Retry configuration for transient failures.',\n ),\n});\n\nexport const SettingsSchema = z.object({\n kafka: KafkaSettingsSchema.describe(\n 'Kafka connection and producer settings.',\n ),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n key: z\n .string()\n .optional()\n .describe(\n 'Override message key mapping path for this rule (e.g. data.id). Takes precedence over settings.kafka.key.',\n ),\n topic: z\n .string()\n .optional()\n .describe(\n 'Override Kafka topic for this rule. Takes precedence over settings.kafka.topic.',\n ),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type {\n Env,\n KafkaClientConstructor,\n KafkaClientMock,\n KafkaProducerMock,\n ProducerRecord,\n ProducerConfig,\n KafkaClientConfig,\n CompressionTypesMap,\n} from '../types';\n\n// Narrow helper type aliases so the mock SDK is typed explicitly without `any`.\ntype ProducerConnect = () => Promise<void>;\ntype ProducerDisconnect = () => Promise<void>;\ntype ProducerSend = (record: ProducerRecord) => Promise<unknown>;\ntype KafkaProducerFactory = (config?: ProducerConfig) => KafkaProducerMock;\n\nconst asyncConnect: ProducerConnect = () => Promise.resolve();\nconst asyncDisconnect: ProducerDisconnect = () => Promise.resolve();\nconst asyncSend: ProducerSend = () => Promise.resolve([]);\n\nfunction createMockProducer(): KafkaProducerMock {\n return {\n connect: asyncConnect,\n disconnect: asyncDisconnect,\n send: asyncSend,\n };\n}\n\nconst mockProducerFactory: KafkaProducerFactory = () => createMockProducer();\n\nclass MockKafkaClient implements KafkaClientMock {\n constructor(_config: KafkaClientConfig) {}\n producer(config?: ProducerConfig): KafkaProducerMock {\n return mockProducerFactory(config);\n }\n}\n\nconst MockKafkaConstructor: KafkaClientConstructor = MockKafkaClient;\n\nconst MockCompressionTypes: CompressionTypesMap = {\n None: 0,\n GZIP: 1,\n Snappy: 2,\n LZ4: 3,\n ZSTD: 4,\n};\n\nexport const push: Env = {\n Kafka: {\n Kafka: MockKafkaConstructor,\n CompressionTypes: MockCompressionTypes,\n },\n};\n\nexport const simulation = ['call:producer.send'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Extended step example that may carry destination-level settings overrides.\n */\nexport type KafkaStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n};\n\n/**\n * Default event -- full WalkerOS.Event serialized as JSON to the configured\n * topic. Message key defaults to entity_action when no key path is set.\n */\nexport const defaultEvent: KafkaStepExample = {\n in: getEvent('page view', {\n timestamp: 1700000100,\n }),\n out: [\n [\n 'producer.send',\n {\n topic: 'walkeros-events',\n messages: [\n {\n key: 'page_view',\n value: 'json:event',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000100',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Mapped event name -- rule.name renames the event, which also changes the\n * default message key when no key mapping is configured.\n */\nexport const mappedEventName: KafkaStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000101,\n }),\n mapping: {\n name: 'purchase',\n },\n out: [\n [\n 'producer.send',\n {\n topic: 'walkeros-events',\n messages: [\n {\n key: 'purchase',\n value: 'json:event',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000101',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Mapped data -- data.map transforms the event payload. Value is the mapped\n * object serialized as JSON.\n */\nexport const mappedData: KafkaStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000102,\n data: { id: 'ORD-400', total: 99.99, currency: 'EUR' },\n }),\n mapping: {\n name: 'purchase',\n data: {\n map: {\n order_id: 'data.id',\n revenue: 'data.total',\n currency: 'data.currency',\n },\n },\n },\n out: [\n [\n 'producer.send',\n {\n topic: 'walkeros-events',\n messages: [\n {\n key: 'purchase',\n value: 'json:data',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000102',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Key from user -- settings.kafka.key path resolves the message key from\n * the event (here user.id).\n */\nexport const keyFromUser: KafkaStepExample = {\n in: getEvent('user signup', {\n timestamp: 1700000103,\n user: { id: 'usr-789' },\n data: { plan: 'pro' },\n }),\n settings: {\n kafka: {\n brokers: ['localhost:9092'],\n topic: 'walkeros-events',\n key: 'user.id',\n },\n },\n out: [\n [\n 'producer.send',\n {\n topic: 'walkeros-events',\n messages: [\n {\n key: 'usr-789',\n value: 'json:event',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000103',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Topic override -- rule.settings.topic routes this rule to a different\n * topic than the destination default.\n */\nexport const topicOverride: KafkaStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000104,\n data: { id: 'ORD-500', total: 42 },\n }),\n mapping: {\n settings: {\n topic: 'orders-stream',\n },\n },\n out: [\n [\n 'producer.send',\n {\n topic: 'orders-stream',\n messages: [\n {\n key: 'order_complete',\n value: 'json:event',\n headers: { 'content-type': 'application/json' },\n timestamp: '1700000104',\n },\n ],\n acks: -1,\n compression: 1,\n },\n ],\n ],\n};\n\n/**\n * Ignored event -- mapping.ignore: true produces no producer.send call.\n */\nexport const ignoredEvent: KafkaStepExample = {\n in: getEvent('debug noise', {\n timestamp: 1700000105,\n }),\n mapping: { ignore: true },\n out: [],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAElB,IAAM,aAAa,EAAE,OAAO;AAAA,EAC1B,WAAW,EACR,KAAK,CAAC,SAAS,iBAAiB,iBAAiB,OAAO,aAAa,CAAC,EACtE,SAAS,gCAAgC;AAAA,EAC5C,UAAU,EACP,OAAO,EACP,SAAS,EACT,SAAS,sCAAsC;AAAA,EAClD,UAAU,EACP,OAAO,EACP,SAAS,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,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,gBAAkC;AAAA,EAC7C,IAAI,SAAS,kBAAkB;AAAA,IAC7B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,GAAG;AAAA,EACnC,CAAC;AAAA,EACD,SAAS;AAAA,IACP,UAAU;AAAA,MACR,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,QACE,OAAO;AAAA,QACP,UAAU;AAAA,UACR;AAAA,YACE,KAAK;AAAA,YACL,OAAO;AAAA,YACP,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,YAC9C,WAAW;AAAA,UACb;AAAA,QACF;AAAA,QACA,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,eAAiC;AAAA,EAC5C,IAAI,SAAS,eAAe;AAAA,IAC1B,WAAW;AAAA,EACb,CAAC;AAAA,EACD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;","names":["z"]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
2
|
+
import { Flow } from '@walkeros/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mock-friendly Producer interface used by the destination.
|
|
6
|
+
* Tests provide this via env.Kafka; production creates a real
|
|
7
|
+
* kafkajs Producer and adapts it through settings._producer.
|
|
8
|
+
*/
|
|
9
|
+
interface KafkaProducerMock {
|
|
10
|
+
connect: () => Promise<void>;
|
|
11
|
+
disconnect: () => Promise<void>;
|
|
12
|
+
send: (record: ProducerRecord) => Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Mock-friendly Kafka client interface (subset of kafkajs.Kafka).
|
|
16
|
+
*/
|
|
17
|
+
interface KafkaClientMock {
|
|
18
|
+
producer: (config?: ProducerConfig) => KafkaProducerMock;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Constructor signature for the Kafka client. Accepts a config
|
|
22
|
+
* object and returns a client with producer() factory.
|
|
23
|
+
*/
|
|
24
|
+
type KafkaClientConstructor = new (config: KafkaClientConfig) => KafkaClientMock;
|
|
25
|
+
interface KafkaClientConfig {
|
|
26
|
+
clientId?: string;
|
|
27
|
+
brokers: string[];
|
|
28
|
+
ssl?: boolean | Record<string, unknown>;
|
|
29
|
+
sasl?: SASLConfig;
|
|
30
|
+
connectionTimeout?: number;
|
|
31
|
+
requestTimeout?: number;
|
|
32
|
+
retry?: RetryConfig;
|
|
33
|
+
}
|
|
34
|
+
interface ProducerConfig {
|
|
35
|
+
allowAutoTopicCreation?: boolean;
|
|
36
|
+
idempotent?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface ProducerRecord {
|
|
39
|
+
topic: string;
|
|
40
|
+
messages: ProducerMessage[];
|
|
41
|
+
acks?: number;
|
|
42
|
+
compression?: number;
|
|
43
|
+
timeout?: number;
|
|
44
|
+
}
|
|
45
|
+
interface ProducerMessage {
|
|
46
|
+
key?: string;
|
|
47
|
+
value: string;
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
timestamp?: string;
|
|
50
|
+
partition?: number;
|
|
51
|
+
}
|
|
52
|
+
interface CompressionTypesMap {
|
|
53
|
+
None: number;
|
|
54
|
+
GZIP: number;
|
|
55
|
+
Snappy: number;
|
|
56
|
+
LZ4: number;
|
|
57
|
+
ZSTD: number;
|
|
58
|
+
}
|
|
59
|
+
type CompressionType = 'none' | 'gzip' | 'snappy' | 'lz4' | 'zstd';
|
|
60
|
+
interface SASLConfig {
|
|
61
|
+
mechanism: 'plain' | 'scram-sha-256' | 'scram-sha-512' | 'aws' | 'oauthbearer';
|
|
62
|
+
username?: string;
|
|
63
|
+
password?: string;
|
|
64
|
+
accessKeyId?: string;
|
|
65
|
+
secretAccessKey?: string;
|
|
66
|
+
sessionToken?: string;
|
|
67
|
+
authorizationIdentity?: string;
|
|
68
|
+
}
|
|
69
|
+
interface RetryConfig {
|
|
70
|
+
maxRetryTime?: number;
|
|
71
|
+
initialRetryTime?: number;
|
|
72
|
+
retries?: number;
|
|
73
|
+
}
|
|
74
|
+
interface KafkaSettings {
|
|
75
|
+
brokers: string[];
|
|
76
|
+
clientId?: string;
|
|
77
|
+
ssl?: boolean | Record<string, unknown>;
|
|
78
|
+
sasl?: SASLConfig;
|
|
79
|
+
connectionTimeout?: number;
|
|
80
|
+
requestTimeout?: number;
|
|
81
|
+
topic: string;
|
|
82
|
+
acks?: number;
|
|
83
|
+
timeout?: number;
|
|
84
|
+
compression?: CompressionType;
|
|
85
|
+
idempotent?: boolean;
|
|
86
|
+
allowAutoTopicCreation?: boolean;
|
|
87
|
+
key?: string;
|
|
88
|
+
headers?: Record<string, string>;
|
|
89
|
+
retry?: RetryConfig;
|
|
90
|
+
_producer?: KafkaProducerMock;
|
|
91
|
+
}
|
|
92
|
+
interface Settings {
|
|
93
|
+
kafka: KafkaSettings;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Env -- optional Kafka SDK override. Production leaves this undefined
|
|
97
|
+
* and the destination creates real Kafka client instances. Tests provide
|
|
98
|
+
* mocks via env.Kafka.
|
|
99
|
+
*/
|
|
100
|
+
interface Env extends DestinationServer.Env {
|
|
101
|
+
Kafka?: {
|
|
102
|
+
Kafka: KafkaClientConstructor;
|
|
103
|
+
CompressionTypes: CompressionTypesMap;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare const push: Env;
|
|
108
|
+
declare const simulation: string[];
|
|
109
|
+
|
|
110
|
+
declare const env_push: typeof push;
|
|
111
|
+
declare const env_simulation: typeof simulation;
|
|
112
|
+
declare namespace env {
|
|
113
|
+
export { env_push as push, env_simulation as simulation };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Extended step example that may carry destination-level settings overrides.
|
|
118
|
+
*/
|
|
119
|
+
type KafkaStepExample = Flow.StepExample & {
|
|
120
|
+
settings?: Partial<Settings>;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Default event -- full WalkerOS.Event serialized as JSON to the configured
|
|
124
|
+
* topic. Message key defaults to entity_action when no key path is set.
|
|
125
|
+
*/
|
|
126
|
+
declare const defaultEvent: KafkaStepExample;
|
|
127
|
+
/**
|
|
128
|
+
* Mapped event name -- rule.name renames the event, which also changes the
|
|
129
|
+
* default message key when no key mapping is configured.
|
|
130
|
+
*/
|
|
131
|
+
declare const mappedEventName: KafkaStepExample;
|
|
132
|
+
/**
|
|
133
|
+
* Mapped data -- data.map transforms the event payload. Value is the mapped
|
|
134
|
+
* object serialized as JSON.
|
|
135
|
+
*/
|
|
136
|
+
declare const mappedData: KafkaStepExample;
|
|
137
|
+
/**
|
|
138
|
+
* Key from user -- settings.kafka.key path resolves the message key from
|
|
139
|
+
* the event (here user.id).
|
|
140
|
+
*/
|
|
141
|
+
declare const keyFromUser: KafkaStepExample;
|
|
142
|
+
/**
|
|
143
|
+
* Topic override -- rule.settings.topic routes this rule to a different
|
|
144
|
+
* topic than the destination default.
|
|
145
|
+
*/
|
|
146
|
+
declare const topicOverride: KafkaStepExample;
|
|
147
|
+
/**
|
|
148
|
+
* Ignored event -- mapping.ignore: true produces no producer.send call.
|
|
149
|
+
*/
|
|
150
|
+
declare const ignoredEvent: KafkaStepExample;
|
|
151
|
+
|
|
152
|
+
type step_KafkaStepExample = KafkaStepExample;
|
|
153
|
+
declare const step_defaultEvent: typeof defaultEvent;
|
|
154
|
+
declare const step_ignoredEvent: typeof ignoredEvent;
|
|
155
|
+
declare const step_keyFromUser: typeof keyFromUser;
|
|
156
|
+
declare const step_mappedData: typeof mappedData;
|
|
157
|
+
declare const step_mappedEventName: typeof mappedEventName;
|
|
158
|
+
declare const step_topicOverride: typeof topicOverride;
|
|
159
|
+
declare namespace step {
|
|
160
|
+
export { type step_KafkaStepExample as KafkaStepExample, step_defaultEvent as defaultEvent, step_ignoredEvent as ignoredEvent, step_keyFromUser as keyFromUser, step_mappedData as mappedData, step_mappedEventName as mappedEventName, step_topicOverride as topicOverride };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export { env, step };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
2
|
+
import { Flow } from '@walkeros/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mock-friendly Producer interface used by the destination.
|
|
6
|
+
* Tests provide this via env.Kafka; production creates a real
|
|
7
|
+
* kafkajs Producer and adapts it through settings._producer.
|
|
8
|
+
*/
|
|
9
|
+
interface KafkaProducerMock {
|
|
10
|
+
connect: () => Promise<void>;
|
|
11
|
+
disconnect: () => Promise<void>;
|
|
12
|
+
send: (record: ProducerRecord) => Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Mock-friendly Kafka client interface (subset of kafkajs.Kafka).
|
|
16
|
+
*/
|
|
17
|
+
interface KafkaClientMock {
|
|
18
|
+
producer: (config?: ProducerConfig) => KafkaProducerMock;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Constructor signature for the Kafka client. Accepts a config
|
|
22
|
+
* object and returns a client with producer() factory.
|
|
23
|
+
*/
|
|
24
|
+
type KafkaClientConstructor = new (config: KafkaClientConfig) => KafkaClientMock;
|
|
25
|
+
interface KafkaClientConfig {
|
|
26
|
+
clientId?: string;
|
|
27
|
+
brokers: string[];
|
|
28
|
+
ssl?: boolean | Record<string, unknown>;
|
|
29
|
+
sasl?: SASLConfig;
|
|
30
|
+
connectionTimeout?: number;
|
|
31
|
+
requestTimeout?: number;
|
|
32
|
+
retry?: RetryConfig;
|
|
33
|
+
}
|
|
34
|
+
interface ProducerConfig {
|
|
35
|
+
allowAutoTopicCreation?: boolean;
|
|
36
|
+
idempotent?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface ProducerRecord {
|
|
39
|
+
topic: string;
|
|
40
|
+
messages: ProducerMessage[];
|
|
41
|
+
acks?: number;
|
|
42
|
+
compression?: number;
|
|
43
|
+
timeout?: number;
|
|
44
|
+
}
|
|
45
|
+
interface ProducerMessage {
|
|
46
|
+
key?: string;
|
|
47
|
+
value: string;
|
|
48
|
+
headers?: Record<string, string>;
|
|
49
|
+
timestamp?: string;
|
|
50
|
+
partition?: number;
|
|
51
|
+
}
|
|
52
|
+
interface CompressionTypesMap {
|
|
53
|
+
None: number;
|
|
54
|
+
GZIP: number;
|
|
55
|
+
Snappy: number;
|
|
56
|
+
LZ4: number;
|
|
57
|
+
ZSTD: number;
|
|
58
|
+
}
|
|
59
|
+
type CompressionType = 'none' | 'gzip' | 'snappy' | 'lz4' | 'zstd';
|
|
60
|
+
interface SASLConfig {
|
|
61
|
+
mechanism: 'plain' | 'scram-sha-256' | 'scram-sha-512' | 'aws' | 'oauthbearer';
|
|
62
|
+
username?: string;
|
|
63
|
+
password?: string;
|
|
64
|
+
accessKeyId?: string;
|
|
65
|
+
secretAccessKey?: string;
|
|
66
|
+
sessionToken?: string;
|
|
67
|
+
authorizationIdentity?: string;
|
|
68
|
+
}
|
|
69
|
+
interface RetryConfig {
|
|
70
|
+
maxRetryTime?: number;
|
|
71
|
+
initialRetryTime?: number;
|
|
72
|
+
retries?: number;
|
|
73
|
+
}
|
|
74
|
+
interface KafkaSettings {
|
|
75
|
+
brokers: string[];
|
|
76
|
+
clientId?: string;
|
|
77
|
+
ssl?: boolean | Record<string, unknown>;
|
|
78
|
+
sasl?: SASLConfig;
|
|
79
|
+
connectionTimeout?: number;
|
|
80
|
+
requestTimeout?: number;
|
|
81
|
+
topic: string;
|
|
82
|
+
acks?: number;
|
|
83
|
+
timeout?: number;
|
|
84
|
+
compression?: CompressionType;
|
|
85
|
+
idempotent?: boolean;
|
|
86
|
+
allowAutoTopicCreation?: boolean;
|
|
87
|
+
key?: string;
|
|
88
|
+
headers?: Record<string, string>;
|
|
89
|
+
retry?: RetryConfig;
|
|
90
|
+
_producer?: KafkaProducerMock;
|
|
91
|
+
}
|
|
92
|
+
interface Settings {
|
|
93
|
+
kafka: KafkaSettings;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Env -- optional Kafka SDK override. Production leaves this undefined
|
|
97
|
+
* and the destination creates real Kafka client instances. Tests provide
|
|
98
|
+
* mocks via env.Kafka.
|
|
99
|
+
*/
|
|
100
|
+
interface Env extends DestinationServer.Env {
|
|
101
|
+
Kafka?: {
|
|
102
|
+
Kafka: KafkaClientConstructor;
|
|
103
|
+
CompressionTypes: CompressionTypesMap;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare const push: Env;
|
|
108
|
+
declare const simulation: string[];
|
|
109
|
+
|
|
110
|
+
declare const env_push: typeof push;
|
|
111
|
+
declare const env_simulation: typeof simulation;
|
|
112
|
+
declare namespace env {
|
|
113
|
+
export { env_push as push, env_simulation as simulation };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Extended step example that may carry destination-level settings overrides.
|
|
118
|
+
*/
|
|
119
|
+
type KafkaStepExample = Flow.StepExample & {
|
|
120
|
+
settings?: Partial<Settings>;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Default event -- full WalkerOS.Event serialized as JSON to the configured
|
|
124
|
+
* topic. Message key defaults to entity_action when no key path is set.
|
|
125
|
+
*/
|
|
126
|
+
declare const defaultEvent: KafkaStepExample;
|
|
127
|
+
/**
|
|
128
|
+
* Mapped event name -- rule.name renames the event, which also changes the
|
|
129
|
+
* default message key when no key mapping is configured.
|
|
130
|
+
*/
|
|
131
|
+
declare const mappedEventName: KafkaStepExample;
|
|
132
|
+
/**
|
|
133
|
+
* Mapped data -- data.map transforms the event payload. Value is the mapped
|
|
134
|
+
* object serialized as JSON.
|
|
135
|
+
*/
|
|
136
|
+
declare const mappedData: KafkaStepExample;
|
|
137
|
+
/**
|
|
138
|
+
* Key from user -- settings.kafka.key path resolves the message key from
|
|
139
|
+
* the event (here user.id).
|
|
140
|
+
*/
|
|
141
|
+
declare const keyFromUser: KafkaStepExample;
|
|
142
|
+
/**
|
|
143
|
+
* Topic override -- rule.settings.topic routes this rule to a different
|
|
144
|
+
* topic than the destination default.
|
|
145
|
+
*/
|
|
146
|
+
declare const topicOverride: KafkaStepExample;
|
|
147
|
+
/**
|
|
148
|
+
* Ignored event -- mapping.ignore: true produces no producer.send call.
|
|
149
|
+
*/
|
|
150
|
+
declare const ignoredEvent: KafkaStepExample;
|
|
151
|
+
|
|
152
|
+
type step_KafkaStepExample = KafkaStepExample;
|
|
153
|
+
declare const step_defaultEvent: typeof defaultEvent;
|
|
154
|
+
declare const step_ignoredEvent: typeof ignoredEvent;
|
|
155
|
+
declare const step_keyFromUser: typeof keyFromUser;
|
|
156
|
+
declare const step_mappedData: typeof mappedData;
|
|
157
|
+
declare const step_mappedEventName: typeof mappedEventName;
|
|
158
|
+
declare const step_topicOverride: typeof topicOverride;
|
|
159
|
+
declare namespace step {
|
|
160
|
+
export { type step_KafkaStepExample as KafkaStepExample, step_defaultEvent as defaultEvent, step_ignoredEvent as ignoredEvent, step_keyFromUser as keyFromUser, step_mappedData as mappedData, step_mappedEventName as mappedEventName, step_topicOverride as topicOverride };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export { env, step };
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/examples/index.ts
|
|
21
|
+
var examples_exports = {};
|
|
22
|
+
__export(examples_exports, {
|
|
23
|
+
env: () => env_exports,
|
|
24
|
+
step: () => step_exports
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(examples_exports);
|
|
27
|
+
|
|
28
|
+
// src/examples/env.ts
|
|
29
|
+
var env_exports = {};
|
|
30
|
+
__export(env_exports, {
|
|
31
|
+
push: () => push,
|
|
32
|
+
simulation: () => simulation
|
|
33
|
+
});
|
|
34
|
+
var asyncConnect = () => Promise.resolve();
|
|
35
|
+
var asyncDisconnect = () => Promise.resolve();
|
|
36
|
+
var asyncSend = () => Promise.resolve([]);
|
|
37
|
+
function createMockProducer() {
|
|
38
|
+
return {
|
|
39
|
+
connect: asyncConnect,
|
|
40
|
+
disconnect: asyncDisconnect,
|
|
41
|
+
send: asyncSend
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
var mockProducerFactory = () => createMockProducer();
|
|
45
|
+
var MockKafkaClient = class {
|
|
46
|
+
constructor(_config) {
|
|
47
|
+
}
|
|
48
|
+
producer(config) {
|
|
49
|
+
return mockProducerFactory(config);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var MockKafkaConstructor = MockKafkaClient;
|
|
53
|
+
var MockCompressionTypes = {
|
|
54
|
+
None: 0,
|
|
55
|
+
GZIP: 1,
|
|
56
|
+
Snappy: 2,
|
|
57
|
+
LZ4: 3,
|
|
58
|
+
ZSTD: 4
|
|
59
|
+
};
|
|
60
|
+
var push = {
|
|
61
|
+
Kafka: {
|
|
62
|
+
Kafka: MockKafkaConstructor,
|
|
63
|
+
CompressionTypes: MockCompressionTypes
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var simulation = ["call:producer.send"];
|
|
67
|
+
|
|
68
|
+
// src/examples/step.ts
|
|
69
|
+
var step_exports = {};
|
|
70
|
+
__export(step_exports, {
|
|
71
|
+
defaultEvent: () => defaultEvent,
|
|
72
|
+
ignoredEvent: () => ignoredEvent,
|
|
73
|
+
keyFromUser: () => keyFromUser,
|
|
74
|
+
mappedData: () => mappedData,
|
|
75
|
+
mappedEventName: () => mappedEventName,
|
|
76
|
+
topicOverride: () => topicOverride
|
|
77
|
+
});
|
|
78
|
+
var import_core = require("@walkeros/core");
|
|
79
|
+
var defaultEvent = {
|
|
80
|
+
in: (0, import_core.getEvent)("page view", {
|
|
81
|
+
timestamp: 1700000100
|
|
82
|
+
}),
|
|
83
|
+
out: [
|
|
84
|
+
[
|
|
85
|
+
"producer.send",
|
|
86
|
+
{
|
|
87
|
+
topic: "walkeros-events",
|
|
88
|
+
messages: [
|
|
89
|
+
{
|
|
90
|
+
key: "page_view",
|
|
91
|
+
value: "json:event",
|
|
92
|
+
headers: { "content-type": "application/json" },
|
|
93
|
+
timestamp: "1700000100"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
acks: -1,
|
|
97
|
+
compression: 1
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
var mappedEventName = {
|
|
103
|
+
in: (0, import_core.getEvent)("order complete", {
|
|
104
|
+
timestamp: 1700000101
|
|
105
|
+
}),
|
|
106
|
+
mapping: {
|
|
107
|
+
name: "purchase"
|
|
108
|
+
},
|
|
109
|
+
out: [
|
|
110
|
+
[
|
|
111
|
+
"producer.send",
|
|
112
|
+
{
|
|
113
|
+
topic: "walkeros-events",
|
|
114
|
+
messages: [
|
|
115
|
+
{
|
|
116
|
+
key: "purchase",
|
|
117
|
+
value: "json:event",
|
|
118
|
+
headers: { "content-type": "application/json" },
|
|
119
|
+
timestamp: "1700000101"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
acks: -1,
|
|
123
|
+
compression: 1
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
var mappedData = {
|
|
129
|
+
in: (0, import_core.getEvent)("order complete", {
|
|
130
|
+
timestamp: 1700000102,
|
|
131
|
+
data: { id: "ORD-400", total: 99.99, currency: "EUR" }
|
|
132
|
+
}),
|
|
133
|
+
mapping: {
|
|
134
|
+
name: "purchase",
|
|
135
|
+
data: {
|
|
136
|
+
map: {
|
|
137
|
+
order_id: "data.id",
|
|
138
|
+
revenue: "data.total",
|
|
139
|
+
currency: "data.currency"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
out: [
|
|
144
|
+
[
|
|
145
|
+
"producer.send",
|
|
146
|
+
{
|
|
147
|
+
topic: "walkeros-events",
|
|
148
|
+
messages: [
|
|
149
|
+
{
|
|
150
|
+
key: "purchase",
|
|
151
|
+
value: "json:data",
|
|
152
|
+
headers: { "content-type": "application/json" },
|
|
153
|
+
timestamp: "1700000102"
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
acks: -1,
|
|
157
|
+
compression: 1
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
]
|
|
161
|
+
};
|
|
162
|
+
var keyFromUser = {
|
|
163
|
+
in: (0, import_core.getEvent)("user signup", {
|
|
164
|
+
timestamp: 1700000103,
|
|
165
|
+
user: { id: "usr-789" },
|
|
166
|
+
data: { plan: "pro" }
|
|
167
|
+
}),
|
|
168
|
+
settings: {
|
|
169
|
+
kafka: {
|
|
170
|
+
brokers: ["localhost:9092"],
|
|
171
|
+
topic: "walkeros-events",
|
|
172
|
+
key: "user.id"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
out: [
|
|
176
|
+
[
|
|
177
|
+
"producer.send",
|
|
178
|
+
{
|
|
179
|
+
topic: "walkeros-events",
|
|
180
|
+
messages: [
|
|
181
|
+
{
|
|
182
|
+
key: "usr-789",
|
|
183
|
+
value: "json:event",
|
|
184
|
+
headers: { "content-type": "application/json" },
|
|
185
|
+
timestamp: "1700000103"
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
acks: -1,
|
|
189
|
+
compression: 1
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
]
|
|
193
|
+
};
|
|
194
|
+
var topicOverride = {
|
|
195
|
+
in: (0, import_core.getEvent)("order complete", {
|
|
196
|
+
timestamp: 1700000104,
|
|
197
|
+
data: { id: "ORD-500", total: 42 }
|
|
198
|
+
}),
|
|
199
|
+
mapping: {
|
|
200
|
+
settings: {
|
|
201
|
+
topic: "orders-stream"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
out: [
|
|
205
|
+
[
|
|
206
|
+
"producer.send",
|
|
207
|
+
{
|
|
208
|
+
topic: "orders-stream",
|
|
209
|
+
messages: [
|
|
210
|
+
{
|
|
211
|
+
key: "order_complete",
|
|
212
|
+
value: "json:event",
|
|
213
|
+
headers: { "content-type": "application/json" },
|
|
214
|
+
timestamp: "1700000104"
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
acks: -1,
|
|
218
|
+
compression: 1
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
]
|
|
222
|
+
};
|
|
223
|
+
var ignoredEvent = {
|
|
224
|
+
in: (0, import_core.getEvent)("debug noise", {
|
|
225
|
+
timestamp: 1700000105
|
|
226
|
+
}),
|
|
227
|
+
mapping: { ignore: true },
|
|
228
|
+
out: []
|
|
229
|
+
};
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
env,
|
|
233
|
+
step
|
|
234
|
+
});
|