@walkeros/server-source-express 3.2.0-next-1775064795590 → 3.2.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/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,i=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},s={};i(s,{examples:()=>y,schemas:()=>n}),module.exports=(e=s,((e,i,s,n)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let l of r(i))a.call(e,l)||l===s||t(e,l,{get:()=>i[l],enumerable:!(n=o(i,l))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};i(n,{CorsOptionsSchema:()=>m,CorsOrigin:()=>h,HttpMethod:()=>p,RouteConfigSchema:()=>g,RouteMethod:()=>u,SettingsSchema:()=>b,settings:()=>f});var l=require("@walkeros/core/dev"),c=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),p=d.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),u=d.z.enum(["GET","POST"]),g=d.z.object({path:d.z.string().describe("Express route path (supports wildcards like /api/*)"),methods:d.z.array(u).min(1).describe("HTTP methods to register. OPTIONS always included for CORS.").optional()}),h=d.z.union([d.z.string(),d.z.array(d.z.string()),d.z.literal("*")]),m=d.z.object({origin:h.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:d.z.array(p).describe("Allowed HTTP methods").optional(),headers:d.z.array(d.z.string()).describe("Allowed request headers").optional(),credentials:d.z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:d.z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),b=c.z.object({port:c.z.number().int().min(0).max(65535).describe("HTTP server port to listen on. Use 0 for random available port. If not provided, server will not start (app only mode)").optional(),path:c.z.string().describe("Deprecated: use paths instead").optional(),paths:c.z.array(c.z.union([c.z.string(),g])).min(1).describe("Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.").optional(),cors:c.z.union([c.z.boolean(),m]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),f=(0,l.zodToSchema)(b),y={};i(y,{createTrigger:()=>O,step:()=>w});var w={};i(w,{pixelGet:()=>z,postEvent:()=>v});var v={trigger:{type:"POST"},in:{method:"POST",path:"/collect",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}}},out:{name:"page view",data:{title:"Home",url:"https://example.com/"},entity:"page",action:"view"}},z={trigger:{type:"GET"},in:{method:"GET",path:"/collect",query:{e:"page view",d:'{"title":"Home"}'}},out:{name:"page view",data:{title:"Home"},entity:"page",action:"view"}},T=require("@walkeros/collector");var O=async e=>{let t,o;return{get flow(){return t},trigger:()=>async r=>{const a=r.method||"POST";if(!t){const r=await(0,T.startFlow)(e);t={collector:r.collector,elb:r.elb};const a=function(e){for(const t of Object.values(e.sources||{})){const e=t;if(e.server){const t=e.server.address();if("object"==typeof t&&null!==t)return t.port}}}(r.collector);if(!a)throw new Error("Express source server not found — ensure port is configured in source settings");o=`http://localhost:${a}`}let i=`${o}${r.path}`;r.query&&(i+=`?${new URLSearchParams(r.query).toString()}`);const s={method:a,headers:{"Content-Type":"application/json",...r.headers}};"GET"!==a&&"HEAD"!==a&&void 0!==r.body&&(s.body=JSON.stringify(r.body));const n=await fetch(i,s),l={};let c;n.headers.forEach((e,t)=>{l[t]=e});return c=(n.headers.get("content-type")||"").includes("application/json")?await n.json():await n.text(),{status:n.status,body:c,headers:l}}}};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,s=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},i={};s(i,{examples:()=>f,schemas:()=>n}),module.exports=(e=i,((e,s,i,n)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let l of r(s))a.call(e,l)||l===i||t(e,l,{get:()=>s[l],enumerable:!(n=o(s,l))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};s(n,{CorsOptionsSchema:()=>m,CorsOrigin:()=>g,HttpMethod:()=>p,RouteConfigSchema:()=>h,RouteMethod:()=>u,SettingsSchema:()=>b,settings:()=>y});var l=require("@walkeros/core/dev"),c=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),p=d.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),u=d.z.enum(["GET","POST"]),h=d.z.object({path:d.z.string().describe("Express route path (supports wildcards like /api/*)"),methods:d.z.array(u).min(1).describe("HTTP methods to register. OPTIONS always included for CORS.").optional()}),g=d.z.union([d.z.string(),d.z.array(d.z.string()),d.z.literal("*")]),m=d.z.object({origin:g.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:d.z.array(p).describe("Allowed HTTP methods").optional(),headers:d.z.array(d.z.string()).describe("Allowed request headers").optional(),credentials:d.z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:d.z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),b=c.z.object({port:c.z.number().int().min(0).max(65535).describe("HTTP server port to listen on. Use 0 for random available port. If not provided, server will not start (app only mode)").optional(),path:c.z.string().describe("Deprecated: use paths instead").optional(),paths:c.z.array(c.z.union([c.z.string(),h])).min(1).describe("Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.").optional(),cors:c.z.union([c.z.boolean(),m]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),y=(0,l.zodToSchema)(b),f={};s(f,{createTrigger:()=>O,step:()=>w});var w={};s(w,{pixelGet:()=>z,postEvent:()=>v});var v={trigger:{type:"POST"},in:{method:"POST",path:"/collect",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}}},out:{name:"page view",data:{title:"Home",url:"https://example.com/"},entity:"page",action:"view"}},z={trigger:{type:"GET"},in:{method:"GET",path:"/collect",query:{e:"page view",d:'{"title":"Home"}'}},out:{name:"page view",data:{title:"Home"},entity:"page",action:"view"}},T=require("@walkeros/collector");var O=async e=>{let t,o;return{get flow(){return t},trigger:()=>async r=>{const a=r.method||"POST";if(!t){const r=await(0,T.startFlow)(e);t={collector:r.collector,elb:r.elb};const a=function(e){for(const t of Object.values(e.sources||{})){const e=t;if(e.server){const t=e.server.address();if("object"==typeof t&&null!==t)return t.port}}}(r.collector);if(!a)throw new Error("Express source server not found — ensure port is configured in source settings");o=`http://localhost:${a}`}let s=`${o}${r.path}`;r.query&&(s+=`?${new URLSearchParams(r.query).toString()}`);const i={method:a,headers:{...r.headers&&Object.keys(r.headers).some(e=>"content-type"===e.toLowerCase())?{}:{"Content-Type":"application/json"},...r.headers}};"GET"!==a&&"HEAD"!==a&&void 0!==r.body&&(i.body="string"==typeof r.body?r.body:JSON.stringify(r.body));const n=await fetch(s,i),l={};let c;n.headers.forEach((e,t)=>{l[t]=e});return c=(n.headers.get("content-type")||"").includes("application/json")?await n.json():await n.text(),{status:n.status,body:c,headers:l}}}};//# sourceMappingURL=dev.js.map
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/examples/index.ts","../src/examples/step.ts","../src/examples/trigger.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 * from './primitives';\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema, RouteConfigSchema } from './primitives';\n\n/**\n * Express source settings schema.\n */\nexport const SettingsSchema = z.object({\n port: z\n .number()\n .int()\n .min(0)\n .max(65535)\n .describe(\n 'HTTP server port to listen on. Use 0 for random available port. If not provided, server will not start (app only mode)',\n )\n .optional(),\n\n /** @deprecated Use `paths` instead */\n path: z.string().describe('Deprecated: use paths instead').optional(),\n\n paths: z\n .array(z.union([z.string(), RouteConfigSchema]))\n .min(1)\n .describe(\n 'Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.',\n )\n .optional(),\n\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration',\n )\n .default(true),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * HTTP methods enum\n */\nexport const HttpMethod = z.enum([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n 'HEAD',\n]);\n\n/**\n * HTTP methods supported for route configuration.\n * OPTIONS is always registered for CORS (not user-configurable per route).\n */\nexport const RouteMethod = z.enum(['GET', 'POST']);\n\n/**\n * Route configuration for multi-path support.\n */\nexport const RouteConfigSchema = z.object({\n path: z\n .string()\n .describe('Express route path (supports wildcards like /api/*)'),\n methods: z\n .array(RouteMethod)\n .min(1)\n .describe('HTTP methods to register. OPTIONS always included for CORS.')\n .optional(),\n});\n\n/**\n * CORS origin configuration\n * Accepts:\n * - '*' for all origins\n * - Single URL string\n * - Array of URL strings\n */\nexport const CorsOrigin = z.union([\n z.string(),\n z.array(z.string()),\n z.literal('*'),\n]);\n\n/**\n * CORS options schema\n * Configuration for Cross-Origin Resource Sharing\n */\nexport const CorsOptionsSchema = z.object({\n origin: CorsOrigin.describe(\n 'Allowed origins (* for all, URL string, or array of URLs)',\n ).optional(),\n\n methods: z.array(HttpMethod).describe('Allowed HTTP methods').optional(),\n\n headers: z.array(z.string()).describe('Allowed request headers').optional(),\n\n credentials: z\n .boolean()\n .describe('Allow credentials (cookies, authorization headers)')\n .optional(),\n\n maxAge: z\n .number()\n .int()\n .positive()\n .describe('Preflight cache duration in seconds')\n .optional(),\n});\n\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n","export * as step from './step';\nexport { createTrigger } from './trigger';\n","import type { Flow } from '@walkeros/core';\n\nexport const postEvent: Flow.StepExample = {\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n path: '/collect',\n body: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n },\n out: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n entity: 'page',\n action: 'view',\n },\n};\n\nexport const pixelGet: Flow.StepExample = {\n trigger: { type: 'GET' },\n in: {\n method: 'GET',\n path: '/collect',\n query: { e: 'page view', d: '{\"title\":\"Home\"}' },\n },\n out: {\n name: 'page view',\n data: { title: 'Home' },\n entity: 'page',\n action: 'view',\n },\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n method: string;\n path: string;\n body?: unknown;\n query?: Record<string, string>;\n headers?: Record<string, string>;\n}\n\nexport interface Result {\n status: number;\n body: unknown;\n headers: Record<string, string>;\n}\n\n/**\n * Discover the port of a running HTTP server from the collector's sources.\n * Scans all registered sources for one with a `server` property (express pattern).\n */\nfunction discoverPort(collector: Collector.Instance): number | undefined {\n for (const source of Object.values(collector.sources || {})) {\n const s = source as { server?: { address(): { port: number } | string } };\n if (s.server) {\n const addr = s.server.address();\n if (typeof addr === 'object' && addr !== null) return addr.port;\n }\n }\n return undefined;\n}\n\n/**\n * Express source createTrigger.\n *\n * Boots a real express server via startFlow, then fires real HTTP requests.\n * Blackbox: no source instance access, no mocked req/res — just fetch().\n *\n * Pass `port: 0` in the express source settings to use a random available port.\n *\n * @example\n * const { trigger, flow } = await createTrigger(config);\n * const result = await trigger('POST')({ path: '/collect', body: { name: 'page view' } });\n * console.log(result.status, result.body);\n */\nconst createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n let baseUrl: string | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n const method = content.method || 'POST';\n\n // Lazy startFlow — first call boots the server\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n\n const port = discoverPort(result.collector);\n if (!port)\n throw new Error(\n 'Express source server not found — ensure port is configured in source settings',\n );\n baseUrl = `http://localhost:${port}`;\n }\n\n // Build URL\n let url = `${baseUrl}${content.path}`;\n if (content.query) {\n url += `?${new URLSearchParams(content.query).toString()}`;\n }\n\n // Build fetch options\n const fetchOptions: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...content.headers,\n },\n };\n if (method !== 'GET' && method !== 'HEAD' && content.body !== undefined) {\n fetchOptions.body = JSON.stringify(content.body);\n }\n\n // Real HTTP request\n const response = await fetch(url, fetchOptions);\n\n // Capture response\n const responseHeaders: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n\n let body: unknown;\n const ct = response.headers.get('content-type') || '';\n if (ct.includes('application/json')) {\n body = await response.json();\n } else {\n body = await response.text();\n }\n\n return {\n status: response.status,\n body,\n headers: responseHeaders,\n };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\nexport { createTrigger };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,IAAAC,cAAkB;;;ACAlB,iBAAkB;AAKX,IAAM,aAAa,aAAE,KAAK;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,cAAc,aAAE,KAAK,CAAC,OAAO,MAAM,CAAC;AAK1C,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACxC,MAAM,aACH,OAAO,EACP,SAAS,qDAAqD;AAAA,EACjE,SAAS,aACN,MAAM,WAAW,EACjB,IAAI,CAAC,EACL,SAAS,6D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QAAI,MAAM,GAAG,OAAO,GAAG,QAAQ,IAAI;AACnC,QAAI,QAAQ,OAAO;AACjB,aAAO,IAAI,IAAI,gBAAgB,QAAQ,KAAK,EAAE,SAAS,CAAC;AAAA,IAC1D;AAGA,UAAM,eAA4B;AAAA,MAChC;AAAA,MACA,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,GAAG,QAAQ;AAAA,MACb;AAAA,IACF;AACA,QAAI,WAAW,SAAS,WAAW,UAAU,QAAQ,SAAS,QAAW;AACvE,mBAAa,OAAO,KAAK,UAAU,QAAQ,IAAI;AAAA,IACjD;AAGA,UAAM,WAAW,MAAM,MAAM,KAAK,YAAY;AAG9C,UAAM,kBAA0C,CAAC;AACjD,aAAS,QAAQ,QAAQ,CAAC,OAAO,QAAQ;AACvC,sBAAgB,GAAG,IAAI;AAAA,IACzB,CAAC;AAED,QAAI;AACJ,UAAM,KAAK,SAAS,QAAQ,IAAI,cAAc,KAAK;AACnD,QAAI,GAAG,SAAS,kBAAkB,GAAG;AACnC,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B,OAAO;AACL,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B;AAEA,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;","names":["import_dev","import_dev"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/examples/index.ts","../src/examples/step.ts","../src/examples/trigger.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 * from './primitives';\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema, RouteConfigSchema } from './primitives';\n\n/**\n * Express source settings schema.\n */\nexport const SettingsSchema = z.object({\n port: z\n .number()\n .int()\n .min(0)\n .max(65535)\n .describe(\n 'HTTP server port to listen on. Use 0 for random available port. If not provided, server will not start (app only mode)',\n )\n .optional(),\n\n /** @deprecated Use `paths` instead */\n path: z.string().describe('Deprecated: use paths instead').optional(),\n\n paths: z\n .array(z.union([z.string(), RouteConfigSchema]))\n .min(1)\n .describe(\n 'Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.',\n )\n .optional(),\n\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration',\n )\n .default(true),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * HTTP methods enum\n */\nexport const HttpMethod = z.enum([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n 'HEAD',\n]);\n\n/**\n * HTTP methods supported for route configuration.\n * OPTIONS is always registered for CORS (not user-configurable per route).\n */\nexport const RouteMethod = z.enum(['GET', 'POST']);\n\n/**\n * Route configuration for multi-path support.\n */\nexport const RouteConfigSchema = z.object({\n path: z\n .string()\n .describe('Express route path (supports wildcards like /api/*)'),\n methods: z\n .array(RouteMethod)\n .min(1)\n .describe('HTTP methods to register. OPTIONS always included for CORS.')\n .optional(),\n});\n\n/**\n * CORS origin configuration\n * Accepts:\n * - '*' for all origins\n * - Single URL string\n * - Array of URL strings\n */\nexport const CorsOrigin = z.union([\n z.string(),\n z.array(z.string()),\n z.literal('*'),\n]);\n\n/**\n * CORS options schema\n * Configuration for Cross-Origin Resource Sharing\n */\nexport const CorsOptionsSchema = z.object({\n origin: CorsOrigin.describe(\n 'Allowed origins (* for all, URL string, or array of URLs)',\n ).optional(),\n\n methods: z.array(HttpMethod).describe('Allowed HTTP methods').optional(),\n\n headers: z.array(z.string()).describe('Allowed request headers').optional(),\n\n credentials: z\n .boolean()\n .describe('Allow credentials (cookies, authorization headers)')\n .optional(),\n\n maxAge: z\n .number()\n .int()\n .positive()\n .describe('Preflight cache duration in seconds')\n .optional(),\n});\n\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n","export * as step from './step';\nexport { createTrigger } from './trigger';\n","import type { Flow } from '@walkeros/core';\n\nexport const postEvent: Flow.StepExample = {\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n path: '/collect',\n body: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n },\n out: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n entity: 'page',\n action: 'view',\n },\n};\n\nexport const pixelGet: Flow.StepExample = {\n trigger: { type: 'GET' },\n in: {\n method: 'GET',\n path: '/collect',\n query: { e: 'page view', d: '{\"title\":\"Home\"}' },\n },\n out: {\n name: 'page view',\n data: { title: 'Home' },\n entity: 'page',\n action: 'view',\n },\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n method: string;\n path: string;\n body?: unknown;\n query?: Record<string, string>;\n headers?: Record<string, string>;\n}\n\nexport interface Result {\n status: number;\n body: unknown;\n headers: Record<string, string>;\n}\n\n/**\n * Discover the port of a running HTTP server from the collector's sources.\n * Scans all registered sources for one with a `server` property (express pattern).\n */\nfunction discoverPort(collector: Collector.Instance): number | undefined {\n for (const source of Object.values(collector.sources || {})) {\n const s = source as { server?: { address(): { port: number } | string } };\n if (s.server) {\n const addr = s.server.address();\n if (typeof addr === 'object' && addr !== null) return addr.port;\n }\n }\n return undefined;\n}\n\n/**\n * Express source createTrigger.\n *\n * Boots a real express server via startFlow, then fires real HTTP requests.\n * Blackbox: no source instance access, no mocked req/res — just fetch().\n *\n * Pass `port: 0` in the express source settings to use a random available port.\n *\n * @example\n * const { trigger, flow } = await createTrigger(config);\n * const result = await trigger('POST')({ path: '/collect', body: { name: 'page view' } });\n * console.log(result.status, result.body);\n */\nconst createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n let baseUrl: string | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n const method = content.method || 'POST';\n\n // Lazy startFlow — first call boots the server\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n\n const port = discoverPort(result.collector);\n if (!port)\n throw new Error(\n 'Express source server not found — ensure port is configured in source settings',\n );\n baseUrl = `http://localhost:${port}`;\n }\n\n // Build URL\n let url = `${baseUrl}${content.path}`;\n if (content.query) {\n url += `?${new URLSearchParams(content.query).toString()}`;\n }\n\n // Build fetch options — only set default Content-Type if user doesn't provide one\n const hasContentType =\n content.headers &&\n Object.keys(content.headers).some(\n (k) => k.toLowerCase() === 'content-type',\n );\n const fetchOptions: RequestInit = {\n method,\n headers: {\n ...(hasContentType ? {} : { 'Content-Type': 'application/json' }),\n ...content.headers,\n },\n };\n if (method !== 'GET' && method !== 'HEAD' && content.body !== undefined) {\n // String bodies sent raw (e.g., base64 beacon with text/plain).\n // Object bodies JSON-serialized.\n fetchOptions.body =\n typeof content.body === 'string'\n ? content.body\n : JSON.stringify(content.body);\n }\n\n // Real HTTP request\n const response = await fetch(url, fetchOptions);\n\n // Capture response\n const responseHeaders: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n\n let body: unknown;\n const ct = response.headers.get('content-type') || '';\n if (ct.includes('application/json')) {\n body = await response.json();\n } else {\n body = await response.text();\n }\n\n return {\n status: response.status,\n body,\n headers: responseHeaders,\n };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\nexport { createTrigger };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AS,KAAK;AAAA,IAC7B,OAAO;AACL,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B;AAEA,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;","names":["import_dev","import_dev"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,o)=>{for(var r in o)e(t,r,{get:o[r],enumerable:!0})},o={};t(o,{CorsOptionsSchema:()=>d,CorsOrigin:()=>c,HttpMethod:()=>s,RouteConfigSchema:()=>l,RouteMethod:()=>n,SettingsSchema:()=>p,settings:()=>u});import{zodToSchema as r}from"@walkeros/core/dev";import{z as a}from"@walkeros/core/dev";import{z as i}from"@walkeros/core/dev";var s=i.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),n=i.enum(["GET","POST"]),l=i.object({path:i.string().describe("Express route path (supports wildcards like /api/*)"),methods:i.array(n).min(1).describe("HTTP methods to register. OPTIONS always included for CORS.").optional()}),c=i.union([i.string(),i.array(i.string()),i.literal("*")]),d=i.object({origin:c.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:i.array(s).describe("Allowed HTTP methods").optional(),headers:i.array(i.string()).describe("Allowed request headers").optional(),credentials:i.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:i.number().int().positive().describe("Preflight cache duration in seconds").optional()}),p=a.object({port:a.number().int().min(0).max(65535).describe("HTTP server port to listen on. Use 0 for random available port. If not provided, server will not start (app only mode)").optional(),path:a.string().describe("Deprecated: use paths instead").optional(),paths:a.array(a.union([a.string(),l])).min(1).describe("Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.").optional(),cors:a.union([a.boolean(),d]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),u=r(p),m={};t(m,{createTrigger:()=>w,step:()=>h});var h={};t(h,{pixelGet:()=>f,postEvent:()=>g});var g={trigger:{type:"POST"},in:{method:"POST",path:"/collect",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}}},out:{name:"page view",data:{title:"Home",url:"https://example.com/"},entity:"page",action:"view"}},f={trigger:{type:"GET"},in:{method:"GET",path:"/collect",query:{e:"page view",d:'{"title":"Home"}'}},out:{name:"page view",data:{title:"Home"},entity:"page",action:"view"}};import{startFlow as b}from"@walkeros/collector";var w=async e=>{let t,o;return{get flow(){return t},trigger:()=>async r=>{const a=r.method||"POST";if(!t){const r=await b(e);t={collector:r.collector,elb:r.elb};const a=function(e){for(const t of Object.values(e.sources||{})){const e=t;if(e.server){const t=e.server.address();if("object"==typeof t&&null!==t)return t.port}}}(r.collector);if(!a)throw new Error("Express source server not found — ensure port is configured in source settings");o=`http://localhost:${a}`}let i=`${o}${r.path}`;r.query&&(i+=`?${new URLSearchParams(r.query).toString()}`);const s={method:a,headers:{"Content-Type":"application/json",...r.headers}};"GET"!==a&&"HEAD"!==a&&void 0!==r.body&&(s.body=JSON.stringify(r.body));const n=await fetch(i,s),l={};let c;n.headers.forEach((e,t)=>{l[t]=e});return c=(n.headers.get("content-type")||"").includes("application/json")?await n.json():await n.text(),{status:n.status,body:c,headers:l}}}};export{m as examples,o as schemas};//# sourceMappingURL=dev.mjs.map
1
+ var e=Object.defineProperty,t=(t,o)=>{for(var r in o)e(t,r,{get:o[r],enumerable:!0})},o={};t(o,{CorsOptionsSchema:()=>d,CorsOrigin:()=>c,HttpMethod:()=>i,RouteConfigSchema:()=>l,RouteMethod:()=>n,SettingsSchema:()=>p,settings:()=>u});import{zodToSchema as r}from"@walkeros/core/dev";import{z as a}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var i=s.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),n=s.enum(["GET","POST"]),l=s.object({path:s.string().describe("Express route path (supports wildcards like /api/*)"),methods:s.array(n).min(1).describe("HTTP methods to register. OPTIONS always included for CORS.").optional()}),c=s.union([s.string(),s.array(s.string()),s.literal("*")]),d=s.object({origin:c.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:s.array(i).describe("Allowed HTTP methods").optional(),headers:s.array(s.string()).describe("Allowed request headers").optional(),credentials:s.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:s.number().int().positive().describe("Preflight cache duration in seconds").optional()}),p=a.object({port:a.number().int().min(0).max(65535).describe("HTTP server port to listen on. Use 0 for random available port. If not provided, server will not start (app only mode)").optional(),path:a.string().describe("Deprecated: use paths instead").optional(),paths:a.array(a.union([a.string(),l])).min(1).describe("Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.").optional(),cors:a.union([a.boolean(),d]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),u=r(p),m={};t(m,{createTrigger:()=>y,step:()=>h});var h={};t(h,{pixelGet:()=>b,postEvent:()=>g});var g={trigger:{type:"POST"},in:{method:"POST",path:"/collect",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}}},out:{name:"page view",data:{title:"Home",url:"https://example.com/"},entity:"page",action:"view"}},b={trigger:{type:"GET"},in:{method:"GET",path:"/collect",query:{e:"page view",d:'{"title":"Home"}'}},out:{name:"page view",data:{title:"Home"},entity:"page",action:"view"}};import{startFlow as f}from"@walkeros/collector";var y=async e=>{let t,o;return{get flow(){return t},trigger:()=>async r=>{const a=r.method||"POST";if(!t){const r=await f(e);t={collector:r.collector,elb:r.elb};const a=function(e){for(const t of Object.values(e.sources||{})){const e=t;if(e.server){const t=e.server.address();if("object"==typeof t&&null!==t)return t.port}}}(r.collector);if(!a)throw new Error("Express source server not found — ensure port is configured in source settings");o=`http://localhost:${a}`}let s=`${o}${r.path}`;r.query&&(s+=`?${new URLSearchParams(r.query).toString()}`);const i={method:a,headers:{...r.headers&&Object.keys(r.headers).some(e=>"content-type"===e.toLowerCase())?{}:{"Content-Type":"application/json"},...r.headers}};"GET"!==a&&"HEAD"!==a&&void 0!==r.body&&(i.body="string"==typeof r.body?r.body:JSON.stringify(r.body));const n=await fetch(s,i),l={};let c;n.headers.forEach((e,t)=>{l[t]=e});return c=(n.headers.get("content-type")||"").includes("application/json")?await n.json():await n.text(),{status:n.status,body:c,headers:l}}}};export{m as examples,o as schemas};//# sourceMappingURL=dev.mjs.map
package/dist/dev.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/examples/index.ts","../src/examples/step.ts","../src/examples/trigger.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport * from './primitives';\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema, RouteConfigSchema } from './primitives';\n\n/**\n * Express source settings schema.\n */\nexport const SettingsSchema = z.object({\n port: z\n .number()\n .int()\n .min(0)\n .max(65535)\n .describe(\n 'HTTP server port to listen on. Use 0 for random available port. If not provided, server will not start (app only mode)',\n )\n .optional(),\n\n /** @deprecated Use `paths` instead */\n path: z.string().describe('Deprecated: use paths instead').optional(),\n\n paths: z\n .array(z.union([z.string(), RouteConfigSchema]))\n .min(1)\n .describe(\n 'Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.',\n )\n .optional(),\n\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration',\n )\n .default(true),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * HTTP methods enum\n */\nexport const HttpMethod = z.enum([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n 'HEAD',\n]);\n\n/**\n * HTTP methods supported for route configuration.\n * OPTIONS is always registered for CORS (not user-configurable per route).\n */\nexport const RouteMethod = z.enum(['GET', 'POST']);\n\n/**\n * Route configuration for multi-path support.\n */\nexport const RouteConfigSchema = z.object({\n path: z\n .string()\n .describe('Express route path (supports wildcards like /api/*)'),\n methods: z\n .array(RouteMethod)\n .min(1)\n .describe('HTTP methods to register. OPTIONS always included for CORS.')\n .optional(),\n});\n\n/**\n * CORS origin configuration\n * Accepts:\n * - '*' for all origins\n * - Single URL string\n * - Array of URL strings\n */\nexport const CorsOrigin = z.union([\n z.string(),\n z.array(z.string()),\n z.literal('*'),\n]);\n\n/**\n * CORS options schema\n * Configuration for Cross-Origin Resource Sharing\n */\nexport const CorsOptionsSchema = z.object({\n origin: CorsOrigin.describe(\n 'Allowed origins (* for all, URL string, or array of URLs)',\n ).optional(),\n\n methods: z.array(HttpMethod).describe('Allowed HTTP methods').optional(),\n\n headers: z.array(z.string()).describe('Allowed request headers').optional(),\n\n credentials: z\n .boolean()\n .describe('Allow credentials (cookies, authorization headers)')\n .optional(),\n\n maxAge: z\n .number()\n .int()\n .positive()\n .describe('Preflight cache duration in seconds')\n .optional(),\n});\n\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n","export * as step from './step';\nexport { createTrigger } from './trigger';\n","import type { Flow } from '@walkeros/core';\n\nexport const postEvent: Flow.StepExample = {\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n path: '/collect',\n body: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n },\n out: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n entity: 'page',\n action: 'view',\n },\n};\n\nexport const pixelGet: Flow.StepExample = {\n trigger: { type: 'GET' },\n in: {\n method: 'GET',\n path: '/collect',\n query: { e: 'page view', d: '{\"title\":\"Home\"}' },\n },\n out: {\n name: 'page view',\n data: { title: 'Home' },\n entity: 'page',\n action: 'view',\n },\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n method: string;\n path: string;\n body?: unknown;\n query?: Record<string, string>;\n headers?: Record<string, string>;\n}\n\nexport interface Result {\n status: number;\n body: unknown;\n headers: Record<string, string>;\n}\n\n/**\n * Discover the port of a running HTTP server from the collector's sources.\n * Scans all registered sources for one with a `server` property (express pattern).\n */\nfunction discoverPort(collector: Collector.Instance): number | undefined {\n for (const source of Object.values(collector.sources || {})) {\n const s = source as { server?: { address(): { port: number } | string } };\n if (s.server) {\n const addr = s.server.address();\n if (typeof addr === 'object' && addr !== null) return addr.port;\n }\n }\n return undefined;\n}\n\n/**\n * Express source createTrigger.\n *\n * Boots a real express server via startFlow, then fires real HTTP requests.\n * Blackbox: no source instance access, no mocked req/res — just fetch().\n *\n * Pass `port: 0` in the express source settings to use a random available port.\n *\n * @example\n * const { trigger, flow } = await createTrigger(config);\n * const result = await trigger('POST')({ path: '/collect', body: { name: 'page view' } });\n * console.log(result.status, result.body);\n */\nconst createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n let baseUrl: string | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n const method = content.method || 'POST';\n\n // Lazy startFlow — first call boots the server\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n\n const port = discoverPort(result.collector);\n if (!port)\n throw new Error(\n 'Express source server not found — ensure port is configured in source settings',\n );\n baseUrl = `http://localhost:${port}`;\n }\n\n // Build URL\n let url = `${baseUrl}${content.path}`;\n if (content.query) {\n url += `?${new URLSearchParams(content.query).toString()}`;\n }\n\n // Build fetch options\n const fetchOptions: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...content.headers,\n },\n };\n if (method !== 'GET' && method !== 'HEAD' && content.body !== undefined) {\n fetchOptions.body = JSON.stringify(content.body);\n }\n\n // Real HTTP request\n const response = await fetch(url, fetchOptions);\n\n // Capture response\n const responseHeaders: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n\n let body: unknown;\n const ct = response.headers.get('content-type') || '';\n if (ct.includes('application/json')) {\n body = await response.json();\n } else {\n body = await response.text();\n }\n\n return {\n status: response.status,\n body,\n headers: responseHeaders,\n };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\nexport { createTrigger };\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAKX,IAAM,aAAa,EAAE,KAAK;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,cAAc,EAAE,KAAK,CAAC,OAAO,MAAM,CAAC;AAK1C,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,MAAM,EACH,OAAO,EACP,SAAS,qDAAqD;AAAA,EACjE,SAAS,EACN,MAAM,WAAW,EACjB,IAAI,CAAC,EACL,SAAS,6DAA6D,EACtE,SAAS;AACd,CAAC;AASM,IAAM,aAAa,EAAE,MAAM;AAAA,EAChC,EAAE,OAAO;AAAA,EACT,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAClB,EAAE,QAAQ,GAAG;AACf,CAAC;AAMM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,QAAQ,WAAW;AAAA,IACjB;AAAA,EACF,EAAE,SAAS;AAAA,EAEX,SAAS,EAAE,MAAM,UAAU,EAAE,SAAS,sBAAsB,EAAE,SAAS;AAAA,EAEvE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,yBAAyB,EAAE,SAAS;AAAA,EAE1E,aAAa,EACV,QAAQ,EACR,SAAS,oDAAoD,EAC7D,SAAS;AAAA,EAEZ,QAAQ,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,qCAAq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AED,QAAI;AACJ,UAAM,KAAK,SAAS,QAAQ,IAAI,cAAc,KAAK;AACnD,QAAI,GAAG,SAAS,kBAAkB,GAAG;AACnC,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B,OAAO;AACL,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B;AAEA,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;","names":["z","z"]}
1
+ {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/examples/index.ts","../src/examples/step.ts","../src/examples/trigger.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport * from './primitives';\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema, RouteConfigSchema } from './primitives';\n\n/**\n * Express source settings schema.\n */\nexport const SettingsSchema = z.object({\n port: z\n .number()\n .int()\n .min(0)\n .max(65535)\n .describe(\n 'HTTP server port to listen on. Use 0 for random available port. If not provided, server will not start (app only mode)',\n )\n .optional(),\n\n /** @deprecated Use `paths` instead */\n path: z.string().describe('Deprecated: use paths instead').optional(),\n\n paths: z\n .array(z.union([z.string(), RouteConfigSchema]))\n .min(1)\n .describe(\n 'Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.',\n )\n .optional(),\n\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration',\n )\n .default(true),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * HTTP methods enum\n */\nexport const HttpMethod = z.enum([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n 'HEAD',\n]);\n\n/**\n * HTTP methods supported for route configuration.\n * OPTIONS is always registered for CORS (not user-configurable per route).\n */\nexport const RouteMethod = z.enum(['GET', 'POST']);\n\n/**\n * Route configuration for multi-path support.\n */\nexport const RouteConfigSchema = z.object({\n path: z\n .string()\n .describe('Express route path (supports wildcards like /api/*)'),\n methods: z\n .array(RouteMethod)\n .min(1)\n .describe('HTTP methods to register. OPTIONS always included for CORS.')\n .optional(),\n});\n\n/**\n * CORS origin configuration\n * Accepts:\n * - '*' for all origins\n * - Single URL string\n * - Array of URL strings\n */\nexport const CorsOrigin = z.union([\n z.string(),\n z.array(z.string()),\n z.literal('*'),\n]);\n\n/**\n * CORS options schema\n * Configuration for Cross-Origin Resource Sharing\n */\nexport const CorsOptionsSchema = z.object({\n origin: CorsOrigin.describe(\n 'Allowed origins (* for all, URL string, or array of URLs)',\n ).optional(),\n\n methods: z.array(HttpMethod).describe('Allowed HTTP methods').optional(),\n\n headers: z.array(z.string()).describe('Allowed request headers').optional(),\n\n credentials: z\n .boolean()\n .describe('Allow credentials (cookies, authorization headers)')\n .optional(),\n\n maxAge: z\n .number()\n .int()\n .positive()\n .describe('Preflight cache duration in seconds')\n .optional(),\n});\n\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n","export * as step from './step';\nexport { createTrigger } from './trigger';\n","import type { Flow } from '@walkeros/core';\n\nexport const postEvent: Flow.StepExample = {\n trigger: { type: 'POST' },\n in: {\n method: 'POST',\n path: '/collect',\n body: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n },\n out: {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n entity: 'page',\n action: 'view',\n },\n};\n\nexport const pixelGet: Flow.StepExample = {\n trigger: { type: 'GET' },\n in: {\n method: 'GET',\n path: '/collect',\n query: { e: 'page view', d: '{\"title\":\"Home\"}' },\n },\n out: {\n name: 'page view',\n data: { title: 'Home' },\n entity: 'page',\n action: 'view',\n },\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n method: string;\n path: string;\n body?: unknown;\n query?: Record<string, string>;\n headers?: Record<string, string>;\n}\n\nexport interface Result {\n status: number;\n body: unknown;\n headers: Record<string, string>;\n}\n\n/**\n * Discover the port of a running HTTP server from the collector's sources.\n * Scans all registered sources for one with a `server` property (express pattern).\n */\nfunction discoverPort(collector: Collector.Instance): number | undefined {\n for (const source of Object.values(collector.sources || {})) {\n const s = source as { server?: { address(): { port: number } | string } };\n if (s.server) {\n const addr = s.server.address();\n if (typeof addr === 'object' && addr !== null) return addr.port;\n }\n }\n return undefined;\n}\n\n/**\n * Express source createTrigger.\n *\n * Boots a real express server via startFlow, then fires real HTTP requests.\n * Blackbox: no source instance access, no mocked req/res — just fetch().\n *\n * Pass `port: 0` in the express source settings to use a random available port.\n *\n * @example\n * const { trigger, flow } = await createTrigger(config);\n * const result = await trigger('POST')({ path: '/collect', body: { name: 'page view' } });\n * console.log(result.status, result.body);\n */\nconst createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n let baseUrl: string | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n const method = content.method || 'POST';\n\n // Lazy startFlow — first call boots the server\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n\n const port = discoverPort(result.collector);\n if (!port)\n throw new Error(\n 'Express source server not found — ensure port is configured in source settings',\n );\n baseUrl = `http://localhost:${port}`;\n }\n\n // Build URL\n let url = `${baseUrl}${content.path}`;\n if (content.query) {\n url += `?${new URLSearchParams(content.query).toString()}`;\n }\n\n // Build fetch options — only set default Content-Type if user doesn't provide one\n const hasContentType =\n content.headers &&\n Object.keys(content.headers).some(\n (k) => k.toLowerCase() === 'content-type',\n );\n const fetchOptions: RequestInit = {\n method,\n headers: {\n ...(hasContentType ? {} : { 'Content-Type': 'application/json' }),\n ...content.headers,\n },\n };\n if (method !== 'GET' && method !== 'HEAD' && content.body !== undefined) {\n // String bodies sent raw (e.g., base64 beacon with text/plain).\n // Object bodies JSON-serialized.\n fetchOptions.body =\n typeof content.body === 'string'\n ? content.body\n : JSON.stringify(content.body);\n }\n\n // Real HTTP request\n const response = await fetch(url, fetchOptions);\n\n // Capture response\n const responseHeaders: Record<string, string> = {};\n response.headers.forEach((value, key) => {\n responseHeaders[key] = value;\n });\n\n let body: unknown;\n const ct = response.headers.get('content-type') || '';\n if (ct.includes('application/json')) {\n body = await response.json();\n } else {\n body = await response.text();\n }\n\n return {\n status: response.status,\n body,\n headers: responseHeaders,\n };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\nexport { createTrigger };\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAKX,IAAM,aAAa,EAAE,KAAK;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,cAAc,EAAE,KAAK,CAAC,OAAO,MAAM,CAAC;AAK1C,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,MAAM,EACH,OAAO,EACP,SAAS,qDAAqD;AAAA,EACjE,SAAS,EACN,MAAM,WAAW,EACjB,IAAI,CAAC,EACL,SAAS,6DAA6D,EACtE,SAAS;AACd,CAAC;AASM,IAAM,aAAa,EAAE,MAAM;AAAA,EAChC,EAAE,OAAO;AAAA,EACT,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAClB,EAAE,QAAQ,GAAG;AACf,CAAC;AAMM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,QAAQ,WAAW;AAAA,IACjB;AAAA,EACF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EAAE,YAAY,MAAM;AAAA,IAC7B;AACF,UAAM,eAA4B;AAAA,MAChC;AAAA,MACA,SAAS;AAAA,QACP,GAAI,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,mBAAmB;AAAA,QAC/D,GAAG,QAAQ;AAAA,MACb;AAAA,IACF;AACA,QAAI,WAAW,SAAS,WAAW,UAAU,QAAQ,SAAS,QAAW;AAGvE,mBAAa,OACX,OAAO,QAAQ,SAAS,WACpB,QAAQ,OACR,KAAK,UAAU,QAAQ,IAAI;AAAA,IACnC;AAGA,UAAM,WAAW,MAAM,MAAM,KAAK,YAAY;AAG9C,UAAM,kBAA0C,CAAC;AACjD,aAAS,QAAQ,QAAQ,CAAC,OAAO,QAAQ;AACvC,sBAAgB,GAAG,IAAI;AAAA,IACzB,CAAC;AAED,QAAI;AACJ,UAAM,KAAK,SAAS,QAAQ,IAAI,cAAc,KAAK;AACnD,QAAI,GAAG,SAAS,kBAAkB,GAAG;AACnC,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B,OAAO;AACL,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B;AAEA,WAAO;AAAA,MACL,QAAQ,SAAS;AAAA,MACjB;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;","names":["z","z"]}
@@ -136,7 +136,7 @@
136
136
  },
137
137
  "examples": {
138
138
  "createTrigger": {
139
- "$code": "async e=>{let t,o;return{get flow(){return t},trigger:()=>async r=>{const a=r.method||\"POST\";if(!t){const r=await b(e);t={collector:r.collector,elb:r.elb};const a=function(e){for(const t of Object.values(e.sources||{})){const e=t;if(e.server){const t=e.server.address();if(\"object\"==typeof t&&null!==t)return t.port}}}(r.collector);if(!a)throw new Error(\"Express source server not found — ensure port is configured in source settings\");o=`http://localhost:${a}`}let i=`${o}${r.path}`;r.query&&(i+=`?${new URLSearchParams(r.query).toString()}`);const s={method:a,headers:{\"Content-Type\":\"application/json\",...r.headers}};\"GET\"!==a&&\"HEAD\"!==a&&void 0!==r.body&&(s.body=JSON.stringify(r.body));const n=await fetch(i,s),l={};let c;n.headers.forEach((e,t)=>{l[t]=e});return c=(n.headers.get(\"content-type\")||\"\").includes(\"application/json\")?await n.json():await n.text(),{status:n.status,body:c,headers:l}}}}"
139
+ "$code": "async e=>{let t,o;return{get flow(){return t},trigger:()=>async r=>{const a=r.method||\"POST\";if(!t){const r=await f(e);t={collector:r.collector,elb:r.elb};const a=function(e){for(const t of Object.values(e.sources||{})){const e=t;if(e.server){const t=e.server.address();if(\"object\"==typeof t&&null!==t)return t.port}}}(r.collector);if(!a)throw new Error(\"Express source server not found — ensure port is configured in source settings\");o=`http://localhost:${a}`}let s=`${o}${r.path}`;r.query&&(s+=`?${new URLSearchParams(r.query).toString()}`);const i={method:a,headers:{...r.headers&&Object.keys(r.headers).some(e=>\"content-type\"===e.toLowerCase())?{}:{\"Content-Type\":\"application/json\"},...r.headers}};\"GET\"!==a&&\"HEAD\"!==a&&void 0!==r.body&&(i.body=\"string\"==typeof r.body?r.body:JSON.stringify(r.body));const n=await fetch(s,i),l={};let c;n.headers.forEach((e,t)=>{l[t]=e});return c=(n.headers.get(\"content-type\")||\"\").includes(\"application/json\")?await n.json():await n.text(),{status:n.status,body:c,headers:l}}}}"
140
140
  },
141
141
  "step": {
142
142
  "pixelGet": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/server-source-express",
3
3
  "description": "Express server source for walkerOS",
4
- "version": "3.2.0-next-1775064795590",
4
+ "version": "3.2.0",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -19,8 +19,8 @@
19
19
  "update": "npx npm-check-updates -u && npm update"
20
20
  },
21
21
  "dependencies": {
22
- "@walkeros/collector": "3.2.0-next-1775064795590",
23
- "@walkeros/core": "3.2.0-next-1775064795590",
22
+ "@walkeros/collector": "^3.2.0",
23
+ "@walkeros/core": "^3.2.0",
24
24
  "express": "^5.2.1",
25
25
  "cors": "^2.8.5"
26
26
  },