@walkeros/server-destination-kafka 3.4.0 → 3.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/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.js +11 -0
- package/dist/examples/index.mjs +11 -0
- package/dist/walkerOS.json +19 -8
- package/package.json +4 -4
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(e,a)=>{for(var o in a)t(e,o,{get:a[o],enumerable:!0})},r={};s(r,{examples:()=>b,schemas:()=>n}),module.exports=(e=r,((e,s,r,n)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of o(s))i.call(e,c)||c===r||t(e,c,{get:()=>s[c],enumerable:!(n=a(s,c))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};s(n,{KafkaSettingsSchema:()=>l,MappingSchema:()=>f,SettingsSchema:()=>u,mapping:()=>k,settings:()=>v});var c=require("@walkeros/core/dev"),p=require("@walkeros/core/dev"),d=p.z.object({mechanism:p.z.enum(["plain","scram-sha-256","scram-sha-512","aws","oauthbearer"]).describe("SASL authentication mechanism."),username:p.z.string().optional().describe("Username for plain/scram mechanisms."),password:p.z.string().optional().describe("Password for plain/scram mechanisms."),accessKeyId:p.z.string().optional().describe("AWS access key ID for IAM auth (mechanism: aws)."),secretAccessKey:p.z.string().optional().describe("AWS secret access key for IAM auth (mechanism: aws)."),sessionToken:p.z.string().optional().describe("AWS session token for temporary credentials (mechanism: aws)."),authorizationIdentity:p.z.string().optional().describe("AWS authorization identity (mechanism: aws).")}),m=p.z.object({maxRetryTime:p.z.number().int().positive().optional().describe("Max total retry wait in ms. Default: 30000."),initialRetryTime:p.z.number().int().positive().optional().describe("First retry delay in ms. Default: 300."),retries:p.z.number().int().min(0).optional().describe("Max retry count. Default: 5.")}),l=p.z.object({brokers:p.z.array(p.z.string().min(1)).min(1).describe("Kafka broker addresses (host:port). At least one required."),clientId:p.z.string().optional().describe("Kafka client ID. Default: walkeros."),ssl:p.z.union([p.z.boolean(),p.z.record(p.z.string(),p.z.unknown())]).optional().describe("TLS configuration. Set true for default TLS, or provide a tls.ConnectionOptions object for mTLS."),sasl:d.optional().describe("SASL authentication config. Required for Confluent Cloud, AWS MSK with IAM, etc."),connectionTimeout:p.z.number().int().positive().optional().describe("Connection timeout in ms. Default: 1000."),requestTimeout:p.z.number().int().positive().optional().describe("Request timeout in ms. Default: 30000."),topic:p.z.string().min(1).describe("Target Kafka topic name."),acks:p.z.number().int().min(-1).max(1).optional().describe("Acknowledgement level. -1 = all replicas, 0 = fire-and-forget, 1 = leader only. Default: -1."),timeout:p.z.number().int().positive().optional().describe("Broker response timeout in ms. Default: 30000."),compression:p.z.enum(["none","gzip","snappy","lz4","zstd"]).optional().describe("Message compression codec. Default: gzip. Snappy/LZ4/ZSTD require additional npm packages."),idempotent:p.z.boolean().optional().describe("Enable idempotent producer for exactly-once delivery. Default: false."),allowAutoTopicCreation:p.z.boolean().optional().describe("Allow auto-creation of topics on the broker. Default: false."),key:p.z.string().optional().describe("Mapping value path for message key derivation (e.g. user.id, data.userId). Default: entity_action."),headers:p.z.record(p.z.string(),p.z.string()).optional().describe("Static headers added to every message."),retry:m.optional().describe("Retry configuration for transient failures.")}),u=p.z.object({kafka:l.describe("Kafka connection and producer settings.")}),g=require("@walkeros/core/dev"),f=g.z.object({key:g.z.string().optional().describe("Override message key mapping path for this rule (e.g. data.id). Takes precedence over settings.kafka.key."),topic:g.z.string().optional().describe("Override Kafka topic for this rule. Takes precedence over settings.kafka.topic.")}),v=(0,c.zodToSchema)(u),k=(0,c.zodToSchema)(f),b={};s(b,{env:()=>y,step:()=>A});var y={};s(y,{push:()=>j,simulation:()=>D});var h=()=>Promise.resolve(),z=()=>Promise.resolve(),w=()=>Promise.resolve([]);var S=()=>({connect:h,disconnect:z,send:w}),j={Kafka:{Kafka:class{constructor(e){}producer(e){return S()}},CompressionTypes:{None:0,GZIP:1,Snappy:2,LZ4:3,ZSTD:4}}},D=["call:producer.send"],A={};s(A,{defaultEvent:()=>K,ignoredEvent:()=>q,keyFromUser:()=>M,mappedData:()=>E,mappedEventName:()=>O,topicOverride:()=>I});var T=require("@walkeros/core"),K={title:"Default event",description:"An event is produced to the configured Kafka topic with the full JSON body and entity_action as the message key.",in:(0,T.getEvent)("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}]]},O={title:"Renamed event",description:"A mapping renames the event which also changes the default Kafka message key used for partitioning.",in:(0,T.getEvent)("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}]]},E={title:"Mapped payload",description:"A data mapping transforms the event payload before producing it as the Kafka message value.",in:(0,T.getEvent)("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}]]},M={title:"Key from user id",description:"A settings.kafka.key path resolves the message key from the event, here using user.id for per-user partitioning.",in:(0,T.getEvent)("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}]]},I={title:"Topic override",description:"A mapping rule overrides the destination topic so specific events are routed to a dedicated stream.",in:(0,T.getEvent)("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}]]},q={public:!1,in:(0,T.getEvent)("debug noise",{timestamp:1700000105}),mapping:{ignore:!0},out:[]};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +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;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAElB,IAAM,aAAa,aAAE,OAAO;AAAA,EAC1B,WAAW,aACR,KAAK,CAAC,SAAS,iBAAiB,iBAAiB,OAAO,aAA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K;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"]}
|
|
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 title: 'Default event',\n description:\n 'An event is produced to the configured Kafka topic with the full JSON body and entity_action as the message key.',\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 title: 'Renamed event',\n description:\n 'A mapping renames the event which also changes the default Kafka message key used for partitioning.',\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 title: 'Mapped payload',\n description:\n 'A data mapping transforms the event payload before producing it as the Kafka message value.',\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 title: 'Key from user id',\n description:\n 'A settings.kafka.key path resolves the message key from the event, here using user.id for per-user partitioning.',\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 title: 'Topic override',\n description:\n 'A mapping rule overrides the destination topic so specific events are routed to a dedicated stream.',\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 public: false,\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;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAElB,IAAM,aAAa,aAAE,OAAO;AAAA,EAC1B,WAAW,aACR,KAAK,CAAC,SAAS,iBAAiB,iBAAiB,OAAO,aAAa,CAAC,EACtE,SAAS,gCAAgC;AAAA,EAC5C,UAAU,aACP,OAAO,EACP,SAAS,EACT,SAAS,sCAAsC;AAAA,EAClD,UAAU,aACP,OAAO,EACP,SAAS,EACT,SAAS,sCAAsC;AAAA,EAClD,aAAa,aACV,OAAO,EACP,SAAS,EACT,SAAS,kDAAkD;AAAA,EAC9D,iBAAiB,aACd,OAAO,EACP,SAAS,EACT,SAAS,sDAAsD;AAAA,EAClE,cAAc,aACX,OAAO,EACP,SAAS,EACT,SAAS,+DAA+D;AAAA,EAC3E,uBAAuB,aACpB,OAAO,EACP,SAAS,EACT,SAAS,8CAA8C;AAC5D,CAAC;AAED,IAAM,cAAc,aAAE,OAAO;AAAA,EAC3B,cAAc,aACX,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,EACT,SAAS,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AA,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,QAAQ;AAAA,EACR,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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,a)=>{for(var
|
|
1
|
+
var e=Object.defineProperty,t=(t,a)=>{for(var i in a)e(t,i,{get:a[i],enumerable:!0})},a={};t(a,{KafkaSettingsSchema:()=>n,MappingSchema:()=>d,SettingsSchema:()=>c,mapping:()=>l,settings:()=>m});import{zodToSchema as i}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var o=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:o.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 d=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.")}),m=i(c),l=i(d),u={};t(u,{env:()=>g,step:()=>w});var g={};t(g,{push:()=>b,simulation:()=>y});var f=()=>Promise.resolve(),k=()=>Promise.resolve(),v=()=>Promise.resolve([]);var h=()=>({connect:f,disconnect:k,send:v}),b={Kafka:{Kafka:class{constructor(e){}producer(e){return h()}},CompressionTypes:{None:0,GZIP:1,Snappy:2,LZ4:3,ZSTD:4}}},y=["call:producer.send"],w={};t(w,{defaultEvent:()=>A,ignoredEvent:()=>I,keyFromUser:()=>T,mappedData:()=>j,mappedEventName:()=>D,topicOverride:()=>K});import{getEvent as S}from"@walkeros/core";var A={title:"Default event",description:"An event is produced to the configured Kafka topic with the full JSON body and entity_action as the message key.",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}]]},D={title:"Renamed event",description:"A mapping renames the event which also changes the default Kafka message key used for partitioning.",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}]]},j={title:"Mapped payload",description:"A data mapping transforms the event payload before producing it as the Kafka message value.",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={title:"Key from user id",description:"A settings.kafka.key path resolves the message key from the event, here using user.id for per-user partitioning.",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={title:"Topic override",description:"A mapping rule overrides the destination topic so specific events are routed to a dedicated stream.",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={public:!1,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
CHANGED
|
@@ -1 +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,EACT,SAAS,sCAAsC;AAAA,EAClD,aAAa,EACV,OAAO,EACP,SAAS,EACT,SAAS,kDAAkD;AAAA,EAC9D,iBAAiB,EACd,OAAO,EACP,SAAS,EACT,SAAS,sDAAsD;AAAA,EAClE,cAAc,EACX,OAAO,EAC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AA,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"]}
|
|
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 title: 'Default event',\n description:\n 'An event is produced to the configured Kafka topic with the full JSON body and entity_action as the message key.',\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 title: 'Renamed event',\n description:\n 'A mapping renames the event which also changes the default Kafka message key used for partitioning.',\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 title: 'Mapped payload',\n description:\n 'A data mapping transforms the event payload before producing it as the Kafka message value.',\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 title: 'Key from user id',\n description:\n 'A settings.kafka.key path resolves the message key from the event, here using user.id for per-user partitioning.',\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 title: 'Topic override',\n description:\n 'A mapping rule overrides the destination topic so specific events are routed to a dedicated stream.',\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 public: false,\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,EACT,SAAS,sCAAsC;AAAA,EAClD,aAAa,EACV,OAAO,EACP,SAAS,EACT,SAAS,kDAAkD;AAAA,EAC9D,iBAAiB,EACd,OAAO,EACP,SAAS,EACT,SAAS,sDAAsD;AAAA,EAClE,cAAc,EACX,OAAO,EACP,SAAS,EACT,SAAS,+DAA+D;AAAA,EAC3E,uBAAuB,EACpB,OAAO,EACP,SAAS,EACT,SAAS,8CAA8C;AAC5D,CAAC;AAED,IAAM,cAAc,EAAE,OAAO;AAAA,EAC3B,cAAc,EACX,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,EACT,SAAS,6CAA6C;AAAA,EACzD,kBAAkB,EACf,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,EACT,SAAS,wCAAwC;AAAA,EACpD,SAAS,EACN,OAAO,EACP,IAAI,EACJ,IAAI,CAAC,EACL,SAAS,EACT,SAAS,8BAA8B;AAC5C,CAAC;AAEM,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,SAAS,EACN,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EACvB,IAAI,CAAC,EACL,SAAS,4DAA4D;AAAA,EACxE,UAAU,EACP,OAAO,EACP,SAAS,EACT,SAAS,qCAAqC;AAAA,EACjD,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B,WAAW;AAAA,EACb,CAAC;AAAA,EACD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;","names":["z"]}
|
package/dist/examples/index.js
CHANGED
|
@@ -77,6 +77,8 @@ __export(step_exports, {
|
|
|
77
77
|
});
|
|
78
78
|
var import_core = require("@walkeros/core");
|
|
79
79
|
var defaultEvent = {
|
|
80
|
+
title: "Default event",
|
|
81
|
+
description: "An event is produced to the configured Kafka topic with the full JSON body and entity_action as the message key.",
|
|
80
82
|
in: (0, import_core.getEvent)("page view", {
|
|
81
83
|
timestamp: 1700000100
|
|
82
84
|
}),
|
|
@@ -100,6 +102,8 @@ var defaultEvent = {
|
|
|
100
102
|
]
|
|
101
103
|
};
|
|
102
104
|
var mappedEventName = {
|
|
105
|
+
title: "Renamed event",
|
|
106
|
+
description: "A mapping renames the event which also changes the default Kafka message key used for partitioning.",
|
|
103
107
|
in: (0, import_core.getEvent)("order complete", {
|
|
104
108
|
timestamp: 1700000101
|
|
105
109
|
}),
|
|
@@ -126,6 +130,8 @@ var mappedEventName = {
|
|
|
126
130
|
]
|
|
127
131
|
};
|
|
128
132
|
var mappedData = {
|
|
133
|
+
title: "Mapped payload",
|
|
134
|
+
description: "A data mapping transforms the event payload before producing it as the Kafka message value.",
|
|
129
135
|
in: (0, import_core.getEvent)("order complete", {
|
|
130
136
|
timestamp: 1700000102,
|
|
131
137
|
data: { id: "ORD-400", total: 99.99, currency: "EUR" }
|
|
@@ -160,6 +166,8 @@ var mappedData = {
|
|
|
160
166
|
]
|
|
161
167
|
};
|
|
162
168
|
var keyFromUser = {
|
|
169
|
+
title: "Key from user id",
|
|
170
|
+
description: "A settings.kafka.key path resolves the message key from the event, here using user.id for per-user partitioning.",
|
|
163
171
|
in: (0, import_core.getEvent)("user signup", {
|
|
164
172
|
timestamp: 1700000103,
|
|
165
173
|
user: { id: "usr-789" },
|
|
@@ -192,6 +200,8 @@ var keyFromUser = {
|
|
|
192
200
|
]
|
|
193
201
|
};
|
|
194
202
|
var topicOverride = {
|
|
203
|
+
title: "Topic override",
|
|
204
|
+
description: "A mapping rule overrides the destination topic so specific events are routed to a dedicated stream.",
|
|
195
205
|
in: (0, import_core.getEvent)("order complete", {
|
|
196
206
|
timestamp: 1700000104,
|
|
197
207
|
data: { id: "ORD-500", total: 42 }
|
|
@@ -221,6 +231,7 @@ var topicOverride = {
|
|
|
221
231
|
]
|
|
222
232
|
};
|
|
223
233
|
var ignoredEvent = {
|
|
234
|
+
public: false,
|
|
224
235
|
in: (0, import_core.getEvent)("debug noise", {
|
|
225
236
|
timestamp: 1700000105
|
|
226
237
|
}),
|
package/dist/examples/index.mjs
CHANGED
|
@@ -56,6 +56,8 @@ __export(step_exports, {
|
|
|
56
56
|
});
|
|
57
57
|
import { getEvent } from "@walkeros/core";
|
|
58
58
|
var defaultEvent = {
|
|
59
|
+
title: "Default event",
|
|
60
|
+
description: "An event is produced to the configured Kafka topic with the full JSON body and entity_action as the message key.",
|
|
59
61
|
in: getEvent("page view", {
|
|
60
62
|
timestamp: 1700000100
|
|
61
63
|
}),
|
|
@@ -79,6 +81,8 @@ var defaultEvent = {
|
|
|
79
81
|
]
|
|
80
82
|
};
|
|
81
83
|
var mappedEventName = {
|
|
84
|
+
title: "Renamed event",
|
|
85
|
+
description: "A mapping renames the event which also changes the default Kafka message key used for partitioning.",
|
|
82
86
|
in: getEvent("order complete", {
|
|
83
87
|
timestamp: 1700000101
|
|
84
88
|
}),
|
|
@@ -105,6 +109,8 @@ var mappedEventName = {
|
|
|
105
109
|
]
|
|
106
110
|
};
|
|
107
111
|
var mappedData = {
|
|
112
|
+
title: "Mapped payload",
|
|
113
|
+
description: "A data mapping transforms the event payload before producing it as the Kafka message value.",
|
|
108
114
|
in: getEvent("order complete", {
|
|
109
115
|
timestamp: 1700000102,
|
|
110
116
|
data: { id: "ORD-400", total: 99.99, currency: "EUR" }
|
|
@@ -139,6 +145,8 @@ var mappedData = {
|
|
|
139
145
|
]
|
|
140
146
|
};
|
|
141
147
|
var keyFromUser = {
|
|
148
|
+
title: "Key from user id",
|
|
149
|
+
description: "A settings.kafka.key path resolves the message key from the event, here using user.id for per-user partitioning.",
|
|
142
150
|
in: getEvent("user signup", {
|
|
143
151
|
timestamp: 1700000103,
|
|
144
152
|
user: { id: "usr-789" },
|
|
@@ -171,6 +179,8 @@ var keyFromUser = {
|
|
|
171
179
|
]
|
|
172
180
|
};
|
|
173
181
|
var topicOverride = {
|
|
182
|
+
title: "Topic override",
|
|
183
|
+
description: "A mapping rule overrides the destination topic so specific events are routed to a dedicated stream.",
|
|
174
184
|
in: getEvent("order complete", {
|
|
175
185
|
timestamp: 1700000104,
|
|
176
186
|
data: { id: "ORD-500", total: 42 }
|
|
@@ -200,6 +210,7 @@ var topicOverride = {
|
|
|
200
210
|
]
|
|
201
211
|
};
|
|
202
212
|
var ignoredEvent = {
|
|
213
|
+
public: false,
|
|
203
214
|
in: getEvent("debug noise", {
|
|
204
215
|
timestamp: 1700000105
|
|
205
216
|
}),
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/server-destination-kafka",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"type": "destination",
|
|
6
6
|
"platform": [
|
|
7
7
|
"server"
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"push": {
|
|
213
213
|
"Kafka": {
|
|
214
214
|
"Kafka": {
|
|
215
|
-
"$code": "class{constructor(e){}producer(e){return
|
|
215
|
+
"$code": "class{constructor(e){}producer(e){return h()}}"
|
|
216
216
|
},
|
|
217
217
|
"CompressionTypes": {
|
|
218
218
|
"None": 0,
|
|
@@ -229,6 +229,8 @@
|
|
|
229
229
|
},
|
|
230
230
|
"step": {
|
|
231
231
|
"defaultEvent": {
|
|
232
|
+
"title": "Default event",
|
|
233
|
+
"description": "An event is produced to the configured Kafka topic with the full JSON body and entity_action as the message key.",
|
|
232
234
|
"in": {
|
|
233
235
|
"name": "page view",
|
|
234
236
|
"data": {
|
|
@@ -283,7 +285,7 @@
|
|
|
283
285
|
"group": "gr0up",
|
|
284
286
|
"count": 1,
|
|
285
287
|
"version": {
|
|
286
|
-
"source": "3.4.
|
|
288
|
+
"source": "3.4.1",
|
|
287
289
|
"tagging": 1
|
|
288
290
|
},
|
|
289
291
|
"source": {
|
|
@@ -314,6 +316,7 @@
|
|
|
314
316
|
]
|
|
315
317
|
},
|
|
316
318
|
"ignoredEvent": {
|
|
319
|
+
"public": false,
|
|
317
320
|
"in": {
|
|
318
321
|
"name": "debug noise",
|
|
319
322
|
"data": {
|
|
@@ -370,7 +373,7 @@
|
|
|
370
373
|
"group": "gr0up",
|
|
371
374
|
"count": 1,
|
|
372
375
|
"version": {
|
|
373
|
-
"source": "3.4.
|
|
376
|
+
"source": "3.4.1",
|
|
374
377
|
"tagging": 1
|
|
375
378
|
},
|
|
376
379
|
"source": {
|
|
@@ -385,6 +388,8 @@
|
|
|
385
388
|
"out": []
|
|
386
389
|
},
|
|
387
390
|
"keyFromUser": {
|
|
391
|
+
"title": "Key from user id",
|
|
392
|
+
"description": "A settings.kafka.key path resolves the message key from the event, here using user.id for per-user partitioning.",
|
|
388
393
|
"in": {
|
|
389
394
|
"name": "user signup",
|
|
390
395
|
"data": {
|
|
@@ -432,7 +437,7 @@
|
|
|
432
437
|
"group": "gr0up",
|
|
433
438
|
"count": 1,
|
|
434
439
|
"version": {
|
|
435
|
-
"source": "3.4.
|
|
440
|
+
"source": "3.4.1",
|
|
436
441
|
"tagging": 1
|
|
437
442
|
},
|
|
438
443
|
"source": {
|
|
@@ -472,6 +477,8 @@
|
|
|
472
477
|
]
|
|
473
478
|
},
|
|
474
479
|
"mappedData": {
|
|
480
|
+
"title": "Mapped payload",
|
|
481
|
+
"description": "A data mapping transforms the event payload before producing it as the Kafka message value.",
|
|
475
482
|
"in": {
|
|
476
483
|
"name": "order complete",
|
|
477
484
|
"data": {
|
|
@@ -556,7 +563,7 @@
|
|
|
556
563
|
"group": "gr0up",
|
|
557
564
|
"count": 1,
|
|
558
565
|
"version": {
|
|
559
|
-
"source": "3.4.
|
|
566
|
+
"source": "3.4.1",
|
|
560
567
|
"tagging": 1
|
|
561
568
|
},
|
|
562
569
|
"source": {
|
|
@@ -597,6 +604,8 @@
|
|
|
597
604
|
]
|
|
598
605
|
},
|
|
599
606
|
"mappedEventName": {
|
|
607
|
+
"title": "Renamed event",
|
|
608
|
+
"description": "A mapping renames the event which also changes the default Kafka message key used for partitioning.",
|
|
600
609
|
"in": {
|
|
601
610
|
"name": "order complete",
|
|
602
611
|
"data": {
|
|
@@ -683,7 +692,7 @@
|
|
|
683
692
|
"group": "gr0up",
|
|
684
693
|
"count": 1,
|
|
685
694
|
"version": {
|
|
686
|
-
"source": "3.4.
|
|
695
|
+
"source": "3.4.1",
|
|
687
696
|
"tagging": 1
|
|
688
697
|
},
|
|
689
698
|
"source": {
|
|
@@ -717,6 +726,8 @@
|
|
|
717
726
|
]
|
|
718
727
|
},
|
|
719
728
|
"topicOverride": {
|
|
729
|
+
"title": "Topic override",
|
|
730
|
+
"description": "A mapping rule overrides the destination topic so specific events are routed to a dedicated stream.",
|
|
720
731
|
"in": {
|
|
721
732
|
"name": "order complete",
|
|
722
733
|
"data": {
|
|
@@ -800,7 +811,7 @@
|
|
|
800
811
|
"group": "gr0up",
|
|
801
812
|
"count": 1,
|
|
802
813
|
"version": {
|
|
803
|
-
"source": "3.4.
|
|
814
|
+
"source": "3.4.1",
|
|
804
815
|
"tagging": 1
|
|
805
816
|
},
|
|
806
817
|
"source": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/server-destination-kafka",
|
|
3
3
|
"description": "Apache Kafka server destination for walkerOS (kafkajs, JSON serialization, GZIP compression)",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"kafkajs": "^2.2.4",
|
|
38
|
-
"@walkeros/core": "3.4.
|
|
39
|
-
"@walkeros/server-core": "3.4.
|
|
38
|
+
"@walkeros/core": "3.4.1",
|
|
39
|
+
"@walkeros/server-core": "3.4.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@walkeros/collector": "3.4.
|
|
42
|
+
"@walkeros/collector": "3.4.1"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|