@walkeros/server-destination-api 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @walkeros/server-destination-api
2
2
 
3
+ ## 4.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4de76ed: `config.batch` now works on the server API destination. It previously
8
+ had no `pushBatch`, which is the collector's gate for batching, so the setting
9
+ was accepted and silently ignored and every event was still sent as its own
10
+ request. A flush is now one request whose body is a JSON array of the batched
11
+ events, one element per event, mapped per event and passed through `transform`
12
+ per element, matching the web variant. `transform` is also declared in the
13
+ settings schema now, so it shows up in the package hints instead of being an
14
+ undocumented option.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [63845bb]
19
+ - Updated dependencies [79cdcb0]
20
+ - Updated dependencies [756b571]
21
+ - @walkeros/core@4.5.0
22
+ - @walkeros/server-core@4.5.0
23
+
3
24
  ## 4.4.0
4
25
 
5
26
  ### Patch Changes
package/dist/dev.d.mts CHANGED
@@ -7,17 +7,25 @@ declare const SettingsSchema: z.ZodObject<{
7
7
  url: z.ZodString;
8
8
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
9
9
  method: z.ZodOptional<z.ZodString>;
10
+ transform: z.ZodOptional<z.ZodAny>;
10
11
  timeout: z.ZodOptional<z.ZodNumber>;
11
12
  }, z.core.$strip>;
12
13
  type Settings = z.infer<typeof SettingsSchema>;
13
14
 
15
+ declare const MappingSchema: z.ZodObject<{}, z.core.$strip>;
16
+ type Mapping = z.infer<typeof MappingSchema>;
17
+
14
18
  declare const settings: _walkeros_core_dev.JSONSchema;
19
+ declare const mapping: _walkeros_core_dev.JSONSchema;
15
20
 
21
+ type index$1_Mapping = Mapping;
22
+ declare const index$1_MappingSchema: typeof MappingSchema;
16
23
  type index$1_Settings = Settings;
17
24
  declare const index$1_SettingsSchema: typeof SettingsSchema;
25
+ declare const index$1_mapping: typeof mapping;
18
26
  declare const index$1_settings: typeof settings;
19
27
  declare namespace index$1 {
20
- export { type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
28
+ export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
21
29
  }
22
30
 
23
31
  interface Env extends DestinationServer.Env {
package/dist/dev.d.ts CHANGED
@@ -7,17 +7,25 @@ declare const SettingsSchema: z.ZodObject<{
7
7
  url: z.ZodString;
8
8
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
9
9
  method: z.ZodOptional<z.ZodString>;
10
+ transform: z.ZodOptional<z.ZodAny>;
10
11
  timeout: z.ZodOptional<z.ZodNumber>;
11
12
  }, z.core.$strip>;
12
13
  type Settings = z.infer<typeof SettingsSchema>;
13
14
 
15
+ declare const MappingSchema: z.ZodObject<{}, z.core.$strip>;
16
+ type Mapping = z.infer<typeof MappingSchema>;
17
+
14
18
  declare const settings: _walkeros_core_dev.JSONSchema;
19
+ declare const mapping: _walkeros_core_dev.JSONSchema;
15
20
 
21
+ type index$1_Mapping = Mapping;
22
+ declare const index$1_MappingSchema: typeof MappingSchema;
16
23
  type index$1_Settings = Settings;
17
24
  declare const index$1_SettingsSchema: typeof SettingsSchema;
25
+ declare const index$1_mapping: typeof mapping;
18
26
  declare const index$1_settings: typeof settings;
19
27
  declare namespace index$1 {
20
- export { type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
28
+ export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
21
29
  }
22
30
 
23
31
  interface Env extends DestinationServer.Env {
package/dist/dev.js CHANGED
@@ -1 +1 @@
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
1
+ "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,i=(e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})},s={};i(s,{examples:()=>v,schemas:()=>d}),module.exports=(e=s,((e,i,s,d)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let n of o(i))a.call(e,n)||n===s||t(e,n,{get:()=>i[n],enumerable:!(d=r(i,n))||d.enumerable});return e})(t({},"__esModule",{value:!0}),e));var d={};i(d,{MappingSchema:()=>p,SettingsSchema:()=>c,mapping:()=>l,settings:()=>u});var n=require("@walkeros/core/dev"),m=require("@walkeros/core/dev"),c=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(),transform:m.z.any().describe("Function to transform event data before sending (like (data, config, mapping) => JSON.stringify(data))").optional(),timeout:m.z.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()}),p=require("@walkeros/core/dev").z.object({}),u=(0,n.zodToSchema)(c),l=(0,n.zodToSchema)(p),v={};i(v,{env:()=>h,step:()=>b});var h={};i(h,{init:()=>g,simulation:()=>f,standard:()=>y});var g={sendServer:void 0},y={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},f=["sendServer"],b={};i(b,{customHeaders:()=>w,customTransform:()=>z,fullEvent:()=>P});var S=require("@walkeros/core"),O="https://api.example.com/events",P={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,S.getEvent)("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"express",platform:"server"}}),mapping:{data:"data"},out:[["sendServer",O,JSON.stringify({title:"Docs",url:"https://example.com/docs"}),{headers:void 0,method:void 0,timeout:void 0}]]},w={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,S.getEvent)("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"express",platform:"server"}}),mapping:{data:"data"},out:[["sendServer",O,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},z={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,S.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",O,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: '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;;;ADRM,IAAM,eAAW,yBAAY,cAAc;;;AENlD;AAAA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AAS,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"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\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 transform: z\n .any()\n .describe(\n 'Function to transform event data before sending (like (data, config, mapping) => JSON.stringify(data))',\n )\n .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","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\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;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,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,eAAe;AAAA,IAC1B,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,WAAW,OAAO,mBAAmB;AAAA,IACnD,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,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,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","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:()=>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
1
+ var e=Object.defineProperty,t=(t,r)=>{for(var o in r)e(t,o,{get:r[o],enumerable:!0})},r={};t(r,{MappingSchema:()=>d,SettingsSchema:()=>i,mapping:()=>m,settings:()=>n});import{zodToSchema as o}from"@walkeros/core/dev";import{z as a}from"@walkeros/core/dev";var i=a.object({url:a.string().url().describe("The API endpoint URL to send events to"),headers:a.record(a.string(),a.string()).describe("Custom HTTP headers to include with requests").optional(),method:a.string().describe("HTTP method to use (default: POST)").optional(),transform:a.any().describe("Function to transform event data before sending (like (data, config, mapping) => JSON.stringify(data))").optional(),timeout:a.number().positive().describe("Request timeout in milliseconds (default: 5000)").optional()});import{z as s}from"@walkeros/core/dev";var d=s.object({}),n=o(i),m=o(d),p={};t(p,{env:()=>c,step:()=>h});var c={};t(c,{init:()=>u,simulation:()=>v,standard:()=>l});var u={sendServer:void 0},l={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},v=["sendServer"],h={};t(h,{customHeaders:()=>S,customTransform:()=>b,fullEvent:()=>y});import{getEvent as f}from"@walkeros/core";var g="https://api.example.com/events",y={title:"Forward event data",description:"A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",in:f("page view",{timestamp:1700000800,data:{title:"Docs",url:"https://example.com/docs"},source:{type:"express",platform:"server"}}),mapping:{data:"data"},out:[["sendServer",g,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:f("form submit",{timestamp:1700000801,data:{type:"contact",email:"user@example.com"},source:{type:"express",platform:"server"}}),mapping:{data:"data"},out:[["sendServer",g,JSON.stringify({type:"contact",email:"user@example.com"}),{headers:{"X-API-Key":"YOUR_API_KEY"},method:void 0,timeout:void 0}]]},b={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:f("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",g,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{p 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: '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;;;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,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,M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AA,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/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\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 transform: z\n .any()\n .describe(\n 'Function to transform event data before sending (like (data, config, mapping) => JSON.stringify(data))',\n )\n .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","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\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;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,WAAW,EACR,IAAI,EACJ;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,SAAS,EACN,OAAO,EACP,SAAS,EACT,SAAS,iDAAiD,EAC1D,SAAS;AACd,CAAC;;;ACpBD,SAAS,KAAAA,UAAS;AAEX,IAAM,gBAAgBA,GAAE,OAAO,CAAC,CAAC;;;AFMjC,IAAM,WAAW,YAAY,cAAc;AAC3C,IAAM,UAAU,YAAY,aAAa;;;AGThD;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,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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":["z"]}
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,index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationAPI:()=>types_exports,default:()=>index_default,destinationAPI:()=>destinationAPI}),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_core=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),types_exports={},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_core.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
1
+ "use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationAPI:()=>types_exports,default:()=>index_default,destinationAPI:()=>destinationAPI}),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_core=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),types_exports={};async function send(body,settings,env,logger){const{url:url,headers:headers,method:method,timeout:timeout}=settings,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})}var 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,method:method,transform:transform}=settings||{};if(!url)return;const eventData=(0,import_core.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}),await send(body,{...settings,url:url},env,logger)},async pushBatch(batch,{config:config,rule:rule,env:env,logger:logger}){const{settings:settings}=config,{url:url,method:method,transform:transform}=settings||{};if(!url)return;const items=batch.entries.map(entry=>(0,import_core.isDefined)(entry.data)?entry.data:entry.event),payload=transform?items.map(item=>transform(item,config,rule)):items;logger?.debug("API destination sending batch",{url:url,method:method||"POST",events:items.length}),await send(JSON.stringify(payload),{...settings,url:url},env,logger)}},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"],"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\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA0B;AAC1B,yBAA2B;;;ACF3B;;;ADOO,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,uBAAU,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
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { Logger, SendDataValue } from '@walkeros/core';\nimport 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\nasync function send(\n body: SendDataValue,\n settings: Settings,\n env: Env | undefined,\n logger?: Logger.Instance,\n): Promise<void> {\n const { url, headers, method, timeout } = settings;\n const sendServerFn = env?.sendServer || sendServer;\n\n const response = await sendServerFn(url, body, { headers, method, timeout });\n\n logger?.debug('API destination response', { ok: response?.ok });\n}\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, method, transform } = 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 await send(body, { ...settings, url }, env, logger);\n },\n\n async pushBatch(batch, { config, rule, env, logger }) {\n const { settings } = config;\n const { url, method, transform } = settings || {};\n\n if (!url) return;\n\n const items = batch.entries.map((entry) =>\n isDefined(entry.data) ? entry.data : entry.event,\n );\n\n // Transform applies per item; the request body is the array of results\n const payload = transform\n ? items.map((item) => transform(item, config, rule))\n : items;\n\n logger?.debug('API destination sending batch', {\n url,\n method: method || 'POST',\n events: items.length,\n });\n\n await send(JSON.stringify(payload), { ...settings, url }, env, logger);\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA0B;AAC1B,yBAA2B;;;ACH3B;;;ADQA,eAAe,KACb,MACA,UACA,KACA,QACe;AACf,QAAM,EA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AAAA,MAClB,QAAQ,MAAM;AAAA,IAChB,CAAC;AAED,UAAM,KAAK,KAAK,UAAU,OAAO,GAAG,EAAE,GAAG,UAAU,IAAI,GAAG,KAAK,MAAM;AAAA,EACvE;AACF;AAEA,IAAO,gBAAQ;","names":[]}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{isDefined}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";var types_exports={},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};//# sourceMappingURL=index.mjs.map
1
+ import{isDefined}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";var types_exports={};async function send(body,settings,env,logger){const{url:url,headers:headers,method:method,timeout:timeout}=settings,sendServerFn=env?.sendServer||sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});logger?.debug("API destination response",{ok:response?.ok})}var 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,method:method,transform:transform}=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}),await send(body,{...settings,url:url},env,logger)},async pushBatch(batch,{config:config,rule:rule,env:env,logger:logger}){const{settings:settings}=config,{url:url,method:method,transform:transform}=settings||{};if(!url)return;const items=batch.entries.map(entry=>isDefined(entry.data)?entry.data:entry.event),payload=transform?items.map(item=>transform(item,config,rule)):items;logger?.debug("API destination sending batch",{url:url,method:method||"POST",events:items.length}),await send(JSON.stringify(payload),{...settings,url:url},env,logger)}},index_default=destinationAPI;export{types_exports as DestinationAPI,index_default as default,destinationAPI};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/index.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\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"],"mappings":";AACA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;;;ACF3B;;;ADOO,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,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
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { Logger, SendDataValue } from '@walkeros/core';\nimport 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\nasync function send(\n body: SendDataValue,\n settings: Settings,\n env: Env | undefined,\n logger?: Logger.Instance,\n): Promise<void> {\n const { url, headers, method, timeout } = settings;\n const sendServerFn = env?.sendServer || sendServer;\n\n const response = await sendServerFn(url, body, { headers, method, timeout });\n\n logger?.debug('API destination response', { ok: response?.ok });\n}\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, method, transform } = 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 await send(body, { ...settings, url }, env, logger);\n },\n\n async pushBatch(batch, { config, rule, env, logger }) {\n const { settings } = config;\n const { url, method, transform } = settings || {};\n\n if (!url) return;\n\n const items = batch.entries.map((entry) =>\n isDefined(entry.data) ? entry.data : entry.event,\n );\n\n // Transform applies per item; the request body is the array of results\n const payload = transform\n ? items.map((item) => transform(item, config, rule))\n : items;\n\n logger?.debug('API destination sending batch', {\n url,\n method: method || 'POST',\n events: items.length,\n });\n\n await send(JSON.stringify(payload), { ...settings, url }, env, logger);\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"],"mappings":";AAEA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;;;ACH3B;;;ADQ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iC;AAAA,MAC7C;AAAA,MACA,QAAQ,UAAU;AAAA,MAClB,QAAQ,MAAM;AAAA,IAChB,CAAC;AAED,UAAM,KAAK,KAAK,UAAU,OAAO,GAAG,EAAE,GAAG,UAAU,IAAI,GAAG,KAAK,MAAM;AAAA,EACvE;AACF;AAEA,IAAO,gBAAQ;","names":[]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$meta": {
3
3
  "package": "@walkeros/server-destination-api",
4
- "version": "4.4.0",
4
+ "version": "4.5.0",
5
5
  "type": "destination",
6
6
  "platform": [
7
7
  "server"
@@ -10,6 +10,12 @@
10
10
  "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/server/destinations/api/src"
11
11
  },
12
12
  "schemas": {
13
+ "mapping": {
14
+ "$schema": "http://json-schema.org/draft-07/schema#",
15
+ "type": "object",
16
+ "properties": {},
17
+ "additionalProperties": false
18
+ },
13
19
  "settings": {
14
20
  "$schema": "http://json-schema.org/draft-07/schema#",
15
21
  "type": "object",
@@ -33,6 +39,9 @@
33
39
  "type": "string",
34
40
  "description": "HTTP method to use (default: POST)"
35
41
  },
42
+ "transform": {
43
+ "description": "Function to transform event data before sending (like (data, config, mapping) => JSON.stringify(data))"
44
+ },
36
45
  "timeout": {
37
46
  "type": "number",
38
47
  "exclusiveMinimum": 0,
@@ -95,7 +104,7 @@
95
104
  "consent": {
96
105
  "functional": true
97
106
  },
98
- "id": "31ae7659767e8c1f",
107
+ "id": "5e83c50e659cd25b",
99
108
  "trigger": "test",
100
109
  "entity": "form",
101
110
  "action": "submit",
@@ -200,7 +209,7 @@
200
209
  "consent": {
201
210
  "functional": true
202
211
  },
203
- "id": "12e18a57ff2bd145",
212
+ "id": "14ef2cb376c756eb",
204
213
  "trigger": "load",
205
214
  "entity": "order",
206
215
  "action": "complete",
@@ -270,7 +279,7 @@
270
279
  "consent": {
271
280
  "functional": true
272
281
  },
273
- "id": "9c823e090ed374c8",
282
+ "id": "ce83c51ce270ca49",
274
283
  "trigger": "load",
275
284
  "entity": "page",
276
285
  "action": "view",
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": "4.4.0",
4
+ "version": "4.5.0",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -38,8 +38,8 @@
38
38
  "update": "npx npm-check-updates -u && npm update"
39
39
  },
40
40
  "dependencies": {
41
- "@walkeros/core": "4.4.0",
42
- "@walkeros/server-core": "4.4.0"
41
+ "@walkeros/core": "4.5.0",
42
+ "@walkeros/server-core": "4.5.0"
43
43
  },
44
44
  "devDependencies": {},
45
45
  "repository": {