@walkeros/server-destination-api 0.5.1-next.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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_core3=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),types_exports={},examples_exports={};__export(examples_exports,{env:()=>env_exports,events:()=>events_exports,mapping:()=>mapping_exports,outputs:()=>outputs_exports});var env_exports={};__export(env_exports,{init:()=>init,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},events_exports={};__export(events_exports,{entity_action:()=>entity_action});var import_core=require("@walkeros/core");function entity_action(){const event=(0,import_core.getEvent)("entity action");return JSON.stringify(event.data)}var mapping_exports={};__export(mapping_exports,{config:()=>config,entity_action:()=>entity_action2});var entity_action2={data:"data"},config={entity:{action:entity_action2}},outputs_exports={};__export(outputs_exports,{customOptionsPost:()=>customOptionsPost,fullEventPost:()=>fullEventPost,mappedDataPost:()=>mappedDataPost});var sampleEvent=(0,require("@walkeros/core").getEvent)("entity action"),fullEventPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:void 0,method:void 0,timeout:void 0}},mappedDataPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent.data),options:{headers:void 0,method:void 0,timeout:void 0}},customOptionsPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:{"X-API-Key":"YOUR_API_KEY","Content-Type":"application/json"},method:"PUT",timeout:1e4}},destinationAPI={type:"api",config:{},env:{sendServer:import_server_core.sendServer},async push(event,{config:config2,mapping:mapping,data:data,env:env,logger:logger}){const{settings:settings}=config2,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=(0,import_core3.isDefined)(data)?data:event,body=transform?transform(eventData,config2,mapping):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_core3=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),types_exports={},examples_exports={};__export(examples_exports,{env:()=>env_exports,events:()=>events_exports,mapping:()=>mapping_exports,outputs:()=>outputs_exports});var env_exports={};__export(env_exports,{init:()=>init,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},events_exports={};__export(events_exports,{entity_action:()=>entity_action});var import_core=require("@walkeros/core");function entity_action(){const event=(0,import_core.getEvent)("entity action");return JSON.stringify(event.data)}var mapping_exports={};__export(mapping_exports,{config:()=>config,entity_action:()=>entity_action2});var entity_action2={data:"data"},config={entity:{action:entity_action2}},outputs_exports={};__export(outputs_exports,{customOptionsPost:()=>customOptionsPost,fullEventPost:()=>fullEventPost,mappedDataPost:()=>mappedDataPost});var sampleEvent=(0,require("@walkeros/core").getEvent)("entity action"),fullEventPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:void 0,method:void 0,timeout:void 0}},mappedDataPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent.data),options:{headers:void 0,method:void 0,timeout:void 0}},customOptionsPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:{"X-API-Key":"YOUR_API_KEY","Content-Type":"application/json"},method:"PUT",timeout:1e4}},destinationAPI={type:"api",config:{},env:{sendServer:import_server_core.sendServer},async push(event,{config:config2,rule:rule,data:data,env:env,logger:logger}){const{settings:settings}=config2,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=(0,import_core3.isDefined)(data)?data:event,body=transform?transform(eventData,config2,rule):JSON.stringify(eventData);null==logger||logger.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=(null==env?void 0:env.sendServer)||import_server_core.sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});null==logger||logger.debug("API destination response",{ok:null==response?void 0:response.ok})}},index_default=destinationAPI;//# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/examples/outputs.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, mapping, 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, mapping) // 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 events from './events';\nexport * as mapping from './mapping';\nexport * as outputs from './outputs';\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","import { getEvent } from '@walkeros/core';\n\nexport function entity_action() {\n const event = getEvent('entity action');\n\n return JSON.stringify(event.data);\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { Rule, Rules } from '../types';\n\nexport const entity_action: Rule = {\n data: 'data',\n};\n\nexport const config = {\n entity: { action: entity_action },\n} satisfies Rules;\n","import { getEvent } from '@walkeros/core';\n\n/**\n * Examples of API calls the destination will make.\n * Tests verify implementation produces these outputs.\n */\n\nconst sampleEvent = getEvent('entity action');\n\n// Full event POST (default behavior)\nexport const fullEventPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom data (via mapping)\nexport const mappedDataPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent.data),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom headers and method\nexport const customOptionsPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: {\n headers: {\n 'X-API-Key': 'YOUR_API_KEY',\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n timeout: 10000,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,eAA0B;AAC1B,yBAA2B;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;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;;;ACnBA;AAAA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ACT,UAAU,WAAWA,SAAQ,OAAO,IACpC,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","entity_action","import_core","config"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/examples/outputs.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 events from './events';\nexport * as mapping from './mapping';\nexport * as outputs from './outputs';\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","import { getEvent } from '@walkeros/core';\n\nexport function entity_action() {\n const event = getEvent('entity action');\n\n return JSON.stringify(event.data);\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { Rule, Rules } from '../types';\n\nexport const entity_action: Rule = {\n data: 'data',\n};\n\nexport const config = {\n entity: { action: entity_action },\n} satisfies Rules;\n","import { getEvent } from '@walkeros/core';\n\n/**\n * Examples of API calls the destination will make.\n * Tests verify implementation produces these outputs.\n */\n\nconst sampleEvent = getEvent('entity action');\n\n// Full event POST (default behavior)\nexport const fullEventPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom data (via mapping)\nexport const mappedDataPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent.data),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom headers and method\nexport const customOptionsPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: {\n headers: {\n 'X-API-Key': 'YOUR_API_KEY',\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n timeout: 10000,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,eAA0B;AAC1B,yBAA2B;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;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;;;ACnBA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAElB,SAAS,gBAAgB;AAC9B,QAAM,YAAQ,sBAAS,eAAe;AAEtC,SAAO,KAAK,UAAU,MAAM,IAAI;AAClC;;;ACNA;AAAA;AAAA;AAAA,uBAAAC;AAAA;AAGO,IAAMA,iBAAsB;AAAA,EACjC,MAAM;AACR;AAEO,IAAM,SAAS;AAAA,EACpB,QAAQ,EAAE,QAAQA,eAAc;AAClC;;;ACTA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAC,eAAyB;AAOzB,IAAM,kBAAc,uBAAS,eAAe;AAGrC,IAAM,gBAAgB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,iBAAiB;AAAA,EAC5B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,YAAY,IAAI;AAAA,EACrC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,oBAAoB;AAAA,EAC/B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS;AAAA,IACP,SAAS;AAAA,MACP,aAAa;AAAA,MACb,gBAAgB;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;;;ANzBO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,0CAAW;AAAA,EAElB,MAAM,KAAK,OAAO,EAAE,QAAAC,SAAQ,MAAM,MAAM,KAAK,OAAO,GAAG;AACrD,UAAM,EAAE,SAAS,IAAIA;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,WAAWA,SAAQ,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","entity_action","import_core","config"]}
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,events:()=>events_exports,mapping:()=>mapping_exports,outputs:()=>outputs_exports});var env_exports={};__export(env_exports,{init:()=>init,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},events_exports={};__export(events_exports,{entity_action:()=>entity_action});import{getEvent}from"@walkeros/core";function entity_action(){const event=getEvent("entity action");return JSON.stringify(event.data)}var mapping_exports={};__export(mapping_exports,{config:()=>config,entity_action:()=>entity_action2});var entity_action2={data:"data"},config={entity:{action:entity_action2}},outputs_exports={};__export(outputs_exports,{customOptionsPost:()=>customOptionsPost,fullEventPost:()=>fullEventPost,mappedDataPost:()=>mappedDataPost});import{getEvent as getEvent2}from"@walkeros/core";var sampleEvent=getEvent2("entity action"),fullEventPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:void 0,method:void 0,timeout:void 0}},mappedDataPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent.data),options:{headers:void 0,method:void 0,timeout:void 0}},customOptionsPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:{"X-API-Key":"YOUR_API_KEY","Content-Type":"application/json"},method:"PUT",timeout:1e4}},destinationAPI={type:"api",config:{},env:{sendServer:sendServer},async push(event,{config:config2,mapping:mapping,data:data,env:env,logger:logger}){const{settings:settings}=config2,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=isDefined(data)?data:event,body=transform?transform(eventData,config2,mapping):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,events:()=>events_exports,mapping:()=>mapping_exports,outputs:()=>outputs_exports});var env_exports={};__export(env_exports,{init:()=>init,standard:()=>standard});var init={sendServer:void 0},standard={sendServer:Object.assign(()=>Promise.resolve({ok:!0}),{})},events_exports={};__export(events_exports,{entity_action:()=>entity_action});import{getEvent}from"@walkeros/core";function entity_action(){const event=getEvent("entity action");return JSON.stringify(event.data)}var mapping_exports={};__export(mapping_exports,{config:()=>config,entity_action:()=>entity_action2});var entity_action2={data:"data"},config={entity:{action:entity_action2}},outputs_exports={};__export(outputs_exports,{customOptionsPost:()=>customOptionsPost,fullEventPost:()=>fullEventPost,mappedDataPost:()=>mappedDataPost});import{getEvent as getEvent2}from"@walkeros/core";var sampleEvent=getEvent2("entity action"),fullEventPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:void 0,method:void 0,timeout:void 0}},mappedDataPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent.data),options:{headers:void 0,method:void 0,timeout:void 0}},customOptionsPost={url:"https://api.example.com/events",body:JSON.stringify(sampleEvent),options:{headers:{"X-API-Key":"YOUR_API_KEY","Content-Type":"application/json"},method:"PUT",timeout:1e4}},destinationAPI={type:"api",config:{},env:{sendServer:sendServer},async push(event,{config:config2,rule:rule,data:data,env:env,logger:logger}){const{settings:settings}=config2,{url:url,headers:headers,method:method,transform:transform,timeout:timeout}=settings||{};if(!url)return;const eventData=isDefined(data)?data:event,body=transform?transform(eventData,config2,rule):JSON.stringify(eventData);null==logger||logger.debug("API destination sending request",{url:url,method:method||"POST",eventName:event.name});const sendServerFn=(null==env?void 0:env.sendServer)||sendServer,response=await sendServerFn(url,body,{headers:headers,method:method,timeout:timeout});null==logger||logger.debug("API destination response",{ok:null==response?void 0:response.ok})}},index_default=destinationAPI;export{types_exports as DestinationAPI,index_default as default,destinationAPI,examples_exports as examples};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/examples/outputs.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, mapping, 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, mapping) // 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 events from './events';\nexport * as mapping from './mapping';\nexport * as outputs from './outputs';\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","import { getEvent } from '@walkeros/core';\n\nexport function entity_action() {\n const event = getEvent('entity action');\n\n return JSON.stringify(event.data);\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { Rule, Rules } from '../types';\n\nexport const entity_action: Rule = {\n data: 'data',\n};\n\nexport const config = {\n entity: { action: entity_action },\n} satisfies Rules;\n","import { getEvent } from '@walkeros/core';\n\n/**\n * Examples of API calls the destination will make.\n * Tests verify implementation produces these outputs.\n */\n\nconst sampleEvent = getEvent('entity action');\n\n// Full event POST (default behavior)\nexport const fullEventPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom data (via mapping)\nexport const mappedDataPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent.data),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom headers and method\nexport const customOptionsPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: {\n headers: {\n 'X-API-Key': 'YOUR_API_KEY',\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n timeout: 10000,\n },\n};\n"],"mappings":";;;;;;;AACA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;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;AA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AAY,UAAU,IAAI,IAAI,OAAO;AAC3C,UAAM,OAAO,YACT,UAAU,WAAWA,SAAQ,OAAO,IACpC,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":["entity_action","getEvent","config"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/examples/outputs.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 events from './events';\nexport * as mapping from './mapping';\nexport * as outputs from './outputs';\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","import { getEvent } from '@walkeros/core';\n\nexport function entity_action() {\n const event = getEvent('entity action');\n\n return JSON.stringify(event.data);\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { Rule, Rules } from '../types';\n\nexport const entity_action: Rule = {\n data: 'data',\n};\n\nexport const config = {\n entity: { action: entity_action },\n} satisfies Rules;\n","import { getEvent } from '@walkeros/core';\n\n/**\n * Examples of API calls the destination will make.\n * Tests verify implementation produces these outputs.\n */\n\nconst sampleEvent = getEvent('entity action');\n\n// Full event POST (default behavior)\nexport const fullEventPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom data (via mapping)\nexport const mappedDataPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent.data),\n options: { headers: undefined, method: undefined, timeout: undefined },\n};\n\n// POST with custom headers and method\nexport const customOptionsPost = {\n url: 'https://api.example.com/events',\n body: JSON.stringify(sampleEvent),\n options: {\n headers: {\n 'X-API-Key': 'YOUR_API_KEY',\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n timeout: 10000,\n },\n};\n"],"mappings":";;;;;;;AACA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;;;ACF3B;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;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;;;ACnBA;AAAA;AAAA;AAAA;AAAA,SAAS,gBAAgB;AAElB,SAAS,gBAAgB;AAC9B,QAAM,QAAQ,SAAS,eAAe;AAEtC,SAAO,KAAK,UAAU,MAAM,IAAI;AAClC;;;ACNA;AAAA;AAAA;AAAA,uBAAAA;AAAA;AAGO,IAAMA,iBAAsB;AAAA,EACjC,MAAM;AACR;AAEO,IAAM,SAAS;AAAA,EACpB,QAAQ,EAAE,QAAQA,eAAc;AAClC;;;ACTA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,YAAAC,iBAAgB;AAOzB,IAAM,cAAcA,UAAS,eAAe;AAGrC,IAAM,gBAAgB;AAAA,EAC3B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,iBAAiB;AAAA,EAC5B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,YAAY,IAAI;AAAA,EACrC,SAAS,EAAE,SAAS,QAAW,QAAQ,QAAW,SAAS,OAAU;AACvE;AAGO,IAAM,oBAAoB;AAAA,EAC/B,KAAK;AAAA,EACL,MAAM,KAAK,UAAU,WAAW;AAAA,EAChC,SAAS;AAAA,IACP,SAAS;AAAA,MACP,aAAa;AAAA,MACb,gBAAgB;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AACF;;;ANzBO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,WAAW;AAAA,EAElB,MAAM,KAAK,OAAO,EAAE,QAAAC,SAAQ,MAAM,MAAM,KAAK,OAAO,GAAG;AACrD,UAAM,EAAE,SAAS,IAAIA;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,WAAWA,SAAQ,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":["entity_action","getEvent","config"]}
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": "0.5.1-next.0",
4
+ "version": "0.6.1",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -35,8 +35,8 @@
35
35
  "update": "npx npm-check-updates -u && npm update"
36
36
  },
37
37
  "dependencies": {
38
- "@walkeros/core": "0.5.1-next.0",
39
- "@walkeros/server-core": "0.5.1-next.0"
38
+ "@walkeros/core": "0.7.0",
39
+ "@walkeros/server-core": "0.6.1"
40
40
  },
41
41
  "devDependencies": {},
42
42
  "repository": {