@walkeros/server-destination-api 3.4.2 → 4.0.0-next-1777463920154

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:()=>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
1
+ "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a=(e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})},i={};a(i,{examples:()=>p,schemas:()=>d}),module.exports=(e=i,((e,a,i,d)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let n of o(a))s.call(e,n)||n===i||t(e,n,{get:()=>a[n],enumerable:!(d=r(a,n))||d.enumerable});return e})(t({},"__esModule",{value:!0}),e));var d={};a(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={};a(p,{env:()=>l,step:()=>f});var l={};a(l,{init:()=>v,simulation:()=>y,standard:()=>h});var v={sendServer:void 0},h={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},y=["sendServer"],f={};a(f,{customHeaders:()=>S,customTransform:()=>P,fullEvent:()=>O});var g=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,g.getEvent)("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"express",platform:"server"}}),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,g.getEvent)("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"express",platform:"server"}}),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,g.getEvent)("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"express",platform:"server"}}),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 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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AK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,MAAM;AAAA,QACN,OAAO;AAAA,MACT,CAAC;AAAA,MACD;AAAA,QACE,SAAS,EAAE,aAAa,eAAe;AAAA,QACvC,QAAQ;AAAA,QACR,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,kBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,QAAI,sBAAS,kBAAkB;AAAA,IAC7B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,QAAQ,UAAU,MAAM;AAAA,IACtD,MAAM,EAAE,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: 'express', platform: 'server' },\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: 'express', platform: 'server' },\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: 'express', platform: 'server' },\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;;;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AO;AAAA,MACT,CAAC;AAAA,MACD;AAAA,QACE,SAAS,EAAE,aAAa,eAAe;AAAA,QACvC,QAAQ;AAAA,QACR,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,kBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,QAAI,sBAAS,kBAAkB;AAAA,IAC7B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,QAAQ,UAAU,MAAM;AAAA,IACtD,MAAM,EAAE,IAAI,WAAW;AAAA,IACvB,QAAQ,EAAE,MAAM,WAAW,UAAU,SAAS;AAAA,EAChD,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 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
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:()=>a,settings:()=>i});import{zodToSchema as o}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var a=s.object({url:s.string().url().describe("The API endpoint URL to send events to"),headers:s.record(s.string(),s.string()).describe("Custom HTTP headers to include with requests").optional(),method:s.string().describe("HTTP method to use (default: POST)").optional(),timeout:s.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()}),i=o(a),d={};t(d,{env:()=>n,step:()=>u});var n={};t(n,{init:()=>m,simulation:()=>c,standard:()=>p});var m={sendServer:void 0},p={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},c=["sendServer"],u={};t(u,{customHeaders:()=>y,customTransform:()=>f,fullEvent:()=>h});import{getEvent as l}from"@walkeros/core";var v="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:l("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"express",platform:"server"}}),mapping:{data:"data"},out:[["sendServer",v,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:l("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"express",platform:"server"}}),mapping:{data:"data"},out:[["sendServer",v,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:l("order complete",{timestamp:1700000802,data:{id:"ORD-500",total:199.99,currency:"USD"},user:{id:"buyer-42"},source:{type:"express",platform:"server"}}),mapping:{data:{map:{order_id:"data.id",amount:"data.total",currency:"data.currency",customer_id:"user.id",event_type:"name"}}},out:[["sendServer",v,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 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,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,QAA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AA,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,MAAM;AAAA,QACN,OAAO;AAAA,MACT,CAAC;AAAA,MACD;AAAA,QACE,SAAS,EAAE,aAAa,eAAe;AAAA,QACvC,QAAQ;AAAA,QACR,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,kBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,SAAS,kBAAkB;AAAA,IAC7B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,QAAQ,UAAU,MAAM;AAAA,IACtD,MAAM,EAAE,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":[]}
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: 'express', platform: 'server' },\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: 'express', platform: 'server' },\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: 'express', platform: 'server' },\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;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MACD;AAAA,QACE,SAAS,EAAE,aAAa,eAAe;AAAA,QACvC,QAAQ;AAAA,QACR,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,kBAAoC;AAAA,EAC/C,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,SAAS,kBAAkB;AAAA,IAC7B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,QAAQ,UAAU,MAAM;AAAA,IACtD,MAAM,EAAE,IAAI,WAAW;AAAA,IACvB,QAAQ,EAAE,MAAM,WAAW,UAAU,SAAS;AAAA,EAChD,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":[]}
@@ -58,7 +58,7 @@ var fullEvent = {
58
58
  in: (0, import_core.getEvent)("page view", {
59
59
  timestamp: 1700000800,
60
60
  data: { title: "Docs", url: "https://example.com/docs" },
61
- source: { type: "server", id: "", previous_id: "" }
61
+ source: { type: "express", platform: "server" }
62
62
  }),
63
63
  mapping: {
64
64
  data: "data"
@@ -81,7 +81,7 @@ var customHeaders = {
81
81
  in: (0, import_core.getEvent)("form submit", {
82
82
  timestamp: 1700000801,
83
83
  data: { type: "contact", email: "user@example.com" },
84
- source: { type: "server", id: "", previous_id: "" }
84
+ source: { type: "express", platform: "server" }
85
85
  }),
86
86
  mapping: {
87
87
  data: "data"
@@ -109,7 +109,7 @@ var customTransform = {
109
109
  timestamp: 1700000802,
110
110
  data: { id: "ORD-500", total: 199.99, currency: "USD" },
111
111
  user: { id: "buyer-42" },
112
- source: { type: "server", id: "", previous_id: "" }
112
+ source: { type: "express", platform: "server" }
113
113
  }),
114
114
  mapping: {
115
115
  data: {
@@ -37,7 +37,7 @@ var fullEvent = {
37
37
  in: getEvent("page view", {
38
38
  timestamp: 1700000800,
39
39
  data: { title: "Docs", url: "https://example.com/docs" },
40
- source: { type: "server", id: "", previous_id: "" }
40
+ source: { type: "express", platform: "server" }
41
41
  }),
42
42
  mapping: {
43
43
  data: "data"
@@ -60,7 +60,7 @@ var customHeaders = {
60
60
  in: getEvent("form submit", {
61
61
  timestamp: 1700000801,
62
62
  data: { type: "contact", email: "user@example.com" },
63
- source: { type: "server", id: "", previous_id: "" }
63
+ source: { type: "express", platform: "server" }
64
64
  }),
65
65
  mapping: {
66
66
  data: "data"
@@ -88,7 +88,7 @@ var customTransform = {
88
88
  timestamp: 1700000802,
89
89
  data: { id: "ORD-500", total: 199.99, currency: "USD" },
90
90
  user: { id: "buyer-42" },
91
- source: { type: "server", id: "", previous_id: "" }
91
+ source: { type: "express", platform: "server" }
92
92
  }),
93
93
  mapping: {
94
94
  data: {
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={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
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:"express",platform:"server"}}),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:"express",platform:"server"}}),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:"express",platform:"server"}}),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);logger?.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=env?.sendServer||import_server_core.sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});logger?.debug("API destination response",{ok: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 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;AAA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QACb,YAAY;AAAA,MACd,CAAC;AAAA,MACD,EAAE,SAAS,QAAW,QAAQ,QAAW,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"]}
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: 'express', platform: 'server' },\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: 'express', platform: 'server' },\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: 'express', platform: 'server' },\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 compl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AQ,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,YAAQ,MAAM,mCAAmC;AAAA,MAC/C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,WAAW,MAAM;AAAA,IACnB,CAAC;AAED,UAAM,eAAgB,KAAa,cAAc;AACjD,UAAM,WAAW,MAAM,aAAa,KAAK,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,4BAA4B,EAAE,IAAI,UAAU,GAAG,CAAC;AAAA,EAChE;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={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
+ 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:"express",platform:"server"}}),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:"express",platform:"server"}}),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:"express",platform:"server"}}),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);logger?.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=env?.sendServer||sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});logger?.debug("API destination response",{ok: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 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":";;;;;;;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,OAAO;AAAA,EACP,aACE;AAAA,EACF,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,IAC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;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;;;AJ9FO,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: 'express', platform: 'server' },\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: 'express', platform: 'server' },\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: 'express', platform: 'server' },\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,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,SAAS,aAAa;AAAA,IACxB,WAAW;AAAA,IACX,MAAM,EAAE,OAAO,QAAQ,KAAK,2BAA2B;AAAA,IACvD,QAAQ,EAAE,MAAM,WAAW,UAAU,SAAS;AAAA,EAChD,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,QAAW,SAAS,OAAU;AAAA,IAC9D;AAAA,EACF;AACF;AAEO,IAAM,gBAAkC;AAAA,EAC7C,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,SAAS,eAAe;AAAA,IAC1B,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,WAAW,OAAO,mBAAmB;AAAA,IACnD,QAAQ,E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ACrB,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,YAAQ,MAAM,mCAAmC;AAAA,MAC/C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,WAAW,MAAM;AAAA,IACnB,CAAC;AAED,UAAM,eAAgB,KAAa,cAAc;AACjD,UAAM,WAAW,MAAM,aAAa,KAAK,MAAM;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,4BAA4B,EAAE,IAAI,UAAU,GAAG,CAAC;AAAA,EAChE;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.2",
4
+ "version": "4.0.0-next-1777463920154",
5
5
  "type": "destination",
6
6
  "platform": [
7
7
  "server"
@@ -89,35 +89,21 @@
89
89
  "entity": "child",
90
90
  "data": {
91
91
  "is": "subordinated"
92
- },
93
- "nested": [],
94
- "context": {
95
- "element": [
96
- "child",
97
- 0
98
- ]
99
92
  }
100
93
  }
101
94
  ],
102
95
  "consent": {
103
96
  "functional": true
104
97
  },
105
- "id": "1700000801-gr0up-1",
98
+ "id": "e35eee1a769deb03",
106
99
  "trigger": "test",
107
100
  "entity": "form",
108
101
  "action": "submit",
109
102
  "timestamp": 1700000801,
110
103
  "timing": 3.14,
111
- "group": "gr0up",
112
- "count": 1,
113
- "version": {
114
- "source": "3.4.2",
115
- "tagging": 1
116
- },
117
104
  "source": {
118
- "type": "server",
119
- "id": "",
120
- "previous_id": ""
105
+ "type": "express",
106
+ "platform": "server"
121
107
  }
122
108
  },
123
109
  "mapping": {
@@ -212,22 +198,15 @@
212
198
  "consent": {
213
199
  "functional": true
214
200
  },
215
- "id": "1700000802-gr0up-1",
201
+ "id": "4f852598c7456cf4",
216
202
  "trigger": "load",
217
203
  "entity": "order",
218
204
  "action": "complete",
219
205
  "timestamp": 1700000802,
220
206
  "timing": 3.14,
221
- "group": "gr0up",
222
- "count": 1,
223
- "version": {
224
- "source": "3.4.2",
225
- "tagging": 1
226
- },
227
207
  "source": {
228
- "type": "server",
229
- "id": "",
230
- "previous_id": ""
208
+ "type": "express",
209
+ "platform": "server"
231
210
  }
232
211
  },
233
212
  "mapping": {
@@ -281,35 +260,21 @@
281
260
  "entity": "child",
282
261
  "data": {
283
262
  "is": "subordinated"
284
- },
285
- "nested": [],
286
- "context": {
287
- "element": [
288
- "child",
289
- 0
290
- ]
291
263
  }
292
264
  }
293
265
  ],
294
266
  "consent": {
295
267
  "functional": true
296
268
  },
297
- "id": "1700000800-gr0up-1",
269
+ "id": "be1b2abcb85b8973",
298
270
  "trigger": "load",
299
271
  "entity": "page",
300
272
  "action": "view",
301
273
  "timestamp": 1700000800,
302
274
  "timing": 3.14,
303
- "group": "gr0up",
304
- "count": 1,
305
- "version": {
306
- "source": "3.4.2",
307
- "tagging": 1
308
- },
309
275
  "source": {
310
- "type": "server",
311
- "id": "",
312
- "previous_id": ""
276
+ "type": "express",
277
+ "platform": "server"
313
278
  }
314
279
  },
315
280
  "mapping": {
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.2",
4
+ "version": "4.0.0-next-1777463920154",
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.2",
41
- "@walkeros/server-core": "3.4.2"
40
+ "@walkeros/core": "4.0.0-next-1777463920154",
41
+ "@walkeros/server-core": "4.0.0-next-1777463920154"
42
42
  },
43
43
  "devDependencies": {},
44
44
  "repository": {