@walkeros/server-source-express 4.9.0-next-1793116456867 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,26 +1,43 @@
1
1
  # @walkeros/server-source-express
2
2
 
3
- ## 4.9.0-next-1793116456867
3
+ ## 4.9.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - 1fb57b0: The route `path` description now names the patterns Express 5
8
+ accepts, `/api/:id` and `/api/*path`. A bare `/api/*`, which the old text
9
+ suggested, is rejected at startup because the wildcard has no parameter name.
10
+ Only the description text changed, not the route handling.
11
+ - 1306d8a: The Express `path` setting is described as a single route path that
12
+ `paths` overrides, and it is no longer marked deprecated. The
13
+ `validate_tagging` tool description lists all its checks, empty entity names
14
+ first. The demo transformer's docs link points to the transformers page, which
15
+ also shows in MCP `package_get`.
7
16
  - 5313635: The pixel GET example now sends `name` and `data[...]` query
8
17
  parameters, the form the source turns into an event. The previous example used
9
18
  `e` and `d` parameters, which the collector rejects as an event without a
10
19
  name, so the request answered with the GIF and nothing was delivered.
20
+ - Updated dependencies [a67546d]
11
21
  - Updated dependencies [5313635]
12
22
  - Updated dependencies [5313635]
13
23
  - Updated dependencies [34fd225]
24
+ - Updated dependencies [1306d8a]
25
+ - Updated dependencies [1306d8a]
14
26
  - Updated dependencies [34fd225]
15
27
  - Updated dependencies [5313635]
28
+ - Updated dependencies [1306d8a]
29
+ - Updated dependencies [fa46337]
16
30
  - Updated dependencies [5313635]
17
31
  - Updated dependencies [5313635]
18
32
  - Updated dependencies [5313635]
19
33
  - Updated dependencies [5313635]
20
34
  - Updated dependencies [34fd225]
35
+ - Updated dependencies [fa46337]
36
+ - Updated dependencies [1306d8a]
37
+ - Updated dependencies [1fb57b0]
21
38
  - Updated dependencies [5313635]
22
- - @walkeros/collector@4.9.0-next-1793116456867
23
- - @walkeros/core@4.9.0-next-1793116456867
39
+ - @walkeros/core@4.9.0
40
+ - @walkeros/collector@4.9.0
24
41
 
25
42
  ## 4.8.2
26
43
 
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,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
1
+ "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,s=(e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})},i={};s(i,{examples:()=>y,schemas:()=>n}),module.exports=(e=i,((e,s,i,n)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let l of o(s))a.call(e,l)||l===i||t(e,l,{get:()=>s[l],enumerable:!(n=r(s,l))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};s(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: a literal, a named parameter (/api/:id) or a named wildcard (/api/*path); express 5 rejects a bare *"),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("Single route path, registered for GET and POST. Ignored when paths is set; paths takes several routes.").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(),m]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),f=(0,l.zodToSchema)(b),y={};s(y,{createTrigger:()=>S,step:()=>w});var w={};s(w,{pixelGet:()=>T,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/"}}]]},T={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"}}]]},O=require("@walkeros/core"),z=require("@walkeros/collector");var S=async(e,t)=>{const r=function(e,t){const r=e.sources??{},o=Object.keys(r),a=(0,O.isObject)(t)&&"string"==typeof t.sourceId?t.sourceId:1===o.length?o[0]:void 0,s=a?r[a]:void 0;if(!a||!s)return e;const i=s.config??{},n=(0,O.isObject)(i.settings)?i.settings:{};return void 0!==n.port?e:{...e,sources:{...r,[a]:{...s,config:{...i,settings:{...n,port:0}}}}}}(e,t);let o,a;return{get flow(){return o},trigger:()=>async e=>{const t=e.method||"POST";if(!o){const e=await(0,z.startFlow)(r);o={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");a=`http://localhost:${t}`}let s=`${a}${e.path}`;e.query&&(s+=`?${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(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 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: respon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AA,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 path: z\n .string()\n .describe(\n 'Single route path, registered for GET and POST. Ignored when paths is set; paths takes several routes.',\n )\n .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(\n 'Express route path: a literal, a named parameter (/api/:id) or a named wildcard (/api/*path); express 5 rejects a bare *',\n ),\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;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,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 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
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 a}from"@walkeros/core/dev";import{z as s}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: a literal, a named parameter (/api/:id) or a named wildcard (/api/*path); express 5 rejects a bare *"),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=s.object({port:s.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:s.string().describe("Single route path, registered for GET and POST. Ignored when paths is set; paths takes several routes.").optional(),paths:s.array(s.union([s.string(),c])).min(1).describe("Route paths to register. String shorthand registers GET+POST. RouteConfig allows per-route method control.").optional(),maxBatchSize:s.number().int().min(1).describe("Maximum number of events accepted in a single batch request").default(100),cors:s.union([s.boolean(),p]).describe("CORS configuration: false = disabled, true = allow all origins (default), object = custom configuration").default(!0)}),u=a(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),a=y(t)&&"string"==typeof t.sourceId?t.sourceId:1===r.length?r[0]:void 0,s=a?o[a]:void 0;if(!a||!s)return e;const i=s.config??{},n=y(i.settings)?i.settings:{};return void 0!==n.port?e:{...e,sources:{...o,[a]:{...s,config:{...i,settings:{...n,port:0}}}}}}(e,t);let r,a;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");a=`http://localhost:${t}`}let s=`${a}${e.path}`;e.query&&(s+=`?${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(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{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 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,EAAE,MAAM;AAAA,EAChC,EAAE,OAAO;AA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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 path: z\n .string()\n .describe(\n 'Single route path, registered for GET and POST. Ignored when paths is set; paths takes several routes.',\n )\n .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(\n 'Express route path: a literal, a named parameter (/api/:id) or a named wildcard (/api/*path); express 5 rejects a bare *',\n ),\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;AAAA,IACC;AAAA,EACF;AAAA,EACF,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,MA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,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.9.0-next-1793116456867",
4
+ "version": "4.9.0",
5
5
  "type": "source",
6
6
  "platform": [
7
7
  "server"
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "path": {
25
25
  "type": "string",
26
- "description": "Deprecated: use paths instead"
26
+ "description": "Single route path, registered for GET and POST. Ignored when paths is set; paths takes several routes."
27
27
  },
28
28
  "paths": {
29
29
  "minItems": 1,
@@ -38,7 +38,7 @@
38
38
  "properties": {
39
39
  "path": {
40
40
  "type": "string",
41
- "description": "Express route path (supports wildcards like /api/*)"
41
+ "description": "Express route path: a literal, a named parameter (/api/:id) or a named wildcard (/api/*path); express 5 rejects a bare *"
42
42
  },
43
43
  "methods": {
44
44
  "minItems": 1,
@@ -142,7 +142,7 @@
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,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}}}}"
145
+ "$code": "async(e,t)=>{const o=function(e,t){const o=e.sources??{},r=Object.keys(o),a=y(t)&&\"string\"==typeof t.sourceId?t.sourceId:1===r.length?r[0]:void 0,s=a?o[a]:void 0;if(!a||!s)return e;const i=s.config??{},n=y(i.settings)?i.settings:{};return void 0!==n.port?e:{...e,sources:{...o,[a]:{...s,config:{...i,settings:{...n,port:0}}}}}}(e,t);let r,a;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\");a=`http://localhost:${t}`}let s=`${a}${e.path}`;e.query&&(s+=`?${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(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}}}}"
146
146
  },
147
147
  "step": {
148
148
  "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": "4.9.0-next-1793116456867",
4
+ "version": "4.9.0",
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.9.0-next-1793116456867",
24
- "@walkeros/core": "4.9.0-next-1793116456867",
23
+ "@walkeros/collector": "4.9.0",
24
+ "@walkeros/core": "4.9.0",
25
25
  "express": "^5.2.1",
26
26
  "cors": "^2.8.5"
27
27
  },