@walkeros/server-source-express 4.8.2 → 4.8.3-next-1793115089237

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,27 @@
1
1
  # @walkeros/server-source-express
2
2
 
3
+ ## 4.8.3-next-1793115089237
4
+
5
+ ### Patch Changes
6
+
7
+ - 5313635: The pixel GET example now sends `name` and `data[...]` query
8
+ parameters, the form the source turns into an event. The previous example used
9
+ `e` and `d` parameters, which the collector rejects as an event without a
10
+ name, so the request answered with the GIF and nothing was delivered.
11
+ - Updated dependencies [5313635]
12
+ - Updated dependencies [5313635]
13
+ - Updated dependencies [34fd225]
14
+ - Updated dependencies [34fd225]
15
+ - Updated dependencies [5313635]
16
+ - Updated dependencies [5313635]
17
+ - Updated dependencies [5313635]
18
+ - Updated dependencies [5313635]
19
+ - Updated dependencies [5313635]
20
+ - Updated dependencies [34fd225]
21
+ - Updated dependencies [5313635]
22
+ - @walkeros/collector@4.8.3-next-1793115089237
23
+ - @walkeros/core@4.8.3-next-1793115089237
24
+
3
25
  ## 4.8.2
4
26
 
5
27
  ### Patch Changes
@@ -362,9 +384,6 @@
362
384
  and `event.context` remain required.
363
385
  - Each source self-registers via TypeScript module augmentation of `SourceMap`
364
386
  in `@walkeros/core`.
365
- - App-side coordination (`/workspaces/developer/app`) is a follow-up plan, not
366
- part of this release. Telemetry from v4 CLI/MCP will not validate against
367
- the existing app schema until that follow-up ships.
368
387
  - `Mapping.Rule.skip` is renamed to `Mapping.Rule.silent`. Customer flow.json
369
388
  configs using `skip: true` in mapping rules must rename to `silent: true`.
370
389
  Hard cut: no legacy alias, the field is gone.
package/README.md CHANGED
@@ -6,17 +6,18 @@
6
6
 
7
7
  # @walkeros/server-source-express
8
8
 
9
- Turn-key HTTP event collection server with Express.js. Runs standalone or embeds
10
- inside an existing Express app, handles JSON POST events (including
9
+ HTTP event collection server built on Express.js. It runs standalone or inside
10
+ an existing Express app and handles JSON POST events (including
11
11
  `navigator.sendBeacon` payloads sent as `text/plain`), raw `text/plain` bodies
12
12
  for request decoders such as `@walkeros/transformer-ga4`, pixel tracking via
13
13
  GET, and configurable CORS.
14
14
 
15
15
  A `text/plain` POST body is parsed as JSON when it is JSON
16
16
  (`navigator.sendBeacon` sends JSON as `text/plain`) and otherwise kept as the
17
- raw string on `ingest.body`, so a `before` transformer can decode it, for
18
- example batched gtag.js hits with `@walkeros/transformer-ga4`. An
19
- `application/json` body must parse, or the request is answered with 400.
17
+ raw string, which a `before` transformer reads from `ingest.body` once
18
+ `config.ingest` maps it (`body: { key: 'body' }`), for example batched gtag.js
19
+ hits with `@walkeros/transformer-ga4`. An `application/json` body must parse, or
20
+ the request is answered with 400.
20
21
 
21
22
  [Documentation](https://www.walkeros.io/docs/sources/server/express) •
22
23
  [NPM Package](https://www.npmjs.com/package/@walkeros/server-source-express)
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,i=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},a={};i(a,{examples:()=>y,schemas:()=>n}),module.exports=(e=a,((e,i,a,n)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let l of r(i))s.call(e,l)||l===a||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:()=>b,CorsOrigin:()=>h,HttpMethod:()=>p,RouteConfigSchema:()=>g,RouteMethod:()=>u,SettingsSchema:()=>m,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("*")]),b=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()}),m=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(),maxBatchSize:c.z.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),cors:c.z.union([c.z.boolean(),b]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),f=(0,l.zodToSchema)(m),y={};i(y,{createTrigger:()=>S,step:()=>v});var v={};i(v,{pixelGet:()=>O,postEvent:()=>w});var w={title:"POST event",description:"An Express POST to /collect with a JSON body becomes a single walker elb event.",trigger:{type:"POST"},in:{method:"POST",path:"/collect",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}}},out:[["elb",{name:"page view",data:{title:"Home",url:"https://example.com/"}}]]},O={title:"Pixel GET",description:"An Express GET to /collect with query parameters is parsed into an elb event payload for pixel tracking.",trigger:{type:"GET"},in:{method:"GET",path:"/collect",query:{e:"page view",d:'{"title":"Home"}'}},out:[["elb",{e:"page view",d:'{"title":"Home"}'}]]},T=require("@walkeros/core"),z=require("@walkeros/collector");var S=async(e,t)=>{const o=function(e,t){const o=e.sources??{},r=Object.keys(o),s=(0,T.isObject)(t)&&"string"==typeof t.sourceId?t.sourceId:1===r.length?r[0]:void 0,i=s?o[s]:void 0;if(!s||!i)return e;const a=i.config??{},n=(0,T.isObject)(a.settings)?a.settings:{};return void 0!==n.port?e:{...e,sources:{...o,[s]:{...i,config:{...a,settings:{...n,port:0}}}}}}(e,t);let r,s;return{get flow(){return r},trigger:()=>async e=>{const t=e.method||"POST";if(!r){const e=await(0,z.startFlow)(o);r={collector:e.collector,elb:e.elb};const t=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}}}(e.collector);if(!t)throw new Error("Express source server not found: the triggered source did not start a server");s=`http://localhost:${t}`}let i=`${s}${e.path}`;e.query&&(i+=`?${new URLSearchParams(e.query).toString()}`);const a={method:t,headers:{...e.headers&&Object.keys(e.headers).some(e=>"content-type"===e.toLowerCase())?{}:{"Content-Type":"application/json"},...e.headers}};"GET"!==t&&"HEAD"!==t&&void 0!==e.body&&(a.body="string"==typeof e.body?e.body:JSON.stringify(e.body));const n=await fetch(i,a),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,s=Object.prototype.hasOwnProperty,a=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},i={};a(i,{examples:()=>y,schemas:()=>n}),module.exports=(e=i,((e,a,i,n)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let l of r(a))s.call(e,l)||l===i||t(e,l,{get:()=>a[l],enumerable:!(n=o(a,l))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};a(n,{CorsOptionsSchema:()=>b,CorsOrigin:()=>m,HttpMethod:()=>p,RouteConfigSchema:()=>g,RouteMethod:()=>u,SettingsSchema:()=>h,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()}),m=d.z.union([d.z.string(),d.z.array(d.z.string()),d.z.literal("*")]),b=d.z.object({origin:m.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()}),h=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(),maxBatchSize:c.z.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),cors:c.z.union([c.z.boolean(),b]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),f=(0,l.zodToSchema)(h),y={};a(y,{createTrigger:()=>S,step:()=>w});var w={};a(w,{pixelGet:()=>O,postEvent:()=>v});var v={title:"POST event",description:"An Express POST to /collect with a JSON body becomes a single walker elb event.",trigger:{type:"POST"},in:{method:"POST",path:"/collect",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}}},out:[["elb",{name:"page view",data:{title:"Home",url:"https://example.com/"}}]]},O={title:"Pixel GET",description:"An Express GET to /collect with name and data[...] query parameters becomes a single walker elb event for pixel tracking.",trigger:{type:"GET"},in:{method:"GET",path:"/collect",query:{name:"page view","data[title]":"Home"}},out:[["elb",{name:"page view",data:{title:"Home"}}]]},T=require("@walkeros/core"),z=require("@walkeros/collector");var S=async(e,t)=>{const o=function(e,t){const o=e.sources??{},r=Object.keys(o),s=(0,T.isObject)(t)&&"string"==typeof t.sourceId?t.sourceId:1===r.length?r[0]:void 0,a=s?o[s]:void 0;if(!s||!a)return e;const i=a.config??{},n=(0,T.isObject)(i.settings)?i.settings:{};return void 0!==n.port?e:{...e,sources:{...o,[s]:{...a,config:{...i,settings:{...n,port:0}}}}}}(e,t);let r,s;return{get flow(){return r},trigger:()=>async e=>{const t=e.method||"POST";if(!r){const e=await(0,z.startFlow)(o);r={collector:e.collector,elb:e.elb};const t=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}}}(e.collector);if(!t)throw new Error("Express source server not found: the triggered source did not start a server");s=`http://localhost:${t}`}let a=`${s}${e.path}`;e.query&&(a+=`?${new URLSearchParams(e.query).toString()}`);const i={method:t,headers:{...e.headers&&Object.keys(e.headers).some(e=>"content-type"===e.toLowerCase())?{}:{"Content-Type":"application/json"},...e.headers}};"GET"!==t&&"HEAD"!==t&&void 0!==e.body&&(i.body="string"==typeof e.body?e.body:JSON.stringify(e.body));const n=await fetch(a,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 maxBatchSize: z\n .number()\n .int()\n .min(1)\n .describe('Maximum number of events accepted in a single batch request')\n .default(100),\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 title: 'POST event',\n description:\n 'An Express POST to /collect with a JSON body becomes a single walker elb event.',\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 [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n ],\n ],\n};\n\nexport const pixelGet: Flow.StepExample = {\n title: 'Pixel GET',\n description:\n 'An Express GET to /collect with query parameters is parsed into an elb event payload for pixel tracking.',\n trigger: { type: 'GET' },\n in: {\n method: 'GET',\n path: '/collect',\n query: { e: 'page view', d: '{\"title\":\"Home\"}' },\n },\n out: [\n [\n 'elb',\n {\n e: 'page view',\n d: '{\"title\":\"Home\"}',\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { isObject } 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 * The config with the triggered express source on a free port (0) when it\n * names none, so a simulation needs no port setting. The source is the one\n * `options.sourceId` names, else the config's only source. A configured port\n * and every other source stay as given.\n */\nfunction withFreePort(\n config: Collector.InitConfig,\n options: unknown,\n): Collector.InitConfig {\n const sources = config.sources ?? {};\n const ids = Object.keys(sources);\n const sourceId =\n isObject(options) && typeof options.sourceId === 'string'\n ? options.sourceId\n : ids.length === 1\n ? ids[0]\n : undefined;\n const source = sourceId ? sources[sourceId] : undefined;\n if (!sourceId || !source) return config;\n\n const sourceConfig = source.config ?? {};\n const settings = isObject(sourceConfig.settings) ? sourceConfig.settings : {};\n if (settings.port !== undefined) return config;\n\n return {\n ...config,\n sources: {\n ...sources,\n [sourceId]: {\n ...source,\n config: { ...sourceConfig, settings: { ...settings, port: 0 } },\n },\n },\n };\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 * Without `settings.port` the triggered source listens on a free 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 initConfig: Collector.InitConfig,\n options?: unknown,\n) => {\n const config = withFreePort(initConfig, options);\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: the triggered source did not start a server',\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;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,6DAA6D,EACtE,SAAS;AACd,CAAC;AASM,IAAM,aAAa,aAAE,MAAM;AAAA,EAChC,aAAE,OAAO;AAAA,EACT,aAAE,MAAM,aAAE,OAAO,CAAC;AAAA,EAClB,aAAE,QAAQ,GAAG;AACf,CAAC;AAMM,IAAM,oBAAo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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":["import_dev","import_dev","settings"]}
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 maxBatchSize: z\n .number()\n .int()\n .min(1)\n .describe('Maximum number of events accepted in a single batch request')\n .default(100),\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 title: 'POST event',\n description:\n 'An Express POST to /collect with a JSON body becomes a single walker elb event.',\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 [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n ],\n ],\n};\n\nexport const pixelGet: Flow.StepExample = {\n title: 'Pixel GET',\n description:\n 'An Express GET to /collect with name and data[...] query parameters becomes a single walker elb event for pixel tracking.',\n trigger: { type: 'GET' },\n in: {\n method: 'GET',\n path: '/collect',\n query: { name: 'page view', 'data[title]': 'Home' },\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { isObject } 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 * The config with the triggered express source on a free port (0) when it\n * names none, so a simulation needs no port setting. The source is the one\n * `options.sourceId` names, else the config's only source. A configured port\n * and every other source stay as given.\n */\nfunction withFreePort(\n config: Collector.InitConfig,\n options: unknown,\n): Collector.InitConfig {\n const sources = config.sources ?? {};\n const ids = Object.keys(sources);\n const sourceId =\n isObject(options) && typeof options.sourceId === 'string'\n ? options.sourceId\n : ids.length === 1\n ? ids[0]\n : undefined;\n const source = sourceId ? sources[sourceId] : undefined;\n if (!sourceId || !source) return config;\n\n const sourceConfig = source.config ?? {};\n const settings = isObject(sourceConfig.settings) ? sourceConfig.settings : {};\n if (settings.port !== undefined) return config;\n\n return {\n ...config,\n sources: {\n ...sources,\n [sourceId]: {\n ...source,\n config: { ...sourceConfig, settings: { ...settings, port: 0 } },\n },\n },\n };\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 * Without `settings.port` the triggered source listens on a free 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 initConfig: Collector.InitConfig,\n options?: unknown,\n) => {\n const config = withFreePort(initConfig, options);\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: the triggered source did not start a server',\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;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,6DAA6D,EACtE,SAAS;AACd,CAAC;AASM,IAAM,aAAa,aAAE,MAAM;AAAA,EAChC,aAAE,OAAO;AAAA,EACT,aAAE,MAAM,aAAE,OAAO,CAAC;AAAA,EAClB,aAAE,QAAQ,GAAG;AACf,CAAC;AAMM,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACxC,QAAQ,WAAW;AAAA,IACjB;AAAA,EACF,EAAE,SAAS;AAAA,EAEX,SAAS,aAAE,MAAM,UAAU,EAAE,SAAS,sBAAsB,EAAE,SAAS;AAAA,EAEvE,SAAS,aAAE,MAAM,aAAE,OAAO,CAAC,EAAE,SAAS,y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G,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","settings"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,o=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},r={};o(r,{CorsOptionsSchema:()=>p,CorsOrigin:()=>d,HttpMethod:()=>n,RouteConfigSchema:()=>c,RouteMethod:()=>l,SettingsSchema:()=>m,settings:()=>u});import{zodToSchema as s}from"@walkeros/core/dev";import{z as i}from"@walkeros/core/dev";import{z as a}from"@walkeros/core/dev";var n=a.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),l=a.enum(["GET","POST"]),c=a.object({path:a.string().describe("Express route path (supports wildcards like /api/*)"),methods:a.array(l).min(1).describe("HTTP methods to register. OPTIONS always included for CORS.").optional()}),d=a.union([a.string(),a.array(a.string()),a.literal("*")]),p=a.object({origin:d.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:a.array(n).describe("Allowed HTTP methods").optional(),headers:a.array(a.string()).describe("Allowed request headers").optional(),credentials:a.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:a.number().int().positive().describe("Preflight cache duration in seconds").optional()}),m=i.object({port:i.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:i.string().describe("Deprecated: use paths instead").optional(),paths:i.array(i.union([i.string(),c])).min(1).describe("Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.").optional(),maxBatchSize:i.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),cors:i.union([i.boolean(),p]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),u=s(m),g={};o(g,{createTrigger:()=>w,step:()=>h});var h={};o(h,{pixelGet:()=>f,postEvent:()=>b});var b={title:"POST event",description:"An Express POST to /collect with a JSON body becomes a single walker elb event.",trigger:{type:"POST"},in:{method:"POST",path:"/collect",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}}},out:[["elb",{name:"page view",data:{title:"Home",url:"https://example.com/"}}]]},f={title:"Pixel GET",description:"An Express GET to /collect with query parameters is parsed into an elb event payload for pixel tracking.",trigger:{type:"GET"},in:{method:"GET",path:"/collect",query:{e:"page view",d:'{"title":"Home"}'}},out:[["elb",{e:"page view",d:'{"title":"Home"}'}]]};import{isObject as y}from"@walkeros/core";import{startFlow as v}from"@walkeros/collector";var w=async(e,t)=>{const o=function(e,t){const o=e.sources??{},r=Object.keys(o),s=y(t)&&"string"==typeof t.sourceId?t.sourceId:1===r.length?r[0]:void 0,i=s?o[s]:void 0;if(!s||!i)return e;const a=i.config??{},n=y(a.settings)?a.settings:{};return void 0!==n.port?e:{...e,sources:{...o,[s]:{...i,config:{...a,settings:{...n,port:0}}}}}}(e,t);let r,s;return{get flow(){return r},trigger:()=>async e=>{const t=e.method||"POST";if(!r){const e=await v(o);r={collector:e.collector,elb:e.elb};const t=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}}}(e.collector);if(!t)throw new Error("Express source server not found: the triggered source did not start a server");s=`http://localhost:${t}`}let i=`${s}${e.path}`;e.query&&(i+=`?${new URLSearchParams(e.query).toString()}`);const a={method:t,headers:{...e.headers&&Object.keys(e.headers).some(e=>"content-type"===e.toLowerCase())?{}:{"Content-Type":"application/json"},...e.headers}};"GET"!==t&&"HEAD"!==t&&void 0!==e.body&&(a.body="string"==typeof e.body?e.body:JSON.stringify(e.body));const n=await fetch(i,a),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{g as examples,r as schemas};//# sourceMappingURL=dev.mjs.map
1
+ import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,o=(e,o)=>{for(var r in o)t(e,r,{get:o[r],enumerable:!0})},r={};o(r,{CorsOptionsSchema:()=>p,CorsOrigin:()=>d,HttpMethod:()=>n,RouteConfigSchema:()=>c,RouteMethod:()=>l,SettingsSchema:()=>m,settings:()=>u});import{zodToSchema as s}from"@walkeros/core/dev";import{z as a}from"@walkeros/core/dev";import{z as i}from"@walkeros/core/dev";var n=i.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),l=i.enum(["GET","POST"]),c=i.object({path:i.string().describe("Express route path (supports wildcards like /api/*)"),methods:i.array(l).min(1).describe("HTTP methods to register. OPTIONS always included for CORS.").optional()}),d=i.union([i.string(),i.array(i.string()),i.literal("*")]),p=i.object({origin:d.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:i.array(n).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()}),m=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(),c])).min(1).describe("Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.").optional(),maxBatchSize:a.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),cors:a.union([a.boolean(),p]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),u=s(m),g={};o(g,{createTrigger:()=>w,step:()=>h});var h={};o(h,{pixelGet:()=>f,postEvent:()=>b});var b={title:"POST event",description:"An Express POST to /collect with a JSON body becomes a single walker elb event.",trigger:{type:"POST"},in:{method:"POST",path:"/collect",body:{name:"page view",data:{title:"Home",url:"https://example.com/"}}},out:[["elb",{name:"page view",data:{title:"Home",url:"https://example.com/"}}]]},f={title:"Pixel GET",description:"An Express GET to /collect with name and data[...] query parameters becomes a single walker elb event for pixel tracking.",trigger:{type:"GET"},in:{method:"GET",path:"/collect",query:{name:"page view","data[title]":"Home"}},out:[["elb",{name:"page view",data:{title:"Home"}}]]};import{isObject as y}from"@walkeros/core";import{startFlow as v}from"@walkeros/collector";var w=async(e,t)=>{const o=function(e,t){const o=e.sources??{},r=Object.keys(o),s=y(t)&&"string"==typeof t.sourceId?t.sourceId:1===r.length?r[0]:void 0,a=s?o[s]:void 0;if(!s||!a)return e;const i=a.config??{},n=y(i.settings)?i.settings:{};return void 0!==n.port?e:{...e,sources:{...o,[s]:{...a,config:{...i,settings:{...n,port:0}}}}}}(e,t);let r,s;return{get flow(){return r},trigger:()=>async e=>{const t=e.method||"POST";if(!r){const e=await v(o);r={collector:e.collector,elb:e.elb};const t=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}}}(e.collector);if(!t)throw new Error("Express source server not found: the triggered source did not start a server");s=`http://localhost:${t}`}let a=`${s}${e.path}`;e.query&&(a+=`?${new URLSearchParams(e.query).toString()}`);const i={method:t,headers:{...e.headers&&Object.keys(e.headers).some(e=>"content-type"===e.toLowerCase())?{}:{"Content-Type":"application/json"},...e.headers}};"GET"!==t&&"HEAD"!==t&&void 0!==e.body&&(i.body="string"==typeof e.body?e.body:JSON.stringify(e.body));const n=await fetch(a,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{g 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/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 maxBatchSize: z\n .number()\n .int()\n .min(1)\n .describe('Maximum number of events accepted in a single batch request')\n .default(100),\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 title: 'POST event',\n description:\n 'An Express POST to /collect with a JSON body becomes a single walker elb event.',\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 [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n ],\n ],\n};\n\nexport const pixelGet: Flow.StepExample = {\n title: 'Pixel GET',\n description:\n 'An Express GET to /collect with query parameters is parsed into an elb event payload for pixel tracking.',\n trigger: { type: 'GET' },\n in: {\n method: 'GET',\n path: '/collect',\n query: { e: 'page view', d: '{\"title\":\"Home\"}' },\n },\n out: [\n [\n 'elb',\n {\n e: 'page view',\n d: '{\"title\":\"Home\"}',\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { isObject } 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 * The config with the triggered express source on a free port (0) when it\n * names none, so a simulation needs no port setting. The source is the one\n * `options.sourceId` names, else the config's only source. A configured port\n * and every other source stay as given.\n */\nfunction withFreePort(\n config: Collector.InitConfig,\n options: unknown,\n): Collector.InitConfig {\n const sources = config.sources ?? {};\n const ids = Object.keys(sources);\n const sourceId =\n isObject(options) && typeof options.sourceId === 'string'\n ? options.sourceId\n : ids.length === 1\n ? ids[0]\n : undefined;\n const source = sourceId ? sources[sourceId] : undefined;\n if (!sourceId || !source) return config;\n\n const sourceConfig = source.config ?? {};\n const settings = isObject(sourceConfig.settings) ? sourceConfig.settings : {};\n if (settings.port !== undefined) return config;\n\n return {\n ...config,\n sources: {\n ...sources,\n [sourceId]: {\n ...source,\n config: { ...sourceConfig, settings: { ...settings, port: 0 } },\n },\n },\n };\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 * Without `settings.port` the triggered source listens on a free 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 initConfig: Collector.InitConfig,\n options?: unknown,\n) => {\n const config = withFreePort(initConfig, options);\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: the triggered source did not start a server',\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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aAAO,IAAI,IAAI,gBAAgB,QAAQ,KAAK,EAAE,SAAS,CAAC;AAAA,IAC1D;AAGA,UAAM,iBACJ,QAAQ,WACR,OAAO,KAAK,QAAQ,OAAO,EAAE;AAAA,MAC3B,CAAC,MAAM,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","settings"]}
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 maxBatchSize: z\n .number()\n .int()\n .min(1)\n .describe('Maximum number of events accepted in a single batch request')\n .default(100),\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 title: 'POST event',\n description:\n 'An Express POST to /collect with a JSON body becomes a single walker elb event.',\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 [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home', url: 'https://example.com/' },\n },\n ],\n ],\n};\n\nexport const pixelGet: Flow.StepExample = {\n title: 'Pixel GET',\n description:\n 'An Express GET to /collect with name and data[...] query parameters becomes a single walker elb event for pixel tracking.',\n trigger: { type: 'GET' },\n in: {\n method: 'GET',\n path: '/collect',\n query: { name: 'page view', 'data[title]': 'Home' },\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { isObject } 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 * The config with the triggered express source on a free port (0) when it\n * names none, so a simulation needs no port setting. The source is the one\n * `options.sourceId` names, else the config's only source. A configured port\n * and every other source stay as given.\n */\nfunction withFreePort(\n config: Collector.InitConfig,\n options: unknown,\n): Collector.InitConfig {\n const sources = config.sources ?? {};\n const ids = Object.keys(sources);\n const sourceId =\n isObject(options) && typeof options.sourceId === 'string'\n ? options.sourceId\n : ids.length === 1\n ? ids[0]\n : undefined;\n const source = sourceId ? sources[sourceId] : undefined;\n if (!sourceId || !source) return config;\n\n const sourceConfig = source.config ?? {};\n const settings = isObject(sourceConfig.settings) ? sourceConfig.settings : {};\n if (settings.port !== undefined) return config;\n\n return {\n ...config,\n sources: {\n ...sources,\n [sourceId]: {\n ...source,\n config: { ...sourceConfig, settings: { ...settings, port: 0 } },\n },\n },\n };\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 * Without `settings.port` the triggered source listens on a free 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 initConfig: Collector.InitConfig,\n options?: unknown,\n) => {\n const config = withFreePort(initConfig, options);\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: the triggered source did not start a server',\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,E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AI,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","settings"]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$meta": {
3
3
  "package": "@walkeros/server-source-express",
4
- "version": "4.8.2",
4
+ "version": "4.8.3-next-1793115089237",
5
5
  "type": "source",
6
6
  "platform": [
7
7
  "server"
@@ -142,12 +142,12 @@
142
142
  },
143
143
  "examples": {
144
144
  "createTrigger": {
145
- "$code": "async(e,t)=>{const o=function(e,t){const o=e.sources??{},r=Object.keys(o),s=y(t)&&\"string\"==typeof t.sourceId?t.sourceId:1===r.length?r[0]:void 0,i=s?o[s]:void 0;if(!s||!i)return e;const a=i.config??{},n=y(a.settings)?a.settings:{};return void 0!==n.port?e:{...e,sources:{...o,[s]:{...i,config:{...a,settings:{...n,port:0}}}}}}(e,t);let r,s;return{get flow(){return r},trigger:()=>async e=>{const t=e.method||\"POST\";if(!r){const e=await v(o);r={collector:e.collector,elb:e.elb};const t=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}}}(e.collector);if(!t)throw new Error(\"Express source server not found: the triggered source did not start a server\");s=`http://localhost:${t}`}let i=`${s}${e.path}`;e.query&&(i+=`?${new URLSearchParams(e.query).toString()}`);const a={method:t,headers:{...e.headers&&Object.keys(e.headers).some(e=>\"content-type\"===e.toLowerCase())?{}:{\"Content-Type\":\"application/json\"},...e.headers}};\"GET\"!==t&&\"HEAD\"!==t&&void 0!==e.body&&(a.body=\"string\"==typeof e.body?e.body:JSON.stringify(e.body));const n=await fetch(i,a),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}}}}"
145
+ "$code": "async(e,t)=>{const o=function(e,t){const o=e.sources??{},r=Object.keys(o),s=y(t)&&\"string\"==typeof t.sourceId?t.sourceId:1===r.length?r[0]:void 0,a=s?o[s]:void 0;if(!s||!a)return e;const i=a.config??{},n=y(i.settings)?i.settings:{};return void 0!==n.port?e:{...e,sources:{...o,[s]:{...a,config:{...i,settings:{...n,port:0}}}}}}(e,t);let r,s;return{get flow(){return r},trigger:()=>async e=>{const t=e.method||\"POST\";if(!r){const e=await v(o);r={collector:e.collector,elb:e.elb};const t=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}}}(e.collector);if(!t)throw new Error(\"Express source server not found: the triggered source did not start a server\");s=`http://localhost:${t}`}let a=`${s}${e.path}`;e.query&&(a+=`?${new URLSearchParams(e.query).toString()}`);const i={method:t,headers:{...e.headers&&Object.keys(e.headers).some(e=>\"content-type\"===e.toLowerCase())?{}:{\"Content-Type\":\"application/json\"},...e.headers}};\"GET\"!==t&&\"HEAD\"!==t&&void 0!==e.body&&(i.body=\"string\"==typeof e.body?e.body:JSON.stringify(e.body));const n=await fetch(a,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}}}}"
146
146
  },
147
147
  "step": {
148
148
  "pixelGet": {
149
149
  "title": "Pixel GET",
150
- "description": "An Express GET to /collect with query parameters is parsed into an elb event payload for pixel tracking.",
150
+ "description": "An Express GET to /collect with name and data[...] query parameters becomes a single walker elb event for pixel tracking.",
151
151
  "trigger": {
152
152
  "type": "GET"
153
153
  },
@@ -155,16 +155,18 @@
155
155
  "method": "GET",
156
156
  "path": "/collect",
157
157
  "query": {
158
- "e": "page view",
159
- "d": "{\"title\":\"Home\"}"
158
+ "name": "page view",
159
+ "data[title]": "Home"
160
160
  }
161
161
  },
162
162
  "out": [
163
163
  [
164
164
  "elb",
165
165
  {
166
- "e": "page view",
167
- "d": "{\"title\":\"Home\"}"
166
+ "name": "page view",
167
+ "data": {
168
+ "title": "Home"
169
+ }
168
170
  }
169
171
  ]
170
172
  ]
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": "4.8.2",
4
+ "version": "4.8.3-next-1793115089237",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -20,8 +20,8 @@
20
20
  "update": "npx npm-check-updates -u && npm update"
21
21
  },
22
22
  "dependencies": {
23
- "@walkeros/collector": "4.8.2",
24
- "@walkeros/core": "4.8.2",
23
+ "@walkeros/collector": "4.8.3-next-1793115089237",
24
+ "@walkeros/core": "4.8.3-next-1793115089237",
25
25
  "express": "^5.2.1",
26
26
  "cors": "^2.8.5"
27
27
  },