@walkeros/server-source-aws 4.2.0 → 4.2.1-next-1781538735002

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,12 @@
1
1
  # @walkeros/server-source-aws
2
2
 
3
+ ## 4.2.1-next-1781538735002
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5cbcd23]
8
+ - @walkeros/core@4.2.1-next-1781538735002
9
+
3
10
  ## 4.2.0
4
11
 
5
12
  ### Patch Changes
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,r=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},i={};r(i,{examples:()=>I,schemas:()=>a,sqsExamples:()=>nt}),module.exports=(e=i,((e,r,i,a)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let c of o(r))s.call(e,c)||c===i||t(e,c,{get:()=>r[c],enumerable:!(a=n(r,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};r(a,{CorsOptionsSchema:()=>f,CorsOrigin:()=>p,HttpMethod:()=>d,SettingsSchema:()=>g,settings:()=>h,sqsSettings:()=>S,sqsSetup:()=>q});var c=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),d=l.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),p=l.z.union([l.z.string(),l.z.array(l.z.string()),l.z.literal("*")]),f=l.z.object({origin:p.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:l.z.array(d).describe("Allowed HTTP methods").optional(),headers:l.z.array(l.z.string()).describe("Allowed request headers").optional(),credentials:l.z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:l.z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),g=u.z.object({cors:u.z.union([u.z.boolean(),f]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").default(!0),timeout:u.z.number().int().positive().max(9e5).describe("Request timeout in milliseconds (max: 900000 for Lambda)").default(3e4),enablePixelTracking:u.z.boolean().describe("Enable GET requests with 1x1 transparent GIF response for pixel tracking").default(!0),healthPath:u.z.string().describe("Health check endpoint path (e.g., /health)").default("/health")}),h=(0,c.zodToSchema)(g),m=require("@walkeros/core/dev"),y=require("@walkeros/core/dev"),w=y.z.object({queueName:y.z.string().min(1).describe("SQS queue short name (like walkeros-events). Required for both setup and runtime poll."),region:y.z.string().describe("AWS region (like eu-central-1). Default: eu-central-1.").optional(),queueUrl:y.z.string().url().describe("Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.").optional(),client:y.z.any().describe("Pre-configured AWS SQSClient instance. Bypasses construction when supplied.").optional(),config:y.z.any().describe("AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).").optional(),decoder:y.z.enum(["json","text","raw"]).describe("Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.").optional(),maxMessages:y.z.number().int().min(1).max(10).describe("SQS receive batch size. Cap 10. Default: 10.").optional(),waitTimeSeconds:y.z.number().int().min(0).max(20).describe("Long-poll duration in seconds. Cap 20. Default: 20.").optional(),visibilityTimeout:y.z.number().int().nonnegative().describe("Per-receive visibility timeout override. Default: queue-configured value.").optional(),shutdownTimeoutMs:y.z.number().int().positive().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.").optional(),onPushError:y.z.enum(["nack","ack"]).describe("Behavior when forwarding to the collector throws. nack (default) skips DeleteMessage so the message redelivers; ack drops it.").optional()}),v=require("@walkeros/core/dev"),b=v.z.record(v.z.string(),v.z.string()),k=v.z.object({region:v.z.string().min(1).describe("AWS region.").optional(),fifoQueue:v.z.boolean().describe("FIFO queue with content-based deduplication. Auto-appends .fifo suffix to the queue name.").optional(),visibilityTimeoutSeconds:v.z.number().int().nonnegative().describe("Visibility timeout in seconds. Default: 30.").optional(),messageRetentionSeconds:v.z.number().int().positive().describe("Message retention period in seconds. Default: 345600 (4 days).").optional(),maximumMessageSize:v.z.number().int().min(1024).max(262144).describe("Max message size in bytes. Default: 262144 (256 KB).").optional(),kmsMasterKeyId:v.z.string().describe("KMS key alias or ID for at-rest encryption.").optional(),deadLetterQueue:v.z.object({arn:v.z.string().describe("ARN of an existing DLQ. Mutually exclusive with create: true.").optional(),create:v.z.boolean().describe("Create a sibling DLQ named <queueName>-dlq. Default: false.").optional(),maxReceiveCount:v.z.number().int().min(1).max(1e3).describe("Max receive count before message goes to DLQ. Default: 5.").optional()}).describe("Optional dead-letter queue.").optional(),tags:b.describe("Tags applied to the queue (and inherited by an auto-created DLQ).").optional(),subscribeToSnsTopic:v.z.object({topicArn:v.z.string().min(1).describe("Topic ARN to subscribe to."),rawMessageDelivery:v.z.boolean().describe("Deliver SNS messages without the SNS envelope.").optional(),filterPolicy:v.z.record(v.z.string(),v.z.unknown()).describe("SNS filter policy applied at subscription level.").optional()}).describe("Optional SNS topic subscription. Creates the subscription and the matching queue policy.").optional()}),S=(0,m.zodToSchema)(w),q=(0,m.zodToSchema)(k),I={};r(I,{createTrigger:()=>et,env:()=>O,step:()=>T,trigger:()=>tt});var O={};r(O,{push:()=>A});var C=()=>()=>Promise.resolve({ok:!0}),x=()=>{},j={error:x,warn:x,info:x,debug:x,throw:e=>{throw"string"==typeof e?new Error(e):e},json:x,scope:()=>j},A={get push(){return C()},get command(){return C()},get elb(){return C()},logger:j},T={};r(T,{apiGatewayV1Post:()=>E,lambdaGet:()=>M,lambdaPost:()=>D});var D={title:"Lambda POST",description:"An API Gateway v2 HTTP POST with a JSON body is converted into a walker elb event.",trigger:{type:"POST"},in:{version:"2.0",requestContext:{http:{method:"POST",path:"/collect"},requestId:"req-123"},body:JSON.stringify({event:"page view",data:{title:"Home"}}),isBase64Encoded:!1},out:[["elb",{name:"page view",data:{title:"Home"}}]]},E={title:"API Gateway v1 POST",description:"A REST API Gateway v1 POST request with a JSON body is converted into a walker elb event.",trigger:{type:"POST"},in:{httpMethod:"POST",path:"/collect",requestContext:{requestId:"req-789",identity:{sourceIp:"203.0.113.42"}},queryStringParameters:null,body:JSON.stringify({event:"page view",data:{title:"Home"}}),isBase64Encoded:!1},out:[["elb",{name:"page view",data:{title:"Home"}}]]},M={title:"Lambda GET",description:"An API Gateway v2 HTTP GET with query parameters is parsed into an elb event payload.",trigger:{type:"GET"},in:{version:"2.0",requestContext:{http:{method:"GET",path:"/collect"},requestId:"req-456"},rawQueryString:"e=page+view&d=%7B%22title%22%3A%22Home%22%7D",isBase64Encoded:!1},out:[["elb",{e:"page view",d:'{"title":"Home"}'}]]},z=require("@walkeros/core"),P=require("@walkeros/core"),$=require("@walkeros/core"),_=(require("@walkeros/core"),require("@walkeros/core")),H=require("@walkeros/core"),N=require("@walkeros/core"),R=require("@walkeros/core"),G=require("@walkeros/core"),B=require("@walkeros/core"),F=require("@walkeros/core"),L=require("@walkeros/core"),U=require("@walkeros/core"),K=require("@walkeros/core"),Q={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Scoped:"_",Session:"session",Shutdown:"shutdown",User:"user",Walker:"walker"};function J(e,t){const n=e.status.startedAt;return{flowId:"default",stepId:t.stepId,stepType:t.stepType,phase:t.phase,eventId:t.eventId,timestamp:new Date(t.now).toISOString(),elapsedMs:t.now-n}}function W(e,t){return e.storeId&&t.stores[e.storeId]?t.stores[e.storeId]:t.stores.__cache}function V(e,t){return e?t.stores[e]:t.stores.__cache}function Y(e){const t={};for(const[n,o]of Object.entries(e)){const e=o.config?.next;"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?t[n]={next:e}:t[n]={}}return t}function X(e,t){const n=e.config||{},o=e[t];return void 0!==o?{config:{...n,[t]:o},chainValue:o}:{config:n,chainValue:void 0}}function Z(e,t={}){if(!e)return[];if(Array.isArray(e))return e;const n=[],o=new Set;let s=e;for(;s&&t[s]&&!o.has(s);){o.add(s),n.push(s);const e=t[s].next;if(Array.isArray(e)){n.push(...e);break}s=e}return n}async function ee(e,t,n){if(t.init&&!t.config.init){const o=t.type||"unknown",s=e.logger.scope(`transformer:${o}`),r={collector:e,logger:s,id:n,ingest:(0,R.createIngest)(n),config:t.config,env:se(t.config.env)};s.debug("init");const i=await(0,R.useHooks)(t.init,"TransformerInit",e.hooks,e.logger)(r);if(!1===i)return!1;t.config={...i||t.config,env:i?.env||t.config.env,init:!0},s.debug("init done")}return!0}async function te(e,t,n,o,s,r){const i=t.type||"unknown",a=e.logger.scope(`transformer:${i}`),c={collector:e,logger:a,id:n,ingest:s,config:t.config,env:{...se(t.config.env),...r?{respond:r}:{}}};a.debug("push",{event:o.name});const u="string"==typeof o.id?o.id:"",l=Date.now(),d=J(e,{stepId:(0,R.stepId)("transformer",n),stepType:"transformer",phase:"in",eventId:u,now:l});(0,R.emitStep)(e,d);try{const s=await(0,R.useHooks)(t.push,"TransformerPush",e.hooks,e.logger)(o,c),r=Date.now(),i=J(e,{stepId:(0,R.stepId)("transformer",n),stepType:"transformer",phase:"out",eventId:u,now:r});return i.durationMs=r-l,i.outEvent=s,(0,R.emitStep)(e,i),a.debug("push done"),s}catch(t){const o=Date.now(),s=J(e,{stepId:(0,R.stepId)("transformer",n),stepType:"transformer",phase:"error",eventId:u,now:o});throw s.durationMs=o-l,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},(0,R.emitStep)(e,s),t}}function ne(e,t){return e?{...e,_meta:{...e._meta,path:[...e._meta.path]}}:(0,R.createIngest)(t)}async function oe(e,t,n,o,s,r,i){s||(s=(0,R.createIngest)(n[0]??"chain")),i&&s._meta&&(s._meta.chainPath=i);let a=o,c=r;for(const o of n){const r=t[o];if(!r){e.logger.warn(`Transformer not found: ${o}`);continue}if(s&&s._meta&&s._meta.path.length>256)return e.logger.error(`Max path length exceeded at ${o}`),{event:null,respond:c};if(s&&s._meta&&(s._meta.hops++,s._meta.path.push(o)),!await(0,R.tryCatchAsync)(ee,t=>{if(t instanceof R.FatalError)throw t;return e.status.failed++,e.logger.scope(`transformer:${r.type||"unknown"}`).error("transformer init failed",{transformer:o,error:t}),!1})(e,r,o))return{event:null,respond:c};if(i&&void 0!==r.config?.chainMocks?.[i]){const t=r.config.chainMocks[i];e.logger.scope(`transformer:${r.type||"unknown"}`).debug("chainMock",{chain:i}),a=t;continue}if(void 0!==r.config?.mock){e.logger.scope(`transformer:${r.type||"unknown"}`).debug("mock"),a=r.config.mock;continue}if(r.config?.disabled)continue;const u=r.config?.cache,l=u?(0,R.compileCache)(u):void 0,d=l?W(l,e):void 0,p=r.config?.state?(0,R.compileState)(r.config.state):void 0,f=p?.filter(e=>"get"===e.mode),g=p?.filter(e=>"set"===e.mode),h=async t=>g&&0!==g.length?(0,R.applyState)(g,t=>V(t,e),t,e):t;let m;if(l&&d){const e=(0,R.buildCacheContext)(s,a),t=await(0,R.checkCache)(l,d,e);if("HIT"===t?.status&&t.value){if(a=t.value,l.stop)return{event:a,respond:c,stopped:!0};continue}"MISS"===t?.status&&(m={key:t.key,ttl:t.rule.ttl})}const y=r.config.before;if(y){const n=(0,R.getNextSteps)(y,(0,R.buildCacheContext)(s,a));if(1===n.length){const o=Z(n[0],Y(t));if(o.length>0){const n=await oe(e,t,o,a,s,c,i);if(null===n.event)return{event:null,respond:n.respond??c};if(n.stopped)return{event:Array.isArray(n.event)?n.event[0]:n.event,respond:n.respond??c,stopped:!0};n.respond&&(c=n.respond),a=Array.isArray(n.event)?n.event[0]:n.event}}else n.length>1&&await Promise.all(n.map(n=>(0,R.tryCatchAsync)(oe,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Z(n,Y(t)),a,ne(s,n),void 0,i)))}f&&f.length>0&&(a=await(0,R.applyState)(f,t=>V(t,e),a,e));const w=await(0,R.tryCatchAsync)(te,t=>(e.logger.scope(`transformer:${r.type||"unknown"}`).error("Push failed",{error:t}),!1))(e,r,o,a,s,c);if(!1===w)return{event:null,respond:c};if(Array.isArray(w)){const r=n.slice(n.indexOf(o)+1),u=await Promise.all(w.map(async n=>{const o=await h(n.event||a),u=ne(s,"unknown");if(n.next){const s=(0,R.getNextSteps)(n.next,(0,R.buildCacheContext)(u,o));if(0===s.length)return{event:o,respond:c};if(1===s.length){const n=Z(s[0],Y(t));return n.length>0?oe(e,t,n,o,u,c,i):{event:o,respond:c}}return(await Promise.all(s.map(n=>(0,R.tryCatchAsync)(oe,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Z(n,Y(t)),o,ne(u,n),void 0,i)))).map(e=>({event:e.event,respond:void 0}))}return r.length>0?oe(e,t,r,o,u,c,i):{event:o,respond:c}}));let l=c;const d=[];for(const e of u.flat())if(null!==e)if(e&&"object"==typeof e&&"event"in e){const t=e;if(t.respond&&(l=t.respond),null===t.event)continue;Array.isArray(t.event)?d.push(...t.event):d.push(t.event)}else d.push(e);return 0===d.length?{event:null,respond:l}:1===d.length?{event:d[0],respond:l}:{event:d,respond:l}}if(w&&"object"==typeof w){const{event:n,respond:o,next:r}=w;if(o&&(c=o),void 0!==r){const o=await h(n||a),u=(0,R.getNextSteps)(r,(0,R.buildCacheContext)(s,o));if(0===u.length){a=o;continue}if(1===u.length){const n=Z(u[0],Y(t));return n.length>0?oe(e,t,n,o,s,c,i):(e.logger.warn(`Branch target not found: ${JSON.stringify(r)}`),{event:null,respond:c})}return await Promise.all(u.map(n=>(0,R.tryCatchAsync)(oe,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Z(n,Y(t)),o,ne(s,n),void 0,i))),{event:null,respond:void 0}}n&&(a=n)}g&&g.length>0&&(a=await(0,R.applyState)(g,t=>V(t,e),a,e)),m&&d&&(0,R.storeCache)(d,m.key,a,m.ttl);const v=r.config.next,b="string"==typeof v||Array.isArray(v)&&v.every(e=>"string"==typeof e),k=void 0!==v&&!b;if((!w||"object"==typeof w&&!w.next)&&k){const n=(0,R.getNextSteps)(r.config.next,(0,R.buildCacheContext)(s,a));if(1===n.length){const o=Z(n[0],Y(t));return o.length>0?oe(e,t,o,a,s,c,i):{event:a,respond:c}}return n.length>1?(await Promise.all(n.map(n=>(0,R.tryCatchAsync)(oe,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Z(n,Y(t)),a,ne(s,n),void 0,i))),{event:null,respond:void 0}):{event:a,respond:c}}}return{event:a,respond:c}}function se(e){return e&&(0,R.isObject)(e)?e:{}}function re(e){return"string"==typeof e||!(!Array.isArray(e)||!e.every(e=>"string"==typeof e))}async function ie(e,t,n){if(!t.on||!t.queueOn?.length)return;const o=t.queueOn;t.queueOn=[];const s=n||t.config?.id||"unknown";for(const{type:n,data:r}of o)he(n)&&!be(e,t,n)||(await(0,N.tryCatchAsync)(t.on,t=>{if(t instanceof N.FatalError)throw t;e.status.failed++,e.logger.scope("source").error("source on flush failed",{sourceId:s,type:n,error:t})})(n,r),he(n)&&ve(e,t,n))}function ae(e){return Boolean(e.config.init)&&!e.config.require?.length}async function ce(e,t,n){const{code:o,config:s={},env:r={},primary:i,next:a,before:c,cache:u}=n,l=s.state??n.state,d=l?(0,N.compileState)(l):void 0,p=u,f=p?(0,N.compileCache)({...p,stop:p.stop??!0}):void 0,g=re(a)?Z(a,Y(e.transformers)):void 0,h=re(c)?Z(c,Y(e.transformers)):void 0,m=r.push,y=m??e.push,w=Boolean(m),v=async(n,o,r)=>{let i;const u=h??(void 0!==c?(()=>{const t=(0,N.getNextSteps)(c,(0,N.buildCacheContext)(r.ingest));return 0===t.length?[]:Z(1===t.length?t[0]:t,Y(e.transformers))})():[]);let l=[n];if(u.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const o=await oe(e,e.transformers,u,n,r.ingest,r.respond,`source.${t}.before`);if(null===o.event)return{ok:!0};if(o.stopped)return o.respond&&(r.respond=o.respond),{ok:!0};o.respond&&(r.respond=o.respond),l=Array.isArray(o.event)?o.event:[o.event]}if(f){const t=W(f,e);if(t){const n=(0,N.buildCacheContext)(r.ingest),o=await(0,N.checkCache)(f,t,n);if(o){if("HIT"===o.status&&void 0!==o.value&&f.stop){let t=o.value;return o.rule.update&&(t=await(0,N.applyUpdate)(t,o.rule.update,{...n,cache:{status:"HIT"}},e)),r.respond?.(t),{ok:!0}}if("MISS"===o.status&&f.stop&&r.respond){const s=r.respond,a=o.rule.update,c={...n,cache:{status:"MISS"}},u=o.key,l=o.rule.ttl,d=n=>{(0,N.storeCache)(t,u,n,l),a?i=(async()=>{const t=await(0,N.applyUpdate)(n,a,c,e);s(t)})():s(n)};r.respond=d}"MISS"!==o.status||f.stop||(0,N.storeCache)(t,o.key,!0,o.rule.ttl)}}}const p=g?{kind:"single",preChain:g}:void 0!==a?(()=>{const t=(0,N.getNextSteps)(a,(0,N.buildCacheContext)(r.ingest));return 0===t.length?{kind:"single",preChain:[]}:1===t.length?{kind:"single",preChain:Z(t[0],Y(e.transformers))}:{kind:"many",branches:t.map(t=>Z(t,Y(e.transformers)))}})():{kind:"single",preChain:[]};!w&&d&&d.length>0&&(l=await Promise.all(l.map(t=>(0,N.applyState)(d,t=>V(t,e),t,e))));let m={ok:!0};for(const n of l)"many"===p.kind?(await Promise.all(p.branches.map((i,a)=>(0,N.tryCatchAsync)(async()=>w?y(n):y(n,{...o,id:t,ingest:ne(r.ingest,`${t}.${a}`),respond:void 0,mapping:s,preChain:i}),t=>(e.logger.scope("source:many").error(`many branch ${a} failed`,{error:t}),{ok:!0}))())),m={ok:!0}):m=w?await y(n):await y(n,{...o,id:t,ingest:r.ingest,respond:r.respond,mapping:s,preChain:p.preChain});return i&&await i,m},b=async n=>{const o=(0,N.createIngest)(t);if(!s.ingest||void 0===n)return o;const r=await(0,N.getMappingValue)(n,s.ingest,{collector:e});return{...o,...r,_meta:o._meta}},k=e.logger.scope("source").scope(t),S={command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:k,...r,push:async(e,n={})=>{const o={ingest:(0,N.createIngest)(t),respond:void 0};return v(e,n,o)}},q={collector:e,logger:k,id:t,config:s,env:S,withScope:async(e,t,n)=>{const o={ingest:await b(e),respond:t};return n({...S,push:(e,t={})=>v(e,t,o),ingest:o.ingest,respond:o.respond})}},I=await(0,N.tryCatchAsync)(o,n=>{if(n instanceof N.FatalError)throw n;e.status.failed++,e.logger.scope("source").error("source factory failed",{sourceId:t,error:n})})(q);if(!I)return;const O=I.type||"unknown",C=e.logger.scope(O).scope(t);return S.logger=C,i&&(I.config={...I.config,primary:i}),I}async function ue(e){for(const[t,n]of Object.entries(e.sources)){if(ae(n))continue;const o=n.config.require;if(!o?.length)continue;const s=o.filter(t=>!ye(e,t));s.length!==o.length&&(n.config.require=s,ae(n)&&await ie(e,n,t))}for(const[t,n]of Object.entries(e.pending.destinations)){if(!e.pending.destinations[t]||e.destinations[t])continue;const o=n.config?.require;if(!o)continue;const s=o.filter(t=>!ye(e,t));if(n.config&&(n.config.require=s),s.length>0)continue;delete e.pending.destinations[t];const r=Ge(n);!1!==r.config.queue&&(r.queuePush=[...e.queue]),e.destinations[t]=r}}function le(e){if("object"!=typeof e||null===e)return!1;if(!("logger"in e))return!1;const t=e.logger;return"object"==typeof t&&null!==t&&"scope"in t&&"function"==typeof t.scope}var de=!1;function pe(){de||(de=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("walkerOS: ignored an on-dispatch call with a non-collector argument"))}function fe(e,t,n,o){if(n instanceof _.FatalError)throw n;e.logger.scope("on").error("on callback failed",{kind:t,...o,error:n})}var ge=[Q.Consent,Q.User,Q.Globals,Q.Custom];function he(e){return ge.includes(e)}function me(e,t){switch(t){case Q.Consent:return Object.keys(e.consent).length>0;case Q.User:return Object.keys(e.user).length>0;case Q.Globals:return Object.keys(e.globals).length>0;case Q.Custom:return Object.keys(e.custom).length>0;default:return!1}}function ye(e,t){switch(t){case Q.Consent:case Q.User:case Q.Globals:case Q.Custom:return me(e,t);case Q.Run:case Q.Ready:return!0===e.allowed;default:return e.seenEvents.has(String(t))}}function we(e,t){return e.cellVersion[String(t)]??0}function ve(e,t,n){let o=e.delivery.get(t);o||(o={},e.delivery.set(t,o)),o[String(n)]=we(e,n)}function be(e,t,n){return e.allowed&&we(e,n)>function(e,t,n){const o=e.delivery.get(t),s=o?.[String(n)];return void 0===s?-1:s}(e,t,n)}function ke(e,t,n){const o=e.cascade;if(!o)return!0;let s=o.counts.get(t);s||(s={},o.counts.set(t,s));const r=String(n),i=(s[r]||0)+1;return s[r]=i,i<=8||(9===i&&e.logger.error("state delivery did not converge",{type:r}),!1)}function Se(e,t){return{collector:e,logger:e.logger.scope("on").scope(String(t))}}function qe(e,t,n,o,s){if(!t.on)return;const r=t.type||"unknown",i=e.logger.scope(r).scope("on").scope(o),a={collector:e,logger:i,id:n,config:t.config,data:s,env:Be(t.env,t.config.env)};(0,H.tryCatch)(t.on,t=>fe(e,"destination",t,{destId:n,type:o}))(o,a)}function Ie(e,t,n,o){if(!le(e))return void pe();const s=Oe(e,t,o);if(n.length)switch(t){case Q.Consent:!function(e,t,n){const o=n||e.consent,s=Se(e,Q.Consent);t.forEach(t=>{be(e,t,Q.Consent)&&ke(e,t,Q.Consent)&&(Object.keys(o).filter(e=>e in t).forEach(n=>{(0,H.tryCatch)(t[n],t=>fe(e,"consent",t,{key:n}))(o,s)}),ve(e,t,Q.Consent))})}(e,n,o);break;case Q.Ready:!function(e,t){if(!e.allowed)return;const n=Se(e,Q.Ready);t.forEach(t=>{(0,H.tryCatch)(t,t=>fe(e,"ready",t))(void 0,n)})}(e,n);break;case Q.Run:!function(e,t){if(!e.allowed)return;const n=Se(e,Q.Run);t.forEach(t=>{(0,H.tryCatch)(t,t=>fe(e,"run",t))(void 0,n)})}(e,n);break;case Q.Session:!function(e,t){if(!e.session)return;const n=Se(e,Q.Session);t.forEach(t=>{(0,H.tryCatch)(t,t=>fe(e,"session",t))(e.session,n)})}(e,n);break;default:{const o=Se(e,t),r=he(t);n.forEach(n=>{"function"==typeof n&&(r&&!be(e,n,t)||r&&!ke(e,n,t)||((0,H.tryCatch)(n,n=>fe(e,"generic",n,{type:t}))(s,o),r&&ve(e,n,t)))});break}}}function Oe(e,t,n){switch(t){case Q.Consent:return n||e.consent;case Q.Session:return e.session;case Q.User:return n||e.user;case Q.Custom:return n||e.custom;case Q.Globals:return n||e.globals;case Q.Config:return n||e.config;default:return}}async function Ce(e,t,n,o,s){if(!t.on)return!1;if(he(o)&&!be(e,t,o))return!1;if(he(o)&&!ke(e,t,o))return!1;const r=await(0,H.tryCatchAsync)(t.on,t=>fe(e,"source",t,{sourceId:n,type:o}))(o,s);return he(o)&&ve(e,t,o),!1===r}function xe(e,t,n,o){if(!Number.isFinite(n.max)||n.max<=0)throw new Error(`pushBounded: max must be > 0 (got ${n.max})`);if("dropNewest"===(n.onOverflow??"dropOldest"))return e.length>=n.max?(o&&o([t]),{appended:!1,dropped:1}):(e.push(t),{appended:!0,dropped:0});const s=[];for(;e.length>=n.max;)s.push(e.shift());return e.push(t),s.length>0&&o&&o(s),{appended:!0,dropped:s.length}}var je=new WeakMap;function Ae(e,t,n,o){je.get(e)||(je.set(e,!0),t.warn(n,o))}function Te(e){je.delete(e)}var De=Object.freeze({batched:!0});function Ee(e){return e===De}function Me(e){return void 0===e?{}:"number"==typeof e?{wait:e}:{wait:e.wait,size:e.size,age:e.age}}function ze(e,t){return e.status.destinations[t]||(e.status.destinations[t]={count:0,failed:0,duration:0,queuePushSize:0,dlqSize:0}),e.status.destinations[t]}function Pe(e,t,n,o){e.dropped[t]||(e.dropped[t]={});const s=e.dropped[t];return s[n]=(s[n]??0)+o,s[n]}function $e(e,t,n){if(!e)return[];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return Z(e,t);if("string"==typeof e)return Z(e,t);const o=(0,$.getNextSteps)(e,(0,$.buildCacheContext)(n));return 0===o.length?[]:1===o.length?Z(o[0],t):Z(o,t)}async function _e(e,t,n={},o){const{allowed:s,consent:r,globals:i,user:a}=e;if(!s)return Re({ok:!1});if(t){const n=e.config.queueMax;if(void 0===n)throw new Error("Collector.Config.queueMax is undefined; defaults must be seeded by collector()");const o=xe(e.queue,t,{max:n});if(o.dropped>0){const t=Pe(e.status,(0,$.stepId)("collector"),"queue",o.dropped);Ae(e.queue,e.logger,"collector.queue overflow; oldest events dropped",{buffer:"queue",cap:n,droppedCount:t})}else e.queue.length<n&&Te(e.queue);e.status.in++}o||(o=e.destinations);const c=e.transformers?Y(e.transformers):{},u=await Promise.all(Object.entries(o||{}).map(async([o,s])=>{if(s.config.disabled)return{id:o,destination:s,skipped:!0};let u=(s.queuePush||[]).map(e=>({...e,consent:r}));s.queuePush=[],t&&u.push((0,$.clone)(t));const l=n.ingest?{...n.ingest,_meta:{...n.ingest._meta,path:[...n.ingest._meta.path]}}:(0,$.createIngest)("unknown");if(!u.length&&!s.queueOn?.length)return{id:o,destination:s,skipped:!0};if(!u.length&&s.queueOn?.length){let t=!1;try{t=await He(e,s,o)}catch(t){e.status.failed++;const n=s.type||"unknown";e.logger.scope(n).error("destination init failed",{error:t instanceof Error?t.message:String(t)})}return{id:o,destination:s,skipped:!t}}const d=[],p=u.filter(t=>{const n=(0,$.getGrantedConsent)(s.config.consent,r,t.consent);if(n)return t.consent=n,d.push(t),!1;const i=J(e,{stepId:(0,$.stepId)("destination",o),stepType:"destination",phase:"skip",eventId:"string"==typeof t.id?t.id:"",now:Date.now()});return i.skipReason="consent",r&&(i.consent={...r}),s.config.consent&&(i.meta={required:{...s.config.consent}}),(0,$.emitStep)(e,i),!0});if(p.length>0){const t=s.queuePush,n=s.config.id||o,r={max:s.config.queueMax??1e3};let i=0;for(const e of p)i+=xe(t,e,r).dropped;if(i>0){ze(e,n);const o=Pe(e.status,(0,$.stepId)("destination",n),"queue",i);Ae(t,e.logger.scope(s.type||"unknown"),"destination.queuePush overflow; oldest events dropped",{buffer:"queuePush",destination:n,cap:r.max,droppedCount:o})}else t.length<r.max&&Te(t)}if(!d.length)return{id:o,destination:s,queue:u};let f,g,h=!1;try{h=await He(e,s,o)}catch(t){e.status.failed++;const n=s.type||"unknown";e.logger.scope(n).error("destination init failed",{error:t instanceof Error?t.message:String(t)})}if(!h)return{id:o,destination:s,queue:u};s.dlq||(s.dlq=[]);const m=$e(s.config.before,c,l),y=s.config.next,w=s.config?.cache,v=w?(0,$.compileCache)(w):void 0,b=v?W(v,e):void 0,k=s.config?.state?(0,$.compileState)(s.config.state):void 0,S=k?.filter(e=>"get"===e.mode),q=k?.filter(e=>"set"===e.mode);let I=0,O=0;return await Promise.all(d.map(async t=>{let r;if(t.globals=(0,$.assign)(i,t.globals),t.user=(0,$.assign)(a,t.user),v?.stop&&b){const e=(0,$.buildCacheContext)(l,t),n=await(0,$.checkCache)(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}let u=t,d=n.respond;if(m.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const s=await oe(e,e.transformers,m,t,l,n.respond,`destination.${o}.before`);if(null===s.event)return t;s.respond&&(d=s.respond),u=Array.isArray(s.event)?s.event[0]:s.event}if(v&&!v.stop&&b){const e=(0,$.buildCacheContext)(l,u),n=await(0,$.checkCache)(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}S&&S.length>0&&u&&(u=await(0,$.applyState)(S,t=>V(t,e),u,e));const p=Date.now();let h=!1;const w=await(0,$.tryCatchAsync)(Ne,t=>{const n=s.type||"unknown";e.logger.scope(n).error("Push failed",{error:t,event:u.name}),f=t,h=!0;const r=s.dlq,i=s.config.id||o,a={max:s.config.dlqMax??100},c=xe(r,[u,t],a);if(c.dropped>0){ze(e,i);const t=Pe(e.status,(0,$.stepId)("destination",i),"dlq",c.dropped);Ae(r,e.logger.scope(s.type||"unknown"),"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:i,cap:a.max,droppedCount:t})}else r.length<a.max&&Te(r)})(e,s,o,u,l,d);if(I+=Date.now()-p,r&&b&&void 0===s.config.mock&&(0,$.storeCache)(b,r.key,w??!0,r.ttl),!h&&!Ee(w)&&q&&q.length>0&&u&&(u=await(0,$.applyState)(q,t=>V(t,e),u,e)),void 0===w||Ee(w)||(g=w),Ee(w)&&O++,!h&&y){void 0!==w&&(l._response=w);const t=$e(y,c,l);if(t.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const n=await oe(e,e.transformers,t,u,l,d,`destination.${o}.next`);n.respond&&(d=n.respond)}}return t})),{id:o,destination:s,error:f,response:g,totalDuration:I,batchedCount:O,allowedCount:d.length}})),l={},d={},p={};for(const t of u){if(t.skipped)continue;const n=t.destination,o={type:n.type||"unknown",data:t.response};ze(e,t.id);const s=e.status.destinations[t.id],r=Date.now();if(s.queuePushSize=n.queuePush?.length??0,s.dlqSize=n.dlq?.length??0,t.error)o.error=t.error,p[t.id]=o,s.failed++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.failed++;else if(t.queue&&t.queue.length)d[t.id]=o;else{const n=t.batchedCount??0,i=t.allowedCount??0;(Math.max(0,i-n)>0||0===i)&&(l[t.id]=o,s.count++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.out++)}}return Re({event:t,...Object.keys(l).length&&{done:l},...Object.keys(d).length&&{queued:d},...Object.keys(p).length&&{failed:p}})}async function He(e,t,n){if(t.init&&!t.config.init){const o=t.type||"unknown",s=e.logger.scope(o),r={collector:e,logger:s,id:n,config:t.config,env:Be(t.env,t.config.env)};s.debug("init");const i=Date.now();let a;(0,$.emitStep)(e,J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"init",eventId:"",now:i}));try{a=await(0,$.useHooks)(t.init,"DestinationInit",e.hooks,e.logger)(r)}catch(t){const o=Date.now(),s=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"error",eventId:"",now:o});throw s.durationMs=o-i,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},(0,$.emitStep)(e,s),t}if(!1===a)return a;if(t.config={...a||t.config,init:!0},t.queueOn?.length){const o=t.queueOn;t.queueOn=[];for(const{type:s,data:r}of o)qe(e,t,n,s,r)}s.debug("init done")}return!0}async function Ne(e,t,n,o,s,r){const{config:i}=t,a=await(0,$.processEventMapping)(o,i,e);if(a.ignore)return!1;const c=t.type||"unknown",u=e.logger.scope(c),l={collector:e,logger:u,id:n,config:i,data:a.data,rule:a.mapping,ingest:s,env:{...Be(t.env,i.env),...r?{respond:r}:{}}};if(void 0!==i.mock)return u.debug("mock",{event:a.event.name}),i.mock;const d=a.mapping,p=void 0!==d?.batch,f=p?a.mappingKey||"* *":" batch-all";if((p||void 0!==i.batch)&&t.pushBatch&&void 0===i.mock){if(t.batches=t.batches||{},!t.batches[f]){const o={key:f,entries:[],events:[],data:[]},s=Me(d?.batch),r=Me(i.batch),a=s.wait??r.wait??3e4,c=s.size??r.size??1e3,l=s.age??r.age??3e4,g=Be(t.env,i.env),h=(0,$.debounce)(async()=>{const o=t.batches[f],s=o.batched;if(0===s.entries.length)return;const r={key:s.key,entries:s.entries,events:s.events,data:s.data};s.entries=[],s.events=[],s.data=[];const a=r.entries[0],c={collector:e,logger:u,id:n,config:i,data:void 0,rule:o.isDefault?void 0:a.rule,ingest:a.ingest,env:{...g,...a.respond?{respond:a.respond}:{}}};u.debug("push batch",{events:r.entries.length});const l=t.config.id||n,d=ze(e,l),p=Date.now(),h=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"flush",eventId:"",now:p});h.batch={size:r.entries.length,index:0},(0,$.emitStep)(e,h);const m=n=>{const o=t.dlq=t.dlq||[],s={max:t.config.dlqMax??100};let r=0;for(const e of n)r+=xe(o,e,s).dropped;if(r>0){const t=Pe(e.status,(0,$.stepId)("destination",l),"dlq",r);Ae(o,u,"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:l,cap:s.max,droppedCount:t})}else o.length<s.max&&Te(o);d.failed+=n.length,d.dlqSize=o.length,e.status.failed+=n.length};let y=r.entries.length;const w=await(0,$.tryCatchAsync)((0,$.useHooks)(t.pushBatch,"DestinationPushBatch",e.hooks,e.logger),t=>{y=0;const o=Date.now(),s=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"error",eventId:"",now:o});s.durationMs=o-p,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},s.batch={size:r.entries.length,index:0},(0,$.emitStep)(e,s),m(r.entries.map(e=>[e.event,t])),u.error("Push batch failed",{error:t instanceof Error?t.message:String(t),entries:r.entries.length})})(r,c);if((0,$.isObject)(v=w)&&Array.isArray(v.failed)&&w.failed.length>0){const e=[],t=new Set;for(const n of w.failed){const o=r.entries[n.index];o&&!t.has(n.index)&&(t.add(n.index),e.push([o.event,n.error??new Error(`Push batch entry ${n.index} failed (no per-row error provided)`)]))}e.length>0&&(m(e),y=Math.max(0,r.entries.length-e.length),u.error("Push batch partial failure",{failed:e.length,delivered:y,entries:r.entries.length}))}var v;u.debug("push batch done"),d.inFlightBatch=Math.max(0,(d.inFlightBatch??0)-r.entries.length),y>0&&(d.count+=y,d.lastAt=Date.now(),e.status.out+=y)},{wait:a,size:c,age:l});t.batches[f]={batched:o,isDefault:!p,batchFn:()=>{h()},flush:async()=>{await h.flush()}}}const o=t.batches[f];o.batched.entries.push({event:a.event,ingest:s,respond:r,rule:d,data:a.data}),o.batched.events.push(a.event),(0,$.isDefined)(a.data)&&o.batched.data.push(a.data);const c=t.config.id||n,l=ze(e,c);return l.inFlightBatch=(l.inFlightBatch??0)+1,o.batchFn(),De}{u.debug("push",{event:a.event.name});const o="string"==typeof a.event.id?a.event.id:"",s=Date.now(),r=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"in",eventId:o,now:s});a.mappingKey&&(r.mappingKey=a.mappingKey),a.event.consent&&(r.consent={...a.event.consent}),(0,$.emitStep)(e,r);try{const r=await(0,$.useHooks)(t.push,"DestinationPush",e.hooks,e.logger)(a.event,l),i=Date.now(),c=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"out",eventId:o,now:i});return c.durationMs=i-s,c.outEvent=r,a.mappingKey&&(c.mappingKey=a.mappingKey),(0,$.emitStep)(e,c),u.debug("push done"),r}catch(t){const r=Date.now(),i=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"error",eventId:o,now:r});throw i.durationMs=r-s,i.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},a.mappingKey&&(i.mappingKey=a.mappingKey),(0,$.emitStep)(e,i),t}}}function Re(e){return{ok:!e?.failed,...e}}function Ge(e){const{code:t,config:n={},env:o={},cache:s,state:r}=e,{config:i}=X(e,"before"),{config:a}=X({...e,config:i},"next"),c={...t.config,...n,...a};s&&(c.cache=s),void 0!==r&&void 0===c.state&&(c.state=r);const u=Be(t.env,o);return{...t,config:c,env:u}}function Be(e,t){return e||t?t?e&&(0,$.isObject)(e)&&(0,$.isObject)(t)?{...e,...t}:t:e:{}}async function Fe(e,t,n){const o=Object.entries(e).map(async([e,o])=>{const s=o.destroy;if(!s)return;const r=o.type||"unknown",i=n.scope(r),a={id:e,config:o.config,env:o.env??{},logger:i};let c;try{await Promise.race([s(a),new Promise((n,o)=>{c=setTimeout(()=>o(new Error(`${t} '${e}' destroy timed out`)),5e3)})])}catch(n){i.error(`${t} '${e}' destroy failed: ${n}`)}finally{c&&clearTimeout(c)}});await Promise.allSettled(o)}function Le(e,t){e.stateVersion++,e.cellVersion[t]=e.stateVersion}async function Ue(e,t,n){let o,s,r=!1;const i=function(e){return e.cascade?()=>{}:(e.cascade={counts:new WeakMap},()=>{e.cascade=void 0})}(e);try{return await async function(){switch(t){case Q.Config:(0,B.isObject)(n)&&((0,G.assign)(e.config,n,{shallow:!1}),s=n,r=!0);break;case Q.Consent:if((0,B.isObject)(n)){const{update:t}=function(e,t){const n={};return Object.entries(t).forEach(([e,t])=>{n[e]=!!t}),e.consent=(0,z.assign)(e.consent,n),{update:n}}(e,n);Le(e,Q.Consent),s=t,r=!0}break;case Q.Custom:(0,B.isObject)(n)&&(e.custom=(0,G.assign)(e.custom,n),Le(e,Q.Custom),s=n,r=!0);break;case Q.Destination:(0,B.isObject)(n)&&"code"in n&&(0,B.isObject)(n.code)&&(o=await async function(e,t){const{code:n,config:o={},env:s={},before:r,next:i,cache:a,state:c}=t;if(!(0,$.isFunction)(n.push))return Re({ok:!1,failed:{invalid:{type:"invalid",error:"Destination code must have a push method"}}});const u=o||{init:!1};let l=r?{...u,before:r}:{...u};i&&(l={...l,next:i}),a&&(l={...l,cache:a}),void 0!==c&&void 0===l.state&&(l={...l,state:c});let d=l.id;if(!d)do{d=(0,$.getId)(5,"abcdefghijklmnopqrstuvwxyz")}while(e.destinations[d]||e.pending.destinations[d]);if(l.require?.length){e.pending.destinations[d]=t,await ue(e);const n=e.destinations[d];return n?_e(e,void 0,{},{[d]:n}):Re({ok:!0})}const p={...n,config:l,env:Be(n.env,s)};return e.destinations[d]=p,!1!==p.config.queue&&(p.queuePush=[...e.queue]),_e(e,void 0,{},{[d]:p})}(e,n));break;case Q.Globals:(0,B.isObject)(n)&&(e.globals=(0,G.assign)(e.globals,n),Le(e,Q.Globals),s=n,r=!0);break;case Q.Hook:if((0,B.isObject)(n)&&(0,G.isString)(n.name)&&(0,G.isFunction)(n.fn)){const{name:t,fn:o}=n;e.hooks[t]=o,s=n,r=!0}break;case Q.On:if((0,B.isObject)(n)&&(0,G.isString)(n.type)){const{type:t,rules:o}=n;await async function(e,t,n){if(!le(e))return void pe();const o=e.on,s=o[t]||[],r=(0,_.isArray)(n)?n:[n];r.forEach(e=>{s.push(e)}),o[t]=s,Ie(e,t,r)}(e,t,o)}break;case Q.Ready:r=!0;break;case Q.Run:o=await async function(e,t){return e.allowed=!0,e.timing=Date.now(),t&&(t.consent&&(e.consent=(0,G.assign)(e.consent,t.consent),Le(e,Q.Consent)),t.user&&(e.user=(0,G.assign)(e.user,t.user),Le(e,Q.User)),t.globals&&(e.globals=(0,G.assign)(e.config.globalsStatic||{},t.globals),Le(e,Q.Globals)),t.custom&&(e.custom=(0,G.assign)(e.custom,t.custom),Le(e,Q.Custom))),Object.values(e.destinations).forEach(e=>{e.queuePush=[]}),e.queue=[],e.round++,await ue(e),await async function(e){if(le(e))for(const t of ge){if(!me(e,t))continue;const n=Oe(e,t);Ie(e,t,e.on[t]||[]);for(const[o,s]of Object.entries(e.sources))ae(s)&&await Ce(e,s,o,t,n)}else pe()}(e),await _e(e)}(e,n),r=!0;break;case Q.Session:r=!0;break;case Q.Shutdown:e.hasShutdown||(e.hasShutdown=!0,await async function(e){const t=e.logger;await Fe(e.sources,"source",t),await async function(e,t){const n=Object.entries(e).flatMap(([e,n])=>{const o=n.batches;if(!o)return[];const s=t.scope(n.type||"destination");return Object.values(o).map(async t=>{let n;try{await Promise.race([t.flush(),new Promise((t,o)=>{n=setTimeout(()=>o(new Error(`destination '${e}' batch flush timed out`)),5e3)})])}catch(t){s.error(`destination '${e}' batch flush failed: ${t}`)}finally{n&&clearTimeout(n)}})});await Promise.allSettled(n)}(e.destinations,t),await Fe(e.destinations,"destination",t),await Fe(e.transformers,"transformer",t),await Fe(e.stores,"store",t)}(e));break;case Q.User:(0,B.isObject)(n)&&((0,G.assign)(e.user,n,{shallow:!1}),Le(e,Q.User),s=n,r=!0)}return r&&(await async function(e,t,n,o){if(!le(e))return pe(),!0;e.seenEvents.add(String(t));let s=n||[];n||(s=e.on[t]||[]);const r=Oe(e,t,o);let i=!1;for(const[n,o]of Object.entries(e.sources)){if(o.config.require?.length){const e=o.config.require.indexOf(t);-1!==e&&o.config.require.splice(e,1)}o.on&&(ae(o)?await Ce(e,o,n,t,r)&&(i=!0):(o.queueOn=o.queueOn||[],o.queueOn.push({type:t,data:r})))}Object.entries(e.destinations).forEach(([n,o])=>{if(o.on){if(!o.config.init)return o.queueOn=o.queueOn||[],void o.queueOn.push({type:t,data:r});qe(e,o,n,t,r)}});for(const[t,n]of Object.entries(e.sources))ae(n)&&n.queueOn?.length&&await ie(e,n,t);const a=Object.values(e.sources).some(e=>!ae(e)&&e.config.require?.length);return(Object.keys(e.pending.destinations).length>0||a)&&await ue(e),Ie(e,t,s,o),!i}(e,t,void 0,s),o=await _e(e)),o||Re({ok:!0})}()}finally{i()}}function Ke(e,t){return{timing:Math.round((Date.now()-e.timing)/10)/100,source:{type:"collector",schema:"4",version:"4.2.0"},...t}}function Qe(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");const{timestamp:s=Date.now(),name:r=`${n} ${o}`,data:i={},context:a={},globals:c=e.globals,custom:u={},user:l=e.user,nested:d=[],consent:p=e.consent,id:f=(0,G.getSpanId)(),trigger:g="",entity:h=n,action:m=o,timing:y=0,source:w={type:"collector",schema:"4"}}=t;return{name:r,data:i,context:a,globals:c,custom:u,user:l,nested:d,consent:p,id:f,trigger:g,entity:h,action:m,timestamp:s,timing:y,source:w}}function Je(e,t){const n=(0,F.useHooks)(async(n,o={})=>await(0,F.tryCatchAsync)(async()=>{const s=Date.now(),{id:r,ingest:i,respond:a,mapping:c,preChain:u,include:l,exclude:d}=o;let p=a,f=n;const g=l||d?function(e,t,n){let o=e;return t&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>t.includes(e)))),n&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>!n.includes(e)))),o}(e.destinations,l,d):void 0,h=i??(0,F.createIngest)(r||"unknown");if(c){const t=await(0,F.processEventMapping)(f,c,e);if(t.ignore)return Re({ok:!0});if(c.consent&&!(0,F.getGrantedConsent)(c.consent,e.consent,t.event.consent))return Re({ok:!0});f=t.event}if(u?.length&&e.transformers&&Object.keys(e.transformers).length>0){const n=await oe(e,e.transformers,u,f,h,p,r?`source.${r}.next`:void 0);if(null===n.event)return Re({ok:!0});if(n.stopped)return n.respond&&(p=n.respond),Re({ok:!0});if(n.respond&&(p=n.respond),Array.isArray(n.event)){const o=await Promise.all(n.event.map(async n=>{const o=t(n),s=Qe(e,o);return _e(e,s,{id:r,ingest:h,respond:p},g)}));if(r){e.status.sources[r]||(e.status.sources[r]={count:0,duration:0});const t=e.status.sources[r];t.count+=n.event.length,t.lastAt=Date.now(),t.duration+=Date.now()-s}return o[0]??Re({ok:!0})}f=n.event}const m=function(e,t){return Qe(e,Ke(e,t))}(e,f),y=await _e(e,m,{id:r,ingest:h,respond:p},g);if(r){e.status.sources[r]||(e.status.sources[r]={count:0,duration:0});const t=e.status.sources[r];t.count++,t.lastAt=Date.now(),t.duration+=Date.now()-s}return y},t=>{if(t instanceof F.FatalError)throw t;return e.status.failed++,e.logger.error("push failed",{event:n,ingest:o.ingest,error:t}),Re({ok:!1})})(),"Push",e.hooks,e.logger);return async(t,o)=>{const s="string"==typeof t.id?t.id:"",r=Date.now();(0,F.emitStep)(e,J(e,{stepId:"collector.push",stepType:"collector",phase:"in",eventId:s,now:r}));try{const i=await n(t,o),a=Date.now(),c=J(e,{stepId:"collector.push",stepType:"collector",phase:"out",eventId:s,now:a});return c.durationMs=a-r,c.outEvent=i,(0,F.emitStep)(e,c),i}catch(t){const n=Date.now(),o=J(e,{stepId:"collector.push",stepType:"collector",phase:"error",eventId:s,now:n});throw o.durationMs=n-r,o.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},(0,F.emitStep)(e,o),t}}}function We(e={}){const t=e.maxEntries??1e4,n=e.lowWaterMark??.8,o=e.sweepIntervalMs??6e4,s=Math.floor(t*n),r=new Map,i={hits:0,misses:0,populates:0,writes:0,deletes:0,evictions_entries:0,evictions_ttl:0};let a;return o>0&&(a=setInterval(function(){const e=Date.now();let t=0;for(const[n,o]of r)void 0!==o.expires&&o.expires<=e&&(r.delete(n),t++);i.evictions_ttl+=t},o),a&&"function"==typeof a.unref&&a.unref()),{type:"memory",config:{},get(e){const t=r.get(e);if(t)return void 0!==t.expires&&t.expires<=Date.now()?(r.delete(e),i.evictions_ttl++,void i.misses++):(r.delete(e),r.set(e,t),i.hits++,t.value);i.misses++},set(e,n,o){const a=!r.has(e);a||r.delete(e),r.set(e,{value:n,expires:void 0!==o?Date.now()+o:void 0}),i.writes++,a&&i.populates++,r.size>t&&function(){if(r.size<=t)return;const e=r.size-s;let n=0;for(const t of r.keys()){if(n>=e)break;r.delete(t),n++}i.evictions_entries+=n}()},delete(e){r.delete(e)&&i.deletes++},get counters(){return{...i}},destroy(){void 0!==a&&(clearInterval(a),a=void 0),r.clear()}}}function Ve(e,t){const{cacheConfig:n,cacheStore:o,namespace:s,logger:r,storeId:i,collector:a}=t,c=(e,t)=>{if(!a)return;const n=J(a,{stepId:`store.${i}`,stepType:"store",phase:"in",eventId:"",now:Date.now()});n.meta={op:"cache",cached:"hit"===t,status:t,key:e},(0,K.emitStep)(a,n)},u={hits:0,misses:0,populates:0,writes:0,deletes:0,inflight_dedups:0},l=n.rules.map(e=>({match:e.match?(0,K.compileMatcher)(e.match):()=>!0,ttl:e.ttl})),d=e=>`${s}:${e}`;function p(e,t){const n=void 0===t?{key:e}:{key:e,value:t};return l.find(e=>e.match(n))}const f=new Map;return{type:e.type,config:e.config,setup:e.setup,get counters(){return{...u}},async get(t){const n=d(t),s=await o.get(n),r=(0,K.readCacheEnvelope)(s);if(void 0!==r){if(!("expired"in r))return u.hits++,c(t,"hit"),r.value;try{await o.delete(n)}catch(e){g("delete",t,e)}}const i=f.get(n);if(i)return u.inflight_dedups++,c(t,"hit"),i;u.misses++,c(t,"miss");const a=(async()=>{try{const s=await e.get(t);if(void 0===s)return;const r=p(t,s);if(r)try{const e=1e3*r.ttl;await o.set(n,(0,K.wrapCacheEnvelope)(s,e),e),u.populates++}catch(e){g("set",t,e)}return s}finally{f.delete(n)}})();return f.set(n,a),a},async set(t,n,s){u.writes++,await e.set(t,n,s);const r=p(t,n);if(r)try{const e=1e3*r.ttl;await o.set(d(t),(0,K.wrapCacheEnvelope)(n,e),e)}catch(e){g("set",t,e)}},async delete(t){u.deletes++,await e.delete(t);try{await o.delete(d(t))}catch(e){g("delete",t,e)}}};function g(e,t,n){const o=`store-cache(${i}): cache ${e} failed for "${t}"; backing succeeded, continuing`;r?r.warn(o,{error:n}):console.warn(o,n)}}function Ye(e,t,n){const o=`store.${n}`,s=(0,U.useHooks)(t.get,"StoreGet",e.hooks,e.logger),r=(0,U.useHooks)(t.set,"StoreSet",e.hooks,e.logger),i=(0,U.useHooks)(t.delete,"StoreDelete",e.hooks,e.logger);t.get=async t=>{const n=Date.now(),r=J(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});r.meta={op:"get",key:t},(0,U.emitStep)(e,r);try{const r=await s(t),i=Date.now(),a=J(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:i});return a.durationMs=i-n,a.meta={op:"get",key:t},(0,U.emitStep)(e,a),r}catch(s){const r=Date.now(),i=J(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw i.durationMs=r-n,i.meta={op:"get",key:t},i.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},(0,U.emitStep)(e,i),s}},t.set=async(t,n,s)=>{const i=Date.now(),a=J(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:i});a.meta={op:"set",key:t},(0,U.emitStep)(e,a);try{await r(t,n,s);const a=Date.now(),c=J(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:a});c.durationMs=a-i,c.meta={op:"set",key:t},(0,U.emitStep)(e,c)}catch(n){const s=Date.now(),r=J(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:s});throw r.durationMs=s-i,r.meta={op:"set",key:t},r.error=n instanceof Error?{name:n.name,message:n.message}:{message:String(n)},(0,U.emitStep)(e,r),n}},t.delete=async t=>{const n=Date.now(),s=J(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});s.meta={op:"delete",key:t},(0,U.emitStep)(e,s);try{await i(t);const s=Date.now(),r=J(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:s});r.durationMs=s-n,r.meta={op:"delete",key:t},(0,U.emitStep)(e,r)}catch(s){const r=Date.now(),i=J(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw i.durationMs=r-n,i.meta={op:"delete",key:t},i.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},(0,U.emitStep)(e,i),s}}}async function Xe(e){const t=(0,P.assign)({globalsStatic:{},sessionStatic:{},run:!0,queueMax:1e3},e,{merge:!1,extend:!1}),n={level:e.logger?.level,handler:e.logger?.handler},o=(0,P.createLogger)(n),s={...t.globalsStatic,...e.globals},r={allowed:!1,config:t,consent:e.consent||{},custom:e.custom||{},destinations:{},transformers:{},stores:{},globals:s,hooks:e.hooks||{},observers:new Set,logger:o,on:{},queue:[],round:0,stateVersion:0,cellVersion:{},delivery:new WeakMap,session:void 0,status:{startedAt:Date.now(),in:0,out:0,failed:0,sources:{},destinations:{},dropped:{}},timing:Date.now(),user:e.user||{},sources:{},pending:{destinations:{}},hasShutdown:!1,seenEvents:new Set,push:void 0,command:void 0};var i,a;r.push=Je(r,e=>Ke(r,e)),r.command=(i=r,a=Ue,(0,L.useHooks)(async(e,t,n)=>await(0,L.tryCatchAsync)(async()=>await a(i,e,t,n),n=>{if(n instanceof L.FatalError)throw n;return i.status.failed++,i.logger.error("command failed",{command:e,data:t,error:n}),Re({ok:!1})})(),"Command",i.hooks,i.logger));const c=e.stores||{};return r.stores=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const{code:t,config:r={},env:i={}}=s,a=e.logger.scope("store").scope(o),c={collector:e,logger:a,id:o,config:r,env:i},u=await t(c);n[o]=u}const o=t,s=function(e){const t={};for(const n of Object.keys(e))t[n]="WHITE";const n=[],o=[];function s(r){const i=t[r];if("BLACK"===i)return;if("GRAY"===i){const e=o.indexOf(r),t=o.slice(-1===e?0:e).concat(r).join(" -> ");throw new Error(`Cycle in cache.store chain: ${t}`)}t[r]="GRAY",o.push(r);const a=e[r].cache?.store;if(void 0!==a){if(!(a in e))throw new Error(`Store "${r}" cache.store references "${a}", which is not declared in flow.stores`);s(a)}o.pop(),t[r]="BLACK",n.push(r)}for(const n of Object.keys(e))"WHITE"===t[n]&&s(n);return n}(o);for(const t of s){const s=o[t].cache;if(!s)continue;let r,i;void 0!==s.store?(r=n[s.store],i=s.store):(n.__cache||(n.__cache=We()),r=n.__cache,i="__cache");const a=s.namespace??t;e.logger.scope("store-cache").scope(t).info(`store "${t}" caches with namespace "${a}:" via ${i}`),n[t]=Ve(n[t],{storeId:t,cacheConfig:s,cacheStore:r,namespace:a,logger:e.logger.scope("store-cache").scope(t),collector:e})}for(const[t,o]of Object.entries(n))"__cache"!==t&&Ye(e,o,t);return n}(r,c),function(e,t,n){const o=new Map;for(const[n,s]of Object.entries(e))t[n]&&o.set(s,t[n]);if(0!==o.size)for(const e of[n.transformers,n.destinations,n.sources])if(e)for(const t of Object.values(e))s(t.env);function s(e){if(e)for(const[t,n]of Object.entries(e))if("object"==typeof n&&null!==n){const s=o.get(n);s&&(e[t]=s)}}}(c,r.stores,e),r.stores.__cache||(r.stores.__cache=We()),r.destinations=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t))s.config?.require?.length?e.pending.destinations[o]=s:n[o]=Ge(s);return n}(r,e.destinations||{}),r.transformers=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const{code:t,env:r={}}=s,i=(0,R.validateStepEntry)(s,"Transformer");if(!i.ok){e.logger.warn(`Transformer ${o} invalid (${i.code}): ${i.reason}. Skipping.`);continue}const{config:a}=X(s,"before"),{config:c}=X({...s,config:a},"next"),u=Object.keys(r).length>0?{...c,env:r}:c,{cache:l}=s,d=l?{...u,cache:l}:u,p=s.config?.state??s.state,f=void 0!==p&&void 0===d.state?{...d,state:p}:d,g=e.logger.scope("transformer").scope(o),h={collector:e,logger:g,id:o,ingest:(0,R.createIngest)(o),config:f,env:r},m=t??(e=>{const t=s.mapping;if(t){const n=[];if(void 0!==t.data&&n.push("data"),t.mapping)for(const[e,o]of Object.entries(t.mapping))if("object"==typeof o&&null!==o)for(const[t,s]of Object.entries(o)){if("object"!=typeof s||null===s)continue;const o=s;void 0!==o.data&&n.push(`mapping[${e}][${t}].data`),void 0!==o.silent&&n.push(`mapping[${e}][${t}].silent`)}return n.length>0&&e.collector.logger.warn(`Transformer ${o}: \`${n.join(", ")}\` ignored at transformer position (only event-mutating fields apply).`),{type:"pass",config:e.config,push:async n=>{const o=await(0,R.processEventMapping)(n,t,e.collector);return!o.ignore&&{event:o.event}}}}return{type:"pass",config:e.config,push:e=>({event:e})}}),y=await m(h);void 0!==s.before&&void 0===y.config?.before&&(y.config={...y.config??{},before:s.before}),void 0!==s.next&&void 0===y.config?.next&&(y.config={...y.config??{},next:s.next}),void 0!==p&&void 0===y.config?.state&&(y.config={...y.config??{},state:p}),n[o]=y}return n}(r,e.transformers||{}),r}async function Ze(e){e=e||{};const t=await Xe(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,s,r)=>{if("string"==typeof e&&e.startsWith("walker ")){const n=e.replace("walker ","");return o.command(n,t)}let i;if("string"==typeof e)i={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(i.data=t);else{if(!e||"object"!=typeof e)return Re({ok:!1});i=e,t&&"object"==typeof t&&!Array.isArray(t)&&(i.data={...i.data||{},...t})}return n&&"object"==typeof n&&(i.context=n),s&&Array.isArray(s)&&(i.nested=s),r&&"object"==typeof r&&(i.custom=r),o.push(i)}});var o;t.sources.elb=n,await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const t=await ce(e,o,s);if(!t)continue;const r=s.config?.require;t.config={...t.config,init:!1,...r?{require:[...r]}:{}},n[o]=t}Object.assign(e.sources,n);for(const t of Object.keys(n)){const n=e.sources[t];let o=!1;n.init&&await(0,N.tryCatchAsync)(n.init.bind(n),n=>{if(n instanceof N.FatalError)throw n;o=!0,e.status.failed++,e.logger.scope("source").error("source init failed",{sourceId:t,error:n})})(),o||(n.config.init=!0,ae(n)&&await ie(e,n,t))}return await ue(e),n}(t,e.sources||{});const{consent:s,user:r,globals:i,custom:a}=e;s&&await t.command("consent",s),r&&await t.command("user",r),i&&await t.command("globals",i),a&&await t.command("custom",a),t.config.run&&await t.command("run");let c=n.push;const u=Object.values(t.sources).filter(e=>"elb"!==e.type),l=u.find(e=>e.config.primary);return l?c=l.push:u.length>0&&(c=u[0].push),{collector:t,elb:c}}var et=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await Ze(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources||{}))if("lambda"===t.type)return t}(t.collector);if(!o)throw new Error("Lambda source not found in collector");const s={awsRequestId:`test-${Date.now()}`},r=o.push,i=await r(n,s);let a;try{a=JSON.parse(i.body||"{}")}catch{a=i.body}const c={};if(i.headers)for(const[e,t]of Object.entries(i.headers))void 0!==t&&(c[e]=String(t));return{statusCode:i.statusCode,body:a,headers:c}}}};function tt(e){return async t=>{const n={...t};if(n.body&&"string"==typeof n.body){const e=JSON.parse(n.body);e.name&&!e.event&&(n.body=JSON.stringify({...e,event:e.name,name:void 0}))}return e.push(n,{awsRequestId:"test-req"})}}var nt={};r(nt,{createTrigger:()=>ht,env:()=>ot,step:()=>ut});var ot={};r(ot,{push:()=>at,simulation:()=>ct});var st=()=>{},rt={error:st,warn:st,info:st,debug:st,throw:e=>{throw"string"==typeof e?new Error(e):e},json:st,scope:()=>rt},it=()=>()=>Promise.resolve({ok:!0}),at={get push(){return it()},get command(){return it()},get elb(){return it()},logger:rt},ct=["AWS.SQSClient"],ut={};r(ut,{decoderText:()=>pt,malformedJson:()=>ft,orderComplete:()=>dt,pageView:()=>lt});var lt={title:"Page view from SQS",description:"A standard SQS message body containing a walker elb event payload as JSON.",in:{MessageId:"m-1",Body:JSON.stringify({event:"page view",data:{title:"Documentation",url:"https://example.com/docs"}})},out:[["message.ack","m-1"]]},dt={title:"Order complete from SQS",description:"Order complete event flowing through the long-poll loop.",in:{MessageId:"m-2",Body:JSON.stringify({event:"order complete",data:{id:"ORD-500",total:199.99,currency:"EUR"}})},out:[["message.ack","m-2"]]},pt={title:"Text decoder",description:'When decoder is "text", the body string flows under data.payload.',in:{MessageId:"m-3",Body:"raw text payload"},out:[["message.ack","m-3"]]},ft={title:"Malformed JSON nacks",description:"Default decoder is JSON. A malformed body throws DecoderError; the source nacks (skips DeleteMessage) so the message redelivers.",in:{MessageId:"m-4",Body:"{not json"},out:[["message.nack","m-4"]]};function gt(e){if("object"!=typeof e||null===e)return!1;const t=e;return"sqs"===t.type&&"function"==typeof t.push}var ht=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await Ze(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources??{}))if(gt(t))return t}(t.collector);if(!o)throw new Error("sqs source not registered in collector, ensure it is configured in sources");const s={MessageId:n.MessageId,Body:n.Body,ReceiptHandle:n.ReceiptHandle,Attributes:n.Attributes,MessageAttributes:n.MessageAttributes},r=await o.push(s),i=[];return r&&"object"==typeof r&&(r.acked&&i.push(["message.ack",n.MessageId]),r.nacked&&i.push(["message.nack",n.MessageId])),i}}};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,r=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},i={};r(i,{examples:()=>I,schemas:()=>a,sqsExamples:()=>nt}),module.exports=(e=i,((e,r,i,a)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let c of o(r))s.call(e,c)||c===i||t(e,c,{get:()=>r[c],enumerable:!(a=n(r,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};r(a,{CorsOptionsSchema:()=>f,CorsOrigin:()=>p,HttpMethod:()=>d,SettingsSchema:()=>g,settings:()=>h,sqsSettings:()=>S,sqsSetup:()=>q});var c=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),d=l.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),p=l.z.union([l.z.string(),l.z.array(l.z.string()),l.z.literal("*")]),f=l.z.object({origin:p.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:l.z.array(d).describe("Allowed HTTP methods").optional(),headers:l.z.array(l.z.string()).describe("Allowed request headers").optional(),credentials:l.z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:l.z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),g=u.z.object({cors:u.z.union([u.z.boolean(),f]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").default(!0),timeout:u.z.number().int().positive().max(9e5).describe("Request timeout in milliseconds (max: 900000 for Lambda)").default(3e4),enablePixelTracking:u.z.boolean().describe("Enable GET requests with 1x1 transparent GIF response for pixel tracking").default(!0),healthPath:u.z.string().describe("Health check endpoint path (e.g., /health)").default("/health")}),h=(0,c.zodToSchema)(g),m=require("@walkeros/core/dev"),y=require("@walkeros/core/dev"),w=y.z.object({queueName:y.z.string().min(1).describe("SQS queue short name (like walkeros-events). Required for both setup and runtime poll."),region:y.z.string().describe("AWS region (like eu-central-1). Default: eu-central-1.").optional(),queueUrl:y.z.string().url().describe("Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.").optional(),client:y.z.any().describe("Pre-configured AWS SQSClient instance. Bypasses construction when supplied.").optional(),config:y.z.any().describe("AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).").optional(),decoder:y.z.enum(["json","text","raw"]).describe("Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.").optional(),maxMessages:y.z.number().int().min(1).max(10).describe("SQS receive batch size. Cap 10. Default: 10.").optional(),waitTimeSeconds:y.z.number().int().min(0).max(20).describe("Long-poll duration in seconds. Cap 20. Default: 20.").optional(),visibilityTimeout:y.z.number().int().nonnegative().describe("Per-receive visibility timeout override. Default: queue-configured value.").optional(),shutdownTimeoutMs:y.z.number().int().positive().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.").optional(),onPushError:y.z.enum(["nack","ack"]).describe("Behavior when forwarding to the collector throws. nack (default) skips DeleteMessage so the message redelivers; ack drops it.").optional()}),v=require("@walkeros/core/dev"),b=v.z.record(v.z.string(),v.z.string()),k=v.z.object({region:v.z.string().min(1).describe("AWS region.").optional(),fifoQueue:v.z.boolean().describe("FIFO queue with content-based deduplication. Auto-appends .fifo suffix to the queue name.").optional(),visibilityTimeoutSeconds:v.z.number().int().nonnegative().describe("Visibility timeout in seconds. Default: 30.").optional(),messageRetentionSeconds:v.z.number().int().positive().describe("Message retention period in seconds. Default: 345600 (4 days).").optional(),maximumMessageSize:v.z.number().int().min(1024).max(262144).describe("Max message size in bytes. Default: 262144 (256 KB).").optional(),kmsMasterKeyId:v.z.string().describe("KMS key alias or ID for at-rest encryption.").optional(),deadLetterQueue:v.z.object({arn:v.z.string().describe("ARN of an existing DLQ. Mutually exclusive with create: true.").optional(),create:v.z.boolean().describe("Create a sibling DLQ named <queueName>-dlq. Default: false.").optional(),maxReceiveCount:v.z.number().int().min(1).max(1e3).describe("Max receive count before message goes to DLQ. Default: 5.").optional()}).describe("Optional dead-letter queue.").optional(),tags:b.describe("Tags applied to the queue (and inherited by an auto-created DLQ).").optional(),subscribeToSnsTopic:v.z.object({topicArn:v.z.string().min(1).describe("Topic ARN to subscribe to."),rawMessageDelivery:v.z.boolean().describe("Deliver SNS messages without the SNS envelope.").optional(),filterPolicy:v.z.record(v.z.string(),v.z.unknown()).describe("SNS filter policy applied at subscription level.").optional()}).describe("Optional SNS topic subscription. Creates the subscription and the matching queue policy.").optional()}),S=(0,m.zodToSchema)(w),q=(0,m.zodToSchema)(k),I={};r(I,{createTrigger:()=>et,env:()=>O,step:()=>T,trigger:()=>tt});var O={};r(O,{push:()=>A});var C=()=>()=>Promise.resolve({ok:!0}),x=()=>{},j={error:x,warn:x,info:x,debug:x,throw:e=>{throw"string"==typeof e?new Error(e):e},json:x,scope:()=>j},A={get push(){return C()},get command(){return C()},get elb(){return C()},logger:j},T={};r(T,{apiGatewayV1Post:()=>E,lambdaGet:()=>M,lambdaPost:()=>D});var D={title:"Lambda POST",description:"An API Gateway v2 HTTP POST with a JSON body is converted into a walker elb event.",trigger:{type:"POST"},in:{version:"2.0",requestContext:{http:{method:"POST",path:"/collect"},requestId:"req-123"},body:JSON.stringify({event:"page view",data:{title:"Home"}}),isBase64Encoded:!1},out:[["elb",{name:"page view",data:{title:"Home"}}]]},E={title:"API Gateway v1 POST",description:"A REST API Gateway v1 POST request with a JSON body is converted into a walker elb event.",trigger:{type:"POST"},in:{httpMethod:"POST",path:"/collect",requestContext:{requestId:"req-789",identity:{sourceIp:"203.0.113.42"}},queryStringParameters:null,body:JSON.stringify({event:"page view",data:{title:"Home"}}),isBase64Encoded:!1},out:[["elb",{name:"page view",data:{title:"Home"}}]]},M={title:"Lambda GET",description:"An API Gateway v2 HTTP GET with query parameters is parsed into an elb event payload.",trigger:{type:"GET"},in:{version:"2.0",requestContext:{http:{method:"GET",path:"/collect"},requestId:"req-456"},rawQueryString:"e=page+view&d=%7B%22title%22%3A%22Home%22%7D",isBase64Encoded:!1},out:[["elb",{e:"page view",d:'{"title":"Home"}'}]]},z=require("@walkeros/core"),P=require("@walkeros/core"),$=require("@walkeros/core"),_=(require("@walkeros/core"),require("@walkeros/core")),H=require("@walkeros/core"),N=require("@walkeros/core"),R=require("@walkeros/core"),G=require("@walkeros/core"),B=require("@walkeros/core"),F=require("@walkeros/core"),L=require("@walkeros/core"),U=require("@walkeros/core"),K=require("@walkeros/core"),Q={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Scoped:"_",Session:"session",Shutdown:"shutdown",User:"user",Walker:"walker"};function J(e,t){const n=e.status.startedAt;return{flowId:"default",stepId:t.stepId,stepType:t.stepType,phase:t.phase,eventId:t.eventId,timestamp:new Date(t.now).toISOString(),elapsedMs:t.now-n}}function W(e,t){return e.storeId&&t.stores[e.storeId]?t.stores[e.storeId]:t.stores.__cache}function V(e,t){return e?t.stores[e]:t.stores.__cache}function Y(e){const t={};for(const[n,o]of Object.entries(e)){const e=o.config?.next;"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?t[n]={next:e}:t[n]={}}return t}function X(e,t){const n=e.config||{},o=e[t];return void 0!==o?{config:{...n,[t]:o},chainValue:o}:{config:n,chainValue:void 0}}function Z(e,t={}){if(!e)return[];if(Array.isArray(e))return e;const n=[],o=new Set;let s=e;for(;s&&t[s]&&!o.has(s);){o.add(s),n.push(s);const e=t[s].next;if(Array.isArray(e)){n.push(...e);break}s=e}return n}async function ee(e,t,n){if(t.init&&!t.config.init){const o=t.type||"unknown",s=e.logger.scope(`transformer:${o}`),r={collector:e,logger:s,id:n,ingest:(0,R.createIngest)(n),config:t.config,env:se(t.config.env)};s.debug("init");const i=await(0,R.useHooks)(t.init,"TransformerInit",e.hooks,e.logger)(r);if(!1===i)return!1;t.config={...i||t.config,env:i?.env||t.config.env,init:!0},s.debug("init done")}return!0}async function te(e,t,n,o,s,r){const i=t.type||"unknown",a=e.logger.scope(`transformer:${i}`),c={collector:e,logger:a,id:n,ingest:s,config:t.config,env:{...se(t.config.env),...r?{respond:r}:{}}};a.debug("push",{event:o.name});const u="string"==typeof o.id?o.id:"",l=Date.now(),d=J(e,{stepId:(0,R.stepId)("transformer",n),stepType:"transformer",phase:"in",eventId:u,now:l});(0,R.emitStep)(e,d);try{const s=await(0,R.useHooks)(t.push,"TransformerPush",e.hooks,e.logger)(o,c),r=Date.now(),i=J(e,{stepId:(0,R.stepId)("transformer",n),stepType:"transformer",phase:"out",eventId:u,now:r});return i.durationMs=r-l,i.outEvent=s,(0,R.emitStep)(e,i),a.debug("push done"),s}catch(t){const o=Date.now(),s=J(e,{stepId:(0,R.stepId)("transformer",n),stepType:"transformer",phase:"error",eventId:u,now:o});throw s.durationMs=o-l,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},(0,R.emitStep)(e,s),t}}function ne(e,t){return e?{...e,_meta:{...e._meta,path:[...e._meta.path]}}:(0,R.createIngest)(t)}async function oe(e,t,n,o,s,r,i){s||(s=(0,R.createIngest)(n[0]??"chain")),i&&s._meta&&(s._meta.chainPath=i);let a=o,c=r;for(const o of n){const r=t[o];if(!r){e.logger.warn(`Transformer not found: ${o}`);continue}if(s&&s._meta&&s._meta.path.length>256)return e.logger.error(`Max path length exceeded at ${o}`),{event:null,respond:c};if(s&&s._meta&&(s._meta.hops++,s._meta.path.push(o)),!await(0,R.tryCatchAsync)(ee,t=>{if(t instanceof R.FatalError)throw t;return e.status.failed++,e.logger.scope(`transformer:${r.type||"unknown"}`).error("transformer init failed",{transformer:o,error:t}),!1})(e,r,o))return{event:null,respond:c};if(i&&void 0!==r.config?.chainMocks?.[i]){const t=r.config.chainMocks[i];e.logger.scope(`transformer:${r.type||"unknown"}`).debug("chainMock",{chain:i}),a=t;continue}if(void 0!==r.config?.mock){e.logger.scope(`transformer:${r.type||"unknown"}`).debug("mock"),a=r.config.mock;continue}if(r.config?.disabled)continue;const u=r.config?.cache,l=u?(0,R.compileCache)(u):void 0,d=l?W(l,e):void 0,p=r.config?.state?(0,R.compileState)(r.config.state):void 0,f=p?.filter(e=>"get"===e.mode),g=p?.filter(e=>"set"===e.mode),h=async t=>g&&0!==g.length?(0,R.applyState)(g,t=>V(t,e),t,e):t;let m;if(l&&d){const e=(0,R.buildCacheContext)(s,a),t=await(0,R.checkCache)(l,d,e);if("HIT"===t?.status&&t.value){if(a=t.value,l.stop)return{event:a,respond:c,stopped:!0};continue}"MISS"===t?.status&&(m={key:t.key,ttl:t.rule.ttl})}const y=r.config.before;if(y){const n=(0,R.getNextSteps)(y,(0,R.buildCacheContext)(s,a));if(1===n.length){const o=Z(n[0],Y(t));if(o.length>0){const n=await oe(e,t,o,a,s,c,i);if(null===n.event)return{event:null,respond:n.respond??c};if(n.stopped)return{event:Array.isArray(n.event)?n.event[0]:n.event,respond:n.respond??c,stopped:!0};n.respond&&(c=n.respond),a=Array.isArray(n.event)?n.event[0]:n.event}}else n.length>1&&await Promise.all(n.map(n=>(0,R.tryCatchAsync)(oe,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Z(n,Y(t)),a,ne(s,n),void 0,i)))}f&&f.length>0&&(a=await(0,R.applyState)(f,t=>V(t,e),a,e));const w=await(0,R.tryCatchAsync)(te,t=>(e.logger.scope(`transformer:${r.type||"unknown"}`).error("Push failed",{error:t}),!1))(e,r,o,a,s,c);if(!1===w)return{event:null,respond:c};if(Array.isArray(w)){const r=n.slice(n.indexOf(o)+1),u=await Promise.all(w.map(async n=>{const o=await h(n.event||a),u=ne(s,"unknown");if(n.next){const s=(0,R.getNextSteps)(n.next,(0,R.buildCacheContext)(u,o));if(0===s.length)return{event:o,respond:c};if(1===s.length){const n=Z(s[0],Y(t));return n.length>0?oe(e,t,n,o,u,c,i):{event:o,respond:c}}return(await Promise.all(s.map(n=>(0,R.tryCatchAsync)(oe,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Z(n,Y(t)),o,ne(u,n),void 0,i)))).map(e=>({event:e.event,respond:void 0}))}return r.length>0?oe(e,t,r,o,u,c,i):{event:o,respond:c}}));let l=c;const d=[];for(const e of u.flat())if(null!==e)if(e&&"object"==typeof e&&"event"in e){const t=e;if(t.respond&&(l=t.respond),null===t.event)continue;Array.isArray(t.event)?d.push(...t.event):d.push(t.event)}else d.push(e);return 0===d.length?{event:null,respond:l}:1===d.length?{event:d[0],respond:l}:{event:d,respond:l}}if(w&&"object"==typeof w){const{event:n,respond:o,next:r}=w;if(o&&(c=o),void 0!==r){const o=await h(n||a),u=(0,R.getNextSteps)(r,(0,R.buildCacheContext)(s,o));if(0===u.length){a=o;continue}if(1===u.length){const n=Z(u[0],Y(t));return n.length>0?oe(e,t,n,o,s,c,i):(e.logger.warn(`Branch target not found: ${JSON.stringify(r)}`),{event:null,respond:c})}return await Promise.all(u.map(n=>(0,R.tryCatchAsync)(oe,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Z(n,Y(t)),o,ne(s,n),void 0,i))),{event:null,respond:void 0}}n&&(a=n)}g&&g.length>0&&(a=await(0,R.applyState)(g,t=>V(t,e),a,e)),m&&d&&(0,R.storeCache)(d,m.key,a,m.ttl);const v=r.config.next,b="string"==typeof v||Array.isArray(v)&&v.every(e=>"string"==typeof e),k=void 0!==v&&!b;if((!w||"object"==typeof w&&!w.next)&&k){const n=(0,R.getNextSteps)(r.config.next,(0,R.buildCacheContext)(s,a));if(1===n.length){const o=Z(n[0],Y(t));return o.length>0?oe(e,t,o,a,s,c,i):{event:a,respond:c}}return n.length>1?(await Promise.all(n.map(n=>(0,R.tryCatchAsync)(oe,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,Z(n,Y(t)),a,ne(s,n),void 0,i))),{event:null,respond:void 0}):{event:a,respond:c}}}return{event:a,respond:c}}function se(e){return e&&(0,R.isObject)(e)?e:{}}function re(e){return"string"==typeof e||!(!Array.isArray(e)||!e.every(e=>"string"==typeof e))}async function ie(e,t,n){if(!t.on||!t.queueOn?.length)return;const o=t.queueOn;t.queueOn=[];const s=n||t.config?.id||"unknown";for(const{type:n,data:r}of o)he(n)&&!be(e,t,n)||(await(0,N.tryCatchAsync)(t.on,t=>{if(t instanceof N.FatalError)throw t;e.status.failed++,e.logger.scope("source").error("source on flush failed",{sourceId:s,type:n,error:t})})(n,r),he(n)&&ve(e,t,n))}function ae(e){return Boolean(e.config.init)&&!e.config.require?.length}async function ce(e,t,n){const{code:o,config:s={},env:r={},primary:i,next:a,before:c,cache:u}=n,l=s.state??n.state,d=l?(0,N.compileState)(l):void 0,p=u,f=p?(0,N.compileCache)({...p,stop:p.stop??!0}):void 0,g=re(a)?Z(a,Y(e.transformers)):void 0,h=re(c)?Z(c,Y(e.transformers)):void 0,m=r.push,y=m??e.push,w=Boolean(m),v=async(n,o,r)=>{let i;const u=h??(void 0!==c?(()=>{const t=(0,N.getNextSteps)(c,(0,N.buildCacheContext)(r.ingest));return 0===t.length?[]:Z(1===t.length?t[0]:t,Y(e.transformers))})():[]);let l=[n];if(u.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const o=await oe(e,e.transformers,u,n,r.ingest,r.respond,`source.${t}.before`);if(null===o.event)return{ok:!0};if(o.stopped)return o.respond&&(r.respond=o.respond),{ok:!0};o.respond&&(r.respond=o.respond),l=Array.isArray(o.event)?o.event:[o.event]}if(f){const t=W(f,e);if(t){const n=(0,N.buildCacheContext)(r.ingest),o=await(0,N.checkCache)(f,t,n);if(o){if("HIT"===o.status&&void 0!==o.value&&f.stop){let t=o.value;return o.rule.update&&(t=await(0,N.applyUpdate)(t,o.rule.update,{...n,cache:{status:"HIT"}},e)),r.respond?.(t),{ok:!0}}if("MISS"===o.status&&f.stop&&r.respond){const s=r.respond,a=o.rule.update,c={...n,cache:{status:"MISS"}},u=o.key,l=o.rule.ttl,d=n=>{(0,N.storeCache)(t,u,n,l),a?i=(async()=>{const t=await(0,N.applyUpdate)(n,a,c,e);s(t)})():s(n)};r.respond=d}"MISS"!==o.status||f.stop||(0,N.storeCache)(t,o.key,!0,o.rule.ttl)}}}const p=g?{kind:"single",preChain:g}:void 0!==a?(()=>{const t=(0,N.getNextSteps)(a,(0,N.buildCacheContext)(r.ingest));return 0===t.length?{kind:"single",preChain:[]}:1===t.length?{kind:"single",preChain:Z(t[0],Y(e.transformers))}:{kind:"many",branches:t.map(t=>Z(t,Y(e.transformers)))}})():{kind:"single",preChain:[]};!w&&d&&d.length>0&&(l=await Promise.all(l.map(t=>(0,N.applyState)(d,t=>V(t,e),t,e))));let m={ok:!0};for(const n of l)"many"===p.kind?(await Promise.all(p.branches.map((i,a)=>(0,N.tryCatchAsync)(async()=>w?y(n):y(n,{...o,id:t,ingest:ne(r.ingest,`${t}.${a}`),respond:void 0,mapping:s,preChain:i}),t=>(e.logger.scope("source:many").error(`many branch ${a} failed`,{error:t}),{ok:!0}))())),m={ok:!0}):m=w?await y(n):await y(n,{...o,id:t,ingest:r.ingest,respond:r.respond,mapping:s,preChain:p.preChain});return i&&await i,m},b=async n=>{const o=(0,N.createIngest)(t);if(!s.ingest||void 0===n)return o;const r=await(0,N.getMappingValue)(n,s.ingest,{collector:e});return{...o,...r,_meta:o._meta}},k=e.logger.scope("source").scope(t),S={command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:k,...r,push:async(e,n={})=>{const o={ingest:(0,N.createIngest)(t),respond:void 0};return v(e,n,o)}},q={collector:e,logger:k,id:t,config:s,env:S,withScope:async(e,t,n)=>{const o={ingest:await b(e),respond:t};return n({...S,push:(e,t={})=>v(e,t,o),ingest:o.ingest,respond:o.respond})}},I=await(0,N.tryCatchAsync)(o,n=>{if(n instanceof N.FatalError)throw n;e.status.failed++,e.logger.scope("source").error("source factory failed",{sourceId:t,error:n})})(q);if(!I)return;const O=I.type||"unknown",C=e.logger.scope(O).scope(t);return S.logger=C,i&&(I.config={...I.config,primary:i}),I}async function ue(e){for(const[t,n]of Object.entries(e.sources)){if(ae(n))continue;const o=n.config.require;if(!o?.length)continue;const s=o.filter(t=>!ye(e,t));s.length!==o.length&&(n.config.require=s,ae(n)&&await ie(e,n,t))}for(const[t,n]of Object.entries(e.pending.destinations)){if(!e.pending.destinations[t]||e.destinations[t])continue;const o=n.config?.require;if(!o)continue;const s=o.filter(t=>!ye(e,t));if(n.config&&(n.config.require=s),s.length>0)continue;delete e.pending.destinations[t];const r=Ge(n);!1!==r.config.queue&&(r.queuePush=[...e.queue]),e.destinations[t]=r}}function le(e){if("object"!=typeof e||null===e)return!1;if(!("logger"in e))return!1;const t=e.logger;return"object"==typeof t&&null!==t&&"scope"in t&&"function"==typeof t.scope}var de=!1;function pe(){de||(de=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("walkerOS: ignored an on-dispatch call with a non-collector argument"))}function fe(e,t,n,o){if(n instanceof _.FatalError)throw n;e.logger.scope("on").error("on callback failed",{kind:t,...o,error:n})}var ge=[Q.Consent,Q.User,Q.Globals,Q.Custom];function he(e){return ge.includes(e)}function me(e,t){switch(t){case Q.Consent:return Object.keys(e.consent).length>0;case Q.User:return Object.keys(e.user).length>0;case Q.Globals:return Object.keys(e.globals).length>0;case Q.Custom:return Object.keys(e.custom).length>0;default:return!1}}function ye(e,t){switch(t){case Q.Consent:case Q.User:case Q.Globals:case Q.Custom:return me(e,t);case Q.Run:case Q.Ready:return!0===e.allowed;default:return e.seenEvents.has(String(t))}}function we(e,t){return e.cellVersion[String(t)]??0}function ve(e,t,n){let o=e.delivery.get(t);o||(o={},e.delivery.set(t,o)),o[String(n)]=we(e,n)}function be(e,t,n){return e.allowed&&we(e,n)>function(e,t,n){const o=e.delivery.get(t),s=o?.[String(n)];return void 0===s?-1:s}(e,t,n)}function ke(e,t,n){const o=e.cascade;if(!o)return!0;let s=o.counts.get(t);s||(s={},o.counts.set(t,s));const r=String(n),i=(s[r]||0)+1;return s[r]=i,i<=8||(9===i&&e.logger.error("state delivery did not converge",{type:r}),!1)}function Se(e,t){return{collector:e,logger:e.logger.scope("on").scope(String(t))}}function qe(e,t,n,o,s){if(!t.on)return;const r=t.type||"unknown",i=e.logger.scope(r).scope("on").scope(o),a={collector:e,logger:i,id:n,config:t.config,data:s,env:Be(t.env,t.config.env)};(0,H.tryCatch)(t.on,t=>fe(e,"destination",t,{destId:n,type:o}))(o,a)}function Ie(e,t,n,o){if(!le(e))return void pe();const s=Oe(e,t,o);if(n.length)switch(t){case Q.Consent:!function(e,t,n){const o=n||e.consent,s=Se(e,Q.Consent);t.forEach(t=>{be(e,t,Q.Consent)&&ke(e,t,Q.Consent)&&(Object.keys(o).filter(e=>e in t).forEach(n=>{(0,H.tryCatch)(t[n],t=>fe(e,"consent",t,{key:n}))(o,s)}),ve(e,t,Q.Consent))})}(e,n,o);break;case Q.Ready:!function(e,t){if(!e.allowed)return;const n=Se(e,Q.Ready);t.forEach(t=>{(0,H.tryCatch)(t,t=>fe(e,"ready",t))(void 0,n)})}(e,n);break;case Q.Run:!function(e,t){if(!e.allowed)return;const n=Se(e,Q.Run);t.forEach(t=>{(0,H.tryCatch)(t,t=>fe(e,"run",t))(void 0,n)})}(e,n);break;case Q.Session:!function(e,t){if(!e.session)return;const n=Se(e,Q.Session);t.forEach(t=>{(0,H.tryCatch)(t,t=>fe(e,"session",t))(e.session,n)})}(e,n);break;default:{const o=Se(e,t),r=he(t);n.forEach(n=>{"function"==typeof n&&(r&&!be(e,n,t)||r&&!ke(e,n,t)||((0,H.tryCatch)(n,n=>fe(e,"generic",n,{type:t}))(s,o),r&&ve(e,n,t)))});break}}}function Oe(e,t,n){switch(t){case Q.Consent:return n||e.consent;case Q.Session:return e.session;case Q.User:return n||e.user;case Q.Custom:return n||e.custom;case Q.Globals:return n||e.globals;case Q.Config:return n||e.config;default:return}}async function Ce(e,t,n,o,s){if(!t.on)return!1;if(he(o)&&!be(e,t,o))return!1;if(he(o)&&!ke(e,t,o))return!1;const r=await(0,H.tryCatchAsync)(t.on,t=>fe(e,"source",t,{sourceId:n,type:o}))(o,s);return he(o)&&ve(e,t,o),!1===r}function xe(e,t,n,o){if(!Number.isFinite(n.max)||n.max<=0)throw new Error(`pushBounded: max must be > 0 (got ${n.max})`);if("dropNewest"===(n.onOverflow??"dropOldest"))return e.length>=n.max?(o&&o([t]),{appended:!1,dropped:1}):(e.push(t),{appended:!0,dropped:0});const s=[];for(;e.length>=n.max;)s.push(e.shift());return e.push(t),s.length>0&&o&&o(s),{appended:!0,dropped:s.length}}var je=new WeakMap;function Ae(e,t,n,o){je.get(e)||(je.set(e,!0),t.warn(n,o))}function Te(e){je.delete(e)}var De=Object.freeze({batched:!0});function Ee(e){return e===De}function Me(e){return void 0===e?{}:"number"==typeof e?{wait:e}:{wait:e.wait,size:e.size,age:e.age}}function ze(e,t){return e.status.destinations[t]||(e.status.destinations[t]={count:0,failed:0,duration:0,queuePushSize:0,dlqSize:0}),e.status.destinations[t]}function Pe(e,t,n,o){e.dropped[t]||(e.dropped[t]={});const s=e.dropped[t];return s[n]=(s[n]??0)+o,s[n]}function $e(e,t,n){if(!e)return[];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return Z(e,t);if("string"==typeof e)return Z(e,t);const o=(0,$.getNextSteps)(e,(0,$.buildCacheContext)(n));return 0===o.length?[]:1===o.length?Z(o[0],t):Z(o,t)}async function _e(e,t,n={},o){const{allowed:s,consent:r,globals:i,user:a}=e;if(!s)return Re({ok:!1});if(t){const n=e.config.queueMax;if(void 0===n)throw new Error("Collector.Config.queueMax is undefined; defaults must be seeded by collector()");const o=xe(e.queue,t,{max:n});if(o.dropped>0){const t=Pe(e.status,(0,$.stepId)("collector"),"queue",o.dropped);Ae(e.queue,e.logger,"collector.queue overflow; oldest events dropped",{buffer:"queue",cap:n,droppedCount:t})}else e.queue.length<n&&Te(e.queue);e.status.in++}o||(o=e.destinations);const c=e.transformers?Y(e.transformers):{},u=await Promise.all(Object.entries(o||{}).map(async([o,s])=>{if(s.config.disabled)return{id:o,destination:s,skipped:!0};let u=(s.queuePush||[]).map(e=>({...e,consent:r}));s.queuePush=[],t&&u.push((0,$.clone)(t));const l=n.ingest?{...n.ingest,_meta:{...n.ingest._meta,path:[...n.ingest._meta.path]}}:(0,$.createIngest)("unknown");if(!u.length&&!s.queueOn?.length)return{id:o,destination:s,skipped:!0};if(!u.length&&s.queueOn?.length){if(!(0,$.getGrantedConsent)(s.config.consent,r))return{id:o,destination:s,skipped:!0};let t=!1;try{t=await He(e,s,o,!0)}catch(t){e.status.failed++;const n=s.type||"unknown";e.logger.scope(n).error("destination init failed",{error:t instanceof Error?t.message:String(t)})}return{id:o,destination:s,skipped:!t}}const d=[],p=u.filter(t=>{const n=(0,$.getGrantedConsent)(s.config.consent,r,t.consent);if(n)return t.consent=n,d.push(t),!1;const i=J(e,{stepId:(0,$.stepId)("destination",o),stepType:"destination",phase:"skip",eventId:"string"==typeof t.id?t.id:"",now:Date.now()});return i.skipReason="consent",r&&(i.consent={...r}),s.config.consent&&(i.meta={required:{...s.config.consent}}),(0,$.emitStep)(e,i),!0});if(p.length>0){const t=s.queuePush,n=s.config.id||o,r={max:s.config.queueMax??1e3};let i=0;for(const e of p)i+=xe(t,e,r).dropped;if(i>0){ze(e,n);const o=Pe(e.status,(0,$.stepId)("destination",n),"queue",i);Ae(t,e.logger.scope(s.type||"unknown"),"destination.queuePush overflow; oldest events dropped",{buffer:"queuePush",destination:n,cap:r.max,droppedCount:o})}else t.length<r.max&&Te(t)}if(!d.length)return{id:o,destination:s,queue:u};let f,g,h=!1;try{h=await He(e,s,o,!0)}catch(t){e.status.failed++;const n=s.type||"unknown";e.logger.scope(n).error("destination init failed",{error:t instanceof Error?t.message:String(t)})}if(!h)return{id:o,destination:s,queue:u};s.dlq||(s.dlq=[]);const m=$e(s.config.before,c,l),y=s.config.next,w=s.config?.cache,v=w?(0,$.compileCache)(w):void 0,b=v?W(v,e):void 0,k=s.config?.state?(0,$.compileState)(s.config.state):void 0,S=k?.filter(e=>"get"===e.mode),q=k?.filter(e=>"set"===e.mode);let I=0,O=0;return await Promise.all(d.map(async t=>{let r;if(t.globals=(0,$.assign)(i,t.globals),t.user=(0,$.assign)(a,t.user),v?.stop&&b){const e=(0,$.buildCacheContext)(l,t),n=await(0,$.checkCache)(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}let u=t,d=n.respond;if(m.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const s=await oe(e,e.transformers,m,t,l,n.respond,`destination.${o}.before`);if(null===s.event)return t;s.respond&&(d=s.respond),u=Array.isArray(s.event)?s.event[0]:s.event}if(v&&!v.stop&&b){const e=(0,$.buildCacheContext)(l,u),n=await(0,$.checkCache)(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}S&&S.length>0&&u&&(u=await(0,$.applyState)(S,t=>V(t,e),u,e));const p=Date.now();let h=!1;const w=await(0,$.tryCatchAsync)(Ne,t=>{const n=s.type||"unknown";e.logger.scope(n).error("Push failed",{error:t,event:u.name}),f=t,h=!0;const r=s.dlq,i=s.config.id||o,a={max:s.config.dlqMax??100},c=xe(r,[u,t],a);if(c.dropped>0){ze(e,i);const t=Pe(e.status,(0,$.stepId)("destination",i),"dlq",c.dropped);Ae(r,e.logger.scope(s.type||"unknown"),"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:i,cap:a.max,droppedCount:t})}else r.length<a.max&&Te(r)})(e,s,o,u,l,d);if(I+=Date.now()-p,r&&b&&void 0===s.config.mock&&(0,$.storeCache)(b,r.key,w??!0,r.ttl),!h&&!Ee(w)&&q&&q.length>0&&u&&(u=await(0,$.applyState)(q,t=>V(t,e),u,e)),void 0===w||Ee(w)||(g=w),Ee(w)&&O++,!h&&y){void 0!==w&&(l._response=w);const t=$e(y,c,l);if(t.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const n=await oe(e,e.transformers,t,u,l,d,`destination.${o}.next`);n.respond&&(d=n.respond)}}return t})),{id:o,destination:s,error:f,response:g,totalDuration:I,batchedCount:O,allowedCount:d.length}})),l={},d={},p={};for(const t of u){if(t.skipped)continue;const n=t.destination,o={type:n.type||"unknown",data:t.response};ze(e,t.id);const s=e.status.destinations[t.id],r=Date.now();if(s.queuePushSize=n.queuePush?.length??0,s.dlqSize=n.dlq?.length??0,t.error)o.error=t.error,p[t.id]=o,s.failed++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.failed++;else if(t.queue&&t.queue.length)d[t.id]=o;else{const n=t.batchedCount??0,i=t.allowedCount??0;(Math.max(0,i-n)>0||0===i)&&(l[t.id]=o,s.count++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.out++)}}return Re({event:t,...Object.keys(l).length&&{done:l},...Object.keys(d).length&&{queued:d},...Object.keys(p).length&&{failed:p}})}async function He(e,t,n,o=!1){if(t.init&&!t.config.init){if(!o&&function(e){const t=e.config.consent;return!!t&&Object.keys(t).length>0}(t))return e.logger.scope(t.type||"unknown").debug("init blocked: consent gate not cleared"),!1;const s=t.type||"unknown",r=e.logger.scope(s),i={collector:e,logger:r,id:n,config:t.config,env:Be(t.env,t.config.env)};r.debug("init");const a=Date.now();let c;(0,$.emitStep)(e,J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"init",eventId:"",now:a}));try{c=await(0,$.useHooks)(t.init,"DestinationInit",e.hooks,e.logger)(i)}catch(t){const o=Date.now(),s=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"error",eventId:"",now:o});throw s.durationMs=o-a,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},(0,$.emitStep)(e,s),t}if(!1===c)return c;if(t.config={...c||t.config,init:!0},t.queueOn?.length){const o=t.queueOn;t.queueOn=[];for(const{type:s,data:r}of o)qe(e,t,n,s,r)}r.debug("init done")}return!0}async function Ne(e,t,n,o,s,r){const{config:i}=t,a=await(0,$.processEventMapping)(o,i,e);if(a.ignore)return!1;const c=t.type||"unknown",u=e.logger.scope(c),l={collector:e,logger:u,id:n,config:i,data:a.data,rule:a.mapping,ingest:s,env:{...Be(t.env,i.env),...r?{respond:r}:{}}};if(void 0!==i.mock)return u.debug("mock",{event:a.event.name}),i.mock;const d=a.mapping,p=void 0!==d?.batch,f=p?a.mappingKey||"* *":" batch-all";if((p||void 0!==i.batch)&&t.pushBatch&&void 0===i.mock){if(t.batches=t.batches||{},!t.batches[f]){const o={key:f,entries:[],events:[],data:[]},s=Me(d?.batch),r=Me(i.batch),a=s.wait??r.wait??3e4,c=s.size??r.size??1e3,l=s.age??r.age??3e4,g=Be(t.env,i.env),h=(0,$.debounce)(async()=>{const o=t.batches[f],s=o.batched;if(0===s.entries.length)return;const r={key:s.key,entries:s.entries,events:s.events,data:s.data};s.entries=[],s.events=[],s.data=[];const a=r.entries[0],c={collector:e,logger:u,id:n,config:i,data:void 0,rule:o.isDefault?void 0:a.rule,ingest:a.ingest,env:{...g,...a.respond?{respond:a.respond}:{}}};u.debug("push batch",{events:r.entries.length});const l=t.config.id||n,d=ze(e,l),p=Date.now(),h=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"flush",eventId:"",now:p});h.batch={size:r.entries.length,index:0},(0,$.emitStep)(e,h);const m=n=>{const o=t.dlq=t.dlq||[],s={max:t.config.dlqMax??100};let r=0;for(const e of n)r+=xe(o,e,s).dropped;if(r>0){const t=Pe(e.status,(0,$.stepId)("destination",l),"dlq",r);Ae(o,u,"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:l,cap:s.max,droppedCount:t})}else o.length<s.max&&Te(o);d.failed+=n.length,d.dlqSize=o.length,e.status.failed+=n.length};let y=r.entries.length;const w=await(0,$.tryCatchAsync)((0,$.useHooks)(t.pushBatch,"DestinationPushBatch",e.hooks,e.logger),t=>{y=0;const o=Date.now(),s=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"error",eventId:"",now:o});s.durationMs=o-p,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},s.batch={size:r.entries.length,index:0},(0,$.emitStep)(e,s),m(r.entries.map(e=>[e.event,t])),u.error("Push batch failed",{error:t instanceof Error?t.message:String(t),entries:r.entries.length})})(r,c);if((0,$.isObject)(v=w)&&Array.isArray(v.failed)&&w.failed.length>0){const e=[],t=new Set;for(const n of w.failed){const o=r.entries[n.index];o&&!t.has(n.index)&&(t.add(n.index),e.push([o.event,n.error??new Error(`Push batch entry ${n.index} failed (no per-row error provided)`)]))}e.length>0&&(m(e),y=Math.max(0,r.entries.length-e.length),u.error("Push batch partial failure",{failed:e.length,delivered:y,entries:r.entries.length}))}var v;u.debug("push batch done"),d.inFlightBatch=Math.max(0,(d.inFlightBatch??0)-r.entries.length),y>0&&(d.count+=y,d.lastAt=Date.now(),e.status.out+=y)},{wait:a,size:c,age:l});t.batches[f]={batched:o,isDefault:!p,batchFn:()=>{h()},flush:async()=>{await h.flush()}}}const o=t.batches[f];o.batched.entries.push({event:a.event,ingest:s,respond:r,rule:d,data:a.data}),o.batched.events.push(a.event),(0,$.isDefined)(a.data)&&o.batched.data.push(a.data);const c=t.config.id||n,l=ze(e,c);return l.inFlightBatch=(l.inFlightBatch??0)+1,o.batchFn(),De}{u.debug("push",{event:a.event.name});const o="string"==typeof a.event.id?a.event.id:"",s=Date.now(),r=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"in",eventId:o,now:s});a.mappingKey&&(r.mappingKey=a.mappingKey),a.event.consent&&(r.consent={...a.event.consent}),(0,$.emitStep)(e,r);try{const r=await(0,$.useHooks)(t.push,"DestinationPush",e.hooks,e.logger)(a.event,l),i=Date.now(),c=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"out",eventId:o,now:i});return c.durationMs=i-s,c.outEvent=r,a.mappingKey&&(c.mappingKey=a.mappingKey),(0,$.emitStep)(e,c),u.debug("push done"),r}catch(t){const r=Date.now(),i=J(e,{stepId:(0,$.stepId)("destination",n),stepType:"destination",phase:"error",eventId:o,now:r});throw i.durationMs=r-s,i.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},a.mappingKey&&(i.mappingKey=a.mappingKey),(0,$.emitStep)(e,i),t}}}function Re(e){return{ok:!e?.failed,...e}}function Ge(e){const{code:t,config:n={},env:o={},cache:s,state:r}=e,{config:i}=X(e,"before"),{config:a}=X({...e,config:i},"next"),c={...t.config,...n,...a};s&&(c.cache=s),void 0!==r&&void 0===c.state&&(c.state=r);const u=Be(t.env,o);return{...t,config:c,env:u}}function Be(e,t){return e||t?t?e&&(0,$.isObject)(e)&&(0,$.isObject)(t)?{...e,...t}:t:e:{}}async function Fe(e,t,n){const o=Object.entries(e).map(async([e,o])=>{const s=o.destroy;if(!s)return;const r=o.type||"unknown",i=n.scope(r),a={id:e,config:o.config,env:o.env??{},logger:i};let c;try{await Promise.race([s(a),new Promise((n,o)=>{c=setTimeout(()=>o(new Error(`${t} '${e}' destroy timed out`)),5e3)})])}catch(n){i.error(`${t} '${e}' destroy failed: ${n}`)}finally{c&&clearTimeout(c)}});await Promise.allSettled(o)}function Le(e,t){e.stateVersion++,e.cellVersion[t]=e.stateVersion}async function Ue(e,t,n){let o,s,r=!1;const i=function(e){return e.cascade?()=>{}:(e.cascade={counts:new WeakMap},()=>{e.cascade=void 0})}(e);try{return await async function(){switch(t){case Q.Config:(0,B.isObject)(n)&&((0,G.assign)(e.config,n,{shallow:!1}),s=n,r=!0);break;case Q.Consent:if((0,B.isObject)(n)){const{update:t}=function(e,t){const n={};return Object.entries(t).forEach(([e,t])=>{n[e]=!!t}),e.consent=(0,z.assign)(e.consent,n),{update:n}}(e,n);Le(e,Q.Consent),s=t,r=!0}break;case Q.Custom:(0,B.isObject)(n)&&(e.custom=(0,G.assign)(e.custom,n),Le(e,Q.Custom),s=n,r=!0);break;case Q.Destination:(0,B.isObject)(n)&&"code"in n&&(0,B.isObject)(n.code)&&(o=await async function(e,t){const{code:n,config:o={},env:s={},before:r,next:i,cache:a,state:c}=t;if(!(0,$.isFunction)(n.push))return Re({ok:!1,failed:{invalid:{type:"invalid",error:"Destination code must have a push method"}}});const u=o||{init:!1};let l=r?{...u,before:r}:{...u};i&&(l={...l,next:i}),a&&(l={...l,cache:a}),void 0!==c&&void 0===l.state&&(l={...l,state:c});let d=l.id;if(!d)do{d=(0,$.getId)(5,"abcdefghijklmnopqrstuvwxyz")}while(e.destinations[d]||e.pending.destinations[d]);if(l.require?.length){e.pending.destinations[d]=t,await ue(e);const n=e.destinations[d];return n?_e(e,void 0,{},{[d]:n}):Re({ok:!0})}const p={...n,config:l,env:Be(n.env,s)};return e.destinations[d]=p,!1!==p.config.queue&&(p.queuePush=[...e.queue]),_e(e,void 0,{},{[d]:p})}(e,n));break;case Q.Globals:(0,B.isObject)(n)&&(e.globals=(0,G.assign)(e.globals,n),Le(e,Q.Globals),s=n,r=!0);break;case Q.Hook:if((0,B.isObject)(n)&&(0,G.isString)(n.name)&&(0,G.isFunction)(n.fn)){const{name:t,fn:o}=n;e.hooks[t]=o,s=n,r=!0}break;case Q.On:if((0,B.isObject)(n)&&(0,G.isString)(n.type)){const{type:t,rules:o}=n;await async function(e,t,n){if(!le(e))return void pe();const o=e.on,s=o[t]||[],r=(0,_.isArray)(n)?n:[n];r.forEach(e=>{s.push(e)}),o[t]=s,Ie(e,t,r)}(e,t,o)}break;case Q.Ready:r=!0;break;case Q.Run:o=await async function(e,t){return e.allowed=!0,e.timing=Date.now(),t&&(t.consent&&(e.consent=(0,G.assign)(e.consent,t.consent),Le(e,Q.Consent)),t.user&&(e.user=(0,G.assign)(e.user,t.user),Le(e,Q.User)),t.globals&&(e.globals=(0,G.assign)(e.config.globalsStatic||{},t.globals),Le(e,Q.Globals)),t.custom&&(e.custom=(0,G.assign)(e.custom,t.custom),Le(e,Q.Custom))),Object.values(e.destinations).forEach(e=>{e.queuePush=[]}),e.queue=[],e.round++,await ue(e),await async function(e){if(le(e))for(const t of ge){if(!me(e,t))continue;const n=Oe(e,t);Ie(e,t,e.on[t]||[]);for(const[o,s]of Object.entries(e.sources))ae(s)&&await Ce(e,s,o,t,n)}else pe()}(e),await _e(e)}(e,n),r=!0;break;case Q.Session:r=!0;break;case Q.Shutdown:e.hasShutdown||(e.hasShutdown=!0,await async function(e){const t=e.logger;await Fe(e.sources,"source",t),await async function(e,t){const n=Object.entries(e).flatMap(([e,n])=>{const o=n.batches;if(!o)return[];const s=t.scope(n.type||"destination");return Object.values(o).map(async t=>{let n;try{await Promise.race([t.flush(),new Promise((t,o)=>{n=setTimeout(()=>o(new Error(`destination '${e}' batch flush timed out`)),5e3)})])}catch(t){s.error(`destination '${e}' batch flush failed: ${t}`)}finally{n&&clearTimeout(n)}})});await Promise.allSettled(n)}(e.destinations,t),await Fe(e.destinations,"destination",t),await Fe(e.transformers,"transformer",t),await Fe(e.stores,"store",t)}(e));break;case Q.User:(0,B.isObject)(n)&&((0,G.assign)(e.user,n,{shallow:!1}),Le(e,Q.User),s=n,r=!0)}return r&&(await async function(e,t,n,o){if(!le(e))return pe(),!0;e.seenEvents.add(String(t));let s=n||[];n||(s=e.on[t]||[]);const r=Oe(e,t,o);let i=!1;for(const[n,o]of Object.entries(e.sources)){if(o.config.require?.length){const e=o.config.require.indexOf(t);-1!==e&&o.config.require.splice(e,1)}o.on&&(ae(o)?await Ce(e,o,n,t,r)&&(i=!0):(o.queueOn=o.queueOn||[],o.queueOn.push({type:t,data:r})))}Object.entries(e.destinations).forEach(([n,o])=>{if(o.on){if(!o.config.init)return o.queueOn=o.queueOn||[],void o.queueOn.push({type:t,data:r});qe(e,o,n,t,r)}});for(const[t,n]of Object.entries(e.sources))ae(n)&&n.queueOn?.length&&await ie(e,n,t);const a=Object.values(e.sources).some(e=>!ae(e)&&e.config.require?.length);return(Object.keys(e.pending.destinations).length>0||a)&&await ue(e),Ie(e,t,s,o),!i}(e,t,void 0,s),o=await _e(e)),o||Re({ok:!0})}()}finally{i()}}function Ke(e,t){return{timing:Math.round((Date.now()-e.timing)/10)/100,source:{type:"collector",schema:"4",version:"4.2.1-next-1781538735002"},...t}}function Qe(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");const{timestamp:s=Date.now(),name:r=`${n} ${o}`,data:i={},context:a={},globals:c=e.globals,custom:u={},user:l=e.user,nested:d=[],consent:p=e.consent,id:f=(0,G.getSpanId)(),trigger:g="",entity:h=n,action:m=o,timing:y=0,source:w={type:"collector",schema:"4"}}=t;return{name:r,data:i,context:a,globals:c,custom:u,user:l,nested:d,consent:p,id:f,trigger:g,entity:h,action:m,timestamp:s,timing:y,source:w}}function Je(e,t){const n=(0,F.useHooks)(async(n,o={})=>await(0,F.tryCatchAsync)(async()=>{const s=Date.now(),{id:r,ingest:i,respond:a,mapping:c,preChain:u,include:l,exclude:d}=o;let p=a,f=n;const g=l||d?function(e,t,n){let o=e;return t&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>t.includes(e)))),n&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>!n.includes(e)))),o}(e.destinations,l,d):void 0,h=i??(0,F.createIngest)(r||"unknown");if(c){const t=await(0,F.processEventMapping)(f,c,e);if(t.ignore)return Re({ok:!0});if(c.consent&&!(0,F.getGrantedConsent)(c.consent,e.consent,t.event.consent))return Re({ok:!0});f=t.event}if(u?.length&&e.transformers&&Object.keys(e.transformers).length>0){const n=await oe(e,e.transformers,u,f,h,p,r?`source.${r}.next`:void 0);if(null===n.event)return Re({ok:!0});if(n.stopped)return n.respond&&(p=n.respond),Re({ok:!0});if(n.respond&&(p=n.respond),Array.isArray(n.event)){const o=await Promise.all(n.event.map(async n=>{const o=t(n),s=Qe(e,o);return _e(e,s,{id:r,ingest:h,respond:p},g)}));if(r){e.status.sources[r]||(e.status.sources[r]={count:0,duration:0});const t=e.status.sources[r];t.count+=n.event.length,t.lastAt=Date.now(),t.duration+=Date.now()-s}return o[0]??Re({ok:!0})}f=n.event}const m=function(e,t){return Qe(e,Ke(e,t))}(e,f),y=await _e(e,m,{id:r,ingest:h,respond:p},g);if(r){e.status.sources[r]||(e.status.sources[r]={count:0,duration:0});const t=e.status.sources[r];t.count++,t.lastAt=Date.now(),t.duration+=Date.now()-s}return y},t=>{if(t instanceof F.FatalError)throw t;return e.status.failed++,e.logger.error("push failed",{event:n,ingest:o.ingest,error:t}),Re({ok:!1})})(),"Push",e.hooks,e.logger);return async(t,o)=>{const s="string"==typeof t.id?t.id:"",r=Date.now();(0,F.emitStep)(e,J(e,{stepId:"collector.push",stepType:"collector",phase:"in",eventId:s,now:r}));try{const i=await n(t,o),a=Date.now(),c=J(e,{stepId:"collector.push",stepType:"collector",phase:"out",eventId:s,now:a});return c.durationMs=a-r,c.outEvent=i,(0,F.emitStep)(e,c),i}catch(t){const n=Date.now(),o=J(e,{stepId:"collector.push",stepType:"collector",phase:"error",eventId:s,now:n});throw o.durationMs=n-r,o.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},(0,F.emitStep)(e,o),t}}}function We(e={}){const t=e.maxEntries??1e4,n=e.lowWaterMark??.8,o=e.sweepIntervalMs??6e4,s=Math.floor(t*n),r=new Map,i={hits:0,misses:0,populates:0,writes:0,deletes:0,evictions_entries:0,evictions_ttl:0};let a;return o>0&&(a=setInterval(function(){const e=Date.now();let t=0;for(const[n,o]of r)void 0!==o.expires&&o.expires<=e&&(r.delete(n),t++);i.evictions_ttl+=t},o),a&&"function"==typeof a.unref&&a.unref()),{type:"memory",config:{},get(e){const t=r.get(e);if(t)return void 0!==t.expires&&t.expires<=Date.now()?(r.delete(e),i.evictions_ttl++,void i.misses++):(r.delete(e),r.set(e,t),i.hits++,t.value);i.misses++},set(e,n,o){const a=!r.has(e);a||r.delete(e),r.set(e,{value:n,expires:void 0!==o?Date.now()+o:void 0}),i.writes++,a&&i.populates++,r.size>t&&function(){if(r.size<=t)return;const e=r.size-s;let n=0;for(const t of r.keys()){if(n>=e)break;r.delete(t),n++}i.evictions_entries+=n}()},delete(e){r.delete(e)&&i.deletes++},get counters(){return{...i}},destroy(){void 0!==a&&(clearInterval(a),a=void 0),r.clear()}}}function Ve(e,t){const{cacheConfig:n,cacheStore:o,namespace:s,logger:r,storeId:i,collector:a}=t,c=(e,t)=>{if(!a)return;const n=J(a,{stepId:`store.${i}`,stepType:"store",phase:"in",eventId:"",now:Date.now()});n.meta={op:"cache",cached:"hit"===t,status:t,key:e},(0,K.emitStep)(a,n)},u={hits:0,misses:0,populates:0,writes:0,deletes:0,inflight_dedups:0},l=n.rules.map(e=>({match:e.match?(0,K.compileMatcher)(e.match):()=>!0,ttl:e.ttl})),d=e=>`${s}:${e}`;function p(e,t){const n=void 0===t?{key:e}:{key:e,value:t};return l.find(e=>e.match(n))}const f=new Map;return{type:e.type,config:e.config,setup:e.setup,get counters(){return{...u}},async get(t){const n=d(t),s=await o.get(n),r=(0,K.readCacheEnvelope)(s);if(void 0!==r){if(!("expired"in r))return u.hits++,c(t,"hit"),r.value;try{await o.delete(n)}catch(e){g("delete",t,e)}}const i=f.get(n);if(i)return u.inflight_dedups++,c(t,"hit"),i;u.misses++,c(t,"miss");const a=(async()=>{try{const s=await e.get(t);if(void 0===s)return;const r=p(t,s);if(r)try{const e=1e3*r.ttl;await o.set(n,(0,K.wrapCacheEnvelope)(s,e),e),u.populates++}catch(e){g("set",t,e)}return s}finally{f.delete(n)}})();return f.set(n,a),a},async set(t,n,s){u.writes++,await e.set(t,n,s);const r=p(t,n);if(r)try{const e=1e3*r.ttl;await o.set(d(t),(0,K.wrapCacheEnvelope)(n,e),e)}catch(e){g("set",t,e)}},async delete(t){u.deletes++,await e.delete(t);try{await o.delete(d(t))}catch(e){g("delete",t,e)}}};function g(e,t,n){const o=`store-cache(${i}): cache ${e} failed for "${t}"; backing succeeded, continuing`;r?r.warn(o,{error:n}):console.warn(o,n)}}function Ye(e,t,n){const o=`store.${n}`,s=(0,U.useHooks)(t.get,"StoreGet",e.hooks,e.logger),r=(0,U.useHooks)(t.set,"StoreSet",e.hooks,e.logger),i=(0,U.useHooks)(t.delete,"StoreDelete",e.hooks,e.logger);t.get=async t=>{const n=Date.now(),r=J(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});r.meta={op:"get",key:t},(0,U.emitStep)(e,r);try{const r=await s(t),i=Date.now(),a=J(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:i});return a.durationMs=i-n,a.meta={op:"get",key:t},(0,U.emitStep)(e,a),r}catch(s){const r=Date.now(),i=J(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw i.durationMs=r-n,i.meta={op:"get",key:t},i.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},(0,U.emitStep)(e,i),s}},t.set=async(t,n,s)=>{const i=Date.now(),a=J(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:i});a.meta={op:"set",key:t},(0,U.emitStep)(e,a);try{await r(t,n,s);const a=Date.now(),c=J(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:a});c.durationMs=a-i,c.meta={op:"set",key:t},(0,U.emitStep)(e,c)}catch(n){const s=Date.now(),r=J(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:s});throw r.durationMs=s-i,r.meta={op:"set",key:t},r.error=n instanceof Error?{name:n.name,message:n.message}:{message:String(n)},(0,U.emitStep)(e,r),n}},t.delete=async t=>{const n=Date.now(),s=J(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});s.meta={op:"delete",key:t},(0,U.emitStep)(e,s);try{await i(t);const s=Date.now(),r=J(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:s});r.durationMs=s-n,r.meta={op:"delete",key:t},(0,U.emitStep)(e,r)}catch(s){const r=Date.now(),i=J(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw i.durationMs=r-n,i.meta={op:"delete",key:t},i.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},(0,U.emitStep)(e,i),s}}}async function Xe(e){const t=(0,P.assign)({globalsStatic:{},sessionStatic:{},run:!0,queueMax:1e3},e,{merge:!1,extend:!1}),n={level:e.logger?.level,handler:e.logger?.handler},o=(0,P.createLogger)(n),s={...t.globalsStatic,...e.globals},r={allowed:!1,config:t,consent:e.consent||{},custom:e.custom||{},destinations:{},transformers:{},stores:{},globals:s,hooks:e.hooks||{},observers:new Set,logger:o,on:{},queue:[],round:0,stateVersion:0,cellVersion:{},delivery:new WeakMap,session:void 0,status:{startedAt:Date.now(),in:0,out:0,failed:0,sources:{},destinations:{},dropped:{}},timing:Date.now(),user:e.user||{},sources:{},pending:{destinations:{}},hasShutdown:!1,seenEvents:new Set,push:void 0,command:void 0};var i,a;r.push=Je(r,e=>Ke(r,e)),r.command=(i=r,a=Ue,(0,L.useHooks)(async(e,t,n)=>await(0,L.tryCatchAsync)(async()=>await a(i,e,t,n),n=>{if(n instanceof L.FatalError)throw n;return i.status.failed++,i.logger.error("command failed",{command:e,data:t,error:n}),Re({ok:!1})})(),"Command",i.hooks,i.logger));const c=e.stores||{};return r.stores=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const{code:t,config:r={},env:i={}}=s,a=e.logger.scope("store").scope(o),c={collector:e,logger:a,id:o,config:r,env:i},u=await t(c);n[o]=u}const o=t,s=function(e){const t={};for(const n of Object.keys(e))t[n]="WHITE";const n=[],o=[];function s(r){const i=t[r];if("BLACK"===i)return;if("GRAY"===i){const e=o.indexOf(r),t=o.slice(-1===e?0:e).concat(r).join(" -> ");throw new Error(`Cycle in cache.store chain: ${t}`)}t[r]="GRAY",o.push(r);const a=e[r].cache?.store;if(void 0!==a){if(!(a in e))throw new Error(`Store "${r}" cache.store references "${a}", which is not declared in flow.stores`);s(a)}o.pop(),t[r]="BLACK",n.push(r)}for(const n of Object.keys(e))"WHITE"===t[n]&&s(n);return n}(o);for(const t of s){const s=o[t].cache;if(!s)continue;let r,i;void 0!==s.store?(r=n[s.store],i=s.store):(n.__cache||(n.__cache=We()),r=n.__cache,i="__cache");const a=s.namespace??t;e.logger.scope("store-cache").scope(t).info(`store "${t}" caches with namespace "${a}:" via ${i}`),n[t]=Ve(n[t],{storeId:t,cacheConfig:s,cacheStore:r,namespace:a,logger:e.logger.scope("store-cache").scope(t),collector:e})}for(const[t,o]of Object.entries(n))"__cache"!==t&&Ye(e,o,t);return n}(r,c),function(e,t,n){const o=new Map;for(const[n,s]of Object.entries(e))t[n]&&o.set(s,t[n]);if(0!==o.size)for(const e of[n.transformers,n.destinations,n.sources])if(e)for(const t of Object.values(e))s(t.env);function s(e){if(e)for(const[t,n]of Object.entries(e))if("object"==typeof n&&null!==n){const s=o.get(n);s&&(e[t]=s)}}}(c,r.stores,e),r.stores.__cache||(r.stores.__cache=We()),r.destinations=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t))s.config?.require?.length?e.pending.destinations[o]=s:n[o]=Ge(s);return n}(r,e.destinations||{}),r.transformers=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const{code:t,env:r={}}=s,i=(0,R.validateStepEntry)(s,"Transformer");if(!i.ok){e.logger.warn(`Transformer ${o} invalid (${i.code}): ${i.reason}. Skipping.`);continue}const{config:a}=X(s,"before"),{config:c}=X({...s,config:a},"next"),u=Object.keys(r).length>0?{...c,env:r}:c,{cache:l}=s,d=l?{...u,cache:l}:u,p=s.config?.state??s.state,f=void 0!==p&&void 0===d.state?{...d,state:p}:d,g=e.logger.scope("transformer").scope(o),h={collector:e,logger:g,id:o,ingest:(0,R.createIngest)(o),config:f,env:r},m=t??(e=>{const t=s.mapping;if(t){const n=[];if(void 0!==t.data&&n.push("data"),t.mapping)for(const[e,o]of Object.entries(t.mapping))if("object"==typeof o&&null!==o)for(const[t,s]of Object.entries(o)){if("object"!=typeof s||null===s)continue;const o=s;void 0!==o.data&&n.push(`mapping[${e}][${t}].data`),void 0!==o.silent&&n.push(`mapping[${e}][${t}].silent`)}return n.length>0&&e.collector.logger.warn(`Transformer ${o}: \`${n.join(", ")}\` ignored at transformer position (only event-mutating fields apply).`),{type:"pass",config:e.config,push:async n=>{const o=await(0,R.processEventMapping)(n,t,e.collector);return!o.ignore&&{event:o.event}}}}return{type:"pass",config:e.config,push:e=>({event:e})}}),y=await m(h);void 0!==s.before&&void 0===y.config?.before&&(y.config={...y.config??{},before:s.before}),void 0!==s.next&&void 0===y.config?.next&&(y.config={...y.config??{},next:s.next}),void 0!==p&&void 0===y.config?.state&&(y.config={...y.config??{},state:p}),n[o]=y}return n}(r,e.transformers||{}),r}async function Ze(e){e=e||{};const t=await Xe(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,s,r)=>{if("string"==typeof e&&e.startsWith("walker ")){const n=e.replace("walker ","");return o.command(n,t)}let i;if("string"==typeof e)i={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(i.data=t);else{if(!e||"object"!=typeof e)return Re({ok:!1});i=e,t&&"object"==typeof t&&!Array.isArray(t)&&(i.data={...i.data||{},...t})}return n&&"object"==typeof n&&(i.context=n),s&&Array.isArray(s)&&(i.nested=s),r&&"object"==typeof r&&(i.custom=r),o.push(i)}});var o;t.sources.elb=n,await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const t=await ce(e,o,s);if(!t)continue;const r=s.config?.require;t.config={...t.config,init:!1,...r?{require:[...r]}:{}},n[o]=t}Object.assign(e.sources,n);for(const t of Object.keys(n)){const n=e.sources[t];let o=!1;n.init&&await(0,N.tryCatchAsync)(n.init.bind(n),n=>{if(n instanceof N.FatalError)throw n;o=!0,e.status.failed++,e.logger.scope("source").error("source init failed",{sourceId:t,error:n})})(),o||(n.config.init=!0,ae(n)&&await ie(e,n,t))}return await ue(e),n}(t,e.sources||{});const{consent:s,user:r,globals:i,custom:a}=e;s&&await t.command("consent",s),r&&await t.command("user",r),i&&await t.command("globals",i),a&&await t.command("custom",a),t.config.run&&await t.command("run");let c=n.push;const u=Object.values(t.sources).filter(e=>"elb"!==e.type),l=u.find(e=>e.config.primary);return l?c=l.push:u.length>0&&(c=u[0].push),{collector:t,elb:c}}var et=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await Ze(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources||{}))if("lambda"===t.type)return t}(t.collector);if(!o)throw new Error("Lambda source not found in collector");const s={awsRequestId:`test-${Date.now()}`},r=o.push,i=await r(n,s);let a;try{a=JSON.parse(i.body||"{}")}catch{a=i.body}const c={};if(i.headers)for(const[e,t]of Object.entries(i.headers))void 0!==t&&(c[e]=String(t));return{statusCode:i.statusCode,body:a,headers:c}}}};function tt(e){return async t=>{const n={...t};if(n.body&&"string"==typeof n.body){const e=JSON.parse(n.body);e.name&&!e.event&&(n.body=JSON.stringify({...e,event:e.name,name:void 0}))}return e.push(n,{awsRequestId:"test-req"})}}var nt={};r(nt,{createTrigger:()=>ht,env:()=>ot,step:()=>ut});var ot={};r(ot,{push:()=>at,simulation:()=>ct});var st=()=>{},rt={error:st,warn:st,info:st,debug:st,throw:e=>{throw"string"==typeof e?new Error(e):e},json:st,scope:()=>rt},it=()=>()=>Promise.resolve({ok:!0}),at={get push(){return it()},get command(){return it()},get elb(){return it()},logger:rt},ct=["AWS.SQSClient"],ut={};r(ut,{decoderText:()=>pt,malformedJson:()=>ft,orderComplete:()=>dt,pageView:()=>lt});var lt={title:"Page view from SQS",description:"A standard SQS message body containing a walker elb event payload as JSON.",in:{MessageId:"m-1",Body:JSON.stringify({event:"page view",data:{title:"Documentation",url:"https://example.com/docs"}})},out:[["message.ack","m-1"]]},dt={title:"Order complete from SQS",description:"Order complete event flowing through the long-poll loop.",in:{MessageId:"m-2",Body:JSON.stringify({event:"order complete",data:{id:"ORD-500",total:199.99,currency:"EUR"}})},out:[["message.ack","m-2"]]},pt={title:"Text decoder",description:'When decoder is "text", the body string flows under data.payload.',in:{MessageId:"m-3",Body:"raw text payload"},out:[["message.ack","m-3"]]},ft={title:"Malformed JSON nacks",description:"Default decoder is JSON. A malformed body throws DecoderError; the source nacks (skips DeleteMessage) so the message redelivers.",in:{MessageId:"m-4",Body:"{not json"},out:[["message.nack","m-4"]]};function gt(e){if("object"!=typeof e||null===e)return!1;const t=e;return"sqs"===t.type&&"function"==typeof t.push}var ht=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await Ze(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources??{}))if(gt(t))return t}(t.collector);if(!o)throw new Error("sqs source not registered in collector, ensure it is configured in sources");const s={MessageId:n.MessageId,Body:n.Body,ReceiptHandle:n.ReceiptHandle,Attributes:n.Attributes,MessageAttributes:n.MessageAttributes},r=await o.push(s),i=[];return r&&"object"==typeof r&&(r.acked&&i.push(["message.ack",n.MessageId]),r.nacked&&i.push(["message.nack",n.MessageId])),i}}};//# sourceMappingURL=dev.js.map
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dev.ts","../src/schemas.ts","../src/lambda/schemas/index.ts","../src/lambda/schemas/settings.ts","../src/lambda/schemas/primitives.ts","../src/sqs/schemas/index.ts","../src/sqs/schemas/settings.ts","../src/sqs/schemas/setup.ts","../src/lambda/examples/index.ts","../src/lambda/examples/env.ts","../src/lambda/examples/step.ts","../src/lambda/examples/trigger.ts","../src/sqs/examples/index.ts","../src/sqs/examples/env.ts","../src/sqs/examples/step.ts","../src/sqs/examples/trigger.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './lambda/examples';\nexport * as sqsExamples from './sqs/examples';\n","// Lambda (default sub-source).\nexport { settings, SettingsSchema, type Settings } from './lambda/schemas';\nexport * from './lambda/schemas/primitives';\n\n// SQS sub-source. Prefixed so the website's <Configuration> snippet can\n// remap data.schemas.sqsSettings / sqsSetup onto data.schemas.settings.\nexport { settings as sqsSettings } from './sqs/schemas';\nexport { setup as sqsSetup } from './sqs/schemas';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export primitives\nexport * from './primitives';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema } from './primitives';\n\n/**\n * AWS Lambda source settings schema\n */\nexport const SettingsSchema = z.object({\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins, object = custom configuration',\n )\n .default(true),\n\n timeout: z\n .number()\n .int()\n .positive()\n .max(900000) // AWS Lambda max timeout: 15 minutes\n .describe('Request timeout in milliseconds (max: 900000 for Lambda)')\n .default(30000),\n\n enablePixelTracking: z\n .boolean()\n .describe(\n 'Enable GET requests with 1x1 transparent GIF response for pixel tracking',\n )\n .default(true),\n\n healthPath: z\n .string()\n .describe('Health check endpoint path (e.g., /health)')\n .default('/health'),\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 * 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","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { SetupSchema } from './setup';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { SetupSchema, type Setup } from './setup';\n\n// JSON Schema exports (for website PropertyTable + MCP package_get).\nexport const settings = zodToSchema(SettingsSchema);\nexport const setup = zodToSchema(SetupSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * AWS SQS source settings schema.\n *\n * Required: queueName. All other fields optional with sensible defaults\n * applied at runtime by `getConfig`.\n */\nexport const SettingsSchema = z.object({\n queueName: z\n .string()\n .min(1)\n .describe(\n 'SQS queue short name (like walkeros-events). Required for both setup and runtime poll.',\n ),\n region: z\n .string()\n .describe('AWS region (like eu-central-1). Default: eu-central-1.')\n .optional(),\n queueUrl: z\n .string()\n .url()\n .describe(\n 'Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.',\n )\n .optional(),\n client: z\n .any()\n .describe(\n 'Pre-configured AWS SQSClient instance. Bypasses construction when supplied.',\n )\n .optional(),\n config: z\n .any()\n .describe(\n 'AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).',\n )\n .optional(),\n decoder: z\n .enum(['json', 'text', 'raw'])\n .describe(\n 'Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.',\n )\n .optional(),\n maxMessages: z\n .number()\n .int()\n .min(1)\n .max(10)\n .describe('SQS receive batch size. Cap 10. Default: 10.')\n .optional(),\n waitTimeSeconds: z\n .number()\n .int()\n .min(0)\n .max(20)\n .describe('Long-poll duration in seconds. Cap 20. Default: 20.')\n .optional(),\n visibilityTimeout: z\n .number()\n .int()\n .nonnegative()\n .describe(\n 'Per-receive visibility timeout override. Default: queue-configured value.',\n )\n .optional(),\n shutdownTimeoutMs: z\n .number()\n .int()\n .positive()\n .describe(\n 'Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.',\n )\n .optional(),\n onPushError: z\n .enum(['nack', 'ack'])\n .describe(\n 'Behavior when forwarding to the collector throws. nack (default) skips DeleteMessage so the message redelivers; ack drops it.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * AWS SQS source setup schema.\n *\n * Provisioning options for `walkeros setup source.<id>`. Authoritative-apply:\n * declared state is written via a single CreateQueueCommand; non-declared\n * tags or attributes are left untouched.\n */\nconst TagsSchema = z.record(z.string(), z.string());\n\nexport const SetupSchema = z.object({\n region: z.string().min(1).describe('AWS region.').optional(),\n fifoQueue: z\n .boolean()\n .describe(\n 'FIFO queue with content-based deduplication. Auto-appends .fifo suffix to the queue name.',\n )\n .optional(),\n visibilityTimeoutSeconds: z\n .number()\n .int()\n .nonnegative()\n .describe('Visibility timeout in seconds. Default: 30.')\n .optional(),\n messageRetentionSeconds: z\n .number()\n .int()\n .positive()\n .describe('Message retention period in seconds. Default: 345600 (4 days).')\n .optional(),\n maximumMessageSize: z\n .number()\n .int()\n .min(1024)\n .max(262144)\n .describe('Max message size in bytes. Default: 262144 (256 KB).')\n .optional(),\n kmsMasterKeyId: z\n .string()\n .describe('KMS key alias or ID for at-rest encryption.')\n .optional(),\n deadLetterQueue: z\n .object({\n arn: z\n .string()\n .describe(\n 'ARN of an existing DLQ. Mutually exclusive with create: true.',\n )\n .optional(),\n create: z\n .boolean()\n .describe('Create a sibling DLQ named <queueName>-dlq. Default: false.')\n .optional(),\n maxReceiveCount: z\n .number()\n .int()\n .min(1)\n .max(1000)\n .describe('Max receive count before message goes to DLQ. Default: 5.')\n .optional(),\n })\n .describe('Optional dead-letter queue.')\n .optional(),\n tags: TagsSchema.describe(\n 'Tags applied to the queue (and inherited by an auto-created DLQ).',\n ).optional(),\n subscribeToSnsTopic: z\n .object({\n topicArn: z.string().min(1).describe('Topic ARN to subscribe to.'),\n rawMessageDelivery: z\n .boolean()\n .describe('Deliver SNS messages without the SNS envelope.')\n .optional(),\n filterPolicy: z\n .record(z.string(), z.unknown())\n .describe('SNS filter policy applied at subscription level.')\n .optional(),\n })\n .describe(\n 'Optional SNS topic subscription. Creates the subscription and the matching queue policy.',\n )\n .optional(),\n});\n\nexport type Setup = z.infer<typeof SetupSchema>;\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for AWS Lambda source\n *\n * These environments provide standardized mock structures for testing\n * Lambda event handling without requiring actual Lambda deployment.\n */\n\n// Create a properly typed elb/push/command function that returns a promise with PushResult\nconst createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n// Simple no-op logger for demo purposes\nconst noopFn = () => {};\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n warn: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noopFn,\n scope: () => noopLogger,\n};\n\n/**\n * Standard mock environment for testing Lambda source\n *\n * Use this for testing Lambda event ingestion and request/response handling\n * without requiring a real AWS Lambda environment.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const lambdaPost: Flow.StepExample = {\n title: 'Lambda POST',\n description:\n 'An API Gateway v2 HTTP POST with a JSON body is converted into a walker elb event.',\n trigger: { type: 'POST' },\n in: {\n version: '2.0',\n requestContext: {\n http: { method: 'POST', path: '/collect' },\n requestId: 'req-123',\n },\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home' },\n }),\n isBase64Encoded: false,\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n\nexport const apiGatewayV1Post: Flow.StepExample = {\n title: 'API Gateway v1 POST',\n description:\n 'A REST API Gateway v1 POST request with a JSON body is converted into a walker elb event.',\n trigger: { type: 'POST' },\n in: {\n httpMethod: 'POST',\n path: '/collect',\n requestContext: {\n requestId: 'req-789',\n identity: { sourceIp: '203.0.113.42' },\n },\n queryStringParameters: null,\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home' },\n }),\n isBase64Encoded: false,\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n\nexport const lambdaGet: Flow.StepExample = {\n title: 'Lambda GET',\n description:\n 'An API Gateway v2 HTTP GET with query parameters is parsed into an elb event payload.',\n trigger: { type: 'GET' },\n in: {\n version: '2.0',\n requestContext: {\n http: { method: 'GET', path: '/collect' },\n requestId: 'req-456',\n },\n rawQueryString: 'e=page+view&d=%7B%22title%22%3A%22Home%22%7D',\n isBase64Encoded: false,\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 type { LambdaEvent, LambdaContext, LambdaResult } from '../types';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n [key: string]: unknown;\n}\n\nexport interface Result {\n statusCode: number;\n body: unknown;\n headers: Record<string, string>;\n}\n\n/**\n * Find the lambda source instance from the collector's registered sources.\n */\nfunction findLambdaSource(collector: Collector.Instance) {\n for (const source of Object.values(collector.sources || {})) {\n if ((source as { type?: string }).type === 'lambda') return source;\n }\n}\n\n/**\n * Lambda source createTrigger.\n *\n * Boots the collector via startFlow, then invokes the Lambda source's push()\n * with a real API Gateway event and a minimal Lambda context.\n *\n * Content is the raw Lambda event object (API Gateway v1 or v2 format).\n * Result contains statusCode, parsed body, and headers.\n *\n * @example\n * const { trigger, flow } = await createTrigger(config);\n * const result = await trigger('POST')({ version: '2.0', ... });\n * console.log(result.statusCode, result.body);\n */\nconst createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n // Lazy startFlow\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n }\n\n const source = findLambdaSource(flow.collector);\n if (!source) throw new Error('Lambda source not found in collector');\n\n // Create minimal Lambda context\n const lambdaContext = {\n awsRequestId: `test-${Date.now()}`,\n } as unknown as LambdaContext;\n\n // Call source.push with the raw Lambda event + context\n const pushFn = (\n source as unknown as {\n push: (...args: unknown[]) => Promise<LambdaResult>;\n }\n ).push;\n const lambdaResult = await pushFn(\n content as unknown as LambdaEvent,\n lambdaContext,\n );\n\n // Parse response\n let body: unknown;\n try {\n body = JSON.parse(lambdaResult.body || '{}');\n } catch {\n body = lambdaResult.body;\n }\n\n const headers: Record<string, string> = {};\n if (lambdaResult.headers) {\n for (const [k, v] of Object.entries(lambdaResult.headers)) {\n if (v !== undefined) headers[k] = String(v);\n }\n }\n\n return {\n statusCode: lambdaResult.statusCode,\n body,\n headers,\n };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/**\n * Legacy trigger — takes a source instance directly.\n * Preserved for CLI simulate path.\n */\nfunction trigger(source: {\n push: (event: LambdaEvent, context: LambdaContext) => Promise<LambdaResult>;\n}): (content: Content) => Promise<LambdaResult> {\n return async (content: Content) => {\n const lambdaEvent = { ...(content as Record<string, unknown>) };\n\n // Adapt body format: step examples may use `name`, source expects `event`\n if (lambdaEvent.body && typeof lambdaEvent.body === 'string') {\n const body = JSON.parse(lambdaEvent.body);\n if (body.name && !body.event) {\n lambdaEvent.body = JSON.stringify({\n ...body,\n event: body.name,\n name: undefined,\n });\n }\n }\n\n const context: LambdaContext = {\n awsRequestId: 'test-req',\n } as unknown as LambdaContext;\n\n return source.push(lambdaEvent as unknown as LambdaEvent, context);\n };\n}\n\nexport { createTrigger, trigger };\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger } from './trigger';\nexport type { Content, Result } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment for the AWS SQS source.\n *\n * Tests substitute the real SDK via `jest.mock('@aws-sdk/client-sqs')` and\n * `jest.mock('@aws-sdk/client-sns')`, which is the canonical pattern: imports\n * of those modules get replaced module-wide, no env-injection plumbing\n * required at the call site.\n *\n * The `simulation` list documents which SDK identifiers the source touches\n * during a simulated run, used by the simulator to know what to stub.\n */\n\nconst noopFn = (): void => undefined;\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n warn: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noopFn,\n scope: () => noopLogger,\n};\n\nconst createMockElbFn = (): Elb.Fn => {\n const fn: Elb.Fn = () => Promise.resolve({ ok: true });\n return fn;\n};\n\n/**\n * Standard mock environment for the SQS source.\n *\n * AWS SDK constructors are intentionally absent: the canonical pattern is\n * module-level `jest.mock('@aws-sdk/client-sqs')` and -sns, not env-injection.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n\nexport const simulation = ['AWS.SQSClient'];\n","import type { Flow } from '@walkeros/core';\n\n/**\n * SQS source step examples.\n *\n * Each `in` is a partial SQS Message-like (MessageId, Body, optional\n * ReceiptHandle). The trigger synthesizes the missing fields and dispatches\n * through the source's `push()` (the same pipeline the long-poll loop uses).\n * `out` records the terminal state recorded by the trigger as\n * `[method, ...args]` entries.\n */\n\nconst eventPayload = {\n event: 'page view',\n data: { title: 'Documentation', url: 'https://example.com/docs' },\n};\n\nconst orderPayload = {\n event: 'order complete',\n data: { id: 'ORD-500', total: 199.99, currency: 'EUR' },\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view from SQS',\n description:\n 'A standard SQS message body containing a walker elb event payload as JSON.',\n in: {\n MessageId: 'm-1',\n Body: JSON.stringify(eventPayload),\n },\n out: [['message.ack', 'm-1']],\n};\n\nexport const orderComplete: Flow.StepExample = {\n title: 'Order complete from SQS',\n description: 'Order complete event flowing through the long-poll loop.',\n in: {\n MessageId: 'm-2',\n Body: JSON.stringify(orderPayload),\n },\n out: [['message.ack', 'm-2']],\n};\n\nexport const decoderText: Flow.StepExample = {\n title: 'Text decoder',\n description:\n 'When decoder is \"text\", the body string flows under data.payload.',\n in: { MessageId: 'm-3', Body: 'raw text payload' },\n out: [['message.ack', 'm-3']],\n};\n\nexport const malformedJson: Flow.StepExample = {\n title: 'Malformed JSON nacks',\n description:\n 'Default decoder is JSON. A malformed body throws DecoderError; the source nacks (skips DeleteMessage) so the message redelivers.',\n in: { MessageId: 'm-4', Body: '{not json' },\n out: [['message.nack', 'm-4']],\n};\n","import type { Collector, Trigger } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport type { SyntheticMessage, SyntheticPushResult } from '../types';\n\n/**\n * Content shape for the SQS source trigger.\n *\n * The trigger synthesizes a SyntheticMessage from this partial input and\n * dispatches it through the source's `push()` (the same pipeline the\n * long-poll loop uses).\n */\nexport interface Content {\n MessageId: string;\n Body: string;\n ReceiptHandle?: string;\n Attributes?: Record<string, string>;\n MessageAttributes?: Record<\n string,\n { DataType: string; StringValue?: string }\n >;\n}\n\n/**\n * Trigger result: the recorded ack/nack as `[method, MessageId]` entries.\n * Mirrors the destination's `[method, ...args]` recording shape.\n */\nexport type Result = Array<[string, ...unknown[]]>;\n\ninterface SqsSourceLike {\n type: string;\n push: (content?: SyntheticMessage) => Promise<SyntheticPushResult | void>;\n}\n\nfunction isSqsSource(value: unknown): value is SqsSourceLike {\n if (typeof value !== 'object' || value === null) return false;\n const candidate: { type?: unknown; push?: unknown } = value;\n return candidate.type === 'sqs' && typeof candidate.push === 'function';\n}\n\nfunction findSource(collector: Collector.Instance): SqsSourceLike | undefined {\n for (const source of Object.values(collector.sources ?? {})) {\n if (isSqsSource(source)) return source;\n }\n return undefined;\n}\n\n/**\n * SQS source createTrigger.\n *\n * Boots the collector via startFlow, finds the registered SQS source, and\n * invokes its `push()` with a synthesized message. The source dispatches the\n * synthetic message through the same handler the long-poll loop uses,\n * exercising the full decode / forward / ack-nack pipeline without touching\n * real SQS infrastructure.\n */\nexport const createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n }\n\n const source = findSource(flow.collector);\n if (!source) {\n throw new Error(\n 'sqs source not registered in collector, ensure it is configured in sources',\n );\n }\n\n const synthetic: SyntheticMessage = {\n MessageId: content.MessageId,\n Body: content.Body,\n ReceiptHandle: content.ReceiptHandle,\n Attributes: content.Attributes,\n MessageAttributes: content.MessageAttributes,\n };\n\n const result = await source.push(synthetic);\n const recorded: Result = [];\n if (result && typeof result === 'object') {\n if (result.acked) recorded.push(['message.ack', content.MessageId]);\n if (result.nacked) recorded.push(['message.nack', content.MessageId]);\n }\n return recorded;\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAAC;AAAA,EAAA;AAAA;;;ACAA,IAAAC,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;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,yBAAyB,EAAE,SAAS;AAAA,EAE1E,aAAa,aACV,QAAQ,EACR,SAAS,oDAAoD,EAC7D,SAAS;AAAA,EAEZ,QAAQ,aACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,qCAAqC,EAC9C,SAAS;AACd,CAAC;;;AD9CM,IAAM,iBAAiB,cAAE,OAAO;AAAA,EACrC,MAAM,cACH,MAAM,CAAC,cAAE,QAAQ,GAAG,iBAAiB,CAAC,EACtC;AAAA,IACC;AAAA,EACF,EACC,QAAQ,IAAI;AAAA,EAEf,SAAS,cACN,OAAO,EACP,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AAO;AACT;AAWO,IAAMC,iBAAmD,OAC9D,WACG;AACH,MAAI;AAEJ,QAAMC,WACJ,MACA,OAAO,YAAsC;AAC3C,QAAI,CAAC,MAAM;AACT,YAAMC,UAAS,MAAM,GAAU,MAAM;AACrC,aAAO,EAAE,WAAWA,QAAO,WAAW,KAAKA,QAAO,IAAI;AAAA,IACxD;AAEA,UAAM,SAAS,WAAW,KAAK,SAAS;AACxC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAA8B;AAAA,MAClC,WAAW,QAAQ;AAAA,MACnB,MAAM,QAAQ;AAAA,MACd,eAAe,QAAQ;AAAA,MACvB,YAAY,QAAQ;AAAA,MACpB,mBAAmB,QAAQ;AAAA,IAC7B;AAEA,UAAM,SAAS,MAAM,OAAO,KAAK,SAAS;AAC1C,UAAM,WAAmB,CAAC;AAC1B,QAAI,UAAU,OAAO,WAAW,UAAU;AACxC,UAAI,OAAO,MAAO,UAAS,KAAK,CAAC,eAAe,QAAQ,SAAS,CAAC;AAClE,UAAI,OAAO,OAAQ,UAAS,KAAK,CAAC,gBAAgB,QAAQ,SAAS,CAAC;AAAA,IACtE;AACA,WAAO;AAAA,EACT;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA,SAAAD;AAAA,EACF;AACF;","names":["examples_exports","settings","import_dev","import_dev","import_dev","import_dev","SettingsSchema","import_dev","settings","SettingsSchema","trigger","k","v","examples_exports","createTrigger","env_exports","step_exports","env_exports","push","noopFn","noopLogger","createMockElbFn","step_exports","createTrigger","trigger","result"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas.ts","../src/lambda/schemas/index.ts","../src/lambda/schemas/settings.ts","../src/lambda/schemas/primitives.ts","../src/sqs/schemas/index.ts","../src/sqs/schemas/settings.ts","../src/sqs/schemas/setup.ts","../src/lambda/examples/index.ts","../src/lambda/examples/env.ts","../src/lambda/examples/step.ts","../src/lambda/examples/trigger.ts","../src/sqs/examples/index.ts","../src/sqs/examples/env.ts","../src/sqs/examples/step.ts","../src/sqs/examples/trigger.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './lambda/examples';\nexport * as sqsExamples from './sqs/examples';\n","// Lambda (default sub-source).\nexport { settings, SettingsSchema, type Settings } from './lambda/schemas';\nexport * from './lambda/schemas/primitives';\n\n// SQS sub-source. Prefixed so the website's <Configuration> snippet can\n// remap data.schemas.sqsSettings / sqsSetup onto data.schemas.settings.\nexport { settings as sqsSettings } from './sqs/schemas';\nexport { setup as sqsSetup } from './sqs/schemas';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export primitives\nexport * from './primitives';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema } from './primitives';\n\n/**\n * AWS Lambda source settings schema\n */\nexport const SettingsSchema = z.object({\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins, object = custom configuration',\n )\n .default(true),\n\n timeout: z\n .number()\n .int()\n .positive()\n .max(900000) // AWS Lambda max timeout: 15 minutes\n .describe('Request timeout in milliseconds (max: 900000 for Lambda)')\n .default(30000),\n\n enablePixelTracking: z\n .boolean()\n .describe(\n 'Enable GET requests with 1x1 transparent GIF response for pixel tracking',\n )\n .default(true),\n\n healthPath: z\n .string()\n .describe('Health check endpoint path (e.g., /health)')\n .default('/health'),\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 * 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","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { SetupSchema } from './setup';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { SetupSchema, type Setup } from './setup';\n\n// JSON Schema exports (for website PropertyTable + MCP package_get).\nexport const settings = zodToSchema(SettingsSchema);\nexport const setup = zodToSchema(SetupSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * AWS SQS source settings schema.\n *\n * Required: queueName. All other fields optional with sensible defaults\n * applied at runtime by `getConfig`.\n */\nexport const SettingsSchema = z.object({\n queueName: z\n .string()\n .min(1)\n .describe(\n 'SQS queue short name (like walkeros-events). Required for both setup and runtime poll.',\n ),\n region: z\n .string()\n .describe('AWS region (like eu-central-1). Default: eu-central-1.')\n .optional(),\n queueUrl: z\n .string()\n .url()\n .describe(\n 'Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.',\n )\n .optional(),\n client: z\n .any()\n .describe(\n 'Pre-configured AWS SQSClient instance. Bypasses construction when supplied.',\n )\n .optional(),\n config: z\n .any()\n .describe(\n 'AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).',\n )\n .optional(),\n decoder: z\n .enum(['json', 'text', 'raw'])\n .describe(\n 'Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.',\n )\n .optional(),\n maxMessages: z\n .number()\n .int()\n .min(1)\n .max(10)\n .describe('SQS receive batch size. Cap 10. Default: 10.')\n .optional(),\n waitTimeSeconds: z\n .number()\n .int()\n .min(0)\n .max(20)\n .describe('Long-poll duration in seconds. Cap 20. Default: 20.')\n .optional(),\n visibilityTimeout: z\n .number()\n .int()\n .nonnegative()\n .describe(\n 'Per-receive visibility timeout override. Default: queue-configured value.',\n )\n .optional(),\n shutdownTimeoutMs: z\n .number()\n .int()\n .positive()\n .describe(\n 'Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.',\n )\n .optional(),\n onPushError: z\n .enum(['nack', 'ack'])\n .describe(\n 'Behavior when forwarding to the collector throws. nack (default) skips DeleteMessage so the message redelivers; ack drops it.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * AWS SQS source setup schema.\n *\n * Provisioning options for `walkeros setup source.<id>`. Authoritative-apply:\n * declared state is written via a single CreateQueueCommand; non-declared\n * tags or attributes are left untouched.\n */\nconst TagsSchema = z.record(z.string(), z.string());\n\nexport const SetupSchema = z.object({\n region: z.string().min(1).describe('AWS region.').optional(),\n fifoQueue: z\n .boolean()\n .describe(\n 'FIFO queue with content-based deduplication. Auto-appends .fifo suffix to the queue name.',\n )\n .optional(),\n visibilityTimeoutSeconds: z\n .number()\n .int()\n .nonnegative()\n .describe('Visibility timeout in seconds. Default: 30.')\n .optional(),\n messageRetentionSeconds: z\n .number()\n .int()\n .positive()\n .describe('Message retention period in seconds. Default: 345600 (4 days).')\n .optional(),\n maximumMessageSize: z\n .number()\n .int()\n .min(1024)\n .max(262144)\n .describe('Max message size in bytes. Default: 262144 (256 KB).')\n .optional(),\n kmsMasterKeyId: z\n .string()\n .describe('KMS key alias or ID for at-rest encryption.')\n .optional(),\n deadLetterQueue: z\n .object({\n arn: z\n .string()\n .describe(\n 'ARN of an existing DLQ. Mutually exclusive with create: true.',\n )\n .optional(),\n create: z\n .boolean()\n .describe('Create a sibling DLQ named <queueName>-dlq. Default: false.')\n .optional(),\n maxReceiveCount: z\n .number()\n .int()\n .min(1)\n .max(1000)\n .describe('Max receive count before message goes to DLQ. Default: 5.')\n .optional(),\n })\n .describe('Optional dead-letter queue.')\n .optional(),\n tags: TagsSchema.describe(\n 'Tags applied to the queue (and inherited by an auto-created DLQ).',\n ).optional(),\n subscribeToSnsTopic: z\n .object({\n topicArn: z.string().min(1).describe('Topic ARN to subscribe to.'),\n rawMessageDelivery: z\n .boolean()\n .describe('Deliver SNS messages without the SNS envelope.')\n .optional(),\n filterPolicy: z\n .record(z.string(), z.unknown())\n .describe('SNS filter policy applied at subscription level.')\n .optional(),\n })\n .describe(\n 'Optional SNS topic subscription. Creates the subscription and the matching queue policy.',\n )\n .optional(),\n});\n\nexport type Setup = z.infer<typeof SetupSchema>;\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for AWS Lambda source\n *\n * These environments provide standardized mock structures for testing\n * Lambda event handling without requiring actual Lambda deployment.\n */\n\n// Create a properly typed elb/push/command function that returns a promise with PushResult\nconst createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n// Simple no-op logger for demo purposes\nconst noopFn = () => {};\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n warn: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noopFn,\n scope: () => noopLogger,\n};\n\n/**\n * Standard mock environment for testing Lambda source\n *\n * Use this for testing Lambda event ingestion and request/response handling\n * without requiring a real AWS Lambda environment.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const lambdaPost: Flow.StepExample = {\n title: 'Lambda POST',\n description:\n 'An API Gateway v2 HTTP POST with a JSON body is converted into a walker elb event.',\n trigger: { type: 'POST' },\n in: {\n version: '2.0',\n requestContext: {\n http: { method: 'POST', path: '/collect' },\n requestId: 'req-123',\n },\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home' },\n }),\n isBase64Encoded: false,\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n\nexport const apiGatewayV1Post: Flow.StepExample = {\n title: 'API Gateway v1 POST',\n description:\n 'A REST API Gateway v1 POST request with a JSON body is converted into a walker elb event.',\n trigger: { type: 'POST' },\n in: {\n httpMethod: 'POST',\n path: '/collect',\n requestContext: {\n requestId: 'req-789',\n identity: { sourceIp: '203.0.113.42' },\n },\n queryStringParameters: null,\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home' },\n }),\n isBase64Encoded: false,\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n\nexport const lambdaGet: Flow.StepExample = {\n title: 'Lambda GET',\n description:\n 'An API Gateway v2 HTTP GET with query parameters is parsed into an elb event payload.',\n trigger: { type: 'GET' },\n in: {\n version: '2.0',\n requestContext: {\n http: { method: 'GET', path: '/collect' },\n requestId: 'req-456',\n },\n rawQueryString: 'e=page+view&d=%7B%22title%22%3A%22Home%22%7D',\n isBase64Encoded: false,\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 type { LambdaEvent, LambdaContext, LambdaResult } from '../types';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n [key: string]: unknown;\n}\n\nexport interface Result {\n statusCode: number;\n body: unknown;\n headers: Record<string, string>;\n}\n\n/**\n * Find the lambda source instance from the collector's registered sources.\n */\nfunction findLambdaSource(collector: Collector.Instance) {\n for (const source of Object.values(collector.sources || {})) {\n if ((source as { type?: string }).type === 'lambda') return source;\n }\n}\n\n/**\n * Lambda source createTrigger.\n *\n * Boots the collector via startFlow, then invokes the Lambda source's push()\n * with a real API Gateway event and a minimal Lambda context.\n *\n * Content is the raw Lambda event object (API Gateway v1 or v2 format).\n * Result contains statusCode, parsed body, and headers.\n *\n * @example\n * const { trigger, flow } = await createTrigger(config);\n * const result = await trigger('POST')({ version: '2.0', ... });\n * console.log(result.statusCode, result.body);\n */\nconst createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n // Lazy startFlow\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n }\n\n const source = findLambdaSource(flow.collector);\n if (!source) throw new Error('Lambda source not found in collector');\n\n // Create minimal Lambda context\n const lambdaContext = {\n awsRequestId: `test-${Date.now()}`,\n } as unknown as LambdaContext;\n\n // Call source.push with the raw Lambda event + context\n const pushFn = (\n source as unknown as {\n push: (...args: unknown[]) => Promise<LambdaResult>;\n }\n ).push;\n const lambdaResult = await pushFn(\n content as unknown as LambdaEvent,\n lambdaContext,\n );\n\n // Parse response\n let body: unknown;\n try {\n body = JSON.parse(lambdaResult.body || '{}');\n } catch {\n body = lambdaResult.body;\n }\n\n const headers: Record<string, string> = {};\n if (lambdaResult.headers) {\n for (const [k, v] of Object.entries(lambdaResult.headers)) {\n if (v !== undefined) headers[k] = String(v);\n }\n }\n\n return {\n statusCode: lambdaResult.statusCode,\n body,\n headers,\n };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/**\n * Legacy trigger — takes a source instance directly.\n * Preserved for CLI simulate path.\n */\nfunction trigger(source: {\n push: (event: LambdaEvent, context: LambdaContext) => Promise<LambdaResult>;\n}): (content: Content) => Promise<LambdaResult> {\n return async (content: Content) => {\n const lambdaEvent = { ...(content as Record<string, unknown>) };\n\n // Adapt body format: step examples may use `name`, source expects `event`\n if (lambdaEvent.body && typeof lambdaEvent.body === 'string') {\n const body = JSON.parse(lambdaEvent.body);\n if (body.name && !body.event) {\n lambdaEvent.body = JSON.stringify({\n ...body,\n event: body.name,\n name: undefined,\n });\n }\n }\n\n const context: LambdaContext = {\n awsRequestId: 'test-req',\n } as unknown as LambdaContext;\n\n return source.push(lambdaEvent as unknown as LambdaEvent, context);\n };\n}\n\nexport { createTrigger, trigger };\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger } from './trigger';\nexport type { Content, Result } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment for the AWS SQS source.\n *\n * Tests substitute the real SDK via `jest.mock('@aws-sdk/client-sqs')` and\n * `jest.mock('@aws-sdk/client-sns')`, which is the canonical pattern: imports\n * of those modules get replaced module-wide, no env-injection plumbing\n * required at the call site.\n *\n * The `simulation` list documents which SDK identifiers the source touches\n * during a simulated run, used by the simulator to know what to stub.\n */\n\nconst noopFn = (): void => undefined;\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n warn: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noopFn,\n scope: () => noopLogger,\n};\n\nconst createMockElbFn = (): Elb.Fn => {\n const fn: Elb.Fn = () => Promise.resolve({ ok: true });\n return fn;\n};\n\n/**\n * Standard mock environment for the SQS source.\n *\n * AWS SDK constructors are intentionally absent: the canonical pattern is\n * module-level `jest.mock('@aws-sdk/client-sqs')` and -sns, not env-injection.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n\nexport const simulation = ['AWS.SQSClient'];\n","import type { Flow } from '@walkeros/core';\n\n/**\n * SQS source step examples.\n *\n * Each `in` is a partial SQS Message-like (MessageId, Body, optional\n * ReceiptHandle). The trigger synthesizes the missing fields and dispatches\n * through the source's `push()` (the same pipeline the long-poll loop uses).\n * `out` records the terminal state recorded by the trigger as\n * `[method, ...args]` entries.\n */\n\nconst eventPayload = {\n event: 'page view',\n data: { title: 'Documentation', url: 'https://example.com/docs' },\n};\n\nconst orderPayload = {\n event: 'order complete',\n data: { id: 'ORD-500', total: 199.99, currency: 'EUR' },\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view from SQS',\n description:\n 'A standard SQS message body containing a walker elb event payload as JSON.',\n in: {\n MessageId: 'm-1',\n Body: JSON.stringify(eventPayload),\n },\n out: [['message.ack', 'm-1']],\n};\n\nexport const orderComplete: Flow.StepExample = {\n title: 'Order complete from SQS',\n description: 'Order complete event flowing through the long-poll loop.',\n in: {\n MessageId: 'm-2',\n Body: JSON.stringify(orderPayload),\n },\n out: [['message.ack', 'm-2']],\n};\n\nexport const decoderText: Flow.StepExample = {\n title: 'Text decoder',\n description:\n 'When decoder is \"text\", the body string flows under data.payload.',\n in: { MessageId: 'm-3', Body: 'raw text payload' },\n out: [['message.ack', 'm-3']],\n};\n\nexport const malformedJson: Flow.StepExample = {\n title: 'Malformed JSON nacks',\n description:\n 'Default decoder is JSON. A malformed body throws DecoderError; the source nacks (skips DeleteMessage) so the message redelivers.',\n in: { MessageId: 'm-4', Body: '{not json' },\n out: [['message.nack', 'm-4']],\n};\n","import type { Collector, Trigger } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport type { SyntheticMessage, SyntheticPushResult } from '../types';\n\n/**\n * Content shape for the SQS source trigger.\n *\n * The trigger synthesizes a SyntheticMessage from this partial input and\n * dispatches it through the source's `push()` (the same pipeline the\n * long-poll loop uses).\n */\nexport interface Content {\n MessageId: string;\n Body: string;\n ReceiptHandle?: string;\n Attributes?: Record<string, string>;\n MessageAttributes?: Record<\n string,\n { DataType: string; StringValue?: string }\n >;\n}\n\n/**\n * Trigger result: the recorded ack/nack as `[method, MessageId]` entries.\n * Mirrors the destination's `[method, ...args]` recording shape.\n */\nexport type Result = Array<[string, ...unknown[]]>;\n\ninterface SqsSourceLike {\n type: string;\n push: (content?: SyntheticMessage) => Promise<SyntheticPushResult | void>;\n}\n\nfunction isSqsSource(value: unknown): value is SqsSourceLike {\n if (typeof value !== 'object' || value === null) return false;\n const candidate: { type?: unknown; push?: unknown } = value;\n return candidate.type === 'sqs' && typeof candidate.push === 'function';\n}\n\nfunction findSource(collector: Collector.Instance): SqsSourceLike | undefined {\n for (const source of Object.values(collector.sources ?? {})) {\n if (isSqsSource(source)) return source;\n }\n return undefined;\n}\n\n/**\n * SQS source createTrigger.\n *\n * Boots the collector via startFlow, finds the registered SQS source, and\n * invokes its `push()` with a synthesized message. The source dispatches the\n * synthetic message through the same handler the long-poll loop uses,\n * exercising the full decode / forward / ack-nack pipeline without touching\n * real SQS infrastructure.\n */\nexport const createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n }\n\n const source = findSource(flow.collector);\n if (!source) {\n throw new Error(\n 'sqs source not registered in collector, ensure it is configured in sources',\n );\n }\n\n const synthetic: SyntheticMessage = {\n MessageId: content.MessageId,\n Body: content.Body,\n ReceiptHandle: content.ReceiptHandle,\n Attributes: content.Attributes,\n MessageAttributes: content.MessageAttributes,\n };\n\n const result = await source.push(synthetic);\n const recorded: Result = [];\n if (result && typeof result === 'object') {\n if (result.acked) recorded.push(['message.ack', content.MessageId]);\n if (result.nacked) recorded.push(['message.nack', content.MessageId]);\n }\n return recorded;\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;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O,WAAW,KAAKA,QAAO,IAAI;AAAA,IACxD;AAEA,UAAM,SAAS,WAAW,KAAK,SAAS;AACxC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAA8B;AAAA,MAClC,WAAW,QAAQ;AAAA,MACnB,MAAM,QAAQ;AAAA,MACd,eAAe,QAAQ;AAAA,MACvB,YAAY,QAAQ;AAAA,MACpB,mBAAmB,QAAQ;AAAA,IAC7B;AAEA,UAAM,SAAS,MAAM,OAAO,KAAK,SAAS;AAC1C,UAAM,WAAmB,CAAC;AAC1B,QAAI,UAAU,OAAO,WAAW,UAAU;AACxC,UAAI,OAAO,MAAO,UAAS,KAAK,CAAC,eAAe,QAAQ,SAAS,CAAC;AAClE,UAAI,OAAO,OAAQ,UAAS,KAAK,CAAC,gBAAgB,QAAQ,SAAS,CAAC;AAAA,IACtE;AACA,WAAO;AAAA,EACT;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA,SAAAD;AAAA,EACF;AACF;","names":["examples_exports","settings","import_dev","import_dev","import_dev","import_dev","SettingsSchema","import_dev","settings","SettingsSchema","trigger","k","v","examples_exports","createTrigger","env_exports","step_exports","env_exports","push","noopFn","noopLogger","createMockElbFn","step_exports","createTrigger","trigger","result"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})},n={};t(n,{CorsOptionsSchema:()=>c,CorsOrigin:()=>a,HttpMethod:()=>i,SettingsSchema:()=>u,settings:()=>l,sqsSettings:()=>y,sqsSetup:()=>w});import{zodToSchema as o}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";import{z as r}from"@walkeros/core/dev";var i=r.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),a=r.union([r.string(),r.array(r.string()),r.literal("*")]),c=r.object({origin:a.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:r.array(i).describe("Allowed HTTP methods").optional(),headers:r.array(r.string()).describe("Allowed request headers").optional(),credentials:r.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:r.number().int().positive().describe("Preflight cache duration in seconds").optional()}),u=s.object({cors:s.union([s.boolean(),c]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").default(!0),timeout:s.number().int().positive().max(9e5).describe("Request timeout in milliseconds (max: 900000 for Lambda)").default(3e4),enablePixelTracking:s.boolean().describe("Enable GET requests with 1x1 transparent GIF response for pixel tracking").default(!0),healthPath:s.string().describe("Health check endpoint path (e.g., /health)").default("/health")}),l=o(u);import{zodToSchema as d}from"@walkeros/core/dev";import{z as f}from"@walkeros/core/dev";var p=f.object({queueName:f.string().min(1).describe("SQS queue short name (like walkeros-events). Required for both setup and runtime poll."),region:f.string().describe("AWS region (like eu-central-1). Default: eu-central-1.").optional(),queueUrl:f.string().url().describe("Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.").optional(),client:f.any().describe("Pre-configured AWS SQSClient instance. Bypasses construction when supplied.").optional(),config:f.any().describe("AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).").optional(),decoder:f.enum(["json","text","raw"]).describe("Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.").optional(),maxMessages:f.number().int().min(1).max(10).describe("SQS receive batch size. Cap 10. Default: 10.").optional(),waitTimeSeconds:f.number().int().min(0).max(20).describe("Long-poll duration in seconds. Cap 20. Default: 20.").optional(),visibilityTimeout:f.number().int().nonnegative().describe("Per-receive visibility timeout override. Default: queue-configured value.").optional(),shutdownTimeoutMs:f.number().int().positive().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.").optional(),onPushError:f.enum(["nack","ack"]).describe("Behavior when forwarding to the collector throws. nack (default) skips DeleteMessage so the message redelivers; ack drops it.").optional()});import{z as g}from"@walkeros/core/dev";var h=g.record(g.string(),g.string()),m=g.object({region:g.string().min(1).describe("AWS region.").optional(),fifoQueue:g.boolean().describe("FIFO queue with content-based deduplication. Auto-appends .fifo suffix to the queue name.").optional(),visibilityTimeoutSeconds:g.number().int().nonnegative().describe("Visibility timeout in seconds. Default: 30.").optional(),messageRetentionSeconds:g.number().int().positive().describe("Message retention period in seconds. Default: 345600 (4 days).").optional(),maximumMessageSize:g.number().int().min(1024).max(262144).describe("Max message size in bytes. Default: 262144 (256 KB).").optional(),kmsMasterKeyId:g.string().describe("KMS key alias or ID for at-rest encryption.").optional(),deadLetterQueue:g.object({arn:g.string().describe("ARN of an existing DLQ. Mutually exclusive with create: true.").optional(),create:g.boolean().describe("Create a sibling DLQ named <queueName>-dlq. Default: false.").optional(),maxReceiveCount:g.number().int().min(1).max(1e3).describe("Max receive count before message goes to DLQ. Default: 5.").optional()}).describe("Optional dead-letter queue.").optional(),tags:h.describe("Tags applied to the queue (and inherited by an auto-created DLQ).").optional(),subscribeToSnsTopic:g.object({topicArn:g.string().min(1).describe("Topic ARN to subscribe to."),rawMessageDelivery:g.boolean().describe("Deliver SNS messages without the SNS envelope.").optional(),filterPolicy:g.record(g.string(),g.unknown()).describe("SNS filter policy applied at subscription level.").optional()}).describe("Optional SNS topic subscription. Creates the subscription and the matching queue policy.").optional()}),y=d(p),w=d(m),v={};t(v,{createTrigger:()=>an,env:()=>b,step:()=>O,trigger:()=>cn});var b={};t(b,{push:()=>I});var k=()=>()=>Promise.resolve({ok:!0}),S=()=>{},q={error:S,warn:S,info:S,debug:S,throw:e=>{throw"string"==typeof e?new Error(e):e},json:S,scope:()=>q},I={get push(){return k()},get command(){return k()},get elb(){return k()},logger:q},O={};t(O,{apiGatewayV1Post:()=>C,lambdaGet:()=>j,lambdaPost:()=>x});var x={title:"Lambda POST",description:"An API Gateway v2 HTTP POST with a JSON body is converted into a walker elb event.",trigger:{type:"POST"},in:{version:"2.0",requestContext:{http:{method:"POST",path:"/collect"},requestId:"req-123"},body:JSON.stringify({event:"page view",data:{title:"Home"}}),isBase64Encoded:!1},out:[["elb",{name:"page view",data:{title:"Home"}}]]},C={title:"API Gateway v1 POST",description:"A REST API Gateway v1 POST request with a JSON body is converted into a walker elb event.",trigger:{type:"POST"},in:{httpMethod:"POST",path:"/collect",requestContext:{requestId:"req-789",identity:{sourceIp:"203.0.113.42"}},queryStringParameters:null,body:JSON.stringify({event:"page view",data:{title:"Home"}}),isBase64Encoded:!1},out:[["elb",{name:"page view",data:{title:"Home"}}]]},j={title:"Lambda GET",description:"An API Gateway v2 HTTP GET with query parameters is parsed into an elb event payload.",trigger:{type:"GET"},in:{version:"2.0",requestContext:{http:{method:"GET",path:"/collect"},requestId:"req-456"},rawQueryString:"e=page+view&d=%7B%22title%22%3A%22Home%22%7D",isBase64Encoded:!1},out:[["elb",{e:"page view",d:'{"title":"Home"}'}]]};import{assign as A}from"@walkeros/core";import{assign as D,createLogger as T}from"@walkeros/core";import{assign as E,buildCacheContext as M,clone as P,compileCache as $,checkCache as _,storeCache as R,createIngest as H,debounce as G,emitStep as N,getId as B,getGrantedConsent as z,getNextSteps as F,isDefined as L,isFunction as U,isObject as K,processEventMapping as Q,stepId as J,tryCatchAsync as W,useHooks as V,compileState as Y,applyState as X}from"@walkeros/core";import{emitStep as Z}from"@walkeros/core";import{isArray as ee,FatalError as te}from"@walkeros/core";import{tryCatch as ne,tryCatchAsync as oe}from"@walkeros/core";import{createIngest as se,FatalError as re,getMappingValue as ie,tryCatchAsync as ae,getNextSteps as ce,compileCache as ue,checkCache as le,storeCache as de,applyUpdate as fe,buildCacheContext as pe,compileState as ge,applyState as he}from"@walkeros/core";import{createIngest as me,emitStep as ye,FatalError as we,isObject as ve,stepId as be,tryCatchAsync as ke,useHooks as Se,getNextSteps as qe,compileCache as Ie,checkCache as Oe,storeCache as xe,buildCacheContext as Ce,validateStepEntry as je,processEventMapping as Ae,compileState as De,applyState as Te}from"@walkeros/core";import{assign as Ee,getSpanId as Me,isFunction as Pe,isString as $e}from"@walkeros/core";import{isObject as _e}from"@walkeros/core";import{createIngest as Re,emitStep as He,FatalError as Ge,getGrantedConsent as Ne,processEventMapping as Be,tryCatchAsync as ze,useHooks as Fe}from"@walkeros/core";import{FatalError as Le,useHooks as Ue,tryCatchAsync as Ke}from"@walkeros/core";import{emitStep as Qe,useHooks as Je}from"@walkeros/core";import{compileMatcher as We,emitStep as Ve,readCacheEnvelope as Ye,wrapCacheEnvelope as Xe}from"@walkeros/core";var Ze={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Scoped:"_",Session:"session",Shutdown:"shutdown",User:"user",Walker:"walker"};function et(e,t){const n=e.status.startedAt;return{flowId:"default",stepId:t.stepId,stepType:t.stepType,phase:t.phase,eventId:t.eventId,timestamp:new Date(t.now).toISOString(),elapsedMs:t.now-n}}function tt(e,t){return e.storeId&&t.stores[e.storeId]?t.stores[e.storeId]:t.stores.__cache}function nt(e,t){return e?t.stores[e]:t.stores.__cache}function ot(e){const t={};for(const[n,o]of Object.entries(e)){const e=o.config?.next;"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?t[n]={next:e}:t[n]={}}return t}function st(e,t){const n=e.config||{},o=e[t];return void 0!==o?{config:{...n,[t]:o},chainValue:o}:{config:n,chainValue:void 0}}function rt(e,t={}){if(!e)return[];if(Array.isArray(e))return e;const n=[],o=new Set;let s=e;for(;s&&t[s]&&!o.has(s);){o.add(s),n.push(s);const e=t[s].next;if(Array.isArray(e)){n.push(...e);break}s=e}return n}async function it(e,t,n){if(t.init&&!t.config.init){const o=t.type||"unknown",s=e.logger.scope(`transformer:${o}`),r={collector:e,logger:s,id:n,ingest:me(n),config:t.config,env:lt(t.config.env)};s.debug("init");const i=await Se(t.init,"TransformerInit",e.hooks,e.logger)(r);if(!1===i)return!1;t.config={...i||t.config,env:i?.env||t.config.env,init:!0},s.debug("init done")}return!0}async function at(e,t,n,o,s,r){const i=t.type||"unknown",a=e.logger.scope(`transformer:${i}`),c={collector:e,logger:a,id:n,ingest:s,config:t.config,env:{...lt(t.config.env),...r?{respond:r}:{}}};a.debug("push",{event:o.name});const u="string"==typeof o.id?o.id:"",l=Date.now(),d=et(e,{stepId:be("transformer",n),stepType:"transformer",phase:"in",eventId:u,now:l});ye(e,d);try{const s=await Se(t.push,"TransformerPush",e.hooks,e.logger)(o,c),r=Date.now(),i=et(e,{stepId:be("transformer",n),stepType:"transformer",phase:"out",eventId:u,now:r});return i.durationMs=r-l,i.outEvent=s,ye(e,i),a.debug("push done"),s}catch(t){const o=Date.now(),s=et(e,{stepId:be("transformer",n),stepType:"transformer",phase:"error",eventId:u,now:o});throw s.durationMs=o-l,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},ye(e,s),t}}function ct(e,t){return e?{...e,_meta:{...e._meta,path:[...e._meta.path]}}:me(t)}async function ut(e,t,n,o,s,r,i){s||(s=me(n[0]??"chain")),i&&s._meta&&(s._meta.chainPath=i);let a=o,c=r;for(const o of n){const r=t[o];if(!r){e.logger.warn(`Transformer not found: ${o}`);continue}if(s&&s._meta&&s._meta.path.length>256)return e.logger.error(`Max path length exceeded at ${o}`),{event:null,respond:c};if(s&&s._meta&&(s._meta.hops++,s._meta.path.push(o)),!await ke(it,t=>{if(t instanceof we)throw t;return e.status.failed++,e.logger.scope(`transformer:${r.type||"unknown"}`).error("transformer init failed",{transformer:o,error:t}),!1})(e,r,o))return{event:null,respond:c};if(i&&void 0!==r.config?.chainMocks?.[i]){const t=r.config.chainMocks[i];e.logger.scope(`transformer:${r.type||"unknown"}`).debug("chainMock",{chain:i}),a=t;continue}if(void 0!==r.config?.mock){e.logger.scope(`transformer:${r.type||"unknown"}`).debug("mock"),a=r.config.mock;continue}if(r.config?.disabled)continue;const u=r.config?.cache,l=u?Ie(u):void 0,d=l?tt(l,e):void 0,f=r.config?.state?De(r.config.state):void 0,p=f?.filter(e=>"get"===e.mode),g=f?.filter(e=>"set"===e.mode),h=async t=>g&&0!==g.length?Te(g,t=>nt(t,e),t,e):t;let m;if(l&&d){const e=Ce(s,a),t=await Oe(l,d,e);if("HIT"===t?.status&&t.value){if(a=t.value,l.stop)return{event:a,respond:c,stopped:!0};continue}"MISS"===t?.status&&(m={key:t.key,ttl:t.rule.ttl})}const y=r.config.before;if(y){const n=qe(y,Ce(s,a));if(1===n.length){const o=rt(n[0],ot(t));if(o.length>0){const n=await ut(e,t,o,a,s,c,i);if(null===n.event)return{event:null,respond:n.respond??c};if(n.stopped)return{event:Array.isArray(n.event)?n.event[0]:n.event,respond:n.respond??c,stopped:!0};n.respond&&(c=n.respond),a=Array.isArray(n.event)?n.event[0]:n.event}}else n.length>1&&await Promise.all(n.map(n=>ke(ut,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,rt(n,ot(t)),a,ct(s,n),void 0,i)))}p&&p.length>0&&(a=await Te(p,t=>nt(t,e),a,e));const w=await ke(at,t=>(e.logger.scope(`transformer:${r.type||"unknown"}`).error("Push failed",{error:t}),!1))(e,r,o,a,s,c);if(!1===w)return{event:null,respond:c};if(Array.isArray(w)){const r=n.slice(n.indexOf(o)+1),u=await Promise.all(w.map(async n=>{const o=await h(n.event||a),u=ct(s,"unknown");if(n.next){const s=qe(n.next,Ce(u,o));if(0===s.length)return{event:o,respond:c};if(1===s.length){const n=rt(s[0],ot(t));return n.length>0?ut(e,t,n,o,u,c,i):{event:o,respond:c}}return(await Promise.all(s.map(n=>ke(ut,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,rt(n,ot(t)),o,ct(u,n),void 0,i)))).map(e=>({event:e.event,respond:void 0}))}return r.length>0?ut(e,t,r,o,u,c,i):{event:o,respond:c}}));let l=c;const d=[];for(const e of u.flat())if(null!==e)if(e&&"object"==typeof e&&"event"in e){const t=e;if(t.respond&&(l=t.respond),null===t.event)continue;Array.isArray(t.event)?d.push(...t.event):d.push(t.event)}else d.push(e);return 0===d.length?{event:null,respond:l}:1===d.length?{event:d[0],respond:l}:{event:d,respond:l}}if(w&&"object"==typeof w){const{event:n,respond:o,next:r}=w;if(o&&(c=o),void 0!==r){const o=await h(n||a),u=qe(r,Ce(s,o));if(0===u.length){a=o;continue}if(1===u.length){const n=rt(u[0],ot(t));return n.length>0?ut(e,t,n,o,s,c,i):(e.logger.warn(`Branch target not found: ${JSON.stringify(r)}`),{event:null,respond:c})}return await Promise.all(u.map(n=>ke(ut,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,rt(n,ot(t)),o,ct(s,n),void 0,i))),{event:null,respond:void 0}}n&&(a=n)}g&&g.length>0&&(a=await Te(g,t=>nt(t,e),a,e)),m&&d&&xe(d,m.key,a,m.ttl);const v=r.config.next,b="string"==typeof v||Array.isArray(v)&&v.every(e=>"string"==typeof e),k=void 0!==v&&!b;if((!w||"object"==typeof w&&!w.next)&&k){const n=qe(r.config.next,Ce(s,a));if(1===n.length){const o=rt(n[0],ot(t));return o.length>0?ut(e,t,o,a,s,c,i):{event:a,respond:c}}return n.length>1?(await Promise.all(n.map(n=>ke(ut,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,rt(n,ot(t)),a,ct(s,n),void 0,i))),{event:null,respond:void 0}):{event:a,respond:c}}}return{event:a,respond:c}}function lt(e){return e&&ve(e)?e:{}}function dt(e){return"string"==typeof e||!(!Array.isArray(e)||!e.every(e=>"string"==typeof e))}async function ft(e,t,n){if(!t.on||!t.queueOn?.length)return;const o=t.queueOn;t.queueOn=[];const s=n||t.config?.id||"unknown";for(const{type:n,data:r}of o)kt(n)&&!xt(e,t,n)||(await ae(t.on,t=>{if(t instanceof re)throw t;e.status.failed++,e.logger.scope("source").error("source on flush failed",{sourceId:s,type:n,error:t})})(n,r),kt(n)&&Ot(e,t,n))}function pt(e){return Boolean(e.config.init)&&!e.config.require?.length}async function gt(e,t,n){const{code:o,config:s={},env:r={},primary:i,next:a,before:c,cache:u}=n,l=s.state??n.state,d=l?ge(l):void 0,f=u,p=f?ue({...f,stop:f.stop??!0}):void 0,g=dt(a)?rt(a,ot(e.transformers)):void 0,h=dt(c)?rt(c,ot(e.transformers)):void 0,m=r.push,y=m??e.push,w=Boolean(m),v=async(n,o,r)=>{let i;const u=h??(void 0!==c?(()=>{const t=ce(c,pe(r.ingest));return 0===t.length?[]:rt(1===t.length?t[0]:t,ot(e.transformers))})():[]);let l=[n];if(u.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const o=await ut(e,e.transformers,u,n,r.ingest,r.respond,`source.${t}.before`);if(null===o.event)return{ok:!0};if(o.stopped)return o.respond&&(r.respond=o.respond),{ok:!0};o.respond&&(r.respond=o.respond),l=Array.isArray(o.event)?o.event:[o.event]}if(p){const t=tt(p,e);if(t){const n=pe(r.ingest),o=await le(p,t,n);if(o){if("HIT"===o.status&&void 0!==o.value&&p.stop){let t=o.value;return o.rule.update&&(t=await fe(t,o.rule.update,{...n,cache:{status:"HIT"}},e)),r.respond?.(t),{ok:!0}}if("MISS"===o.status&&p.stop&&r.respond){const s=r.respond,a=o.rule.update,c={...n,cache:{status:"MISS"}},u=o.key,l=o.rule.ttl,d=n=>{de(t,u,n,l),a?i=(async()=>{const t=await fe(n,a,c,e);s(t)})():s(n)};r.respond=d}"MISS"!==o.status||p.stop||de(t,o.key,!0,o.rule.ttl)}}}const f=g?{kind:"single",preChain:g}:void 0!==a?(()=>{const t=ce(a,pe(r.ingest));return 0===t.length?{kind:"single",preChain:[]}:1===t.length?{kind:"single",preChain:rt(t[0],ot(e.transformers))}:{kind:"many",branches:t.map(t=>rt(t,ot(e.transformers)))}})():{kind:"single",preChain:[]};!w&&d&&d.length>0&&(l=await Promise.all(l.map(t=>he(d,t=>nt(t,e),t,e))));let m={ok:!0};for(const n of l)"many"===f.kind?(await Promise.all(f.branches.map((i,a)=>ae(async()=>w?y(n):y(n,{...o,id:t,ingest:ct(r.ingest,`${t}.${a}`),respond:void 0,mapping:s,preChain:i}),t=>(e.logger.scope("source:many").error(`many branch ${a} failed`,{error:t}),{ok:!0}))())),m={ok:!0}):m=w?await y(n):await y(n,{...o,id:t,ingest:r.ingest,respond:r.respond,mapping:s,preChain:f.preChain});return i&&await i,m},b=async n=>{const o=se(t);if(!s.ingest||void 0===n)return o;const r=await ie(n,s.ingest,{collector:e});return{...o,...r,_meta:o._meta}},k=e.logger.scope("source").scope(t),S={command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:k,...r,push:async(e,n={})=>{const o={ingest:se(t),respond:void 0};return v(e,n,o)}},q={collector:e,logger:k,id:t,config:s,env:S,withScope:async(e,t,n)=>{const o={ingest:await b(e),respond:t};return n({...S,push:(e,t={})=>v(e,t,o),ingest:o.ingest,respond:o.respond})}},I=await ae(o,n=>{if(n instanceof re)throw n;e.status.failed++,e.logger.scope("source").error("source factory failed",{sourceId:t,error:n})})(q);if(!I)return;const O=I.type||"unknown",x=e.logger.scope(O).scope(t);return S.logger=x,i&&(I.config={...I.config,primary:i}),I}async function ht(e){for(const[t,n]of Object.entries(e.sources)){if(pt(n))continue;const o=n.config.require;if(!o?.length)continue;const s=o.filter(t=>!qt(e,t));s.length!==o.length&&(n.config.require=s,pt(n)&&await ft(e,n,t))}for(const[t,n]of Object.entries(e.pending.destinations)){if(!e.pending.destinations[t]||e.destinations[t])continue;const o=n.config?.require;if(!o)continue;const s=o.filter(t=>!qt(e,t));if(n.config&&(n.config.require=s),s.length>0)continue;delete e.pending.destinations[t];const r=Qt(n);!1!==r.config.queue&&(r.queuePush=[...e.queue]),e.destinations[t]=r}}function mt(e){if("object"!=typeof e||null===e)return!1;if(!("logger"in e))return!1;const t=e.logger;return"object"==typeof t&&null!==t&&"scope"in t&&"function"==typeof t.scope}var yt=!1;function wt(){yt||(yt=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("walkerOS: ignored an on-dispatch call with a non-collector argument"))}function vt(e,t,n,o){if(n instanceof te)throw n;e.logger.scope("on").error("on callback failed",{kind:t,...o,error:n})}var bt=[Ze.Consent,Ze.User,Ze.Globals,Ze.Custom];function kt(e){return bt.includes(e)}function St(e,t){switch(t){case Ze.Consent:return Object.keys(e.consent).length>0;case Ze.User:return Object.keys(e.user).length>0;case Ze.Globals:return Object.keys(e.globals).length>0;case Ze.Custom:return Object.keys(e.custom).length>0;default:return!1}}function qt(e,t){switch(t){case Ze.Consent:case Ze.User:case Ze.Globals:case Ze.Custom:return St(e,t);case Ze.Run:case Ze.Ready:return!0===e.allowed;default:return e.seenEvents.has(String(t))}}function It(e,t){return e.cellVersion[String(t)]??0}function Ot(e,t,n){let o=e.delivery.get(t);o||(o={},e.delivery.set(t,o)),o[String(n)]=It(e,n)}function xt(e,t,n){return e.allowed&&It(e,n)>function(e,t,n){const o=e.delivery.get(t),s=o?.[String(n)];return void 0===s?-1:s}(e,t,n)}function Ct(e,t,n){const o=e.cascade;if(!o)return!0;let s=o.counts.get(t);s||(s={},o.counts.set(t,s));const r=String(n),i=(s[r]||0)+1;return s[r]=i,i<=8||(9===i&&e.logger.error("state delivery did not converge",{type:r}),!1)}function jt(e,t){return{collector:e,logger:e.logger.scope("on").scope(String(t))}}function At(e,t,n,o,s){if(!t.on)return;const r=t.type||"unknown",i=e.logger.scope(r).scope("on").scope(o),a={collector:e,logger:i,id:n,config:t.config,data:s,env:Jt(t.env,t.config.env)};ne(t.on,t=>vt(e,"destination",t,{destId:n,type:o}))(o,a)}function Dt(e,t,n,o){if(!mt(e))return void wt();const s=Tt(e,t,o);if(n.length)switch(t){case Ze.Consent:!function(e,t,n){const o=n||e.consent,s=jt(e,Ze.Consent);t.forEach(t=>{xt(e,t,Ze.Consent)&&Ct(e,t,Ze.Consent)&&(Object.keys(o).filter(e=>e in t).forEach(n=>{ne(t[n],t=>vt(e,"consent",t,{key:n}))(o,s)}),Ot(e,t,Ze.Consent))})}(e,n,o);break;case Ze.Ready:!function(e,t){if(!e.allowed)return;const n=jt(e,Ze.Ready);t.forEach(t=>{ne(t,t=>vt(e,"ready",t))(void 0,n)})}(e,n);break;case Ze.Run:!function(e,t){if(!e.allowed)return;const n=jt(e,Ze.Run);t.forEach(t=>{ne(t,t=>vt(e,"run",t))(void 0,n)})}(e,n);break;case Ze.Session:!function(e,t){if(!e.session)return;const n=jt(e,Ze.Session);t.forEach(t=>{ne(t,t=>vt(e,"session",t))(e.session,n)})}(e,n);break;default:{const o=jt(e,t),r=kt(t);n.forEach(n=>{"function"==typeof n&&(r&&!xt(e,n,t)||r&&!Ct(e,n,t)||(ne(n,n=>vt(e,"generic",n,{type:t}))(s,o),r&&Ot(e,n,t)))});break}}}function Tt(e,t,n){switch(t){case Ze.Consent:return n||e.consent;case Ze.Session:return e.session;case Ze.User:return n||e.user;case Ze.Custom:return n||e.custom;case Ze.Globals:return n||e.globals;case Ze.Config:return n||e.config;default:return}}async function Et(e,t,n,o,s){if(!t.on)return!1;if(kt(o)&&!xt(e,t,o))return!1;if(kt(o)&&!Ct(e,t,o))return!1;const r=await oe(t.on,t=>vt(e,"source",t,{sourceId:n,type:o}))(o,s);return kt(o)&&Ot(e,t,o),!1===r}function Mt(e,t,n,o){if(!Number.isFinite(n.max)||n.max<=0)throw new Error(`pushBounded: max must be > 0 (got ${n.max})`);if("dropNewest"===(n.onOverflow??"dropOldest"))return e.length>=n.max?(o&&o([t]),{appended:!1,dropped:1}):(e.push(t),{appended:!0,dropped:0});const s=[];for(;e.length>=n.max;)s.push(e.shift());return e.push(t),s.length>0&&o&&o(s),{appended:!0,dropped:s.length}}var Pt=new WeakMap;function $t(e,t,n,o){Pt.get(e)||(Pt.set(e,!0),t.warn(n,o))}function _t(e){Pt.delete(e)}var Rt=Object.freeze({batched:!0});function Ht(e){return e===Rt}function Gt(e){return void 0===e?{}:"number"==typeof e?{wait:e}:{wait:e.wait,size:e.size,age:e.age}}function Nt(e,t){return e.status.destinations[t]||(e.status.destinations[t]={count:0,failed:0,duration:0,queuePushSize:0,dlqSize:0}),e.status.destinations[t]}function Bt(e,t,n,o){e.dropped[t]||(e.dropped[t]={});const s=e.dropped[t];return s[n]=(s[n]??0)+o,s[n]}function zt(e,t,n){if(!e)return[];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return rt(e,t);if("string"==typeof e)return rt(e,t);const o=F(e,M(n));return 0===o.length?[]:1===o.length?rt(o[0],t):rt(o,t)}async function Ft(e,t,n={},o){const{allowed:s,consent:r,globals:i,user:a}=e;if(!s)return Kt({ok:!1});if(t){const n=e.config.queueMax;if(void 0===n)throw new Error("Collector.Config.queueMax is undefined; defaults must be seeded by collector()");const o=Mt(e.queue,t,{max:n});if(o.dropped>0){const t=Bt(e.status,J("collector"),"queue",o.dropped);$t(e.queue,e.logger,"collector.queue overflow; oldest events dropped",{buffer:"queue",cap:n,droppedCount:t})}else e.queue.length<n&&_t(e.queue);e.status.in++}o||(o=e.destinations);const c=e.transformers?ot(e.transformers):{},u=await Promise.all(Object.entries(o||{}).map(async([o,s])=>{if(s.config.disabled)return{id:o,destination:s,skipped:!0};let u=(s.queuePush||[]).map(e=>({...e,consent:r}));s.queuePush=[],t&&u.push(P(t));const l=n.ingest?{...n.ingest,_meta:{...n.ingest._meta,path:[...n.ingest._meta.path]}}:H("unknown");if(!u.length&&!s.queueOn?.length)return{id:o,destination:s,skipped:!0};if(!u.length&&s.queueOn?.length){let t=!1;try{t=await Lt(e,s,o)}catch(t){e.status.failed++;const n=s.type||"unknown";e.logger.scope(n).error("destination init failed",{error:t instanceof Error?t.message:String(t)})}return{id:o,destination:s,skipped:!t}}const d=[],f=u.filter(t=>{const n=z(s.config.consent,r,t.consent);if(n)return t.consent=n,d.push(t),!1;const i=et(e,{stepId:J("destination",o),stepType:"destination",phase:"skip",eventId:"string"==typeof t.id?t.id:"",now:Date.now()});return i.skipReason="consent",r&&(i.consent={...r}),s.config.consent&&(i.meta={required:{...s.config.consent}}),N(e,i),!0});if(f.length>0){const t=s.queuePush,n=s.config.id||o,r={max:s.config.queueMax??1e3};let i=0;for(const e of f)i+=Mt(t,e,r).dropped;if(i>0){Nt(e,n);const o=Bt(e.status,J("destination",n),"queue",i);$t(t,e.logger.scope(s.type||"unknown"),"destination.queuePush overflow; oldest events dropped",{buffer:"queuePush",destination:n,cap:r.max,droppedCount:o})}else t.length<r.max&&_t(t)}if(!d.length)return{id:o,destination:s,queue:u};let p,g,h=!1;try{h=await Lt(e,s,o)}catch(t){e.status.failed++;const n=s.type||"unknown";e.logger.scope(n).error("destination init failed",{error:t instanceof Error?t.message:String(t)})}if(!h)return{id:o,destination:s,queue:u};s.dlq||(s.dlq=[]);const m=zt(s.config.before,c,l),y=s.config.next,w=s.config?.cache,v=w?$(w):void 0,b=v?tt(v,e):void 0,k=s.config?.state?Y(s.config.state):void 0,S=k?.filter(e=>"get"===e.mode),q=k?.filter(e=>"set"===e.mode);let I=0,O=0;return await Promise.all(d.map(async t=>{let r;if(t.globals=E(i,t.globals),t.user=E(a,t.user),v?.stop&&b){const e=M(l,t),n=await _(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}let u=t,d=n.respond;if(m.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const s=await ut(e,e.transformers,m,t,l,n.respond,`destination.${o}.before`);if(null===s.event)return t;s.respond&&(d=s.respond),u=Array.isArray(s.event)?s.event[0]:s.event}if(v&&!v.stop&&b){const e=M(l,u),n=await _(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}S&&S.length>0&&u&&(u=await X(S,t=>nt(t,e),u,e));const f=Date.now();let h=!1;const w=await W(Ut,t=>{const n=s.type||"unknown";e.logger.scope(n).error("Push failed",{error:t,event:u.name}),p=t,h=!0;const r=s.dlq,i=s.config.id||o,a={max:s.config.dlqMax??100},c=Mt(r,[u,t],a);if(c.dropped>0){Nt(e,i);const t=Bt(e.status,J("destination",i),"dlq",c.dropped);$t(r,e.logger.scope(s.type||"unknown"),"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:i,cap:a.max,droppedCount:t})}else r.length<a.max&&_t(r)})(e,s,o,u,l,d);if(I+=Date.now()-f,r&&b&&void 0===s.config.mock&&R(b,r.key,w??!0,r.ttl),!h&&!Ht(w)&&q&&q.length>0&&u&&(u=await X(q,t=>nt(t,e),u,e)),void 0===w||Ht(w)||(g=w),Ht(w)&&O++,!h&&y){void 0!==w&&(l._response=w);const t=zt(y,c,l);if(t.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const n=await ut(e,e.transformers,t,u,l,d,`destination.${o}.next`);n.respond&&(d=n.respond)}}return t})),{id:o,destination:s,error:p,response:g,totalDuration:I,batchedCount:O,allowedCount:d.length}})),l={},d={},f={};for(const t of u){if(t.skipped)continue;const n=t.destination,o={type:n.type||"unknown",data:t.response};Nt(e,t.id);const s=e.status.destinations[t.id],r=Date.now();if(s.queuePushSize=n.queuePush?.length??0,s.dlqSize=n.dlq?.length??0,t.error)o.error=t.error,f[t.id]=o,s.failed++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.failed++;else if(t.queue&&t.queue.length)d[t.id]=o;else{const n=t.batchedCount??0,i=t.allowedCount??0;(Math.max(0,i-n)>0||0===i)&&(l[t.id]=o,s.count++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.out++)}}return Kt({event:t,...Object.keys(l).length&&{done:l},...Object.keys(d).length&&{queued:d},...Object.keys(f).length&&{failed:f}})}async function Lt(e,t,n){if(t.init&&!t.config.init){const o=t.type||"unknown",s=e.logger.scope(o),r={collector:e,logger:s,id:n,config:t.config,env:Jt(t.env,t.config.env)};s.debug("init");const i=Date.now();let a;N(e,et(e,{stepId:J("destination",n),stepType:"destination",phase:"init",eventId:"",now:i}));try{a=await V(t.init,"DestinationInit",e.hooks,e.logger)(r)}catch(t){const o=Date.now(),s=et(e,{stepId:J("destination",n),stepType:"destination",phase:"error",eventId:"",now:o});throw s.durationMs=o-i,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},N(e,s),t}if(!1===a)return a;if(t.config={...a||t.config,init:!0},t.queueOn?.length){const o=t.queueOn;t.queueOn=[];for(const{type:s,data:r}of o)At(e,t,n,s,r)}s.debug("init done")}return!0}async function Ut(e,t,n,o,s,r){const{config:i}=t,a=await Q(o,i,e);if(a.ignore)return!1;const c=t.type||"unknown",u=e.logger.scope(c),l={collector:e,logger:u,id:n,config:i,data:a.data,rule:a.mapping,ingest:s,env:{...Jt(t.env,i.env),...r?{respond:r}:{}}};if(void 0!==i.mock)return u.debug("mock",{event:a.event.name}),i.mock;const d=a.mapping,f=void 0!==d?.batch,p=f?a.mappingKey||"* *":" batch-all";if((f||void 0!==i.batch)&&t.pushBatch&&void 0===i.mock){if(t.batches=t.batches||{},!t.batches[p]){const o={key:p,entries:[],events:[],data:[]},s=Gt(d?.batch),r=Gt(i.batch),a=s.wait??r.wait??3e4,c=s.size??r.size??1e3,l=s.age??r.age??3e4,g=Jt(t.env,i.env),h=G(async()=>{const o=t.batches[p],s=o.batched;if(0===s.entries.length)return;const r={key:s.key,entries:s.entries,events:s.events,data:s.data};s.entries=[],s.events=[],s.data=[];const a=r.entries[0],c={collector:e,logger:u,id:n,config:i,data:void 0,rule:o.isDefault?void 0:a.rule,ingest:a.ingest,env:{...g,...a.respond?{respond:a.respond}:{}}};u.debug("push batch",{events:r.entries.length});const l=t.config.id||n,d=Nt(e,l),f=Date.now(),h=et(e,{stepId:J("destination",n),stepType:"destination",phase:"flush",eventId:"",now:f});h.batch={size:r.entries.length,index:0},N(e,h);const m=n=>{const o=t.dlq=t.dlq||[],s={max:t.config.dlqMax??100};let r=0;for(const e of n)r+=Mt(o,e,s).dropped;if(r>0){const t=Bt(e.status,J("destination",l),"dlq",r);$t(o,u,"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:l,cap:s.max,droppedCount:t})}else o.length<s.max&&_t(o);d.failed+=n.length,d.dlqSize=o.length,e.status.failed+=n.length};let y=r.entries.length;const w=await W(V(t.pushBatch,"DestinationPushBatch",e.hooks,e.logger),t=>{y=0;const o=Date.now(),s=et(e,{stepId:J("destination",n),stepType:"destination",phase:"error",eventId:"",now:o});s.durationMs=o-f,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},s.batch={size:r.entries.length,index:0},N(e,s),m(r.entries.map(e=>[e.event,t])),u.error("Push batch failed",{error:t instanceof Error?t.message:String(t),entries:r.entries.length})})(r,c);if(K(v=w)&&Array.isArray(v.failed)&&w.failed.length>0){const e=[],t=new Set;for(const n of w.failed){const o=r.entries[n.index];o&&!t.has(n.index)&&(t.add(n.index),e.push([o.event,n.error??new Error(`Push batch entry ${n.index} failed (no per-row error provided)`)]))}e.length>0&&(m(e),y=Math.max(0,r.entries.length-e.length),u.error("Push batch partial failure",{failed:e.length,delivered:y,entries:r.entries.length}))}var v;u.debug("push batch done"),d.inFlightBatch=Math.max(0,(d.inFlightBatch??0)-r.entries.length),y>0&&(d.count+=y,d.lastAt=Date.now(),e.status.out+=y)},{wait:a,size:c,age:l});t.batches[p]={batched:o,isDefault:!f,batchFn:()=>{h()},flush:async()=>{await h.flush()}}}const o=t.batches[p];o.batched.entries.push({event:a.event,ingest:s,respond:r,rule:d,data:a.data}),o.batched.events.push(a.event),L(a.data)&&o.batched.data.push(a.data);const c=t.config.id||n,l=Nt(e,c);return l.inFlightBatch=(l.inFlightBatch??0)+1,o.batchFn(),Rt}{u.debug("push",{event:a.event.name});const o="string"==typeof a.event.id?a.event.id:"",s=Date.now(),r=et(e,{stepId:J("destination",n),stepType:"destination",phase:"in",eventId:o,now:s});a.mappingKey&&(r.mappingKey=a.mappingKey),a.event.consent&&(r.consent={...a.event.consent}),N(e,r);try{const r=await V(t.push,"DestinationPush",e.hooks,e.logger)(a.event,l),i=Date.now(),c=et(e,{stepId:J("destination",n),stepType:"destination",phase:"out",eventId:o,now:i});return c.durationMs=i-s,c.outEvent=r,a.mappingKey&&(c.mappingKey=a.mappingKey),N(e,c),u.debug("push done"),r}catch(t){const r=Date.now(),i=et(e,{stepId:J("destination",n),stepType:"destination",phase:"error",eventId:o,now:r});throw i.durationMs=r-s,i.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},a.mappingKey&&(i.mappingKey=a.mappingKey),N(e,i),t}}}function Kt(e){return{ok:!e?.failed,...e}}function Qt(e){const{code:t,config:n={},env:o={},cache:s,state:r}=e,{config:i}=st(e,"before"),{config:a}=st({...e,config:i},"next"),c={...t.config,...n,...a};s&&(c.cache=s),void 0!==r&&void 0===c.state&&(c.state=r);const u=Jt(t.env,o);return{...t,config:c,env:u}}function Jt(e,t){return e||t?t?e&&K(e)&&K(t)?{...e,...t}:t:e:{}}async function Wt(e,t,n){const o=Object.entries(e).map(async([e,o])=>{const s=o.destroy;if(!s)return;const r=o.type||"unknown",i=n.scope(r),a={id:e,config:o.config,env:o.env??{},logger:i};let c;try{await Promise.race([s(a),new Promise((n,o)=>{c=setTimeout(()=>o(new Error(`${t} '${e}' destroy timed out`)),5e3)})])}catch(n){i.error(`${t} '${e}' destroy failed: ${n}`)}finally{c&&clearTimeout(c)}});await Promise.allSettled(o)}function Vt(e,t){e.stateVersion++,e.cellVersion[t]=e.stateVersion}async function Yt(e,t,n){let o,s,r=!1;const i=function(e){return e.cascade?()=>{}:(e.cascade={counts:new WeakMap},()=>{e.cascade=void 0})}(e);try{return await async function(){switch(t){case Ze.Config:_e(n)&&(Ee(e.config,n,{shallow:!1}),s=n,r=!0);break;case Ze.Consent:if(_e(n)){const{update:t}=function(e,t){const n={};return Object.entries(t).forEach(([e,t])=>{n[e]=!!t}),e.consent=A(e.consent,n),{update:n}}(e,n);Vt(e,Ze.Consent),s=t,r=!0}break;case Ze.Custom:_e(n)&&(e.custom=Ee(e.custom,n),Vt(e,Ze.Custom),s=n,r=!0);break;case Ze.Destination:_e(n)&&"code"in n&&_e(n.code)&&(o=await async function(e,t){const{code:n,config:o={},env:s={},before:r,next:i,cache:a,state:c}=t;if(!U(n.push))return Kt({ok:!1,failed:{invalid:{type:"invalid",error:"Destination code must have a push method"}}});const u=o||{init:!1};let l=r?{...u,before:r}:{...u};i&&(l={...l,next:i}),a&&(l={...l,cache:a}),void 0!==c&&void 0===l.state&&(l={...l,state:c});let d=l.id;if(!d)do{d=B(5,"abcdefghijklmnopqrstuvwxyz")}while(e.destinations[d]||e.pending.destinations[d]);if(l.require?.length){e.pending.destinations[d]=t,await ht(e);const n=e.destinations[d];return n?Ft(e,void 0,{},{[d]:n}):Kt({ok:!0})}const f={...n,config:l,env:Jt(n.env,s)};return e.destinations[d]=f,!1!==f.config.queue&&(f.queuePush=[...e.queue]),Ft(e,void 0,{},{[d]:f})}(e,n));break;case Ze.Globals:_e(n)&&(e.globals=Ee(e.globals,n),Vt(e,Ze.Globals),s=n,r=!0);break;case Ze.Hook:if(_e(n)&&$e(n.name)&&Pe(n.fn)){const{name:t,fn:o}=n;e.hooks[t]=o,s=n,r=!0}break;case Ze.On:if(_e(n)&&$e(n.type)){const{type:t,rules:o}=n;await async function(e,t,n){if(!mt(e))return void wt();const o=e.on,s=o[t]||[],r=ee(n)?n:[n];r.forEach(e=>{s.push(e)}),o[t]=s,Dt(e,t,r)}(e,t,o)}break;case Ze.Ready:r=!0;break;case Ze.Run:o=await async function(e,t){return e.allowed=!0,e.timing=Date.now(),t&&(t.consent&&(e.consent=Ee(e.consent,t.consent),Vt(e,Ze.Consent)),t.user&&(e.user=Ee(e.user,t.user),Vt(e,Ze.User)),t.globals&&(e.globals=Ee(e.config.globalsStatic||{},t.globals),Vt(e,Ze.Globals)),t.custom&&(e.custom=Ee(e.custom,t.custom),Vt(e,Ze.Custom))),Object.values(e.destinations).forEach(e=>{e.queuePush=[]}),e.queue=[],e.round++,await ht(e),await async function(e){if(mt(e))for(const t of bt){if(!St(e,t))continue;const n=Tt(e,t);Dt(e,t,e.on[t]||[]);for(const[o,s]of Object.entries(e.sources))pt(s)&&await Et(e,s,o,t,n)}else wt()}(e),await Ft(e)}(e,n),r=!0;break;case Ze.Session:r=!0;break;case Ze.Shutdown:e.hasShutdown||(e.hasShutdown=!0,await async function(e){const t=e.logger;await Wt(e.sources,"source",t),await async function(e,t){const n=Object.entries(e).flatMap(([e,n])=>{const o=n.batches;if(!o)return[];const s=t.scope(n.type||"destination");return Object.values(o).map(async t=>{let n;try{await Promise.race([t.flush(),new Promise((t,o)=>{n=setTimeout(()=>o(new Error(`destination '${e}' batch flush timed out`)),5e3)})])}catch(t){s.error(`destination '${e}' batch flush failed: ${t}`)}finally{n&&clearTimeout(n)}})});await Promise.allSettled(n)}(e.destinations,t),await Wt(e.destinations,"destination",t),await Wt(e.transformers,"transformer",t),await Wt(e.stores,"store",t)}(e));break;case Ze.User:_e(n)&&(Ee(e.user,n,{shallow:!1}),Vt(e,Ze.User),s=n,r=!0)}return r&&(await async function(e,t,n,o){if(!mt(e))return wt(),!0;e.seenEvents.add(String(t));let s=n||[];n||(s=e.on[t]||[]);const r=Tt(e,t,o);let i=!1;for(const[n,o]of Object.entries(e.sources)){if(o.config.require?.length){const e=o.config.require.indexOf(t);-1!==e&&o.config.require.splice(e,1)}o.on&&(pt(o)?await Et(e,o,n,t,r)&&(i=!0):(o.queueOn=o.queueOn||[],o.queueOn.push({type:t,data:r})))}Object.entries(e.destinations).forEach(([n,o])=>{if(o.on){if(!o.config.init)return o.queueOn=o.queueOn||[],void o.queueOn.push({type:t,data:r});At(e,o,n,t,r)}});for(const[t,n]of Object.entries(e.sources))pt(n)&&n.queueOn?.length&&await ft(e,n,t);const a=Object.values(e.sources).some(e=>!pt(e)&&e.config.require?.length);return(Object.keys(e.pending.destinations).length>0||a)&&await ht(e),Dt(e,t,s,o),!i}(e,t,void 0,s),o=await Ft(e)),o||Kt({ok:!0})}()}finally{i()}}function Xt(e,t){return{timing:Math.round((Date.now()-e.timing)/10)/100,source:{type:"collector",schema:"4",version:"4.2.0"},...t}}function Zt(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");const{timestamp:s=Date.now(),name:r=`${n} ${o}`,data:i={},context:a={},globals:c=e.globals,custom:u={},user:l=e.user,nested:d=[],consent:f=e.consent,id:p=Me(),trigger:g="",entity:h=n,action:m=o,timing:y=0,source:w={type:"collector",schema:"4"}}=t;return{name:r,data:i,context:a,globals:c,custom:u,user:l,nested:d,consent:f,id:p,trigger:g,entity:h,action:m,timestamp:s,timing:y,source:w}}function en(e,t){const n=Fe(async(n,o={})=>await ze(async()=>{const s=Date.now(),{id:r,ingest:i,respond:a,mapping:c,preChain:u,include:l,exclude:d}=o;let f=a,p=n;const g=l||d?function(e,t,n){let o=e;return t&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>t.includes(e)))),n&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>!n.includes(e)))),o}(e.destinations,l,d):void 0,h=i??Re(r||"unknown");if(c){const t=await Be(p,c,e);if(t.ignore)return Kt({ok:!0});if(c.consent&&!Ne(c.consent,e.consent,t.event.consent))return Kt({ok:!0});p=t.event}if(u?.length&&e.transformers&&Object.keys(e.transformers).length>0){const n=await ut(e,e.transformers,u,p,h,f,r?`source.${r}.next`:void 0);if(null===n.event)return Kt({ok:!0});if(n.stopped)return n.respond&&(f=n.respond),Kt({ok:!0});if(n.respond&&(f=n.respond),Array.isArray(n.event)){const o=await Promise.all(n.event.map(async n=>{const o=t(n),s=Zt(e,o);return Ft(e,s,{id:r,ingest:h,respond:f},g)}));if(r){e.status.sources[r]||(e.status.sources[r]={count:0,duration:0});const t=e.status.sources[r];t.count+=n.event.length,t.lastAt=Date.now(),t.duration+=Date.now()-s}return o[0]??Kt({ok:!0})}p=n.event}const m=function(e,t){return Zt(e,Xt(e,t))}(e,p),y=await Ft(e,m,{id:r,ingest:h,respond:f},g);if(r){e.status.sources[r]||(e.status.sources[r]={count:0,duration:0});const t=e.status.sources[r];t.count++,t.lastAt=Date.now(),t.duration+=Date.now()-s}return y},t=>{if(t instanceof Ge)throw t;return e.status.failed++,e.logger.error("push failed",{event:n,ingest:o.ingest,error:t}),Kt({ok:!1})})(),"Push",e.hooks,e.logger);return async(t,o)=>{const s="string"==typeof t.id?t.id:"",r=Date.now();He(e,et(e,{stepId:"collector.push",stepType:"collector",phase:"in",eventId:s,now:r}));try{const i=await n(t,o),a=Date.now(),c=et(e,{stepId:"collector.push",stepType:"collector",phase:"out",eventId:s,now:a});return c.durationMs=a-r,c.outEvent=i,He(e,c),i}catch(t){const n=Date.now(),o=et(e,{stepId:"collector.push",stepType:"collector",phase:"error",eventId:s,now:n});throw o.durationMs=n-r,o.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},He(e,o),t}}}function tn(e={}){const t=e.maxEntries??1e4,n=e.lowWaterMark??.8,o=e.sweepIntervalMs??6e4,s=Math.floor(t*n),r=new Map,i={hits:0,misses:0,populates:0,writes:0,deletes:0,evictions_entries:0,evictions_ttl:0};let a;return o>0&&(a=setInterval(function(){const e=Date.now();let t=0;for(const[n,o]of r)void 0!==o.expires&&o.expires<=e&&(r.delete(n),t++);i.evictions_ttl+=t},o),a&&"function"==typeof a.unref&&a.unref()),{type:"memory",config:{},get(e){const t=r.get(e);if(t)return void 0!==t.expires&&t.expires<=Date.now()?(r.delete(e),i.evictions_ttl++,void i.misses++):(r.delete(e),r.set(e,t),i.hits++,t.value);i.misses++},set(e,n,o){const a=!r.has(e);a||r.delete(e),r.set(e,{value:n,expires:void 0!==o?Date.now()+o:void 0}),i.writes++,a&&i.populates++,r.size>t&&function(){if(r.size<=t)return;const e=r.size-s;let n=0;for(const t of r.keys()){if(n>=e)break;r.delete(t),n++}i.evictions_entries+=n}()},delete(e){r.delete(e)&&i.deletes++},get counters(){return{...i}},destroy(){void 0!==a&&(clearInterval(a),a=void 0),r.clear()}}}function nn(e,t){const{cacheConfig:n,cacheStore:o,namespace:s,logger:r,storeId:i,collector:a}=t,c=(e,t)=>{if(!a)return;const n=et(a,{stepId:`store.${i}`,stepType:"store",phase:"in",eventId:"",now:Date.now()});n.meta={op:"cache",cached:"hit"===t,status:t,key:e},Ve(a,n)},u={hits:0,misses:0,populates:0,writes:0,deletes:0,inflight_dedups:0},l=n.rules.map(e=>({match:e.match?We(e.match):()=>!0,ttl:e.ttl})),d=e=>`${s}:${e}`;function f(e,t){const n=void 0===t?{key:e}:{key:e,value:t};return l.find(e=>e.match(n))}const p=new Map;return{type:e.type,config:e.config,setup:e.setup,get counters(){return{...u}},async get(t){const n=d(t),s=await o.get(n),r=Ye(s);if(void 0!==r){if(!("expired"in r))return u.hits++,c(t,"hit"),r.value;try{await o.delete(n)}catch(e){g("delete",t,e)}}const i=p.get(n);if(i)return u.inflight_dedups++,c(t,"hit"),i;u.misses++,c(t,"miss");const a=(async()=>{try{const s=await e.get(t);if(void 0===s)return;const r=f(t,s);if(r)try{const e=1e3*r.ttl;await o.set(n,Xe(s,e),e),u.populates++}catch(e){g("set",t,e)}return s}finally{p.delete(n)}})();return p.set(n,a),a},async set(t,n,s){u.writes++,await e.set(t,n,s);const r=f(t,n);if(r)try{const e=1e3*r.ttl;await o.set(d(t),Xe(n,e),e)}catch(e){g("set",t,e)}},async delete(t){u.deletes++,await e.delete(t);try{await o.delete(d(t))}catch(e){g("delete",t,e)}}};function g(e,t,n){const o=`store-cache(${i}): cache ${e} failed for "${t}"; backing succeeded, continuing`;r?r.warn(o,{error:n}):console.warn(o,n)}}function on(e,t,n){const o=`store.${n}`,s=Je(t.get,"StoreGet",e.hooks,e.logger),r=Je(t.set,"StoreSet",e.hooks,e.logger),i=Je(t.delete,"StoreDelete",e.hooks,e.logger);t.get=async t=>{const n=Date.now(),r=et(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});r.meta={op:"get",key:t},Qe(e,r);try{const r=await s(t),i=Date.now(),a=et(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:i});return a.durationMs=i-n,a.meta={op:"get",key:t},Qe(e,a),r}catch(s){const r=Date.now(),i=et(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw i.durationMs=r-n,i.meta={op:"get",key:t},i.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},Qe(e,i),s}},t.set=async(t,n,s)=>{const i=Date.now(),a=et(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:i});a.meta={op:"set",key:t},Qe(e,a);try{await r(t,n,s);const a=Date.now(),c=et(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:a});c.durationMs=a-i,c.meta={op:"set",key:t},Qe(e,c)}catch(n){const s=Date.now(),r=et(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:s});throw r.durationMs=s-i,r.meta={op:"set",key:t},r.error=n instanceof Error?{name:n.name,message:n.message}:{message:String(n)},Qe(e,r),n}},t.delete=async t=>{const n=Date.now(),s=et(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});s.meta={op:"delete",key:t},Qe(e,s);try{await i(t);const s=Date.now(),r=et(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:s});r.durationMs=s-n,r.meta={op:"delete",key:t},Qe(e,r)}catch(s){const r=Date.now(),i=et(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw i.durationMs=r-n,i.meta={op:"delete",key:t},i.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},Qe(e,i),s}}}async function sn(e){const t=D({globalsStatic:{},sessionStatic:{},run:!0,queueMax:1e3},e,{merge:!1,extend:!1}),n={level:e.logger?.level,handler:e.logger?.handler},o=T(n),s={...t.globalsStatic,...e.globals},r={allowed:!1,config:t,consent:e.consent||{},custom:e.custom||{},destinations:{},transformers:{},stores:{},globals:s,hooks:e.hooks||{},observers:new Set,logger:o,on:{},queue:[],round:0,stateVersion:0,cellVersion:{},delivery:new WeakMap,session:void 0,status:{startedAt:Date.now(),in:0,out:0,failed:0,sources:{},destinations:{},dropped:{}},timing:Date.now(),user:e.user||{},sources:{},pending:{destinations:{}},hasShutdown:!1,seenEvents:new Set,push:void 0,command:void 0};var i,a;r.push=en(r,e=>Xt(r,e)),r.command=(a=Yt,Ue(async(e,t,n)=>await Ke(async()=>await a(i,e,t,n),n=>{if(n instanceof Le)throw n;return i.status.failed++,i.logger.error("command failed",{command:e,data:t,error:n}),Kt({ok:!1})})(),"Command",(i=r).hooks,i.logger));const c=e.stores||{};return r.stores=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const{code:t,config:r={},env:i={}}=s,a=e.logger.scope("store").scope(o),c={collector:e,logger:a,id:o,config:r,env:i},u=await t(c);n[o]=u}const o=t,s=function(e){const t={};for(const n of Object.keys(e))t[n]="WHITE";const n=[],o=[];function s(r){const i=t[r];if("BLACK"===i)return;if("GRAY"===i){const e=o.indexOf(r),t=o.slice(-1===e?0:e).concat(r).join(" -> ");throw new Error(`Cycle in cache.store chain: ${t}`)}t[r]="GRAY",o.push(r);const a=e[r].cache?.store;if(void 0!==a){if(!(a in e))throw new Error(`Store "${r}" cache.store references "${a}", which is not declared in flow.stores`);s(a)}o.pop(),t[r]="BLACK",n.push(r)}for(const n of Object.keys(e))"WHITE"===t[n]&&s(n);return n}(o);for(const t of s){const s=o[t].cache;if(!s)continue;let r,i;void 0!==s.store?(r=n[s.store],i=s.store):(n.__cache||(n.__cache=tn()),r=n.__cache,i="__cache");const a=s.namespace??t;e.logger.scope("store-cache").scope(t).info(`store "${t}" caches with namespace "${a}:" via ${i}`),n[t]=nn(n[t],{storeId:t,cacheConfig:s,cacheStore:r,namespace:a,logger:e.logger.scope("store-cache").scope(t),collector:e})}for(const[t,o]of Object.entries(n))"__cache"!==t&&on(e,o,t);return n}(r,c),function(e,t,n){const o=new Map;for(const[n,s]of Object.entries(e))t[n]&&o.set(s,t[n]);if(0!==o.size)for(const e of[n.transformers,n.destinations,n.sources])if(e)for(const t of Object.values(e))s(t.env);function s(e){if(e)for(const[t,n]of Object.entries(e))if("object"==typeof n&&null!==n){const s=o.get(n);s&&(e[t]=s)}}}(c,r.stores,e),r.stores.__cache||(r.stores.__cache=tn()),r.destinations=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t))s.config?.require?.length?e.pending.destinations[o]=s:n[o]=Qt(s);return n}(r,e.destinations||{}),r.transformers=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const{code:t,env:r={}}=s,i=je(s,"Transformer");if(!i.ok){e.logger.warn(`Transformer ${o} invalid (${i.code}): ${i.reason}. Skipping.`);continue}const{config:a}=st(s,"before"),{config:c}=st({...s,config:a},"next"),u=Object.keys(r).length>0?{...c,env:r}:c,{cache:l}=s,d=l?{...u,cache:l}:u,f=s.config?.state??s.state,p=void 0!==f&&void 0===d.state?{...d,state:f}:d,g=e.logger.scope("transformer").scope(o),h={collector:e,logger:g,id:o,ingest:me(o),config:p,env:r},m=t??(e=>{const t=s.mapping;if(t){const n=[];if(void 0!==t.data&&n.push("data"),t.mapping)for(const[e,o]of Object.entries(t.mapping))if("object"==typeof o&&null!==o)for(const[t,s]of Object.entries(o)){if("object"!=typeof s||null===s)continue;const o=s;void 0!==o.data&&n.push(`mapping[${e}][${t}].data`),void 0!==o.silent&&n.push(`mapping[${e}][${t}].silent`)}return n.length>0&&e.collector.logger.warn(`Transformer ${o}: \`${n.join(", ")}\` ignored at transformer position (only event-mutating fields apply).`),{type:"pass",config:e.config,push:async n=>{const o=await Ae(n,t,e.collector);return!o.ignore&&{event:o.event}}}}return{type:"pass",config:e.config,push:e=>({event:e})}}),y=await m(h);void 0!==s.before&&void 0===y.config?.before&&(y.config={...y.config??{},before:s.before}),void 0!==s.next&&void 0===y.config?.next&&(y.config={...y.config??{},next:s.next}),void 0!==f&&void 0===y.config?.state&&(y.config={...y.config??{},state:f}),n[o]=y}return n}(r,e.transformers||{}),r}async function rn(e){e=e||{};const t=await sn(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,s,r)=>{if("string"==typeof e&&e.startsWith("walker ")){const n=e.replace("walker ","");return o.command(n,t)}let i;if("string"==typeof e)i={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(i.data=t);else{if(!e||"object"!=typeof e)return Kt({ok:!1});i=e,t&&"object"==typeof t&&!Array.isArray(t)&&(i.data={...i.data||{},...t})}return n&&"object"==typeof n&&(i.context=n),s&&Array.isArray(s)&&(i.nested=s),r&&"object"==typeof r&&(i.custom=r),o.push(i)}});var o;t.sources.elb=n,await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const t=await gt(e,o,s);if(!t)continue;const r=s.config?.require;t.config={...t.config,init:!1,...r?{require:[...r]}:{}},n[o]=t}Object.assign(e.sources,n);for(const t of Object.keys(n)){const n=e.sources[t];let o=!1;n.init&&await ae(n.init.bind(n),n=>{if(n instanceof re)throw n;o=!0,e.status.failed++,e.logger.scope("source").error("source init failed",{sourceId:t,error:n})})(),o||(n.config.init=!0,pt(n)&&await ft(e,n,t))}return await ht(e),n}(t,e.sources||{});const{consent:s,user:r,globals:i,custom:a}=e;s&&await t.command("consent",s),r&&await t.command("user",r),i&&await t.command("globals",i),a&&await t.command("custom",a),t.config.run&&await t.command("run");let c=n.push;const u=Object.values(t.sources).filter(e=>"elb"!==e.type),l=u.find(e=>e.config.primary);return l?c=l.push:u.length>0&&(c=u[0].push),{collector:t,elb:c}}var an=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await rn(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources||{}))if("lambda"===t.type)return t}(t.collector);if(!o)throw new Error("Lambda source not found in collector");const s={awsRequestId:`test-${Date.now()}`},r=o.push,i=await r(n,s);let a;try{a=JSON.parse(i.body||"{}")}catch{a=i.body}const c={};if(i.headers)for(const[e,t]of Object.entries(i.headers))void 0!==t&&(c[e]=String(t));return{statusCode:i.statusCode,body:a,headers:c}}}};function cn(e){return async t=>{const n={...t};if(n.body&&"string"==typeof n.body){const e=JSON.parse(n.body);e.name&&!e.event&&(n.body=JSON.stringify({...e,event:e.name,name:void 0}))}return e.push(n,{awsRequestId:"test-req"})}}var un={};t(un,{createTrigger:()=>Sn,env:()=>ln,step:()=>mn});var ln={};t(ln,{push:()=>gn,simulation:()=>hn});var dn=()=>{},fn={error:dn,warn:dn,info:dn,debug:dn,throw:e=>{throw"string"==typeof e?new Error(e):e},json:dn,scope:()=>fn},pn=()=>()=>Promise.resolve({ok:!0}),gn={get push(){return pn()},get command(){return pn()},get elb(){return pn()},logger:fn},hn=["AWS.SQSClient"],mn={};t(mn,{decoderText:()=>vn,malformedJson:()=>bn,orderComplete:()=>wn,pageView:()=>yn});var yn={title:"Page view from SQS",description:"A standard SQS message body containing a walker elb event payload as JSON.",in:{MessageId:"m-1",Body:JSON.stringify({event:"page view",data:{title:"Documentation",url:"https://example.com/docs"}})},out:[["message.ack","m-1"]]},wn={title:"Order complete from SQS",description:"Order complete event flowing through the long-poll loop.",in:{MessageId:"m-2",Body:JSON.stringify({event:"order complete",data:{id:"ORD-500",total:199.99,currency:"EUR"}})},out:[["message.ack","m-2"]]},vn={title:"Text decoder",description:'When decoder is "text", the body string flows under data.payload.',in:{MessageId:"m-3",Body:"raw text payload"},out:[["message.ack","m-3"]]},bn={title:"Malformed JSON nacks",description:"Default decoder is JSON. A malformed body throws DecoderError; the source nacks (skips DeleteMessage) so the message redelivers.",in:{MessageId:"m-4",Body:"{not json"},out:[["message.nack","m-4"]]};function kn(e){if("object"!=typeof e||null===e)return!1;const t=e;return"sqs"===t.type&&"function"==typeof t.push}var Sn=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await rn(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources??{}))if(kn(t))return t}(t.collector);if(!o)throw new Error("sqs source not registered in collector, ensure it is configured in sources");const s={MessageId:n.MessageId,Body:n.Body,ReceiptHandle:n.ReceiptHandle,Attributes:n.Attributes,MessageAttributes:n.MessageAttributes},r=await o.push(s),i=[];return r&&"object"==typeof r&&(r.acked&&i.push(["message.ack",n.MessageId]),r.nacked&&i.push(["message.nack",n.MessageId])),i}}};export{v as examples,n as schemas,un as sqsExamples};//# sourceMappingURL=dev.mjs.map
1
+ var e=Object.defineProperty,t=(t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})},n={};t(n,{CorsOptionsSchema:()=>c,CorsOrigin:()=>a,HttpMethod:()=>i,SettingsSchema:()=>u,settings:()=>l,sqsSettings:()=>y,sqsSetup:()=>w});import{zodToSchema as o}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";import{z as r}from"@walkeros/core/dev";var i=r.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),a=r.union([r.string(),r.array(r.string()),r.literal("*")]),c=r.object({origin:a.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:r.array(i).describe("Allowed HTTP methods").optional(),headers:r.array(r.string()).describe("Allowed request headers").optional(),credentials:r.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:r.number().int().positive().describe("Preflight cache duration in seconds").optional()}),u=s.object({cors:s.union([s.boolean(),c]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").default(!0),timeout:s.number().int().positive().max(9e5).describe("Request timeout in milliseconds (max: 900000 for Lambda)").default(3e4),enablePixelTracking:s.boolean().describe("Enable GET requests with 1x1 transparent GIF response for pixel tracking").default(!0),healthPath:s.string().describe("Health check endpoint path (e.g., /health)").default("/health")}),l=o(u);import{zodToSchema as d}from"@walkeros/core/dev";import{z as f}from"@walkeros/core/dev";var p=f.object({queueName:f.string().min(1).describe("SQS queue short name (like walkeros-events). Required for both setup and runtime poll."),region:f.string().describe("AWS region (like eu-central-1). Default: eu-central-1.").optional(),queueUrl:f.string().url().describe("Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.").optional(),client:f.any().describe("Pre-configured AWS SQSClient instance. Bypasses construction when supplied.").optional(),config:f.any().describe("AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).").optional(),decoder:f.enum(["json","text","raw"]).describe("Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.").optional(),maxMessages:f.number().int().min(1).max(10).describe("SQS receive batch size. Cap 10. Default: 10.").optional(),waitTimeSeconds:f.number().int().min(0).max(20).describe("Long-poll duration in seconds. Cap 20. Default: 20.").optional(),visibilityTimeout:f.number().int().nonnegative().describe("Per-receive visibility timeout override. Default: queue-configured value.").optional(),shutdownTimeoutMs:f.number().int().positive().describe("Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.").optional(),onPushError:f.enum(["nack","ack"]).describe("Behavior when forwarding to the collector throws. nack (default) skips DeleteMessage so the message redelivers; ack drops it.").optional()});import{z as g}from"@walkeros/core/dev";var h=g.record(g.string(),g.string()),m=g.object({region:g.string().min(1).describe("AWS region.").optional(),fifoQueue:g.boolean().describe("FIFO queue with content-based deduplication. Auto-appends .fifo suffix to the queue name.").optional(),visibilityTimeoutSeconds:g.number().int().nonnegative().describe("Visibility timeout in seconds. Default: 30.").optional(),messageRetentionSeconds:g.number().int().positive().describe("Message retention period in seconds. Default: 345600 (4 days).").optional(),maximumMessageSize:g.number().int().min(1024).max(262144).describe("Max message size in bytes. Default: 262144 (256 KB).").optional(),kmsMasterKeyId:g.string().describe("KMS key alias or ID for at-rest encryption.").optional(),deadLetterQueue:g.object({arn:g.string().describe("ARN of an existing DLQ. Mutually exclusive with create: true.").optional(),create:g.boolean().describe("Create a sibling DLQ named <queueName>-dlq. Default: false.").optional(),maxReceiveCount:g.number().int().min(1).max(1e3).describe("Max receive count before message goes to DLQ. Default: 5.").optional()}).describe("Optional dead-letter queue.").optional(),tags:h.describe("Tags applied to the queue (and inherited by an auto-created DLQ).").optional(),subscribeToSnsTopic:g.object({topicArn:g.string().min(1).describe("Topic ARN to subscribe to."),rawMessageDelivery:g.boolean().describe("Deliver SNS messages without the SNS envelope.").optional(),filterPolicy:g.record(g.string(),g.unknown()).describe("SNS filter policy applied at subscription level.").optional()}).describe("Optional SNS topic subscription. Creates the subscription and the matching queue policy.").optional()}),y=d(p),w=d(m),v={};t(v,{createTrigger:()=>an,env:()=>b,step:()=>I,trigger:()=>cn});var b={};t(b,{push:()=>O});var k=()=>()=>Promise.resolve({ok:!0}),S=()=>{},q={error:S,warn:S,info:S,debug:S,throw:e=>{throw"string"==typeof e?new Error(e):e},json:S,scope:()=>q},O={get push(){return k()},get command(){return k()},get elb(){return k()},logger:q},I={};t(I,{apiGatewayV1Post:()=>C,lambdaGet:()=>j,lambdaPost:()=>x});var x={title:"Lambda POST",description:"An API Gateway v2 HTTP POST with a JSON body is converted into a walker elb event.",trigger:{type:"POST"},in:{version:"2.0",requestContext:{http:{method:"POST",path:"/collect"},requestId:"req-123"},body:JSON.stringify({event:"page view",data:{title:"Home"}}),isBase64Encoded:!1},out:[["elb",{name:"page view",data:{title:"Home"}}]]},C={title:"API Gateway v1 POST",description:"A REST API Gateway v1 POST request with a JSON body is converted into a walker elb event.",trigger:{type:"POST"},in:{httpMethod:"POST",path:"/collect",requestContext:{requestId:"req-789",identity:{sourceIp:"203.0.113.42"}},queryStringParameters:null,body:JSON.stringify({event:"page view",data:{title:"Home"}}),isBase64Encoded:!1},out:[["elb",{name:"page view",data:{title:"Home"}}]]},j={title:"Lambda GET",description:"An API Gateway v2 HTTP GET with query parameters is parsed into an elb event payload.",trigger:{type:"GET"},in:{version:"2.0",requestContext:{http:{method:"GET",path:"/collect"},requestId:"req-456"},rawQueryString:"e=page+view&d=%7B%22title%22%3A%22Home%22%7D",isBase64Encoded:!1},out:[["elb",{e:"page view",d:'{"title":"Home"}'}]]};import{assign as A}from"@walkeros/core";import{assign as D,createLogger as T}from"@walkeros/core";import{assign as E,buildCacheContext as M,clone as P,compileCache as $,checkCache as _,storeCache as R,createIngest as H,debounce as G,emitStep as N,getId as B,getGrantedConsent as z,getNextSteps as F,isDefined as L,isFunction as U,isObject as K,processEventMapping as Q,stepId as J,tryCatchAsync as W,useHooks as V,compileState as Y,applyState as X}from"@walkeros/core";import{emitStep as Z}from"@walkeros/core";import{isArray as ee,FatalError as te}from"@walkeros/core";import{tryCatch as ne,tryCatchAsync as oe}from"@walkeros/core";import{createIngest as se,FatalError as re,getMappingValue as ie,tryCatchAsync as ae,getNextSteps as ce,compileCache as ue,checkCache as le,storeCache as de,applyUpdate as fe,buildCacheContext as pe,compileState as ge,applyState as he}from"@walkeros/core";import{createIngest as me,emitStep as ye,FatalError as we,isObject as ve,stepId as be,tryCatchAsync as ke,useHooks as Se,getNextSteps as qe,compileCache as Oe,checkCache as Ie,storeCache as xe,buildCacheContext as Ce,validateStepEntry as je,processEventMapping as Ae,compileState as De,applyState as Te}from"@walkeros/core";import{assign as Ee,getSpanId as Me,isFunction as Pe,isString as $e}from"@walkeros/core";import{isObject as _e}from"@walkeros/core";import{createIngest as Re,emitStep as He,FatalError as Ge,getGrantedConsent as Ne,processEventMapping as Be,tryCatchAsync as ze,useHooks as Fe}from"@walkeros/core";import{FatalError as Le,useHooks as Ue,tryCatchAsync as Ke}from"@walkeros/core";import{emitStep as Qe,useHooks as Je}from"@walkeros/core";import{compileMatcher as We,emitStep as Ve,readCacheEnvelope as Ye,wrapCacheEnvelope as Xe}from"@walkeros/core";var Ze={Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Scoped:"_",Session:"session",Shutdown:"shutdown",User:"user",Walker:"walker"};function et(e,t){const n=e.status.startedAt;return{flowId:"default",stepId:t.stepId,stepType:t.stepType,phase:t.phase,eventId:t.eventId,timestamp:new Date(t.now).toISOString(),elapsedMs:t.now-n}}function tt(e,t){return e.storeId&&t.stores[e.storeId]?t.stores[e.storeId]:t.stores.__cache}function nt(e,t){return e?t.stores[e]:t.stores.__cache}function ot(e){const t={};for(const[n,o]of Object.entries(e)){const e=o.config?.next;"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)?t[n]={next:e}:t[n]={}}return t}function st(e,t){const n=e.config||{},o=e[t];return void 0!==o?{config:{...n,[t]:o},chainValue:o}:{config:n,chainValue:void 0}}function rt(e,t={}){if(!e)return[];if(Array.isArray(e))return e;const n=[],o=new Set;let s=e;for(;s&&t[s]&&!o.has(s);){o.add(s),n.push(s);const e=t[s].next;if(Array.isArray(e)){n.push(...e);break}s=e}return n}async function it(e,t,n){if(t.init&&!t.config.init){const o=t.type||"unknown",s=e.logger.scope(`transformer:${o}`),r={collector:e,logger:s,id:n,ingest:me(n),config:t.config,env:lt(t.config.env)};s.debug("init");const i=await Se(t.init,"TransformerInit",e.hooks,e.logger)(r);if(!1===i)return!1;t.config={...i||t.config,env:i?.env||t.config.env,init:!0},s.debug("init done")}return!0}async function at(e,t,n,o,s,r){const i=t.type||"unknown",a=e.logger.scope(`transformer:${i}`),c={collector:e,logger:a,id:n,ingest:s,config:t.config,env:{...lt(t.config.env),...r?{respond:r}:{}}};a.debug("push",{event:o.name});const u="string"==typeof o.id?o.id:"",l=Date.now(),d=et(e,{stepId:be("transformer",n),stepType:"transformer",phase:"in",eventId:u,now:l});ye(e,d);try{const s=await Se(t.push,"TransformerPush",e.hooks,e.logger)(o,c),r=Date.now(),i=et(e,{stepId:be("transformer",n),stepType:"transformer",phase:"out",eventId:u,now:r});return i.durationMs=r-l,i.outEvent=s,ye(e,i),a.debug("push done"),s}catch(t){const o=Date.now(),s=et(e,{stepId:be("transformer",n),stepType:"transformer",phase:"error",eventId:u,now:o});throw s.durationMs=o-l,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},ye(e,s),t}}function ct(e,t){return e?{...e,_meta:{...e._meta,path:[...e._meta.path]}}:me(t)}async function ut(e,t,n,o,s,r,i){s||(s=me(n[0]??"chain")),i&&s._meta&&(s._meta.chainPath=i);let a=o,c=r;for(const o of n){const r=t[o];if(!r){e.logger.warn(`Transformer not found: ${o}`);continue}if(s&&s._meta&&s._meta.path.length>256)return e.logger.error(`Max path length exceeded at ${o}`),{event:null,respond:c};if(s&&s._meta&&(s._meta.hops++,s._meta.path.push(o)),!await ke(it,t=>{if(t instanceof we)throw t;return e.status.failed++,e.logger.scope(`transformer:${r.type||"unknown"}`).error("transformer init failed",{transformer:o,error:t}),!1})(e,r,o))return{event:null,respond:c};if(i&&void 0!==r.config?.chainMocks?.[i]){const t=r.config.chainMocks[i];e.logger.scope(`transformer:${r.type||"unknown"}`).debug("chainMock",{chain:i}),a=t;continue}if(void 0!==r.config?.mock){e.logger.scope(`transformer:${r.type||"unknown"}`).debug("mock"),a=r.config.mock;continue}if(r.config?.disabled)continue;const u=r.config?.cache,l=u?Oe(u):void 0,d=l?tt(l,e):void 0,f=r.config?.state?De(r.config.state):void 0,p=f?.filter(e=>"get"===e.mode),g=f?.filter(e=>"set"===e.mode),h=async t=>g&&0!==g.length?Te(g,t=>nt(t,e),t,e):t;let m;if(l&&d){const e=Ce(s,a),t=await Ie(l,d,e);if("HIT"===t?.status&&t.value){if(a=t.value,l.stop)return{event:a,respond:c,stopped:!0};continue}"MISS"===t?.status&&(m={key:t.key,ttl:t.rule.ttl})}const y=r.config.before;if(y){const n=qe(y,Ce(s,a));if(1===n.length){const o=rt(n[0],ot(t));if(o.length>0){const n=await ut(e,t,o,a,s,c,i);if(null===n.event)return{event:null,respond:n.respond??c};if(n.stopped)return{event:Array.isArray(n.event)?n.event[0]:n.event,respond:n.respond??c,stopped:!0};n.respond&&(c=n.respond),a=Array.isArray(n.event)?n.event[0]:n.event}}else n.length>1&&await Promise.all(n.map(n=>ke(ut,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,rt(n,ot(t)),a,ct(s,n),void 0,i)))}p&&p.length>0&&(a=await Te(p,t=>nt(t,e),a,e));const w=await ke(at,t=>(e.logger.scope(`transformer:${r.type||"unknown"}`).error("Push failed",{error:t}),!1))(e,r,o,a,s,c);if(!1===w)return{event:null,respond:c};if(Array.isArray(w)){const r=n.slice(n.indexOf(o)+1),u=await Promise.all(w.map(async n=>{const o=await h(n.event||a),u=ct(s,"unknown");if(n.next){const s=qe(n.next,Ce(u,o));if(0===s.length)return{event:o,respond:c};if(1===s.length){const n=rt(s[0],ot(t));return n.length>0?ut(e,t,n,o,u,c,i):{event:o,respond:c}}return(await Promise.all(s.map(n=>ke(ut,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,rt(n,ot(t)),o,ct(u,n),void 0,i)))).map(e=>({event:e.event,respond:void 0}))}return r.length>0?ut(e,t,r,o,u,c,i):{event:o,respond:c}}));let l=c;const d=[];for(const e of u.flat())if(null!==e)if(e&&"object"==typeof e&&"event"in e){const t=e;if(t.respond&&(l=t.respond),null===t.event)continue;Array.isArray(t.event)?d.push(...t.event):d.push(t.event)}else d.push(e);return 0===d.length?{event:null,respond:l}:1===d.length?{event:d[0],respond:l}:{event:d,respond:l}}if(w&&"object"==typeof w){const{event:n,respond:o,next:r}=w;if(o&&(c=o),void 0!==r){const o=await h(n||a),u=qe(r,Ce(s,o));if(0===u.length){a=o;continue}if(1===u.length){const n=rt(u[0],ot(t));return n.length>0?ut(e,t,n,o,s,c,i):(e.logger.warn(`Branch target not found: ${JSON.stringify(r)}`),{event:null,respond:c})}return await Promise.all(u.map(n=>ke(ut,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,rt(n,ot(t)),o,ct(s,n),void 0,i))),{event:null,respond:void 0}}n&&(a=n)}g&&g.length>0&&(a=await Te(g,t=>nt(t,e),a,e)),m&&d&&xe(d,m.key,a,m.ttl);const v=r.config.next,b="string"==typeof v||Array.isArray(v)&&v.every(e=>"string"==typeof e),k=void 0!==v&&!b;if((!w||"object"==typeof w&&!w.next)&&k){const n=qe(r.config.next,Ce(s,a));if(1===n.length){const o=rt(n[0],ot(t));return o.length>0?ut(e,t,o,a,s,c,i):{event:a,respond:c}}return n.length>1?(await Promise.all(n.map(n=>ke(ut,t=>(e.logger.scope("transformer:many").error(`many branch ${n} failed`,{error:t}),{event:null,respond:void 0}))(e,t,rt(n,ot(t)),a,ct(s,n),void 0,i))),{event:null,respond:void 0}):{event:a,respond:c}}}return{event:a,respond:c}}function lt(e){return e&&ve(e)?e:{}}function dt(e){return"string"==typeof e||!(!Array.isArray(e)||!e.every(e=>"string"==typeof e))}async function ft(e,t,n){if(!t.on||!t.queueOn?.length)return;const o=t.queueOn;t.queueOn=[];const s=n||t.config?.id||"unknown";for(const{type:n,data:r}of o)kt(n)&&!xt(e,t,n)||(await ae(t.on,t=>{if(t instanceof re)throw t;e.status.failed++,e.logger.scope("source").error("source on flush failed",{sourceId:s,type:n,error:t})})(n,r),kt(n)&&It(e,t,n))}function pt(e){return Boolean(e.config.init)&&!e.config.require?.length}async function gt(e,t,n){const{code:o,config:s={},env:r={},primary:i,next:a,before:c,cache:u}=n,l=s.state??n.state,d=l?ge(l):void 0,f=u,p=f?ue({...f,stop:f.stop??!0}):void 0,g=dt(a)?rt(a,ot(e.transformers)):void 0,h=dt(c)?rt(c,ot(e.transformers)):void 0,m=r.push,y=m??e.push,w=Boolean(m),v=async(n,o,r)=>{let i;const u=h??(void 0!==c?(()=>{const t=ce(c,pe(r.ingest));return 0===t.length?[]:rt(1===t.length?t[0]:t,ot(e.transformers))})():[]);let l=[n];if(u.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const o=await ut(e,e.transformers,u,n,r.ingest,r.respond,`source.${t}.before`);if(null===o.event)return{ok:!0};if(o.stopped)return o.respond&&(r.respond=o.respond),{ok:!0};o.respond&&(r.respond=o.respond),l=Array.isArray(o.event)?o.event:[o.event]}if(p){const t=tt(p,e);if(t){const n=pe(r.ingest),o=await le(p,t,n);if(o){if("HIT"===o.status&&void 0!==o.value&&p.stop){let t=o.value;return o.rule.update&&(t=await fe(t,o.rule.update,{...n,cache:{status:"HIT"}},e)),r.respond?.(t),{ok:!0}}if("MISS"===o.status&&p.stop&&r.respond){const s=r.respond,a=o.rule.update,c={...n,cache:{status:"MISS"}},u=o.key,l=o.rule.ttl,d=n=>{de(t,u,n,l),a?i=(async()=>{const t=await fe(n,a,c,e);s(t)})():s(n)};r.respond=d}"MISS"!==o.status||p.stop||de(t,o.key,!0,o.rule.ttl)}}}const f=g?{kind:"single",preChain:g}:void 0!==a?(()=>{const t=ce(a,pe(r.ingest));return 0===t.length?{kind:"single",preChain:[]}:1===t.length?{kind:"single",preChain:rt(t[0],ot(e.transformers))}:{kind:"many",branches:t.map(t=>rt(t,ot(e.transformers)))}})():{kind:"single",preChain:[]};!w&&d&&d.length>0&&(l=await Promise.all(l.map(t=>he(d,t=>nt(t,e),t,e))));let m={ok:!0};for(const n of l)"many"===f.kind?(await Promise.all(f.branches.map((i,a)=>ae(async()=>w?y(n):y(n,{...o,id:t,ingest:ct(r.ingest,`${t}.${a}`),respond:void 0,mapping:s,preChain:i}),t=>(e.logger.scope("source:many").error(`many branch ${a} failed`,{error:t}),{ok:!0}))())),m={ok:!0}):m=w?await y(n):await y(n,{...o,id:t,ingest:r.ingest,respond:r.respond,mapping:s,preChain:f.preChain});return i&&await i,m},b=async n=>{const o=se(t);if(!s.ingest||void 0===n)return o;const r=await ie(n,s.ingest,{collector:e});return{...o,...r,_meta:o._meta}},k=e.logger.scope("source").scope(t),S={command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:k,...r,push:async(e,n={})=>{const o={ingest:se(t),respond:void 0};return v(e,n,o)}},q={collector:e,logger:k,id:t,config:s,env:S,withScope:async(e,t,n)=>{const o={ingest:await b(e),respond:t};return n({...S,push:(e,t={})=>v(e,t,o),ingest:o.ingest,respond:o.respond})}},O=await ae(o,n=>{if(n instanceof re)throw n;e.status.failed++,e.logger.scope("source").error("source factory failed",{sourceId:t,error:n})})(q);if(!O)return;const I=O.type||"unknown",x=e.logger.scope(I).scope(t);return S.logger=x,i&&(O.config={...O.config,primary:i}),O}async function ht(e){for(const[t,n]of Object.entries(e.sources)){if(pt(n))continue;const o=n.config.require;if(!o?.length)continue;const s=o.filter(t=>!qt(e,t));s.length!==o.length&&(n.config.require=s,pt(n)&&await ft(e,n,t))}for(const[t,n]of Object.entries(e.pending.destinations)){if(!e.pending.destinations[t]||e.destinations[t])continue;const o=n.config?.require;if(!o)continue;const s=o.filter(t=>!qt(e,t));if(n.config&&(n.config.require=s),s.length>0)continue;delete e.pending.destinations[t];const r=Qt(n);!1!==r.config.queue&&(r.queuePush=[...e.queue]),e.destinations[t]=r}}function mt(e){if("object"!=typeof e||null===e)return!1;if(!("logger"in e))return!1;const t=e.logger;return"object"==typeof t&&null!==t&&"scope"in t&&"function"==typeof t.scope}var yt=!1;function wt(){yt||(yt=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn("walkerOS: ignored an on-dispatch call with a non-collector argument"))}function vt(e,t,n,o){if(n instanceof te)throw n;e.logger.scope("on").error("on callback failed",{kind:t,...o,error:n})}var bt=[Ze.Consent,Ze.User,Ze.Globals,Ze.Custom];function kt(e){return bt.includes(e)}function St(e,t){switch(t){case Ze.Consent:return Object.keys(e.consent).length>0;case Ze.User:return Object.keys(e.user).length>0;case Ze.Globals:return Object.keys(e.globals).length>0;case Ze.Custom:return Object.keys(e.custom).length>0;default:return!1}}function qt(e,t){switch(t){case Ze.Consent:case Ze.User:case Ze.Globals:case Ze.Custom:return St(e,t);case Ze.Run:case Ze.Ready:return!0===e.allowed;default:return e.seenEvents.has(String(t))}}function Ot(e,t){return e.cellVersion[String(t)]??0}function It(e,t,n){let o=e.delivery.get(t);o||(o={},e.delivery.set(t,o)),o[String(n)]=Ot(e,n)}function xt(e,t,n){return e.allowed&&Ot(e,n)>function(e,t,n){const o=e.delivery.get(t),s=o?.[String(n)];return void 0===s?-1:s}(e,t,n)}function Ct(e,t,n){const o=e.cascade;if(!o)return!0;let s=o.counts.get(t);s||(s={},o.counts.set(t,s));const r=String(n),i=(s[r]||0)+1;return s[r]=i,i<=8||(9===i&&e.logger.error("state delivery did not converge",{type:r}),!1)}function jt(e,t){return{collector:e,logger:e.logger.scope("on").scope(String(t))}}function At(e,t,n,o,s){if(!t.on)return;const r=t.type||"unknown",i=e.logger.scope(r).scope("on").scope(o),a={collector:e,logger:i,id:n,config:t.config,data:s,env:Jt(t.env,t.config.env)};ne(t.on,t=>vt(e,"destination",t,{destId:n,type:o}))(o,a)}function Dt(e,t,n,o){if(!mt(e))return void wt();const s=Tt(e,t,o);if(n.length)switch(t){case Ze.Consent:!function(e,t,n){const o=n||e.consent,s=jt(e,Ze.Consent);t.forEach(t=>{xt(e,t,Ze.Consent)&&Ct(e,t,Ze.Consent)&&(Object.keys(o).filter(e=>e in t).forEach(n=>{ne(t[n],t=>vt(e,"consent",t,{key:n}))(o,s)}),It(e,t,Ze.Consent))})}(e,n,o);break;case Ze.Ready:!function(e,t){if(!e.allowed)return;const n=jt(e,Ze.Ready);t.forEach(t=>{ne(t,t=>vt(e,"ready",t))(void 0,n)})}(e,n);break;case Ze.Run:!function(e,t){if(!e.allowed)return;const n=jt(e,Ze.Run);t.forEach(t=>{ne(t,t=>vt(e,"run",t))(void 0,n)})}(e,n);break;case Ze.Session:!function(e,t){if(!e.session)return;const n=jt(e,Ze.Session);t.forEach(t=>{ne(t,t=>vt(e,"session",t))(e.session,n)})}(e,n);break;default:{const o=jt(e,t),r=kt(t);n.forEach(n=>{"function"==typeof n&&(r&&!xt(e,n,t)||r&&!Ct(e,n,t)||(ne(n,n=>vt(e,"generic",n,{type:t}))(s,o),r&&It(e,n,t)))});break}}}function Tt(e,t,n){switch(t){case Ze.Consent:return n||e.consent;case Ze.Session:return e.session;case Ze.User:return n||e.user;case Ze.Custom:return n||e.custom;case Ze.Globals:return n||e.globals;case Ze.Config:return n||e.config;default:return}}async function Et(e,t,n,o,s){if(!t.on)return!1;if(kt(o)&&!xt(e,t,o))return!1;if(kt(o)&&!Ct(e,t,o))return!1;const r=await oe(t.on,t=>vt(e,"source",t,{sourceId:n,type:o}))(o,s);return kt(o)&&It(e,t,o),!1===r}function Mt(e,t,n,o){if(!Number.isFinite(n.max)||n.max<=0)throw new Error(`pushBounded: max must be > 0 (got ${n.max})`);if("dropNewest"===(n.onOverflow??"dropOldest"))return e.length>=n.max?(o&&o([t]),{appended:!1,dropped:1}):(e.push(t),{appended:!0,dropped:0});const s=[];for(;e.length>=n.max;)s.push(e.shift());return e.push(t),s.length>0&&o&&o(s),{appended:!0,dropped:s.length}}var Pt=new WeakMap;function $t(e,t,n,o){Pt.get(e)||(Pt.set(e,!0),t.warn(n,o))}function _t(e){Pt.delete(e)}var Rt=Object.freeze({batched:!0});function Ht(e){return e===Rt}function Gt(e){return void 0===e?{}:"number"==typeof e?{wait:e}:{wait:e.wait,size:e.size,age:e.age}}function Nt(e,t){return e.status.destinations[t]||(e.status.destinations[t]={count:0,failed:0,duration:0,queuePushSize:0,dlqSize:0}),e.status.destinations[t]}function Bt(e,t,n,o){e.dropped[t]||(e.dropped[t]={});const s=e.dropped[t];return s[n]=(s[n]??0)+o,s[n]}function zt(e,t,n){if(!e)return[];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return rt(e,t);if("string"==typeof e)return rt(e,t);const o=F(e,M(n));return 0===o.length?[]:1===o.length?rt(o[0],t):rt(o,t)}async function Ft(e,t,n={},o){const{allowed:s,consent:r,globals:i,user:a}=e;if(!s)return Kt({ok:!1});if(t){const n=e.config.queueMax;if(void 0===n)throw new Error("Collector.Config.queueMax is undefined; defaults must be seeded by collector()");const o=Mt(e.queue,t,{max:n});if(o.dropped>0){const t=Bt(e.status,J("collector"),"queue",o.dropped);$t(e.queue,e.logger,"collector.queue overflow; oldest events dropped",{buffer:"queue",cap:n,droppedCount:t})}else e.queue.length<n&&_t(e.queue);e.status.in++}o||(o=e.destinations);const c=e.transformers?ot(e.transformers):{},u=await Promise.all(Object.entries(o||{}).map(async([o,s])=>{if(s.config.disabled)return{id:o,destination:s,skipped:!0};let u=(s.queuePush||[]).map(e=>({...e,consent:r}));s.queuePush=[],t&&u.push(P(t));const l=n.ingest?{...n.ingest,_meta:{...n.ingest._meta,path:[...n.ingest._meta.path]}}:H("unknown");if(!u.length&&!s.queueOn?.length)return{id:o,destination:s,skipped:!0};if(!u.length&&s.queueOn?.length){if(!z(s.config.consent,r))return{id:o,destination:s,skipped:!0};let t=!1;try{t=await Lt(e,s,o,!0)}catch(t){e.status.failed++;const n=s.type||"unknown";e.logger.scope(n).error("destination init failed",{error:t instanceof Error?t.message:String(t)})}return{id:o,destination:s,skipped:!t}}const d=[],f=u.filter(t=>{const n=z(s.config.consent,r,t.consent);if(n)return t.consent=n,d.push(t),!1;const i=et(e,{stepId:J("destination",o),stepType:"destination",phase:"skip",eventId:"string"==typeof t.id?t.id:"",now:Date.now()});return i.skipReason="consent",r&&(i.consent={...r}),s.config.consent&&(i.meta={required:{...s.config.consent}}),N(e,i),!0});if(f.length>0){const t=s.queuePush,n=s.config.id||o,r={max:s.config.queueMax??1e3};let i=0;for(const e of f)i+=Mt(t,e,r).dropped;if(i>0){Nt(e,n);const o=Bt(e.status,J("destination",n),"queue",i);$t(t,e.logger.scope(s.type||"unknown"),"destination.queuePush overflow; oldest events dropped",{buffer:"queuePush",destination:n,cap:r.max,droppedCount:o})}else t.length<r.max&&_t(t)}if(!d.length)return{id:o,destination:s,queue:u};let p,g,h=!1;try{h=await Lt(e,s,o,!0)}catch(t){e.status.failed++;const n=s.type||"unknown";e.logger.scope(n).error("destination init failed",{error:t instanceof Error?t.message:String(t)})}if(!h)return{id:o,destination:s,queue:u};s.dlq||(s.dlq=[]);const m=zt(s.config.before,c,l),y=s.config.next,w=s.config?.cache,v=w?$(w):void 0,b=v?tt(v,e):void 0,k=s.config?.state?Y(s.config.state):void 0,S=k?.filter(e=>"get"===e.mode),q=k?.filter(e=>"set"===e.mode);let O=0,I=0;return await Promise.all(d.map(async t=>{let r;if(t.globals=E(i,t.globals),t.user=E(a,t.user),v?.stop&&b){const e=M(l,t),n=await _(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}let u=t,d=n.respond;if(m.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const s=await ut(e,e.transformers,m,t,l,n.respond,`destination.${o}.before`);if(null===s.event)return t;s.respond&&(d=s.respond),u=Array.isArray(s.event)?s.event[0]:s.event}if(v&&!v.stop&&b){const e=M(l,u),n=await _(v,b,e);if("HIT"===n?.status)return t;"MISS"===n?.status&&(r={key:n.key,ttl:n.rule.ttl})}S&&S.length>0&&u&&(u=await X(S,t=>nt(t,e),u,e));const f=Date.now();let h=!1;const w=await W(Ut,t=>{const n=s.type||"unknown";e.logger.scope(n).error("Push failed",{error:t,event:u.name}),p=t,h=!0;const r=s.dlq,i=s.config.id||o,a={max:s.config.dlqMax??100},c=Mt(r,[u,t],a);if(c.dropped>0){Nt(e,i);const t=Bt(e.status,J("destination",i),"dlq",c.dropped);$t(r,e.logger.scope(s.type||"unknown"),"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:i,cap:a.max,droppedCount:t})}else r.length<a.max&&_t(r)})(e,s,o,u,l,d);if(O+=Date.now()-f,r&&b&&void 0===s.config.mock&&R(b,r.key,w??!0,r.ttl),!h&&!Ht(w)&&q&&q.length>0&&u&&(u=await X(q,t=>nt(t,e),u,e)),void 0===w||Ht(w)||(g=w),Ht(w)&&I++,!h&&y){void 0!==w&&(l._response=w);const t=zt(y,c,l);if(t.length>0&&e.transformers&&Object.keys(e.transformers).length>0){const n=await ut(e,e.transformers,t,u,l,d,`destination.${o}.next`);n.respond&&(d=n.respond)}}return t})),{id:o,destination:s,error:p,response:g,totalDuration:O,batchedCount:I,allowedCount:d.length}})),l={},d={},f={};for(const t of u){if(t.skipped)continue;const n=t.destination,o={type:n.type||"unknown",data:t.response};Nt(e,t.id);const s=e.status.destinations[t.id],r=Date.now();if(s.queuePushSize=n.queuePush?.length??0,s.dlqSize=n.dlq?.length??0,t.error)o.error=t.error,f[t.id]=o,s.failed++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.failed++;else if(t.queue&&t.queue.length)d[t.id]=o;else{const n=t.batchedCount??0,i=t.allowedCount??0;(Math.max(0,i-n)>0||0===i)&&(l[t.id]=o,s.count++,s.lastAt=r,s.duration+=t.totalDuration||0,e.status.out++)}}return Kt({event:t,...Object.keys(l).length&&{done:l},...Object.keys(d).length&&{queued:d},...Object.keys(f).length&&{failed:f}})}async function Lt(e,t,n,o=!1){if(t.init&&!t.config.init){if(!o&&function(e){const t=e.config.consent;return!!t&&Object.keys(t).length>0}(t))return e.logger.scope(t.type||"unknown").debug("init blocked: consent gate not cleared"),!1;const s=t.type||"unknown",r=e.logger.scope(s),i={collector:e,logger:r,id:n,config:t.config,env:Jt(t.env,t.config.env)};r.debug("init");const a=Date.now();let c;N(e,et(e,{stepId:J("destination",n),stepType:"destination",phase:"init",eventId:"",now:a}));try{c=await V(t.init,"DestinationInit",e.hooks,e.logger)(i)}catch(t){const o=Date.now(),s=et(e,{stepId:J("destination",n),stepType:"destination",phase:"error",eventId:"",now:o});throw s.durationMs=o-a,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},N(e,s),t}if(!1===c)return c;if(t.config={...c||t.config,init:!0},t.queueOn?.length){const o=t.queueOn;t.queueOn=[];for(const{type:s,data:r}of o)At(e,t,n,s,r)}r.debug("init done")}return!0}async function Ut(e,t,n,o,s,r){const{config:i}=t,a=await Q(o,i,e);if(a.ignore)return!1;const c=t.type||"unknown",u=e.logger.scope(c),l={collector:e,logger:u,id:n,config:i,data:a.data,rule:a.mapping,ingest:s,env:{...Jt(t.env,i.env),...r?{respond:r}:{}}};if(void 0!==i.mock)return u.debug("mock",{event:a.event.name}),i.mock;const d=a.mapping,f=void 0!==d?.batch,p=f?a.mappingKey||"* *":" batch-all";if((f||void 0!==i.batch)&&t.pushBatch&&void 0===i.mock){if(t.batches=t.batches||{},!t.batches[p]){const o={key:p,entries:[],events:[],data:[]},s=Gt(d?.batch),r=Gt(i.batch),a=s.wait??r.wait??3e4,c=s.size??r.size??1e3,l=s.age??r.age??3e4,g=Jt(t.env,i.env),h=G(async()=>{const o=t.batches[p],s=o.batched;if(0===s.entries.length)return;const r={key:s.key,entries:s.entries,events:s.events,data:s.data};s.entries=[],s.events=[],s.data=[];const a=r.entries[0],c={collector:e,logger:u,id:n,config:i,data:void 0,rule:o.isDefault?void 0:a.rule,ingest:a.ingest,env:{...g,...a.respond?{respond:a.respond}:{}}};u.debug("push batch",{events:r.entries.length});const l=t.config.id||n,d=Nt(e,l),f=Date.now(),h=et(e,{stepId:J("destination",n),stepType:"destination",phase:"flush",eventId:"",now:f});h.batch={size:r.entries.length,index:0},N(e,h);const m=n=>{const o=t.dlq=t.dlq||[],s={max:t.config.dlqMax??100};let r=0;for(const e of n)r+=Mt(o,e,s).dropped;if(r>0){const t=Bt(e.status,J("destination",l),"dlq",r);$t(o,u,"destination.dlq overflow; oldest entries dropped",{buffer:"dlq",destination:l,cap:s.max,droppedCount:t})}else o.length<s.max&&_t(o);d.failed+=n.length,d.dlqSize=o.length,e.status.failed+=n.length};let y=r.entries.length;const w=await W(V(t.pushBatch,"DestinationPushBatch",e.hooks,e.logger),t=>{y=0;const o=Date.now(),s=et(e,{stepId:J("destination",n),stepType:"destination",phase:"error",eventId:"",now:o});s.durationMs=o-f,s.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},s.batch={size:r.entries.length,index:0},N(e,s),m(r.entries.map(e=>[e.event,t])),u.error("Push batch failed",{error:t instanceof Error?t.message:String(t),entries:r.entries.length})})(r,c);if(K(v=w)&&Array.isArray(v.failed)&&w.failed.length>0){const e=[],t=new Set;for(const n of w.failed){const o=r.entries[n.index];o&&!t.has(n.index)&&(t.add(n.index),e.push([o.event,n.error??new Error(`Push batch entry ${n.index} failed (no per-row error provided)`)]))}e.length>0&&(m(e),y=Math.max(0,r.entries.length-e.length),u.error("Push batch partial failure",{failed:e.length,delivered:y,entries:r.entries.length}))}var v;u.debug("push batch done"),d.inFlightBatch=Math.max(0,(d.inFlightBatch??0)-r.entries.length),y>0&&(d.count+=y,d.lastAt=Date.now(),e.status.out+=y)},{wait:a,size:c,age:l});t.batches[p]={batched:o,isDefault:!f,batchFn:()=>{h()},flush:async()=>{await h.flush()}}}const o=t.batches[p];o.batched.entries.push({event:a.event,ingest:s,respond:r,rule:d,data:a.data}),o.batched.events.push(a.event),L(a.data)&&o.batched.data.push(a.data);const c=t.config.id||n,l=Nt(e,c);return l.inFlightBatch=(l.inFlightBatch??0)+1,o.batchFn(),Rt}{u.debug("push",{event:a.event.name});const o="string"==typeof a.event.id?a.event.id:"",s=Date.now(),r=et(e,{stepId:J("destination",n),stepType:"destination",phase:"in",eventId:o,now:s});a.mappingKey&&(r.mappingKey=a.mappingKey),a.event.consent&&(r.consent={...a.event.consent}),N(e,r);try{const r=await V(t.push,"DestinationPush",e.hooks,e.logger)(a.event,l),i=Date.now(),c=et(e,{stepId:J("destination",n),stepType:"destination",phase:"out",eventId:o,now:i});return c.durationMs=i-s,c.outEvent=r,a.mappingKey&&(c.mappingKey=a.mappingKey),N(e,c),u.debug("push done"),r}catch(t){const r=Date.now(),i=et(e,{stepId:J("destination",n),stepType:"destination",phase:"error",eventId:o,now:r});throw i.durationMs=r-s,i.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},a.mappingKey&&(i.mappingKey=a.mappingKey),N(e,i),t}}}function Kt(e){return{ok:!e?.failed,...e}}function Qt(e){const{code:t,config:n={},env:o={},cache:s,state:r}=e,{config:i}=st(e,"before"),{config:a}=st({...e,config:i},"next"),c={...t.config,...n,...a};s&&(c.cache=s),void 0!==r&&void 0===c.state&&(c.state=r);const u=Jt(t.env,o);return{...t,config:c,env:u}}function Jt(e,t){return e||t?t?e&&K(e)&&K(t)?{...e,...t}:t:e:{}}async function Wt(e,t,n){const o=Object.entries(e).map(async([e,o])=>{const s=o.destroy;if(!s)return;const r=o.type||"unknown",i=n.scope(r),a={id:e,config:o.config,env:o.env??{},logger:i};let c;try{await Promise.race([s(a),new Promise((n,o)=>{c=setTimeout(()=>o(new Error(`${t} '${e}' destroy timed out`)),5e3)})])}catch(n){i.error(`${t} '${e}' destroy failed: ${n}`)}finally{c&&clearTimeout(c)}});await Promise.allSettled(o)}function Vt(e,t){e.stateVersion++,e.cellVersion[t]=e.stateVersion}async function Yt(e,t,n){let o,s,r=!1;const i=function(e){return e.cascade?()=>{}:(e.cascade={counts:new WeakMap},()=>{e.cascade=void 0})}(e);try{return await async function(){switch(t){case Ze.Config:_e(n)&&(Ee(e.config,n,{shallow:!1}),s=n,r=!0);break;case Ze.Consent:if(_e(n)){const{update:t}=function(e,t){const n={};return Object.entries(t).forEach(([e,t])=>{n[e]=!!t}),e.consent=A(e.consent,n),{update:n}}(e,n);Vt(e,Ze.Consent),s=t,r=!0}break;case Ze.Custom:_e(n)&&(e.custom=Ee(e.custom,n),Vt(e,Ze.Custom),s=n,r=!0);break;case Ze.Destination:_e(n)&&"code"in n&&_e(n.code)&&(o=await async function(e,t){const{code:n,config:o={},env:s={},before:r,next:i,cache:a,state:c}=t;if(!U(n.push))return Kt({ok:!1,failed:{invalid:{type:"invalid",error:"Destination code must have a push method"}}});const u=o||{init:!1};let l=r?{...u,before:r}:{...u};i&&(l={...l,next:i}),a&&(l={...l,cache:a}),void 0!==c&&void 0===l.state&&(l={...l,state:c});let d=l.id;if(!d)do{d=B(5,"abcdefghijklmnopqrstuvwxyz")}while(e.destinations[d]||e.pending.destinations[d]);if(l.require?.length){e.pending.destinations[d]=t,await ht(e);const n=e.destinations[d];return n?Ft(e,void 0,{},{[d]:n}):Kt({ok:!0})}const f={...n,config:l,env:Jt(n.env,s)};return e.destinations[d]=f,!1!==f.config.queue&&(f.queuePush=[...e.queue]),Ft(e,void 0,{},{[d]:f})}(e,n));break;case Ze.Globals:_e(n)&&(e.globals=Ee(e.globals,n),Vt(e,Ze.Globals),s=n,r=!0);break;case Ze.Hook:if(_e(n)&&$e(n.name)&&Pe(n.fn)){const{name:t,fn:o}=n;e.hooks[t]=o,s=n,r=!0}break;case Ze.On:if(_e(n)&&$e(n.type)){const{type:t,rules:o}=n;await async function(e,t,n){if(!mt(e))return void wt();const o=e.on,s=o[t]||[],r=ee(n)?n:[n];r.forEach(e=>{s.push(e)}),o[t]=s,Dt(e,t,r)}(e,t,o)}break;case Ze.Ready:r=!0;break;case Ze.Run:o=await async function(e,t){return e.allowed=!0,e.timing=Date.now(),t&&(t.consent&&(e.consent=Ee(e.consent,t.consent),Vt(e,Ze.Consent)),t.user&&(e.user=Ee(e.user,t.user),Vt(e,Ze.User)),t.globals&&(e.globals=Ee(e.config.globalsStatic||{},t.globals),Vt(e,Ze.Globals)),t.custom&&(e.custom=Ee(e.custom,t.custom),Vt(e,Ze.Custom))),Object.values(e.destinations).forEach(e=>{e.queuePush=[]}),e.queue=[],e.round++,await ht(e),await async function(e){if(mt(e))for(const t of bt){if(!St(e,t))continue;const n=Tt(e,t);Dt(e,t,e.on[t]||[]);for(const[o,s]of Object.entries(e.sources))pt(s)&&await Et(e,s,o,t,n)}else wt()}(e),await Ft(e)}(e,n),r=!0;break;case Ze.Session:r=!0;break;case Ze.Shutdown:e.hasShutdown||(e.hasShutdown=!0,await async function(e){const t=e.logger;await Wt(e.sources,"source",t),await async function(e,t){const n=Object.entries(e).flatMap(([e,n])=>{const o=n.batches;if(!o)return[];const s=t.scope(n.type||"destination");return Object.values(o).map(async t=>{let n;try{await Promise.race([t.flush(),new Promise((t,o)=>{n=setTimeout(()=>o(new Error(`destination '${e}' batch flush timed out`)),5e3)})])}catch(t){s.error(`destination '${e}' batch flush failed: ${t}`)}finally{n&&clearTimeout(n)}})});await Promise.allSettled(n)}(e.destinations,t),await Wt(e.destinations,"destination",t),await Wt(e.transformers,"transformer",t),await Wt(e.stores,"store",t)}(e));break;case Ze.User:_e(n)&&(Ee(e.user,n,{shallow:!1}),Vt(e,Ze.User),s=n,r=!0)}return r&&(await async function(e,t,n,o){if(!mt(e))return wt(),!0;e.seenEvents.add(String(t));let s=n||[];n||(s=e.on[t]||[]);const r=Tt(e,t,o);let i=!1;for(const[n,o]of Object.entries(e.sources)){if(o.config.require?.length){const e=o.config.require.indexOf(t);-1!==e&&o.config.require.splice(e,1)}o.on&&(pt(o)?await Et(e,o,n,t,r)&&(i=!0):(o.queueOn=o.queueOn||[],o.queueOn.push({type:t,data:r})))}Object.entries(e.destinations).forEach(([n,o])=>{if(o.on){if(!o.config.init)return o.queueOn=o.queueOn||[],void o.queueOn.push({type:t,data:r});At(e,o,n,t,r)}});for(const[t,n]of Object.entries(e.sources))pt(n)&&n.queueOn?.length&&await ft(e,n,t);const a=Object.values(e.sources).some(e=>!pt(e)&&e.config.require?.length);return(Object.keys(e.pending.destinations).length>0||a)&&await ht(e),Dt(e,t,s,o),!i}(e,t,void 0,s),o=await Ft(e)),o||Kt({ok:!0})}()}finally{i()}}function Xt(e,t){return{timing:Math.round((Date.now()-e.timing)/10)/100,source:{type:"collector",schema:"4",version:"4.2.1-next-1781538735002"},...t}}function Zt(e,t){if(!t.name)throw new Error("Event name is required");const[n,o]=t.name.split(" ");if(!n||!o)throw new Error("Event name is invalid");const{timestamp:s=Date.now(),name:r=`${n} ${o}`,data:i={},context:a={},globals:c=e.globals,custom:u={},user:l=e.user,nested:d=[],consent:f=e.consent,id:p=Me(),trigger:g="",entity:h=n,action:m=o,timing:y=0,source:w={type:"collector",schema:"4"}}=t;return{name:r,data:i,context:a,globals:c,custom:u,user:l,nested:d,consent:f,id:p,trigger:g,entity:h,action:m,timestamp:s,timing:y,source:w}}function en(e,t){const n=Fe(async(n,o={})=>await ze(async()=>{const s=Date.now(),{id:r,ingest:i,respond:a,mapping:c,preChain:u,include:l,exclude:d}=o;let f=a,p=n;const g=l||d?function(e,t,n){let o=e;return t&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>t.includes(e)))),n&&(o=Object.fromEntries(Object.entries(o).filter(([e])=>!n.includes(e)))),o}(e.destinations,l,d):void 0,h=i??Re(r||"unknown");if(c){const t=await Be(p,c,e);if(t.ignore)return Kt({ok:!0});if(c.consent&&!Ne(c.consent,e.consent,t.event.consent))return Kt({ok:!0});p=t.event}if(u?.length&&e.transformers&&Object.keys(e.transformers).length>0){const n=await ut(e,e.transformers,u,p,h,f,r?`source.${r}.next`:void 0);if(null===n.event)return Kt({ok:!0});if(n.stopped)return n.respond&&(f=n.respond),Kt({ok:!0});if(n.respond&&(f=n.respond),Array.isArray(n.event)){const o=await Promise.all(n.event.map(async n=>{const o=t(n),s=Zt(e,o);return Ft(e,s,{id:r,ingest:h,respond:f},g)}));if(r){e.status.sources[r]||(e.status.sources[r]={count:0,duration:0});const t=e.status.sources[r];t.count+=n.event.length,t.lastAt=Date.now(),t.duration+=Date.now()-s}return o[0]??Kt({ok:!0})}p=n.event}const m=function(e,t){return Zt(e,Xt(e,t))}(e,p),y=await Ft(e,m,{id:r,ingest:h,respond:f},g);if(r){e.status.sources[r]||(e.status.sources[r]={count:0,duration:0});const t=e.status.sources[r];t.count++,t.lastAt=Date.now(),t.duration+=Date.now()-s}return y},t=>{if(t instanceof Ge)throw t;return e.status.failed++,e.logger.error("push failed",{event:n,ingest:o.ingest,error:t}),Kt({ok:!1})})(),"Push",e.hooks,e.logger);return async(t,o)=>{const s="string"==typeof t.id?t.id:"",r=Date.now();He(e,et(e,{stepId:"collector.push",stepType:"collector",phase:"in",eventId:s,now:r}));try{const i=await n(t,o),a=Date.now(),c=et(e,{stepId:"collector.push",stepType:"collector",phase:"out",eventId:s,now:a});return c.durationMs=a-r,c.outEvent=i,He(e,c),i}catch(t){const n=Date.now(),o=et(e,{stepId:"collector.push",stepType:"collector",phase:"error",eventId:s,now:n});throw o.durationMs=n-r,o.error=t instanceof Error?{name:t.name,message:t.message}:{message:String(t)},He(e,o),t}}}function tn(e={}){const t=e.maxEntries??1e4,n=e.lowWaterMark??.8,o=e.sweepIntervalMs??6e4,s=Math.floor(t*n),r=new Map,i={hits:0,misses:0,populates:0,writes:0,deletes:0,evictions_entries:0,evictions_ttl:0};let a;return o>0&&(a=setInterval(function(){const e=Date.now();let t=0;for(const[n,o]of r)void 0!==o.expires&&o.expires<=e&&(r.delete(n),t++);i.evictions_ttl+=t},o),a&&"function"==typeof a.unref&&a.unref()),{type:"memory",config:{},get(e){const t=r.get(e);if(t)return void 0!==t.expires&&t.expires<=Date.now()?(r.delete(e),i.evictions_ttl++,void i.misses++):(r.delete(e),r.set(e,t),i.hits++,t.value);i.misses++},set(e,n,o){const a=!r.has(e);a||r.delete(e),r.set(e,{value:n,expires:void 0!==o?Date.now()+o:void 0}),i.writes++,a&&i.populates++,r.size>t&&function(){if(r.size<=t)return;const e=r.size-s;let n=0;for(const t of r.keys()){if(n>=e)break;r.delete(t),n++}i.evictions_entries+=n}()},delete(e){r.delete(e)&&i.deletes++},get counters(){return{...i}},destroy(){void 0!==a&&(clearInterval(a),a=void 0),r.clear()}}}function nn(e,t){const{cacheConfig:n,cacheStore:o,namespace:s,logger:r,storeId:i,collector:a}=t,c=(e,t)=>{if(!a)return;const n=et(a,{stepId:`store.${i}`,stepType:"store",phase:"in",eventId:"",now:Date.now()});n.meta={op:"cache",cached:"hit"===t,status:t,key:e},Ve(a,n)},u={hits:0,misses:0,populates:0,writes:0,deletes:0,inflight_dedups:0},l=n.rules.map(e=>({match:e.match?We(e.match):()=>!0,ttl:e.ttl})),d=e=>`${s}:${e}`;function f(e,t){const n=void 0===t?{key:e}:{key:e,value:t};return l.find(e=>e.match(n))}const p=new Map;return{type:e.type,config:e.config,setup:e.setup,get counters(){return{...u}},async get(t){const n=d(t),s=await o.get(n),r=Ye(s);if(void 0!==r){if(!("expired"in r))return u.hits++,c(t,"hit"),r.value;try{await o.delete(n)}catch(e){g("delete",t,e)}}const i=p.get(n);if(i)return u.inflight_dedups++,c(t,"hit"),i;u.misses++,c(t,"miss");const a=(async()=>{try{const s=await e.get(t);if(void 0===s)return;const r=f(t,s);if(r)try{const e=1e3*r.ttl;await o.set(n,Xe(s,e),e),u.populates++}catch(e){g("set",t,e)}return s}finally{p.delete(n)}})();return p.set(n,a),a},async set(t,n,s){u.writes++,await e.set(t,n,s);const r=f(t,n);if(r)try{const e=1e3*r.ttl;await o.set(d(t),Xe(n,e),e)}catch(e){g("set",t,e)}},async delete(t){u.deletes++,await e.delete(t);try{await o.delete(d(t))}catch(e){g("delete",t,e)}}};function g(e,t,n){const o=`store-cache(${i}): cache ${e} failed for "${t}"; backing succeeded, continuing`;r?r.warn(o,{error:n}):console.warn(o,n)}}function on(e,t,n){const o=`store.${n}`,s=Je(t.get,"StoreGet",e.hooks,e.logger),r=Je(t.set,"StoreSet",e.hooks,e.logger),i=Je(t.delete,"StoreDelete",e.hooks,e.logger);t.get=async t=>{const n=Date.now(),r=et(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});r.meta={op:"get",key:t},Qe(e,r);try{const r=await s(t),i=Date.now(),a=et(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:i});return a.durationMs=i-n,a.meta={op:"get",key:t},Qe(e,a),r}catch(s){const r=Date.now(),i=et(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw i.durationMs=r-n,i.meta={op:"get",key:t},i.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},Qe(e,i),s}},t.set=async(t,n,s)=>{const i=Date.now(),a=et(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:i});a.meta={op:"set",key:t},Qe(e,a);try{await r(t,n,s);const a=Date.now(),c=et(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:a});c.durationMs=a-i,c.meta={op:"set",key:t},Qe(e,c)}catch(n){const s=Date.now(),r=et(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:s});throw r.durationMs=s-i,r.meta={op:"set",key:t},r.error=n instanceof Error?{name:n.name,message:n.message}:{message:String(n)},Qe(e,r),n}},t.delete=async t=>{const n=Date.now(),s=et(e,{stepId:o,stepType:"store",phase:"in",eventId:"",now:n});s.meta={op:"delete",key:t},Qe(e,s);try{await i(t);const s=Date.now(),r=et(e,{stepId:o,stepType:"store",phase:"out",eventId:"",now:s});r.durationMs=s-n,r.meta={op:"delete",key:t},Qe(e,r)}catch(s){const r=Date.now(),i=et(e,{stepId:o,stepType:"store",phase:"error",eventId:"",now:r});throw i.durationMs=r-n,i.meta={op:"delete",key:t},i.error=s instanceof Error?{name:s.name,message:s.message}:{message:String(s)},Qe(e,i),s}}}async function sn(e){const t=D({globalsStatic:{},sessionStatic:{},run:!0,queueMax:1e3},e,{merge:!1,extend:!1}),n={level:e.logger?.level,handler:e.logger?.handler},o=T(n),s={...t.globalsStatic,...e.globals},r={allowed:!1,config:t,consent:e.consent||{},custom:e.custom||{},destinations:{},transformers:{},stores:{},globals:s,hooks:e.hooks||{},observers:new Set,logger:o,on:{},queue:[],round:0,stateVersion:0,cellVersion:{},delivery:new WeakMap,session:void 0,status:{startedAt:Date.now(),in:0,out:0,failed:0,sources:{},destinations:{},dropped:{}},timing:Date.now(),user:e.user||{},sources:{},pending:{destinations:{}},hasShutdown:!1,seenEvents:new Set,push:void 0,command:void 0};var i,a;r.push=en(r,e=>Xt(r,e)),r.command=(a=Yt,Ue(async(e,t,n)=>await Ke(async()=>await a(i,e,t,n),n=>{if(n instanceof Le)throw n;return i.status.failed++,i.logger.error("command failed",{command:e,data:t,error:n}),Kt({ok:!1})})(),"Command",(i=r).hooks,i.logger));const c=e.stores||{};return r.stores=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const{code:t,config:r={},env:i={}}=s,a=e.logger.scope("store").scope(o),c={collector:e,logger:a,id:o,config:r,env:i},u=await t(c);n[o]=u}const o=t,s=function(e){const t={};for(const n of Object.keys(e))t[n]="WHITE";const n=[],o=[];function s(r){const i=t[r];if("BLACK"===i)return;if("GRAY"===i){const e=o.indexOf(r),t=o.slice(-1===e?0:e).concat(r).join(" -> ");throw new Error(`Cycle in cache.store chain: ${t}`)}t[r]="GRAY",o.push(r);const a=e[r].cache?.store;if(void 0!==a){if(!(a in e))throw new Error(`Store "${r}" cache.store references "${a}", which is not declared in flow.stores`);s(a)}o.pop(),t[r]="BLACK",n.push(r)}for(const n of Object.keys(e))"WHITE"===t[n]&&s(n);return n}(o);for(const t of s){const s=o[t].cache;if(!s)continue;let r,i;void 0!==s.store?(r=n[s.store],i=s.store):(n.__cache||(n.__cache=tn()),r=n.__cache,i="__cache");const a=s.namespace??t;e.logger.scope("store-cache").scope(t).info(`store "${t}" caches with namespace "${a}:" via ${i}`),n[t]=nn(n[t],{storeId:t,cacheConfig:s,cacheStore:r,namespace:a,logger:e.logger.scope("store-cache").scope(t),collector:e})}for(const[t,o]of Object.entries(n))"__cache"!==t&&on(e,o,t);return n}(r,c),function(e,t,n){const o=new Map;for(const[n,s]of Object.entries(e))t[n]&&o.set(s,t[n]);if(0!==o.size)for(const e of[n.transformers,n.destinations,n.sources])if(e)for(const t of Object.values(e))s(t.env);function s(e){if(e)for(const[t,n]of Object.entries(e))if("object"==typeof n&&null!==n){const s=o.get(n);s&&(e[t]=s)}}}(c,r.stores,e),r.stores.__cache||(r.stores.__cache=tn()),r.destinations=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t))s.config?.require?.length?e.pending.destinations[o]=s:n[o]=Qt(s);return n}(r,e.destinations||{}),r.transformers=await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const{code:t,env:r={}}=s,i=je(s,"Transformer");if(!i.ok){e.logger.warn(`Transformer ${o} invalid (${i.code}): ${i.reason}. Skipping.`);continue}const{config:a}=st(s,"before"),{config:c}=st({...s,config:a},"next"),u=Object.keys(r).length>0?{...c,env:r}:c,{cache:l}=s,d=l?{...u,cache:l}:u,f=s.config?.state??s.state,p=void 0!==f&&void 0===d.state?{...d,state:f}:d,g=e.logger.scope("transformer").scope(o),h={collector:e,logger:g,id:o,ingest:me(o),config:p,env:r},m=t??(e=>{const t=s.mapping;if(t){const n=[];if(void 0!==t.data&&n.push("data"),t.mapping)for(const[e,o]of Object.entries(t.mapping))if("object"==typeof o&&null!==o)for(const[t,s]of Object.entries(o)){if("object"!=typeof s||null===s)continue;const o=s;void 0!==o.data&&n.push(`mapping[${e}][${t}].data`),void 0!==o.silent&&n.push(`mapping[${e}][${t}].silent`)}return n.length>0&&e.collector.logger.warn(`Transformer ${o}: \`${n.join(", ")}\` ignored at transformer position (only event-mutating fields apply).`),{type:"pass",config:e.config,push:async n=>{const o=await Ae(n,t,e.collector);return!o.ignore&&{event:o.event}}}}return{type:"pass",config:e.config,push:e=>({event:e})}}),y=await m(h);void 0!==s.before&&void 0===y.config?.before&&(y.config={...y.config??{},before:s.before}),void 0!==s.next&&void 0===y.config?.next&&(y.config={...y.config??{},next:s.next}),void 0!==f&&void 0===y.config?.state&&(y.config={...y.config??{},state:f}),n[o]=y}return n}(r,e.transformers||{}),r}async function rn(e){e=e||{};const t=await sn(e),n=(o=t,{type:"elb",config:{},push:async(e,t,n,s,r)=>{if("string"==typeof e&&e.startsWith("walker ")){const n=e.replace("walker ","");return o.command(n,t)}let i;if("string"==typeof e)i={name:e},t&&"object"==typeof t&&!Array.isArray(t)&&(i.data=t);else{if(!e||"object"!=typeof e)return Kt({ok:!1});i=e,t&&"object"==typeof t&&!Array.isArray(t)&&(i.data={...i.data||{},...t})}return n&&"object"==typeof n&&(i.context=n),s&&Array.isArray(s)&&(i.nested=s),r&&"object"==typeof r&&(i.custom=r),o.push(i)}});var o;t.sources.elb=n,await async function(e,t={}){const n={};for(const[o,s]of Object.entries(t)){const t=await gt(e,o,s);if(!t)continue;const r=s.config?.require;t.config={...t.config,init:!1,...r?{require:[...r]}:{}},n[o]=t}Object.assign(e.sources,n);for(const t of Object.keys(n)){const n=e.sources[t];let o=!1;n.init&&await ae(n.init.bind(n),n=>{if(n instanceof re)throw n;o=!0,e.status.failed++,e.logger.scope("source").error("source init failed",{sourceId:t,error:n})})(),o||(n.config.init=!0,pt(n)&&await ft(e,n,t))}return await ht(e),n}(t,e.sources||{});const{consent:s,user:r,globals:i,custom:a}=e;s&&await t.command("consent",s),r&&await t.command("user",r),i&&await t.command("globals",i),a&&await t.command("custom",a),t.config.run&&await t.command("run");let c=n.push;const u=Object.values(t.sources).filter(e=>"elb"!==e.type),l=u.find(e=>e.config.primary);return l?c=l.push:u.length>0&&(c=u[0].push),{collector:t,elb:c}}var an=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await rn(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources||{}))if("lambda"===t.type)return t}(t.collector);if(!o)throw new Error("Lambda source not found in collector");const s={awsRequestId:`test-${Date.now()}`},r=o.push,i=await r(n,s);let a;try{a=JSON.parse(i.body||"{}")}catch{a=i.body}const c={};if(i.headers)for(const[e,t]of Object.entries(i.headers))void 0!==t&&(c[e]=String(t));return{statusCode:i.statusCode,body:a,headers:c}}}};function cn(e){return async t=>{const n={...t};if(n.body&&"string"==typeof n.body){const e=JSON.parse(n.body);e.name&&!e.event&&(n.body=JSON.stringify({...e,event:e.name,name:void 0}))}return e.push(n,{awsRequestId:"test-req"})}}var un={};t(un,{createTrigger:()=>Sn,env:()=>ln,step:()=>mn});var ln={};t(ln,{push:()=>gn,simulation:()=>hn});var dn=()=>{},fn={error:dn,warn:dn,info:dn,debug:dn,throw:e=>{throw"string"==typeof e?new Error(e):e},json:dn,scope:()=>fn},pn=()=>()=>Promise.resolve({ok:!0}),gn={get push(){return pn()},get command(){return pn()},get elb(){return pn()},logger:fn},hn=["AWS.SQSClient"],mn={};t(mn,{decoderText:()=>vn,malformedJson:()=>bn,orderComplete:()=>wn,pageView:()=>yn});var yn={title:"Page view from SQS",description:"A standard SQS message body containing a walker elb event payload as JSON.",in:{MessageId:"m-1",Body:JSON.stringify({event:"page view",data:{title:"Documentation",url:"https://example.com/docs"}})},out:[["message.ack","m-1"]]},wn={title:"Order complete from SQS",description:"Order complete event flowing through the long-poll loop.",in:{MessageId:"m-2",Body:JSON.stringify({event:"order complete",data:{id:"ORD-500",total:199.99,currency:"EUR"}})},out:[["message.ack","m-2"]]},vn={title:"Text decoder",description:'When decoder is "text", the body string flows under data.payload.',in:{MessageId:"m-3",Body:"raw text payload"},out:[["message.ack","m-3"]]},bn={title:"Malformed JSON nacks",description:"Default decoder is JSON. A malformed body throws DecoderError; the source nacks (skips DeleteMessage) so the message redelivers.",in:{MessageId:"m-4",Body:"{not json"},out:[["message.nack","m-4"]]};function kn(e){if("object"!=typeof e||null===e)return!1;const t=e;return"sqs"===t.type&&"function"==typeof t.push}var Sn=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{if(!t){const n=await rn(e);t={collector:n.collector,elb:n.elb}}const o=function(e){for(const t of Object.values(e.sources??{}))if(kn(t))return t}(t.collector);if(!o)throw new Error("sqs source not registered in collector, ensure it is configured in sources");const s={MessageId:n.MessageId,Body:n.Body,ReceiptHandle:n.ReceiptHandle,Attributes:n.Attributes,MessageAttributes:n.MessageAttributes},r=await o.push(s),i=[];return r&&"object"==typeof r&&(r.acked&&i.push(["message.ack",n.MessageId]),r.nacked&&i.push(["message.nack",n.MessageId])),i}}};export{v as examples,n as schemas,un as sqsExamples};//# sourceMappingURL=dev.mjs.map
package/dist/dev.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schemas.ts","../src/lambda/schemas/index.ts","../src/lambda/schemas/settings.ts","../src/lambda/schemas/primitives.ts","../src/sqs/schemas/index.ts","../src/sqs/schemas/settings.ts","../src/sqs/schemas/setup.ts","../src/lambda/examples/index.ts","../src/lambda/examples/env.ts","../src/lambda/examples/step.ts","../src/lambda/examples/trigger.ts","../src/sqs/examples/index.ts","../src/sqs/examples/env.ts","../src/sqs/examples/step.ts","../src/sqs/examples/trigger.ts"],"sourcesContent":["// Lambda (default sub-source).\nexport { settings, SettingsSchema, type Settings } from './lambda/schemas';\nexport * from './lambda/schemas/primitives';\n\n// SQS sub-source. Prefixed so the website's <Configuration> snippet can\n// remap data.schemas.sqsSettings / sqsSetup onto data.schemas.settings.\nexport { settings as sqsSettings } from './sqs/schemas';\nexport { setup as sqsSetup } from './sqs/schemas';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export primitives\nexport * from './primitives';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema } from './primitives';\n\n/**\n * AWS Lambda source settings schema\n */\nexport const SettingsSchema = z.object({\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins, object = custom configuration',\n )\n .default(true),\n\n timeout: z\n .number()\n .int()\n .positive()\n .max(900000) // AWS Lambda max timeout: 15 minutes\n .describe('Request timeout in milliseconds (max: 900000 for Lambda)')\n .default(30000),\n\n enablePixelTracking: z\n .boolean()\n .describe(\n 'Enable GET requests with 1x1 transparent GIF response for pixel tracking',\n )\n .default(true),\n\n healthPath: z\n .string()\n .describe('Health check endpoint path (e.g., /health)')\n .default('/health'),\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 * 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","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { SetupSchema } from './setup';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { SetupSchema, type Setup } from './setup';\n\n// JSON Schema exports (for website PropertyTable + MCP package_get).\nexport const settings = zodToSchema(SettingsSchema);\nexport const setup = zodToSchema(SetupSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * AWS SQS source settings schema.\n *\n * Required: queueName. All other fields optional with sensible defaults\n * applied at runtime by `getConfig`.\n */\nexport const SettingsSchema = z.object({\n queueName: z\n .string()\n .min(1)\n .describe(\n 'SQS queue short name (like walkeros-events). Required for both setup and runtime poll.',\n ),\n region: z\n .string()\n .describe('AWS region (like eu-central-1). Default: eu-central-1.')\n .optional(),\n queueUrl: z\n .string()\n .url()\n .describe(\n 'Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.',\n )\n .optional(),\n client: z\n .any()\n .describe(\n 'Pre-configured AWS SQSClient instance. Bypasses construction when supplied.',\n )\n .optional(),\n config: z\n .any()\n .describe(\n 'AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).',\n )\n .optional(),\n decoder: z\n .enum(['json', 'text', 'raw'])\n .describe(\n 'Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.',\n )\n .optional(),\n maxMessages: z\n .number()\n .int()\n .min(1)\n .max(10)\n .describe('SQS receive batch size. Cap 10. Default: 10.')\n .optional(),\n waitTimeSeconds: z\n .number()\n .int()\n .min(0)\n .max(20)\n .describe('Long-poll duration in seconds. Cap 20. Default: 20.')\n .optional(),\n visibilityTimeout: z\n .number()\n .int()\n .nonnegative()\n .describe(\n 'Per-receive visibility timeout override. Default: queue-configured value.',\n )\n .optional(),\n shutdownTimeoutMs: z\n .number()\n .int()\n .positive()\n .describe(\n 'Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.',\n )\n .optional(),\n onPushError: z\n .enum(['nack', 'ack'])\n .describe(\n 'Behavior when forwarding to the collector throws. nack (default) skips DeleteMessage so the message redelivers; ack drops it.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * AWS SQS source setup schema.\n *\n * Provisioning options for `walkeros setup source.<id>`. Authoritative-apply:\n * declared state is written via a single CreateQueueCommand; non-declared\n * tags or attributes are left untouched.\n */\nconst TagsSchema = z.record(z.string(), z.string());\n\nexport const SetupSchema = z.object({\n region: z.string().min(1).describe('AWS region.').optional(),\n fifoQueue: z\n .boolean()\n .describe(\n 'FIFO queue with content-based deduplication. Auto-appends .fifo suffix to the queue name.',\n )\n .optional(),\n visibilityTimeoutSeconds: z\n .number()\n .int()\n .nonnegative()\n .describe('Visibility timeout in seconds. Default: 30.')\n .optional(),\n messageRetentionSeconds: z\n .number()\n .int()\n .positive()\n .describe('Message retention period in seconds. Default: 345600 (4 days).')\n .optional(),\n maximumMessageSize: z\n .number()\n .int()\n .min(1024)\n .max(262144)\n .describe('Max message size in bytes. Default: 262144 (256 KB).')\n .optional(),\n kmsMasterKeyId: z\n .string()\n .describe('KMS key alias or ID for at-rest encryption.')\n .optional(),\n deadLetterQueue: z\n .object({\n arn: z\n .string()\n .describe(\n 'ARN of an existing DLQ. Mutually exclusive with create: true.',\n )\n .optional(),\n create: z\n .boolean()\n .describe('Create a sibling DLQ named <queueName>-dlq. Default: false.')\n .optional(),\n maxReceiveCount: z\n .number()\n .int()\n .min(1)\n .max(1000)\n .describe('Max receive count before message goes to DLQ. Default: 5.')\n .optional(),\n })\n .describe('Optional dead-letter queue.')\n .optional(),\n tags: TagsSchema.describe(\n 'Tags applied to the queue (and inherited by an auto-created DLQ).',\n ).optional(),\n subscribeToSnsTopic: z\n .object({\n topicArn: z.string().min(1).describe('Topic ARN to subscribe to.'),\n rawMessageDelivery: z\n .boolean()\n .describe('Deliver SNS messages without the SNS envelope.')\n .optional(),\n filterPolicy: z\n .record(z.string(), z.unknown())\n .describe('SNS filter policy applied at subscription level.')\n .optional(),\n })\n .describe(\n 'Optional SNS topic subscription. Creates the subscription and the matching queue policy.',\n )\n .optional(),\n});\n\nexport type Setup = z.infer<typeof SetupSchema>;\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for AWS Lambda source\n *\n * These environments provide standardized mock structures for testing\n * Lambda event handling without requiring actual Lambda deployment.\n */\n\n// Create a properly typed elb/push/command function that returns a promise with PushResult\nconst createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n// Simple no-op logger for demo purposes\nconst noopFn = () => {};\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n warn: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noopFn,\n scope: () => noopLogger,\n};\n\n/**\n * Standard mock environment for testing Lambda source\n *\n * Use this for testing Lambda event ingestion and request/response handling\n * without requiring a real AWS Lambda environment.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const lambdaPost: Flow.StepExample = {\n title: 'Lambda POST',\n description:\n 'An API Gateway v2 HTTP POST with a JSON body is converted into a walker elb event.',\n trigger: { type: 'POST' },\n in: {\n version: '2.0',\n requestContext: {\n http: { method: 'POST', path: '/collect' },\n requestId: 'req-123',\n },\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home' },\n }),\n isBase64Encoded: false,\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n\nexport const apiGatewayV1Post: Flow.StepExample = {\n title: 'API Gateway v1 POST',\n description:\n 'A REST API Gateway v1 POST request with a JSON body is converted into a walker elb event.',\n trigger: { type: 'POST' },\n in: {\n httpMethod: 'POST',\n path: '/collect',\n requestContext: {\n requestId: 'req-789',\n identity: { sourceIp: '203.0.113.42' },\n },\n queryStringParameters: null,\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home' },\n }),\n isBase64Encoded: false,\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n\nexport const lambdaGet: Flow.StepExample = {\n title: 'Lambda GET',\n description:\n 'An API Gateway v2 HTTP GET with query parameters is parsed into an elb event payload.',\n trigger: { type: 'GET' },\n in: {\n version: '2.0',\n requestContext: {\n http: { method: 'GET', path: '/collect' },\n requestId: 'req-456',\n },\n rawQueryString: 'e=page+view&d=%7B%22title%22%3A%22Home%22%7D',\n isBase64Encoded: false,\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 type { LambdaEvent, LambdaContext, LambdaResult } from '../types';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n [key: string]: unknown;\n}\n\nexport interface Result {\n statusCode: number;\n body: unknown;\n headers: Record<string, string>;\n}\n\n/**\n * Find the lambda source instance from the collector's registered sources.\n */\nfunction findLambdaSource(collector: Collector.Instance) {\n for (const source of Object.values(collector.sources || {})) {\n if ((source as { type?: string }).type === 'lambda') return source;\n }\n}\n\n/**\n * Lambda source createTrigger.\n *\n * Boots the collector via startFlow, then invokes the Lambda source's push()\n * with a real API Gateway event and a minimal Lambda context.\n *\n * Content is the raw Lambda event object (API Gateway v1 or v2 format).\n * Result contains statusCode, parsed body, and headers.\n *\n * @example\n * const { trigger, flow } = await createTrigger(config);\n * const result = await trigger('POST')({ version: '2.0', ... });\n * console.log(result.statusCode, result.body);\n */\nconst createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n // Lazy startFlow\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n }\n\n const source = findLambdaSource(flow.collector);\n if (!source) throw new Error('Lambda source not found in collector');\n\n // Create minimal Lambda context\n const lambdaContext = {\n awsRequestId: `test-${Date.now()}`,\n } as unknown as LambdaContext;\n\n // Call source.push with the raw Lambda event + context\n const pushFn = (\n source as unknown as {\n push: (...args: unknown[]) => Promise<LambdaResult>;\n }\n ).push;\n const lambdaResult = await pushFn(\n content as unknown as LambdaEvent,\n lambdaContext,\n );\n\n // Parse response\n let body: unknown;\n try {\n body = JSON.parse(lambdaResult.body || '{}');\n } catch {\n body = lambdaResult.body;\n }\n\n const headers: Record<string, string> = {};\n if (lambdaResult.headers) {\n for (const [k, v] of Object.entries(lambdaResult.headers)) {\n if (v !== undefined) headers[k] = String(v);\n }\n }\n\n return {\n statusCode: lambdaResult.statusCode,\n body,\n headers,\n };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/**\n * Legacy trigger — takes a source instance directly.\n * Preserved for CLI simulate path.\n */\nfunction trigger(source: {\n push: (event: LambdaEvent, context: LambdaContext) => Promise<LambdaResult>;\n}): (content: Content) => Promise<LambdaResult> {\n return async (content: Content) => {\n const lambdaEvent = { ...(content as Record<string, unknown>) };\n\n // Adapt body format: step examples may use `name`, source expects `event`\n if (lambdaEvent.body && typeof lambdaEvent.body === 'string') {\n const body = JSON.parse(lambdaEvent.body);\n if (body.name && !body.event) {\n lambdaEvent.body = JSON.stringify({\n ...body,\n event: body.name,\n name: undefined,\n });\n }\n }\n\n const context: LambdaContext = {\n awsRequestId: 'test-req',\n } as unknown as LambdaContext;\n\n return source.push(lambdaEvent as unknown as LambdaEvent, context);\n };\n}\n\nexport { createTrigger, trigger };\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger } from './trigger';\nexport type { Content, Result } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment for the AWS SQS source.\n *\n * Tests substitute the real SDK via `jest.mock('@aws-sdk/client-sqs')` and\n * `jest.mock('@aws-sdk/client-sns')`, which is the canonical pattern: imports\n * of those modules get replaced module-wide, no env-injection plumbing\n * required at the call site.\n *\n * The `simulation` list documents which SDK identifiers the source touches\n * during a simulated run, used by the simulator to know what to stub.\n */\n\nconst noopFn = (): void => undefined;\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n warn: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noopFn,\n scope: () => noopLogger,\n};\n\nconst createMockElbFn = (): Elb.Fn => {\n const fn: Elb.Fn = () => Promise.resolve({ ok: true });\n return fn;\n};\n\n/**\n * Standard mock environment for the SQS source.\n *\n * AWS SDK constructors are intentionally absent: the canonical pattern is\n * module-level `jest.mock('@aws-sdk/client-sqs')` and -sns, not env-injection.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n\nexport const simulation = ['AWS.SQSClient'];\n","import type { Flow } from '@walkeros/core';\n\n/**\n * SQS source step examples.\n *\n * Each `in` is a partial SQS Message-like (MessageId, Body, optional\n * ReceiptHandle). The trigger synthesizes the missing fields and dispatches\n * through the source's `push()` (the same pipeline the long-poll loop uses).\n * `out` records the terminal state recorded by the trigger as\n * `[method, ...args]` entries.\n */\n\nconst eventPayload = {\n event: 'page view',\n data: { title: 'Documentation', url: 'https://example.com/docs' },\n};\n\nconst orderPayload = {\n event: 'order complete',\n data: { id: 'ORD-500', total: 199.99, currency: 'EUR' },\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view from SQS',\n description:\n 'A standard SQS message body containing a walker elb event payload as JSON.',\n in: {\n MessageId: 'm-1',\n Body: JSON.stringify(eventPayload),\n },\n out: [['message.ack', 'm-1']],\n};\n\nexport const orderComplete: Flow.StepExample = {\n title: 'Order complete from SQS',\n description: 'Order complete event flowing through the long-poll loop.',\n in: {\n MessageId: 'm-2',\n Body: JSON.stringify(orderPayload),\n },\n out: [['message.ack', 'm-2']],\n};\n\nexport const decoderText: Flow.StepExample = {\n title: 'Text decoder',\n description:\n 'When decoder is \"text\", the body string flows under data.payload.',\n in: { MessageId: 'm-3', Body: 'raw text payload' },\n out: [['message.ack', 'm-3']],\n};\n\nexport const malformedJson: Flow.StepExample = {\n title: 'Malformed JSON nacks',\n description:\n 'Default decoder is JSON. A malformed body throws DecoderError; the source nacks (skips DeleteMessage) so the message redelivers.',\n in: { MessageId: 'm-4', Body: '{not json' },\n out: [['message.nack', 'm-4']],\n};\n","import type { Collector, Trigger } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport type { SyntheticMessage, SyntheticPushResult } from '../types';\n\n/**\n * Content shape for the SQS source trigger.\n *\n * The trigger synthesizes a SyntheticMessage from this partial input and\n * dispatches it through the source's `push()` (the same pipeline the\n * long-poll loop uses).\n */\nexport interface Content {\n MessageId: string;\n Body: string;\n ReceiptHandle?: string;\n Attributes?: Record<string, string>;\n MessageAttributes?: Record<\n string,\n { DataType: string; StringValue?: string }\n >;\n}\n\n/**\n * Trigger result: the recorded ack/nack as `[method, MessageId]` entries.\n * Mirrors the destination's `[method, ...args]` recording shape.\n */\nexport type Result = Array<[string, ...unknown[]]>;\n\ninterface SqsSourceLike {\n type: string;\n push: (content?: SyntheticMessage) => Promise<SyntheticPushResult | void>;\n}\n\nfunction isSqsSource(value: unknown): value is SqsSourceLike {\n if (typeof value !== 'object' || value === null) return false;\n const candidate: { type?: unknown; push?: unknown } = value;\n return candidate.type === 'sqs' && typeof candidate.push === 'function';\n}\n\nfunction findSource(collector: Collector.Instance): SqsSourceLike | undefined {\n for (const source of Object.values(collector.sources ?? {})) {\n if (isSqsSource(source)) return source;\n }\n return undefined;\n}\n\n/**\n * SQS source createTrigger.\n *\n * Boots the collector via startFlow, finds the registered SQS source, and\n * invokes its `push()` with a synthesized message. The source dispatches the\n * synthetic message through the same handler the long-poll loop uses,\n * exercising the full decode / forward / ack-nack pipeline without touching\n * real SQS infrastructure.\n */\nexport const createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n }\n\n const source = findSource(flow.collector);\n if (!source) {\n throw new Error(\n 'sqs source not registered in collector, ensure it is configured in sources',\n );\n }\n\n const synthetic: SyntheticMessage = {\n MessageId: content.MessageId,\n Body: content.Body,\n ReceiptHandle: content.ReceiptHandle,\n Attributes: content.Attributes,\n MessageAttributes: content.MessageAttributes,\n };\n\n const result = await source.push(synthetic);\n const recorded: Result = [];\n if (result && typeof result === 'object') {\n if (result.acked) recorded.push(['message.ack', content.MessageId]);\n if (result.nacked) recorded.push(['message.nack', content.MessageId]);\n }\n return recorded;\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAAA;AAAA,EAAA;AAAA;;;ACAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAC,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;AASM,IAAM,aAAa,EAAE,MAAM;AAAA,EAChC,EAAE,OAAO;AAAA,EACT,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAClB,EAAE,QAAQ,GAAG;AACf,CAAC;AAMM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,QAAQ,WAAW;AAAA,IACjB;AAAA,EACF,EAAE,SAAS;AAAA,EAEX,SAAS,EAAE,MAAM,UAAU,EA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AAS,CAAC;AAAA,IACtE;AACA,WAAO;AAAA,EACT;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA,SAAAD;AAAA,EACF;AACF;","names":["settings","z","z","zodToSchema","z","SettingsSchema","z","settings","zodToSchema","SettingsSchema","trigger","k","v","examples_exports","createTrigger","env_exports","step_exports","env_exports","push","noopFn","noopLogger","createMockElbFn","step_exports","createTrigger","trigger","result"]}
1
+ {"version":3,"sources":["../src/schemas.ts","../src/lambda/schemas/index.ts","../src/lambda/schemas/settings.ts","../src/lambda/schemas/primitives.ts","../src/sqs/schemas/index.ts","../src/sqs/schemas/settings.ts","../src/sqs/schemas/setup.ts","../src/lambda/examples/index.ts","../src/lambda/examples/env.ts","../src/lambda/examples/step.ts","../src/lambda/examples/trigger.ts","../src/sqs/examples/index.ts","../src/sqs/examples/env.ts","../src/sqs/examples/step.ts","../src/sqs/examples/trigger.ts"],"sourcesContent":["// Lambda (default sub-source).\nexport { settings, SettingsSchema, type Settings } from './lambda/schemas';\nexport * from './lambda/schemas/primitives';\n\n// SQS sub-source. Prefixed so the website's <Configuration> snippet can\n// remap data.schemas.sqsSettings / sqsSetup onto data.schemas.settings.\nexport { settings as sqsSettings } from './sqs/schemas';\nexport { setup as sqsSetup } from './sqs/schemas';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export primitives\nexport * from './primitives';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema } from './primitives';\n\n/**\n * AWS Lambda source settings schema\n */\nexport const SettingsSchema = z.object({\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins, object = custom configuration',\n )\n .default(true),\n\n timeout: z\n .number()\n .int()\n .positive()\n .max(900000) // AWS Lambda max timeout: 15 minutes\n .describe('Request timeout in milliseconds (max: 900000 for Lambda)')\n .default(30000),\n\n enablePixelTracking: z\n .boolean()\n .describe(\n 'Enable GET requests with 1x1 transparent GIF response for pixel tracking',\n )\n .default(true),\n\n healthPath: z\n .string()\n .describe('Health check endpoint path (e.g., /health)')\n .default('/health'),\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 * 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","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { SetupSchema } from './setup';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { SetupSchema, type Setup } from './setup';\n\n// JSON Schema exports (for website PropertyTable + MCP package_get).\nexport const settings = zodToSchema(SettingsSchema);\nexport const setup = zodToSchema(SetupSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * AWS SQS source settings schema.\n *\n * Required: queueName. All other fields optional with sensible defaults\n * applied at runtime by `getConfig`.\n */\nexport const SettingsSchema = z.object({\n queueName: z\n .string()\n .min(1)\n .describe(\n 'SQS queue short name (like walkeros-events). Required for both setup and runtime poll.',\n ),\n region: z\n .string()\n .describe('AWS region (like eu-central-1). Default: eu-central-1.')\n .optional(),\n queueUrl: z\n .string()\n .url()\n .describe(\n 'Optional pre-resolved queue URL. When set, init skips the GetQueueUrl lookup.',\n )\n .optional(),\n client: z\n .any()\n .describe(\n 'Pre-configured AWS SQSClient instance. Bypasses construction when supplied.',\n )\n .optional(),\n config: z\n .any()\n .describe(\n 'AWS SDK SQSClientConfig (credentials, endpoint overrides, retries).',\n )\n .optional(),\n decoder: z\n .enum(['json', 'text', 'raw'])\n .describe(\n 'Decoder for the message body. json (default) parses JSON, text forwards UTF-8, raw forwards a Buffer.',\n )\n .optional(),\n maxMessages: z\n .number()\n .int()\n .min(1)\n .max(10)\n .describe('SQS receive batch size. Cap 10. Default: 10.')\n .optional(),\n waitTimeSeconds: z\n .number()\n .int()\n .min(0)\n .max(20)\n .describe('Long-poll duration in seconds. Cap 20. Default: 20.')\n .optional(),\n visibilityTimeout: z\n .number()\n .int()\n .nonnegative()\n .describe(\n 'Per-receive visibility timeout override. Default: queue-configured value.',\n )\n .optional(),\n shutdownTimeoutMs: z\n .number()\n .int()\n .positive()\n .describe(\n 'Graceful shutdown timeout in milliseconds. Default: 30000. After this window, destroy() force-closes.',\n )\n .optional(),\n onPushError: z\n .enum(['nack', 'ack'])\n .describe(\n 'Behavior when forwarding to the collector throws. nack (default) skips DeleteMessage so the message redelivers; ack drops it.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * AWS SQS source setup schema.\n *\n * Provisioning options for `walkeros setup source.<id>`. Authoritative-apply:\n * declared state is written via a single CreateQueueCommand; non-declared\n * tags or attributes are left untouched.\n */\nconst TagsSchema = z.record(z.string(), z.string());\n\nexport const SetupSchema = z.object({\n region: z.string().min(1).describe('AWS region.').optional(),\n fifoQueue: z\n .boolean()\n .describe(\n 'FIFO queue with content-based deduplication. Auto-appends .fifo suffix to the queue name.',\n )\n .optional(),\n visibilityTimeoutSeconds: z\n .number()\n .int()\n .nonnegative()\n .describe('Visibility timeout in seconds. Default: 30.')\n .optional(),\n messageRetentionSeconds: z\n .number()\n .int()\n .positive()\n .describe('Message retention period in seconds. Default: 345600 (4 days).')\n .optional(),\n maximumMessageSize: z\n .number()\n .int()\n .min(1024)\n .max(262144)\n .describe('Max message size in bytes. Default: 262144 (256 KB).')\n .optional(),\n kmsMasterKeyId: z\n .string()\n .describe('KMS key alias or ID for at-rest encryption.')\n .optional(),\n deadLetterQueue: z\n .object({\n arn: z\n .string()\n .describe(\n 'ARN of an existing DLQ. Mutually exclusive with create: true.',\n )\n .optional(),\n create: z\n .boolean()\n .describe('Create a sibling DLQ named <queueName>-dlq. Default: false.')\n .optional(),\n maxReceiveCount: z\n .number()\n .int()\n .min(1)\n .max(1000)\n .describe('Max receive count before message goes to DLQ. Default: 5.')\n .optional(),\n })\n .describe('Optional dead-letter queue.')\n .optional(),\n tags: TagsSchema.describe(\n 'Tags applied to the queue (and inherited by an auto-created DLQ).',\n ).optional(),\n subscribeToSnsTopic: z\n .object({\n topicArn: z.string().min(1).describe('Topic ARN to subscribe to.'),\n rawMessageDelivery: z\n .boolean()\n .describe('Deliver SNS messages without the SNS envelope.')\n .optional(),\n filterPolicy: z\n .record(z.string(), z.unknown())\n .describe('SNS filter policy applied at subscription level.')\n .optional(),\n })\n .describe(\n 'Optional SNS topic subscription. Creates the subscription and the matching queue policy.',\n )\n .optional(),\n});\n\nexport type Setup = z.infer<typeof SetupSchema>;\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for AWS Lambda source\n *\n * These environments provide standardized mock structures for testing\n * Lambda event handling without requiring actual Lambda deployment.\n */\n\n// Create a properly typed elb/push/command function that returns a promise with PushResult\nconst createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n// Simple no-op logger for demo purposes\nconst noopFn = () => {};\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n warn: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noopFn,\n scope: () => noopLogger,\n};\n\n/**\n * Standard mock environment for testing Lambda source\n *\n * Use this for testing Lambda event ingestion and request/response handling\n * without requiring a real AWS Lambda environment.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const lambdaPost: Flow.StepExample = {\n title: 'Lambda POST',\n description:\n 'An API Gateway v2 HTTP POST with a JSON body is converted into a walker elb event.',\n trigger: { type: 'POST' },\n in: {\n version: '2.0',\n requestContext: {\n http: { method: 'POST', path: '/collect' },\n requestId: 'req-123',\n },\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home' },\n }),\n isBase64Encoded: false,\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n\nexport const apiGatewayV1Post: Flow.StepExample = {\n title: 'API Gateway v1 POST',\n description:\n 'A REST API Gateway v1 POST request with a JSON body is converted into a walker elb event.',\n trigger: { type: 'POST' },\n in: {\n httpMethod: 'POST',\n path: '/collect',\n requestContext: {\n requestId: 'req-789',\n identity: { sourceIp: '203.0.113.42' },\n },\n queryStringParameters: null,\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home' },\n }),\n isBase64Encoded: false,\n },\n out: [\n [\n 'elb',\n {\n name: 'page view',\n data: { title: 'Home' },\n },\n ],\n ],\n};\n\nexport const lambdaGet: Flow.StepExample = {\n title: 'Lambda GET',\n description:\n 'An API Gateway v2 HTTP GET with query parameters is parsed into an elb event payload.',\n trigger: { type: 'GET' },\n in: {\n version: '2.0',\n requestContext: {\n http: { method: 'GET', path: '/collect' },\n requestId: 'req-456',\n },\n rawQueryString: 'e=page+view&d=%7B%22title%22%3A%22Home%22%7D',\n isBase64Encoded: false,\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 type { LambdaEvent, LambdaContext, LambdaResult } from '../types';\nimport { startFlow } from '@walkeros/collector';\n\nexport interface Content {\n [key: string]: unknown;\n}\n\nexport interface Result {\n statusCode: number;\n body: unknown;\n headers: Record<string, string>;\n}\n\n/**\n * Find the lambda source instance from the collector's registered sources.\n */\nfunction findLambdaSource(collector: Collector.Instance) {\n for (const source of Object.values(collector.sources || {})) {\n if ((source as { type?: string }).type === 'lambda') return source;\n }\n}\n\n/**\n * Lambda source createTrigger.\n *\n * Boots the collector via startFlow, then invokes the Lambda source's push()\n * with a real API Gateway event and a minimal Lambda context.\n *\n * Content is the raw Lambda event object (API Gateway v1 or v2 format).\n * Result contains statusCode, parsed body, and headers.\n *\n * @example\n * const { trigger, flow } = await createTrigger(config);\n * const result = await trigger('POST')({ version: '2.0', ... });\n * console.log(result.statusCode, result.body);\n */\nconst createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n // Lazy startFlow\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n }\n\n const source = findLambdaSource(flow.collector);\n if (!source) throw new Error('Lambda source not found in collector');\n\n // Create minimal Lambda context\n const lambdaContext = {\n awsRequestId: `test-${Date.now()}`,\n } as unknown as LambdaContext;\n\n // Call source.push with the raw Lambda event + context\n const pushFn = (\n source as unknown as {\n push: (...args: unknown[]) => Promise<LambdaResult>;\n }\n ).push;\n const lambdaResult = await pushFn(\n content as unknown as LambdaEvent,\n lambdaContext,\n );\n\n // Parse response\n let body: unknown;\n try {\n body = JSON.parse(lambdaResult.body || '{}');\n } catch {\n body = lambdaResult.body;\n }\n\n const headers: Record<string, string> = {};\n if (lambdaResult.headers) {\n for (const [k, v] of Object.entries(lambdaResult.headers)) {\n if (v !== undefined) headers[k] = String(v);\n }\n }\n\n return {\n statusCode: lambdaResult.statusCode,\n body,\n headers,\n };\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/**\n * Legacy trigger — takes a source instance directly.\n * Preserved for CLI simulate path.\n */\nfunction trigger(source: {\n push: (event: LambdaEvent, context: LambdaContext) => Promise<LambdaResult>;\n}): (content: Content) => Promise<LambdaResult> {\n return async (content: Content) => {\n const lambdaEvent = { ...(content as Record<string, unknown>) };\n\n // Adapt body format: step examples may use `name`, source expects `event`\n if (lambdaEvent.body && typeof lambdaEvent.body === 'string') {\n const body = JSON.parse(lambdaEvent.body);\n if (body.name && !body.event) {\n lambdaEvent.body = JSON.stringify({\n ...body,\n event: body.name,\n name: undefined,\n });\n }\n }\n\n const context: LambdaContext = {\n awsRequestId: 'test-req',\n } as unknown as LambdaContext;\n\n return source.push(lambdaEvent as unknown as LambdaEvent, context);\n };\n}\n\nexport { createTrigger, trigger };\n","export * as env from './env';\nexport * as step from './step';\nexport { createTrigger } from './trigger';\nexport type { Content, Result } from './trigger';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment for the AWS SQS source.\n *\n * Tests substitute the real SDK via `jest.mock('@aws-sdk/client-sqs')` and\n * `jest.mock('@aws-sdk/client-sns')`, which is the canonical pattern: imports\n * of those modules get replaced module-wide, no env-injection plumbing\n * required at the call site.\n *\n * The `simulation` list documents which SDK identifiers the source touches\n * during a simulated run, used by the simulator to know what to stub.\n */\n\nconst noopFn = (): void => undefined;\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n warn: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noopFn,\n scope: () => noopLogger,\n};\n\nconst createMockElbFn = (): Elb.Fn => {\n const fn: Elb.Fn = () => Promise.resolve({ ok: true });\n return fn;\n};\n\n/**\n * Standard mock environment for the SQS source.\n *\n * AWS SDK constructors are intentionally absent: the canonical pattern is\n * module-level `jest.mock('@aws-sdk/client-sqs')` and -sns, not env-injection.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n\nexport const simulation = ['AWS.SQSClient'];\n","import type { Flow } from '@walkeros/core';\n\n/**\n * SQS source step examples.\n *\n * Each `in` is a partial SQS Message-like (MessageId, Body, optional\n * ReceiptHandle). The trigger synthesizes the missing fields and dispatches\n * through the source's `push()` (the same pipeline the long-poll loop uses).\n * `out` records the terminal state recorded by the trigger as\n * `[method, ...args]` entries.\n */\n\nconst eventPayload = {\n event: 'page view',\n data: { title: 'Documentation', url: 'https://example.com/docs' },\n};\n\nconst orderPayload = {\n event: 'order complete',\n data: { id: 'ORD-500', total: 199.99, currency: 'EUR' },\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view from SQS',\n description:\n 'A standard SQS message body containing a walker elb event payload as JSON.',\n in: {\n MessageId: 'm-1',\n Body: JSON.stringify(eventPayload),\n },\n out: [['message.ack', 'm-1']],\n};\n\nexport const orderComplete: Flow.StepExample = {\n title: 'Order complete from SQS',\n description: 'Order complete event flowing through the long-poll loop.',\n in: {\n MessageId: 'm-2',\n Body: JSON.stringify(orderPayload),\n },\n out: [['message.ack', 'm-2']],\n};\n\nexport const decoderText: Flow.StepExample = {\n title: 'Text decoder',\n description:\n 'When decoder is \"text\", the body string flows under data.payload.',\n in: { MessageId: 'm-3', Body: 'raw text payload' },\n out: [['message.ack', 'm-3']],\n};\n\nexport const malformedJson: Flow.StepExample = {\n title: 'Malformed JSON nacks',\n description:\n 'Default decoder is JSON. A malformed body throws DecoderError; the source nacks (skips DeleteMessage) so the message redelivers.',\n in: { MessageId: 'm-4', Body: '{not json' },\n out: [['message.nack', 'm-4']],\n};\n","import type { Collector, Trigger } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport type { SyntheticMessage, SyntheticPushResult } from '../types';\n\n/**\n * Content shape for the SQS source trigger.\n *\n * The trigger synthesizes a SyntheticMessage from this partial input and\n * dispatches it through the source's `push()` (the same pipeline the\n * long-poll loop uses).\n */\nexport interface Content {\n MessageId: string;\n Body: string;\n ReceiptHandle?: string;\n Attributes?: Record<string, string>;\n MessageAttributes?: Record<\n string,\n { DataType: string; StringValue?: string }\n >;\n}\n\n/**\n * Trigger result: the recorded ack/nack as `[method, MessageId]` entries.\n * Mirrors the destination's `[method, ...args]` recording shape.\n */\nexport type Result = Array<[string, ...unknown[]]>;\n\ninterface SqsSourceLike {\n type: string;\n push: (content?: SyntheticMessage) => Promise<SyntheticPushResult | void>;\n}\n\nfunction isSqsSource(value: unknown): value is SqsSourceLike {\n if (typeof value !== 'object' || value === null) return false;\n const candidate: { type?: unknown; push?: unknown } = value;\n return candidate.type === 'sqs' && typeof candidate.push === 'function';\n}\n\nfunction findSource(collector: Collector.Instance): SqsSourceLike | undefined {\n for (const source of Object.values(collector.sources ?? {})) {\n if (isSqsSource(source)) return source;\n }\n return undefined;\n}\n\n/**\n * SQS source createTrigger.\n *\n * Boots the collector via startFlow, finds the registered SQS source, and\n * invokes its `push()` with a synthesized message. The source dispatches the\n * synthetic message through the same handler the long-poll loop uses,\n * exercising the full decode / forward / ack-nack pipeline without touching\n * real SQS infrastructure.\n */\nexport const createTrigger: Trigger.CreateFn<Content, Result> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<Content, Result> =\n () =>\n async (content: Content): Promise<Result> => {\n if (!flow) {\n const result = await startFlow(config);\n flow = { collector: result.collector, elb: result.elb };\n }\n\n const source = findSource(flow.collector);\n if (!source) {\n throw new Error(\n 'sqs source not registered in collector, ensure it is configured in sources',\n );\n }\n\n const synthetic: SyntheticMessage = {\n MessageId: content.MessageId,\n Body: content.Body,\n ReceiptHandle: content.ReceiptHandle,\n Attributes: content.Attributes,\n MessageAttributes: content.MessageAttributes,\n };\n\n const result = await source.push(synthetic);\n const recorded: Result = [];\n if (result && typeof result === 'object') {\n if (result.acked) recorded.push(['message.ack', content.MessageId]);\n if (result.nacked) recorded.push(['message.nack', content.MessageId]);\n }\n return recorded;\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAAA;AAAA,EAAA;AAAA;;;ACAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAC,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;AASM,IAAM,aAAa,EAAE,MAAM;AAAA,EAChC,EAAE,OAAO;AAAA,EACT,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAClB,EAAE,QAAQ,GAAG;AACf,CAAC;AAMM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,QAAQ,WAAW;AAAA,IACjB;AAAA,EACF,EAAE,SAAS;AAAA,EAEX,SAAS,EAAE,MAAM,UAAU,EAAE,SAAS,sBAAsB,EAAE,SAAS;AAAA,EAEvE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,yBAAyB,EAAE,SAAS;AAAA,EAE1E,aAAa,EACV,QAAQ,EACR,SAAS,oDAAoD,EAC7D,SAAS;AAAA,EAEZ,QAAQ,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,qCAAqC,EAC9C,SAAS;AACd,CAAC;;;AD9CM,IAA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M,QAAO;AACxD,QAAM,YAAgD;AACtD,SAAO,UAAU,SAAS,SAAS,OAAO,UAAU,SAAS;AAC/D;AAEA,SAAS,WAAW,WAA0D;AAC5E,aAAW,UAAU,OAAO,OAAO,UAAU,WAAW,CAAC,CAAC,GAAG;AAC3D,QAAI,YAAY,MAAM,EAAG,QAAO;AAAA,EAClC;AACA,SAAO;AACT;AAWO,IAAMC,iBAAmD,OAC9D,WACG;AACH,MAAI;AAEJ,QAAMC,WACJ,MACA,OAAO,YAAsC;AAC3C,QAAI,CAAC,MAAM;AACT,YAAMC,UAAS,MAAM,GAAU,MAAM;AACrC,aAAO,EAAE,WAAWA,QAAO,WAAW,KAAKA,QAAO,IAAI;AAAA,IACxD;AAEA,UAAM,SAAS,WAAW,KAAK,SAAS;AACxC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,YAA8B;AAAA,MAClC,WAAW,QAAQ;AAAA,MACnB,MAAM,QAAQ;AAAA,MACd,eAAe,QAAQ;AAAA,MACvB,YAAY,QAAQ;AAAA,MACpB,mBAAmB,QAAQ;AAAA,IAC7B;AAEA,UAAM,SAAS,MAAM,OAAO,KAAK,SAAS;AAC1C,UAAM,WAAmB,CAAC;AAC1B,QAAI,UAAU,OAAO,WAAW,UAAU;AACxC,UAAI,OAAO,MAAO,UAAS,KAAK,CAAC,eAAe,QAAQ,SAAS,CAAC;AAClE,UAAI,OAAO,OAAQ,UAAS,KAAK,CAAC,gBAAgB,QAAQ,SAAS,CAAC;AAAA,IACtE;AACA,WAAO;AAAA,EACT;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA,SAAAD;AAAA,EACF;AACF;","names":["settings","z","z","zodToSchema","z","SettingsSchema","z","settings","zodToSchema","SettingsSchema","trigger","k","v","examples_exports","createTrigger","env_exports","step_exports","env_exports","push","noopFn","noopLogger","createMockElbFn","step_exports","createTrigger","trigger","result"]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$meta": {
3
3
  "package": "@walkeros/server-source-aws",
4
- "version": "4.2.0",
4
+ "version": "4.2.1-next-1781538735002",
5
5
  "type": "source",
6
6
  "platform": [
7
7
  "server"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/server-source-aws",
3
3
  "description": "AWS server sources for walkerOS (Lambda, API Gateway, Function URLs)",
4
- "version": "4.2.0",
4
+ "version": "4.2.1-next-1781538735002",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -23,14 +23,14 @@
23
23
  "dependencies": {
24
24
  "@aws-sdk/client-sqs": "^3.952.0",
25
25
  "@aws-sdk/client-sns": "^3.952.0",
26
- "@walkeros/core": "4.2.0"
26
+ "@walkeros/core": "4.2.1-next-1781538735002"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@types/aws-lambda": "^8.10.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/aws-lambda": "^8.10.159",
33
- "@walkeros/collector": "4.2.0"
33
+ "@walkeros/collector": "4.2.1-next-1781538735002"
34
34
  },
35
35
  "repository": {
36
36
  "url": "git+https://github.com/elbwalker/walkerOS.git",