@walkeros/server-destination-api 3.4.0 → 3.4.1-next-1776790594143

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 CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})},a={};s(a,{examples:()=>p,schemas:()=>d}),module.exports=(e=a,((e,s,a,d)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let n of o(s))i.call(e,n)||n===a||t(e,n,{get:()=>s[n],enumerable:!(d=r(s,n))||d.enumerable});return e})(t({},"__esModule",{value:!0}),e));var d={};s(d,{SettingsSchema:()=>u,settings:()=>c});var n=require("@walkeros/core/dev"),m=require("@walkeros/core/dev"),u=m.z.object({url:m.z.string().url().describe("The API endpoint URL to send events to"),headers:m.z.record(m.z.string(),m.z.string()).describe("Custom HTTP headers to include with requests").optional(),method:m.z.string().describe("HTTP method to use (default: POST)").optional(),timeout:m.z.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()}),c=(0,n.zodToSchema)(u),p={};s(p,{env:()=>v,step:()=>h});var v={};s(v,{init:()=>l,simulation:()=>g,standard:()=>y});var l={sendServer:void 0},y={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},g=["sendServer"],h={};s(h,{customHeaders:()=>S,customTransform:()=>_,fullEvent:()=>O});var b=require("@walkeros/core"),f="https://api.example.com/events",O={in:(0,b.getEvent)("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",f,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},S={in:(0,b.getEvent)("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",f,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},_={in:(0,b.getEvent)("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",f,JSON.stringify({order_id:"ORD-500",amount:199.99,currency:"USD",customer_id:"buyer-42",event_type:"order complete"}),{headers:void 0,method:void 0,timeout:void 0}]]};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})},a={};s(a,{examples:()=>p,schemas:()=>d}),module.exports=(e=a,((e,s,a,d)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let n of o(s))i.call(e,n)||n===a||t(e,n,{get:()=>s[n],enumerable:!(d=r(s,n))||d.enumerable});return e})(t({},"__esModule",{value:!0}),e));var d={};s(d,{SettingsSchema:()=>u,settings:()=>c});var n=require("@walkeros/core/dev"),m=require("@walkeros/core/dev"),u=m.z.object({url:m.z.string().url().describe("The API endpoint URL to send events to"),headers:m.z.record(m.z.string(),m.z.string()).describe("Custom HTTP headers to include with requests").optional(),method:m.z.string().describe("HTTP method to use (default: POST)").optional(),timeout:m.z.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()}),c=(0,n.zodToSchema)(u),p={};s(p,{env:()=>l,step:()=>g});var l={};s(l,{init:()=>v,simulation:()=>y,standard:()=>h});var v={sendServer:void 0},h={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},y=["sendServer"],g={};s(g,{customHeaders:()=>S,customTransform:()=>P,fullEvent:()=>O});var f=require("@walkeros/core"),b="https://api.example.com/events",O={title:"Forward event data",description:"A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",in:(0,f.getEvent)("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",b,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},S={title:"Custom headers",description:"A form submission is sent to the API with custom request headers such as an API key for authentication.",in:(0,f.getEvent)("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",b,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},P={title:"Custom payload",description:"An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.",in:(0,f.getEvent)("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",b,JSON.stringify({order_id:"ORD-500",amount:199.99,currency:"USD",customer_id:"buyer-42",event_type:"order complete"}),{headers:void 0,method:void 0,timeout:void 0}]]};//# 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/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';\n\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n url: z.string().url().describe('The API endpoint URL to send events to'),\n headers: z\n .record(z.string(), z.string())\n .describe('Custom HTTP headers to include with requests')\n .optional(),\n method: z.string().describe('HTTP method to use (default: POST)').optional(),\n timeout: z\n .number()\n .positive()\n .describe('Request timeout in milliseconds (default: 5000)')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n\n/**\n * Simulation tracking paths\n * Specifies which function calls to track during simulation\n */\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * API server destination step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is the configured endpoint, `body` is the JSON-stringified\n * event data (or mapped data), and `options` carries headers/method/timeout.\n *\n * Each `out` tuple is `['sendServer', url, body, options]` mirroring the real\n * call signature. The test fixture injects the configured settings per example.\n */\nconst URL = 'https://api.example.com/events';\n\nexport const fullEvent: Flow.StepExample = {\n in: getEvent('page view', {\n timestamp: 1700000800,\n data: { title: 'Docs', url: 'https://example.com/docs' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n title: 'Docs',\n url: 'https://example.com/docs',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n\nexport const customHeaders: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000801,\n data: { type: 'contact', email: 'user@example.com' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n type: 'contact',\n email: 'user@example.com',\n }),\n {\n headers: { 'X-API-Key': 'YOUR_API_KEY' },\n method: undefined,\n timeout: undefined,\n },\n ],\n ],\n};\n\nexport const customTransform: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000802,\n data: { id: 'ORD-500', total: 199.99, currency: 'USD' },\n user: { id: 'buyer-42' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: {\n map: {\n order_id: 'data.id',\n amount: 'data.total',\n currency: 'data.currency',\n customer_id: 'user.id',\n event_type: 'name',\n },\n },\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n order_id: 'ORD-500',\n amount: 199.99,\n currency: 'USD',\n customer_id: 'buyer-42',\n event_type: 'order complete',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,KAAK,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS,wCAAwC;AAAA,EACvE,SAAS,aACN,OAAO,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,EAC7B,SAAS,8CAA8C,EACvD,SAAS;AAAA,EACZ,QAAQ,aAAE,OAAO,EAAE,SAAS,oCAAoC,EAAE,SAAS;AAAA,EAC3E,SAAS,aACN,OAAO,EACP,SAAS,EACT,SAAS,iDAAiD,EAC1D,SAAS;AACd,CAAC;;;ADRM,IAAM,eAAW,yBAAY,cAAc;;;AENlD;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MA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IAAI,WAAW;AAAA,IACvB,QAAQ,EAAE,MAAM,UAAU,IAAI,IAAI,aAAa,GAAG;AAAA,EACpD,CAAC;AAAA,EACD,SAAS;AAAA,IACP,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,MACd,CAAC;AAAA,MACD,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AAAA,IAC9D;AAAA,EACF;AACF;","names":["import_dev"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.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';\n\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n url: z.string().url().describe('The API endpoint URL to send events to'),\n headers: z\n .record(z.string(), z.string())\n .describe('Custom HTTP headers to include with requests')\n .optional(),\n method: z.string().describe('HTTP method to use (default: POST)').optional(),\n timeout: z\n .number()\n .positive()\n .describe('Request timeout in milliseconds (default: 5000)')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n\n/**\n * Simulation tracking paths\n * Specifies which function calls to track during simulation\n */\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * API server destination step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is the configured endpoint, `body` is the JSON-stringified\n * event data (or mapped data), and `options` carries headers/method/timeout.\n *\n * Each `out` tuple is `['sendServer', url, body, options]` mirroring the real\n * call signature. The test fixture injects the configured settings per example.\n */\nconst URL = 'https://api.example.com/events';\n\nexport const fullEvent: Flow.StepExample = {\n title: 'Forward event data',\n description:\n 'A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.',\n in: getEvent('page view', {\n timestamp: 1700000800,\n data: { title: 'Docs', url: 'https://example.com/docs' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n title: 'Docs',\n url: 'https://example.com/docs',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n\nexport const customHeaders: Flow.StepExample = {\n title: 'Custom headers',\n description:\n 'A form submission is sent to the API with custom request headers such as an API key for authentication.',\n in: getEvent('form submit', {\n timestamp: 1700000801,\n data: { type: 'contact', email: 'user@example.com' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n type: 'contact',\n email: 'user@example.com',\n }),\n {\n headers: { 'X-API-Key': 'YOUR_API_KEY' },\n method: undefined,\n timeout: undefined,\n },\n ],\n ],\n};\n\nexport const customTransform: Flow.StepExample = {\n title: 'Custom payload',\n description:\n 'An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.',\n in: getEvent('order complete', {\n timestamp: 1700000802,\n data: { id: 'ORD-500', total: 199.99, currency: 'USD' },\n user: { id: 'buyer-42' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: {\n map: {\n order_id: 'data.id',\n amount: 'data.total',\n currency: 'data.currency',\n customer_id: 'user.id',\n event_type: 'name',\n },\n },\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n order_id: 'ORD-500',\n amount: 199.99,\n currency: 'USD',\n customer_id: 'buyer-42',\n event_type: 'order complete',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,KAAK,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS,wCAAwC;AAAA,EACvE,SAAS,aACN,OAAO,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,EAC7B,SAAS,8CAA8C,EACvD,SAAS;AAAA,EACZ,QAAQ,aAAE,OAAO,EAAE,SAAS,oCAAoC,EAAE,SAAS;AAAA,EAC3E,SAAS,aACN,OAAO,EACP,SAAS,EACT,SAAS,iDAAiD,EAC1D,SAAS;AACd,CAAC;;;ADRM,IAAM,eAAW,yBAAY,cAAc;;;AENlD;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;AAMO,IAAM,aAAa,CAAC,YAAY;;;ACzBvC;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAyB;AAYzB,IAAM,MAAM;AAEL,IAAM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AAI,IAAI,aAAa,GAAG;AAAA,EACpD,CAAC;AAAA,EACD,SAAS;AAAA,IACP,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,MACd,CAAC;AAAA,MACD,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AAAA,IAC9D;AAAA,EACF;AACF;","names":["import_dev"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,r)=>{for(var o in r)e(t,o,{get:r[o],enumerable:!0})},r={};t(r,{SettingsSchema:()=>s,settings:()=>a});import{zodToSchema as o}from"@walkeros/core/dev";import{z as i}from"@walkeros/core/dev";var s=i.object({url:i.string().url().describe("The API endpoint URL to send events to"),headers:i.record(i.string(),i.string()).describe("Custom HTTP headers to include with requests").optional(),method:i.string().describe("HTTP method to use (default: POST)").optional(),timeout:i.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()}),a=o(s),d={};t(d,{env:()=>m,step:()=>p});var m={};t(m,{init:()=>n,simulation:()=>c,standard:()=>u});var n={sendServer:void 0},u={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},c=["sendServer"],p={};t(p,{customHeaders:()=>h,customTransform:()=>g,fullEvent:()=>y});import{getEvent as v}from"@walkeros/core";var l="https://api.example.com/events",y={in:v("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",l,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},h={in:v("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",l,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},g={in:v("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",l,JSON.stringify({order_id:"ORD-500",amount:199.99,currency:"USD",customer_id:"buyer-42",event_type:"order complete"}),{headers:void 0,method:void 0,timeout:void 0}]]};export{d as examples,r as schemas};//# sourceMappingURL=dev.mjs.map
1
+ var e=Object.defineProperty,t=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0})},r={};t(r,{SettingsSchema:()=>s,settings:()=>a});import{zodToSchema as i}from"@walkeros/core/dev";import{z as o}from"@walkeros/core/dev";var s=o.object({url:o.string().url().describe("The API endpoint URL to send events to"),headers:o.record(o.string(),o.string()).describe("Custom HTTP headers to include with requests").optional(),method:o.string().describe("HTTP method to use (default: POST)").optional(),timeout:o.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()}),a=i(s),d={};t(d,{env:()=>n,step:()=>c});var n={};t(n,{init:()=>m,simulation:()=>p,standard:()=>u});var m={sendServer:void 0},u={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},p=["sendServer"],c={};t(c,{customHeaders:()=>y,customTransform:()=>f,fullEvent:()=>h});import{getEvent as v}from"@walkeros/core";var l="https://api.example.com/events",h={title:"Forward event data",description:"A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",in:v("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",l,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},y={title:"Custom headers",description:"A form submission is sent to the API with custom request headers such as an API key for authentication.",in:v("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",l,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},f={title:"Custom payload",description:"An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.",in:v("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",l,JSON.stringify({order_id:"ORD-500",amount:199.99,currency:"USD",customer_id:"buyer-42",event_type:"order complete"}),{headers:void 0,method:void 0,timeout:void 0}]]};export{d as examples,r 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/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n url: z.string().url().describe('The API endpoint URL to send events to'),\n headers: z\n .record(z.string(), z.string())\n .describe('Custom HTTP headers to include with requests')\n .optional(),\n method: z.string().describe('HTTP method to use (default: POST)').optional(),\n timeout: z\n .number()\n .positive()\n .describe('Request timeout in milliseconds (default: 5000)')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n\n/**\n * Simulation tracking paths\n * Specifies which function calls to track during simulation\n */\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * API server destination step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is the configured endpoint, `body` is the JSON-stringified\n * event data (or mapped data), and `options` carries headers/method/timeout.\n *\n * Each `out` tuple is `['sendServer', url, body, options]` mirroring the real\n * call signature. The test fixture injects the configured settings per example.\n */\nconst URL = 'https://api.example.com/events';\n\nexport const fullEvent: Flow.StepExample = {\n in: getEvent('page view', {\n timestamp: 1700000800,\n data: { title: 'Docs', url: 'https://example.com/docs' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n title: 'Docs',\n url: 'https://example.com/docs',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n\nexport const customHeaders: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000801,\n data: { type: 'contact', email: 'user@example.com' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n type: 'contact',\n email: 'user@example.com',\n }),\n {\n headers: { 'X-API-Key': 'YOUR_API_KEY' },\n method: undefined,\n timeout: undefined,\n },\n ],\n ],\n};\n\nexport const customTransform: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000802,\n data: { id: 'ORD-500', total: 199.99, currency: 'USD' },\n user: { id: 'buyer-42' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: {\n map: {\n order_id: 'data.id',\n amount: 'data.total',\n currency: 'data.currency',\n customer_id: 'user.id',\n event_type: 'name',\n },\n },\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n order_id: 'ORD-500',\n amount: 199.99,\n currency: 'USD',\n customer_id: 'buyer-42',\n event_type: 'order complete',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,wCAAwC;AAAA,EACvE,SAAS,EACN,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAC7B,SAAS,8CAA8C,EACvD,SAAS;AAAA,EACZ,QAAQ,EAAE,OAAO,EAAE,SAAS,oCAAoC,EAAE,SAAS;AAAA,EAC3E,SAAS,EACN,OAAO,EACP,SAAS,EACT,SAAS,iDAAiD,EAC1D,SAAS;AACd,CAAC;;;ADRM,IAAM,WAAW,YAAY,cAAc;;;AENlD;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;AAMO,IAAM,aAAa,CAAC,YAAY;;;ACzBvC;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAS,gBAAgB;AAYzB,IAAM,MAAM;AAEL,IAAM,YAA8B;AAAA,EACzC,IAAI,SAAS,aAAa;AAAA,IACxB,WAAW;AAAA,IACX,MAAM,EAAE,OAAO,QAAQ,KAAK,2BAA2B;AAAA,IACvD,QAAQ,EAAE,MAAM,UAAU,I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E;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,MACd,CAAC;AAAA,MACD,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AAAA,IAC9D;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n url: z.string().url().describe('The API endpoint URL to send events to'),\n headers: z\n .record(z.string(), z.string())\n .describe('Custom HTTP headers to include with requests')\n .optional(),\n method: z.string().describe('HTTP method to use (default: POST)').optional(),\n timeout: z\n .number()\n .positive()\n .describe('Request timeout in milliseconds (default: 5000)')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n\n/**\n * Simulation tracking paths\n * Specifies which function calls to track during simulation\n */\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * API server destination step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is the configured endpoint, `body` is the JSON-stringified\n * event data (or mapped data), and `options` carries headers/method/timeout.\n *\n * Each `out` tuple is `['sendServer', url, body, options]` mirroring the real\n * call signature. The test fixture injects the configured settings per example.\n */\nconst URL = 'https://api.example.com/events';\n\nexport const fullEvent: Flow.StepExample = {\n title: 'Forward event data',\n description:\n 'A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.',\n in: getEvent('page view', {\n timestamp: 1700000800,\n data: { title: 'Docs', url: 'https://example.com/docs' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n title: 'Docs',\n url: 'https://example.com/docs',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n\nexport const customHeaders: Flow.StepExample = {\n title: 'Custom headers',\n description:\n 'A form submission is sent to the API with custom request headers such as an API key for authentication.',\n in: getEvent('form submit', {\n timestamp: 1700000801,\n data: { type: 'contact', email: 'user@example.com' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n type: 'contact',\n email: 'user@example.com',\n }),\n {\n headers: { 'X-API-Key': 'YOUR_API_KEY' },\n method: undefined,\n timeout: undefined,\n },\n ],\n ],\n};\n\nexport const customTransform: Flow.StepExample = {\n title: 'Custom payload',\n description:\n 'An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.',\n in: getEvent('order complete', {\n timestamp: 1700000802,\n data: { id: 'ORD-500', total: 199.99, currency: 'USD' },\n user: { id: 'buyer-42' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: {\n map: {\n order_id: 'data.id',\n amount: 'data.total',\n currency: 'data.currency',\n customer_id: 'user.id',\n event_type: 'name',\n },\n },\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n order_id: 'ORD-500',\n amount: 199.99,\n currency: 'USD',\n customer_id: 'buyer-42',\n event_type: 'order complete',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n"],"mapp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AAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AAAA,IAC9D;AAAA,EACF;AACF;","names":[]}
@@ -53,6 +53,8 @@ __export(step_exports, {
53
53
  var import_core = require("@walkeros/core");
54
54
  var URL = "https://api.example.com/events";
55
55
  var fullEvent = {
56
+ title: "Forward event data",
57
+ description: "A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",
56
58
  in: (0, import_core.getEvent)("page view", {
57
59
  timestamp: 1700000800,
58
60
  data: { title: "Docs", url: "https://example.com/docs" },
@@ -74,6 +76,8 @@ var fullEvent = {
74
76
  ]
75
77
  };
76
78
  var customHeaders = {
79
+ title: "Custom headers",
80
+ description: "A form submission is sent to the API with custom request headers such as an API key for authentication.",
77
81
  in: (0, import_core.getEvent)("form submit", {
78
82
  timestamp: 1700000801,
79
83
  data: { type: "contact", email: "user@example.com" },
@@ -99,6 +103,8 @@ var customHeaders = {
99
103
  ]
100
104
  };
101
105
  var customTransform = {
106
+ title: "Custom payload",
107
+ description: "An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.",
102
108
  in: (0, import_core.getEvent)("order complete", {
103
109
  timestamp: 1700000802,
104
110
  data: { id: "ORD-500", total: 199.99, currency: "USD" },
@@ -32,6 +32,8 @@ __export(step_exports, {
32
32
  import { getEvent } from "@walkeros/core";
33
33
  var URL = "https://api.example.com/events";
34
34
  var fullEvent = {
35
+ title: "Forward event data",
36
+ description: "A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",
35
37
  in: getEvent("page view", {
36
38
  timestamp: 1700000800,
37
39
  data: { title: "Docs", url: "https://example.com/docs" },
@@ -53,6 +55,8 @@ var fullEvent = {
53
55
  ]
54
56
  };
55
57
  var customHeaders = {
58
+ title: "Custom headers",
59
+ description: "A form submission is sent to the API with custom request headers such as an API key for authentication.",
56
60
  in: getEvent("form submit", {
57
61
  timestamp: 1700000801,
58
62
  data: { type: "contact", email: "user@example.com" },
@@ -78,6 +82,8 @@ var customHeaders = {
78
82
  ]
79
83
  };
80
84
  var customTransform = {
85
+ title: "Custom payload",
86
+ description: "An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.",
81
87
  in: getEvent("order complete", {
82
88
  timestamp: 1700000802,
83
89
  data: { id: "ORD-500", total: 199.99, currency: "USD" },
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},index_exports={};__export(index_exports,{DestinationAPI:()=>types_exports,default:()=>index_default,destinationAPI:()=>destinationAPI,examples:()=>examples_exports}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_core2=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),types_exports={},examples_exports={};__export(examples_exports,{env:()=>env_exports,step:()=>step_exports});var env_exports={};__export(env_exports,{init:()=>init,simulation:()=>simulation,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},simulation=["sendServer"],step_exports={};__export(step_exports,{customHeaders:()=>customHeaders,customTransform:()=>customTransform,fullEvent:()=>fullEvent});var import_core=require("@walkeros/core"),URL="https://api.example.com/events",fullEvent={in:(0,import_core.getEvent)("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",URL,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},customHeaders={in:(0,import_core.getEvent)("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",URL,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},customTransform={in:(0,import_core.getEvent)("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",URL,JSON.stringify({order_id:"ORD-500",amount:199.99,currency:"USD",customer_id:"buyer-42",event_type:"order complete"}),{headers:void 0,method:void 0,timeout:void 0}]]},destinationAPI={type:"api",config:{},env:{sendServer:import_server_core.sendServer},async push(event,{config:config,rule:rule,data:data,env:env,logger:logger}){const{settings:settings}=config,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=(0,import_core2.isDefined)(data)?data:event,body=transform?transform(eventData,config,rule):JSON.stringify(eventData);null==logger||logger.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=(null==env?void 0:env.sendServer)||import_server_core.sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});null==logger||logger.debug("API destination response",{ok:null==response?void 0:response.ok})}},index_default=destinationAPI;//# sourceMappingURL=index.js.map
1
+ "use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},index_exports={};__export(index_exports,{DestinationAPI:()=>types_exports,default:()=>index_default,destinationAPI:()=>destinationAPI,examples:()=>examples_exports}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_core2=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),types_exports={},examples_exports={};__export(examples_exports,{env:()=>env_exports,step:()=>step_exports});var env_exports={};__export(env_exports,{init:()=>init,simulation:()=>simulation,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},simulation=["sendServer"],step_exports={};__export(step_exports,{customHeaders:()=>customHeaders,customTransform:()=>customTransform,fullEvent:()=>fullEvent});var import_core=require("@walkeros/core"),URL="https://api.example.com/events",fullEvent={title:"Forward event data",description:"A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",in:(0,import_core.getEvent)("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",URL,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},customHeaders={title:"Custom headers",description:"A form submission is sent to the API with custom request headers such as an API key for authentication.",in:(0,import_core.getEvent)("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",URL,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},customTransform={title:"Custom payload",description:"An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.",in:(0,import_core.getEvent)("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",URL,JSON.stringify({order_id:"ORD-500",amount:199.99,currency:"USD",customer_id:"buyer-42",event_type:"order complete"}),{headers:void 0,method:void 0,timeout:void 0}]]},destinationAPI={type:"api",config:{},env:{sendServer:import_server_core.sendServer},async push(event,{config:config,rule:rule,data:data,env:env,logger:logger}){const{settings:settings}=config,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=(0,import_core2.isDefined)(data)?data:event,body=transform?transform(eventData,config,rule):JSON.stringify(eventData);null==logger||logger.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=(null==env?void 0:env.sendServer)||import_server_core.sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});null==logger||logger.debug("API destination response",{ok:null==response?void 0:response.ok})}},index_default=destinationAPI;//# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import type { Settings, Destination, Env } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\n// Examples\nexport * as examples from './examples';\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n env: { sendServer },\n\n async push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, headers, method, transform, timeout } = settings || {};\n\n if (!url) return;\n\n const eventData = isDefined(data) ? data : event;\n const body = transform\n ? transform(eventData, config, rule) // Transform event data\n : JSON.stringify(eventData);\n\n logger?.debug('API destination sending request', {\n url,\n method: method || 'POST',\n eventName: event.name,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const response = await sendServerFn(url, body, {\n headers,\n method,\n timeout,\n });\n\n logger?.debug('API destination response', { ok: response?.ok });\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n timeout?: number;\n}\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env>;\n\nexport type Destination = DestinationServer.Destination<Types>;\nexport type Config = DestinationServer.Config<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n\n/**\n * Simulation tracking paths\n * Specifies which function calls to track during simulation\n */\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * API server destination step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is the configured endpoint, `body` is the JSON-stringified\n * event data (or mapped data), and `options` carries headers/method/timeout.\n *\n * Each `out` tuple is `['sendServer', url, body, options]` mirroring the real\n * call signature. The test fixture injects the configured settings per example.\n */\nconst URL = 'https://api.example.com/events';\n\nexport const fullEvent: Flow.StepExample = {\n in: getEvent('page view', {\n timestamp: 1700000800,\n data: { title: 'Docs', url: 'https://example.com/docs' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n title: 'Docs',\n url: 'https://example.com/docs',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n\nexport const customHeaders: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000801,\n data: { type: 'contact', email: 'user@example.com' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n type: 'contact',\n email: 'user@example.com',\n }),\n {\n headers: { 'X-API-Key': 'YOUR_API_KEY' },\n method: undefined,\n timeout: undefined,\n },\n ],\n ],\n};\n\nexport const customTransform: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000802,\n data: { id: 'ORD-500', total: 199.99, currency: 'USD' },\n user: { id: 'buyer-42' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: {\n map: {\n order_id: 'data.id',\n amount: 'data.total',\n currency: 'data.currency',\n customer_id: 'user.id',\n event_type: 'name',\n },\n },\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n order_id: 'ORD-500',\n amount: 199.99,\n currency: 'USD',\n customer_id: 'buyer-42',\n event_type: 'order complete',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,eAA0B;AAC1B,yBAA2B;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;AAMO,IAAM,aAAa,CAAC,YAAY;;;ACzBvC;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAyB;AAYzB,IAAM,MAAM;AAEL,IAAM,YAA8B;AAAA,EACzC,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V,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,MACd,CAAC;AAAA,MACD,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AAAA,IAC9D;AAAA,EACF;AACF;;;AJrFO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,0CAAW;AAAA,EAElB,MAAM,KAAK,OAAO,EAAE,QAAQ,MAAM,MAAM,KAAK,OAAO,GAAG;AACrD,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM,EAAE,KAAK,SAAS,QAAQ,WAAW,QAAQ,IAAI,YAAY,CAAC;AAElE,QAAI,CAAC,IAAK;AAEV,UAAM,gBAAY,wBAAU,IAAI,IAAI,OAAO;AAC3C,UAAM,OAAO,YACT,UAAU,WAAW,QAAQ,IAAI,IACjC,KAAK,UAAU,SAAS;AAE5B,qCAAQ,MAAM,mCAAmC;AAAA,MAC/C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,WAAW,MAAM;AAAA,IACnB;AAEA,UAAM,gBAAgB,2BAAa,eAAc;AACjD,UAAM,WAAW,MAAM,aAAa,KAAK,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,qCAAQ,MAAM,4BAA4B,EAAE,IAAI,qCAAU,GAAG;AAAA,EAC/D;AACF;AAEA,IAAO,gBAAQ;","names":["import_core"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import type { Settings, Destination, Env } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\n// Examples\nexport * as examples from './examples';\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n env: { sendServer },\n\n async push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, headers, method, transform, timeout } = settings || {};\n\n if (!url) return;\n\n const eventData = isDefined(data) ? data : event;\n const body = transform\n ? transform(eventData, config, rule) // Transform event data\n : JSON.stringify(eventData);\n\n logger?.debug('API destination sending request', {\n url,\n method: method || 'POST',\n eventName: event.name,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const response = await sendServerFn(url, body, {\n headers,\n method,\n timeout,\n });\n\n logger?.debug('API destination response', { ok: response?.ok });\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n timeout?: number;\n}\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env>;\n\nexport type Destination = DestinationServer.Destination<Types>;\nexport type Config = DestinationServer.Config<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n\n/**\n * Simulation tracking paths\n * Specifies which function calls to track during simulation\n */\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * API server destination step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is the configured endpoint, `body` is the JSON-stringified\n * event data (or mapped data), and `options` carries headers/method/timeout.\n *\n * Each `out` tuple is `['sendServer', url, body, options]` mirroring the real\n * call signature. The test fixture injects the configured settings per example.\n */\nconst URL = 'https://api.example.com/events';\n\nexport const fullEvent: Flow.StepExample = {\n title: 'Forward event data',\n description:\n 'A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.',\n in: getEvent('page view', {\n timestamp: 1700000800,\n data: { title: 'Docs', url: 'https://example.com/docs' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n title: 'Docs',\n url: 'https://example.com/docs',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n\nexport const customHeaders: Flow.StepExample = {\n title: 'Custom headers',\n description:\n 'A form submission is sent to the API with custom request headers such as an API key for authentication.',\n in: getEvent('form submit', {\n timestamp: 1700000801,\n data: { type: 'contact', email: 'user@example.com' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n type: 'contact',\n email: 'user@example.com',\n }),\n {\n headers: { 'X-API-Key': 'YOUR_API_KEY' },\n method: undefined,\n timeout: undefined,\n },\n ],\n ],\n};\n\nexport const customTransform: Flow.StepExample = {\n title: 'Custom payload',\n description:\n 'An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.',\n in: getEvent('order complete', {\n timestamp: 1700000802,\n data: { id: 'ORD-500', total: 199.99, currency: 'USD' },\n user: { id: 'buyer-42' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: {\n map: {\n order_id: 'data.id',\n amount: 'data.total',\n currency: 'data.currency',\n customer_id: 'user.id',\n event_type: 'name',\n },\n },\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n order_id: 'ORD-500',\n amount: 199.99,\n currency: 'USD',\n customer_id: 'buyer-42',\n event_type: 'order complete',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,eAA0B;AAC1B,yBAA2B;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;AAMO,IAAM,aAAa,CAAC,YAAY;;;ACzBvC;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAyB;AAYzB,IAAM,MAAM;AAEL,IAAM,YAA8B;AAAA,EACzC,OAAO;AAAA,EACP,aACE;AAAA,EACF,QAAI,sBAAS,aAAa;AAAA,IACxB,WAAW;AAAA,IACX,MAAM,EAAE,OAAO,QAAQ,KAAK,2BAA2B;AAAA,IACvD,QAAQ,EAAE,MAAM,UAAU,IAAI,IAAI,aAAa,GAAG;AAAA,EACpD,CAAC;AAAA,EACD,SAAS;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,OAAO;AAAA,QACP,KAAK;AAAA,MACP,CAAC;AAAA,MACD,EAAE,SAAS,QAAW,QAAQ,QAA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SAAS,OAAU;AAAA,IAC9D;AAAA,EACF;AACF;;;AJ9FO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,0CAAW;AAAA,EAElB,MAAM,KAAK,OAAO,EAAE,QAAQ,MAAM,MAAM,KAAK,OAAO,GAAG;AACrD,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM,EAAE,KAAK,SAAS,QAAQ,WAAW,QAAQ,IAAI,YAAY,CAAC;AAElE,QAAI,CAAC,IAAK;AAEV,UAAM,gBAAY,wBAAU,IAAI,IAAI,OAAO;AAC3C,UAAM,OAAO,YACT,UAAU,WAAW,QAAQ,IAAI,IACjC,KAAK,UAAU,SAAS;AAE5B,qCAAQ,MAAM,mCAAmC;AAAA,MAC/C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,WAAW,MAAM;AAAA,IACnB;AAEA,UAAM,gBAAgB,2BAAa,eAAc;AACjD,UAAM,WAAW,MAAM,aAAa,KAAK,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,qCAAQ,MAAM,4BAA4B,EAAE,IAAI,qCAAU,GAAG;AAAA,EAC/D;AACF;AAEA,IAAO,gBAAQ;","names":["import_core"]}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var __defProp=Object.defineProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})};import{isDefined}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";var types_exports={},examples_exports={};__export(examples_exports,{env:()=>env_exports,step:()=>step_exports});var env_exports={};__export(env_exports,{init:()=>init,simulation:()=>simulation,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},simulation=["sendServer"],step_exports={};__export(step_exports,{customHeaders:()=>customHeaders,customTransform:()=>customTransform,fullEvent:()=>fullEvent});import{getEvent}from"@walkeros/core";var URL="https://api.example.com/events",fullEvent={in:getEvent("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",URL,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},customHeaders={in:getEvent("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",URL,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},customTransform={in:getEvent("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",URL,JSON.stringify({order_id:"ORD-500",amount:199.99,currency:"USD",customer_id:"buyer-42",event_type:"order complete"}),{headers:void 0,method:void 0,timeout:void 0}]]},destinationAPI={type:"api",config:{},env:{sendServer:sendServer},async push(event,{config:config,rule:rule,data:data,env:env,logger:logger}){const{settings:settings}=config,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=isDefined(data)?data:event,body=transform?transform(eventData,config,rule):JSON.stringify(eventData);null==logger||logger.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=(null==env?void 0:env.sendServer)||sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});null==logger||logger.debug("API destination response",{ok:null==response?void 0:response.ok})}},index_default=destinationAPI;export{types_exports as DestinationAPI,index_default as default,destinationAPI,examples_exports as examples};//# sourceMappingURL=index.mjs.map
1
+ var __defProp=Object.defineProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})};import{isDefined}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";var types_exports={},examples_exports={};__export(examples_exports,{env:()=>env_exports,step:()=>step_exports});var env_exports={};__export(env_exports,{init:()=>init,simulation:()=>simulation,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},simulation=["sendServer"],step_exports={};__export(step_exports,{customHeaders:()=>customHeaders,customTransform:()=>customTransform,fullEvent:()=>fullEvent});import{getEvent}from"@walkeros/core";var URL="https://api.example.com/events",fullEvent={title:"Forward event data",description:"A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",in:getEvent("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",URL,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},customHeaders={title:"Custom headers",description:"A form submission is sent to the API with custom request headers such as an API key for authentication.",in:getEvent("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:"data"},out:[["sendServer",URL,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},customTransform={title:"Custom payload",description:"An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.",in:getEvent("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"server",id:"",previous_id:""}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",URL,JSON.stringify({order_id:"ORD-500",amount:199.99,currency:"USD",customer_id:"buyer-42",event_type:"order complete"}),{headers:void 0,method:void 0,timeout:void 0}]]},destinationAPI={type:"api",config:{},env:{sendServer:sendServer},async push(event,{config:config,rule:rule,data:data,env:env,logger:logger}){const{settings:settings}=config,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=isDefined(data)?data:event,body=transform?transform(eventData,config,rule):JSON.stringify(eventData);null==logger||logger.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=(null==env?void 0:env.sendServer)||sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});null==logger||logger.debug("API destination response",{ok:null==response?void 0:response.ok})}},index_default=destinationAPI;export{types_exports as DestinationAPI,index_default as default,destinationAPI,examples_exports as examples};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import type { Settings, Destination, Env } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\n// Examples\nexport * as examples from './examples';\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n env: { sendServer },\n\n async push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, headers, method, transform, timeout } = settings || {};\n\n if (!url) return;\n\n const eventData = isDefined(data) ? data : event;\n const body = transform\n ? transform(eventData, config, rule) // Transform event data\n : JSON.stringify(eventData);\n\n logger?.debug('API destination sending request', {\n url,\n method: method || 'POST',\n eventName: event.name,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const response = await sendServerFn(url, body, {\n headers,\n method,\n timeout,\n });\n\n logger?.debug('API destination response', { ok: response?.ok });\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n timeout?: number;\n}\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env>;\n\nexport type Destination = DestinationServer.Destination<Types>;\nexport type Config = DestinationServer.Config<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n\n/**\n * Simulation tracking paths\n * Specifies which function calls to track during simulation\n */\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * API server destination step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is the configured endpoint, `body` is the JSON-stringified\n * event data (or mapped data), and `options` carries headers/method/timeout.\n *\n * Each `out` tuple is `['sendServer', url, body, options]` mirroring the real\n * call signature. The test fixture injects the configured settings per example.\n */\nconst URL = 'https://api.example.com/events';\n\nexport const fullEvent: Flow.StepExample = {\n in: getEvent('page view', {\n timestamp: 1700000800,\n data: { title: 'Docs', url: 'https://example.com/docs' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n title: 'Docs',\n url: 'https://example.com/docs',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n\nexport const customHeaders: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000801,\n data: { type: 'contact', email: 'user@example.com' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n type: 'contact',\n email: 'user@example.com',\n }),\n {\n headers: { 'X-API-Key': 'YOUR_API_KEY' },\n method: undefined,\n timeout: undefined,\n },\n ],\n ],\n};\n\nexport const customTransform: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000802,\n data: { id: 'ORD-500', total: 199.99, currency: 'USD' },\n user: { id: 'buyer-42' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: {\n map: {\n order_id: 'data.id',\n amount: 'data.total',\n currency: 'data.currency',\n customer_id: 'user.id',\n event_type: 'name',\n },\n },\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n order_id: 'ORD-500',\n amount: 199.99,\n currency: 'USD',\n customer_id: 'buyer-42',\n event_type: 'order complete',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n"],"mappings":";;;;;;;AACA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,OAAO,MAAM,QAAQ,QAAQ,EAAE,IAAI,KAAK,CAAC;AAExC,IAAM,OAAwB;AAAA,EACnC,YAAY;AACd;AAEO,IAAM,WAAgB;AAAA,EAC3B,YAAY,OAAO,OAAO,MAAM;AAAA;AAAA,EAEhC,CAAC;AACH;AAMO,IAAM,aAAa,CAAC,YAAY;;;ACzBvC;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAS,gBAAgB;AAYzB,IAAM,MAAM;AAEL,IAAM,YAA8B;AAAA,EACzC,IAAI,SAAS,aAAa;AAAA,IACxB,WAAW;AAAA,IACX,MAAM,EAAE,OAAO,QAAQ,KAAK,2BAA2B;AAAA,IACvD,QAAQ,EAAE,MAAM,UAAU,IAAI,IAAI,aAAa,GAAG;AAAA,EACpD,CAAC;AAAA,EACD,SAAS;AAAA,IACP,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA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AA,QACb,YAAY;AAAA,MACd,CAAC;AAAA,MACD,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AAAA,IAC9D;AAAA,EACF;AACF;;;AJrFO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,WAAW;AAAA,EAElB,MAAM,KAAK,OAAO,EAAE,QAAQ,MAAM,MAAM,KAAK,OAAO,GAAG;AACrD,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM,EAAE,KAAK,SAAS,QAAQ,WAAW,QAAQ,IAAI,YAAY,CAAC;AAElE,QAAI,CAAC,IAAK;AAEV,UAAM,YAAY,UAAU,IAAI,IAAI,OAAO;AAC3C,UAAM,OAAO,YACT,UAAU,WAAW,QAAQ,IAAI,IACjC,KAAK,UAAU,SAAS;AAE5B,qCAAQ,MAAM,mCAAmC;AAAA,MAC/C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,WAAW,MAAM;AAAA,IACnB;AAEA,UAAM,gBAAgB,2BAAa,eAAc;AACjD,UAAM,WAAW,MAAM,aAAa,KAAK,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,qCAAQ,MAAM,4BAA4B,EAAE,IAAI,qCAAU,GAAG;AAAA,EAC/D;AACF;AAEA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import type { Settings, Destination, Env } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\n// Examples\nexport * as examples from './examples';\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n env: { sendServer },\n\n async push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, headers, method, transform, timeout } = settings || {};\n\n if (!url) return;\n\n const eventData = isDefined(data) ? data : event;\n const body = transform\n ? transform(eventData, config, rule) // Transform event data\n : JSON.stringify(eventData);\n\n logger?.debug('API destination sending request', {\n url,\n method: method || 'POST',\n eventName: event.name,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const response = await sendServerFn(url, body, {\n headers,\n method,\n timeout,\n });\n\n logger?.debug('API destination response', { ok: response?.ok });\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n timeout?: number;\n}\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env>;\n\nexport type Destination = DestinationServer.Destination<Types>;\nexport type Config = DestinationServer.Config<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nconst noop = () => Promise.resolve({ ok: true });\n\nexport const init: Env | undefined = {\n sendServer: undefined,\n};\n\nexport const standard: Env = {\n sendServer: Object.assign(noop, {\n // Add any specific properties if needed for sendServer\n }) as unknown as Env['sendServer'],\n};\n\n/**\n * Simulation tracking paths\n * Specifies which function calls to track during simulation\n */\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * API server destination step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is the configured endpoint, `body` is the JSON-stringified\n * event data (or mapped data), and `options` carries headers/method/timeout.\n *\n * Each `out` tuple is `['sendServer', url, body, options]` mirroring the real\n * call signature. The test fixture injects the configured settings per example.\n */\nconst URL = 'https://api.example.com/events';\n\nexport const fullEvent: Flow.StepExample = {\n title: 'Forward event data',\n description:\n 'A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.',\n in: getEvent('page view', {\n timestamp: 1700000800,\n data: { title: 'Docs', url: 'https://example.com/docs' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n title: 'Docs',\n url: 'https://example.com/docs',\n }),\n { headers: undefined, method: undefined, timeout: undefined },\n ],\n ],\n};\n\nexport const customHeaders: Flow.StepExample = {\n title: 'Custom headers',\n description:\n 'A form submission is sent to the API with custom request headers such as an API key for authentication.',\n in: getEvent('form submit', {\n timestamp: 1700000801,\n data: { type: 'contact', email: 'user@example.com' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: 'data',\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n type: 'contact',\n email: 'user@example.com',\n }),\n {\n headers: { 'X-API-Key': 'YOUR_API_KEY' },\n method: undefined,\n timeout: undefined,\n },\n ],\n ],\n};\n\nexport const customTransform: Flow.StepExample = {\n title: 'Custom payload',\n description:\n 'An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.',\n in: getEvent('order complete', {\n timestamp: 1700000802,\n data: { id: 'ORD-500', total: 199.99, currency: 'USD' },\n user: { id: 'buyer-42' },\n source: { type: 'server', id: '', previous_id: '' },\n }),\n mapping: {\n data: {\n map: {\n order_id: 'data.id',\n amount: 'data.total',\n currency: 'data.currency',\n customer_id: 'user.id',\n event_type: 'name',\n },\n },\n },\n out: [\n [\n 'sendServer',\n URL,\n JSON.stringify({\n order_id: 'ORD-500',\n amount: 199.99,\n currency: 'USD',\n customer_id: 'buyer-42',\n event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AAY,CAAC;AAElE,QAAI,CAAC,IAAK;AAEV,UAAM,YAAY,UAAU,IAAI,IAAI,OAAO;AAC3C,UAAM,OAAO,YACT,UAAU,WAAW,QAAQ,IAAI,IACjC,KAAK,UAAU,SAAS;AAE5B,qCAAQ,MAAM,mCAAmC;AAAA,MAC/C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,WAAW,MAAM;AAAA,IACnB;AAEA,UAAM,gBAAgB,2BAAa,eAAc;AACjD,UAAM,WAAW,MAAM,aAAa,KAAK,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,qCAAQ,MAAM,4BAA4B,EAAE,IAAI,qCAAU,GAAG;AAAA,EAC/D;AACF;AAEA,IAAO,gBAAQ;","names":[]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$meta": {
3
3
  "package": "@walkeros/server-destination-api",
4
- "version": "3.4.0",
4
+ "version": "3.4.1-next-1776790594143",
5
5
  "type": "destination",
6
6
  "platform": [
7
7
  "server"
@@ -59,6 +59,8 @@
59
59
  },
60
60
  "step": {
61
61
  "customHeaders": {
62
+ "title": "Custom headers",
63
+ "description": "A form submission is sent to the API with custom request headers such as an API key for authentication.",
62
64
  "in": {
63
65
  "name": "form submit",
64
66
  "data": {
@@ -109,7 +111,7 @@
109
111
  "group": "gr0up",
110
112
  "count": 1,
111
113
  "version": {
112
- "source": "3.4.0",
114
+ "source": "3.4.1-next-1776790594143",
113
115
  "tagging": 1
114
116
  },
115
117
  "source": {
@@ -135,6 +137,8 @@
135
137
  ]
136
138
  },
137
139
  "customTransform": {
140
+ "title": "Custom payload",
141
+ "description": "An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.",
138
142
  "in": {
139
143
  "name": "order complete",
140
144
  "data": {
@@ -217,7 +221,7 @@
217
221
  "group": "gr0up",
218
222
  "count": 1,
219
223
  "version": {
220
- "source": "3.4.0",
224
+ "source": "3.4.1-next-1776790594143",
221
225
  "tagging": 1
222
226
  },
223
227
  "source": {
@@ -247,6 +251,8 @@
247
251
  ]
248
252
  },
249
253
  "fullEvent": {
254
+ "title": "Forward event data",
255
+ "description": "A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",
250
256
  "in": {
251
257
  "name": "page view",
252
258
  "data": {
@@ -297,7 +303,7 @@
297
303
  "group": "gr0up",
298
304
  "count": 1,
299
305
  "version": {
300
- "source": "3.4.0",
306
+ "source": "3.4.1-next-1776790594143",
301
307
  "tagging": 1
302
308
  },
303
309
  "source": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/server-destination-api",
3
3
  "description": "API server destination for walkerOS",
4
- "version": "3.4.0",
4
+ "version": "3.4.1-next-1776790594143",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -37,8 +37,8 @@
37
37
  "update": "npx npm-check-updates -u && npm update"
38
38
  },
39
39
  "dependencies": {
40
- "@walkeros/core": "3.4.0",
41
- "@walkeros/server-core": "3.4.0"
40
+ "@walkeros/core": "3.4.1-next-1776790594143",
41
+ "@walkeros/server-core": "3.4.1-next-1776790594143"
42
42
  },
43
43
  "devDependencies": {},
44
44
  "repository": {